diff options
Diffstat (limited to 'source/blender')
18 files changed, 931 insertions, 478 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 42b187ec57f..8ce43049265 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1144,7 +1144,8 @@ static void copy_object_pose(Object *obn, const Object *ob, const int flag) { bPoseChannel *chan; - /* note: need to clear obn->pose pointer first, so that BKE_pose_copy_data works (otherwise there's a crash) */ + /* note: need to clear obn->pose pointer first, + * so that BKE_pose_copy_data works (otherwise there's a crash) */ obn->pose = NULL; BKE_pose_copy_data_ex(&obn->pose, ob->pose, flag, true); /* true = copy constraints */ @@ -1626,7 +1627,8 @@ void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob) ob->mat = MEM_dupallocN(target->mat); ob->matbits = MEM_dupallocN(target->matbits); for (i = 0; i < target->totcol; i++) { - /* don't need to run test_object_materials since we know this object is new and not used elsewhere */ + /* don't need to run test_object_materials + * since we know this object is new and not used elsewhere */ id_us_plus((ID *)ob->mat[i]); } } @@ -2788,15 +2790,24 @@ void BKE_scene_foreach_display_point( /* copied from DNA_object_types.h */ typedef struct ObTfmBack { float loc[3], dloc[3], orig[3]; - float size[3], dscale[3]; /* scale and delta scale */ - float rot[3], drot[3]; /* euler rotation */ - float quat[4], dquat[4]; /* quaternion rotation */ - float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */ - float rotAngle, drotAngle; /* axis angle rotation - angle part */ - float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */ - float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */ - float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */ - float imat[4][4]; /* inverse matrix of 'obmat' for during render, temporally: ipokeys of transform */ + /** scale and delta scale. */ + float size[3], dscale[3]; + /** euler rotation. */ + float rot[3], drot[3]; + /** quaternion rotation. */ + float quat[4], dquat[4]; + /** axis angle rotation - axis part. */ + float rotAxis[3], drotAxis[3]; + /** axis angle rotation - angle part. */ + float rotAngle, drotAngle; + /** final worldspace matrix with constraints & animsys applied. */ + float obmat[4][4]; + /** inverse result of parent, so that object doesn't 'stick' to parent. */ + float parentinv[4][4]; + /** inverse result of constraints. doesn't include effect of parent or object local transform. */ + float constinv[4][4]; + /** inverse matrix of 'obmat' for during render, temporally: ipokeys of transform. */ + float imat[4][4]; } ObTfmBack; void *BKE_object_tfm_backup(Object *ob) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 8d09215c564..86d2ceddced 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1688,7 +1688,8 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa /* 4.0 seems to be a pretty good value */ float interaction_radius = fluid->radius * (fluid->flag & SPH_FAC_RADIUS ? 4.0f * pa->size : 1.0f); float h = interaction_radius * sphdata->hfac; - float rest_density = fluid->rest_density * (fluid->flag & SPH_FAC_DENSITY ? 4.77f : 1.f); /* 4.77 is an experimentally determined density factor */ + /* 4.77 is an experimentally determined density factor */ + float rest_density = fluid->rest_density * (fluid->flag & SPH_FAC_DENSITY ? 4.77f : 1.f); float rest_length = fluid->rest_length * (fluid->flag & SPH_FAC_REST_LENGTH ? 2.588f * pa->size : 1.f); float stiffness = fluid->stiffness_k; @@ -2657,12 +2658,18 @@ static int collision_response(ParticleSimulationData *sim, ParticleData *pa, Par ParticleCollisionElement *pce = &col->pce; PartDeflect *pd = col->hit->pd; RNG *rng = sim->rng; - float co[3]; /* point of collision */ - float x = hit->dist/col->original_ray_length; /* location factor of collision between this iteration */ - float f = col->f + x * (1.0f - col->f); /* time factor of collision between timestep */ - float dt1 = (f - col->f) * col->total_time; /* time since previous collision (in seconds) */ - float dt2 = (1.0f - f) * col->total_time; /* time left after collision (in seconds) */ - int through = (BLI_rng_get_float(rng) < pd->pdef_perm) ? 1 : 0; /* did particle pass through the collision surface? */ + /* point of collision */ + float co[3]; + /* location factor of collision between this iteration */ + float x = hit->dist/col->original_ray_length; + /* time factor of collision between timestep */ + float f = col->f + x * (1.0f - col->f); + /* time since previous collision (in seconds) */ + float dt1 = (f - col->f) * col->total_time; + /* time left after collision (in seconds) */ + float dt2 = (1.0f - f) * col->total_time; + /* did particle pass through the collision surface? */ + int through = (BLI_rng_get_float(rng) < pd->pdef_perm) ? 1 : 0; /* calculate exact collision location */ interp_v3_v3v3(co, col->co1, col->co2, x); @@ -2682,10 +2689,14 @@ static int collision_response(ParticleSimulationData *sim, ParticleData *pa, Par } /* figure out velocity and other data after collision */ else { - float v0[3]; /* velocity directly before collision to be modified into velocity directly after collision */ - float v0_nor[3];/* normal component of v0 */ - float v0_tan[3];/* tangential component of v0 */ - float vc_tan[3];/* tangential component of collision surface velocity */ + /* velocity directly before collision to be modified into velocity directly after collision */ + float v0[3]; + /* normal component of v0 */ + float v0_nor[3]; + /* tangential component of v0 */ + float v0_tan[3]; + /* tangential component of collision surface velocity */ + float vc_tan[3]; float v0_dot, vc_dot; float damp = pd->pdef_damp + pd->pdef_rdamp * 2 * (BLI_rng_get_float(rng) - 0.5f); float frict = pd->pdef_frict + pd->pdef_rfrict * 2 * (BLI_rng_get_float(rng) - 0.5f); @@ -2728,7 +2739,8 @@ static int collision_response(ParticleSimulationData *sim, ParticleData *pa, Par madd_v3_v3fl(v1_tan, vr_tan, -0.4); mul_v3_fl(v1_tan, 1.0f/1.4f); /* 1/(1+0.4) */ - /* rolling friction is around 0.01 of sliding friction (could be made a parameter) */ + /* rolling friction is around 0.01 of sliding friction + * (could be made a parameter) */ mul_v3_fl(v1_tan, 1.0f - 0.01f * frict); /* surface_velocity is opposite to cm velocity */ @@ -3185,7 +3197,8 @@ static void do_hair_dynamics(ParticleSimulationData *sim) } } - realloc_roots = false; /* whether hair root info array has to be reallocated */ + /* whether hair root info array has to be reallocated */ + realloc_roots = false; if (psys->hair_in_mesh) { Mesh *mesh = psys->hair_in_mesh; if (totpoint != mesh->totvert || totedge != mesh->totedge) { diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index e4203a01b17..d83de68169e 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -61,27 +61,41 @@ typedef struct BVHTreeOverlap { } BVHTreeOverlap; typedef struct BVHTreeNearest { - int index; /* the index of the nearest found (untouched if none is found within a dist radius from the given coordinates) */ - float co[3]; /* nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */ - float no[3]; /* normal at nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */ - float dist_sq; /* squared distance to search around */ + /** The index of the nearest found + * (untouched if none is found within a dist radius from the given coordinates) */ + int index; + /** Nearest coordinates + * (untouched it none is found within a dist radius from the given coordinates). */ + float co[3]; + /** Normal at nearest coordinates + * (untouched it none is found within a dist radius from the given coordinates). */ + float no[3]; + /** squared distance to search around */ + float dist_sq; int flags; } BVHTreeNearest; typedef struct BVHTreeRay { - float origin[3]; /* ray origin */ - float direction[3]; /* ray direction */ - float radius; /* radius around ray */ + /** ray origin */ + float origin[3]; + /** ray direction */ + float direction[3]; + /** radius around ray */ + float radius; #ifdef USE_KDOPBVH_WATERTIGHT struct IsectRayPrecalc *isect_precalc; #endif } BVHTreeRay; typedef struct BVHTreeRayHit { - int index; /* index of the tree node (untouched if no hit is found) */ - float co[3]; /* coordinates of the hit point */ - float no[3]; /* normal on hit point */ - float dist; /* distance to the hit point */ + /** Index of the tree node (untouched if no hit is found). */ + int index; + /** Coordinates of the hit point. */ + float co[3]; + /** Normal on hit point. */ + float no[3]; + /** Distance to the hit point. */ + float dist; } BVHTreeRayHit; enum { diff --git a/source/blender/blenlib/BLI_voronoi_2d.h b/source/blender/blenlib/BLI_voronoi_2d.h index 8d1ff2d4c2b..7caba2b0692 100644 --- a/source/blender/blenlib/BLI_voronoi_2d.h +++ b/source/blender/blenlib/BLI_voronoi_2d.h @@ -40,18 +40,24 @@ typedef struct VoronoiSite { typedef struct VoronoiEdge { struct VoronoiEdge *next, *prev; - float start[2], end[2]; /* start and end points */ + /* start and end points */ + float start[2], end[2]; /* this fields are used during diagram computation only */ - float direction[2]; /* directional vector, from "start", points to "end", normal of |left, right| */ + /* directional vector, from "start", points to "end", normal of |left, right| */ + float direction[2]; - float left[2]; /* point on Voronoi place on the left side of edge */ - float right[2]; /* point on Voronoi place on the right side of edge */ + /* point on Voronoi place on the left side of edge */ + float left[2]; + /* point on Voronoi place on the right side of edge */ + float right[2]; - float f, g; /* directional coeffitients satisfying equation y = f * x + g (edge lies on this line) */ + /* directional coeffitients satisfying equation y = f * x + g (edge lies on this line) */ + float f, g; - /* some edges consist of two parts, so we add the pointer to another part to connect them at the end of an algorithm */ + /* some edges consist of two parts, + * so we add the pointer to another part to connect them at the end of an algorithm */ struct VoronoiEdge *neighbor; } VoronoiEdge; diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c index 3c399f8fe7d..47bd018736c 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -157,7 +157,8 @@ static void bm_decim_calc_target_co_db( &vquadrics[BM_elem_index_get(e->v2)]); if (BLI_quadric_optimize(&q, optimize_co, OPTIMIZE_EPS)) { - return; /* all is good */ + /* all is good */ + return; } else { optimize_co[0] = 0.5 * ((double)e->v1->co[0] + (double)e->v2->co[0]); @@ -194,9 +195,12 @@ static bool bm_edge_collapse_is_degenerate_flip(BMEdge *e, const float optimize_ float cross_optim[3]; #if 1 - float vec_other[3]; /* line between the two outer verts, re-use for both cross products */ - float vec_exist[3]; /* before collapse */ - float vec_optim[3]; /* after collapse */ + /* line between the two outer verts, re-use for both cross products */ + float vec_other[3]; + /* before collapse */ + float vec_exist[3]; + /* after collapse */ + float vec_optim[3]; sub_v3_v3v3(vec_other, co_prev, co_next); sub_v3_v3v3(vec_exist, co_prev, v->co); @@ -369,7 +373,8 @@ static void bm_decim_build_edge_cost( uint i; BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) { - eheap_table[i] = NULL; /* keep sanity check happy */ + /* keep sanity check happy */ + eheap_table[i] = NULL; bm_decim_build_edge_cost_single(e, vquadrics, vweights, vweight_factor, eheap, eheap_table); } } @@ -722,7 +727,8 @@ static void bm_edge_collapse_loop_customdata( BLI_assert(l_clear->v == v_clear); BLI_assert(l_other->v == v_other); - (void)v_other; /* quiet warnings for release */ + /* quiet warnings for release */ + (void)v_other; /* now we have both corners of the face 'l->f' */ for (side = 0; side < 2; side++) { @@ -1147,7 +1153,8 @@ static bool bm_decim_edge_collapse( int e_clear_other[2]; BMVert *v_other = e->v1; const int v_other_index = BM_elem_index_get(e->v1); - const int v_clear_index = BM_elem_index_get(e->v2); /* the vert is removed so only store the index */ + /* the vert is removed so only store the index */ + const int v_clear_index = BM_elem_index_get(e->v2); float customdata_fac; #ifdef USE_VERT_NORMAL_INTERP @@ -1159,7 +1166,8 @@ static bool bm_decim_edge_collapse( if (optimize_co_calc) { /* disallow collapsing which results in degenerate cases */ if (UNLIKELY(bm_edge_collapse_is_degenerate_topology(e))) { - bm_decim_invalid_edge_cost_single(e, eheap, eheap_table); /* add back with a high cost */ + /* add back with a high cost */ + bm_decim_invalid_edge_cost_single(e, eheap, eheap_table); return false; } @@ -1167,7 +1175,8 @@ static bool bm_decim_edge_collapse( /* check if this would result in an overlapping face */ if (UNLIKELY(bm_edge_collapse_is_degenerate_flip(e, optimize_co))) { - bm_decim_invalid_edge_cost_single(e, eheap, eheap_table); /* add back with a high cost */ + /* add back with a high cost */ + bm_decim_invalid_edge_cost_single(e, eheap, eheap_table); return false; } } @@ -1203,7 +1212,8 @@ static bool bm_decim_edge_collapse( vweights[v_other_index] = v_other_weight; } - e = NULL; /* paranoid safety check */ + /* paranoid safety check */ + e = NULL; copy_v3_v3(v_other->co, optimize_co); @@ -1295,9 +1305,12 @@ void BM_mesh_decimate_collapse( const bool do_triangulate, const int symmetry_axis, const float symmetry_eps) { - Heap *eheap; /* edge heap */ - HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */ - Quadric *vquadrics; /* vert index aligned quadrics */ + /* edge heap */ + Heap *eheap; + /* edge index aligned table pointing to the eheap */ + HeapNode **eheap_table; + /* vert index aligned quadrics */ + Quadric *vquadrics; int tot_edge_orig; int face_tot_target; @@ -1359,7 +1372,8 @@ void BM_mesh_decimate_collapse( // const float value = BLI_heap_node_value(BLI_heap_top(eheap)); BMEdge *e = BLI_heap_pop_min(eheap); float optimize_co[3]; - BLI_assert(BM_elem_index_get(e) < tot_edge_orig); /* handy to detect corruptions elsewhere */ + /* handy to detect corruptions elsewhere */ + BLI_assert(BM_elem_index_get(e) < tot_edge_orig); /* under normal conditions wont be accessed again, * but NULL just incase so we don't use freed node */ @@ -1511,5 +1525,6 @@ invalidate: /* testing only */ // BM_mesh_validate(bm); - (void)tot_edge_orig; /* quiet release build warning */ + /* quiet release build warning */ + (void)tot_edge_orig; } diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index fdfbd4679f3..0acd3e33075 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -1194,7 +1194,8 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float else { // "bleed out" buffer edge mode is turned on do_adjacentBleedBorders(t, rw, limask, lomask, lres, res, rsize); } - isz = rsize[0]; // set up inner edge, outer edge, and gradient buffer sizes after border pass + // set up inner edge, outer edge, and gradient buffer sizes after border pass + isz = rsize[0]; osz = rsize[1]; gsz = rsize[2]; // detect edges in all non-border pixels in the buffer @@ -1207,24 +1208,31 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float else { // "bleed out" buffer edge mode is turned on do_allBleedBorders(t, rw, limask, lomask, lres, res, rsize); } - isz = rsize[0]; // set up inner edge, outer edge, and gradient buffer sizes after border pass + // set up inner edge, outer edge, and gradient buffer sizes after border pass + isz = rsize[0]; osz = rsize[1]; gsz = rsize[2]; // detect edges in all non-border pixels in the buffer do_allEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz); } - isz = rsize[0]; // set edge and gradient buffer sizes once again... - osz = rsize[1]; // the sizes in rsize[] may have been modified - gsz = rsize[2]; // by the do_*EdgeDetection() function. + // set edge and gradient buffer sizes once again... + // the sizes in rsize[] may have been modified + // by the do_*EdgeDetection() function. + isz = rsize[0]; + osz = rsize[1]; + gsz = rsize[2]; - fsz = gsz + isz + osz; // calculate size of pixel index buffer needed - gbuf = (unsigned short *)MEM_callocN(sizeof(unsigned short) * fsz * 2, "DEM"); // allocate edge/gradient pixel index buffer + // calculate size of pixel index buffer needed + fsz = gsz + isz + osz; + // allocate edge/gradient pixel index buffer + gbuf = (unsigned short *)MEM_callocN(sizeof(unsigned short) * fsz * 2, "DEM"); do_createEdgeLocationBuffer(t, rw, lres, res, gbuf, &innerEdgeOffset, &outerEdgeOffset, isz, gsz); do_fillGradientBuffer(rw, res, gbuf, isz, osz, gsz, innerEdgeOffset, outerEdgeOffset); - MEM_freeN(gbuf); // free the gradient index buffer + // free the gradient index buffer + MEM_freeN(gbuf); } } diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 9fc0a304c0b..f7578182c15 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -372,7 +372,8 @@ typedef struct EEVEE_ShadowCube { } EEVEE_ShadowCube; typedef struct EEVEE_ShadowCascade { - float shadowmat[MAX_CASCADE_NUM][4][4]; /* World->Lamp->NDC->Tex : used for sampling the shadow map. */ + /* World->Lamp->NDC->Tex : used for sampling the shadow map. */ + float shadowmat[MAX_CASCADE_NUM][4][4]; float split_start[4]; float split_end[4]; } EEVEE_ShadowCascade; @@ -729,7 +730,8 @@ typedef struct EEVEE_ShadowCubeData { typedef struct EEVEE_ShadowCascadeData { short light_id, shadow_id, cascade_id, layer_id; - float viewprojmat[MAX_CASCADE_NUM][4][4]; /* World->Lamp->NDC : used for rendering the shadow map. */ + /* World->Lamp->NDC : used for rendering the shadow map. */ + float viewprojmat[MAX_CASCADE_NUM][4][4]; float projmat[MAX_CASCADE_NUM][4][4]; float viewmat[4][4], viewinv[4][4]; float radius[MAX_CASCADE_NUM]; diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index a4dbd9a931e..832f755b612 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -188,11 +188,15 @@ typedef struct WORKBENCH_PrivateData { float cached_shadow_direction[3]; float shadow_mat[4][4]; float shadow_inv[4][4]; - float shadow_far_plane[4]; /* Far plane of the view frustum. */ - float shadow_near_corners[4][3]; /* Near plane corners in shadow space. */ - float shadow_near_min[3]; /* min and max of shadow_near_corners. allow fast test */ + /* Far plane of the view frustum. */ + float shadow_far_plane[4]; + /* Near plane corners in shadow space. */ + float shadow_near_corners[4][3]; + /* min and max of shadow_near_corners. allow fast test */ + float shadow_near_min[3]; float shadow_near_max[3]; - float shadow_near_sides[2][4]; /* This is a parallelogram, so only 2 normal and distance to the edges. */ + /* This is a parallelogram, so only 2 normal and distance to the edges. */ + float shadow_near_sides[2][4]; bool shadow_changed; bool is_playback; @@ -243,7 +247,8 @@ typedef struct WORKBENCH_ObjectData { /* Shadow direction in local object space. */ float shadow_dir[3], shadow_depth; - float shadow_min[3], shadow_max[3]; /* Min, max in shadow space */ + /* Min, max in shadow space */ + float shadow_min[3], shadow_max[3]; BoundBox shadow_bbox; bool shadow_bbox_dirty; diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index da24787fc18..0f4fc4832b8 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -147,27 +147,35 @@ void POSE_OT_bone_layers(struct wmOperatorType *ot); typedef struct tPChanFCurveLink { struct tPChanFCurveLink *next, *prev; - struct Object *ob; /* Object this Pose Channel belongs to. */ + /** Object this Pose Channel belongs to. */ + struct Object *ob; - ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */ - struct bPoseChannel *pchan; /* Pose Channel which data is attached to */ + /** F-Curves for this PoseChannel (wrapped with LinkData) */ + ListBase fcurves; + /** Pose Channel which data is attached to */ + struct bPoseChannel *pchan; - char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */ + /** RNA Path to this Pose Channel (needs to be freed when we're done) */ + char *pchan_path; - float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */ + /** transform values at start of operator (to be restored before each modal step) */ + float oldloc[3]; float oldrot[3]; float oldscale[3]; float oldquat[4]; float oldangle; float oldaxis[3]; - float roll1, roll2; /* old bbone values (to be restored along with the transform properties) */ - float curveInX, curveInY; /* (NOTE: we haven't renamed these this time, as their names are already long enough) */ + /** old bbone values (to be restored along with the transform properties) */ + float roll1, roll2; + /** (NOTE: we haven't renamed these this time, as their names are already long enough) */ + float curveInX, curveInY; float curveOutX, curveOutY; float ease1, ease2; float scaleIn, scaleOut; - struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */ + /** copy of custom properties at start of operator (to be restored before each modal step) */ + struct IDProperty *oldprops; } tPChanFCurveLink; /* ----------- */ diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 4b069deefa3..4014d7e9728 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -926,7 +926,8 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op) bArmature *arm = armature_layers_get_data(&ob); PointerRNA ptr; int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16; - bool layers[32] = {false}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32] = {false}; int i; /* sanity checking */ @@ -978,7 +979,8 @@ static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *ev Object *ob = CTX_data_active_object(C); bArmature *arm = armature_layers_get_data(&ob); PointerRNA ptr; - bool layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32]; /* sanity checking */ if (arm == NULL) @@ -999,7 +1001,8 @@ static int armature_layers_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); bArmature *arm = armature_layers_get_data(&ob); PointerRNA ptr; - bool layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32]; if (arm == NULL) { return OPERATOR_CANCELLED; @@ -1043,7 +1046,8 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot) /* Present a popup to get the layers that should be used */ static int pose_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - bool layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32] = {0}; /* get layers that are active already */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) @@ -1068,7 +1072,8 @@ static int pose_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *e static int pose_bone_layers_exec(bContext *C, wmOperator *op) { PointerRNA ptr; - bool layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32]; /* get the values set in the operator properties */ RNA_boolean_get_array(op->ptr, "layers", layers); @@ -1117,7 +1122,8 @@ void POSE_OT_bone_layers(wmOperatorType *ot) /* Present a popup to get the layers that should be used */ static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - bool layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32] = {0}; /* get layers that are active already */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -1145,7 +1151,8 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_edit_object(C); PointerRNA ptr; - bool layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32]; /* get the values set in the operator properties */ RNA_boolean_get_array(op->ptr, "layers", layers); diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 14706f89607..c8ce0774208 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -825,30 +825,49 @@ void POSELIB_OT_pose_move(wmOperatorType *ot) /* Simple struct for storing settings/data for use during PoseLib preview */ typedef struct tPoseLib_PreviewData { - ListBase backups; /* tPoseLib_Backup structs for restoring poses */ - ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */ - - Scene *scene; /* active scene */ - ScrArea *sa; /* active area */ - - PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */ - Object *ob; /* object to work on */ - bArmature *arm; /* object's armature data */ - bPose *pose; /* object's pose */ - bAction *act; /* poselib to use */ - TimeMarker *marker; /* 'active' pose */ - - int totcount; /* total number of elements to work on */ - - short state; /* state of main loop */ - short redraw; /* redraw/update settings during main loop */ - short flag; /* flags for various settings */ + /** tPoseLib_Backup structs for restoring poses. */ + ListBase backups; + /** LinkData structs storing list of poses which match the current search-string. */ + ListBase searchp; + + /** active scene. */ + Scene *scene; + /** active area. */ + ScrArea *sa; - short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */ - char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */ - char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */ + /** RNA-Pointer to Object 'ob' .*/ + PointerRNA rna_ptr; + /** object to work on. */ + Object *ob; + /** object's armature data. */ + bArmature *arm; + /** object's pose. */ + bPose *pose; + /** poselib to use. */ + bAction *act; + /** 'active' pose. */ + TimeMarker *marker; - char headerstr[UI_MAX_DRAW_STR]; /* Info-text to print in header */ + /** total number of elements to work on. */ + int totcount; + + /** state of main loop. */ + short state; + /** redraw/update settings during main loop. */ + short redraw; + /** flags for various settings. */ + short flag; + + /** position of cursor in searchstr (cursor occurs before the item at the nominated index) */ + short search_cursor; + /** (Part of) Name to search for to filter poses that get shown. */ + char searchstr[64]; + /** Previously set searchstr (from last loop run), + * so that we can detected when to rebuild searchp. */ + char searchold[64]; + + /** Info-text to print in header. */ + char headerstr[UI_MAX_DRAW_STR]; } tPoseLib_PreviewData; /* defines for tPoseLib_PreviewData->state values */ diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index b6f81c81823..c6f88287e3e 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -116,56 +116,84 @@ typedef enum eGPencil_PaintFlags { */ typedef struct tGPsdata { Main *bmain; - Scene *scene; /* current scene from context */ + /** current scene from context. */ + Scene *scene; struct Depsgraph *depsgraph; - wmWindow *win; /* window where painting originated */ - ScrArea *sa; /* area where painting originated */ - ARegion *ar; /* region where painting originated */ - View2D *v2d; /* needed for GP_STROKE_2DSPACE */ - rctf *subrect; /* for using the camera rect within the 3d view */ + /** window where painting originated. */ + wmWindow *win; + /** area where painting originated. */ + ScrArea *sa; + /** region where painting originated. */ + ARegion *ar; + /** needed for GP_STROKE_2DSPACE. */ + View2D *v2d; + /** for using the camera rect within the 3d view. */ + rctf *subrect; rctf subrect_data; - GP_SpaceConversion gsc; /* settings to pass to gp_points_to_xy() */ - - PointerRNA ownerPtr; /* pointer to owner of gp-datablock */ - bGPdata *gpd; /* gp-datablock layer comes from */ - bGPDlayer *gpl; /* layer we're working on */ - bGPDframe *gpf; /* frame we're working on */ - - char *align_flag; /* projection-mode flags (toolsettings - eGPencil_Placement_Flags) */ - - eGPencil_PaintStatus status; /* current status of painting */ - eGPencil_PaintModes paintmode; /* mode for painting */ - eGPencil_PaintFlags flags; /* flags that can get set during runtime (eGPencil_PaintFlags) */ - - short radius; /* radius of influence for eraser */ - - float mval[2]; /* current mouse-position */ - float mvalo[2]; /* previous recorded mouse-position */ - - float pressure; /* current stylus pressure */ - float opressure; /* previous stylus pressure */ + /** settings to pass to gp_points_to_xy(). */ + GP_SpaceConversion gsc; + + /** pointer to owner of gp-datablock. */ + PointerRNA ownerPtr; + /** gp-datablock layer comes from. */ + bGPdata *gpd; + /** layer we're working on. */ + bGPDlayer *gpl; + /** frame we're working on. */ + bGPDframe *gpf; + + /** projection-mode flags (toolsettings - eGPencil_Placement_Flags) */ + char *align_flag; + + /** current status of painting. */ + eGPencil_PaintStatus status; + /** mode for painting. */ + eGPencil_PaintModes paintmode; + /** flags that can get set during runtime (eGPencil_PaintFlags) */ + eGPencil_PaintFlags flags; + + /** radius of influence for eraser. */ + short radius; + + /** current mouse-position. */ + float mval[2]; + /** previous recorded mouse-position. */ + float mvalo[2]; + + /** current stylus pressure. */ + float pressure; + /** previous stylus pressure. */ + float opressure; /* These need to be doubles, as (at least under unix) they are in seconds since epoch, * float (and its 7 digits precision) is definitively not enough here! * double, with its 15 digits precision, ensures us millisecond precision for a few centuries at least. */ - double inittime; /* Used when converting to path */ - double curtime; /* Used when converting to path */ - double ocurtime; /* Used when converting to path */ - - float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space - * to region space */ + /** Used when converting to path. */ + double inittime; + /** Used when converting to path. */ + double curtime; + /** Used when converting to path. */ + double ocurtime; + + /** Inverted transformation matrix applying when converting coords from screen-space + * to region space. */ + float imat[4][4]; float mat[4][4]; - float custom_color[4]; /* custom color - hack for enforcing a particular color for track/mask editing */ + /** custom color - hack for enforcing a particular color for track/mask editing. */ + float custom_color[4]; - void *erasercursor; /* radial cursor data for drawing eraser */ + /** radial cursor data for drawing eraser. */ + void *erasercursor; - short straight[2]; /* 1: line horizontal, 2: line vertical, other: not defined, second element position */ + /** 1: line horizontal, 2: line vertical, other: not defined, second element position. */ + short straight[2]; - short keymodifier; /* key used for invoking the operator */ + /** key used for invoking the operator. */ + short keymodifier; } tGPsdata; /* ------ */ @@ -348,7 +376,8 @@ static short gp_stroke_addpoint( /* store settings */ copy_v2_v2(&pt->x, mval); - pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ + /* T44932 - Pressure vals are unreliable, so ignore for now */ + pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -363,7 +392,8 @@ static short gp_stroke_addpoint( /* store settings */ copy_v2_v2(&pt->x, mval); - pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ + /* T44932 - Pressure vals are unreliable, so ignore for now */ + pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -385,7 +415,8 @@ static short gp_stroke_addpoint( /* store settings */ copy_v2_v2(&pt->x, mval); pt->pressure = pressure; - pt->strength = 1.0f; /* unused for annotations, but initialise for easier conversions to GP Object */ + /* unused for annotations, but initialise for easier conversions to GP Object */ + pt->strength = 1.0f; /* point time */ pt->time = (float)(curtime - p->inittime); @@ -405,7 +436,8 @@ static short gp_stroke_addpoint( /* store settings */ copy_v2_v2(&pt->x, mval); - pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ + /* T44932 - Pressure vals are unreliable, so ignore for now */ + pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -1297,7 +1329,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(p->scene, depsgraph, p->ar, v3d, rv3d, &p->subrect_data, true); /* no shift */ + /* no shift */ + ED_view3d_calc_camera_border(p->scene, depsgraph, p->ar, v3d, rv3d, &p->subrect_data, true); p->subrect = &p->subrect_data; } } @@ -1689,7 +1722,8 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, Depsg int tablet = 0; /* convert from window-space to area-space mouse coordinates - * NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... + * NOTE: float to ints conversions, + * +1 factor is probably used to ensure a bit more accurate rounding... */ p->mval[0] = event->mval[0] + 1; p->mval[1] = event->mval[1] + 1; @@ -1789,7 +1823,8 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, Depsg gpencil_draw_apply(op, p, depsgraph); /* force refresh */ - ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */ + /* just active area for now, since doing whole screen is too slow */ + ED_region_tag_redraw(p->ar); } /* ------------------------------- */ @@ -2006,7 +2041,8 @@ static void gpencil_stroke_end(wmOperator *op) static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) { tGPsdata *p = op->customdata; - int estate = OPERATOR_PASS_THROUGH; /* default exit state - pass through to support MMB view nav, etc. */ + /* default exit state - pass through to support MMB view nav, etc. */ + int estate = OPERATOR_PASS_THROUGH; /* if (event->type == NDOF_MOTION) * return OPERATOR_PASS_THROUGH; @@ -2249,7 +2285,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* force refresh */ - ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */ + /* just active area for now, since doing whole screen is too slow */ + ED_region_tag_redraw(p->ar); /* event handled, so just tag as running modal */ estate = OPERATOR_RUNNING_MODAL; @@ -2269,7 +2306,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) else { /* update status indicators - cursor, header, etc. */ gpencil_draw_status_indicators(C, p); - gpencil_draw_cursor_set(p); /* cursor may have changed outside our control - T44084 */ + /* cursor may have changed outside our control - T44084 */ + gpencil_draw_cursor_set(p); } /* process last operations before exiting */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 204d6fe267a..6543a65f67f 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -128,70 +128,107 @@ typedef enum eGPencil_PaintFlags { typedef struct tGPsdata { bContext *C; - Main *bmain; /* main database pointer */ - Scene *scene; /* current scene from context */ + /** main database pointer. */ + Main *bmain; + /** current scene from context. */ + Scene *scene; struct Depsgraph *depsgraph; - Object *ob; /* current object */ - wmWindow *win; /* window where painting originated */ - ScrArea *sa; /* area where painting originated */ - ARegion *ar; /* region where painting originated */ - View2D *v2d; /* needed for GP_STROKE_2DSPACE */ - rctf *subrect; /* for using the camera rect within the 3d view */ + /** current object. */ + Object *ob; + /** window where painting originated. */ + wmWindow *win; + /** area where painting originated. */ + ScrArea *sa; + /** region where painting originated. */ + ARegion *ar; + /** needed for GP_STROKE_2DSPACE. */ + View2D *v2d; + /** for using the camera rect within the 3d view. */ + rctf *subrect; rctf subrect_data; - GP_SpaceConversion gsc; /* settings to pass to gp_points_to_xy() */ + /** settings to pass to gp_points_to_xy(). */ + GP_SpaceConversion gsc; - PointerRNA ownerPtr; /* pointer to owner of gp-datablock */ - bGPdata *gpd; /* gp-datablock layer comes from */ - bGPDlayer *gpl; /* layer we're working on */ - bGPDframe *gpf; /* frame we're working on */ + /** pointer to owner of gp-datablock. */ + PointerRNA ownerPtr; + /** gp-datablock layer comes from. */ + bGPdata *gpd; + /** layer we're working on. */ + bGPDlayer *gpl; + /** frame we're working on. */ + bGPDframe *gpf; - char *align_flag; /* projection-mode flags (toolsettings - eGPencil_Placement_Flags) */ + /** projection-mode flags (toolsettings - eGPencil_Placement_Flags) */ + char *align_flag; - eGPencil_PaintStatus status; /* current status of painting */ - eGPencil_PaintModes paintmode; /* mode for painting */ - eGPencil_PaintFlags flags; /* flags that can get set during runtime (eGPencil_PaintFlags) */ + /** current status of painting. */ + eGPencil_PaintStatus status; + /** mode for painting. */ + eGPencil_PaintModes paintmode; + /** flags that can get set during runtime (eGPencil_PaintFlags) */ + eGPencil_PaintFlags flags; - short radius; /* radius of influence for eraser */ + /** radius of influence for eraser. */ + short radius; - float mval[2]; /* current mouse-position */ - float mvalo[2]; /* previous recorded mouse-position */ + /** current mouse-position. */ + float mval[2]; + /** previous recorded mouse-position. */ + float mvalo[2]; - float pressure; /* current stylus pressure */ - float opressure; /* previous stylus pressure */ + /** current stylus pressure. */ + float pressure; + /** previous stylus pressure. */ + float opressure; /* These need to be doubles, as (at least under unix) they are in seconds since epoch, * float (and its 7 digits precision) is definitively not enough here! * double, with its 15 digits precision, ensures us millisecond precision for a few centuries at least. */ - double inittime; /* Used when converting to path */ - double curtime; /* Used when converting to path */ - double ocurtime; /* Used when converting to path */ - - float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space - * to region space */ + /** Used when converting to path. */ + double inittime; + /** Used when converting to path. */ + double curtime; + /** Used when converting to path. */ + double ocurtime; + + /** Inverted transformation matrix applying when converting coords from screen-space + * to region space. */ + float imat[4][4]; float mat[4][4]; - float custom_color[4]; /* custom color - hack for enforcing a particular color for track/mask editing */ + /** custom color - hack for enforcing a particular color for track/mask editing. */ + float custom_color[4]; - void *erasercursor; /* radial cursor data for drawing eraser */ + /** radial cursor data for drawing eraser. */ + void *erasercursor; /* mat settings are only used for 3D view */ - Material *material; /* current material */ - - Brush *brush; /* current drawing brush */ - Brush *eraser; /* default eraser brush */ - short straight[2]; /* 1: line horizontal, 2: line vertical, other: not defined, second element position */ - int lock_axis; /* lock drawing to one axis */ - bool disable_fill; /* the stroke is no fill mode */ + /** current material. */ + Material *material; + + /** current drawing brush. */ + Brush *brush; + /** default eraser brush. */ + Brush *eraser; + /** 1: line horizontal, 2: line vertical, other: not defined, second element position. */ + short straight[2]; + /** lock drawing to one axis. */ + int lock_axis; + /** the stroke is no fill mode. */ + bool disable_fill; RNG *rng; - short keymodifier; /* key used for invoking the operator */ - short shift; /* shift modifier flag */ + /** key used for invoking the operator. */ + short keymodifier; + /** shift modifier flag. */ + short shift; - float totpixlen; /* size in pixels for uv calculation */ + /** size in pixels for uv calculation. */ + float totpixlen; ReportList *reports; } tGPsdata; @@ -430,7 +467,8 @@ static void gp_brush_jitter( float curvef = curvemapping_evaluateF(brush->gpencil_settings->curve_jitter, 0, pressure); tmp_pressure = curvef * brush->gpencil_settings->draw_sensitivity; } - const float exfactor = (brush->gpencil_settings->draw_jitter + 2.0f) * (brush->gpencil_settings->draw_jitter + 2.0f); /* exponential value */ + /* exponential value */ + const float exfactor = (brush->gpencil_settings->draw_jitter + 2.0f) * (brush->gpencil_settings->draw_jitter + 2.0f); const float fac = BLI_rng_get_float(rng) * exfactor * tmp_pressure; /* Jitter is applied perpendicular to the mouse movement vector (2D space) */ float mvec[2], svec[2]; @@ -468,8 +506,10 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const floa float fac; float mpressure; - float angle = brush->gpencil_settings->draw_angle; /* default angle of brush in radians */; - float v0[2] = { cos(angle), sin(angle) }; /* angle vector of the brush with full thickness */ + /* default angle of brush in radians */; + float angle = brush->gpencil_settings->draw_angle; + /* angle vector of the brush with full thickness */ + float v0[2] = { cos(angle), sin(angle) }; /* Apply to first point (only if there are 2 points because before no data to do it ) */ if (gpd->runtime.sbuffer_size == 1) { @@ -582,7 +622,8 @@ static short gp_stroke_addpoint( /* store settings */ copy_v2_v2(&pt->x, mval); - pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ + /* T44932 - Pressure vals are unreliable, so ignore for now */ + pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -597,7 +638,8 @@ static short gp_stroke_addpoint( /* store settings */ copy_v2_v2(&pt->x, mval); - pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ + /* T44932 - Pressure vals are unreliable, so ignore for now */ + pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -754,7 +796,8 @@ static short gp_stroke_addpoint( /* store settings */ copy_v2_v2(&pt->x, mval); - pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ + /* T44932 - Pressure vals are unreliable, so ignore for now */ + pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); @@ -2121,7 +2164,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(p->scene, depsgraph, p->ar, v3d, rv3d, &p->subrect_data, true); /* no shift */ + /* no shift */ + ED_view3d_calc_camera_border(p->scene, depsgraph, p->ar, v3d, rv3d, &p->subrect_data, true); p->subrect = &p->subrect_data; } } @@ -2979,7 +3023,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) { tGPsdata *p = op->customdata; ToolSettings *ts = CTX_data_tool_settings(C); - int estate = OPERATOR_PASS_THROUGH; /* default exit state - pass through to support MMB view nav, etc. */ + /* default exit state - pass through to support MMB view nav, etc. */ + int estate = OPERATOR_PASS_THROUGH; /* if (event->type == NDOF_MOTION) * return OPERATOR_PASS_THROUGH; @@ -3254,7 +3299,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* force refresh */ - ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */ + /* just active area for now, since doing whole screen is too slow */ + ED_region_tag_redraw(p->ar); /* event handled, so just tag as running modal */ estate = OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index e366246efbc..1285616e6a2 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -188,17 +188,20 @@ BLI_INLINE unsigned char f_to_char(const float val) /* to avoid locking in tile initialization */ #define TILE_PENDING POINTER_FROM_INT(-1) -/* This is mainly a convenience struct used so we can keep an array of images we use - +/** This is mainly a convenience struct used so we can keep an array of images we use - * their imbufs, etc, in 1 array, When using threads this array is copied for each thread * because 'partRedrawRect' and 'touch' values would not be thread safe */ typedef struct ProjPaintImage { Image *ima; ImBuf *ibuf; ImagePaintPartialRedraw *partRedrawRect; - volatile void **undoRect; /* only used to build undo tiles during painting */ - unsigned short **maskRect; /* the mask accumulation must happen on canvas, not on space screen bucket. - * Here we store the mask rectangle */ - bool **valid; /* store flag to enforce validation of undo rectangle */ + /** Only used to build undo tiles during painting. */ + volatile void **undoRect; + /** The mask accumulation must happen on canvas, not on space screen bucket. + * Here we store the mask rectangle. */ + unsigned short **maskRect; + /** Store flag to enforce validation of undo rectangle. */ + bool **valid; bool touch; } ProjPaintImage; @@ -232,7 +235,8 @@ typedef struct ProjPaintState { ARegion *ar; Depsgraph *depsgraph; Scene *scene; - int source; /* PROJ_SRC_**** */ + /* PROJ_SRC_**** */ + int source; /* the paint color. It can change depending of inverted mode or not */ float paint_color[3]; @@ -255,25 +259,37 @@ typedef struct ProjPaintState { float stencil_value; /* projection painting only */ - MemArena *arena_mt[BLENDER_MAX_THREADS]; /* for multithreading, the first item is sometimes used for non threaded cases too */ - LinkNode **bucketRect; /* screen sized 2D array, each pixel has a linked list of ProjPixel's */ - LinkNode **bucketFaces; /* bucketRect aligned array linkList of faces overlapping each bucket */ - unsigned char *bucketFlags; /* store if the bucks have been initialized */ - - char *vertFlags; /* store options per vert, now only store if the vert is pointing away from the view */ - int buckets_x; /* The size of the bucket grid, the grid span's screenMin/screenMax so you can paint outsize the screen or with 2 brushes at once */ + /** for multithreading, the first item is sometimes used for non threaded cases too. */ + MemArena *arena_mt[BLENDER_MAX_THREADS]; + /** screen sized 2D array, each pixel has a linked list of ProjPixel's */ + LinkNode **bucketRect; + /** bucketRect aligned array linkList of faces overlapping each bucket. */ + LinkNode **bucketFaces; + /** store if the bucks have been initialized. */ + unsigned char *bucketFlags; + + /** store options per vert, now only store if the vert is pointing away from the view. */ + char *vertFlags; + /** The size of the bucket grid, the grid span's screenMin/screenMax so you can paint outsize the screen or with 2 brushes at once. */ + int buckets_x; int buckets_y; - int pixel_sizeof; /* result of project_paint_pixel_sizeof(), constant per stroke */ + /** result of project_paint_pixel_sizeof(), constant per stroke. */ + int pixel_sizeof; - int image_tot; /* size of projectImages array */ + /** size of projectImages array. */ + int image_tot; - float (*screenCoords)[4]; /* verts projected into floating point screen space */ - float screenMin[2]; /* 2D bounds for mesh verts on the screen's plane (screenspace) */ + /** verts projected into floating point screen space. */ + float (*screenCoords)[4]; + /** 2D bounds for mesh verts on the screen's plane (screenspace). */ + float screenMin[2]; float screenMax[2]; - float screen_width; /* Calculated from screenMin & screenMax */ + /** Calculated from screenMin & screenMax. */ + float screen_width; float screen_height; - int winx, winy; /* from the carea or from the projection render */ + /** from the carea or from the projection render. */ + int winx, winy; /* options for projection painting */ bool do_layer_clone; @@ -282,32 +298,49 @@ typedef struct ProjPaintState { bool do_stencil_brush; bool do_material_slots; - bool do_occlude; /* Use raytraced occlusion? - ortherwise will paint right through to the back*/ - bool do_backfacecull; /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */ - bool do_mask_normal; /* mask out pixels based on their normals */ - bool do_mask_cavity; /* mask out pixels based on cavity */ - float normal_angle; /* what angle to mask at */ - float normal_angle__cos; /* cos(normal_angle), faster to compare */ + /** Use raytraced occlusion? - ortherwise will paint right through to the back. */ + bool do_occlude; + /** ignore faces with normals pointing away, + * skips a lot of raycasts if your normals are correctly flipped. */ + bool do_backfacecull; + /** mask out pixels based on their normals. */ + bool do_mask_normal; + /** mask out pixels based on cavity. */ + bool do_mask_cavity; + /** what angle to mask at. */ + float normal_angle; + /** cos(normal_angle), faster to compare. */ + float normal_angle__cos; float normal_angle_inner; float normal_angle_inner__cos; - float normal_angle_range; /* difference between normal_angle and normal_angle_inner, for easy access */ + /** difference between normal_angle and normal_angle_inner, for easy access. */ + float normal_angle_range; - bool do_face_sel; /* quick access to (me->editflag & ME_EDIT_PAINT_FACE_SEL) */ + /** quick access to (me->editflag & ME_EDIT_PAINT_FACE_SEL) */ + bool do_face_sel; bool is_ortho; - bool is_flip_object; /* the object is negative scaled */ - bool do_masking; /* use masking during painting. Some operations such as airbrush may disable */ - bool is_texbrush; /* only to avoid running */ - bool is_maskbrush; /* mask brush is applied before masking */ + /** the object is negative scaled. */ + bool is_flip_object; + /** use masking during painting. Some operations such as airbrush may disable. */ + bool do_masking; + /** only to avoid running. */ + bool is_texbrush; + /** mask brush is applied before masking. */ + bool is_maskbrush; #ifndef PROJ_DEBUG_NOSEAMBLEED float seam_bleed_px; #endif /* clone vars */ float cloneOffset[2]; - float projectMat[4][4]; /* Projection matrix, use for getting screen coords */ - float projectMatInv[4][4]; /* inverse of projectMat */ - float viewDir[3]; /* View vector, use for do_backfacecull and for ray casting with an ortho viewport */ - float viewPos[3]; /* View location in object relative 3D space, so can compare to verts */ + /** Projection matrix, use for getting screen coords. */ + float projectMat[4][4]; + /** inverse of projectMat. */ + float projectMatInv[4][4]; + /** View vector, use for do_backfacecull and for ray casting with an ortho viewport. */ + float viewDir[3]; + /** View location in object relative 3D space, so can compare to verts. */ + float viewPos[3]; float clipsta, clipend; /* reproject vars */ @@ -320,7 +353,8 @@ typedef struct ProjPaintState { int thread_tot; int bucketMin[2]; int bucketMax[2]; - int context_bucket_x, context_bucket_y; /* must lock threads while accessing these */ + /** must lock threads while accessing these. */ + int context_bucket_x, context_bucket_y; struct CurveMapping *cavity_curve; BlurKernel *blurkernel; @@ -343,13 +377,19 @@ typedef struct ProjPaintState { bool is_shared_user; ProjPaintImage *projImages; - float *cavities; /* cavity amount for vertices */ + /** cavity amount for vertices. */ + float *cavities; #ifndef PROJ_DEBUG_NOSEAMBLEED - char *faceSeamFlags; /* store info about faces, if they are initialized etc*/ - char *faceWindingFlags; /* save the winding of the face in uv space, helps as an extra validation step for seam detection */ - float (*faceSeamUVs)[3][2]; /* expanded UVs for faces to use as seams */ - LinkNode **vertFaces; /* Only needed for when seam_bleed_px is enabled, use to find UV seams */ + /** store info about faces, if they are initialized etc*/ + char *faceSeamFlags; + /** save the winding of the face in uv space, + * helps as an extra validation step for seam detection. */ + char *faceWindingFlags; + /** expanded UVs for faces to use as seams. */ + float (*faceSeamUVs)[3][2]; + /** Only needed for when seam_bleed_px is enabled, use to find UV seams. */ + LinkNode **vertFaces; #endif SpinLock *tile_lock; @@ -375,7 +415,8 @@ typedef struct ProjPaintState { * so a loop indirection is needed as well. */ const MLoopUV **poly_to_loop_uv; - const MLoopUV **poly_to_loop_uv_clone; /* other UV map, use for cloning between layers */ + /** other UV map, use for cloning between layers. */ + const MLoopUV **poly_to_loop_uv_clone; /* Actual material for each index, either from object or Mesh datablock... */ Material **mat_array; @@ -384,8 +425,10 @@ typedef struct ProjPaintState { } ProjPaintState; typedef union pixelPointer { - float *f_pt; /* float buffer */ - unsigned int *uint_pt; /* 2 ways to access a char buffer */ + /** float buffer. */ + float *f_pt; + /** 2 ways to access a char buffer. */ + unsigned int *uint_pt; unsigned char *ch_pt; } PixelPointer; @@ -396,12 +439,14 @@ typedef union pixelStore { } PixelStore; typedef struct ProjPixel { - float projCoSS[2]; /* the floating point screen projection of this pixel */ + /** the floating point screen projection of this pixel. */ + float projCoSS[2]; float worldCoSS[3]; short x_px, y_px; - unsigned short image_index; /* if anyone wants to paint onto more than 65535 images they can bite me */ + /** if anyone wants to paint onto more than 65535 images they can bite me. */ + unsigned short image_index; unsigned char bb_cell_index; /* for various reasons we may want to mask out painting onto this pixel */ @@ -624,7 +669,8 @@ static int project_paint_PickFace( } } - return best_tri_index; /* will be -1 or a valid face */ + /** will be -1 or a valid face. */ + return best_tri_index; } /* Converts a uv coord into a pixel location wrapping if the uv is outside 0-1 range */ @@ -665,7 +711,8 @@ static bool project_paint_PickColor( interp_v2_v2v2v2(uv, UNPACK3(lt_tri_uv), w); ima = project_paint_face_paint_image(ps, tri_index); - ibuf = BKE_image_get_first_ibuf(ima); /* we must have got the imbuf before getting here */ + /** we must have got the imbuf before getting here. */ + ibuf = BKE_image_get_first_ibuf(ima); if (!ibuf) return 0; if (interp) { @@ -745,7 +792,7 @@ static int project_paint_occlude_ptv( /* do a 2D point in try intersection */ if (!isect_point_tri_v2(pt, v1, v2, v3)) - return 0; /* we know there is */ + return 0; /* From here on we know there IS an intersection */ @@ -859,16 +906,19 @@ static int line_isect_y(const float p1[2], const float p2[2], const float y_leve { float y_diff; - if (y_level == p1[1]) { /* are we touching the first point? - no interpolation needed */ + /* are we touching the first point? - no interpolation needed */ + if (y_level == p1[1]) { *x_isect = p1[0]; return ISECT_TRUE_P1; } - if (y_level == p2[1]) { /* are we touching the second point? - no interpolation needed */ + /* are we touching the second point? - no interpolation needed */ + if (y_level == p2[1]) { *x_isect = p2[0]; return ISECT_TRUE_P2; } - y_diff = fabsf(p1[1] - p2[1]); /* yuck, horizontal line, we cant do much here */ + /** yuck, horizontal line, we cant do much here. */ + y_diff = fabsf(p1[1] - p2[1]); if (y_diff < 0.000001f) { *x_isect = (p1[0] + p2[0]) * 0.5f; @@ -876,11 +926,13 @@ static int line_isect_y(const float p1[2], const float p2[2], const float y_leve } if (p1[1] > y_level && p2[1] < y_level) { - *x_isect = (p2[0] * (p1[1] - y_level) + p1[0] * (y_level - p2[1])) / y_diff; /* (p1[1] - p2[1]); */ + /* (p1[1] - p2[1]); */ + *x_isect = (p2[0] * (p1[1] - y_level) + p1[0] * (y_level - p2[1])) / y_diff; return ISECT_TRUE; } else if (p1[1] < y_level && p2[1] > y_level) { - *x_isect = (p2[0] * (y_level - p1[1]) + p1[0] * (p2[1] - y_level)) / y_diff; /* (p2[1] - p1[1]); */ + /* (p2[1] - p1[1]); */ + *x_isect = (p2[0] * (y_level - p1[1]) + p1[0] * (p2[1] - y_level)) / y_diff; return ISECT_TRUE; } else { @@ -901,19 +953,23 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve return ISECT_TRUE_P2; } - x_diff = fabsf(p1[0] - p2[0]); /* yuck, horizontal line, we cant do much here */ + /* yuck, horizontal line, we cant do much here */ + x_diff = fabsf(p1[0] - p2[0]); - if (x_diff < 0.000001f) { /* yuck, vertical line, we cant do much here */ + /* yuck, vertical line, we cant do much here */ + if (x_diff < 0.000001f) { *y_isect = (p1[0] + p2[0]) * 0.5f; return ISECT_TRUE; } if (p1[0] > x_level && p2[0] < x_level) { - *y_isect = (p2[1] * (p1[0] - x_level) + p1[1] * (x_level - p2[0])) / x_diff; /* (p1[0] - p2[0]); */ + /* (p1[0] - p2[0]); */ + *y_isect = (p2[1] * (p1[0] - x_level) + p1[1] * (x_level - p2[0])) / x_diff; return ISECT_TRUE; } else if (p1[0] < x_level && p2[0] > x_level) { - *y_isect = (p2[1] * (x_level - p1[0]) + p1[1] * (p2[0] - x_level)) / x_diff; /* (p2[0] - p1[0]); */ + /* (p2[0] - p1[0]); */ + *y_isect = (p2[1] * (x_level - p1[0]) + p1[1] * (p2[0] - x_level)) / x_diff; return ISECT_TRUE; } else { @@ -954,7 +1010,8 @@ static bool pixel_bounds_uv( const int ibuf_x, const int ibuf_y ) { - float min_uv[2], max_uv[2]; /* UV bounds */ + /* UV bounds */ + float min_uv[2], max_uv[2]; INIT_MINMAX2(min_uv, max_uv); @@ -978,7 +1035,8 @@ static bool pixel_bounds_uv( static bool pixel_bounds_array(float (*uv)[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, int tot) { - float min_uv[2], max_uv[2]; /* UV bounds */ + /* UV bounds */ + float min_uv[2], max_uv[2]; if (tot == 0) { return 0; @@ -1031,7 +1089,8 @@ static bool check_seam( const unsigned int i1 = ps->mloop_eval[orig_lt->tri[orig_i1_fidx]].v; const unsigned int i2 = ps->mloop_eval[orig_lt->tri[orig_i2_fidx]].v; LinkNode *node; - int i1_fidx = -1, i2_fidx = -1; /* index in face */ + /* index in face */ + int i1_fidx = -1, i2_fidx = -1; for (node = ps->vertFaces[i1]; node; node = node->next) { const int tri_index = POINTER_AS_INT(node->link); @@ -1117,8 +1176,10 @@ static void uv_image_outset( const float scale_clamp = 5.0f; float a1, a2, a3; - float puv[3][2]; /* pixelspace uv's */ - float no1[2], no2[2], no3[2]; /* normals */ + /* pixelspace uv's */ + float puv[3][2]; + /* normals */ + float no1[2], no2[2], no3[2]; float dir1[2], dir2[2], dir3[2]; float ibuf_inv[2]; @@ -1190,9 +1251,11 @@ static void uv_image_outset( */ static void project_face_seams_init(const ProjPaintState *ps, const int tri_index) { - int other_face, other_fidx; /* vars for the other face, we also set its flag */ + /* vars for the other face, we also set its flag */ + int other_face, other_fidx; int fidx1 = 2; - int fidx2 = 0; /* next fidx in the face (0,1,2,3) -> (1,2,3,0) or (0,1,2) -> (1,2,0) for a tri */ + /* next fidx in the face (0,1,2,3) -> (1,2,3,0) or (0,1,2) -> (1,2,0) for a tri */ + int fidx2 = 0; /* initialize face winding if needed */ if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_INIT) == 0) @@ -1207,8 +1270,10 @@ static void project_face_seams_init(const ProjPaintState *ps, const int tri_inde } else { ps->faceSeamFlags[tri_index] |= 16 << fidx1; - if (other_face != -1) - ps->faceSeamFlags[other_face] |= 16 << other_fidx; /* second 4 bits for disabled */ + if (other_face != -1) { + /* second 4 bits for disabled */ + ps->faceSeamFlags[other_face] |= 16 << other_fidx; + } } } @@ -1261,7 +1326,8 @@ static void screen_px_from_persp( } else { w[0] = w[1] = w[2] = - w_int[0] = w_int[1] = w_int[2] = 1.0f / 3.0f; /* dummy values for zero area face */ + /* dummy values for zero area face */ + w_int[0] = w_int[1] = w_int[2] = 1.0f / 3.0f; } /* done re-weighting */ @@ -1467,7 +1533,8 @@ static float project_paint_uvpixel_mask( } if (angle_cos <= ps->normal_angle__cos) { - return 0.0f; /* outsize the normal limit*/ + /* outsize the normal limit*/ + return 0.0f; } else if (angle_cos < ps->normal_angle_inner__cos) { mask *= (ps->normal_angle - acosf(angle_cos)) / ps->normal_angle_range; @@ -1686,12 +1753,14 @@ static ProjPixel *project_paint_uvpixel_init( * the faces are already initialized in project_paint_delayed_face_init(...) */ if (ibuf->rect_float) { if (!project_paint_PickColor(ps, co, ((ProjPixelClone *)projPixel)->clonepx.f, NULL, 1)) { - ((ProjPixelClone *)projPixel)->clonepx.f[3] = 0; /* zero alpha - ignore */ + /* zero alpha - ignore */ + ((ProjPixelClone *)projPixel)->clonepx.f[3] = 0; } } else { if (!project_paint_PickColor(ps, co, NULL, ((ProjPixelClone *)projPixel)->clonepx.ch, 1)) { - ((ProjPixelClone *)projPixel)->clonepx.ch[3] = 0; /* zero alpha - ignore */ + /* zero alpha - ignore */ + ((ProjPixelClone *)projPixel)->clonepx.ch[3] = 0; } } } @@ -2249,22 +2318,25 @@ static void project_bucket_clip_face( else { /* The Complicated Case! * - * The 2 cases above are where the face is inside the bucket or the bucket is inside the face. + * The 2 cases above are where the face is inside the bucket + * or the bucket is inside the face. * * we need to make a convex polyline from the intersection between the screenspace face * and the bucket bounds. * - * There are a number of ways this could be done, currently it just collects all intersecting verts, - * and line intersections, then sorts them clockwise, this is a lot easier then evaluating the geometry to - * do a correct clipping on both shapes. */ - - - /* add a bunch of points, we know must make up the convex hull which is the clipped rect and triangle */ + * There are a number of ways this could be done, currently it just collects all + * intersecting verts, and line intersections, then sorts them clockwise, this is + * a lot easier then evaluating the geometry to do a correct clipping on both shapes. + */ + /* Add a bunch of points, we know must make up the convex hull + * which is the clipped rect and triangle */ /* Maximum possible 6 intersections when using a rectangle and triangle */ - float isectVCosSS[8][3]; /* The 3rd float is used to store angle for qsort(), NOT as a Z location */ + + /* The 3rd float is used to store angle for qsort(), NOT as a Z location */ + float isectVCosSS[8][3]; float v1_clipSS[2], v2_clipSS[2]; float w[3]; @@ -2332,7 +2404,8 @@ static void project_bucket_clip_face( } #endif - v1_clipSS[0] = cent[0]; /* Abuse this var for the loop below */ + /* Abuse this var for the loop below */ + v1_clipSS[0] = cent[0]; v1_clipSS[1] = cent[1] + 1.0f; for (i = 0; i < (*tot); i++) { @@ -2358,7 +2431,8 @@ static void project_bucket_clip_face( isectVCosSS[j][0] = isectVCosSS[j + 1][0]; isectVCosSS[j][1] = isectVCosSS[j + 1][1]; } - doubles = true; /* keep looking for more doubles */ + /* keep looking for more doubles */ + doubles = true; (*tot)--; } } @@ -2523,29 +2597,36 @@ static void project_paint_face_init( const float *lt_tri_uv[3] = { PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt) }; /* UV/pixel seeking data */ - int x; /* Image X-Pixel */ - int y; /* Image Y-Pixel */ + /* Image X/Y-Pixel */ + int x, y; float mask; - float uv[2]; /* Image floating point UV - same as x, y but from 0.0-1.0 */ + /* Image floating point UV - same as x, y but from 0.0-1.0 */ + float uv[2]; - const float *v1coSS, *v2coSS, *v3coSS; /* vert co screen-space, these will be assigned to lt_vtri[0-2] */ + /* vert co screen-space, these will be assigned to lt_vtri[0-2] */ + const float *v1coSS, *v2coSS, *v3coSS; - const float *vCo[3]; /* vertex screenspace coords */ + /* vertex screenspace coords */ + const float *vCo[3]; float w[3], wco[3]; - float *uv1co, *uv2co, *uv3co; /* for convenience only, these will be assigned to lt_tri_uv[0],1,2 or lt_tri_uv[0],2,3 */ + /* for convenience only, these will be assigned to lt_tri_uv[0],1,2 or lt_tri_uv[0],2,3 */ + float *uv1co, *uv2co, *uv3co; float pixelScreenCo[4]; bool do_3d_mapping = ps->brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D; - rcti bounds_px; /* ispace bounds */ + /* ispace bounds */ + rcti bounds_px; /* vars for getting uvspace bounds */ - float lt_uv_pxoffset[3][2]; /* bucket bounds in UV space so we can init pixels only for this face, */ + /* bucket bounds in UV space so we can init pixels only for this face, */ + float lt_uv_pxoffset[3][2]; float xhalfpx, yhalfpx; const float ibuf_xf = (float)ibuf->x, ibuf_yf = (float)ibuf->y; - int has_x_isect = 0, has_isect = 0; /* for early loop exit */ + /* for early loop exit */ + int has_x_isect = 0, has_isect = 0; float uv_clip[8][2]; int uv_clip_tot; @@ -2619,12 +2700,14 @@ static void project_paint_face_init( has_isect = 0; for (y = bounds_px.ymin; y < bounds_px.ymax; y++) { //uv[1] = (((float)y) + 0.5f) / (float)ibuf->y; - uv[1] = (float)y / ibuf_yf; /* use pixel offset UV coords instead */ + /* use pixel offset UV coords instead */ + uv[1] = (float)y / ibuf_yf; has_x_isect = 0; for (x = bounds_px.xmin; x < bounds_px.xmax; x++) { //uv[0] = (((float)x) + 0.5f) / ibuf->x; - uv[0] = (float)x / ibuf_xf; /* use pixel offset UV coords instead */ + /* use pixel offset UV coords instead */ + uv[0] = (float)x / ibuf_xf; /* Note about IsectPoly2Df_twoside, checking the face or uv flipping doesn't work, * could check the poly direction but better to do this */ @@ -2646,7 +2729,8 @@ static void project_paint_face_init( ps->mvert_eval[lt_vtri[2]].co, w); if (do_clip && ED_view3d_clipping_test(ps->rv3d, wco, true)) { - continue; /* Watch out that no code below this needs to run */ + /* Watch out that no code below this needs to run */ + continue; } } @@ -2693,8 +2777,10 @@ static void project_paint_face_init( if (ps->seam_bleed_px > 0.0f) { int face_seam_flag; - if (threaded) - BLI_thread_lock(LOCK_CUSTOM1); /* Other threads could be modifying these vars */ + if (threaded) { + /* Other threads could be modifying these vars. */ + BLI_thread_lock(LOCK_CUSTOM1); + } face_seam_flag = ps->faceSeamFlags[tri_index]; @@ -2710,8 +2796,10 @@ static void project_paint_face_init( if ((face_seam_flag & (PROJ_FACE_SEAM1 | PROJ_FACE_SEAM2 | PROJ_FACE_SEAM3)) == 0) { - if (threaded) - BLI_thread_unlock(LOCK_CUSTOM1); /* Other threads could be modifying these vars */ + if (threaded) { + /* Other threads could be modifying these vars. */ + BLI_thread_unlock(LOCK_CUSTOM1); + } } else { @@ -2719,13 +2807,19 @@ static void project_paint_face_init( /* Now create new UV's for the seam face */ float (*outset_uv)[2] = ps->faceSeamUVs[tri_index]; - float insetCos[3][3]; /* inset face coords. NOTE!!! ScreenSace for ortho, Worldspace in perspective view */ + /* inset face coords. NOTE!!! ScreenSace for ortho, Worldspace in perspective view */ + float insetCos[3][3]; - const float *vCoSS[3]; /* vertex screenspace coords */ + /* vertex screenspace coords */ + const float *vCoSS[3]; - float bucket_clip_edges[2][2]; /* store the screenspace coords of the face, clipped by the bucket's screen aligned rectangle */ + /* Store the screenspace coords of the face, + * clipped by the bucket's screen aligned rectangle. */ + float bucket_clip_edges[2][2]; float edge_verts_inset_clip[2][3]; - int fidx1, fidx2; /* face edge pairs - loop throuh these ((0,1), (1,2), (2,3), (3,0)) or ((0,1), (1,2), (2,0)) for a tri */ + /* face edge pairs - loop throuh these: + * ((0,1), (1,2), (2,3), (3,0)) or ((0,1), (1,2), (2,0)) for a tri */ + int fidx1, fidx2; float seam_subsection[4][2]; float fac1, fac2; @@ -2735,9 +2829,11 @@ static void project_paint_face_init( lt_uv_pxoffset, outset_uv, ps->seam_bleed_px, ibuf->x, ibuf->y, (ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_CW) == 0); - /* ps->faceSeamUVs cant be modified when threading, now this is done we can unlock */ - if (threaded) - BLI_thread_unlock(LOCK_CUSTOM1); /* Other threads could be modifying these vars */ + /* ps->faceSeamUVs cant be modified when threading, now this is done we can unlock. */ + if (threaded) { + /* Other threads could be modifying these vars */ + BLI_thread_unlock(LOCK_CUSTOM1); + } vCoSS[0] = ps->screenCoords[lt_vtri[0]]; vCoSS[1] = ps->screenCoords[lt_vtri[1]]; @@ -2752,12 +2848,14 @@ static void project_paint_face_init( } for (fidx1 = 0; fidx1 < 3; fidx1++) { - fidx2 = (fidx1 == 2) ? 0 : fidx1 + 1; /* next fidx in the face (0,1,2) -> (1,2,0) */ + /* next fidx in the face (0,1,2) -> (1,2,0) */ + fidx2 = (fidx1 == 2) ? 0 : fidx1 + 1; if ((face_seam_flag & (1 << fidx1)) && /* 1<<fidx1 -> PROJ_FACE_SEAM# */ line_clip_rect2f(clip_rect, bucket_bounds, vCoSS[fidx1], vCoSS[fidx2], bucket_clip_edges[0], bucket_clip_edges[1])) { - if (len_squared_v2v2(vCoSS[fidx1], vCoSS[fidx2]) > FLT_EPSILON) { /* avoid div by zero */ + /* Avoid div by zero. */ + if (len_squared_v2v2(vCoSS[fidx1], vCoSS[fidx2]) > FLT_EPSILON) { if (is_ortho) { fac1 = line_point_factor_v2(bucket_clip_edges[0], vCoSS[fidx1], vCoSS[fidx2]); @@ -2786,12 +2884,14 @@ static void project_paint_face_init( has_isect = 0; for (y = bounds_px.ymin; y < bounds_px.ymax; y++) { // uv[1] = (((float)y) + 0.5f) / (float)ibuf->y; - uv[1] = (float)y / ibuf_yf; /* use offset uvs instead */ + /* use offset uvs instead */ + uv[1] = (float)y / ibuf_yf; has_x_isect = 0; for (x = bounds_px.xmin; x < bounds_px.xmax; x++) { //uv[0] = (((float)x) + 0.5f) / (float)ibuf->x; - uv[0] = (float)x / ibuf_xf; /* use offset uvs instead */ + /* use offset uvs instead */ + uv[0] = (float)x / ibuf_xf; /* test we're inside uvspace bucket and triangle bounds */ if (isect_point_quad_v2(uv, UNPACK4(seam_subsection))) { @@ -2813,10 +2913,12 @@ static void project_paint_face_init( if (!is_ortho) { pixelScreenCo[3] = 1.0f; - mul_m4_v4((float(*)[4])ps->projectMat, pixelScreenCo); /* cast because of const */ + /* cast because of const */ + mul_m4_v4((float(*)[4])ps->projectMat, pixelScreenCo); pixelScreenCo[0] = (float)(ps->winx * 0.5f) + (ps->winx * 0.5f) * pixelScreenCo[0] / pixelScreenCo[3]; pixelScreenCo[1] = (float)(ps->winy * 0.5f) + (ps->winy * 0.5f) * pixelScreenCo[1] / pixelScreenCo[3]; - pixelScreenCo[2] = pixelScreenCo[2] / pixelScreenCo[3]; /* Use the depth for bucket point occlusion */ + /* Use the depth for bucket point occlusion */ + pixelScreenCo[2] = pixelScreenCo[2] / pixelScreenCo[3]; } if ((ps->do_occlude == false) || @@ -2844,7 +2946,8 @@ static void project_paint_face_init( interp_v3_v3v3v3(wco, vCo[0], vCo[1], vCo[2], w); if (do_clip && ED_view3d_clipping_test(ps->rv3d, wco, true)) { - continue; /* Watch out that no code below this needs to run */ + /* Watch out that no code below this needs to run */ + continue; } } @@ -2886,12 +2989,16 @@ static void project_paint_face_init( } -/* takes floating point screenspace min/max and returns int min/max to be used as indices for ps->bucketRect, ps->bucketFlags */ +/** + * Takes floating point screenspace min/max and + * returns int min/max to be used as indices for ps->bucketRect, ps->bucketFlags + */ static void project_paint_bucket_bounds(const ProjPaintState *ps, const float min[2], const float max[2], int bucketMin[2], int bucketMax[2]) { /* divide by bucketWidth & bucketHeight so the bounds are offset in bucket grid units */ /* XXX: the offset of 0.5 is always truncated to zero and the offset of 1.5f is always truncated to 1, is this really correct?? - jwilkins */ - bucketMin[0] = (int)((int)(((float)(min[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) + 0.5f); /* these offsets of 0.5 and 1.5 seem odd but they are correct */ + /* these offsets of 0.5 and 1.5 seem odd but they are correct */ + bucketMin[0] = (int)((int)(((float)(min[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) + 0.5f); bucketMin[1] = (int)((int)(((float)(min[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y) + 0.5f); bucketMax[0] = (int)((int)(((float)(max[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) + 1.5f); @@ -2906,13 +3013,22 @@ static void project_paint_bucket_bounds(const ProjPaintState *ps, const float mi } /* set bucket_bounds to a screen space-aligned floating point bound-box */ -static void project_bucket_bounds(const ProjPaintState *ps, const int bucket_x, const int bucket_y, rctf *bucket_bounds) +static void project_bucket_bounds( + const ProjPaintState *ps, const int bucket_x, const int bucket_y, rctf *bucket_bounds) { - bucket_bounds->xmin = ps->screenMin[0] + ((bucket_x) * (ps->screen_width / ps->buckets_x)); /* left */ - bucket_bounds->xmax = ps->screenMin[0] + ((bucket_x + 1) * (ps->screen_width / ps->buckets_x)); /* right */ - - bucket_bounds->ymin = ps->screenMin[1] + ((bucket_y) * (ps->screen_height / ps->buckets_y)); /* bottom */ - bucket_bounds->ymax = ps->screenMin[1] + ((bucket_y + 1) * (ps->screen_height / ps->buckets_y)); /* top */ + /* left */ + bucket_bounds->xmin = ( + ps->screenMin[0] + ((bucket_x) * (ps->screen_width / ps->buckets_x))); + /* right */ + bucket_bounds->xmax = ( + ps->screenMin[0] + ((bucket_x + 1) * (ps->screen_width / ps->buckets_x))); + + /* bottom */ + bucket_bounds->ymin = ( + ps->screenMin[1] + ((bucket_y) * (ps->screen_height / ps->buckets_y))); + /* top */ + bucket_bounds->ymax = ( + ps->screenMin[1] + ((bucket_y + 1) * (ps->screen_height / ps->buckets_y))); } /* Fill this bucket with pixels from the faces that intersect it. @@ -3024,15 +3140,19 @@ static bool project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int buck } /* Add faces to the bucket but don't initialize its pixels - * TODO - when painting occluded, sort the faces on their min-Z and only add faces that faces that are not occluded */ + * TODO - when painting occluded, sort the faces on their min-Z + * and only add faces that faces that are not occluded */ static void project_paint_delayed_face_init(ProjPaintState *ps, const MLoopTri *lt, const int tri_index) { const int lt_vtri[3] = { PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt) }; float min[2], max[2], *vCoSS; - int bucketMin[2], bucketMax[2]; /* for ps->bucketRect indexing */ + /* for ps->bucketRect indexing */ + int bucketMin[2], bucketMax[2]; int fidx, bucket_x, bucket_y; - int has_x_isect = -1, has_isect = 0; /* for early loop exit */ - MemArena *arena = ps->arena_mt[0]; /* just use the first thread arena since threading has not started yet */ + /* for early loop exit */ + int has_x_isect = -1, has_isect = 0; + /* just use the first thread arena since threading has not started yet */ + MemArena *arena = ps->arena_mt[0]; INIT_MINMAX2(min, max); @@ -3051,7 +3171,8 @@ static void project_paint_delayed_face_init(ProjPaintState *ps, const MLoopTri * int bucket_index = bucket_x + (bucket_y * ps->buckets_x); BLI_linklist_prepend_arena( &ps->bucketFaces[bucket_index], - POINTER_FROM_INT(tri_index), /* cast to a pointer to shut up the compiler */ + /* cast to a pointer to shut up the compiler */ + POINTER_FROM_INT(tri_index), arena ); @@ -3071,7 +3192,8 @@ static void project_paint_delayed_face_init(ProjPaintState *ps, const MLoopTri * #ifndef PROJ_DEBUG_NOSEAMBLEED if (ps->seam_bleed_px > 0.0f) { - **ps->faceSeamUVs[tri_index] = FLT_MAX; /* set as uninitialized */ + /* set as uninitialized */ + **ps->faceSeamUVs[tri_index] = FLT_MAX; } #endif } @@ -3218,7 +3340,8 @@ static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int di /* screen space, not clamped */ projScreenCo[0] = (float)(ps->winx * 0.5f) + (ps->winx * 0.5f) * projScreenCo[0] / projScreenCo[3]; projScreenCo[1] = (float)(ps->winy * 0.5f) + (ps->winy * 0.5f) * projScreenCo[1] / projScreenCo[3]; - projScreenCo[2] = projScreenCo[2] / projScreenCo[3]; /* Use the depth for bucket point occlusion */ + /* Use the depth for bucket point occlusion */ + projScreenCo[2] = projScreenCo[2] / projScreenCo[3]; minmax_v2v2_v2(ps->screenMin, ps->screenMax, projScreenCo); } else { @@ -3434,7 +3557,8 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p } /* Build final material array, we use this a lot here. */ - const int totmat = ob->totcol + 1; /* materials start from 1, default material is 0 */ + /* materials start from 1, default material is 0 */ + const int totmat = ob->totcol + 1; ps->mat_array = MEM_malloc_arrayN(totmat, sizeof(*ps->mat_array), __func__); /* We leave last material as empty - rationale here is being able to index * the materials by using the mf->mat_nr directly and leaving the last @@ -3814,7 +3938,8 @@ static void project_paint_begin( ProjPaintFaceLookup face_lookup; const MLoopUV *mloopuv_base = NULL; - MemArena *arena; /* at the moment this is just ps->arena_mt[0], but use this to show were not multithreading */ + /* at the moment this is just ps->arena_mt[0], but use this to show were not multithreading */ + MemArena *arena; const int diameter = 2 * BKE_brush_size_get(ps->scene, ps->brush); @@ -3822,8 +3947,10 @@ static void project_paint_begin( /* ---- end defines ---- */ - if (ps->source == PROJ_SRC_VIEW) - ED_view3d_clipping_local(ps->rv3d, ps->ob->obmat); /* faster clipping lookups */ + if (ps->source == PROJ_SRC_VIEW) { + /* faster clipping lookups */ + ED_view3d_clipping_local(ps->rv3d, ps->ob->obmat); + } ps->do_face_sel = ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) != 0); ps->is_flip_object = (ps->ob->transflag & OB_NEG_SCALE) != 0; @@ -4057,7 +4184,8 @@ static bool project_image_refresh_tagged(ProjPaintState *ps) partial_redraw_single_init(pr); } - projIma->touch = 0; /* clear for reuse */ + /* clear for reuse */ + projIma->touch = 0; } } @@ -4149,8 +4277,11 @@ typedef struct ProjectHandle { float prevmval[2]; float mval[2]; - /* annoying but we need to have image bounds per thread, then merge into ps->projectPartialRedraws */ - ProjPaintImage *projImages; /* array of partial redraws */ + /* Annoying but we need to have image bounds per thread, + * then merge into ps->projectPartialRedraws. */ + + /* array of partial redraws */ + ProjPaintImage *projImages; /* thread settings */ int thread_index; @@ -4292,7 +4423,8 @@ static void do_projectpaint_soften( float accum_tot = 0; int xk, yk; BlurKernel *kernel = ps->blurkernel; - float rgba[4]; /* convert to byte after */ + /* convert to byte after */ + float rgba[4]; /* rather then painting, accumulate surrounding colors */ zero_v4(rgba); @@ -4479,18 +4611,21 @@ static void *do_projectpaint_thread(void *ph_v) unsigned short mask_short; const float brush_alpha = BKE_brush_alpha_get(ps->scene, brush); const float brush_radius = ps->brush_size; - const float brush_radius_sq = brush_radius * brush_radius; /* avoid a square root with every dist comparison */ + /* avoid a square root with every dist comparison */ + const float brush_radius_sq = brush_radius * brush_radius; const bool lock_alpha = ELEM(brush->blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA) ? 0 : (brush->flag & BRUSH_LOCK_ALPHA) != 0; LinkNode *smearPixels = NULL; LinkNode *smearPixels_f = NULL; - MemArena *smearArena = NULL; /* mem arena for this brush projection only */ + /* mem arena for this brush projection only */ + MemArena *smearArena = NULL; LinkNode *softenPixels = NULL; LinkNode *softenPixels_f = NULL; - MemArena *softenArena = NULL; /* mem arena for this brush projection only */ + /* mem arena for this brush projection only */ + MemArena *softenArena = NULL; if (tool == PAINT_TOOL_SMEAR) { pos_ofs[0] = pos[0] - lastpos[0]; @@ -5082,7 +5217,8 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int ps->depsgraph = CTX_data_depsgraph(C); ps->scene = scene; - ps->ob = ob; /* allow override of active object */ + /* allow override of active object */ + ps->ob = ob; ps->do_material_slots = (settings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL); ps->stencil_ima = settings->imapaint.stencil; @@ -5116,7 +5252,8 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int #ifndef PROJ_DEBUG_NOSEAMBLEED - ps->seam_bleed_px = settings->imapaint.seam_bleed; /* pixel num to bleed */ + /* pixel num to bleed */ + ps->seam_bleed_px = settings->imapaint.seam_bleed; #endif if (ps->do_mask_normal) { @@ -5131,8 +5268,10 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int ps->normal_angle *= (float)(M_PI_2 / 90); ps->normal_angle_range = ps->normal_angle - ps->normal_angle_inner; - if (ps->normal_angle_range <= 0.0f) - ps->do_mask_normal = false; /* no need to do blending */ + if (ps->normal_angle_range <= 0.0f) { + /* no need to do blending */ + ps->do_mask_normal = false; + } ps->normal_angle__cos = cosf(ps->normal_angle); ps->normal_angle_inner__cos = cosf(ps->normal_angle_inner); @@ -5368,9 +5507,11 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) ps.is_maskbrush = false; ps.do_masking = false; orig_brush_size = BKE_brush_size_get(scene, ps.brush); - BKE_brush_size_set(scene, ps.brush, 32 * U.pixelsize); /* cover the whole image */ + /* cover the whole image */ + BKE_brush_size_set(scene, ps.brush, 32 * U.pixelsize); - ps.tool = PAINT_TOOL_DRAW; /* so pixels are initialized with minimal info */ + /* so pixels are initialized with minimal info */ + ps.tool = PAINT_TOOL_DRAW; scene->toolsettings->imapaint.flag |= IMAGEPAINT_DRAWING; diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c index d8b7d449c36..d2239b9b8ba 100644 --- a/source/blender/editors/space_view3d/view3d_camera_control.c +++ b/source/blender/editors/space_view3d/view3d_camera_control.c @@ -94,20 +94,24 @@ typedef struct View3DCameraControl { Object *root_parent; /* backup values */ - float dist_backup; /* backup the views distance since we use a zero dist for fly mode */ - float ofs_backup[3]; /* backup the views offset in case the user cancels flying in non camera mode */ + float dist_backup; + /* backup the views distance since we use a zero dist for fly mode */ + float ofs_backup[3]; + /* backup the views offset in case the user cancels flying in non camera mode */ /* backup the views quat in case the user cancels flying in non camera mode. * (quat for view, eul for camera) */ float rot_backup[4]; - char persp_backup; /* remember if were ortho or not, only used for restoring the view if it was a ortho view */ + /* remember if were ortho or not, only used for restoring the view if it was a ortho view */ + char persp_backup; /* are we flying an ortho camera in perspective view, * which was originally in ortho view? * could probably figure it out but better be explicit */ bool is_ortho_cam; - void *obtfm; /* backup the objects transform */ + /* backup the objects transform */ + void *obtfm; } View3DCameraControl; @@ -185,8 +189,10 @@ struct View3DCameraControl *ED_view3d_cameracontrol_acquire( } else { /* perspective or ortho */ - if (rv3d->persp == RV3D_ORTHO) - rv3d->persp = RV3D_PERSP; /* if ortho projection, make perspective */ + if (rv3d->persp == RV3D_ORTHO) { + /* if ortho projection, make perspective */ + rv3d->persp = RV3D_PERSP; + } copy_qt_qt(vctrl->rot_backup, rv3d->viewquat); copy_v3_v3(vctrl->ofs_backup, rv3d->ofs); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index fc52f5e723c..f9304f67f0b 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -95,8 +95,10 @@ typedef struct TransSnap { bool peel; bool snap_spatial_grid; short status; - float snapPoint[3]; /* snapping from this point (in global-space)*/ - float snapTarget[3]; /* to this point (in global-space)*/ + /** snapping from this point (in global-space). */ + float snapPoint[3]; + /** to this point (in global-space). */ + float snapTarget[3]; float snapNormal[3]; char snapNodeBorder; ListBase points; @@ -120,59 +122,91 @@ typedef struct TransSnap { } TransSnap; typedef struct TransCon { - short orientation; /**/ - char text[50]; /* Description of the Constraint for header_print */ - float mtx[3][3]; /* Matrix of the Constraint space */ - float imtx[3][3]; /* Inverse Matrix of the Constraint space */ - float pmtx[3][3]; /* Projection Constraint Matrix (same as imtx with some axis == 0) */ - int imval[2]; /* initial mouse value for visual calculation */ - /* the one in TransInfo is not guarantee to stay the same (Rotates change it) */ - int mode; /* Mode flags of the Constraint */ + short orientation; + /** Description of the Constraint for header_print. */ + char text[50]; + /** Matrix of the Constraint space. */ + float mtx[3][3]; + /** Inverse Matrix of the Constraint space. */ + float imtx[3][3]; + /** Projection Constraint Matrix (same as imtx with some axis == 0). */ + float pmtx[3][3]; + /** Initial mouse value for visual calculation + * the one in TransInfo is not guarantee to stay the same (Rotates change it). */ + int imval[2]; + /** Mode flags of the Constraint. */ + int mode; void (*drawExtra)(struct TransInfo *t); - /* Note: if 'tc' is NULL, 'td' must also be NULL. */ - /* For constraints that needs to draw differently from the other - * uses this instead of the generic draw function */ + /* Note: if 'tc' is NULL, 'td' must also be NULL. + * For constraints that needs to draw differently from the other + * uses this instead of the generic draw function. */ + + /** Apply function pointer for linear vectorial transformation + * The last three parameters are pointers to the in/out/printable vectors. */ void (*applyVec)(struct TransInfo *t, struct TransDataContainer *tc, struct TransData *td, const float in[3], float out[3], float pvec[3]); - /* Apply function pointer for linear vectorial transformation */ - /* The last three parameters are pointers to the in/out/printable vectors */ + /** Apply function pointer for size transformation. */ void (*applySize)(struct TransInfo *t, struct TransDataContainer *tc, struct TransData *td, float smat[3][3]); - /* Apply function pointer for size transformation */ + /** Apply function pointer for rotation transformation */ void (*applyRot)(struct TransInfo *t, struct TransDataContainer *tc, struct TransData *td, float vec[3], float *angle); - /* Apply function pointer for rotation transformation */ } TransCon; typedef struct TransDataExtension { - float drot[3]; /* Initial object drot */ - // float drotAngle; /* Initial object drotAngle, TODO: not yet implemented */ - // float drotAxis[3]; /* Initial object drotAxis, TODO: not yet implemented */ - float dquat[4]; /* Initial object dquat */ - float dscale[3]; /* Initial object dscale */ - float *rot; /* Rotation of the data to transform */ - float irot[3]; /* Initial rotation */ - float *quat; /* Rotation quaternion of the data to transform */ - float iquat[4]; /* Initial rotation quaternion */ - float *rotAngle; /* Rotation angle of the data to transform */ - float irotAngle; /* Initial rotation angle */ - float *rotAxis; /* Rotation axis of the data to transform */ - float irotAxis[4]; /* Initial rotation axis */ - float *size; /* Size of the data to transform */ - float isize[3]; /* Initial size */ - float obmat[4][4]; /* Object matrix */ - float l_smtx[3][3]; /* use instead of td->smtx, It is the same but without the 'bone->bone_mat', see TD_PBONE_LOCAL_MTX_C */ - float r_mtx[3][3]; /* The rotscale matrix of pose bone, to allow using snap-align in translation mode, - * when td->mtx is the loc pose bone matrix (and hence can't be used to apply rotation in some cases, - * namely when a bone is in "NoLocal" or "Hinge" mode)... */ - float r_smtx[3][3]; /* Inverse of previous one. */ - int rotOrder; /* rotation mode, as defined in eRotationModes (DNA_action_types.h) */ - float oloc[3], orot[3], oquat[4], orotAxis[3], orotAngle; /* Original object transformation used for rigid bodies */ + /** Initial object drot. */ + float drot[3]; + // /* Initial object drotAngle, TODO: not yet implemented */ + // float drotAngle; + // /* Initial object drotAxis, TODO: not yet implemented */ + // float drotAxis[3]; + /** Initial object dquat. */ + float dquat[4]; + /** Initial object dscale. */ + float dscale[3]; + /** Rotation of the data to transform. */ + float *rot; + /** Initial rotation. */ + float irot[3]; + /** Rotation quaternion of the data to transform. */ + float *quat; + /** Initial rotation quaternion. */ + float iquat[4]; + /** Rotation angle of the data to transform. */ + float *rotAngle; + /** Initial rotation angle. */ + float irotAngle; + /** Rotation axis of the data to transform. */ + float *rotAxis; + /** Initial rotation axis. */ + float irotAxis[4]; + /** Size of the data to transform. */ + float *size; + /** Initial size. */ + float isize[3]; + /** Object matrix. */ + float obmat[4][4]; + /** Use instead of td->smtx, + * It is the same but without the 'bone->bone_mat', see TD_PBONE_LOCAL_MTX_C. */ + float l_smtx[3][3]; + /** The rotscale matrix of pose bone, to allow using snap-align in translation mode, + * when td->mtx is the loc pose bone matrix (and hence can't be used to apply + * rotation in some cases, namely when a bone is in "NoLocal" or "Hinge" mode)... */ + float r_mtx[3][3]; + /** Inverse of previous one. */ + float r_smtx[3][3]; + /** rotation mode, as defined in eRotationModes (DNA_action_types.h). */ + int rotOrder; + /** Original object transformation used for rigid bodies. */ + float oloc[3], orot[3], oquat[4], orotAxis[3], orotAngle; } TransDataExtension; typedef struct TransData2D { - float loc[3]; /* Location of data used to transform (x,y,0) */ - float *loc2d; /* Pointer to real 2d location of data */ + /** Location of data used to transform (x,y,0). */ + float loc[3]; + /** Pointer to real 2d location of data. */ + float *loc2d; - float *h1, *h2; /* Pointer to handle locations, if handles aren't being moved independently */ + /** Pointer to handle locations, if handles aren't being moved independently. */ + float *h1, *h2; float ih1[2], ih2[2]; } TransData2D; @@ -185,9 +219,13 @@ typedef struct TransDataCurveHandleFlags { /* for sequencer transform */ typedef struct TransDataSeq { struct Sequence *seq; - int flag; /* a copy of seq->flag that may be modified for nested strips */ - int start_offset; /* use this so we can have transform data at the strips start, but apply correctly to the start frame */ - short sel_flag; /* one of SELECT, SEQ_LEFTSEL and SEQ_RIGHTSEL */ + /** A copy of seq->flag that may be modified for nested strips. */ + int flag; + /** Use this so we can have transform data at the strips start, + * but apply correctly to the start frame. */ + int start_offset; + /** one of SELECT, SEQ_LEFTSEL and SEQ_RIGHTSEL. */ + short sel_flag; } TransDataSeq; @@ -200,19 +238,27 @@ typedef struct TransSeq { /* for NLA transform (stored in td->extra pointer) */ typedef struct TransDataNla { - ID *id; /* ID-block NLA-data is attached to */ + /** ID-block NLA-data is attached to. */ + ID *id; - struct NlaTrack *oldTrack; /* Original NLA-Track that the strip belongs to */ - struct NlaTrack *nlt; /* Current NLA-Track that the strip belongs to */ + /** Original NLA-Track that the strip belongs to. */ + struct NlaTrack *oldTrack; + /** Current NLA-Track that the strip belongs to. */ + struct NlaTrack *nlt; - struct NlaStrip *strip; /* NLA-strip this data represents */ + /** NLA-strip this data represents. */ + struct NlaStrip *strip; /* dummy values for transform to write in - must have 3 elements... */ - float h1[3]; /* start handle */ - float h2[3]; /* end handle */ - - int trackIndex; /* index of track that strip is currently in */ - int handle; /* handle-index: 0 for dummy entry, -1 for start, 1 for end, 2 for both ends */ + /** start handle. */ + float h1[3]; + /** end handle. */ + float h2[3]; + + /** index of track that strip is currently in. */ + int trackIndex; + /** handle-index: 0 for dummy entry, -1 for start, 1 for end, 2 for both ends. */ + int handle; } TransDataNla; struct LinkNode; @@ -249,18 +295,19 @@ typedef struct SlideOrigData { bool use_origfaces; int cd_loop_mdisp_offset; - struct GHash *origverts; /* map {BMVert: TransDataGenericSlideVert} */ + /** map {BMVert: TransDataGenericSlideVert} */ + struct GHash *origverts; struct GHash *origfaces; struct BMesh *bm_origfaces; struct MemArena *arena; - /* number of math BMLoop layers */ + /** Number of math BMLoop layers. */ int layer_math_map_num; - /* array size of 'layer_math_map_num' + /** Array size of 'layer_math_map_num' * maps TransDataVertSlideVert.cd_group index to absolute CustomData layer index */ int *layer_math_map; - /* array of slide vert data especially for mirror verts */ + /** Array of slide vert data especially for mirror verts. */ TransDataGenericSlideVert *sv_mirror; int totsv_mirror; } SlideOrigData; @@ -333,36 +380,58 @@ typedef struct BoneInitData { } BoneInitData; typedef struct TransData { - float dist; /* Distance needed to affect element (for Proportionnal Editing) */ - float rdist; /* Distance to the nearest element (for Proportionnal Editing) */ - float factor; /* Factor of the transformation (for Proportionnal Editing) */ - float *loc; /* Location of the data to transform */ - float iloc[3]; /* Initial location */ - float *val; /* Value pointer for special transforms */ - float ival; /* Old value*/ - float center[3]; /* Individual data center */ - float mtx[3][3]; /* Transformation matrix from data space to global space */ - float smtx[3][3]; /* Transformation matrix from global space to data space */ - float axismtx[3][3];/* Axis orientation matrix of the data */ + /** Distance needed to affect element (for Proportionnal Editing). */ + float dist; + /** Distance to the nearest element (for Proportionnal Editing). */ + float rdist; + /** Factor of the transformation (for Proportionnal Editing). */ + float factor; + /** Location of the data to transform. */ + float *loc; + /** Initial location. */ + float iloc[3]; + /** Value pointer for special transforms. */ + float *val; + /** Old value. */ + float ival; + /** Individual data center. */ + float center[3]; + /** Transformation matrix from data space to global space. */ + float mtx[3][3]; + /** Transformation matrix from global space to data space. */ + float smtx[3][3]; + /** Axis orientation matrix of the data. */ + float axismtx[3][3]; struct Object *ob; - struct bConstraint *con; /* for objects/bones, the first constraint in its constraint stack */ - TransDataExtension *ext; /* for objects, poses. 1 single malloc per TransInfo! */ - TransDataCurveHandleFlags *hdata; /* for curves, stores handle flags for modification/cancel */ - void *extra; /* extra data (mirrored element pointer, in editmode mesh to BMVert) (editbone for roll fixing) (...) */ - int flag; /* Various flags */ - short protectflag; /* If set, copy of Object or PoseChannel protection */ + /** For objects/bones, the first constraint in its constraint stack. */ + struct bConstraint *con; + /** For objects, poses. 1 single malloc per TransInfo! */ + TransDataExtension *ext; + /** for curves, stores handle flags for modification/cancel. */ + TransDataCurveHandleFlags *hdata; + /** + * Extra data (mirrored element pointer, in editmode mesh to BMVert) + * (editbone for roll fixing) (...). + */ + void *extra; + /** Various flags. */ + int flag; + /** If set, copy of Object or PoseChannel protection. */ + short protectflag; } TransData; typedef struct MouseInput { void (*apply)(struct TransInfo *t, struct MouseInput *mi, const double mval[2], float output[3]); void (*post)(struct TransInfo *t, float values[3]); - int imval[2]; /* initial mouse position */ + /** Initial mouse position. */ + int imval[2]; bool precision; float precision_factor; float center[2]; float factor; - void *data; /* additional data, if needed by the particular function */ + /** Additional data, if needed by the particular function. */ + void *data; /** * Use virtual cursor, which takes precision into account @@ -455,53 +524,85 @@ typedef struct TransInfo { * Use to check if nothing is selected or if we have a single selection. */ int data_len_all; - int mode; /* current mode */ - int flag; /* generic flags for special behaviors */ - int modifiers; /* special modifiers, by function, not key */ - short state; /* current state (running, canceled,...)*/ - int options; /* current context/options for transform */ - float val; /* init value for some transformations (and rotation angle) */ + /** Current mode. */ + int mode; + /** Generic flags for special behaviors. */ + int flag; + /** Special modifiers, by function, not key. */ + int modifiers; + /** Current state (running, canceled. */ + short state; + /** Current context/options for transform. */ + int options; + /** Init value for some transformations (and rotation angle). */ + float val; void (*transform)(struct TransInfo *, const int[2]); - /* transform function pointer */ + /** Transform function pointer. */ eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *); /* event handler function pointer RETURN 1 if redraw is needed */ - TransCon con; /* transformed constraint */ + /** transformed constraint. */ + TransCon con; TransSnap tsnap; - NumInput num; /* numerical input */ - MouseInput mouse; /* mouse input */ - eRedrawFlag redraw; /* redraw flag */ - float prop_size; /* proportional circle radius */ - char proptext[20]; /* proportional falloff text */ - float aspect[3]; /* spaces using non 1:1 aspect, (uv's, f-curve, movie-clip... etc) - * use for conversion and snapping. */ - float center_global[3]; /* center of transformation (in global-space) */ - float center2d[2]; /* center in screen coordinates */ + /** numerical input. */ + NumInput num; + /** mouse input. */ + MouseInput mouse; + /** redraw flag. */ + eRedrawFlag redraw; + /** proportional circle radius. */ + float prop_size; + /** proportional falloff text. */ + char proptext[20]; + /** + * Spaces using non 1:1 aspect, (uv's, f-curve, movie-clip... etc) + * use for conversion and snapping. + */ + float aspect[3]; + /** center of transformation (in global-space) */ + float center_global[3]; + /** center in screen coordinates. */ + float center2d[2]; /* Lazy initialize center data for when we need other center values. * V3D_AROUND_ACTIVE + 1 (static assert checks this) */ TransCenterData center_cache[5]; - short idx_max; /* maximum index on the input vector */ - float snap[3]; /* Snapping Gears */ - float snap_spatial[3]; /* Spatial snapping gears(even when rotating, scaling... etc) */ - char frame_side; /* Mouse side of the cfra, 'L', 'R' or 'B' */ - - float viewmat[4][4]; /* copy from G.vd, prevents feedback, */ - float viewinv[4][4]; /* and to make sure we don't have to */ - float persmat[4][4]; /* access G.vd from other space types */ + /** maximum index on the input vector. */ + short idx_max; + /** Snapping Gears. */ + float snap[3]; + /** Spatial snapping gears(even when rotating, scaling... etc). */ + float snap_spatial[3]; + /** Mouse side of the cfra, 'L', 'R' or 'B' */ + char frame_side; + + /** copy from G.vd, prevents feedback. */ + float viewmat[4][4]; + /** and to make sure we don't have to. */ + float viewinv[4][4]; + /** access G.vd from other space types. */ + float persmat[4][4]; float persinv[4][4]; short persp; short around; - char spacetype; /* spacetype where transforming is */ - char helpline; /* Choice of custom cursor with or without a help line from the gizmo to the mouse position. */ - short obedit_type; /* Avoid looking inside TransDataContainer obedit. */ - - float vec[3]; /* translation, to show for widget */ - float mat[3][3]; /* rot/rescale, to show for widget */ - - float spacemtx[3][3]; /* orientation matrix of the current space */ - char spacename[64]; /* name of the current space, MAX_NAME */ + /** spacetype where transforming is. */ + char spacetype; + /** Choice of custom cursor with or without a help line from the gizmo to the mouse position. */ + char helpline; + /** Avoid looking inside TransDataContainer obedit. */ + short obedit_type; + + /** translation, to show for widget. */ + float vec[3]; + /** rot/rescale, to show for widget. */ + float mat[3][3]; + + /** orientation matrix of the current space. */ + float spacemtx[3][3]; + /** name of the current space, MAX_NAME. */ + char spacename[64]; /*************** NEW STUFF *********************/ - short launch_event; /* event type used to launch transform */ + /** event type used to launch transform. */ + short launch_event; struct { short user; @@ -512,23 +613,28 @@ typedef struct TransInfo { /* this gets used when custom_orientation is V3D_MANIP_CUSTOM */ TransformOrientation *custom; } orientation; - short gizmo_flag; /* backup from view3d, to restore on end */ + /** backup from view3d, to restore on end. */ + short gizmo_flag; short prop_mode; short mirror; float values[4]; - float values_modal_offset[4]; /* Offset applied ontop of modal input. */ + /** Offset applied ontop of modal input. */ + float values_modal_offset[4]; float auto_values[4]; float axis[3]; - float axis_orig[3]; /* TransCon can change 'axis', store the original value here */ + /** TransCon can change 'axis', store the original value here. */ + float axis_orig[3]; float axis_ortho[3]; - bool remove_on_cancel; /* remove elements if operator is canceled */ + /** remove elements if operator is canceled. */ + bool remove_on_cancel; void *view; - struct bContext *context; /* Only valid (non null) during an operator called function. */ + /** Only valid (non null) during an operator called function. */ + struct bContext *context; struct ScrArea *sa; struct ARegion *ar; struct Depsgraph *depsgraph; @@ -536,10 +642,14 @@ typedef struct TransInfo { struct ViewLayer *view_layer; struct ToolSettings *settings; struct wmTimer *animtimer; - struct wmKeyMap *keymap; /* so we can do lookups for header text */ - struct ReportList *reports; /* assign from the operator, or can be NULL */ - int mval[2]; /* current mouse position */ - float zfac; /* use for 3d view */ + /** so we can do lookups for header text. */ + struct wmKeyMap *keymap; + /** assign from the operator, or can be NULL. */ + struct ReportList *reports; + /** current mouse position. */ + int mval[2]; + /** use for 3d view. */ + float zfac; void *draw_handle_apply; void *draw_handle_view; void *draw_handle_pixel; diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h index 74c72e159b4..746b27bd9b3 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.h +++ b/source/blender/freestyle/intern/stroke/Stroke.h @@ -303,9 +303,12 @@ private: typedef std::map<const char *, Vec2f, StringUtils::ltstr> Vec2fMap; typedef std::map<const char *, Vec3f, StringUtils::ltstr> Vec3fMap; - float _color[3]; //! the color - float _alpha; //! alpha - float _thickness[2]; //! the thickness on the right and on the left of the backbone vertex (the stroke is oriented) + //! the color + float _color[3]; + //! alpha + float _alpha; + //! the thickness on the right and on the left of the backbone vertex (the stroke is oriented) + float _thickness[2]; bool _visible; realMap *_userAttributesReal; Vec2fMap *_userAttributesVec2f; diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 2c795a8d9ad..9629b0924ad 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -231,7 +231,8 @@ static Mesh *applyModifier( float axis_vec[3] = {0.0f, 0.0f, 0.0f}; float tmp_vec1[3], tmp_vec2[3]; float mat3[3][3]; - float mtx_tx[4][4]; /* transform the coords by an object relative to this objects transformation */ + /* transform the coords by an object relative to this objects transformation */ + float mtx_tx[4][4]; float mtx_tx_inv[4][4]; /* inverted */ float mtx_tmp_a[4][4]; |