Cleanup: reduce variable scope
This commit is contained in:
@@ -92,9 +92,7 @@ static FontBLF *blf_get(int fontid)
|
||||
|
||||
int BLF_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BLF_MAX_FONT; i++) {
|
||||
for (int i = 0; i < BLF_MAX_FONT; i++) {
|
||||
global_font[i] = NULL;
|
||||
}
|
||||
|
||||
@@ -111,11 +109,8 @@ void BLF_default_dpi(int dpi)
|
||||
|
||||
void BLF_exit(void)
|
||||
{
|
||||
FontBLF *font;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BLF_MAX_FONT; i++) {
|
||||
font = global_font[i];
|
||||
for (int i = 0; i < BLF_MAX_FONT; i++) {
|
||||
FontBLF *font = global_font[i];
|
||||
if (font) {
|
||||
blf_font_free(font);
|
||||
global_font[i] = NULL;
|
||||
@@ -127,11 +122,8 @@ void BLF_exit(void)
|
||||
|
||||
void BLF_cache_clear(void)
|
||||
{
|
||||
FontBLF *font;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BLF_MAX_FONT; i++) {
|
||||
font = global_font[i];
|
||||
for (int i = 0; i < BLF_MAX_FONT; i++) {
|
||||
FontBLF *font = global_font[i];
|
||||
if (font) {
|
||||
blf_glyph_cache_clear(font);
|
||||
blf_kerning_cache_clear(font);
|
||||
@@ -141,11 +133,8 @@ void BLF_cache_clear(void)
|
||||
|
||||
static int blf_search(const char *name)
|
||||
{
|
||||
FontBLF *font;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BLF_MAX_FONT; i++) {
|
||||
font = global_font[i];
|
||||
for (int i = 0; i < BLF_MAX_FONT; i++) {
|
||||
FontBLF *font = global_font[i];
|
||||
if (font && (STREQ(font->name, name))) {
|
||||
return i;
|
||||
}
|
||||
@@ -156,9 +145,7 @@ static int blf_search(const char *name)
|
||||
|
||||
static int blf_search_available(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BLF_MAX_FONT; i++) {
|
||||
for (int i = 0; i < BLF_MAX_FONT; i++) {
|
||||
if (!global_font[i]) {
|
||||
return i;
|
||||
}
|
||||
@@ -192,13 +179,10 @@ bool BLF_has_glyph(int fontid, unsigned int unicode)
|
||||
|
||||
int BLF_load(const char *name)
|
||||
{
|
||||
FontBLF *font;
|
||||
int i;
|
||||
|
||||
/* check if we already load this font. */
|
||||
i = blf_search(name);
|
||||
int i = blf_search(name);
|
||||
if (i >= 0) {
|
||||
font = global_font[i];
|
||||
FontBLF *font = global_font[i];
|
||||
font->reference_count++;
|
||||
return i;
|
||||
}
|
||||
@@ -208,26 +192,22 @@ int BLF_load(const char *name)
|
||||
|
||||
int BLF_load_unique(const char *name)
|
||||
{
|
||||
FontBLF *font;
|
||||
char *filename;
|
||||
int i;
|
||||
|
||||
/* Don't search in the cache!! make a new
|
||||
* object font, this is for keep fonts threads safe.
|
||||
*/
|
||||
i = blf_search_available();
|
||||
int i = blf_search_available();
|
||||
if (i == -1) {
|
||||
printf("Too many fonts!!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
filename = blf_dir_search(name);
|
||||
char *filename = blf_dir_search(name);
|
||||
if (!filename) {
|
||||
printf("Can't find font: %s\n", name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
font = blf_font_new(name, filename);
|
||||
FontBLF *font = blf_font_new(name, filename);
|
||||
MEM_freeN(filename);
|
||||
|
||||
if (!font) {
|
||||
@@ -251,9 +231,7 @@ void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size)
|
||||
|
||||
int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = blf_search(name);
|
||||
int i = blf_search(name);
|
||||
if (i >= 0) {
|
||||
/*font = global_font[i];*/ /*UNUSED*/
|
||||
return i;
|
||||
@@ -263,14 +241,11 @@ int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size)
|
||||
|
||||
int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size)
|
||||
{
|
||||
FontBLF *font;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Don't search in the cache, make a new object font!
|
||||
* this is to keep the font thread safe.
|
||||
*/
|
||||
i = blf_search_available();
|
||||
int i = blf_search_available();
|
||||
if (i == -1) {
|
||||
printf("Too many fonts!!!\n");
|
||||
return -1;
|
||||
@@ -281,7 +256,7 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
|
||||
return -1;
|
||||
}
|
||||
|
||||
font = blf_font_new_from_mem(name, mem, mem_size);
|
||||
FontBLF *font = blf_font_new_from_mem(name, mem, mem_size);
|
||||
if (!font) {
|
||||
printf("Can't load font: %s from memory!!\n", name);
|
||||
return -1;
|
||||
@@ -294,11 +269,8 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
|
||||
|
||||
void BLF_unload(const char *name)
|
||||
{
|
||||
FontBLF *font;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BLF_MAX_FONT; i++) {
|
||||
font = global_font[i];
|
||||
for (int i = 0; i < BLF_MAX_FONT; i++) {
|
||||
FontBLF *font = global_font[i];
|
||||
|
||||
if (font && (STREQ(font->name, name))) {
|
||||
BLI_assert(font->reference_count > 0);
|
||||
|
||||
@@ -115,11 +115,8 @@ char **BLF_dir_get(int *ndir)
|
||||
|
||||
void BLF_dir_free(char **dirs, int count)
|
||||
{
|
||||
char *path;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
path = dirs[i];
|
||||
for (int i = 0; i < count; i++) {
|
||||
char *path = dirs[i];
|
||||
MEM_freeN(path);
|
||||
}
|
||||
MEM_freeN(dirs);
|
||||
|
||||
@@ -316,8 +316,7 @@ static GlyphBLF **blf_font_ensure_ascii_table(FontBLF *font, GlyphCacheBLF *gc)
|
||||
/* build ascii on demand */
|
||||
if (glyph_ascii_table['0'] == NULL) {
|
||||
GlyphBLF *g;
|
||||
unsigned int i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
for (uint i = 0; i < 256; i++) {
|
||||
g = blf_glyph_search(gc, i);
|
||||
if (!g) {
|
||||
FT_UInt glyph_index = FT_Get_Char_Index(font->face, i);
|
||||
|
||||
@@ -205,9 +205,7 @@ void blf_glyph_cache_clear(FontBLF *font)
|
||||
void blf_glyph_cache_free(GlyphCacheBLF *gc)
|
||||
{
|
||||
GlyphBLF *g;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(gc->bucket); i++) {
|
||||
for (uint i = 0; i < ARRAY_SIZE(gc->bucket); i++) {
|
||||
while ((g = BLI_pophead(&gc->bucket[i]))) {
|
||||
blf_glyph_free(g);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ void BLF_thumb_preview(const char *filename,
|
||||
|
||||
FontBLF *font;
|
||||
GlyphCacheBLF *gc;
|
||||
int i;
|
||||
|
||||
/* Create a new blender font obj and fill it with default values */
|
||||
font = blf_font_new("thumb_font", filename);
|
||||
@@ -91,7 +90,7 @@ void BLF_thumb_preview(const char *filename,
|
||||
|
||||
blf_draw_buffer__start(font);
|
||||
|
||||
for (i = 0; i < draw_str_lines; i++) {
|
||||
for (int i = 0; i < draw_str_lines; i++) {
|
||||
const char *draw_str_i18n = i18n_draw_str[i] != NULL ? i18n_draw_str[i] : draw_str[i];
|
||||
const size_t draw_str_i18n_len = strlen(draw_str_i18n);
|
||||
int draw_str_i18n_nbr = 0;
|
||||
|
||||
@@ -72,8 +72,7 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss)
|
||||
}
|
||||
static void _vert_remEdge(CCGVert *v, CCGEdge *e)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < v->numEdges; i++) {
|
||||
for (int i = 0; i < v->numEdges; i++) {
|
||||
if (v->edges[i] == e) {
|
||||
v->edges[i] = v->edges[--v->numEdges];
|
||||
break;
|
||||
@@ -82,8 +81,7 @@ static void _vert_remEdge(CCGVert *v, CCGEdge *e)
|
||||
}
|
||||
static void _vert_remFace(CCGVert *v, CCGFace *f)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < v->numFaces; i++) {
|
||||
for (int i = 0; i < v->numFaces; i++) {
|
||||
if (v->faces[i] == f) {
|
||||
v->faces[i] = v->faces[--v->numFaces];
|
||||
break;
|
||||
@@ -104,8 +102,7 @@ static void _vert_addFace(CCGVert *v, CCGFace *f, CCGSubSurf *ss)
|
||||
}
|
||||
static CCGEdge *_vert_findEdgeTo(const CCGVert *v, const CCGVert *vQ)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < v->numEdges; i++) {
|
||||
for (int i = 0; i < v->numEdges; i++) {
|
||||
CCGEdge *e = v->edges[v->numEdges - 1 - i]; // XXX, note reverse
|
||||
if ((e->v0 == v && e->v1 == vQ) || (e->v1 == v && e->v0 == vQ)) {
|
||||
return e;
|
||||
@@ -155,8 +152,7 @@ static CCGEdge *_edge_new(CCGEdgeHDL eHDL, CCGVert *v0, CCGVert *v1, float creas
|
||||
}
|
||||
static void _edge_remFace(CCGEdge *e, CCGFace *f)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < e->numFaces; i++) {
|
||||
for (int i = 0; i < e->numFaces; i++) {
|
||||
if (e->faces[i] == f) {
|
||||
e->faces[i] = e->faces[--e->numFaces];
|
||||
break;
|
||||
@@ -205,13 +201,12 @@ static CCGFace *_face_new(
|
||||
sizeof(CCGFace) + sizeof(CCGVert *) * numVerts + sizeof(CCGEdge *) * numVerts +
|
||||
ss->meshIFC.vertDataSize * num_face_data + ss->meshIFC.faceUserSize);
|
||||
byte *userData;
|
||||
int i;
|
||||
|
||||
f->numVerts = numVerts;
|
||||
f->fHDL = fHDL;
|
||||
f->flags = 0;
|
||||
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
for (int i = 0; i < numVerts; i++) {
|
||||
FACE_getVerts(f)[i] = verts[i];
|
||||
FACE_getEdges(f)[i] = edges[i];
|
||||
_vert_addFace(verts[i], f, ss);
|
||||
@@ -1418,9 +1413,7 @@ CCGEdge *ccgSubSurf_getFaceEdge(CCGFace *f, int index)
|
||||
}
|
||||
int ccgSubSurf_getFaceEdgeIndex(CCGFace *f, CCGEdge *e)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < f->numVerts; i++) {
|
||||
for (int i = 0; i < f->numVerts; i++) {
|
||||
if (FACE_getEdges(f)[i] == e) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -142,8 +142,7 @@ BLI_INLINE float *ccg_face_getIFNo(
|
||||
|
||||
BLI_INLINE int ccg_face_getVertIndex(CCGFace *f, CCGVert *v)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < f->numVerts; i++) {
|
||||
for (int i = 0; i < f->numVerts; i++) {
|
||||
if (FACE_getVerts(f)[i] == v) {
|
||||
return i;
|
||||
}
|
||||
@@ -153,8 +152,7 @@ BLI_INLINE int ccg_face_getVertIndex(CCGFace *f, CCGVert *v)
|
||||
|
||||
BLI_INLINE int ccg_face_getEdgeIndex(CCGFace *f, CCGEdge *e)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < f->numVerts; i++) {
|
||||
for (int i = 0; i < f->numVerts; i++) {
|
||||
if (FACE_getEdges(f)[i] == e) {
|
||||
return i;
|
||||
}
|
||||
@@ -215,8 +213,7 @@ BLI_INLINE void Normalize(float no[3])
|
||||
|
||||
BLI_INLINE bool VertDataEqual(const float a[], const float b[], const CCGSubSurf *ss)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
for (int i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
if (a[i] != b[i]) {
|
||||
return false;
|
||||
}
|
||||
@@ -231,32 +228,28 @@ BLI_INLINE void VertDataZero(float v[], const CCGSubSurf *ss)
|
||||
|
||||
BLI_INLINE void VertDataCopy(float dst[], const float src[], const CCGSubSurf *ss)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
for (int i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
BLI_INLINE void VertDataAdd(float a[], const float b[], const CCGSubSurf *ss)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
for (int i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
a[i] += b[i];
|
||||
}
|
||||
}
|
||||
|
||||
BLI_INLINE void VertDataSub(float a[], const float b[], const CCGSubSurf *ss)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
for (int i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
a[i] -= b[i];
|
||||
}
|
||||
}
|
||||
|
||||
BLI_INLINE void VertDataMulN(float v[], float f, const CCGSubSurf *ss)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
for (int i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
v[i] *= f;
|
||||
}
|
||||
}
|
||||
@@ -268,8 +261,7 @@ BLI_INLINE void VertDataAvg4(float v[],
|
||||
const float d[],
|
||||
const CCGSubSurf *ss)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
for (int i = 0; i < ss->meshIFC.numLayers; i++) {
|
||||
v[i] = (a[i] + b[i] + c[i] + d[i]) * 0.25f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ static int _edge_isBoundary(const CCGEdge *e)
|
||||
|
||||
static bool _vert_isBoundary(const CCGVert *v)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < v->numEdges; i++) {
|
||||
for (int i = 0; i < v->numEdges; i++) {
|
||||
if (_edge_isBoundary(v->edges[i])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -746,8 +746,6 @@ bool BKE_appdir_program_python_search(char *fullpath,
|
||||
python_ver,
|
||||
basename,
|
||||
};
|
||||
int i;
|
||||
|
||||
bool is_found = false;
|
||||
|
||||
BLI_snprintf(python_ver, sizeof(python_ver), "%s%d.%d", basename, version_major, version_minor);
|
||||
@@ -756,7 +754,7 @@ bool BKE_appdir_program_python_search(char *fullpath,
|
||||
const char *python_bin_dir = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, "bin");
|
||||
if (python_bin_dir) {
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(python_names); i++) {
|
||||
for (int i = 0; i < ARRAY_SIZE(python_names); i++) {
|
||||
BLI_join_dirfile(fullpath, fullpath_len, python_bin_dir, python_names[i]);
|
||||
|
||||
if (
|
||||
@@ -774,7 +772,7 @@ bool BKE_appdir_program_python_search(char *fullpath,
|
||||
}
|
||||
|
||||
if (is_found == false) {
|
||||
for (i = 0; i < ARRAY_SIZE(python_names); i++) {
|
||||
for (int i = 0; i < ARRAY_SIZE(python_names); i++) {
|
||||
if (BLI_path_program_search(fullpath, fullpath_len, python_names[i])) {
|
||||
is_found = true;
|
||||
break;
|
||||
|
||||
@@ -125,7 +125,6 @@ static void splineik_init_tree_from_pchan(Scene *UNUSED(scene),
|
||||
/* perform binding step if required */
|
||||
if ((ikData->flag & CONSTRAINT_SPLINEIK_BOUND) == 0) {
|
||||
float segmentLen = (1.0f / (float)segcount);
|
||||
int i;
|
||||
|
||||
/* setup new empty array for the points list */
|
||||
if (ikData->points) {
|
||||
@@ -140,7 +139,7 @@ static void splineik_init_tree_from_pchan(Scene *UNUSED(scene),
|
||||
/* perform binding of the joints to parametric positions along the curve based
|
||||
* proportion of the total length that each bone occupies
|
||||
*/
|
||||
for (i = 0; i < segcount; i++) {
|
||||
for (int i = 0; i < segcount; i++) {
|
||||
/* 'head' joints, traveling towards the root of the chain
|
||||
* - 2 methods; the one chosen depends on whether we've got usable lengths
|
||||
*/
|
||||
@@ -549,11 +548,9 @@ static void splineik_execute_tree(
|
||||
|
||||
/* for each pose-tree, execute it if it is spline, otherwise just free it */
|
||||
while ((tree = pchan_root->siktree.first) != NULL) {
|
||||
int i;
|
||||
|
||||
/* Firstly, calculate the bone matrix the standard way,
|
||||
* since this is needed for roll control. */
|
||||
for (i = tree->chainlen - 1; i >= 0; i--) {
|
||||
for (int i = tree->chainlen - 1; i >= 0; i--) {
|
||||
BKE_pose_where_is_bone(depsgraph, scene, ob, tree->chain[i], ctime, 1);
|
||||
}
|
||||
|
||||
@@ -565,7 +562,7 @@ static void splineik_execute_tree(
|
||||
* - the chain is traversed in the opposite order to storage order (i.e. parent to children)
|
||||
* so that dependencies are correct
|
||||
*/
|
||||
for (i = tree->chainlen - 1; i >= 0; i--) {
|
||||
for (int i = tree->chainlen - 1; i >= 0; i--) {
|
||||
bPoseChannel *pchan = tree->chain[i];
|
||||
splineik_evaluate_bone(tree, ob, pchan, i, &state);
|
||||
}
|
||||
|
||||
@@ -963,7 +963,6 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(float epsilon,
|
||||
int faces_num_active)
|
||||
{
|
||||
BVHTree *tree = NULL;
|
||||
int i;
|
||||
|
||||
if (faces_num) {
|
||||
if (faces_mask) {
|
||||
@@ -978,7 +977,7 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(float epsilon,
|
||||
tree = BLI_bvhtree_new(faces_num_active, epsilon, tree_type, axis);
|
||||
if (tree) {
|
||||
if (vert && face) {
|
||||
for (i = 0; i < faces_num; i++) {
|
||||
for (int i = 0; i < faces_num; i++) {
|
||||
float co[4][3];
|
||||
if (faces_mask && !BLI_BITMAP_TEST_BOOL(faces_mask, i)) {
|
||||
continue;
|
||||
|
||||
@@ -527,9 +527,8 @@ typedef struct CameraViewFrameData {
|
||||
static void camera_to_frame_view_cb(const float co[3], void *user_data)
|
||||
{
|
||||
CameraViewFrameData *data = (CameraViewFrameData *)user_data;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
|
||||
for (uint i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
|
||||
const float nd = dist_signed_squared_to_plane_v3(co, data->plane_tx[i]);
|
||||
CLAMP_MAX(data->dist_vals_sq[i], nd);
|
||||
}
|
||||
@@ -548,7 +547,6 @@ static void camera_frame_fit_data_init(const Scene *scene,
|
||||
CameraViewFrameData *data)
|
||||
{
|
||||
float camera_rotmat_transposed_inversed[4][4];
|
||||
unsigned int i;
|
||||
|
||||
/* setup parameters */
|
||||
BKE_camera_params_init(params);
|
||||
@@ -585,7 +583,7 @@ static void camera_frame_fit_data_init(const Scene *scene,
|
||||
NULL);
|
||||
|
||||
/* Rotate planes and get normals from them */
|
||||
for (i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
|
||||
for (uint i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
|
||||
mul_m4_v4(camera_rotmat_transposed_inversed, data->plane_tx[i]);
|
||||
normalize_v3_v3(data->normal_tx[i], data->plane_tx[i]);
|
||||
}
|
||||
@@ -606,7 +604,6 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params,
|
||||
float *r_scale)
|
||||
{
|
||||
float plane_tx[CAMERA_VIEWFRAME_NUM_PLANES][4];
|
||||
unsigned int i;
|
||||
|
||||
if (data->tot <= 1) {
|
||||
return false;
|
||||
@@ -620,7 +617,7 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params,
|
||||
float scale_diff;
|
||||
|
||||
/* apply the dist-from-plane's to the transformed plane points */
|
||||
for (i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
|
||||
for (int i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
|
||||
dists[i] = sqrtf_signed(data->dist_vals_sq[i]);
|
||||
}
|
||||
|
||||
@@ -648,7 +645,7 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params,
|
||||
float plane_isect_pt_1[3], plane_isect_pt_2[3];
|
||||
|
||||
/* apply the dist-from-plane's to the transformed plane points */
|
||||
for (i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
|
||||
for (int i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
|
||||
float co[3];
|
||||
mul_v3_v3fl(co, data->normal_tx[i], sqrtf_signed(data->dist_vals_sq[i]));
|
||||
plane_from_point_normal_v3(plane_tx[i], co, data->normal_tx[i]);
|
||||
|
||||
@@ -172,24 +172,18 @@ void cloth_init(ClothModifierData *clmd)
|
||||
|
||||
static BVHTree *bvhtree_build_from_cloth(ClothModifierData *clmd, float epsilon)
|
||||
{
|
||||
unsigned int i;
|
||||
BVHTree *bvhtree;
|
||||
Cloth *cloth;
|
||||
ClothVertex *verts;
|
||||
const MVertTri *vt;
|
||||
|
||||
if (!clmd) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cloth = clmd->clothObject;
|
||||
Cloth *cloth = clmd->clothObject;
|
||||
|
||||
if (!cloth) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
verts = cloth->verts;
|
||||
vt = cloth->tri;
|
||||
ClothVertex *verts = cloth->verts;
|
||||
const MVertTri *vt = cloth->tri;
|
||||
|
||||
/* in the moment, return zero if no faces there */
|
||||
if (!cloth->primitive_num) {
|
||||
@@ -197,11 +191,11 @@ static BVHTree *bvhtree_build_from_cloth(ClothModifierData *clmd, float epsilon)
|
||||
}
|
||||
|
||||
/* create quadtree with k=26 */
|
||||
bvhtree = BLI_bvhtree_new(cloth->primitive_num, epsilon, 4, 26);
|
||||
BVHTree *bvhtree = BLI_bvhtree_new(cloth->primitive_num, epsilon, 4, 26);
|
||||
|
||||
/* fill tree */
|
||||
if (clmd->hairdata == NULL) {
|
||||
for (i = 0; i < cloth->primitive_num; i++, vt++) {
|
||||
for (int i = 0; i < cloth->primitive_num; i++, vt++) {
|
||||
float co[3][3];
|
||||
|
||||
copy_v3_v3(co[0], verts[vt->tri[0]].xold);
|
||||
@@ -214,7 +208,7 @@ static BVHTree *bvhtree_build_from_cloth(ClothModifierData *clmd, float epsilon)
|
||||
else {
|
||||
MEdge *edges = cloth->edges;
|
||||
|
||||
for (i = 0; i < cloth->primitive_num; i++) {
|
||||
for (int i = 0; i < cloth->primitive_num; i++) {
|
||||
float co[2][3];
|
||||
|
||||
copy_v3_v3(co[0], verts[edges[i].v1].xold);
|
||||
@@ -997,8 +991,7 @@ BLI_INLINE void spring_verts_ordered_set(ClothSpring *spring, int v0, int v1)
|
||||
static void cloth_free_edgelist(LinkNodePair *edgelist, unsigned int mvert_num)
|
||||
{
|
||||
if (edgelist) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < mvert_num; i++) {
|
||||
for (uint i = 0; i < mvert_num; i++) {
|
||||
BLI_linklist_free(edgelist[i].list, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,13 +114,11 @@ BVHTree *bvhtree_build_from_mvert(const MVert *mvert,
|
||||
int tri_num,
|
||||
float epsilon)
|
||||
{
|
||||
BVHTree *tree;
|
||||
const MVertTri *vt;
|
||||
int i;
|
||||
|
||||
tree = BLI_bvhtree_new(tri_num, epsilon, 4, 26);
|
||||
BVHTree *tree = BLI_bvhtree_new(tri_num, epsilon, 4, 26);
|
||||
|
||||
/* fill tree */
|
||||
int i;
|
||||
const MVertTri *vt;
|
||||
for (i = 0, vt = tri; i < tri_num; i++, vt++) {
|
||||
float co[3][3];
|
||||
|
||||
@@ -144,8 +142,6 @@ void bvhtree_update_from_mvert(BVHTree *bvhtree,
|
||||
int tri_num,
|
||||
bool moving)
|
||||
{
|
||||
const MVertTri *vt;
|
||||
int i;
|
||||
|
||||
if ((bvhtree == NULL) || (mvert == NULL)) {
|
||||
return;
|
||||
@@ -155,6 +151,8 @@ void bvhtree_update_from_mvert(BVHTree *bvhtree,
|
||||
moving = false;
|
||||
}
|
||||
|
||||
const MVertTri *vt;
|
||||
int i;
|
||||
for (i = 0, vt = tri; i < tri_num; i++, vt++) {
|
||||
float co[3][3];
|
||||
bool ret;
|
||||
|
||||
@@ -347,8 +347,7 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope
|
||||
cuma->curve[1].y = 1;
|
||||
break;
|
||||
case CURVE_PRESET_MID9: {
|
||||
int i;
|
||||
for (i = 0; i < cuma->totpoint; i++) {
|
||||
for (int i = 0; i < cuma->totpoint; i++) {
|
||||
cuma->curve[i].x = i / ((float)cuma->totpoint - 1);
|
||||
cuma->curve[i].y = 0.5;
|
||||
}
|
||||
@@ -421,8 +420,7 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope
|
||||
const int num_points = cuma->totpoint * 2 - 1;
|
||||
CurveMapPoint *new_points = MEM_mallocN(num_points * sizeof(CurveMapPoint),
|
||||
"curve symmetric points");
|
||||
int i;
|
||||
for (i = 0; i < cuma->totpoint; i++) {
|
||||
for (int i = 0; i < cuma->totpoint; i++) {
|
||||
const int src_last_point = cuma->totpoint - i - 1;
|
||||
const int dst_last_point = num_points - i - 1;
|
||||
new_points[i] = cuma->curve[src_last_point];
|
||||
@@ -969,12 +967,9 @@ void BKE_curvemapping_changed_all(CurveMapping *cumap)
|
||||
/* table should be verified */
|
||||
float BKE_curvemap_evaluateF(const CurveMapping *cumap, const CurveMap *cuma, float value)
|
||||
{
|
||||
float fi;
|
||||
int i;
|
||||
|
||||
/* index in table */
|
||||
fi = (value - cuma->mintable) * cuma->range;
|
||||
i = (int)fi;
|
||||
float fi = (value - cuma->mintable) * cuma->range;
|
||||
int i = (int)fi;
|
||||
|
||||
/* fi is table float index and should check against table range i.e. [0.0 CM_TABLE] */
|
||||
if (fi < 0.0f || fi > CM_TABLE) {
|
||||
|
||||
@@ -3811,7 +3811,6 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
|
||||
float newloc[3], newrot[3][3], neweul[3], newsize[3];
|
||||
float dbuf[4], sval[3];
|
||||
float *const dvec = dbuf + 1;
|
||||
int i;
|
||||
|
||||
/* obtain target effect */
|
||||
switch (data->from) {
|
||||
@@ -3854,7 +3853,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
|
||||
|
||||
/* determine where in range current transforms lie */
|
||||
if (data->expo) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (from_max[i] - from_min[i]) {
|
||||
sval[i] = (dvec[i] - from_min[i]) / (from_max[i] - from_min[i]);
|
||||
}
|
||||
@@ -3865,7 +3864,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
|
||||
}
|
||||
else {
|
||||
/* clamp transforms out of range */
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
CLAMP(dvec[i], from_min[i], from_max[i]);
|
||||
if (from_max[i] - from_min[i]) {
|
||||
sval[i] = (dvec[i] - from_min[i]) / (from_max[i] - from_min[i]);
|
||||
@@ -3881,7 +3880,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
|
||||
case TRANS_SCALE:
|
||||
to_min = data->to_min_scale;
|
||||
to_max = data->to_max_scale;
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
newsize[i] = to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i]));
|
||||
}
|
||||
switch (data->mix_mode_scale) {
|
||||
@@ -3897,7 +3896,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
|
||||
case TRANS_ROTATION:
|
||||
to_min = data->to_min_rot;
|
||||
to_max = data->to_max_rot;
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
neweul[i] = to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i]));
|
||||
}
|
||||
switch (data->mix_mode_rot) {
|
||||
@@ -3924,7 +3923,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
|
||||
default:
|
||||
to_min = data->to_min;
|
||||
to_max = data->to_max;
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
newloc[i] = (to_min[i] + (sval[(int)data->map[i]] * (to_max[i] - to_min[i])));
|
||||
}
|
||||
switch (data->mix_mode_loc) {
|
||||
|
||||
@@ -194,30 +194,22 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me,
|
||||
float (*mappedcos)[3],
|
||||
float (*quats)[4])
|
||||
{
|
||||
int i;
|
||||
MVert *mvert;
|
||||
MLoop *mloop;
|
||||
MPoly *mp;
|
||||
|
||||
mvert = me->mvert;
|
||||
for (i = 0; i < me->totvert; i++, mvert++) {
|
||||
MVert *mvert = me->mvert;
|
||||
for (int i = 0; i < me->totvert; i++, mvert++) {
|
||||
mvert->flag &= ~ME_VERT_TMP_TAG;
|
||||
}
|
||||
|
||||
/* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
|
||||
mvert = me->mvert;
|
||||
mp = me->mpoly;
|
||||
mloop = me->mloop;
|
||||
MPoly *mp = me->mpoly;
|
||||
MLoop *mloop = me->mloop;
|
||||
|
||||
for (i = 0; i < me->totpoly; i++, mp++) {
|
||||
MLoop *ml_prev, *ml_curr, *ml_next;
|
||||
int j;
|
||||
for (int i = 0; i < me->totpoly; i++, mp++) {
|
||||
MLoop *ml_next = &mloop[mp->loopstart];
|
||||
MLoop *ml_curr = &ml_next[mp->totloop - 1];
|
||||
MLoop *ml_prev = &ml_next[mp->totloop - 2];
|
||||
|
||||
ml_next = &mloop[mp->loopstart];
|
||||
ml_curr = &ml_next[mp->totloop - 1];
|
||||
ml_prev = &ml_next[mp->totloop - 2];
|
||||
|
||||
for (j = 0; j < mp->totloop; j++) {
|
||||
for (int j = 0; j < mp->totloop; j++) {
|
||||
if ((mvert[ml_curr->v].flag & ME_VERT_TMP_TAG) == 0) {
|
||||
const float *co_prev, *co_curr, *co_next; /* orig */
|
||||
const float *vd_prev, *vd_curr, *vd_next; /* deform */
|
||||
|
||||
@@ -782,11 +782,10 @@ float BKE_nurb_calc_length(const Nurb *nu, int resolution)
|
||||
/* be sure to call makeknots after this */
|
||||
void BKE_nurb_points_add(Nurb *nu, int number)
|
||||
{
|
||||
BPoint *bp;
|
||||
int i;
|
||||
|
||||
nu->bp = MEM_recallocN(nu->bp, (nu->pntsu + number) * sizeof(BPoint));
|
||||
|
||||
BPoint *bp;
|
||||
int i;
|
||||
for (i = 0, bp = &nu->bp[nu->pntsu]; i < number; i++, bp++) {
|
||||
bp->radius = 1.0f;
|
||||
}
|
||||
@@ -1718,12 +1717,10 @@ static void forward_diff_bezier_cotangent(const float p0[3],
|
||||
* they need to be rotated for this,
|
||||
*
|
||||
* This could also be optimized like BKE_curve_forward_diff_bezier */
|
||||
int a;
|
||||
for (a = 0; a <= it; a++) {
|
||||
for (int a = 0; a <= it; a++) {
|
||||
float t = (float)a / (float)it;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
p[i] = (-6.0f * t + 6.0f) * p0[i] + (18.0f * t - 12.0f) * p1[i] +
|
||||
(-18.0f * t + 6.0f) * p2[i] + (6.0f * t) * p3[i];
|
||||
}
|
||||
@@ -4074,17 +4071,14 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag)
|
||||
const float eps = 0.0001f;
|
||||
const float eps_sq = eps * eps;
|
||||
|
||||
BezTriple *bezt2, *bezt1, *bezt0;
|
||||
int i;
|
||||
|
||||
if (nu == NULL || nu->bezt == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
bezt2 = nu->bezt;
|
||||
bezt1 = bezt2 + (nu->pntsu - 1);
|
||||
bezt0 = bezt1 - 1;
|
||||
i = nu->pntsu;
|
||||
BezTriple *bezt2 = nu->bezt;
|
||||
BezTriple *bezt1 = bezt2 + (nu->pntsu - 1);
|
||||
BezTriple *bezt0 = bezt1 - 1;
|
||||
int i = nu->pntsu;
|
||||
|
||||
while (i--) {
|
||||
bool align = false, leftsmall = false, rightsmall = false;
|
||||
@@ -4546,14 +4540,12 @@ void BKE_curve_nurbs_vert_coords_apply_with_mat4(ListBase *lb,
|
||||
const bool constrain_2d)
|
||||
{
|
||||
const float *co = vert_coords[0];
|
||||
Nurb *nu;
|
||||
int i;
|
||||
|
||||
for (nu = lb->first; nu; nu = nu->next) {
|
||||
LISTBASE_FOREACH (Nurb *, nu, lb) {
|
||||
if (nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt = nu->bezt;
|
||||
|
||||
for (i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
for (int i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
mul_v3_m4v3(bezt->vec[0], mat, co);
|
||||
co += 3;
|
||||
mul_v3_m4v3(bezt->vec[1], mat, co);
|
||||
@@ -4565,7 +4557,7 @@ void BKE_curve_nurbs_vert_coords_apply_with_mat4(ListBase *lb,
|
||||
else {
|
||||
BPoint *bp = nu->bp;
|
||||
|
||||
for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
for (int i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
mul_v3_m4v3(bp->vec, mat, co);
|
||||
co += 3;
|
||||
}
|
||||
@@ -4655,14 +4647,11 @@ float (*BKE_curve_nurbs_key_vert_coords_alloc(ListBase *lb, float *key, int *r_v
|
||||
|
||||
void BKE_curve_nurbs_key_vert_tilts_apply(ListBase *lb, const float *key)
|
||||
{
|
||||
Nurb *nu;
|
||||
int i;
|
||||
|
||||
for (nu = lb->first; nu; nu = nu->next) {
|
||||
LISTBASE_FOREACH (Nurb *, nu, lb) {
|
||||
if (nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt = nu->bezt;
|
||||
|
||||
for (i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
for (int i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
bezt->tilt = key[9];
|
||||
bezt->radius = key[10];
|
||||
key += KEYELEM_FLOAT_LEN_BEZTRIPLE;
|
||||
@@ -4671,7 +4660,7 @@ void BKE_curve_nurbs_key_vert_tilts_apply(ListBase *lb, const float *key)
|
||||
else {
|
||||
BPoint *bp = nu->bp;
|
||||
|
||||
for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
for (int i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
bp->tilt = key[3];
|
||||
bp->radius = key[4];
|
||||
key += KEYELEM_FLOAT_LEN_BPOINT;
|
||||
@@ -5197,37 +5186,32 @@ void BKE_curve_translate(Curve *cu, const float offset[3], const bool do_keys)
|
||||
{
|
||||
ListBase *nurb_lb = BKE_curve_nurbs_get(cu);
|
||||
Nurb *nu;
|
||||
int i;
|
||||
|
||||
for (nu = nurb_lb->first; nu; nu = nu->next) {
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
|
||||
LISTBASE_FOREACH (Nurb *, nu, nurb_lb) {
|
||||
if (nu->type == CU_BEZIER) {
|
||||
i = nu->pntsu;
|
||||
for (bezt = nu->bezt; i--; bezt++) {
|
||||
int i = nu->pntsu;
|
||||
for (BezTriple *bezt = nu->bezt; i--; bezt++) {
|
||||
add_v3_v3(bezt->vec[0], offset);
|
||||
add_v3_v3(bezt->vec[1], offset);
|
||||
add_v3_v3(bezt->vec[2], offset);
|
||||
}
|
||||
}
|
||||
else {
|
||||
i = nu->pntsu * nu->pntsv;
|
||||
for (bp = nu->bp; i--; bp++) {
|
||||
int i = nu->pntsu * nu->pntsv;
|
||||
for (BPoint *bp = nu->bp; i--; bp++) {
|
||||
add_v3_v3(bp->vec, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (do_keys && cu->key) {
|
||||
KeyBlock *kb;
|
||||
for (kb = cu->key->block.first; kb; kb = kb->next) {
|
||||
LISTBASE_FOREACH (KeyBlock *, kb, &cu->key->block) {
|
||||
float *fp = kb->data;
|
||||
int n = kb->totelem;
|
||||
|
||||
for (nu = cu->nurb.first; nu; nu = nu->next) {
|
||||
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
|
||||
if (nu->type == CU_BEZIER) {
|
||||
for (i = nu->pntsu; i && (n -= KEYELEM_ELEM_LEN_BEZTRIPLE) >= 0; i--) {
|
||||
for (int i = nu->pntsu; i && (n -= KEYELEM_ELEM_LEN_BEZTRIPLE) >= 0; i--) {
|
||||
add_v3_v3(&fp[0], offset);
|
||||
add_v3_v3(&fp[3], offset);
|
||||
add_v3_v3(&fp[6], offset);
|
||||
@@ -5235,7 +5219,7 @@ void BKE_curve_translate(Curve *cu, const float offset[3], const bool do_keys)
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = nu->pntsu * nu->pntsv; i && (n -= KEYELEM_ELEM_LEN_BPOINT) >= 0; i--) {
|
||||
for (int i = nu->pntsu * nu->pntsv; i && (n -= KEYELEM_ELEM_LEN_BPOINT) >= 0; i--) {
|
||||
add_v3_v3(fp, offset);
|
||||
fp += KEYELEM_FLOAT_LEN_BPOINT;
|
||||
}
|
||||
@@ -5251,17 +5235,14 @@ void BKE_curve_material_index_remove(Curve *cu, int index)
|
||||
|
||||
if (curvetype == OB_FONT) {
|
||||
struct CharInfo *info = cu->strinfo;
|
||||
int i;
|
||||
for (i = cu->len_char32 - 1; i >= 0; i--, info++) {
|
||||
for (int i = cu->len_char32 - 1; i >= 0; i--, info++) {
|
||||
if (info->mat_nr && info->mat_nr >= index) {
|
||||
info->mat_nr--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Nurb *nu;
|
||||
|
||||
for (nu = cu->nurb.first; nu; nu = nu->next) {
|
||||
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
|
||||
if (nu->mat_nr && nu->mat_nr >= index) {
|
||||
nu->mat_nr--;
|
||||
}
|
||||
@@ -5275,17 +5256,14 @@ bool BKE_curve_material_index_used(Curve *cu, int index)
|
||||
|
||||
if (curvetype == OB_FONT) {
|
||||
struct CharInfo *info = cu->strinfo;
|
||||
int i;
|
||||
for (i = cu->len_char32 - 1; i >= 0; i--, info++) {
|
||||
for (int i = cu->len_char32 - 1; i >= 0; i--, info++) {
|
||||
if (info->mat_nr == index) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Nurb *nu;
|
||||
|
||||
for (nu = cu->nurb.first; nu; nu = nu->next) {
|
||||
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
|
||||
if (nu->mat_nr == index) {
|
||||
return true;
|
||||
}
|
||||
@@ -5301,15 +5279,12 @@ void BKE_curve_material_index_clear(Curve *cu)
|
||||
|
||||
if (curvetype == OB_FONT) {
|
||||
struct CharInfo *info = cu->strinfo;
|
||||
int i;
|
||||
for (i = cu->len_char32 - 1; i >= 0; i--, info++) {
|
||||
for (int i = cu->len_char32 - 1; i >= 0; i--, info++) {
|
||||
info->mat_nr = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Nurb *nu;
|
||||
|
||||
for (nu = cu->nurb.first; nu; nu = nu->next) {
|
||||
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
|
||||
nu->mat_nr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user