diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2020-08-02 16:35:20 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2020-08-02 16:35:20 +0300 |
commit | b9845566b4b70222ea8e738cccb43cb5b7578759 (patch) | |
tree | 285ef05797ea77aeb652252578bd34be371146a3 /source | |
parent | 771da552bb4d56f551f576546ec2d1cbc1b863f7 (diff) | |
parent | 4f27e94146fdde945f5b09c9e4efe38ca760635f (diff) |
Merge branch 'master' into newboolean.
Also, make it possible to build when WITH_GMP is disabled.
Diffstat (limited to 'source')
178 files changed, 1355 insertions, 820 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 6fb6675a05a..301aa4538a7 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -123,22 +123,24 @@ void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[4][4], int root, int posed); -void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3]); -void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat[3][3]); +void vec_roll_to_mat3(const float vec[3], const float roll, float r_mat[3][3]); +void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float r_mat[3][3]); void mat3_to_vec_roll(const float mat[3][3], float r_vec[3], float *r_roll); void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll); /* Common Conversions Between Co-ordinate Spaces */ -void BKE_armature_mat_world_to_pose(struct Object *ob, float inmat[4][4], float outmat[4][4]); +void BKE_armature_mat_world_to_pose(struct Object *ob, + const float inmat[4][4], + float outmat[4][4]); void BKE_armature_loc_world_to_pose(struct Object *ob, const float inloc[3], float outloc[3]); void BKE_armature_mat_pose_to_bone(struct bPoseChannel *pchan, - float inmat[4][4], + const float inmat[4][4], float outmat[4][4]); void BKE_armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc[3], float outloc[3]); void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan, - float inmat[4][4], + const float inmat[4][4], float outmat[4][4]); void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], float pose_mat[4][4], @@ -147,13 +149,13 @@ void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph, struct Object *ob, struct bPoseChannel *pchan, - float inmat[4][4], + const float inmat[4][4], float outmat[4][4]); -void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat); -void BKE_pchan_rot_to_mat3(const struct bPoseChannel *pchan, float mat[3][3]); -void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat); -void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float chan_mat[4][4]); +void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, const float mat[3][3], bool use_compat); +void BKE_pchan_rot_to_mat3(const struct bPoseChannel *pchan, float r_mat[3][3]); +void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, const float mat[4][4], bool use_comat); +void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float r_mat[4][4]); void BKE_pchan_calc_mat(struct bPoseChannel *pchan); /* Simple helper, computes the offset bone matrix. */ diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index 0623e0e5395..936d01d1ea4 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -70,7 +70,7 @@ void BKE_curvemapping_changed(struct CurveMapping *cumap, const bool rem_doubles void BKE_curvemapping_changed_all(struct CurveMapping *cumap); /* call before _all_ evaluation functions */ -void BKE_curvemapping_initialize(struct CurveMapping *cumap); +void BKE_curvemapping_init(struct CurveMapping *cumap); /* keep these (const CurveMap) - to help with thread safety */ /* single curve, no table check */ diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index ca41e51984b..3f7b978287d 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -98,15 +98,15 @@ bool BKE_curve_minmax(struct Curve *cu, bool use_radius, float min[3], float max bool BKE_curve_center_median(struct Curve *cu, float cent[3]); bool BKE_curve_center_bounds(struct Curve *cu, float cent[3]); void BKE_curve_transform_ex(struct Curve *cu, - float mat[4][4], + const float mat[4][4], const bool do_keys, const bool do_props, const float unit_scale); void BKE_curve_transform(struct Curve *cu, - float mat[4][4], + const float mat[4][4], const bool do_keys, const bool do_props); -void BKE_curve_translate(struct Curve *cu, float offset[3], const bool do_keys); +void BKE_curve_translate(struct Curve *cu, const float offset[3], const bool do_keys); void BKE_curve_material_index_remove(struct Curve *cu, int index); bool BKE_curve_material_index_used(struct Curve *cu, int index); void BKE_curve_material_index_clear(struct Curve *cu); diff --git a/source/blender/blenkernel/BKE_curveprofile.h b/source/blender/blenkernel/BKE_curveprofile.h index 877ab887138..d7880e9ec43 100644 --- a/source/blender/blenkernel/BKE_curveprofile.h +++ b/source/blender/blenkernel/BKE_curveprofile.h @@ -72,7 +72,7 @@ void BKE_curveprofile_create_samples(struct CurveProfile *profile, bool sample_straight_edges, struct CurveProfilePoint *r_samples); -void BKE_curveprofile_initialize(struct CurveProfile *profile, short segments_len); +void BKE_curveprofile_init(struct CurveProfile *profile, short segments_len); /* Called for a complete update of the widget after modifications */ enum { diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h index 964764d99e7..c97461fb0c8 100644 --- a/source/blender/blenkernel/BKE_gpencil_geom.h +++ b/source/blender/blenkernel/BKE_gpencil_geom.h @@ -76,7 +76,7 @@ void BKE_gpencil_stroke_fill_triangulate(struct bGPDstroke *gps); void BKE_gpencil_stroke_geometry_update(struct bGPDstroke *gps); void BKE_gpencil_stroke_uv_update(struct bGPDstroke *gps); -void BKE_gpencil_transform(struct bGPdata *gpd, float mat[4][4]); +void BKE_gpencil_transform(struct bGPdata *gpd, const float mat[4][4]); typedef struct GPencilPointCoordinates { /* This is used when doing "move only origin" in object_data_transform.c. diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index bb23ad63020..fdcea95704f 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -67,8 +67,8 @@ void BKE_lattice_minmax_dl(struct Object *ob, struct Lattice *lt, float min[3], void BKE_lattice_minmax(struct Lattice *lt, float min[3], float max[3]); void BKE_lattice_center_median(struct Lattice *lt, float cent[3]); void BKE_lattice_center_bounds(struct Lattice *lt, float cent[3]); -void BKE_lattice_translate(struct Lattice *lt, float offset[3], bool do_keys); -void BKE_lattice_transform(struct Lattice *lt, float mat[4][4], bool do_keys); +void BKE_lattice_translate(struct Lattice *lt, const float offset[3], bool do_keys); +void BKE_lattice_transform(struct Lattice *lt, const float mat[4][4], bool do_keys); bool BKE_lattice_is_any_selected(const struct Lattice *lt); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index b2510be656e..e0bedd20617 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -231,7 +231,7 @@ void BKE_mesh_nomain_to_meshkey(struct Mesh *mesh_src, struct Mesh *mesh_dst, st /* vertex level transformations & checks (no derived mesh) */ bool BKE_mesh_minmax(const struct Mesh *me, float r_min[3], float r_max[3]); -void BKE_mesh_transform(struct Mesh *me, float mat[4][4], bool do_keys); +void BKE_mesh_transform(struct Mesh *me, const float mat[4][4], bool do_keys); void BKE_mesh_translate(struct Mesh *me, const float offset[3], const bool do_keys); void BKE_mesh_ensure_navmesh(struct Mesh *me); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index f2a022c84a3..7f2bdccf3a4 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -144,21 +144,21 @@ struct Object *BKE_object_duplicate(struct Main *bmain, void BKE_object_obdata_size_init(struct Object *ob, const float scale); -void BKE_object_scale_to_mat3(struct Object *ob, float mat[3][3]); -void BKE_object_rot_to_mat3(const struct Object *ob, float mat[3][3], bool use_drot); -void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat); -void BKE_object_to_mat3(struct Object *ob, float mat[3][3]); -void BKE_object_to_mat4(struct Object *ob, float mat[4][4]); +void BKE_object_scale_to_mat3(struct Object *ob, float r_mat[3][3]); +void BKE_object_rot_to_mat3(const struct Object *ob, float r_mat[3][3], bool use_drot); +void BKE_object_mat3_to_rot(struct Object *ob, float r_mat[3][3], bool use_compat); +void BKE_object_to_mat3(struct Object *ob, float r_mat[3][3]); +void BKE_object_to_mat4(struct Object *ob, float r_mat[4][4]); void BKE_object_apply_mat4(struct Object *ob, - float mat[4][4], + const float mat[4][4], const bool use_compat, const bool use_parent); void BKE_object_apply_mat4_ex(struct Object *ob, - float mat[4][4], + const float mat[4][4], struct Object *parent, - float parentinv[4][4], + const float parentinv[4][4], const bool use_compat); -void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]); +void BKE_object_matrix_local_get(struct Object *ob, float r_mat[4][4]); bool BKE_object_pose_context_check(const struct Object *ob); struct Object *BKE_object_pose_armature_get(struct Object *ob); @@ -188,7 +188,7 @@ struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_bases_len); -void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float parentmat[4][4]); +void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float r_parentmat[4][4]); void BKE_object_where_is_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); void BKE_object_where_is_calc_ex(struct Depsgraph *depsgraph, struct Scene *scene, @@ -199,7 +199,7 @@ void BKE_object_where_is_calc_time(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime); -void BKE_object_where_is_calc_mat4(struct Object *ob, float obmat[4][4]); +void BKE_object_where_is_calc_mat4(struct Object *ob, float r_obmat[4][4]); /* possibly belong in own moduke? */ struct BoundBox *BKE_boundbox_alloc_unit(void); @@ -207,12 +207,12 @@ void BKE_boundbox_init_from_minmax(struct BoundBox *bb, const float min[3], cons void BKE_boundbox_calc_center_aabb(const struct BoundBox *bb, float r_cent[3]); void BKE_boundbox_calc_size_aabb(const struct BoundBox *bb, float r_size[3]); void BKE_boundbox_minmax(const struct BoundBox *bb, - float obmat[4][4], + const float obmat[4][4], float r_min[3], float r_max[3]); struct BoundBox *BKE_object_boundbox_get(struct Object *ob); -void BKE_object_dimensions_get(struct Object *ob, float vec[3]); +void BKE_object_dimensions_get(struct Object *ob, float r_vec[3]); void BKE_object_dimensions_set_ex(struct Object *ob, const float value[3], int axis_mask, @@ -233,7 +233,7 @@ bool BKE_object_minmax_dupli(struct Depsgraph *depsgraph, /* sometimes min-max isn't enough, we need to loop over each point */ void BKE_object_foreach_display_point(struct Object *ob, - float obmat[4][4], + const float obmat[4][4], void (*func_cb)(const float[3], void *), void *user_data); void BKE_scene_foreach_display_point(struct Depsgraph *depsgraph, diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 7de588450d6..3c0ec8147fe 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -580,7 +580,7 @@ void psys_particle_on_dm(struct Mesh *mesh_final, /* particle_system.c */ void distribute_particles(struct ParticleSimulationData *sim, int from); -void initialize_particle(struct ParticleSimulationData *sim, struct ParticleData *pa); +void init_particle(struct ParticleSimulationData *sim, struct ParticleData *pa); void psys_calc_dmcache(struct Object *ob, struct Mesh *mesh_final, struct Mesh *mesh_original, diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index ea5a4bd99d1..5b5e32f1d81 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1150,7 +1150,7 @@ static int nlaevalchan_validate_index(NlaEvalChannel *nec, int index) return 0; } -/* Initialise default values for NlaEvalChannel from the property data. */ +/* Initialize default values for NlaEvalChannel from the property data. */ static void nlaevalchan_get_default_values(NlaEvalChannel *nec, float *r_values) { PointerRNA *ptr = &nec->key.ptr; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index bf04603aa46..c977ebe4ae2 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1382,7 +1382,7 @@ void get_objectspace_bone_matrix(struct Bone *bone, } /* Convert World-Space Matrix to Pose-Space Matrix */ -void BKE_armature_mat_world_to_pose(Object *ob, float inmat[4][4], float outmat[4][4]) +void BKE_armature_mat_world_to_pose(Object *ob, const float inmat[4][4], float outmat[4][4]) { float obmat[4][4]; @@ -1674,7 +1674,9 @@ void BKE_bone_parent_transform_apply(const struct BoneParentTransform *bpt, /* Convert Pose-Space Matrix to Bone-Space Matrix. * NOTE: this cannot be used to convert to pose-space transforms of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]) +void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, + const float inmat[4][4], + float outmat[4][4]) { BoneParentTransform bpt; @@ -1684,7 +1686,9 @@ void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[4][4], float } /* Convert Bone-Space Matrix to Pose-Space Matrix. */ -void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]) +void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, + const float inmat[4][4], + float outmat[4][4]) { BoneParentTransform bpt; @@ -1720,7 +1724,7 @@ void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], fl void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph, Object *ob, bPoseChannel *pchan, - float inmat[4][4], + const float inmat[4][4], float outmat[4][4]) { bPoseChannel work_pchan = *pchan; @@ -1741,7 +1745,7 @@ void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph, /** * Same as #BKE_object_mat3_to_rot(). */ -void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat) +void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, const float mat[3][3], bool use_compat) { BLI_ASSERT_UNIT_M3(mat); @@ -1766,17 +1770,17 @@ void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat /** * Same as #BKE_object_rot_to_mat3(). */ -void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3]) +void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float r_mat[3][3]) { /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */ if (pchan->rotmode > 0) { /* euler rotations (will cause gimble lock, * but this can be alleviated a bit with rotation orders) */ - eulO_to_mat3(mat, pchan->eul, pchan->rotmode); + eulO_to_mat3(r_mat, pchan->eul, pchan->rotmode); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - not really that great for 3D-changing orientations */ - axis_angle_to_mat3(mat, pchan->rotAxis, pchan->rotAngle); + axis_angle_to_mat3(r_mat, pchan->rotAxis, pchan->rotAngle); } else { /* quats are normalized before use to eliminate scaling issues */ @@ -1786,7 +1790,7 @@ void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3]) * since this was kindof evil in some cases but if this proves to be too problematic, * switch back to the old system of operating directly on the stored copy. */ normalize_qt_qt(quat, pchan->quat); - quat_to_mat3(mat, quat); + quat_to_mat3(r_mat, quat); } } @@ -1794,7 +1798,7 @@ void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3]) * Apply a 4x4 matrix to the pose bone, * similar to #BKE_object_apply_mat4(). */ -void BKE_pchan_apply_mat4(bPoseChannel *pchan, float mat[4][4], bool use_compat) +void BKE_pchan_apply_mat4(bPoseChannel *pchan, const float mat[4][4], bool use_compat) { float rot[3][3]; mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, mat); @@ -1998,7 +2002,7 @@ void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll) * └ -2 * x * z, x^2 - z^2 ┘ * </pre> */ -void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat[3][3]) +void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float r_mat[3][3]) { #define THETA_THRESHOLD_NEGY 1.0e-9f #define THETA_THRESHOLD_NEGY_CLOSE 1.0e-5f @@ -2052,18 +2056,18 @@ void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat axis_angle_normalized_to_mat3(rMatrix, nor, roll); /* Combine and output result */ - mul_m3_m3m3(mat, rMatrix, bMatrix); + mul_m3_m3m3(r_mat, rMatrix, bMatrix); #undef THETA_THRESHOLD_NEGY #undef THETA_THRESHOLD_NEGY_CLOSE } -void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3]) +void vec_roll_to_mat3(const float vec[3], const float roll, float r_mat[3][3]) { float nor[3]; normalize_v3_v3(nor, vec); - vec_roll_to_mat3_normalized(nor, roll, mat); + vec_roll_to_mat3_normalized(nor, roll, r_mat); } /** \} */ @@ -2418,8 +2422,10 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_ /** \name Pose Solver * \{ */ -/* loc/rot/size to given mat4 */ -void BKE_pchan_to_mat4(const bPoseChannel *pchan, float chan_mat[4][4]) +/** + * Convert the loc/rot/size to \a r_chanmat (typically #bPoseChannel.chan_mat). + */ +void BKE_pchan_to_mat4(const bPoseChannel *pchan, float r_chanmat[4][4]) { float smat[3][3]; float rmat[3][3]; @@ -2433,12 +2439,12 @@ void BKE_pchan_to_mat4(const bPoseChannel *pchan, float chan_mat[4][4]) /* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */ mul_m3_m3m3(tmat, rmat, smat); - copy_m4_m3(chan_mat, tmat); + copy_m4_m3(r_chanmat, tmat); /* prevent action channels breaking chains */ /* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */ if ((pchan->bone == NULL) || !(pchan->bone->flag & BONE_CONNECTED)) { - copy_v3_v3(chan_mat[3], pchan->loc); + copy_v3_v3(r_chanmat[3], pchan->loc); } } @@ -2576,7 +2582,7 @@ void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob) } /* 2a. construct the IK tree (standard IK) */ - BIK_initialize_tree(depsgraph, scene, ob, ctime); + BIK_init_tree(depsgraph, scene, ob, ctime); /* 2b. construct the Spline IK trees * - this is not integrated as an IK plugin, since it should be able diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index d66991aed70..97c717572bc 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -658,7 +658,7 @@ void BKE_pose_eval_init_ik(struct Depsgraph *depsgraph, Scene *scene, Object *ob return; } /* construct the IK tree (standard IK) */ - BIK_initialize_tree(depsgraph, scene, object, ctime); + BIK_init_tree(depsgraph, scene, object, ctime); /* construct the Spline IK trees * - this is not integrated as an IK plugin, since it should be able * to function in conjunction with standard IK. */ diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 355bdfd10fd..8178415a8f6 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -557,7 +557,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type) /* Curve. */ custom_curve = brush->gpencil_settings->curve_sensitivity; BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - BKE_curvemapping_initialize(custom_curve); + BKE_curvemapping_init(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INK); brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INK; @@ -594,7 +594,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type) /* Curve. */ custom_curve = brush->gpencil_settings->curve_sensitivity; BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - BKE_curvemapping_initialize(custom_curve); + BKE_curvemapping_init(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INKNOISE); brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INKNOISE; @@ -631,7 +631,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type) /* Curve. */ custom_curve = brush->gpencil_settings->curve_sensitivity; BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - BKE_curvemapping_initialize(custom_curve); + BKE_curvemapping_init(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_MARKER); brush->gpencil_settings->icon_id = GP_BRUSH_ICON_MARKER; @@ -667,12 +667,12 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type) /* Curve. */ custom_curve = brush->gpencil_settings->curve_sensitivity; BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - BKE_curvemapping_initialize(custom_curve); + BKE_curvemapping_init(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_CHISEL_SENSIVITY); custom_curve = brush->gpencil_settings->curve_strength; BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - BKE_curvemapping_initialize(custom_curve); + BKE_curvemapping_init(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_CHISEL_STRENGTH); brush->gpencil_settings->icon_id = GP_BRUSH_ICON_CHISEL; @@ -2274,7 +2274,7 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary, bool int half = side / 2; int i, j; - BKE_curvemapping_initialize(br->curve); + BKE_curvemapping_init(br->curve); texcache = BKE_brush_gen_texture_cache(br, half, secondary); im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect"); im->x = im->y = side; diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 4f4eb8f9f9d..fc326ffb390 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -1202,7 +1202,7 @@ int BKE_curvemapping_RGBA_does_something(const CurveMapping *cumap) return 0; } -void BKE_curvemapping_initialize(CurveMapping *cumap) +void BKE_curvemapping_init(CurveMapping *cumap) { int a; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index acc3c52c08c..e126fb7f632 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -5110,8 +5110,11 @@ bool BKE_curve_center_bounds(Curve *cu, float cent[3]) return false; } -void BKE_curve_transform_ex( - Curve *cu, float mat[4][4], const bool do_keys, const bool do_props, const float unit_scale) +void BKE_curve_transform_ex(Curve *cu, + const float mat[4][4], + const bool do_keys, + const bool do_props, + const float unit_scale) { Nurb *nu; BPoint *bp; @@ -5174,13 +5177,13 @@ void BKE_curve_transform_ex( } } -void BKE_curve_transform(Curve *cu, float mat[4][4], const bool do_keys, const bool do_props) +void BKE_curve_transform(Curve *cu, const float mat[4][4], const bool do_keys, const bool do_props) { float unit_scale = mat4_to_scale(mat); BKE_curve_transform_ex(cu, mat, do_keys, do_props, unit_scale); } -void BKE_curve_translate(Curve *cu, float offset[3], const bool do_keys) +void BKE_curve_translate(Curve *cu, const float offset[3], const bool do_keys) { ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; diff --git a/source/blender/blenkernel/intern/curveprofile.c b/source/blender/blenkernel/intern/curveprofile.c index 8577990dc03..0a41529aac1 100644 --- a/source/blender/blenkernel/intern/curveprofile.c +++ b/source/blender/blenkernel/intern/curveprofile.c @@ -1040,7 +1040,7 @@ void BKE_curveprofile_update(CurveProfile *profile, const int update_flags) * Also sets the number of segments used for the display preview of the locations * of the sampled points. */ -void BKE_curveprofile_initialize(CurveProfile *profile, short segments_len) +void BKE_curveprofile_init(CurveProfile *profile, short segments_len) { if (segments_len != profile->segments_len) { profile->flag |= PROF_DIRTY_PRESET; @@ -1055,7 +1055,7 @@ void BKE_curveprofile_initialize(CurveProfile *profile, short segments_len) * Gives the distance to the next point in the widgets sampled table, in other words the length * of the \a 'i' edge of the table. * - * \note Requires curveprofile_initialize or #BKE_curveprofile_update call before to fill table. + * \note Requires #BKE_curveprofile_init or #BKE_curveprofile_update call before to fill table. */ static float curveprofile_distance_to_next_table_point(const CurveProfile *profile, int i) { @@ -1067,7 +1067,7 @@ static float curveprofile_distance_to_next_table_point(const CurveProfile *profi /** * Calculates the total length of the profile from the curves sampled in the table. * - * \note Requires curveprofile_initialize or #BKE_curveprofile_update call before to fill table. + * \note Requires #BKE_curveprofile_init or #BKE_curveprofile_update call before to fill table. */ float BKE_curveprofile_total_length(const CurveProfile *profile) { @@ -1082,7 +1082,7 @@ float BKE_curveprofile_total_length(const CurveProfile *profile) * Samples evenly spaced positions along the curve profile's table (generated from path). Fills * an entire table at once for a speedup if all of the results are going to be used anyway. * - * \note Requires curveprofile_initialize or #BKE_curveprofile_update call before to fill table. + * \note Requires #BKE_curveprofile_init or #BKE_curveprofile_update call before to fill table. * \note Working, but would conflict with "Sample Straight Edges" option, so this is unused for * now. */ @@ -1145,7 +1145,7 @@ void BKE_curveprofile_create_samples_even_spacing(CurveProfile *profile, * Travels down (length_portion * path) length and returns the position at that point. * * \param length_portion: The portion (0 to 1) of the path's full length to sample at. - * \note Requires curveprofile_initialize or #BKE_curveprofile_update call before to fill table. + * \note Requires #BKE_curveprofile_init or #BKE_curveprofile_update call before to fill table. */ void BKE_curveprofile_evaluate_length_portion(const CurveProfile *profile, float length_portion, diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 079b436a3ea..ad517fe1c23 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -1119,6 +1119,7 @@ static void ensure_obstaclefields(FluidDomainSettings *fds) if (fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE) { manta_ensure_guiding(fds->fluid, fds->fmd); } + manta_update_pointers(fds->fluid, fds->fmd); } static void update_obstacleflags(FluidDomainSettings *fds, @@ -2596,7 +2597,7 @@ static void ensure_flowsfields(FluidDomainSettings *fds) manta_smoke_ensure_fire(fds->fluid, fds->fmd); } if (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) { - /* initialize all smoke with "active_color" */ + /* Initialize all smoke with "active_color". */ manta_smoke_ensure_colors(fds->fluid, fds->fmd); } if (fds->type == FLUID_DOMAIN_TYPE_LIQUID && @@ -2605,6 +2606,7 @@ static void ensure_flowsfields(FluidDomainSettings *fds) fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER)) { manta_liquid_ensure_sndparts(fds->fluid, fds->fmd); } + manta_update_pointers(fds->fluid, fds->fmd); } static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int numflowobj) @@ -2617,7 +2619,7 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n FLUID_DOMAIN_ACTIVE_HEAT | FLUID_DOMAIN_ACTIVE_FIRE); active_fields &= ~prev_flags; - /* Monitor active fields based on flow settings */ + /* Monitor active fields based on flow settings. */ for (flow_index = 0; flow_index < numflowobj; flow_index++) { Object *flow_ob = flowobjs[flow_index]; FluidModifierData *fmd2 = (FluidModifierData *)BKE_modifiers_findby_type(flow_ob, @@ -2628,6 +2630,7 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n continue; } + /* Activate specific grids if at least one flow object requires this grid. */ if ((fmd2->type & MOD_FLUID_TYPE_FLOW) && fmd2->flow) { FluidFlowSettings *ffs = fmd2->flow; if (!ffs) { @@ -2648,17 +2651,17 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n continue; } - /* activate heat field if flow produces any heat */ - if (ffs->temperature) { + /* Activate heat field if a flow object produces any heat. */ + if (ffs->temperature != 0.0) { active_fields |= FLUID_DOMAIN_ACTIVE_HEAT; } - /* activate fuel field if flow adds any fuel */ - if (ffs->fuel_amount && - (ffs->type == FLUID_FLOW_TYPE_FIRE || ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE)) { + /* Activate fuel field if a flow object is of fire type. */ + if (ffs->fuel_amount != 0.0 || ffs->type == FLUID_FLOW_TYPE_FIRE || + ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE) { active_fields |= FLUID_DOMAIN_ACTIVE_FIRE; } - /* activate color field if flows add smoke with varying colors */ - if (ffs->density && + /* Activate color field if flows add smoke with varying colors. */ + if (ffs->density != 0.0 && (ffs->type == FLUID_FLOW_TYPE_SMOKE || ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE)) { if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) { copy_v3_v3(fds->active_color, ffs->color); @@ -2671,11 +2674,11 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n } } } - /* Monitor active fields based on domain settings */ + /* Monitor active fields based on domain settings. */ if (fds->type == FLUID_DOMAIN_TYPE_GAS && active_fields & FLUID_DOMAIN_ACTIVE_FIRE) { - /* heat is always needed for fire */ + /* Heat is always needed for fire. */ active_fields |= FLUID_DOMAIN_ACTIVE_HEAT; - /* also activate colors if domain smoke color differs from active color */ + /* Also activate colors if domain smoke color differs from active color. */ if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) { copy_v3_v3(fds->active_color, fds->flame_smoke_color); active_fields |= FLUID_DOMAIN_ACTIVE_COLOR_SET; @@ -3617,14 +3620,16 @@ static int manta_step( fds->time_per_frame = time_per_frame; fds->time_total = time_total; } + /* Total time must not exceed framecount times framelength. Correct tiny errors here. */ CLAMP(fds->time_total, fds->time_total, time_total_old + fds->frame_length); + /* Compute shadow grid for gas simulations. Make sure to skip if bake job was canceled early. */ if (fds->type == FLUID_DOMAIN_TYPE_GAS && result) { manta_smoke_calc_transparency(fds, DEG_get_evaluated_view_layer(depsgraph)); } - BLI_mutex_unlock(&object_update_lock); + BLI_mutex_unlock(&object_update_lock); return result; } @@ -4073,6 +4078,9 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd, } } + /* Ensure that fluid pointers are always up to date at the end of modifier processing. */ + manta_update_pointers(fds->fluid, fmd); + fds->flags &= ~FLUID_DOMAIN_FILE_LOAD; fmd->time = scene_framenr; } diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 53bfd3aa8ff..14eb6bb4f4c 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -2427,7 +2427,7 @@ void BKE_gpencil_convert_mesh(Main *bmain, * \param gpd: Grease pencil data-block * \param mat: Transformation matrix */ -void BKE_gpencil_transform(bGPdata *gpd, float mat[4][4]) +void BKE_gpencil_transform(bGPdata *gpd, const float mat[4][4]) { if (gpd == NULL) { return; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index fa0be9ea441..e331e5ae1dd 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -3942,7 +3942,7 @@ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr) #endif /* WITH_OPENEXR */ /* common stuff to do with images after loading */ -static void image_initialize_after_load(Image *ima, ImageUser *iuser, ImBuf *UNUSED(ibuf)) +static void image_init_after_load(Image *ima, ImageUser *iuser, ImBuf *UNUSED(ibuf)) { /* Preview is NULL when it has never been used as an icon before. * Never handle previews/icons outside of main thread. */ @@ -4045,11 +4045,11 @@ static ImBuf *load_sequence_single( } } else { - image_initialize_after_load(ima, iuser, ibuf); + image_init_after_load(ima, iuser, ibuf); *r_assign = true; } #else - image_initialize_after_load(ima, iuser, ibuf); + image_init_after_load(ima, iuser, ibuf); *r_assign = true; #endif } @@ -4154,7 +4154,7 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int e BKE_imbuf_stamp_info(ima->rr, ibuf); - image_initialize_after_load(ima, iuser, ibuf); + image_init_after_load(ima, iuser, ibuf); image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, entry); } // else printf("pass not found\n"); @@ -4218,7 +4218,7 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i ibuf = IMB_makeSingleUser(IMB_anim_absolute(ia->anim, fra, IMB_TC_RECORD_RUN, IMB_PROXY_NONE)); if (ibuf) { - image_initialize_after_load(ima, iuser, ibuf); + image_init_after_load(ima, iuser, ibuf); } else { tile->ok = 0; @@ -4363,7 +4363,7 @@ static ImBuf *load_image_single(Image *ima, else #endif { - image_initialize_after_load(ima, iuser, ibuf); + image_init_after_load(ima, iuser, ibuf); *r_assign = true; /* make packed file for autopack */ @@ -4477,7 +4477,7 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) if (rpass) { ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); - image_initialize_after_load(ima, iuser, ibuf); + image_init_after_load(ima, iuser, ibuf); ibuf->rect_float = rpass->rect; ibuf->flags |= IB_rectfloat; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 8820434cbcf..4d523ffa2e0 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -672,7 +672,7 @@ void BKE_lattice_center_bounds(Lattice *lt, float cent[3]) mid_v3_v3v3(cent, min, max); } -void BKE_lattice_transform(Lattice *lt, float mat[4][4], bool do_keys) +void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys) { BPoint *bp = lt->def; int i = lt->pntsu * lt->pntsv * lt->pntsw; @@ -694,7 +694,7 @@ void BKE_lattice_transform(Lattice *lt, float mat[4][4], bool do_keys) } } -void BKE_lattice_translate(Lattice *lt, float offset[3], bool do_keys) +void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys) { int i, numVerts; diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 64649d84320..83071fd5dd3 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -221,7 +221,7 @@ ViewLayer *BKE_view_layer_add(Scene *scene, view_layer_new = view_layer_add(name); BLI_addtail(&scene->view_layers, view_layer_new); - /* Initialise layercollections */ + /* Initialize layer-collections. */ BKE_layer_collection_sync(scene, view_layer_new); layer_collection_exclude_all(view_layer_new->layer_collections.first); diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index aa1005c663f..f42df6765c4 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -58,7 +58,7 @@ static void light_init_data(ID *id) MEMCPY_STRUCT_AFTER(la, DNA_struct_default_get(Light), id); la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); - BKE_curvemapping_initialize(la->curfalloff); + BKE_curvemapping_init(la->curfalloff); } /** diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c index ad178e76ef6..72b99bea0f4 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.c +++ b/source/blender/blenkernel/intern/mball_tessellate.c @@ -315,7 +315,7 @@ static float densfunc(const MetaElem *ball, float x, float y, float z) float dist2; float dvec[3] = {x, y, z}; - mul_m4_v3((float(*)[4])ball->imat, dvec); + mul_m4_v3((const float(*)[4])ball->imat, dvec); switch (ball->type) { case MB_BALL: diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 48baedadd73..048af022adb 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1305,7 +1305,7 @@ bool BKE_mesh_minmax(const Mesh *me, float r_min[3], float r_max[3]) return (me->totvert != 0); } -void BKE_mesh_transform(Mesh *me, float mat[4][4], bool do_keys) +void BKE_mesh_transform(Mesh *me, const float mat[4][4], bool do_keys) { int i; MVert *mvert = me->mvert; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 71d49dd1c19..6c10f6de855 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -241,7 +241,7 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level) md->hidden = subd; } -static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level) +static MDisps *multires_mdisps_init_hidden(Mesh *me, int level) { MDisps *mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_CALLOC, NULL, me->totloop); int gridsize = BKE_ccg_gridsize(level); @@ -868,7 +868,7 @@ static void multires_subdivide_legacy( mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); if (!mdisps) { - mdisps = multires_mdisps_initialize_hidden(me, totlvl); + mdisps = multires_mdisps_init_hidden(me, totlvl); } if (mdisps->disps && !updateblock && lvl != 0) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f77c79a2be7..fe559d2a44e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2344,7 +2344,7 @@ void BKE_object_tfm_copy(Object *object_dst, const Object *object_src) #undef TFMCPY4D } -void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */ +void BKE_object_to_mat3(Object *ob, float r_mat[3][3]) /* no parent */ { float smat[3][3]; float rmat[3][3]; @@ -2355,38 +2355,38 @@ void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */ /* rot */ BKE_object_rot_to_mat3(ob, rmat, true); - mul_m3_m3m3(mat, rmat, smat); + mul_m3_m3m3(r_mat, rmat, smat); } -void BKE_object_to_mat4(Object *ob, float mat[4][4]) +void BKE_object_to_mat4(Object *ob, float r_mat[4][4]) { float tmat[3][3]; BKE_object_to_mat3(ob, tmat); - copy_m4_m3(mat, tmat); + copy_m4_m3(r_mat, tmat); - add_v3_v3v3(mat[3], ob->loc, ob->dloc); + add_v3_v3v3(r_mat[3], ob->loc, ob->dloc); } -void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]) +void BKE_object_matrix_local_get(struct Object *ob, float r_mat[4][4]) { if (ob->parent) { float par_imat[4][4]; BKE_object_get_parent_matrix(ob, ob->parent, par_imat); invert_m4(par_imat); - mul_m4_m4m4(mat, par_imat, ob->obmat); + mul_m4_m4m4(r_mat, par_imat, ob->obmat); } else { - copy_m4_m4(mat, ob->obmat); + copy_m4_m4(r_mat, ob->obmat); } } /** * \return success if \a mat is set. */ -static bool ob_parcurve(Object *ob, Object *par, float mat[4][4]) +static bool ob_parcurve(Object *ob, Object *par, float r_mat[4][4]) { Curve *cu = par->data; float vec[4], dir[3], quat[4], radius, ctime; @@ -2420,34 +2420,34 @@ static bool ob_parcurve(Object *ob, Object *par, float mat[4][4]) } CLAMP(ctime, 0.0f, 1.0f); - unit_m4(mat); + unit_m4(r_mat); /* vec: 4 items! */ if (where_on_path(par, ctime, vec, dir, (cu->flag & CU_FOLLOW) ? quat : NULL, &radius, NULL)) { if (cu->flag & CU_FOLLOW) { quat_apply_track(quat, ob->trackflag, ob->upflag); normalize_qt(quat); - quat_to_mat4(mat, quat); + quat_to_mat4(r_mat, quat); } if (cu->flag & CU_PATH_RADIUS) { float tmat[4][4], rmat[4][4]; scale_m4_fl(tmat, radius); - mul_m4_m4m4(rmat, tmat, mat); - copy_m4_m4(mat, rmat); + mul_m4_m4m4(rmat, tmat, r_mat); + copy_m4_m4(r_mat, rmat); } - copy_v3_v3(mat[3], vec); + copy_v3_v3(r_mat[3], vec); } return true; } -static void ob_parbone(Object *ob, Object *par, float mat[4][4]) +static void ob_parbone(Object *ob, Object *par, float r_mat[4][4]) { bPoseChannel *pchan; float vec[3]; if (par->type != OB_ARMATURE) { - unit_m4(mat); + unit_m4(r_mat); return; } @@ -2456,7 +2456,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[4][4]) if (!pchan || !pchan->bone) { CLOG_ERROR( &LOG, "Object %s with Bone parent: bone %s doesn't exist", ob->id.name + 2, ob->parsubstr); - unit_m4(mat); + unit_m4(r_mat); return; } @@ -2464,15 +2464,15 @@ static void ob_parbone(Object *ob, Object *par, float mat[4][4]) if (pchan->bone->flag & BONE_RELATIVE_PARENTING) { /* the new option uses the root - expected behavior, but differs from old... */ /* XXX check on version patching? */ - copy_m4_m4(mat, pchan->chan_mat); + copy_m4_m4(r_mat, pchan->chan_mat); } else { - copy_m4_m4(mat, pchan->pose_mat); + copy_m4_m4(r_mat, pchan->pose_mat); /* but for backwards compatibility, the child has to move to the tail */ - copy_v3_v3(vec, mat[1]); + copy_v3_v3(vec, r_mat[1]); mul_v3_fl(vec, pchan->bone->length); - add_v3_v3(mat[3], vec); + add_v3_v3(r_mat[3], vec); } } @@ -2594,7 +2594,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) } } -static void ob_parvert3(Object *ob, Object *par, float mat[4][4]) +static void ob_parvert3(Object *ob, Object *par, float r_mat[4][4]) { /* in local ob space */ @@ -2607,16 +2607,16 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4]) tri_to_quat(q, v1, v2, v3); quat_to_mat3(cmat, q); - copy_m4_m3(mat, cmat); + copy_m4_m3(r_mat, cmat); - mid_v3_v3v3v3(mat[3], v1, v2, v3); + mid_v3_v3v3v3(r_mat[3], v1, v2, v3); } else { - unit_m4(mat); + unit_m4(r_mat); } } -void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4]) +void BKE_object_get_parent_matrix(Object *ob, Object *par, float r_parentmat[4][4]) { float tmat[4][4]; float vec[3]; @@ -2632,31 +2632,31 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4] } if (ok) { - mul_m4_m4m4(parentmat, par->obmat, tmat); + mul_m4_m4m4(r_parentmat, par->obmat, tmat); } else { - copy_m4_m4(parentmat, par->obmat); + copy_m4_m4(r_parentmat, par->obmat); } break; case PARBONE: ob_parbone(ob, par, tmat); - mul_m4_m4m4(parentmat, par->obmat, tmat); + mul_m4_m4m4(r_parentmat, par->obmat, tmat); break; case PARVERT1: - unit_m4(parentmat); + unit_m4(r_parentmat); give_parvert(par, ob->par1, vec); - mul_v3_m4v3(parentmat[3], par->obmat, vec); + mul_v3_m4v3(r_parentmat[3], par->obmat, vec); break; case PARVERT3: ob_parvert3(ob, par, tmat); - mul_m4_m4m4(parentmat, par->obmat, tmat); + mul_m4_m4m4(r_parentmat, par->obmat, tmat); break; case PARSKEL: - copy_m4_m4(parentmat, par->obmat); + copy_m4_m4(r_parentmat, par->obmat); break; } } @@ -2672,7 +2672,7 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4] * (without its own matrix applied) */ static void solve_parenting( - Object *ob, Object *par, float obmat[4][4], float r_originmat[3][3], const bool set_origin) + Object *ob, Object *par, const bool set_origin, float r_obmat[4][4], float r_originmat[3][3]) { float totmat[4][4]; float tmat[4][4]; @@ -2684,7 +2684,7 @@ static void solve_parenting( /* total */ mul_m4_m4m4(tmat, totmat, ob->parentinv); - mul_m4_m4m4(obmat, tmat, locmat); + mul_m4_m4m4(r_obmat, tmat, locmat); if (r_originmat) { /* usable originmat */ @@ -2714,7 +2714,7 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph, Object *par = ob->parent; /* calculate parent matrix */ - solve_parenting(ob, par, ob->obmat, r_originmat, true); + solve_parenting(ob, par, true, ob->obmat, r_originmat); } else { BKE_object_to_mat4(ob, ob->obmat); @@ -2757,14 +2757,14 @@ void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *o * constraints -- assume dependencies are already solved by depsgraph. * no changes to object and it's parent would be done. * used for bundles orientation in 3d space relative to parented blender camera */ -void BKE_object_where_is_calc_mat4(Object *ob, float obmat[4][4]) +void BKE_object_where_is_calc_mat4(Object *ob, float r_obmat[4][4]) { if (ob->parent) { Object *par = ob->parent; - solve_parenting(ob, par, obmat, NULL, false); + solve_parenting(ob, par, false, r_obmat, NULL); } else { - BKE_object_to_mat4(ob, obmat); + BKE_object_to_mat4(ob, r_obmat); } } @@ -2825,8 +2825,11 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o * \param use_compat: true to ensure that rotations are set using the * min difference between the old and new orientation. */ -void BKE_object_apply_mat4_ex( - Object *ob, float mat[4][4], Object *parent, float parentinv[4][4], const bool use_compat) +void BKE_object_apply_mat4_ex(Object *ob, + const float mat[4][4], + Object *parent, + const float parentinv[4][4], + const bool use_compat) { /* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */ @@ -2867,7 +2870,7 @@ void BKE_object_apply_mat4_ex( /* XXX: should be removed after COW operators port to use BKE_object_apply_mat4_ex directly */ void BKE_object_apply_mat4(Object *ob, - float mat[4][4], + const float mat[4][4], const bool use_compat, const bool use_parent) { @@ -2917,7 +2920,10 @@ void BKE_boundbox_calc_size_aabb(const BoundBox *bb, float r_size[3]) r_size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]); } -void BKE_boundbox_minmax(const BoundBox *bb, float obmat[4][4], float r_min[3], float r_max[3]) +void BKE_boundbox_minmax(const BoundBox *bb, + const float obmat[4][4], + float r_min[3], + float r_max[3]) { int i; for (i = 0; i < 8; i++) { @@ -3009,7 +3015,7 @@ void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval) * \warning Setting dimensions is prone to feedback loops in evaluation. * \{ */ -void BKE_object_dimensions_get(Object *ob, float vec[3]) +void BKE_object_dimensions_get(Object *ob, float r_vec[3]) { BoundBox *bb = NULL; @@ -3019,12 +3025,12 @@ void BKE_object_dimensions_get(Object *ob, float vec[3]) mat4_to_size(scale, ob->obmat); - vec[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); - vec[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); - vec[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]); + r_vec[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); + r_vec[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); + r_vec[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]); } else { - zero_v3(vec); + zero_v3(r_vec); } } @@ -3293,7 +3299,7 @@ bool BKE_object_minmax_dupli(Depsgraph *depsgraph, } void BKE_object_foreach_display_point(Object *ob, - float obmat[4][4], + const float obmat[4][4], void (*func_cb)(const float[3], void *), void *user_data) { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a003daf1042..1df5cda0ce5 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3871,7 +3871,7 @@ void BKE_particlesettings_clump_curve_init(ParticleSettings *part) cumap->cm[0].curve[1].x = 1.0f; cumap->cm[0].curve[1].y = 1.0f; - BKE_curvemapping_initialize(cumap); + BKE_curvemapping_init(cumap); part->clumpcurve = cumap; } @@ -3885,7 +3885,7 @@ void BKE_particlesettings_rough_curve_init(ParticleSettings *part) cumap->cm[0].curve[1].x = 1.0f; cumap->cm[0].curve[1].y = 1.0f; - BKE_curvemapping_initialize(cumap); + BKE_curvemapping_init(cumap); part->roughcurve = cumap; } @@ -3899,7 +3899,7 @@ void BKE_particlesettings_twist_curve_init(ParticleSettings *part) cumap->cm[0].curve[1].x = 1.0f; cumap->cm[0].curve[1].y = 1.0f; - BKE_curvemapping_initialize(cumap); + BKE_curvemapping_init(cumap); part->twistcurve = cumap; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index bec9cbbad79..6bfbb4b9d00 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -570,7 +570,7 @@ void psys_thread_context_free(ParticleThreadContext *ctx) } } -static void initialize_particle_texture(ParticleSimulationData *sim, ParticleData *pa, int p) +static void init_particle_texture(ParticleSimulationData *sim, ParticleData *pa, int p) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; @@ -595,7 +595,7 @@ static void initialize_particle_texture(ParticleSimulationData *sim, ParticleDat } /* set particle parameters that don't change during particle's life */ -void initialize_particle(ParticleSimulationData *sim, ParticleData *pa) +void init_particle(ParticleSimulationData *sim, ParticleData *pa) { ParticleSettings *part = sim->psys->part; float birth_time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart; @@ -629,7 +629,7 @@ static void initialize_all_particles(ParticleSimulationData *sim) LOOP_PARTICLES { if (!(emit_from_volume_grid && (pa->flag & PARS_UNEXIST) != 0)) { - initialize_particle(sim, pa); + init_particle(sim, pa); } } } @@ -1092,7 +1092,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, * We could only do it now because we'll need to know coordinate * before sampling the texture. */ - initialize_particle_texture(sim, pa, p); + init_particle_texture(sim, pa, p); if (part->phystype == PART_PHYS_BOIDS && pa->boid) { BoidParticle *bpa = pa->boid; @@ -4584,7 +4584,7 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_ psys->dt_frac = get_base_time_step(part); } else if ((int)cfra == startframe) { - /* Variable time step; initialise to subframes */ + /* Variable time step; initialize to sub-frames. */ psys->dt_frac = get_base_time_step(part); } else if (psys->dt_frac < MIN_TIMESTEP) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 5ae2f4b9005..fdec29dd43e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -127,7 +127,7 @@ static void scene_init_data(ID *id) mblur_shutter_curve = &scene->r.mblur_shutter_curve; BKE_curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f); - BKE_curvemapping_initialize(mblur_shutter_curve); + BKE_curvemapping_init(mblur_shutter_curve); BKE_curvemap_reset(mblur_shutter_curve->cm, &mblur_shutter_curve->clipr, CURVE_PRESET_MAX, @@ -140,13 +140,13 @@ static void scene_init_data(ID *id) /* grease pencil multiframe falloff curve */ scene->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_falloff_curve = scene->toolsettings->gp_sculpt.cur_falloff; - BKE_curvemapping_initialize(gp_falloff_curve); + BKE_curvemapping_init(gp_falloff_curve); BKE_curvemap_reset( gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, CURVEMAP_SLOPE_POSITIVE); scene->toolsettings->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_primitive_curve = scene->toolsettings->gp_sculpt.cur_primitive; - BKE_curvemapping_initialize(gp_primitive_curve); + BKE_curvemapping_init(gp_primitive_curve); BKE_curvemap_reset(gp_primitive_curve->cm, &gp_primitive_curve->clipr, CURVE_PRESET_BELL, diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index a630170d6d5..0bf7fffb833 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -396,7 +396,7 @@ static void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *m float black[3] = {0.0f, 0.0f, 0.0f}; float white[3] = {1.0f, 1.0f, 1.0f}; - BKE_curvemapping_initialize(&cmd->curve_mapping); + BKE_curvemapping_init(&cmd->curve_mapping); BKE_curvemapping_premultiply(&cmd->curve_mapping, 0); BKE_curvemapping_set_black_white(&cmd->curve_mapping, black, white); @@ -525,7 +525,7 @@ static void hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImB { HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; - BKE_curvemapping_initialize(&hcmd->curve_mapping); + BKE_curvemapping_init(&hcmd->curve_mapping); modifier_apply_threaded(ibuf, mask, hue_correct_apply_threaded, &hcmd->curve_mapping); } diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c index e09e92588c6..b9c6bb83157 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.c +++ b/source/blender/blenkernel/intern/tracking_stabilize.c @@ -215,7 +215,7 @@ static void use_values_from_fcurves(StabContext *ctx, bool toggle) /* Prepare per call private working area. * Used for access to possibly animated values: retrieve available F-curves. */ -static StabContext *initialize_stabilization_working_context(MovieClip *clip) +static StabContext *init_stabilization_working_context(MovieClip *clip) { StabContext *ctx = MEM_callocN(sizeof(StabContext), "2D stabilization animation runtime data"); ctx->clip = clip; @@ -841,14 +841,14 @@ static int establish_track_initialization_order(StabContext *ctx, TrackInitOrder * * NOTE: when done, this track is marked as initialized */ -static void initialize_track_for_stabilization(StabContext *ctx, - MovieTrackingTrack *track, - int reference_frame, - float aspect, - const float average_translation[2], - const float pivot[2], - const float average_angle, - const float average_scale_step) +static void init_track_for_stabilization(StabContext *ctx, + MovieTrackingTrack *track, + int reference_frame, + float aspect, + const float average_translation[2], + const float pivot[2], + const float average_angle, + const float average_scale_step) { float pos[2], angle, len; TrackStabilizationBase *local_data = access_stabilization_baseline_data(ctx, track); @@ -876,7 +876,7 @@ static void initialize_track_for_stabilization(StabContext *ctx, local_data->is_init_for_stabilization = true; } -static void initialize_all_tracks(StabContext *ctx, float aspect) +static void init_all_tracks(StabContext *ctx, float aspect) { size_t track_len = 0; MovieClip *clip = ctx->clip; @@ -936,14 +936,14 @@ static void initialize_all_tracks(StabContext *ctx, float aspect) &average_angle, &average_scale_step); } - initialize_track_for_stabilization(ctx, - track, - reference_frame, - aspect, - average_translation, - pivot, - average_angle, - average_scale_step); + init_track_for_stabilization(ctx, + track, + reference_frame, + aspect, + average_translation, + pivot, + average_angle, + average_scale_step); } cleanup: @@ -1257,9 +1257,9 @@ static float calculate_autoscale_factor(StabContext *ctx, int size, float aspect */ static StabContext *init_stabilizer(MovieClip *clip, int size, float aspect) { - StabContext *ctx = initialize_stabilization_working_context(clip); + StabContext *ctx = init_stabilization_working_context(clip); BLI_assert(ctx != NULL); - initialize_all_tracks(ctx, aspect); + init_all_tracks(ctx, aspect); if (ctx->stab->flag & TRACKING_AUTOSCALE) { ctx->stab->scale = 1.0; ctx->stab->scale = calculate_autoscale_factor(ctx, size, aspect); diff --git a/source/blender/blenlib/BLI_boolean.hh b/source/blender/blenlib/BLI_boolean.hh index 13fffcee634..2b39f494950 100644 --- a/source/blender/blenlib/BLI_boolean.hh +++ b/source/blender/blenlib/BLI_boolean.hh @@ -21,8 +21,11 @@ * \ingroup bli */ -#include "BLI_mesh_intersect.hh" -#include <functional> +/* The boolean functions in Blenlib use exact arithmetic, so require GMP. */ +#ifdef WITH_GMP + +# include "BLI_mesh_intersect.hh" +# include <functional> namespace blender::meshintersect { @@ -70,4 +73,6 @@ Mesh boolean_trimesh(Mesh &tm, MArena *arena); } // namespace blender::meshintersect + +#endif /* WITH_GMP */ #endif /* __BLI_BOOLEAN_HH__ */ diff --git a/source/blender/blenlib/BLI_delaunay_2d.h b/source/blender/blenlib/BLI_delaunay_2d.h index edbb7cc692d..d5b5e8f59db 100644 --- a/source/blender/blenlib/BLI_delaunay_2d.h +++ b/source/blender/blenlib/BLI_delaunay_2d.h @@ -218,9 +218,13 @@ template<typename Arith_t> struct vec2_impl; template<> struct vec2_impl<double> { typedef double2 type; }; + +# ifdef WITH_GMP template<> struct vec2_impl<mpq_class> { typedef mpq2 type; }; +# endif + template<typename Arith_t> using vec2 = typename vec2_impl<Arith_t>::type; template<typename Arith_t> class CDT_input { @@ -255,8 +259,10 @@ template<typename Arith_t> class CDT_result { CDT_result<double> delaunay_2d_calc(const CDT_input<double> &input, CDT_output_type output_type); +# ifdef WITH_GMP CDT_result<mpq_class> delaunay_2d_calc(const CDT_input<mpq_class> &input, CDT_output_type output_type); +# endif } /* namespace blender::meshintersect */ diff --git a/source/blender/blenlib/BLI_dial_2d.h b/source/blender/blenlib/BLI_dial_2d.h index a39543720e6..83467881eb5 100644 --- a/source/blender/blenlib/BLI_dial_2d.h +++ b/source/blender/blenlib/BLI_dial_2d.h @@ -38,7 +38,7 @@ * float angle; * Dial *dial; * - * dial = BLI_dial_initialize(start_position, threshold); + * dial = BLI_dial_init(start_position, threshold); * * angle = BLI_dial_angle(dial, current_position); * @@ -52,7 +52,7 @@ extern "C" { typedef struct Dial Dial; -Dial *BLI_dial_initialize(const float start_position[2], float threshold); +Dial *BLI_dial_init(const float start_position[2], float threshold); float BLI_dial_angle(Dial *dial, const float current_position[2]); diff --git a/source/blender/blenlib/BLI_math_mpq.hh b/source/blender/blenlib/BLI_math_mpq.hh index 06fa0a2e257..cec2a8956f2 100644 --- a/source/blender/blenlib/BLI_math_mpq.hh +++ b/source/blender/blenlib/BLI_math_mpq.hh @@ -17,6 +17,8 @@ #ifndef __BLI_MATH_MPQ_HH__ #define __BLI_MATH_MPQ_HH__ +#ifdef WITH_GMP + /* This file uses an external file header to define the multiprecision * rational type, mpq_class. * This class keeps separate multiprecision integer numerator and @@ -26,6 +28,7 @@ * See gmplib.org for full documentation. In particular: * https://gmplib.org/manual/C_002b_002b-Interface-Rationals */ -#include "gmpxx.h" +# include "gmpxx.h" +#endif /* WITH_GMP */ #endif /* __BLI_MATH_MPQ_HH__ */ diff --git a/source/blender/blenlib/BLI_mesh_intersect.hh b/source/blender/blenlib/BLI_mesh_intersect.hh index 30a7f43f3b0..061ecdf66ce 100644 --- a/source/blender/blenlib/BLI_mesh_intersect.hh +++ b/source/blender/blenlib/BLI_mesh_intersect.hh @@ -20,19 +20,22 @@ /** \file * \ingroup bli * - * Work in progress on mesh intersection library function. + * Mesh intersection library functions. + * Uses exact arithmetic, so need GMP. */ -#include <iostream> +#ifdef WITH_GMP -#include "BLI_array.hh" -#include "BLI_double3.hh" -#include "BLI_index_range.hh" -#include "BLI_map.hh" -#include "BLI_math_mpq.hh" -#include "BLI_mpq3.hh" -#include "BLI_span.hh" -#include "BLI_vector.hh" +# include <iostream> + +# include "BLI_array.hh" +# include "BLI_double3.hh" +# include "BLI_index_range.hh" +# include "BLI_map.hh" +# include "BLI_math_mpq.hh" +# include "BLI_mpq3.hh" +# include "BLI_span.hh" +# include "BLI_vector.hh" namespace blender::meshintersect { @@ -353,4 +356,5 @@ void write_obj_mesh(Mesh &m, const std::string &objname); } /* namespace blender::meshintersect */ -#endif /* __BLI_MESH_INTERSECT_HH__ */ +#endif /* WITH_GMP */ +#endif /* __BLI_MESH_INTERSECT_HH__ */
\ No newline at end of file diff --git a/source/blender/blenlib/BLI_mpq2.hh b/source/blender/blenlib/BLI_mpq2.hh index 771115ca041..a78ffaaa32d 100644 --- a/source/blender/blenlib/BLI_mpq2.hh +++ b/source/blender/blenlib/BLI_mpq2.hh @@ -17,8 +17,10 @@ #ifndef __BLI_MPQ2_HH__ #define __BLI_MPQ2_HH__ -#include "BLI_math_mpq.hh" -#include "BLI_mpq3.hh" +#ifdef WITH_GMP + +# include "BLI_math_mpq.hh" +# include "BLI_mpq3.hh" namespace blender { @@ -174,4 +176,5 @@ struct mpq2 { } // namespace blender +#endif /* WITH_GMP */ #endif /* __BLI_MPQ_HH__ */ diff --git a/source/blender/blenlib/BLI_mpq3.hh b/source/blender/blenlib/BLI_mpq3.hh index cfe75b1d4c5..0c9edb5a440 100644 --- a/source/blender/blenlib/BLI_mpq3.hh +++ b/source/blender/blenlib/BLI_mpq3.hh @@ -17,11 +17,13 @@ #ifndef __BLI_MPQ3_HH__ #define __BLI_MPQ3_HH__ -#include <iostream> +#ifdef WITH_GMP -#include "BLI_math.h" -#include "BLI_math_mpq.hh" -#include "BLI_span.hh" +# include <iostream> + +# include "BLI_math.h" +# include "BLI_math_mpq.hh" +# include "BLI_span.hh" namespace blender { @@ -270,4 +272,5 @@ uint64_t hash_mpq_class(const mpq_class &value); } // namespace blender +#endif /* WITH_GMP */ #endif /* __BLI_MPQ3_HH__ */ diff --git a/source/blender/blenlib/BLI_uvproject.h b/source/blender/blenlib/BLI_uvproject.h index 8a33ea6961c..4bfa1601b16 100644 --- a/source/blender/blenlib/BLI_uvproject.h +++ b/source/blender/blenlib/BLI_uvproject.h @@ -45,7 +45,7 @@ void BLI_uvproject_from_view(float target[2], float winy); /* apply ortho uv's */ -void BLI_uvproject_from_view_ortho(float target[2], float source[3], float rotmat[4][4]); +void BLI_uvproject_from_view_ortho(float target[2], float source[3], const float rotmat[4][4]); /* so we can adjust scale with keeping the struct private */ void BLI_uvproject_camera_info_scale(struct ProjCameraInfo *uci, float scale_x, float scale_y); diff --git a/source/blender/blenlib/intern/BLI_dial_2d.c b/source/blender/blenlib/intern/BLI_dial_2d.c index c6d28e20f35..7363233d573 100644 --- a/source/blender/blenlib/intern/BLI_dial_2d.c +++ b/source/blender/blenlib/intern/BLI_dial_2d.c @@ -45,7 +45,7 @@ struct Dial { bool initialized; }; -Dial *BLI_dial_initialize(const float start_position[2], float threshold) +Dial *BLI_dial_init(const float start_position[2], float threshold) { Dial *dial = MEM_callocN(sizeof(Dial), "dial"); diff --git a/source/blender/blenlib/intern/boolean.cc b/source/blender/blenlib/intern/boolean.cc index 6f29320b556..ab4b6ea17b4 100644 --- a/source/blender/blenlib/intern/boolean.cc +++ b/source/blender/blenlib/intern/boolean.cc @@ -14,26 +14,28 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include <algorithm> -#include <fstream> -#include <iostream> - -#include "BLI_array.hh" -#include "BLI_assert.h" -#include "BLI_delaunay_2d.h" -#include "BLI_hash.hh" -#include "BLI_map.hh" -#include "BLI_math.h" -#include "BLI_math_mpq.hh" -#include "BLI_mesh_intersect.hh" -#include "BLI_mpq3.hh" -#include "BLI_set.hh" -#include "BLI_span.hh" -#include "BLI_stack.hh" -#include "BLI_vector.hh" -#include "BLI_vector_set.hh" - -#include "BLI_boolean.hh" +#ifdef WITH_GMP + +# include <algorithm> +# include <fstream> +# include <iostream> + +# include "BLI_array.hh" +# include "BLI_assert.h" +# include "BLI_delaunay_2d.h" +# include "BLI_hash.hh" +# include "BLI_map.hh" +# include "BLI_math.h" +# include "BLI_math_mpq.hh" +# include "BLI_mesh_intersect.hh" +# include "BLI_mpq3.hh" +# include "BLI_set.hh" +# include "BLI_span.hh" +# include "BLI_stack.hh" +# include "BLI_vector.hh" +# include "BLI_vector_set.hh" + +# include "BLI_boolean.hh" namespace blender::meshintersect { @@ -2785,3 +2787,5 @@ Mesh boolean_mesh(Mesh &pm, } } // namespace blender::meshintersect + +#endif // WITH_GMP
\ No newline at end of file diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc index 11be4f99d56..87b7dd8dd01 100644 --- a/source/blender/blenlib/intern/delaunay_2d.cc +++ b/source/blender/blenlib/intern/delaunay_2d.cc @@ -39,10 +39,12 @@ template<typename T> T math_abs(const T v) return (v < 0) ? -v : v; } +#ifdef WITH_GMP template<> mpq_class math_abs<mpq_class>(const mpq_class v) { return abs(v); } +#endif template<> double math_abs<double>(const double v) { @@ -55,10 +57,12 @@ template<typename T> double math_to_double(const T UNUSED(v)) return 0.0; } +#ifdef WITH_GMP template<> double math_to_double<mpq_class>(const mpq_class v) { return v.get_d(); } +#endif template<> double math_to_double<double>(const double v) { @@ -1404,7 +1408,11 @@ void fill_crossdata_for_intersect(const vec2<T> &curco, T &lambda = isect.lambda; switch (isect.kind) { case vec2<T>::isect_result::LINE_LINE_CROSS: { +#ifdef WITH_GMP if (!std::is_same<T, mpq_class>::value) { +#else + if (true) { +#endif T len_ab = vec2<T>::distance(va->co, vb->co); if (lambda * len_ab <= epsilon) { fill_crossdata_for_through_vert(va, se_vcva, cd, cd_next); @@ -1441,9 +1449,11 @@ void fill_crossdata_for_intersect(const vec2<T> &curco, } } break; case vec2<T>::isect_result::LINE_LINE_NONE: { +#ifdef WITH_GMP if (std::is_same<T, mpq_class>::value) { BLI_assert(false); } +#endif /* It should be very near one end or other of segment. */ const T middle_lambda = 0.5; if (lambda <= middle_lambda) { @@ -1462,7 +1472,7 @@ void fill_crossdata_for_intersect(const vec2<T> &curco, } } break; } -} +} // namespace blender::meshintersect /* * As part of finding the crossings of a ray to v2, find the next crossing after 'cd', assuming @@ -2307,11 +2317,13 @@ blender::meshintersect::CDT_result<double> delaunay_2d_calc(const CDT_input<doub return delaunay_calc(input, output_type); } +#ifdef WITH_GMP blender::meshintersect::CDT_result<mpq_class> delaunay_2d_calc(const CDT_input<mpq_class> &input, CDT_output_type output_type) { return delaunay_calc(input, output_type); } +#endif } /* namespace blender::meshintersect */ diff --git a/source/blender/blenlib/intern/math_vec.cc b/source/blender/blenlib/intern/math_vec.cc index 1b87c820815..7d81908e298 100644 --- a/source/blender/blenlib/intern/math_vec.cc +++ b/source/blender/blenlib/intern/math_vec.cc @@ -91,6 +91,7 @@ double2::isect_result double2::isect_seg_seg(const double2 &v1, return ans; } +#ifdef WITH_GMP mpq2::isect_result mpq2::isect_seg_seg(const mpq2 &v1, const mpq2 &v2, const mpq2 &v3, @@ -235,6 +236,7 @@ int mpq3::orient3d(const mpq3 &a, const mpq3 &b, const mpq3 &c, const mpq3 &d) mpq_class det = adz * (bdxcdy - cdxbdy) + bdz * (cdxady - adxcdy) + cdz * (adxbdy - bdxady); return sgn(det); } +#endif /* WITH_GMP */ /* For double versions of orient and incircle functions, use robust predicates * that give exact answers for double inputs. diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc index 203cbd7c1fc..89dceddd95b 100644 --- a/source/blender/blenlib/intern/mesh_intersect.cc +++ b/source/blender/blenlib/intern/mesh_intersect.cc @@ -14,40 +14,43 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include <fstream> -#include <iostream> - -#include "BLI_allocator.hh" -#include "BLI_array.hh" -#include "BLI_assert.h" -#include "BLI_delaunay_2d.h" -#include "BLI_double3.hh" -#include "BLI_float3.hh" -#include "BLI_hash.hh" -#include "BLI_kdopbvh.h" -#include "BLI_map.hh" -#include "BLI_math_mpq.hh" -#include "BLI_mpq2.hh" -#include "BLI_mpq3.hh" -#include "BLI_span.hh" -#include "BLI_task.h" -#include "BLI_threads.h" -#include "BLI_vector.hh" -#include "BLI_vector_set.hh" - -#include "BLI_mesh_intersect.hh" +/* The blender::meshintersect API needs GMP. */ +#ifdef WITH_GMP + +# include <fstream> +# include <iostream> + +# include "BLI_allocator.hh" +# include "BLI_array.hh" +# include "BLI_assert.h" +# include "BLI_delaunay_2d.h" +# include "BLI_double3.hh" +# include "BLI_float3.hh" +# include "BLI_hash.hh" +# include "BLI_kdopbvh.h" +# include "BLI_map.hh" +# include "BLI_math_mpq.hh" +# include "BLI_mpq2.hh" +# include "BLI_mpq3.hh" +# include "BLI_span.hh" +# include "BLI_task.h" +# include "BLI_threads.h" +# include "BLI_vector.hh" +# include "BLI_vector_set.hh" + +# include "BLI_mesh_intersect.hh" // #define PERFDEBUG namespace blender::meshintersect { -#ifdef PERFDEBUG +# ifdef PERFDEBUG static void perfdata_init(void); static void incperfcount(int countnum); static void bumpperfcount(int countnum, int amt); static void doperfmax(int maxnum, int val); static void dump_perfdata(void); -#endif +# endif /* For debugging, can disable threading in intersect code with this static constant. */ static constexpr bool intersect_use_threading = true; @@ -363,21 +366,21 @@ class MArena::MArenaImpl { int next_face_id_ = 0; /* Need a lock when multithreading to protect allocation of new elements. */ -#ifdef USE_SPINLOCK +# ifdef USE_SPINLOCK SpinLock lock_; -#else +# else ThreadMutex *mutex_; -#endif +# endif public: MArenaImpl() { if (intersect_use_threading) { -#ifdef USE_SPINLOCK +# ifdef USE_SPINLOCK BLI_spin_init(&lock_); -#else +# else mutex_ = BLI_mutex_alloc(); -#endif +# endif } } MArenaImpl(const MArenaImpl &) = delete; @@ -385,11 +388,11 @@ class MArena::MArenaImpl { ~MArenaImpl() { if (intersect_use_threading) { -#ifdef USE_SPINLOCK +# ifdef USE_SPINLOCK BLI_spin_end(&lock_); -#else +# else BLI_mutex_free(mutex_); -#endif +# endif } } @@ -426,19 +429,19 @@ class MArena::MArenaImpl { { Face *f = new Face(verts, next_face_id_++, orig, edge_origs, is_intersect); if (intersect_use_threading) { -#ifdef USE_SPINLOCK +# ifdef USE_SPINLOCK BLI_spin_lock(&lock_); -#else +# else BLI_mutex_lock(mutex_); -#endif +# endif } allocated_faces_.append(std::unique_ptr<Face>(f)); if (intersect_use_threading) { -#ifdef USE_SPINLOCK +# ifdef USE_SPINLOCK BLI_spin_unlock(&lock_); -#else +# else BLI_mutex_unlock(mutex_); -#endif +# endif } return f; } @@ -462,11 +465,11 @@ class MArena::MArenaImpl { Vert vtry(co, double3(), NO_INDEX, NO_INDEX); VSetKey vskey(&vtry); if (intersect_use_threading) { -#ifdef USE_SPINLOCK +# ifdef USE_SPINLOCK BLI_spin_lock(&lock_); -#else +# else BLI_mutex_lock(mutex_); -#endif +# endif } int i = vset_.index_of_try(vskey); if (i == -1) { @@ -476,11 +479,11 @@ class MArena::MArenaImpl { ans = vset_[i].vert; } if (intersect_use_threading) { -#ifdef USE_SPINLOCK +# ifdef USE_SPINLOCK BLI_spin_unlock(&lock_); -#else +# else BLI_mutex_unlock(mutex_); -#endif +# endif } return ans; } @@ -510,11 +513,11 @@ class MArena::MArenaImpl { Vertp ans; VSetKey vskey(&vtry); if (intersect_use_threading) { -#ifdef USE_SPINLOCK +# ifdef USE_SPINLOCK BLI_spin_lock(&lock_); -#else +# else BLI_mutex_lock(mutex_); -#endif +# endif } int i = vset_.index_of_try(vskey); if (i == -1) { @@ -534,11 +537,11 @@ class MArena::MArenaImpl { ans = vset_[i].vert; } if (intersect_use_threading) { -#ifdef USE_SPINLOCK +# ifdef USE_SPINLOCK BLI_spin_unlock(&lock_); -#else +# else BLI_mutex_unlock(mutex_); -#endif +# endif } return ans; }; @@ -1235,7 +1238,7 @@ static bool non_trivially_coplanar_intersects(const Mesh &tm, /* Keeping this code for a while, but for now, almost all * trivial intersects are found before calling intersect_tri_tri now. */ -#if 0 +# if 0 /* Do tri1 and tri2 intersect at all, and if so, is the intersection * something other than a common vertex or a common edge? * The itt value is the result of calling intersect_tri_tri on tri1, tri2. @@ -1294,7 +1297,7 @@ static bool non_trivial_intersect(const ITT_value &itt, Facep tri1, Facep tri2) const mpq2 *vb[] = {&tri_2d[1][0], &tri_2d[1][1], &tri_2d[1][2]}; return non_trivially_2d_intersect(va, vb); } -#endif +# endif /* The sup and index functions are defined in the paper: * EXACT GEOMETRIC COMPUTATION USING CASCADING, by @@ -1763,9 +1766,9 @@ static ITT_value itt_canon1(const mpq3 &p1, static ITT_value intersect_tri_tri(const Mesh &tm, int t1, int t2) { constexpr int dbg_level = 0; -#ifdef PERFDEBUG +# ifdef PERFDEBUG incperfcount(2); /* Intersect_tri_tri calls. */ -#endif +# endif const Face &tri1 = *tm.face(t1); const Face &tri2 = *tm.face(t2); Vertp vp1 = tri1[0]; @@ -1808,9 +1811,9 @@ static ITT_value intersect_tri_tri(const Mesh &tm, int t1, int t2) int sq1 = filter_plane_side(d_q1, d_r2, d_n2, abs_d_q1, abs_d_r2, abs_d_n2); int sr1 = filter_plane_side(d_r1, d_r2, d_n2, abs_d_r1, abs_d_r2, abs_d_n2); if ((sp1 > 0 && sq1 > 0 && sr1 > 0) || (sp1 < 0 && sq1 < 0 && sr1 < 0)) { -#ifdef PERFDEBUG +# ifdef PERFDEBUG incperfcount(3); /* Tri tri intersects decided by filter plane tests. */ -#endif +# endif if (dbg_level > 0) { std::cout << "no intersection, all t1's verts above or below t2\n"; } @@ -1826,9 +1829,9 @@ static ITT_value intersect_tri_tri(const Mesh &tm, int t1, int t2) int sq2 = filter_plane_side(d_q2, d_r1, d_n1, abs_d_q2, abs_d_r1, abs_d_n1); int sr2 = filter_plane_side(d_r2, d_r1, d_n1, abs_d_r2, abs_d_r1, abs_d_n1); if ((sp2 > 0 && sq2 > 0 && sr2 > 0) || (sp2 < 0 && sq2 < 0 && sr2 < 0)) { -#ifdef PERFDEBUG +# ifdef PERFDEBUG incperfcount(3); /* Tri tri intersects decided by filter plane tests. */ -#endif +# endif if (dbg_level > 0) { std::cout << "no intersection, all t2's verts above or below t1\n"; } @@ -1862,9 +1865,9 @@ static ITT_value intersect_tri_tri(const Mesh &tm, int t1, int t2) if (dbg_level > 0) { std::cout << "no intersection, all t1's verts above or below t2 (exact)\n"; } -#ifdef PERFDEBUG +# ifdef PERFDEBUG incperfcount(4); /* Tri tri interects decided by exact plane tests. */ -#endif +# endif return ITT_value(INONE); } @@ -1888,9 +1891,9 @@ static ITT_value intersect_tri_tri(const Mesh &tm, int t1, int t2) if (dbg_level > 0) { std::cout << "no intersection, all t2's verts above or below t1 (exact)\n"; } -#ifdef PERFDEBUG +# ifdef PERFDEBUG incperfcount(4); /* Tri tri interects decided by exact plane tests. */ -#endif +# endif return ITT_value(INONE); } @@ -1956,11 +1959,11 @@ static ITT_value intersect_tri_tri(const Mesh &tm, int t1, int t2) ans.t_source = t2; } -#ifdef PERFDEBUG +# ifdef PERFDEBUG if (ans.kind != INONE) { incperfcount(5); } -#endif +# endif return ans; } @@ -2540,9 +2543,9 @@ static void calc_subdivided_tris(Array<Mesh> &r_tri_subdivided, if (!(len == 1 && overlap[overlap_index].indexB == t)) { OverlapTriRange range = {t, overlap_index, len}; data.overlap_tri_range.append(range); -#ifdef PERFDEBUG +# ifdef PERFDEBUG bumpperfcount(0, len); /* Overlaps. */ -#endif +# endif } } overlap_index = i + 1; @@ -2766,12 +2769,12 @@ Mesh trimesh_nary_intersect( if (dbg_level > 1) { std::cout << clinfo; } -#ifdef PERFDEBUG +# ifdef PERFDEBUG perfdata_init(); doperfmax(0, static_cast<int>(tm_in.face_size())); doperfmax(1, static_cast<int>(clinfo.tot_cluster())); doperfmax(2, static_cast<int>(tri_ov.overlap().size())); -#endif +# endif Array<CDT_data> cluster_subdivided(clinfo.tot_cluster()); for (int c : clinfo.index_range()) { cluster_subdivided[c] = calc_cluster_subdivided(clinfo, c, tm_in, arena); @@ -2793,9 +2796,9 @@ Mesh trimesh_nary_intersect( std::cout << "TRIMESH_NARY_INTERSECT answer:\n"; std::cout << combined; } -#ifdef PERFDEBUG +# ifdef PERFDEBUG dump_perfdata(); -#endif +# endif return combined; } @@ -2850,11 +2853,11 @@ void write_obj_mesh(Mesh &m, const std::string &objname) /* Would like to use BKE_tempdir_base() here, but that brings in dependence on kernel library. * This is just for developer debugging anyway, and should never be called in production Blender. */ -#ifdef _WIN_32 +# ifdef _WIN_32 const char *objdir = BLI_getenv("HOME"); -#else +# else const char *objdir = "/tmp/"; -#endif +# endif if (m.face_size() == 0) { return; } @@ -2890,7 +2893,7 @@ void write_obj_mesh(Mesh &m, const std::string &objname) f.close(); } -#ifdef PERFDEBUG +# ifdef PERFDEBUG struct PerfCounts { Vector<int> count; Vector<const char *> count_name; @@ -2962,6 +2965,8 @@ static void dump_perfdata(void) std::cout << perfdata.max_name[i] << " = " << perfdata.max[i] << "\n"; } } -#endif +# endif }; // namespace blender::meshintersect + +#endif // WITH_GMP
\ No newline at end of file diff --git a/source/blender/blenlib/intern/session_uuid.c b/source/blender/blenlib/intern/session_uuid.c index a5307684059..d3446fae5cb 100644 --- a/source/blender/blenlib/intern/session_uuid.c +++ b/source/blender/blenlib/intern/session_uuid.c @@ -43,7 +43,7 @@ SessionUUID BLI_session_uuid_generate(void) * Just request the UUID once again, hoping that there are no a lot of high-priority threads * which will overflow the counter once again between the previous call and this one. * - * NOTE: It is possible to have collissions after such overflow. */ + * NOTE: It is possible to have collisions after such overflow. */ result.uuid_ = atomic_add_and_fetch_uint64(&global_session_uuid.uuid_, 1); } return result; diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index a34c551767a..00fef29587c 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -183,7 +183,7 @@ ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, float (*rotmat)[4], float return NULL; } -void BLI_uvproject_from_view_ortho(float target[2], float source[3], float rotmat[4][4]) +void BLI_uvproject_from_view_ortho(float target[2], float source[3], const float rotmat[4][4]) { float pv[3]; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2845c83a1cb..398598a3fb6 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5516,7 +5516,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) if (gpmd->curve_intensity) { BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); /* initialize the curve. Maybe this could be moved to modififer logic */ - BKE_curvemapping_initialize(gpmd->curve_intensity); + BKE_curvemapping_init(gpmd->curve_intensity); } } else if (md->type == eGpencilModifierType_Thick) { @@ -5525,7 +5525,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) BLO_read_data_address(reader, &gpmd->curve_thickness); if (gpmd->curve_thickness) { BKE_curvemapping_blend_read(reader, gpmd->curve_thickness); - BKE_curvemapping_initialize(gpmd->curve_thickness); + BKE_curvemapping_init(gpmd->curve_thickness); } } else if (md->type == eGpencilModifierType_Tint) { @@ -5534,7 +5534,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) BLO_read_data_address(reader, &gpmd->curve_intensity); if (gpmd->curve_intensity) { BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); - BKE_curvemapping_initialize(gpmd->curve_intensity); + BKE_curvemapping_init(gpmd->curve_intensity); } } else if (md->type == eGpencilModifierType_Smooth) { @@ -5542,7 +5542,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) BLO_read_data_address(reader, &gpmd->curve_intensity); if (gpmd->curve_intensity) { BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); - BKE_curvemapping_initialize(gpmd->curve_intensity); + BKE_curvemapping_init(gpmd->curve_intensity); } } else if (md->type == eGpencilModifierType_Color) { @@ -5550,7 +5550,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) BLO_read_data_address(reader, &gpmd->curve_intensity); if (gpmd->curve_intensity) { BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); - BKE_curvemapping_initialize(gpmd->curve_intensity); + BKE_curvemapping_init(gpmd->curve_intensity); } } else if (md->type == eGpencilModifierType_Opacity) { @@ -5558,7 +5558,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) BLO_read_data_address(reader, &gpmd->curve_intensity); if (gpmd->curve_intensity) { BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); - BKE_curvemapping_initialize(gpmd->curve_intensity); + BKE_curvemapping_init(gpmd->curve_intensity); } } } diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 3ed59a0baa1..1432fbeb4e2 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -280,7 +280,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) region->v2d.keepzoom |= (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_KEEPASPECT); region->v2d.keeptot = V2D_KEEPTOT_STRICT; region->v2d.minzoom = region->v2d.maxzoom = 1.0f; - // region->v2d.flag |= V2D_IS_INITIALISED; + // region->v2d.flag |= V2D_IS_INIT; break; } case SPACE_GRAPH: { @@ -297,7 +297,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) region->v2d.max[0] = MAXFRAMEF; region->v2d.max[1] = FLT_MAX; - // region->v2d.flag |= V2D_IS_INITIALISED; + // region->v2d.flag |= V2D_IS_INIT; break; } case SPACE_NLA: { @@ -355,7 +355,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) region->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES); region->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_VERTICAL_HANDLES); region->v2d.align = V2D_ALIGN_NO_NEG_Y; - region->v2d.flag |= V2D_IS_INITIALISED; + region->v2d.flag |= V2D_IS_INIT; break; } case SPACE_NODE: { @@ -965,7 +965,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) bPoseChannel *pchan; for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - /* just need to initialise rotation axis properly... */ + /* Just need to initialize rotation axis properly. */ pchan->rotAxis[1] = 1.0f; } } diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 5e91fea3e20..f74ee9cd735 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -1205,7 +1205,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) if (region->regiontype == RGN_TYPE_PREVIEW) { if (region->alignment != RGN_ALIGN_NONE) { region->flag |= RGN_FLAG_HIDDEN; - region->v2d.flag &= ~V2D_IS_INITIALISED; + region->v2d.flag &= ~V2D_IS_INIT; region->alignment = RGN_ALIGN_NONE; hide = true; diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 521fc4b9b82..2c4602f546b 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1108,7 +1108,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) { CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve; BKE_curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); - BKE_curvemapping_initialize(curve_mapping); + BKE_curvemapping_init(curve_mapping); BKE_curvemap_reset( curve_mapping->cm, &curve_mapping->clipr, CURVE_PRESET_MAX, CURVEMAP_SLOPE_POS_NEG); } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 111ac728cc3..8f5ab69caf8 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1958,7 +1958,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; if ((gset) && (gset->cur_falloff == NULL)) { gset->cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - BKE_curvemapping_initialize(gset->cur_falloff); + BKE_curvemapping_init(gset->cur_falloff); BKE_curvemap_reset(gset->cur_falloff->cm, &gset->cur_falloff->clipr, CURVE_PRESET_GAUSS, @@ -3371,7 +3371,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; if ((gset) && (gset->cur_primitive == NULL)) { gset->cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - BKE_curvemapping_initialize(gset->cur_primitive); + BKE_curvemapping_init(gset->cur_primitive); BKE_curvemap_reset(gset->cur_primitive->cm, &gset->cur_primitive->clipr, CURVE_PRESET_BELL, @@ -4767,7 +4767,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (mmd->curve_intensity == NULL) { mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (mmd->curve_intensity) { - BKE_curvemapping_initialize(mmd->curve_intensity); + BKE_curvemapping_init(mmd->curve_intensity); } } break; @@ -4778,7 +4778,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (mmd->curve_intensity == NULL) { mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (mmd->curve_intensity) { - BKE_curvemapping_initialize(mmd->curve_intensity); + BKE_curvemapping_init(mmd->curve_intensity); } } break; @@ -4788,7 +4788,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (mmd->curve_intensity == NULL) { mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (mmd->curve_intensity) { - BKE_curvemapping_initialize(mmd->curve_intensity); + BKE_curvemapping_init(mmd->curve_intensity); } } break; @@ -4798,7 +4798,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (mmd->curve_intensity == NULL) { mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (mmd->curve_intensity) { - BKE_curvemapping_initialize(mmd->curve_intensity); + BKE_curvemapping_init(mmd->curve_intensity); } } break; @@ -4808,7 +4808,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (mmd->curve_intensity == NULL) { mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (mmd->curve_intensity) { - BKE_curvemapping_initialize(mmd->curve_intensity); + BKE_curvemapping_init(mmd->curve_intensity); } } break; diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 7f75c0100b8..ae6d3a58091 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -106,7 +106,7 @@ static void blo_update_defaults_screen(bScreen *screen, /* Some toolbars have been saved as initialized, * we don't want them to have odd zoom-level or scrolling set, see: T47047 */ if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) { - region->v2d.flag &= ~V2D_IS_INITIALISED; + region->v2d.flag &= ~V2D_IS_INIT; } } @@ -326,7 +326,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) if (ts->gp_sculpt.cur_falloff == NULL) { ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff; - BKE_curvemapping_initialize(gp_falloff_curve); + BKE_curvemapping_init(gp_falloff_curve); BKE_curvemap_reset(gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, @@ -335,7 +335,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) if (ts->gp_sculpt.cur_primitive == NULL) { ts->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive; - BKE_curvemapping_initialize(gp_primitive_curve); + BKE_curvemapping_init(gp_primitive_curve); BKE_curvemap_reset(gp_primitive_curve->cm, &gp_primitive_curve->clipr, CURVE_PRESET_BELL, diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 44c7c35e47d..d25e340d4fc 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -2096,7 +2096,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (la->curfalloff == NULL) { la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); - BKE_curvemapping_initialize(la->curfalloff); + BKE_curvemapping_init(la->curfalloff); } } } diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 39174a49283..cc7aef65bbb 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -7156,7 +7156,7 @@ static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bo if (custom) { /* Make sure the curve profile's sample table is full. */ if (bp->custom_profile->segments_len != seg || !bp->custom_profile->segments) { - BKE_curveprofile_initialize((CurveProfile *)bp->custom_profile, (short)seg); + BKE_curveprofile_init((CurveProfile *)bp->custom_profile, (short)seg); } /* Copy segment locations into the profile spacing struct. */ @@ -7185,7 +7185,7 @@ static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bo (size_t)(seg_2 + 1) * sizeof(double)); if (custom) { /* Make sure the curve profile widget's sample table is full of the seg_2 samples. */ - BKE_curveprofile_initialize((CurveProfile *)bp->custom_profile, (short)seg_2); + BKE_curveprofile_init((CurveProfile *)bp->custom_profile, (short)seg_2); /* Copy segment locations into the profile spacing struct. */ for (int i = 0; i < seg_2 + 1; i++) { diff --git a/source/blender/bmesh/tools/bmesh_boolean.cc b/source/blender/bmesh/tools/bmesh_boolean.cc index f2b0f1819fa..c6c9dfdce56 100644 --- a/source/blender/bmesh/tools/bmesh_boolean.cc +++ b/source/blender/bmesh/tools/bmesh_boolean.cc @@ -33,6 +33,7 @@ namespace blender { namespace meshintersect { +#ifdef WITH_GMP /* Make a blender::meshintersect::Mesh from BMesh bm. * We are given a triangulation of it from the caller via looptris, * which are looptris_tot triples of loops that together tessellate @@ -280,9 +281,9 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, Mesh &m_out) BMIter iter; BMFace *bmf = static_cast<BMFace *>(BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL)); while (bmf != NULL) { -#ifdef DEBUG +# ifdef DEBUG iter.count = BM_iter_mesh_count(BM_FACES_OF_MESH, bm); -#endif +# endif BMFace *bmf_next = static_cast<BMFace *>(BM_iter_step(&iter)); if (BM_elem_flag_test(bmf, KEEP_FLAG)) { BM_elem_flag_disable(bmf, KEEP_FLAG); @@ -296,9 +297,9 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, Mesh &m_out) } BMVert *bmv = static_cast<BMVert *>(BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL)); while (bmv != NULL) { -#ifdef DEBUG +# ifdef DEBUG iter.count = BM_iter_mesh_count(BM_VERTS_OF_MESH, bm); -#endif +# endif BMVert *bmv_next = static_cast<BMVert *>(BM_iter_step(&iter)); if (BM_elem_flag_test(bmv, KEEP_FLAG)) { BM_elem_flag_disable(bmv, KEEP_FLAG); @@ -362,6 +363,8 @@ static bool bmesh_boolean(BMesh *bm, return any_change; } +#endif // WITH_GMP + } // namespace meshintersect } // namespace blender @@ -382,6 +385,7 @@ extern "C" { * (The actual library function called to do the boolean is internally capable of handling * n-ary operands, so maybe in the future we can expose that functionality to users.) */ +#ifdef WITH_GMP bool BM_mesh_boolean(BMesh *bm, struct BMLoop *(*looptris)[3], const int looptris_tot, @@ -419,5 +423,38 @@ bool BM_mesh_boolean_knife(BMesh *bm, use_separate_all, blender::meshintersect::BOOLEAN_NONE); } +#else +bool BM_mesh_boolean(BMesh *UNUSED(bm), + struct BMLoop *(*looptris)[3], + const int UNUSED(looptris_tot), + int (*test_fn)(BMFace *, void *), + void *UNUSED(user_data), + const bool UNUSED(use_self), + const int UNUSED(boolean_mode)) +{ + UNUSED_VARS(looptris, test_fn); + return false; +} + +/* + * Perform a Knife Intersection operation on the mesh bm. + * There are either one or two operands, the same as described above for BM_mesh_boolean(). + * If use_separate_all is true, each edge that is created from the intersection should + * be used to separate all its incident faces. TODO: implement that. + * TODO: need to ensure that "selected/non-selected" flag of original faces gets propagated + * to the intersection result faces. + */ +bool BM_mesh_boolean_knife(BMesh *UNUSED(bm), + struct BMLoop *(*looptris)[3], + const int UNUSED(looptris_tot), + int (*test_fn)(BMFace *, void *), + void *UNUSED(user_data), + const bool UNUSED(use_self), + const bool UNUSED(use_separate_all)) +{ + UNUSED_VARS(looptris, test_fn); + return false; +} +#endif } /* extern "C" */ diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp index 9722ead0716..247e0d11df6 100644 --- a/source/blender/compositor/nodes/COM_TimeNode.cpp +++ b/source/blender/compositor/nodes/COM_TimeNode.cpp @@ -49,7 +49,7 @@ void TimeNode::convertToOperations(NodeConverter &converter, fac = (context.getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1); } - BKE_curvemapping_initialize((CurveMapping *)node->storage); + BKE_curvemapping_init((CurveMapping *)node->storage); fac = BKE_curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac); operation->setValue(clamp_f(fac, 0.0f, 1.0f)); converter.addOperation(operation); diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp index b18e77cf0e3..855f728f7bf 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp @@ -35,7 +35,7 @@ CurveBaseOperation::~CurveBaseOperation() void CurveBaseOperation::initExecution() { - BKE_curvemapping_initialize(this->m_curveMapping); + BKE_curvemapping_init(this->m_curveMapping); } void CurveBaseOperation::deinitExecution() { diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp index 6f47e0e190b..4a7139537c1 100644 --- a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp +++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp @@ -172,7 +172,7 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator { return; } - /* initialise the iteration variables */ + /* Initialize the iteration variables. */ float *buffer = init_buffer_iterator( input, source, co, dist_min, dist_max, x, y, num, v, dv, falloff_factor); zero_v3(border); diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 8bd4832e446..f85b03dc517 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -404,6 +404,13 @@ data_to_c_simple(engines/overlay/shaders/xray_fade_frag.glsl SRC) list(APPEND INC ) +if(WITH_MOD_FLUID) + list(APPEND INC + ../../../intern/mantaflow/extern + ) + add_definitions(-DWITH_FLUID) +endif() + if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index 787fc16a7da..e8619701365 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -160,7 +160,7 @@ void EEVEE_render_view_sync(EEVEE_Data *vedata, RenderEngine *engine, struct Dep struct Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, RE_GetCamera(engine->re)); RE_GetCameraWindow(engine->re, ob_camera_eval, winmat); - RE_GetCameraWindowWithOverscan(engine->re, winmat, g_data->overscan); + RE_GetCameraWindowWithOverscan(engine->re, g_data->overscan, winmat); RE_GetCameraModelMatrix(engine->re, ob_camera_eval, viewinv); invert_m4_m4(viewmat, viewinv); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 7cc10bd14e8..361c66eca6e 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -1274,9 +1274,11 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, FOREACH_MESH_BUFFER_CACHE (cache, mbuffercache) { GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.edituv_data); GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.fdots_uv); + GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.fdots_edituv_data); GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_tris); GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_lines); GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_points); + GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_fdots); } /* We only clear the batches as they may already have been * referenced. */ diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 50733afe6fb..8280b58c21a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -427,7 +427,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) ac->spacetype = (area) ? area->spacetype : 0; ac->regiontype = (region) ? region->regiontype : 0; - /* initialise default y-scale factor */ + /* Initialize default y-scale factor. */ animedit_get_yscale_factor(ac); /* get data context info */ diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index b2e329deee7..04c1ec97841 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -229,7 +229,7 @@ EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const ui return NULL; } -void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]) +void ED_armature_ebone_to_mat3(EditBone *ebone, float r_mat[3][3]) { float delta[3], roll; @@ -246,20 +246,20 @@ void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]) } } - vec_roll_to_mat3_normalized(delta, roll, mat); + vec_roll_to_mat3_normalized(delta, roll, r_mat); } -void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]) +void ED_armature_ebone_to_mat4(EditBone *ebone, float r_mat[4][4]) { float m3[3][3]; ED_armature_ebone_to_mat3(ebone, m3); - copy_m4_m3(mat, m3); - copy_v3_v3(mat[3], ebone->head); + copy_m4_m3(r_mat, m3); + copy_v3_v3(r_mat[3], ebone->head); } -void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]) +void ED_armature_ebone_from_mat3(EditBone *ebone, const float mat[3][3]) { float vec[3], roll; const float len = len_v3v3(ebone->head, ebone->tail); @@ -270,7 +270,7 @@ void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]) ebone->roll = roll; } -void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]) +void ED_armature_ebone_from_mat4(EditBone *ebone, const float mat[4][4]) { float mat3[3][3]; diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 8df9c99896e..e60270bc3f0 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -251,7 +251,7 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode) */ BLI_dlrbTree_init(&pso->keys); - /* initialise numeric input */ + /* Initialize numeric input. */ initNumInput(&pso->num); pso->num.idx_max = 0; /* one axis */ pso->num.val_flag[0] |= NUM_NO_NEGATIVE; @@ -1310,7 +1310,7 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev pso = op->customdata; - /* initialise percentage so that it won't pop on first mouse move */ + /* Initialize percentage so that it won't pop on first mouse move. */ pose_slide_mouse_update_percentage(pso, op, event); /* do common setup work */ @@ -1370,7 +1370,7 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e pso = op->customdata; - /* initialise percentage so that it won't pop on first mouse move */ + /* Initialize percentage so that it won't pop on first mouse move. */ pose_slide_mouse_update_percentage(pso, op, event); /* do common setup work */ @@ -1429,7 +1429,7 @@ static int pose_slide_push_rest_invoke(bContext *C, wmOperator *op, const wmEven pso = op->customdata; - /* initialise percentage so that it won't pop on first mouse move */ + /* Initialize percentage so that it won't pop on first mouse move. */ pose_slide_mouse_update_percentage(pso, op, event); /* do common setup work */ @@ -1489,7 +1489,7 @@ static int pose_slide_relax_rest_invoke(bContext *C, wmOperator *op, const wmEve pso = op->customdata; - /* initialise percentage so that it won't pop on first mouse move */ + /* Initialize percentage so that it won't pop on first mouse move. */ pose_slide_mouse_update_percentage(pso, op, event); /* do common setup work */ @@ -1549,7 +1549,7 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven pso = op->customdata; - /* initialise percentage so that it won't pop on first mouse move */ + /* Initialize percentage so that it won't pop on first mouse move. */ pose_slide_mouse_update_percentage(pso, op, event); /* do common setup work */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 91a8ea0fa3a..72ea52314b9 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1137,7 +1137,7 @@ int ED_curve_updateAnimPaths(Main *bmain, Curve *cu) /** \name Edit Mode Conversion (Make & Load) * \{ */ -static int *initialize_index_map(Object *obedit, int *r_old_totvert) +static int *init_index_map(Object *obedit, int *r_old_totvert) { Curve *curve = (Curve *)obedit->data; EditNurb *editnurb = curve->editnurb; @@ -1225,7 +1225,7 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit) if ((object->parent) && (object->parent->data == curve) && ELEM(object->partype, PARVERT1, PARVERT3)) { if (old_to_new_map == NULL) { - old_to_new_map = initialize_index_map(obedit, &old_totvert); + old_to_new_map = init_index_map(obedit, &old_totvert); } if (object->par1 < old_totvert) { @@ -1254,7 +1254,7 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit) int i, j; if (old_to_new_map == NULL) { - old_to_new_map = initialize_index_map(obedit, &old_totvert); + old_to_new_map = init_index_map(obedit, &old_totvert); } for (i = j = 0; i < hmd->totindex; i++) { diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index 85f84af5f14..406d66dfd8f 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -999,7 +999,7 @@ static int gizmo_cage2d_modal(bContext *C, if (data->dial == NULL) { MUL_V2_V3_M4_FINAL(test_co, data->orig_matrix_offset[3]); - data->dial = BLI_dial_initialize(test_co, FLT_EPSILON); + data->dial = BLI_dial_init(test_co, FLT_EPSILON); MUL_V2_V3_M4_FINAL(test_co, data->orig_mouse); BLI_dial_angle(data->dial, test_co); diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 3aec1db2587..ab83abb6b37 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -603,7 +603,7 @@ static short annotation_stroke_addpoint(tGPsdata *p, /* store settings */ copy_v2_v2(&pt->x, mval); pt->pressure = pressure; - /* unused for annotations, but initialise for easier conversions to GP Object */ + /* Unused for annotations, but initialize for easier conversions to GP Object. */ pt->strength = 1.0f; /* point time */ diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 29ae38fdbd8..9658dc04b52 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1771,7 +1771,7 @@ static int gpencil_blank_frame_add_exec(bContext *C, wmOperator *op) const bool all_layers = RNA_boolean_get(op->ptr, "all_layers"); - /* Initialise datablock and an active layer if nothing exists yet */ + /* Initialize data-block and an active layer if nothing exists yet. */ if (ELEM(NULL, gpd, active_gpl)) { /* Let's just be lazy, and call the "Add New Layer" operator, * which sets everything up as required. */ @@ -4290,14 +4290,14 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op) base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_prev, dupflag); ob_dst = base_new->object; ob_dst->mode = OB_MODE_OBJECT; - /* Duplication will increment bGPdata usercount, but since we create a new greasepencil datablock - * for ob_dst (which gets its own user automatically), we have to decrement the usercount again. - */ + /* Duplication will increment #bGPdata user-count, but since we create a new grease-pencil + * data-block for ob_dst (which gets its own user automatically), + * we have to decrement the user-count again. */ gpd_dst = BKE_gpencil_data_addnew(bmain, gpd_src->id.name + 2); id_us_min(ob_dst->data); ob_dst->data = (bGPdata *)gpd_dst; - /* loop old datablock and separate parts */ + /* Loop old data-block and separate parts. */ if ((mode == GP_SEPARATE_POINT) || (mode == GP_SEPARATE_STROKE)) { CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { gpl_dst = NULL; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index b61baf3d0b1..d1be99150ae 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1817,15 +1817,15 @@ static void gpencil_init_drawing_brush(bContext *C, tGPsdata *p) changed = true; } /* Be sure curves are initializated. */ - BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_sensitivity); - BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_strength); - BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_jitter); - BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_pressure); - BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_strength); - BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_uv); - BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_hue); - BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_saturation); - BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_value); + BKE_curvemapping_init(paint->brush->gpencil_settings->curve_sensitivity); + BKE_curvemapping_init(paint->brush->gpencil_settings->curve_strength); + BKE_curvemapping_init(paint->brush->gpencil_settings->curve_jitter); + BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_pressure); + BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_strength); + BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_uv); + BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_hue); + BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_saturation); + BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_value); /* assign to temp tGPsdata */ p->brush = paint->brush; diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index fb0d94f2307..9006482d7bb 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -740,13 +740,13 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) gpencil_session_validatebuffer(tgpi); gpencil_init_colors(tgpi); if (gset->flag & GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE) { - BKE_curvemapping_initialize(ts->gp_sculpt.cur_primitive); + BKE_curvemapping_init(ts->gp_sculpt.cur_primitive); } if (brush_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) { - BKE_curvemapping_initialize(brush_settings->curve_jitter); + BKE_curvemapping_init(brush_settings->curve_jitter); } if (brush_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) { - BKE_curvemapping_initialize(brush_settings->curve_strength); + BKE_curvemapping_init(brush_settings->curve_strength); } /* get an array of depths, far depths are blended */ @@ -1085,7 +1085,7 @@ static void gpencil_primitive_update(bContext *C, wmOperator *op, tGPDprimitive gpencil_primitive_update_strokes(C, tgpi); } -/* Initialise mouse points */ +/* Initialize mouse points. */ static void gpencil_primitive_interaction_begin(tGPDprimitive *tgpi, const wmEvent *event) { copy_v2fl_v2i(tgpi->mval, event->mval); diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c index 20eeab65623..43c8b766c52 100644 --- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c @@ -444,7 +444,9 @@ typedef struct tGPSB_Grab_StrokeData { int size; } tGPSB_Grab_StrokeData; -/* initialise custom data for handling this stroke */ +/** + * Initialize custom data for handling this stroke. + */ static void gpencil_brush_grab_stroke_init(tGP_BrushEditData *gso, bGPDstroke *gps) { tGPSB_Grab_StrokeData *data = NULL; @@ -910,13 +912,13 @@ typedef struct tGPSB_CloneBrushData { GHash *new_colors; } tGPSB_CloneBrushData; -/* Initialise "clone" brush data */ +/* Initialize "clone" brush data. */ static void gpencil_brush_clone_init(bContext *C, tGP_BrushEditData *gso) { tGPSB_CloneBrushData *data; bGPDstroke *gps; - /* init custom data */ + /* Initialize custom-data. */ gso->customdata = data = MEM_callocN(sizeof(tGPSB_CloneBrushData), "CloneBrushData"); /* compute midpoint of strokes on clipboard */ @@ -1188,7 +1190,7 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op) Paint *paint = &ts->gp_sculptpaint->paint; gso->brush = paint->brush; - BKE_curvemapping_initialize(gso->brush->curve); + BKE_curvemapping_init(gso->brush->curve); /* save mask */ gso->mask = ts->gpencil_selectmode_sculpt; @@ -1200,10 +1202,10 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op) /* Init multi-edit falloff curve data before doing anything, * so we won't have to do it again later. */ if (gso->is_multiframe) { - BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff); + BKE_curvemapping_init(ts->gp_sculpt.cur_falloff); } - /* initialise custom data for brushes */ + /* Initialize custom data for brushes. */ char tool = gso->brush->gpencil_sculpt_tool; switch (tool) { case GPSCULPT_TOOL_CLONE: { @@ -1229,13 +1231,13 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op) op->customdata = NULL; return false; } - /* initialise customdata */ + /* Initialize custom-data. */ gpencil_brush_clone_init(C, gso); break; } case GPSCULPT_TOOL_GRAB: { - /* initialise the cache needed for this brush */ + /* Initialize the cache needed for this brush. */ gso->stroke_customdata = BLI_ghash_ptr_new("GP Grab Brush - Strokes Hash"); break; } @@ -1936,7 +1938,7 @@ static int gpencil_sculpt_brush_invoke(bContext *C, wmOperator *op, const wmEven gso = op->customdata; - /* initialise type-specific data (used for the entire session) */ + /* Initialize type-specific data (used for the entire session). */ char tool = gso->brush->gpencil_sculpt_tool; switch (tool) { /* Brushes requiring timer... */ diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index d412c13aea2..f2ccbd6d2cf 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1500,7 +1500,7 @@ void ED_gpencil_add_defaults(bContext *C, Object *ob) if (ts->gp_sculpt.cur_falloff == NULL) { ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff; - BKE_curvemapping_initialize(gp_falloff_curve); + BKE_curvemapping_init(gp_falloff_curve); BKE_curvemap_reset(gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c index c36bc4388d7..b0dff6589da 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_paint.c +++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c @@ -727,7 +727,7 @@ static bool gpencil_vertexpaint_brush_init(bContext *C, wmOperator *op) gso->brush = paint->brush; srgb_to_linearrgb_v3_v3(gso->linear_color, gso->brush->rgb); - BKE_curvemapping_initialize(gso->brush->curve); + BKE_curvemapping_init(gso->brush->curve); gso->is_painting = false; gso->first = true; @@ -759,7 +759,7 @@ static bool gpencil_vertexpaint_brush_init(bContext *C, wmOperator *op) /* Init multi-edit falloff curve data before doing anything, * so we won't have to do it again later. */ if (gso->is_multiframe) { - BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff); + BKE_curvemapping_init(ts->gp_sculpt.cur_falloff); } /* Setup space conversions. */ diff --git a/source/blender/editors/gpencil/gpencil_weight_paint.c b/source/blender/editors/gpencil/gpencil_weight_paint.c index e41146575e4..9d3e9c6ae45 100644 --- a/source/blender/editors/gpencil/gpencil_weight_paint.c +++ b/source/blender/editors/gpencil/gpencil_weight_paint.c @@ -295,7 +295,7 @@ static bool gpencil_weightpaint_brush_init(bContext *C, wmOperator *op) gso->bmain = CTX_data_main(C); gso->brush = paint->brush; - BKE_curvemapping_initialize(gso->brush->curve); + BKE_curvemapping_init(gso->brush->curve); gso->is_painting = false; gso->first = true; @@ -326,7 +326,7 @@ static bool gpencil_weightpaint_brush_init(bContext *C, wmOperator *op) /* Init multi-edit falloff curve data before doing anything, * so we won't have to do it again later. */ if (gso->is_multiframe) { - BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff); + BKE_curvemapping_init(ts->gp_sculpt.cur_falloff); } /* Setup space conversions. */ @@ -453,9 +453,9 @@ static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso, /* To each point individually... */ pt = &gps->points[i]; - pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt; - index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i; + pt_active = pt->runtime.pt_orig; if (pt_active != NULL) { + index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i; gpencil_save_selected_point(gso, gps_active, index, pc1); } @@ -469,9 +469,9 @@ static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso, */ if (i + 1 == gps->totpoints - 1) { pt = &gps->points[i + 1]; - pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt; - index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i + 1; + pt_active = pt->runtime.pt_orig; if (pt_active != NULL) { + index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i + 1; gpencil_save_selected_point(gso, gps_active, index, pc2); include_last = false; } @@ -487,9 +487,9 @@ static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso, * (but wasn't added then, to avoid double-ups). */ pt = &gps->points[i]; - pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt; - index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i; + pt_active = pt->runtime.pt_orig; if (pt_active != NULL) { + index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i; gpencil_save_selected_point(gso, gps_active, index, pc1); include_last = false; diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index d82c7126cf2..6749adb2ea0 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -225,10 +225,10 @@ void ED_armature_ebone_remove(struct bArmature *arm, EditBone *exBone); bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child); EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot); -void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]); -void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]); -void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]); -void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]); +void ED_armature_ebone_to_mat3(EditBone *ebone, float r_mat[3][3]); +void ED_armature_ebone_to_mat4(EditBone *ebone, float r_mat[4][4]); +void ED_armature_ebone_from_mat3(EditBone *ebone, const float mat[3][3]); +void ED_armature_ebone_from_mat4(EditBone *ebone, const float mat[4][4]); EditBone *ED_armature_ebone_find_name(const struct ListBase *edbo, const char *name); EditBone *ED_armature_ebone_get_mirrored(const struct ListBase *edbo, EditBone *ebo); void ED_armature_ebone_transform_mirror_update(struct bArmature *arm, diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 71b7d35908b..ae99edc950a 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -73,7 +73,7 @@ void ED_region_exit(struct bContext *C, struct ARegion *region); void ED_region_remove(struct bContext *C, struct ScrArea *area, struct ARegion *region); void ED_region_pixelspace(struct ARegion *region); void ED_region_update_rect(struct ARegion *region); -void ED_region_floating_initialize(struct ARegion *region); +void ED_region_floating_init(struct ARegion *region); void ED_region_tag_redraw(struct ARegion *region); void ED_region_tag_redraw_partial(struct ARegion *region, const struct rcti *rct, bool rebuild); void ED_region_tag_redraw_cursor(struct ARegion *region); @@ -171,7 +171,7 @@ void ED_spacetypes_keymap(struct wmKeyConfig *keyconf); int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *block, int yco); /* areas */ -void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area); +void ED_area_init(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area); void ED_area_exit(struct bContext *C, struct ScrArea *area); int ED_screen_area_active(const struct bContext *C); void ED_screen_global_areas_refresh(struct wmWindow *win); @@ -221,7 +221,7 @@ ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area); vert_name->next) /* screens */ -void ED_screens_initialize(struct Main *bmain, struct wmWindowManager *wm); +void ED_screens_init(struct Main *bmain, struct wmWindowManager *wm); void ED_screen_draw_edges(struct wmWindow *win); void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2); void ED_screen_draw_split_preview(struct ScrArea *area, const int dir, const float fac); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index f44b099f42e..4060efbda92 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -135,13 +135,13 @@ bool ED_view3d_has_workbench_in_texture_color(const struct Scene *scene, void ED_view3d_cursor3d_position(struct bContext *C, const int mval[2], const bool use_depth, - float cursor_co[3]); + float r_cursor_co[3]); void ED_view3d_cursor3d_position_rotation(struct bContext *C, const int mval[2], const bool use_depth, enum eV3DCursorOrient orientation, - float cursor_co[3], - float cursor_quat[4]); + float r_cursor_co[3], + float r_cursor_quat[4]); void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2], const bool use_depth, @@ -403,10 +403,10 @@ bool ED_view3d_win_to_segment_clipped(struct Depsgraph *depsgraph, const bool do_clip); void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, struct Object *ob, - float pmat[4][4]); + float r_pmat[4][4]); void ED_view3d_ob_project_mat_get_from_obmat(const struct RegionView3D *rv3d, - float obmat[4][4], - float pmat[4][4]); + const float obmat[4][4], + float r_pmat[4][4]); void ED_view3d_project(const struct ARegion *region, const float world[3], float r_region_co[3]); bool ED_view3d_unproject( @@ -460,7 +460,7 @@ void ED_view3d_clipping_calc(struct BoundBox *bb, const struct ARegion *region, const struct Object *ob, const struct rcti *rect); -void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[4][4]); +void ED_view3d_clipping_local(struct RegionView3D *rv3d, const float mat[4][4]); bool ED_view3d_clipping_test(const struct RegionView3D *rv3d, const float co[3], const bool is_local); @@ -601,8 +601,8 @@ void ED_view3d_draw_setup_view(const struct wmWindowManager *wm, struct Scene *scene, struct ARegion *region, struct View3D *v3d, - float viewmat[4][4], - float winmat[4][4], + const float viewmat[4][4], + const float winmat[4][4], const struct rcti *rect); struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); @@ -613,11 +613,11 @@ void ED_view3d_update_viewmat(struct Depsgraph *depsgraph, const struct Scene *scene, struct View3D *v3d, struct ARegion *region, - float viewmat[4][4], - float winmat[4][4], + const float viewmat[4][4], + const float winmat[4][4], const struct rcti *rect, bool offscreen); -bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float quat[4]); +bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float r_quat[4]); bool ED_view3d_quat_to_axis_view(const float viewquat[4], const float epsilon, char *r_view, @@ -676,7 +676,9 @@ void ED_view3d_lock_clear(struct View3D *v3d); #define VIEW3D_MARGIN 1.4f #define VIEW3D_DIST_FALLBACK 1.0f -float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float dist_fallback); +float ED_view3d_offset_distance(const float mat[4][4], + const float ofs[3], + const float dist_fallback); void ED_view3d_distance_set(struct RegionView3D *rv3d, const float dist); bool ED_view3d_distance_set_from_location(struct RegionView3D *rv3d, const float dist_co[3], diff --git a/source/blender/editors/include/ED_view3d_offscreen.h b/source/blender/editors/include/ED_view3d_offscreen.h index 11d1aed1e73..846f4d7eabb 100644 --- a/source/blender/editors/include/ED_view3d_offscreen.h +++ b/source/blender/editors/include/ED_view3d_offscreen.h @@ -49,8 +49,8 @@ void ED_view3d_draw_offscreen(struct Depsgraph *depsgraph, struct ARegion *region, int winx, int winy, - float viewmat[4][4], - float winmat[4][4], + const float viewmat[4][4], + const float winmat[4][4], bool is_image_render, bool do_sky, bool is_persp, @@ -65,8 +65,8 @@ void ED_view3d_draw_offscreen_simple(struct Depsgraph *depsgraph, int winx, int winy, unsigned int draw_flags, - float viewmat[4][4], - float winmat[4][4], + const float viewmat[4][4], + const float winmat[4][4], float clip_start, float clip_end, bool is_image_render, diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index 1f8af7b9e6e..1773a7b3057 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -367,7 +367,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *area) ED_area_update_region_sizes(wm, win, area); } - ED_region_floating_initialize(region); + ED_region_floating_init(region); ED_region_tag_redraw(region); /* Reset zoom level (not well supported). */ diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index 2ad7e517c60..13c85952f52 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -759,7 +759,7 @@ uiBlock *ui_popup_block_refresh(bContext *C, ui_popup_block_scrolltest(block); /* adds subwindow */ - ED_region_floating_initialize(region); + ED_region_floating_init(region); /* get winmat now that we actually have the subwindow */ wmGetProjectionMatrix(block->winmat, ®ion->winrct); diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c index a9e87f4cc07..80155e3e871 100644 --- a/source/blender/editors/interface/interface_region_search.c +++ b/source/blender/editors/interface/interface_region_search.c @@ -819,7 +819,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but } /* adds subwindow */ - ED_region_floating_initialize(region); + ED_region_floating_init(region); /* notify change and redraw */ ED_region_tag_redraw(region); diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 7c64e4c2709..41b41cb3d75 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -1386,7 +1386,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C, } /* adds subwindow */ - ED_region_floating_initialize(region); + ED_region_floating_init(region); /* notify change and redraw */ ED_region_tag_redraw(region); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 0cbf73280a3..3efed43e08c 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -242,7 +242,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) bool tot_changed = false, do_init; const uiStyle *style = UI_style_get(); - do_init = (v2d->flag & V2D_IS_INITIALISED) == 0; + do_init = (v2d->flag & V2D_IS_INIT) == 0; /* see eView2D_CommonViewTypes in UI_view2d.h for available view presets */ switch (type) { @@ -374,8 +374,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) break; } - /* set initialized flag so that View2D doesn't get reinitialised next time again */ - v2d->flag |= V2D_IS_INITIALISED; + /* set initialized flag so that View2D doesn't get reinitialized next time again */ + v2d->flag |= V2D_IS_INIT; /* store view size */ v2d->winx = winx; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 64cacd44e3d..d62058699d9 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -56,7 +56,7 @@ static bool view2d_poll(bContext *C) { ARegion *region = CTX_wm_region(C); - return (region != NULL) && (region->v2d.flag & V2D_IS_INITIALISED); + return (region != NULL) && (region->v2d.flag & V2D_IS_INIT); } /** \} */ diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index e41445aef09..589b51ce942 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -93,6 +93,10 @@ if(WITH_BULLET) add_definitions(-DWITH_BULLET) endif() +if(WITH_GMP) + add_definitions(-DWITH_GMP) +endif() + add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c index fad6806ae73..1803ea7fb63 100644 --- a/source/blender/editors/mesh/editmesh_intersect.c +++ b/source/blender/editors/mesh/editmesh_intersect.c @@ -143,7 +143,11 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op) bool use_separate_cut = false; const int separate_mode = RNA_enum_get(op->ptr, "separate_mode"); const float eps = RNA_float_get(op->ptr, "threshold"); +#ifdef WITH_GMP const bool exact = RNA_boolean_get(op->ptr, "use_exact"); +#else + const bool exact = false; +#endif bool use_self; bool has_isect; @@ -266,11 +270,13 @@ void MESH_OT_intersect(struct wmOperatorType *ot) ot->srna, "separate_mode", isect_separate_items, ISECT_SEPARATE_CUT, "Separate Mode", ""); RNA_def_float_distance( ot->srna, "threshold", 0.000001f, 0.0, 0.01, "Merge threshold", "", 0.0, 0.001); +#ifdef WITH_GMP RNA_def_boolean(ot->srna, "use_exact", true, "Exact", "Use the Exact-arithmetic boolean (slower, handles more cases"); +#endif /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -294,7 +300,11 @@ static int edbm_intersect_boolean_exec(bContext *C, wmOperator *op) const int boolean_operation = RNA_enum_get(op->ptr, "operation"); bool use_swap = RNA_boolean_get(op->ptr, "use_swap"); bool use_self = RNA_boolean_get(op->ptr, "use_self"); +#ifdef WITH_GMP bool use_exact = RNA_boolean_get(op->ptr, "use_exact"); +#else + bool use_exact = false; +#endif const float eps = RNA_float_get(op->ptr, "threshold"); int (*test_fn)(BMFace *, void *); bool has_isect; @@ -380,11 +390,13 @@ void MESH_OT_intersect_boolean(struct wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_self", false, "Self", "Do self-union or self-intersection"); RNA_def_float_distance( ot->srna, "threshold", 0.000001f, 0.0, 0.01, "Merge threshold", "", 0.0, 0.001); +#ifdef WITH_GMP RNA_def_boolean(ot->srna, "use_exact", true, "Exact", "Use the Exact-arithmetic boolean (slower, handles more cases"); +#endif /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f92dafcc7f9..4270f1cbc72 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -255,13 +255,13 @@ void ED_object_base_init_transform_on_add(Object *object, const float loc[3], co /* Uses context to figure out transform for primitive. * Returns standard diameter. */ float ED_object_new_primitive_matrix( - bContext *C, Object *obedit, const float loc[3], const float rot[3], float primmat[4][4]) + bContext *C, Object *obedit, const float loc[3], const float rot[3], float r_primmat[4][4]) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3]; - unit_m4(primmat); + unit_m4(r_primmat); eul_to_mat3(rmat, rot); invert_m3(rmat); @@ -270,13 +270,13 @@ float ED_object_new_primitive_matrix( copy_m3_m4(mat, obedit->obmat); mul_m3_m3m3(cmat, rmat, mat); invert_m3_m3(imat, cmat); - copy_m4_m3(primmat, imat); + copy_m4_m3(r_primmat, imat); /* center */ - copy_v3_v3(primmat[3], loc); - sub_v3_v3v3(primmat[3], primmat[3], obedit->obmat[3]); + copy_v3_v3(r_primmat[3], loc); + sub_v3_v3v3(r_primmat[3], r_primmat[3], obedit->obmat[3]); invert_m3_m3(imat, mat); - mul_m3_v3(imat, primmat[3]); + mul_m3_v3(imat, r_primmat[3]); { const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : @@ -1237,7 +1237,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op) break; } - /* if this is a new object, initialise default stuff (colors, etc.) */ + /* If this is a new object, initialize default stuff (colors, etc.) */ if (newob) { /* set default viewport color to black */ copy_v3_fl(ob->color, 0.0f); diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 926a47b1ec8..cb92fab3cb0 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -673,7 +673,7 @@ static void build_image_lookup(Main *bmain, Object *ob, BakeImages *bake_images) /* * returns the total number of pixels */ -static size_t initialize_internal_images(BakeImages *bake_images, ReportList *reports) +static size_t init_internal_images(BakeImages *bake_images, ReportList *reports) { int i; size_t tot_size = 0; @@ -828,7 +828,7 @@ static int bake(Render *re, build_image_lookup(bmain, ob_low, &bake_images); if (is_save_internal) { - num_pixels = initialize_internal_images(&bake_images, reports); + num_pixels = init_internal_images(&bake_images, reports); if (num_pixels == 0) { goto cleanup; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 749c6cd640e..82a1139c860 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4346,7 +4346,7 @@ static int brush_add(const bContext *C, PEData *data, short number) } pa->size = 1.0f; - initialize_particle(&sim, pa); + init_particle(&sim, pa); reset_particle(&sim, pa, 0.0, 1.0); point->flag |= PEP_EDIT_RECALC; if (pe_x_mirror(ob)) { diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 3d3936523f9..d279958df8a 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -962,7 +962,7 @@ static void screen_opengl_render_cancel(bContext *C, wmOperator *op) } /* share between invoke and exec */ -static bool screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) +static bool screen_opengl_render_anim_init(bContext *C, wmOperator *op) { /* initialize animation */ OGLRender *oglrender; @@ -1256,7 +1256,7 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, const wmEven } if (anim) { - if (!screen_opengl_render_anim_initialize(C, op)) { + if (!screen_opengl_render_anim_init(C, op)) { return OPERATOR_CANCELLED; } } @@ -1292,7 +1292,7 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op) bool ret = true; - if (!screen_opengl_render_anim_initialize(C, op)) { + if (!screen_opengl_render_anim_init(C, op)) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index f87f631c643..a9a5393b24d 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -813,7 +813,7 @@ void ED_workspace_status_text(bContext *C, const char *str) /* ************************************************************ */ -static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea *area) +static void area_azone_init(wmWindow *win, const bScreen *screen, ScrArea *area) { AZone *az; @@ -883,7 +883,7 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea } } -static void fullscreen_azone_initialize(ScrArea *area, ARegion *region) +static void fullscreen_azone_init(ScrArea *area, ARegion *region) { AZone *az; @@ -1007,10 +1007,10 @@ static bool region_azone_edge_poll(const ARegion *region, const bool is_fullscre return true; } -static void region_azone_edge_initialize(ScrArea *area, - ARegion *region, - AZEdge edge, - const bool is_fullscreen) +static void region_azone_edge_init(ScrArea *area, + ARegion *region, + AZEdge edge, + const bool is_fullscreen) { AZone *az = NULL; const bool is_hidden = (region->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)); @@ -1033,9 +1033,9 @@ static void region_azone_edge_initialize(ScrArea *area, } } -static void region_azone_scrollbar_initialize(ScrArea *area, - ARegion *region, - AZScrollDirection direction) +static void region_azone_scrollbar_init(ScrArea *area, + ARegion *region, + AZScrollDirection direction) { rcti scroller_vert = (direction == AZ_SCROLL_VERT) ? region->v2d.vert : region->v2d.hor; AZone *az = MEM_callocN(sizeof(*az), __func__); @@ -1061,16 +1061,16 @@ static void region_azone_scrollbar_initialize(ScrArea *area, BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } -static void region_azones_scrollbars_initialize(ScrArea *area, ARegion *region) +static void region_azones_scrollbars_init(ScrArea *area, ARegion *region) { const View2D *v2d = ®ion->v2d; if ((v2d->scroll & V2D_SCROLL_VERTICAL) && ((v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) == 0)) { - region_azone_scrollbar_initialize(area, region, AZ_SCROLL_VERT); + region_azone_scrollbar_init(area, region, AZ_SCROLL_VERT); } if ((v2d->scroll & V2D_SCROLL_HORIZONTAL) && ((v2d->scroll & V2D_SCROLL_HORIZONTAL_HANDLES) == 0)) { - region_azone_scrollbar_initialize(area, region, AZ_SCROLL_HOR); + region_azone_scrollbar_init(area, region, AZ_SCROLL_HOR); } } @@ -1083,16 +1083,16 @@ static void region_azones_add_edge(ScrArea *area, /* edge code (t b l r) is along which area edge azone will be drawn */ if (alignment == RGN_ALIGN_TOP) { - region_azone_edge_initialize(area, region, AE_BOTTOM_TO_TOPLEFT, is_fullscreen); + region_azone_edge_init(area, region, AE_BOTTOM_TO_TOPLEFT, is_fullscreen); } else if (alignment == RGN_ALIGN_BOTTOM) { - region_azone_edge_initialize(area, region, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen); + region_azone_edge_init(area, region, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen); } else if (alignment == RGN_ALIGN_RIGHT) { - region_azone_edge_initialize(area, region, AE_LEFT_TO_TOPRIGHT, is_fullscreen); + region_azone_edge_init(area, region, AE_LEFT_TO_TOPRIGHT, is_fullscreen); } else if (alignment == RGN_ALIGN_LEFT) { - region_azone_edge_initialize(area, region, AE_RIGHT_TO_TOPLEFT, is_fullscreen); + region_azone_edge_init(area, region, AE_RIGHT_TO_TOPLEFT, is_fullscreen); } } @@ -1116,10 +1116,10 @@ static void region_azones_add(const bScreen *screen, ScrArea *area, ARegion *reg } if (is_fullscreen) { - fullscreen_azone_initialize(area, region); + fullscreen_azone_init(area, region); } - region_azones_scrollbars_initialize(area, region); + region_azones_scrollbars_init(area, region); } /* dir is direction to check, not the splitting edge direction! */ @@ -1828,7 +1828,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar region_rect_recursive(area, area->regionbase.first, &rect, &overlap_rect, 0); /* Dynamically sized regions may have changed region sizes, so we have to force azone update. */ - area_azone_initialize(win, screen, area); + area_azone_init(win, screen, area); LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { region_subwindow(region); @@ -1847,7 +1847,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar } /* called in screen_refresh, or screens_init, also area size changes */ -void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *area) +void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area) { WorkSpace *workspace = WM_window_get_active_workspace(win); const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); @@ -1890,7 +1890,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *area) } /* clear all azones, add the area triangle widgets */ - area_azone_initialize(win, screen, area); + area_azone_init(win, screen, area); /* region windows, default and own handlers */ for (region = area->regionbase.first; region; region = region->next) { @@ -1944,7 +1944,7 @@ void ED_region_update_rect(ARegion *region) } /* externally called for floating regions like menus */ -void ED_region_floating_initialize(ARegion *region) +void ED_region_floating_init(ARegion *region) { BLI_assert(region->alignment == RGN_ALIGN_FLOAT); @@ -1980,7 +1980,7 @@ void ED_region_visibility_change_update(bContext *C, ScrArea *area, ARegion *reg WM_event_remove_handlers(C, ®ion->handlers); } - ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), area); + ED_area_init(CTX_wm_manager(C), CTX_wm_window(C), area); ED_area_tag_redraw(area); } @@ -2066,8 +2066,8 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) ED_area_data_copy(tmp, sa1, false); ED_area_data_copy(sa1, sa2, true); ED_area_data_copy(sa2, tmp, true); - ED_area_initialize(CTX_wm_manager(C), win, sa1); - ED_area_initialize(CTX_wm_manager(C), win, sa2); + ED_area_init(CTX_wm_manager(C), win, sa1); + ED_area_init(CTX_wm_manager(C), win, sa2); BKE_screen_area_free(tmp); MEM_freeN(tmp); @@ -2204,7 +2204,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi } } - ED_area_initialize(CTX_wm_manager(C), win, area); + ED_area_init(CTX_wm_manager(C), win, area); /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(win); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index b6f210d7f13..ee998e0605a 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -516,7 +516,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) ED_screen_areas_iter (win, screen, area) { /* set spacetype and region callbacks, calls init() */ /* sets subwindows for regions, adds handlers */ - ED_area_initialize(wm, win, area); + ED_area_init(wm, win, area); } /* wake up animtimer */ @@ -536,7 +536,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) } /* file read, set all screens, ... */ -void ED_screens_initialize(Main *bmain, wmWindowManager *wm) +void ED_screens_init(Main *bmain, wmWindowManager *wm) { wmWindow *win; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index fde1498bc5e..f4d36a15d30 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -5184,7 +5184,7 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running else { if (rgi->hidden) { rgi->region->flag |= rgi->hidden; - ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), rgi->area); + ED_area_init(CTX_wm_manager(C), CTX_wm_window(C), rgi->area); } /* area decoration needs redraw in end */ ED_area_tag_redraw(rgi->area); @@ -5215,7 +5215,7 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe /* blend in, reinitialize regions because it got unhidden */ if (rgi->hidden == 0) { - ED_area_initialize(wm, win, area); + ED_area_init(wm, win, area); } else { WM_event_remove_handlers(C, ®ion->handlers); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index da39fbcf0ce..9398e4443f3 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -455,7 +455,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) } buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); - BKE_curvemapping_initialize(br->curve); + BKE_curvemapping_init(br->curve); LoadTexData data = { .br = br, diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 5991032536b..af2762889e8 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -6173,7 +6173,7 @@ static bool texture_paint_image_from_view_poll(bContext *C) CTX_wm_operator_poll_msg_set(C, "No 3D viewport found to create image from"); return false; } - if (G.background || !GPU_is_initialized()) { + if (G.background || !GPU_is_init()) { return false; } return true; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index caecc7b708a..b9361726826 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -920,9 +920,9 @@ PaintStroke *paint_stroke_new(bContext *C, ups->average_stroke_counter = 0; /* initialize here to avoid initialization conflict with threaded strokes */ - BKE_curvemapping_initialize(br->curve); + BKE_curvemapping_init(br->curve); if (p->flags & PAINT_USE_CAVITY_MASK) { - BKE_curvemapping_initialize(p->cavity_curve); + BKE_curvemapping_init(p->cavity_curve); } BKE_paint_set_overlay_override(br->overlay_flags); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 6965946d2ce..83d76c166ce 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -811,7 +811,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) VPaint *wp = ts->wpaint; struct Brush *brush = BKE_paint_brush(&wp->paint); - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); data.brush = brush; data.weightpaint = BKE_brush_weight_get(scene, brush); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 2c110e23ac0..a3396a80444 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2966,7 +2966,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) /* XXX - this shouldn't be necessary, but sculpting crashes in blender2.8 otherwise * initialize before threads so they can do curve mapping. */ - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); /* Threaded loop over nodes. */ SculptThreadedTaskData data = { @@ -3043,7 +3043,7 @@ static void do_draw_sharp_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to /* XXX - this shouldn't be necessary, but sculpting crashes in blender2.8 otherwise * initialize before threads so they can do curve mapping. */ - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); /* Threaded loop over nodes. */ SculptThreadedTaskData data = { @@ -3273,7 +3273,7 @@ static void do_slide_relax_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t return; } - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); SculptThreadedTaskData data = { .sd = sd, @@ -6390,7 +6390,7 @@ static void sculpt_update_cache_invariants( brush = br; cache->saved_smooth_size = BKE_brush_size_get(scene, brush); BKE_brush_size_set(scene, brush, size); - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); } } } @@ -6458,7 +6458,7 @@ static void sculpt_update_cache_invariants( #define PIXEL_INPUT_THRESHHOLD 5 if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) { - cache->dial = BLI_dial_initialize(cache->initial_mouse, PIXEL_INPUT_THRESHHOLD); + cache->dial = BLI_dial_init(cache->initial_mouse, PIXEL_INPUT_THRESHHOLD); } #undef PIXEL_INPUT_THRESHHOLD diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index 39cab883100..371f673625e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -477,7 +477,7 @@ static SculptClothSimulation *cloth_brush_simulation_create(SculptSession *ss, cloth_sim->length_constraint_tweak = MEM_calloc_arrayN( totverts, sizeof(float), "cloth sim length tweak"); - /* Brush can be NULL for tools that neeed the solver but don't rely on constraint to deformation + /* Brush can be NULL for tools that need the solver but don't rely on constraint to deformation * positions. */ if (brush && SCULPT_is_cloth_deform_brush(brush)) { cloth_sim->deformation_pos = MEM_calloc_arrayN( @@ -680,7 +680,7 @@ static void cloth_brush_apply_brush_foces(Sculpt *sd, Object *ob, PBVHNode **nod .mat = imat, }; - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); /* Init the grab delta. */ copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry); diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c index 1940b007cb0..5cc32be331e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.c +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c @@ -192,7 +192,7 @@ void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in SculptSession *ss = ob->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); /* Threaded loop over nodes. */ SculptThreadedTaskData data = { diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c index f01a914fdd3..00a59949130 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c @@ -255,7 +255,7 @@ void SCULPT_do_paint_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode return; } - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); float area_no[3]; float mat[4][4]; @@ -468,7 +468,7 @@ void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode } } - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); SculptThreadedTaskData data = { .sd = sd, diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.c b/source/blender/editors/sculpt_paint/sculpt_pose.c index a338b5346af..976006b3958 100644 --- a/source/blender/editors/sculpt_paint/sculpt_pose.c +++ b/source/blender/editors/sculpt_paint/sculpt_pose.c @@ -1000,7 +1000,7 @@ void SCULPT_pose_brush_init(Sculpt *sd, Object *ob, SculptSession *ss, Brush *br static void sculpt_pose_do_translate_deform(SculptSession *ss, Brush *brush) { SculptPoseIKChain *ik_chain = ss->cache->pose_ik_chain; - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); pose_solve_translate_chain(ik_chain, ss->cache->grab_delta); } @@ -1041,7 +1041,7 @@ static void sculpt_pose_do_twist_deform(SculptSession *ss, Brush *brush) /* Calculate the maximum roll. 0.02 radians per pixel works fine. */ float roll = (ss->cache->initial_mouse[0] - ss->cache->mouse[0]) * ss->cache->bstrength * 0.02f; - BKE_curvemapping_initialize(brush->curve); + BKE_curvemapping_init(brush->curve); pose_solve_roll_chain(ik_chain, brush, roll); } diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 4b3df2dfea2..be509f4aed6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -488,7 +488,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm op->customdata = data; - BKE_curvemapping_initialize(ts->uvsculpt->paint.brush->curve); + BKE_curvemapping_init(ts->uvsculpt->paint.brush->curve); if (data) { int counter = 0, i; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 37d5f602291..0aea7e4b73c 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -684,7 +684,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) if (main_visible) { if (region_main && (region_main->flag & RGN_FLAG_HIDDEN)) { region_main->flag &= ~RGN_FLAG_HIDDEN; - region_main->v2d.flag &= ~V2D_IS_INITIALISED; + region_main->v2d.flag &= ~V2D_IS_INIT; view_changed = true; } @@ -696,7 +696,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) else { if (region_main && !(region_main->flag & RGN_FLAG_HIDDEN)) { region_main->flag |= RGN_FLAG_HIDDEN; - region_main->v2d.flag &= ~V2D_IS_INITIALISED; + region_main->v2d.flag &= ~V2D_IS_INIT; WM_event_remove_handlers((bContext *)C, ®ion_main->handlers); view_changed = true; } @@ -709,7 +709,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) if (properties_visible) { if (region_properties && (region_properties->flag & RGN_FLAG_HIDDEN)) { region_properties->flag &= ~RGN_FLAG_HIDDEN; - region_properties->v2d.flag &= ~V2D_IS_INITIALISED; + region_properties->v2d.flag &= ~V2D_IS_INIT; view_changed = true; } if (region_properties && region_properties->alignment != RGN_ALIGN_RIGHT) { @@ -720,7 +720,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) else { if (region_properties && !(region_properties->flag & RGN_FLAG_HIDDEN)) { region_properties->flag |= RGN_FLAG_HIDDEN; - region_properties->v2d.flag &= ~V2D_IS_INITIALISED; + region_properties->v2d.flag &= ~V2D_IS_INIT; WM_event_remove_handlers((bContext *)C, ®ion_properties->handlers); view_changed = true; } @@ -733,7 +733,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) if (tools_visible) { if (region_tools && (region_tools->flag & RGN_FLAG_HIDDEN)) { region_tools->flag &= ~RGN_FLAG_HIDDEN; - region_tools->v2d.flag &= ~V2D_IS_INITIALISED; + region_tools->v2d.flag &= ~V2D_IS_INIT; view_changed = true; } if (region_tools && region_tools->alignment != RGN_ALIGN_LEFT) { @@ -744,7 +744,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) else { if (region_tools && !(region_tools->flag & RGN_FLAG_HIDDEN)) { region_tools->flag |= RGN_FLAG_HIDDEN; - region_tools->v2d.flag &= ~V2D_IS_INITIALISED; + region_tools->v2d.flag &= ~V2D_IS_INIT; WM_event_remove_handlers((bContext *)C, ®ion_tools->handlers); view_changed = true; } @@ -757,7 +757,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) if (preview_visible) { if (region_preview && (region_preview->flag & RGN_FLAG_HIDDEN)) { region_preview->flag &= ~RGN_FLAG_HIDDEN; - region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + region_preview->v2d.flag &= ~V2D_IS_INIT; region_preview->v2d.cur = region_preview->v2d.tot; view_changed = true; } @@ -769,7 +769,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) else { if (region_preview && !(region_preview->flag & RGN_FLAG_HIDDEN)) { region_preview->flag |= RGN_FLAG_HIDDEN; - region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + region_preview->v2d.flag &= ~V2D_IS_INIT; WM_event_remove_handlers((bContext *)C, ®ion_preview->handlers); view_changed = true; } @@ -782,7 +782,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) if (channels_visible) { if (region_channels && (region_channels->flag & RGN_FLAG_HIDDEN)) { region_channels->flag &= ~RGN_FLAG_HIDDEN; - region_channels->v2d.flag &= ~V2D_IS_INITIALISED; + region_channels->v2d.flag &= ~V2D_IS_INIT; view_changed = true; } if (region_channels && region_channels->alignment != RGN_ALIGN_LEFT) { @@ -793,7 +793,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) else { if (region_channels && !(region_channels->flag & RGN_FLAG_HIDDEN)) { region_channels->flag |= RGN_FLAG_HIDDEN; - region_channels->v2d.flag &= ~V2D_IS_INITIALISED; + region_channels->v2d.flag &= ~V2D_IS_INIT; WM_event_remove_handlers((bContext *)C, ®ion_channels->handlers); view_changed = true; } @@ -804,7 +804,7 @@ static void clip_refresh(const bContext *C, ScrArea *area) } if (view_changed) { - ED_area_initialize(wm, window, area); + ED_area_init(wm, window, area); ED_area_tag_redraw(area); } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 43939b9ff54..355597cddf1 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -235,7 +235,7 @@ static void file_ensure_valid_region_state(bContext *C, ARegion *region_ui = BKE_area_find_region_type(area, RGN_TYPE_UI); ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_TOOL_PROPS); ARegion *region_execute = BKE_area_find_region_type(area, RGN_TYPE_EXECUTE); - bool needs_init = false; /* To avoid multiple ED_area_initialize() calls. */ + bool needs_init = false; /* To avoid multiple ED_area_init() calls. */ /* If there's an file-operation, ensure we have the option and execute region */ if (sfile->op && (region_props == NULL)) { @@ -261,7 +261,7 @@ static void file_ensure_valid_region_state(bContext *C, } if (needs_init) { - ED_area_initialize(wm, win, area); + ED_area_init(wm, win, area); } } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 68fdef54a53..90fe95c6818 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1487,7 +1487,7 @@ static int graphkeys_decimate_invoke(bContext *C, wmOperator *op, const wmEvent dgo->area = CTX_wm_area(C); dgo->region = CTX_wm_region(C); - /* initialise percentage so that it will have the correct value before the first mouse move. */ + /* Initialize percentage so that it will have the correct value before the first mouse move. */ decimate_mouse_update_percentage(dgo, op, event); decimate_draw_status_header(op, dgo); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index d05fe215840..1a98ec0e7c1 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3714,7 +3714,7 @@ static void draw_fill_tile(PointerRNA *ptr, uiLayout *layout) uiItemR(col[1], ptr, "float", 0, NULL, ICON_NONE); } -static void initialize_fill_tile(PointerRNA *ptr, Image *ima, ImageTile *tile) +static void tile_fill_init(PointerRNA *ptr, Image *ima, ImageTile *tile) { ImageUser iuser; BKE_imageuser_default(&iuser); @@ -3827,7 +3827,7 @@ static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev } ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index); - initialize_fill_tile(op->ptr, ima, tile); + tile_fill_init(op->ptr, ima, tile); RNA_int_set(op->ptr, "number", next_number); RNA_int_set(op->ptr, "count", 1); @@ -3973,7 +3973,7 @@ static int tile_fill_exec(bContext *C, wmOperator *op) static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - initialize_fill_tile(op->ptr, CTX_data_edit_image(C), NULL); + tile_fill_init(op->ptr, CTX_data_edit_image(C), NULL); return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X); } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 2f85eb10e77..4dcf5822bb2 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2924,8 +2924,8 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) } /* This moves strips from meta to parent, sating within same edit and no new strips are - * allocated. If the UUID was unique already (as it should) it will stay unique. Nn need to - * re-generate the UUIDs.*/ + * allocated. If the UUID was unique already (as it should) it will stay unique. + * No need to re-generate the UUIDs. */ BLI_movelisttolist(ed->seqbasep, &last_seq->seqbase); BLI_listbase_clear(&last_seq->seqbase); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 926752c6488..fa5e2ea02ff 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -231,12 +231,12 @@ static void sequencer_refresh(const bContext *C, ScrArea *area) case SEQ_VIEW_SEQUENCE: if (region_main && (region_main->flag & RGN_FLAG_HIDDEN)) { region_main->flag &= ~RGN_FLAG_HIDDEN; - region_main->v2d.flag &= ~V2D_IS_INITIALISED; + region_main->v2d.flag &= ~V2D_IS_INIT; view_changed = true; } if (region_preview && !(region_preview->flag & RGN_FLAG_HIDDEN)) { region_preview->flag |= RGN_FLAG_HIDDEN; - region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + region_preview->v2d.flag &= ~V2D_IS_INIT; WM_event_remove_handlers((bContext *)C, ®ion_preview->handlers); view_changed = true; } @@ -252,13 +252,13 @@ static void sequencer_refresh(const bContext *C, ScrArea *area) case SEQ_VIEW_PREVIEW: if (region_main && !(region_main->flag & RGN_FLAG_HIDDEN)) { region_main->flag |= RGN_FLAG_HIDDEN; - region_main->v2d.flag &= ~V2D_IS_INITIALISED; + region_main->v2d.flag &= ~V2D_IS_INIT; WM_event_remove_handlers((bContext *)C, ®ion_main->handlers); view_changed = true; } if (region_preview && (region_preview->flag & RGN_FLAG_HIDDEN)) { region_preview->flag &= ~RGN_FLAG_HIDDEN; - region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + region_preview->v2d.flag &= ~V2D_IS_INIT; region_preview->v2d.cur = region_preview->v2d.tot; view_changed = true; } @@ -281,13 +281,13 @@ static void sequencer_refresh(const bContext *C, ScrArea *area) * 'full window' views before, though... Better than nothing. */ if (region_main->flag & RGN_FLAG_HIDDEN) { region_main->flag &= ~RGN_FLAG_HIDDEN; - region_main->v2d.flag &= ~V2D_IS_INITIALISED; + region_main->v2d.flag &= ~V2D_IS_INIT; region_preview->sizey = (int)(height - region_main->sizey); view_changed = true; } if (region_preview->flag & RGN_FLAG_HIDDEN) { region_preview->flag &= ~RGN_FLAG_HIDDEN; - region_preview->v2d.flag &= ~V2D_IS_INITIALISED; + region_preview->v2d.flag &= ~V2D_IS_INIT; region_preview->v2d.cur = region_preview->v2d.tot; region_main->sizey = (int)(height - region_preview->sizey); view_changed = true; @@ -312,7 +312,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *area) } if (view_changed) { - ED_area_initialize(wm, window, area); + ED_area_init(wm, window, area); ED_area_tag_redraw(area); } } diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index 9eae722d5c8..92f9c187ce5 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -115,7 +115,7 @@ static void userpref_main_region_init(wmWindowManager *wm, ARegion *region) { /* do not use here, the properties changed in userprefs do a system-wide refresh, * then scroller jumps back */ - /* region->v2d.flag &= ~V2D_IS_INITIALISED; */ + /* region->v2d.flag &= ~V2D_IS_INIT; */ region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c index 7e63d650409..1d5b33e7b90 100644 --- a/source/blender/editors/space_view3d/view3d_camera_control.c +++ b/source/blender/editors/space_view3d/view3d_camera_control.c @@ -198,6 +198,56 @@ struct View3DCameraControl *ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph } /** + * A version of #BKE_object_apply_mat4 that respects #Object.protectflag, + * applying the locking back to the view to avoid the view. + * This is needed so the view doesn't get out of sync with the object, + * causing visible jittering when in fly/walk mode for e.g. + * + * \note This could be exposed as an API option, as we might not want the view + * to be constrained by the thing it's controlling. + */ +static bool object_apply_mat4_with_protect(Object *ob, + const float obmat[4][4], + const bool use_parent, + /* Only use when applying lock. */ + RegionView3D *rv3d, + const float view_mat[4][4]) +{ + const bool use_protect = (ob->protectflag != 0); + bool view_changed = false; + + ObjectTfmProtectedChannels obtfm; + if (use_protect) { + BKE_object_tfm_protected_backup(ob, &obtfm); + } + + BKE_object_apply_mat4(ob, obmat, true, use_parent); + + if (use_protect) { + float obmat_noprotect[4][4], obmat_protect[4][4]; + + BKE_object_to_mat4(ob, obmat_noprotect); + BKE_object_tfm_protected_restore(ob, &obtfm, ob->protectflag); + BKE_object_to_mat4(ob, obmat_protect); + + if (!equals_m4m4(obmat_noprotect, obmat_protect)) { + /* Apply the lock protection back to the view, without this the view + * keeps moving, ignoring the object locking, causing jittering in some cases. */ + float diff_mat[4][4]; + float view_mat_protect[4][4]; + float obmat_noprotect_inv[4][4]; + invert_m4_m4(obmat_noprotect_inv, obmat_noprotect); + mul_m4_m4m4(diff_mat, obmat_protect, obmat_noprotect_inv); + + mul_m4_m4m4(view_mat_protect, diff_mat, view_mat); + ED_view3d_from_m4(view_mat_protect, rv3d->ofs, rv3d->viewquat, &rv3d->dist); + view_changed = true; + } + } + return view_changed; +} + +/** * Updates cameras from the ``rv3d`` values, optionally auto-keyframing. */ void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl, @@ -216,21 +266,25 @@ void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl, ID *id_key; + float view_mat[4][4]; + ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); + /* transform the parent or the camera? */ if (vctrl->root_parent) { Object *ob_update; - float view_mat[4][4]; float prev_view_imat[4][4]; float diff_mat[4][4]; float parent_mat[4][4]; invert_m4_m4(prev_view_imat, vctrl->view_mat_prev); - ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); mul_m4_m4m4(diff_mat, view_mat, prev_view_imat); mul_m4_m4m4(parent_mat, diff_mat, vctrl->root_parent->obmat); - BKE_object_apply_mat4(vctrl->root_parent, parent_mat, true, false); + if (object_apply_mat4_with_protect(vctrl->root_parent, parent_mat, false, rv3d, view_mat)) { + /* Calculate again since the view locking changes the matrix. */ + ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); + } ob_update = v3d->camera->parent; while (ob_update) { @@ -243,18 +297,16 @@ void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl, id_key = &vctrl->root_parent->id; } else { - float view_mat[4][4]; float scale_mat[4][4]; float scale_back[3]; /* even though we handle the scale matrix, this still changes over time */ copy_v3_v3(scale_back, v3d->camera->scale); - ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); size_to_mat4(scale_mat, v3d->camera->scale); mul_m4_m4m4(view_mat, view_mat, scale_mat); - BKE_object_apply_mat4(v3d->camera, view_mat, true, true); + object_apply_mat4_with_protect(v3d->camera, view_mat, true, rv3d, view_mat); DEG_id_tag_update(&v3d->camera->id, ID_RECALC_TRANSFORM); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 411b18717bf..cf132a1a0c0 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -115,8 +115,8 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph, const Scene *scene, View3D *v3d, ARegion *region, - float viewmat[4][4], - float winmat[4][4], + const float viewmat[4][4], + const float winmat[4][4], const rcti *rect, bool offscreen) { @@ -197,8 +197,8 @@ static void view3d_main_region_setup_view(Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *region, - float viewmat[4][4], - float winmat[4][4], + const float viewmat[4][4], + const float winmat[4][4], const rcti *rect) { RegionView3D *rv3d = region->regiondata; @@ -214,8 +214,8 @@ static void view3d_main_region_setup_offscreen(Depsgraph *depsgraph, const Scene *scene, View3D *v3d, ARegion *region, - float viewmat[4][4], - float winmat[4][4]) + const float viewmat[4][4], + const float winmat[4][4]) { RegionView3D *rv3d = region->regiondata; ED_view3d_update_viewmat(depsgraph, scene, v3d, region, viewmat, winmat, NULL, true); @@ -353,8 +353,8 @@ void ED_view3d_draw_setup_view(const wmWindowManager *wm, Scene *scene, ARegion *region, View3D *v3d, - float viewmat[4][4], - float winmat[4][4], + const float viewmat[4][4], + const float winmat[4][4], const rcti *rect) { RegionView3D *rv3d = region->regiondata; @@ -1640,7 +1640,7 @@ static void view3d_stereo3d_setup_offscreen(Depsgraph *depsgraph, const Scene *scene, View3D *v3d, ARegion *region, - float winmat[4][4], + const float winmat[4][4], const char *viewname) { /* update the viewport matrices with the new camera */ @@ -1667,8 +1667,8 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph, ARegion *region, int winx, int winy, - float viewmat[4][4], - float winmat[4][4], + const float viewmat[4][4], + const float winmat[4][4], bool is_image_render, bool do_sky, bool UNUSED(is_persp), @@ -1759,8 +1759,8 @@ void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph, int winx, int winy, uint draw_flags, - float viewmat[4][4], - float winmat[4][4], + const float viewmat[4][4], + const float winmat[4][4], float clip_start, float clip_end, bool is_image_render, @@ -2406,7 +2406,7 @@ struct RV3DMatrixStore *ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d) copy_m4_m4(rv3dmat->viewinv, rv3d->viewinv); copy_v4_v4(rv3dmat->viewcamtexcofac, rv3d->viewcamtexcofac); rv3dmat->pixsize = rv3d->pixsize; - return (void *)rv3dmat; + return rv3dmat; } void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat_pt) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index bf02845058e..19aa9cb203b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4868,7 +4868,9 @@ void VIEW3D_OT_background_image_remove(wmOperatorType *ot) * Draw border or toggle off. * \{ */ -static void calc_local_clipping(float clip_local[6][4], BoundBox *clipbb, float mat[4][4]) +static void calc_local_clipping(float clip_local[6][4], + const BoundBox *clipbb, + const float mat[4][4]) { BoundBox clipbb_local; float imat[4][4]; @@ -4883,7 +4885,7 @@ static void calc_local_clipping(float clip_local[6][4], BoundBox *clipbb, float ED_view3d_clipping_calc_from_boundbox(clip_local, &clipbb_local, is_negative_m4(mat)); } -void ED_view3d_clipping_local(RegionView3D *rv3d, float mat[4][4]) +void ED_view3d_clipping_local(RegionView3D *rv3d, const float mat[4][4]) { if (rv3d->rflag & RV3D_CLIPPING) { calc_local_clipping(rv3d->clip_local, rv3d->clipbb, mat); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index cc19ecf35a8..556b5d51505 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -16,6 +16,10 @@ /** \file * \ingroup spview3d + * + * Interactive fly navigation modal operator (flying around in space). + * + * \note Similar logic to `view3d_walk.c` changes here may apply there too. */ /* defines VIEW3D_OT_fly modal operator */ @@ -998,19 +1002,6 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm) interp_v3_v3v3( dvec, dvec_tmp, fly->dvec_prev, (1.0f / (1.0f + (time_redraw * FLY_SMOOTH_FAC)))); - if (rv3d->persp == RV3D_CAMOB) { - Object *lock_ob = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control); - if (lock_ob->protectflag & OB_LOCK_LOCX) { - dvec[0] = 0.0; - } - if (lock_ob->protectflag & OB_LOCK_LOCY) { - dvec[1] = 0.0; - } - if (lock_ob->protectflag & OB_LOCK_LOCZ) { - dvec[2] = 0.0; - } - } - add_v3_v3(rv3d->ofs, dvec); if (rv3d->persp == RV3D_CAMOB) { diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index f4ec9a22520..c10a88af146 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -303,12 +303,12 @@ eV3DProjStatus ED_view3d_project_float_object(const ARegion *region, float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3]) { - return mul_project_m4_v3_zfac((float(*)[4])rv3d->persmat, co) * rv3d->pixsize * U.pixelsize; + return mul_project_m4_v3_zfac(rv3d->persmat, co) * rv3d->pixsize * U.pixelsize; } float ED_view3d_pixel_size_no_ui_scale(const RegionView3D *rv3d, const float co[3]) { - return mul_project_m4_v3_zfac((float(*)[4])rv3d->persmat, co) * rv3d->pixsize; + return mul_project_m4_v3_zfac(rv3d->persmat, co) * rv3d->pixsize; } /** @@ -316,7 +316,7 @@ float ED_view3d_pixel_size_no_ui_scale(const RegionView3D *rv3d, const float co[ */ float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3], bool *r_flip) { - float zfac = mul_project_m4_v3_zfac((float(*)[4])rv3d->persmat, co); + float zfac = mul_project_m4_v3_zfac(rv3d->persmat, co); if (r_flip) { *r_flip = (zfac < 0.0f); @@ -483,11 +483,11 @@ void ED_view3d_global_to_vector(const RegionView3D *rv3d, const float coord[3], p1[3] = 1.0f; copy_v3_v3(p2, p1); p2[3] = 1.0f; - mul_m4_v4((float(*)[4])rv3d->viewmat, p2); + mul_m4_v4(rv3d->viewmat, p2); mul_v3_fl(p2, 2.0f); - mul_m4_v4((float(*)[4])rv3d->viewinv, p2); + mul_m4_v4(rv3d->viewinv, p2); sub_v3_v3v3(vec, p1, p2); } @@ -749,25 +749,26 @@ bool ED_view3d_win_to_segment_clipped(struct Depsgraph *depsgraph, return true; } -/* Utility functions for projection - * ******************************** */ +/* -------------------------------------------------------------------- */ +/** \name Utility functions for projection + * \{ */ -void ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, Object *ob, float pmat[4][4]) +void ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, Object *ob, float r_pmat[4][4]) { float vmat[4][4]; - mul_m4_m4m4(vmat, (float(*)[4])rv3d->viewmat, ob->obmat); - mul_m4_m4m4(pmat, (float(*)[4])rv3d->winmat, vmat); + mul_m4_m4m4(vmat, rv3d->viewmat, ob->obmat); + mul_m4_m4m4(r_pmat, rv3d->winmat, vmat); } void ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, - float obmat[4][4], - float pmat[4][4]) + const float obmat[4][4], + float r_pmat[4][4]) { float vmat[4][4]; - mul_m4_m4m4(vmat, (float(*)[4])rv3d->viewmat, obmat); - mul_m4_m4m4(pmat, (float(*)[4])rv3d->winmat, vmat); + mul_m4_m4m4(vmat, rv3d->viewmat, obmat); + mul_m4_m4m4(r_pmat, rv3d->winmat, vmat); } /** @@ -791,3 +792,5 @@ bool ED_view3d_unproject( return GPU_matrix_unproject(region_co, rv3d->viewmat, rv3d->winmat, viewport, world); } + +/** \} */ diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index bd2323f47f4..4e73a2be17e 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -335,7 +335,7 @@ void ED_view3d_clipping_calc( * * \{ */ -static bool view3d_boundbox_clip_m4(const BoundBox *bb, float persmatob[4][4]) +static bool view3d_boundbox_clip_m4(const BoundBox *bb, const float persmatob[4][4]) { int a, flag = -1, fl; @@ -1243,7 +1243,9 @@ float ED_view3d_radius_to_dist(const View3D *v3d, * \param fallback_dist: The distance to use if the object is too near or in front of \a ofs. * \returns A newly calculated distance or the fallback. */ -float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float fallback_dist) +float ED_view3d_offset_distance(const float mat[4][4], + const float ofs[3], + const float fallback_dist) { float pos[4] = {0.0f, 0.0f, 0.0f, 1.0f}; float dir[4] = {0.0f, 0.0f, 1.0f, 0.0f}; @@ -1374,11 +1376,11 @@ static float view3d_quat_axis[6][4][4] = { }; -bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float quat[4]) +bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float r_quat[4]) { BLI_assert(view_axis_roll <= RV3D_VIEW_AXIS_ROLL_270); if (RV3D_VIEW_IS_AXIS(view)) { - copy_qt_qt(quat, view3d_quat_axis[view - RV3D_VIEW_FRONT][view_axis_roll]); + copy_qt_qt(r_quat, view3d_quat_axis[view - RV3D_VIEW_FRONT][view_axis_roll]); return true; } return false; diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 751e37f0235..64167b83655 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -16,6 +16,11 @@ /** \file * \ingroup spview3d + * + * Interactive walk navigation modal operator + * (similar to walking around in a first person game). + * + * \note Similar logic to `view3d_fly.c` changes here may apply there too. */ /* defines VIEW3D_OT_navigate - walk modal operator */ @@ -1295,19 +1300,6 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) sub_v3_v3v3(dvec, cur_loc, new_loc); } - if (rv3d->persp == RV3D_CAMOB) { - Object *lock_ob = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control); - if (lock_ob->protectflag & OB_LOCK_LOCX) { - dvec[0] = 0.0f; - } - if (lock_ob->protectflag & OB_LOCK_LOCY) { - dvec[1] = 0.0f; - } - if (lock_ob->protectflag & OB_LOCK_LOCZ) { - dvec[2] = 0.0f; - } - } - /* scale the movement to the scene size */ mul_v3_v3fl(dvec_tmp, dvec, walk->grid); add_v3_v3(rv3d->ofs, dvec_tmp); diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c index 0eb12aeabed..84885dd8c49 100644 --- a/source/blender/editors/transform/transform_convert_gpencil.c +++ b/source/blender/editors/transform/transform_convert_gpencil.c @@ -104,7 +104,7 @@ void createTransGPencil(bContext *C, TransInfo *t) /* initialize falloff curve */ if (is_multiedit) { - BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff); + BKE_curvemapping_init(ts->gp_sculpt.cur_falloff); } /* First Pass: Count the number of data-points required for the strokes, diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 2e0f7a3a113..6f447997fb0 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -472,7 +472,7 @@ static void editmesh_mirror_data_calc(BMEditMesh *em, BMIter iter; int i, flag, totvert = bm->totvert; - vert_map = MEM_mallocN(totvert * sizeof(*vert_map), __func__); + vert_map = MEM_callocN(totvert * sizeof(*vert_map), __func__); float select_sum[3] = {0}; BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) { @@ -498,7 +498,8 @@ static void editmesh_mirror_data_calc(BMEditMesh *em, uint mirror_elem_len = 0; int *index[3] = {NULL, NULL, NULL}; - bool test_selected_only = use_select && (mirror_axis[0] + mirror_axis[1] + mirror_axis[2]) == 1; + bool is_single_mirror_axis = (mirror_axis[0] + mirror_axis[1] + mirror_axis[2]) == 1; + bool test_selected_only = use_select && is_single_mirror_axis; for (int a = 0; a < 3; a++) { if (!mirror_axis[a]) { continue; @@ -523,13 +524,23 @@ static void editmesh_mirror_data_calc(BMEditMesh *em, if (!is_in_quadrant_v3(eve->co, quadrant, TRANSFORM_MAXDIST_MIRROR)) { continue; } + if (vert_map[i_mirr].flag != 0) { + /* One mirror per element. + * It can happen when vertices occupy the same position. */ + continue; + } vert_map[i_mirr] = (struct MirrorDataVert){i, flag}; mirror_elem_len++; } } - if (mirror_elem_len) { + if (!mirror_elem_len) { + MEM_freeN(vert_map); + vert_map = NULL; + } + else if (!is_single_mirror_axis) { + /* Adjustment for elements that are mirrors of mirrored elements. */ for (int a = 0; a < 3; a++) { if (!mirror_axis[a]) { continue; @@ -551,10 +562,6 @@ static void editmesh_mirror_data_calc(BMEditMesh *em, } } } - else { - MEM_freeN(vert_map); - vert_map = NULL; - } MEM_SAFE_FREE(index[0]); MEM_SAFE_FREE(index[1]); diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index 4c354ab5940..151c881a466 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -1263,11 +1263,13 @@ static void uv_select_linked_multi(Scene *scene, Object **objects, const uint objects_len, UvNearestHit *hit_final, - bool extend, + const bool extend, bool deselect, - bool toggle, - bool select_faces) + const bool toggle, + const bool select_faces) { + const bool uv_sync_select = (scene->toolsettings->uv_flag & UV_SYNC_SELECTION); + /* loop over objects, or just use hit_final->ob */ for (uint ob_index = 0; ob_index < objects_len; ob_index++) { if (hit_final && ob_index != 0) { @@ -1278,7 +1280,6 @@ static void uv_select_linked_multi(Scene *scene, BMFace *efa; BMLoop *l; BMIter iter, liter; - MLoopUV *luv; UvVertMap *vmap; UvMapVert *vlist, *iterv, *startv; int i, stacksize = 0, *stack; @@ -1296,7 +1297,7 @@ static void uv_select_linked_multi(Scene *scene, * * Better solve this by having a delimit option for select-linked operator, * keeping island-select working as is. */ - vmap = BM_uv_vert_map_create(em->bm, !select_faces, false); + vmap = BM_uv_vert_map_create(em->bm, !uv_sync_select, false); if (vmap == NULL) { continue; @@ -1318,14 +1319,42 @@ static void uv_select_linked_multi(Scene *scene, } else { BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - - if (luv->flag & MLOOPUV_VERTSEL) { - stack[stacksize] = a; - stacksize++; - flag[a] = 1; + if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { + bool add_to_stack = true; + if (uv_sync_select && !select_faces) { + /* Special case, vertex/edge & sync select being enabled. + * + * Without this, a second linked select will 'grow' each time as each new + * selection reaches the boundaries of islands that share vertices but not UV's. + * + * Rules applied here: + * - This loops face isn't selected. + * - The only other fully selected face is connected or, + * - There are no connected fully selected faces UV-connected to this loop. + */ + if (uvedit_face_select_test(scene, l->f, cd_loop_uv_offset)) { + /* pass */ + } + else { + BMIter liter_other; + BMLoop *l_other; + BM_ITER_ELEM (l_other, &liter_other, l->v, BM_LOOPS_OF_VERT) { + if ((l != l_other) && + !BM_loop_uv_share_vert_check(l, l_other, cd_loop_uv_offset) && + uvedit_face_select_test(scene, l_other->f, cd_loop_uv_offset)) { + add_to_stack = false; + break; + } + } + } + } - break; + if (add_to_stack) { + stack[stacksize] = a; + stacksize++; + flag[a] = 1; + break; + } } } } @@ -1394,10 +1423,9 @@ static void uv_select_linked_multi(Scene *scene, } else { BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - - if (luv->flag & MLOOPUV_VERTSEL) { + if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { found_selected = true; + break; } } @@ -1414,10 +1442,7 @@ static void uv_select_linked_multi(Scene *scene, BM_face_select_set(em->bm, efa, value); \ } \ else { \ - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { \ - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); \ - luv->flag = (value) ? (luv->flag | MLOOPUV_VERTSEL) : (luv->flag & ~MLOOPUV_VERTSEL); \ - } \ + uvedit_face_select_set(scene, em, efa, value, false, cd_loop_uv_offset); \ } \ (void)0 @@ -1442,6 +1467,17 @@ static void uv_select_linked_multi(Scene *scene, MEM_freeN(stack); MEM_freeN(flag); BM_uv_vert_map_free(vmap); + + if (uv_sync_select) { + if (deselect) { + EDBM_deselect_flush(em); + } + else { + if (!select_faces) { + EDBM_selectmode_flush(em); + } + } + } } } @@ -2263,13 +2299,6 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent UvNearestHit hit = UV_NEAREST_HIT_INIT; - if ((ts->uv_flag & UV_SYNC_SELECTION) && !(ts->selectmode & SCE_SELECT_FACE)) { - BKE_report(op->reports, - RPT_ERROR, - "Select linked only works in face select mode when sync selection is enabled"); - return OPERATOR_CANCELLED; - } - if (pick) { extend = RNA_boolean_get(op->ptr, "extend"); deselect = RNA_boolean_get(op->ptr, "deselect"); @@ -2300,7 +2329,7 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent } } - if (!extend) { + if (!extend && !deselect) { uv_select_all_perform_multi(scene, objects, objects_len, SEL_DESELECT); } diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h index 876f40b211f..71d7dd03ef3 100644 --- a/source/blender/freestyle/FRS_freestyle.h +++ b/source/blender/freestyle/FRS_freestyle.h @@ -43,7 +43,7 @@ struct FreestyleGlobals { extern struct FreestyleGlobals g_freestyle; /* Rendering */ -void FRS_initialize(void); +void FRS_init(void); void FRS_set_context(struct bContext *C); int FRS_is_freestyle_enabled(struct ViewLayer *view_layer); void FRS_init_stroke_renderer(struct Render *re); diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 51ac281e330..2b43e913b3d 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -100,7 +100,7 @@ static bCallbackFuncStore load_post_callback_funcstore = { // Initialization //======================================================= -void FRS_initialize() +void FRS_init() { if (freestyle_is_initialized) { return; diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index 33078e6ba6a..9796dcda964 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -264,7 +264,7 @@ static PyObject *Freestyle_evaluateCurveMappingF(PyObject * /*self*/, PyObject * return NULL; } cumap = (CurveMapping *)py_srna->ptr.data; - BKE_curvemapping_initialize(cumap); + BKE_curvemapping_init(cumap); /* disable extrapolation if enabled */ if ((cumap->flag & CUMA_EXTEND_EXTRAPOLATE)) { cumap->flag &= ~CUMA_EXTEND_EXTRAPOLATE; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c index 03137a5cf23..21a8962b131 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c @@ -69,7 +69,7 @@ static void initData(GpencilModifierData *md) gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curve_intensity) { CurveMapping *curve = gpmd->curve_intensity; - BKE_curvemapping_initialize(curve); + BKE_curvemapping_init(curve); } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c index 4761dc878c0..10f775ee340 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c @@ -94,7 +94,7 @@ static void initData(GpencilModifierData *md) gpmd->falloff_type = eGPHook_Falloff_Smooth; gpmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curfalloff) { - BKE_curvemapping_initialize(gpmd->curfalloff); + BKE_curvemapping_init(gpmd->curfalloff); } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c index 0d8a5f7914e..67c26bf2584 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c @@ -79,7 +79,7 @@ static void initData(GpencilModifierData *md) if (gpmd->curve_intensity) { CurveMapping *curve = gpmd->curve_intensity; BKE_curvemap_reset(curve->cm, &curve->clipr, CURVE_PRESET_BELL, CURVEMAP_SLOPE_POSITIVE); - BKE_curvemapping_initialize(curve); + BKE_curvemapping_init(curve); } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c index 34142709c18..efa58cc4ae0 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c @@ -70,7 +70,7 @@ static void initData(GpencilModifierData *md) gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curve_intensity) { CurveMapping *curve = gpmd->curve_intensity; - BKE_curvemapping_initialize(curve); + BKE_curvemapping_init(curve); } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c index 175a6d81b1b..a95c4ee63fc 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c @@ -66,7 +66,7 @@ static void initData(GpencilModifierData *md) gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curve_intensity) { CurveMapping *curve = gpmd->curve_intensity; - BKE_curvemapping_initialize(curve); + BKE_curvemapping_init(curve); } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c index 4fa47a592ba..68547614776 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c @@ -65,7 +65,7 @@ static void initData(GpencilModifierData *md) gpmd->material = NULL; gpmd->curve_thickness = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curve_thickness) { - BKE_curvemapping_initialize(gpmd->curve_thickness); + BKE_curvemapping_init(gpmd->curve_thickness); } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c index da7d33839f1..9d10fcbe49b 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c @@ -96,7 +96,7 @@ static void initData(GpencilModifierData *md) gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curve_intensity) { CurveMapping *curve = gpmd->curve_intensity; - BKE_curvemapping_initialize(curve); + BKE_curvemapping_init(curve); } } diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 98a885f88e1..3ea18f72166 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -68,7 +68,7 @@ set(SRC intern/gpu_init_exit.c intern/gpu_material.c intern/gpu_material_library.c - intern/gpu_matrix.c + intern/gpu_matrix.cc intern/gpu_node_graph.c intern/gpu_platform.cc intern/gpu_primitive.c @@ -77,7 +77,7 @@ set(SRC intern/gpu_select_sample_query.c intern/gpu_shader.cc intern/gpu_shader_builtin.c - intern/gpu_shader_interface.c + intern/gpu_shader_interface.cc intern/gpu_state.cc intern/gpu_texture.cc intern/gpu_uniformbuffer.cc diff --git a/source/blender/gpu/GPU_init_exit.h b/source/blender/gpu/GPU_init_exit.h index 3e30a1ddcf5..58b9505cdb1 100644 --- a/source/blender/gpu/GPU_init_exit.h +++ b/source/blender/gpu/GPU_init_exit.h @@ -32,7 +32,7 @@ extern "C" { void GPU_init(void); void GPU_exit(void); -bool GPU_is_initialized(void); +bool GPU_is_init(void); #ifdef __cplusplus } diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c index 54ddb9351b9..c5061ec9ba3 100644 --- a/source/blender/gpu/intern/gpu_init_exit.c +++ b/source/blender/gpu/intern/gpu_init_exit.c @@ -95,7 +95,7 @@ void GPU_exit(void) initialized = false; } -bool GPU_is_initialized(void) +bool GPU_is_init(void) { return initialized; } diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.cc index 669bf56b726..c15bb1fba19 100644 --- a/source/blender/gpu/intern/gpu_matrix.c +++ b/source/blender/gpu/intern/gpu_matrix.cc @@ -37,8 +37,6 @@ #include "MEM_guardedalloc.h" -#define DEBUG_MATRIX_BIND 0 - #define MATRIX_STACK_DEPTH 32 typedef float Mat4[4][4]; @@ -79,7 +77,7 @@ GPUMatrixState *GPU_matrix_state_create(void) } \ } - GPUMatrixState *state = MEM_mallocN(sizeof(*state), __func__); + GPUMatrixState *state = (GPUMatrixState *)MEM_mallocN(sizeof(*state), __func__); const MatrixStack identity_stack = {{MATRIX_4X4_IDENTITY}, 0}; state->model_view_stack = state->projection_stack = identity_stack; @@ -662,51 +660,32 @@ void GPU_matrix_bind(const GPUShaderInterface *shaderface) int32_t MV_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MODELVIEW_INV); int32_t P_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_PROJECTION_INV); + /* XXX(fclem) this works but this assumes shader is unused inside GPU_shader_uniform_vector. */ + GPUShader *sh = NULL; if (MV != -1) { -#if DEBUG_MATRIX_BIND - puts("setting MV matrix"); -#endif - - glUniformMatrix4fv(MV, 1, GL_FALSE, (const float *)GPU_matrix_model_view_get(NULL)); + GPU_shader_uniform_vector(sh, MV, 16, 1, (const float *)GPU_matrix_model_view_get(NULL)); } - if (P != -1) { -#if DEBUG_MATRIX_BIND - puts("setting P matrix"); -#endif - - glUniformMatrix4fv(P, 1, GL_FALSE, (const float *)GPU_matrix_projection_get(NULL)); + GPU_shader_uniform_vector(sh, P, 16, 1, (const float *)GPU_matrix_projection_get(NULL)); } - if (MVP != -1) { -#if DEBUG_MATRIX_BIND - puts("setting MVP matrix"); -#endif - - glUniformMatrix4fv( - MVP, 1, GL_FALSE, (const float *)GPU_matrix_model_view_projection_get(NULL)); + GPU_shader_uniform_vector( + sh, MVP, 16, 1, (const float *)GPU_matrix_model_view_projection_get(NULL)); } - if (N != -1) { -#if DEBUG_MATRIX_BIND - puts("setting normal matrix"); -#endif - - glUniformMatrix3fv(N, 1, GL_FALSE, (const float *)GPU_matrix_normal_get(NULL)); + GPU_shader_uniform_vector(sh, N, 9, 1, (const float *)GPU_matrix_normal_get(NULL)); } - if (MV_inv != -1) { Mat4 m; GPU_matrix_model_view_get(m); invert_m4(m); - glUniformMatrix4fv(MV_inv, 1, GL_FALSE, (const float *)m); + GPU_shader_uniform_vector(sh, MV_inv, 16, 1, (const float *)m); } - if (P_inv != -1) { Mat4 m; GPU_matrix_projection_get(m); invert_m4(m); - glUniformMatrix4fv(P_inv, 1, GL_FALSE, (const float *)m); + GPU_shader_uniform_vector(sh, P_inv, 16, 1, (const float *)m); } gpu_matrix_state_active_set_dirty(false); diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.cc index 9d9f98c6bb0..4586b1ce814 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.cc @@ -47,47 +47,66 @@ static const char *BuiltinUniform_name(GPUUniformBuiltin u) { - static const char *names[] = { - [GPU_UNIFORM_MODEL] = "ModelMatrix", - [GPU_UNIFORM_VIEW] = "ViewMatrix", - [GPU_UNIFORM_MODELVIEW] = "ModelViewMatrix", - [GPU_UNIFORM_PROJECTION] = "ProjectionMatrix", - [GPU_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix", - [GPU_UNIFORM_MVP] = "ModelViewProjectionMatrix", - - [GPU_UNIFORM_MODEL_INV] = "ModelMatrixInverse", - [GPU_UNIFORM_VIEW_INV] = "ViewMatrixInverse", - [GPU_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse", - [GPU_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse", - [GPU_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse", - - [GPU_UNIFORM_NORMAL] = "NormalMatrix", - [GPU_UNIFORM_ORCO] = "OrcoTexCoFactors", - [GPU_UNIFORM_CLIPPLANES] = "WorldClipPlanes", - - [GPU_UNIFORM_COLOR] = "color", - [GPU_UNIFORM_BASE_INSTANCE] = "baseInstance", - [GPU_UNIFORM_RESOURCE_CHUNK] = "resourceChunk", - [GPU_UNIFORM_RESOURCE_ID] = "resourceId", - [GPU_UNIFORM_SRGB_TRANSFORM] = "srgbTarget", - - [GPU_NUM_UNIFORMS] = NULL, - }; - - return names[u]; + switch (u) { + case GPU_UNIFORM_MODEL: + return "ModelMatrix"; + case GPU_UNIFORM_VIEW: + return "ViewMatrix"; + case GPU_UNIFORM_MODELVIEW: + return "ModelViewMatrix"; + case GPU_UNIFORM_PROJECTION: + return "ProjectionMatrix"; + case GPU_UNIFORM_VIEWPROJECTION: + return "ViewProjectionMatrix"; + case GPU_UNIFORM_MVP: + return "ModelViewProjectionMatrix"; + + case GPU_UNIFORM_MODEL_INV: + return "ModelMatrixInverse"; + case GPU_UNIFORM_VIEW_INV: + return "ViewMatrixInverse"; + case GPU_UNIFORM_MODELVIEW_INV: + return "ModelViewMatrixInverse"; + case GPU_UNIFORM_PROJECTION_INV: + return "ProjectionMatrixInverse"; + case GPU_UNIFORM_VIEWPROJECTION_INV: + return "ViewProjectionMatrixInverse"; + + case GPU_UNIFORM_NORMAL: + return "NormalMatrix"; + case GPU_UNIFORM_ORCO: + return "OrcoTexCoFactors"; + case GPU_UNIFORM_CLIPPLANES: + return "WorldClipPlanes"; + + case GPU_UNIFORM_COLOR: + return "color"; + case GPU_UNIFORM_BASE_INSTANCE: + return "baseInstance"; + case GPU_UNIFORM_RESOURCE_CHUNK: + return "resourceChunk"; + case GPU_UNIFORM_RESOURCE_ID: + return "resourceId"; + case GPU_UNIFORM_SRGB_TRANSFORM: + return "srgbTarget"; + + default: + return NULL; + } } static const char *BuiltinUniformBlock_name(GPUUniformBlockBuiltin u) { - static const char *names[] = { - [GPU_UNIFORM_BLOCK_VIEW] = "viewBlock", - [GPU_UNIFORM_BLOCK_MODEL] = "modelBlock", - [GPU_UNIFORM_BLOCK_INFO] = "infoBlock", - - [GPU_NUM_UNIFORM_BLOCKS] = NULL, - }; - - return names[u]; + switch (u) { + case GPU_UNIFORM_BLOCK_VIEW: + return "viewBlock"; + case GPU_UNIFORM_BLOCK_MODEL: + return "modelBlock"; + case GPU_UNIFORM_BLOCK_INFO: + return "infoBlock"; + default: + return NULL; + } } GPU_INLINE bool match(const char *a, const char *b) @@ -273,7 +292,7 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program) /* Bit set to true if uniform comes from a uniform block. */ BLI_bitmap *uniforms_from_blocks = BLI_BITMAP_NEW(active_uniform_len, __func__); /* Set uniforms from block for exclusion. */ - GLint *ubo_uni_ids = MEM_mallocN(sizeof(GLint) * max_ubo_uni_len, __func__); + GLint *ubo_uni_ids = (GLint *)MEM_mallocN(sizeof(GLint) * max_ubo_uni_len, __func__); for (int i = 0; i < ubo_len; i++) { GLint ubo_uni_len; glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &ubo_uni_len); @@ -291,16 +310,18 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program) int input_tot_len = attr_len + ubo_len + uniform_len; size_t interface_size = sizeof(GPUShaderInterface) + sizeof(GPUShaderInput) * input_tot_len; - GPUShaderInterface *shaderface = MEM_callocN(interface_size, "GPUShaderInterface"); + GPUShaderInterface *shaderface = (GPUShaderInterface *)MEM_callocN(interface_size, + "GPUShaderInterface"); shaderface->attribute_len = attr_len; shaderface->ubo_len = ubo_len; shaderface->uniform_len = uniform_len; - shaderface->name_buffer = MEM_mallocN(name_buffer_len, "name_buffer"); + shaderface->name_buffer = (char *)MEM_mallocN(name_buffer_len, "name_buffer"); GPUShaderInput *inputs = shaderface->inputs; /* Temp buffer. */ int input_tmp_len = max_iii(attr_len, ubo_len, uniform_len); - GPUShaderInput *inputs_tmp = MEM_mallocN(sizeof(GPUShaderInput) * input_tmp_len, "name_buffer"); + GPUShaderInput *inputs_tmp = (GPUShaderInput *)MEM_mallocN( + sizeof(GPUShaderInput) * input_tmp_len, "name_buffer"); /* Attributes */ shaderface->enabled_attr_mask = 0; @@ -366,27 +387,29 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program) sort_input_list(inputs, inputs_tmp, shaderface->uniform_len); /* Builtin Uniforms */ - for (GPUUniformBuiltin u = 0; u < GPU_NUM_UNIFORMS; u++) { + for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORMS; u_int++) { + GPUUniformBuiltin u = static_cast<GPUUniformBuiltin>(u_int); shaderface->builtins[u] = glGetUniformLocation(program, BuiltinUniform_name(u)); } /* Builtin Uniforms Blocks */ - for (GPUUniformBlockBuiltin u = 0; u < GPU_NUM_UNIFORM_BLOCKS; u++) { + for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORM_BLOCKS; u_int++) { + GPUUniformBlockBuiltin u = static_cast<GPUUniformBlockBuiltin>(u_int); const GPUShaderInput *block = GPU_shaderinterface_ubo(shaderface, BuiltinUniformBlock_name(u)); shaderface->builtin_blocks[u] = (block != NULL) ? block->binding : -1; } /* Batches ref buffer */ shaderface->batches_len = GPU_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = MEM_callocN(shaderface->batches_len * sizeof(GPUBatch *), - "GPUShaderInterface batches"); + shaderface->batches = (GPUBatch **)MEM_callocN(shaderface->batches_len * sizeof(GPUBatch *), + "GPUShaderInterface batches"); MEM_freeN(uniforms_from_blocks); MEM_freeN(inputs_tmp); /* Resize name buffer to save some memory. */ if (name_buffer_offset < name_buffer_len) { - shaderface->name_buffer = MEM_reallocN(shaderface->name_buffer, name_buffer_offset); + shaderface->name_buffer = (char *)MEM_reallocN(shaderface->name_buffer, name_buffer_offset); } #if DEBUG_SHADER_INTERFACE @@ -501,8 +524,8 @@ void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *shaderface, GPUBatch /* Not enough place, realloc the array. */ i = shaderface->batches_len; shaderface->batches_len += GPU_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = MEM_recallocN(shaderface->batches, - sizeof(GPUBatch *) * shaderface->batches_len); + shaderface->batches = (GPUBatch **)MEM_recallocN(shaderface->batches, + sizeof(GPUBatch *) * shaderface->batches_len); } shaderface->batches[i] = batch; } diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h index 2c2053b47a6..99f68983c21 100644 --- a/source/blender/ikplugin/BIK_api.h +++ b/source/blender/ikplugin/BIK_api.h @@ -36,7 +36,7 @@ struct bConstraint; struct bPose; struct bPoseChannel; -void BIK_initialize_tree(struct Depsgraph *depsgraph, +void BIK_init_tree(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime); diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c index 5e683d36408..233150a77aa 100644 --- a/source/blender/ikplugin/intern/ikplugin_api.c +++ b/source/blender/ikplugin/intern/ikplugin_api.c @@ -80,7 +80,7 @@ static IKPlugin *get_plugin(bPose *pose) /*----------------------------------------*/ /* Plugin API */ -void BIK_initialize_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime) +void BIK_init_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime) { IKPlugin *plugin = get_plugin(ob->pose); diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index c9b3db39976..136d191c6a0 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -3958,7 +3958,7 @@ static void curve_mapping_to_ocio_settings(CurveMapping *curve_mapping, { int i; - BKE_curvemapping_initialize(curve_mapping); + BKE_curvemapping_init(curve_mapping); BKE_curvemapping_premultiply(curve_mapping, false); BKE_curvemapping_table_RGBA( curve_mapping, &curve_mapping_settings->lut, &curve_mapping_settings->lut_size); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 5154f50c7e8..f81c005bf06 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -651,7 +651,7 @@ BLI_INLINE int DOWNSAMPLE_FLOAT_TO_16BIT(const float _val) #define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/ #define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/ -static int initialise_4K_poc(opj_poc_t *POC, int numres) +static int init_4K_poc(opj_poc_t *POC, int numres) { POC[0].tile = 1; POC[0].resno0 = 0; @@ -750,7 +750,7 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, else { parameters->cp_rsiz = DCP_CINEMA2K; } - parameters->numpocs = initialise_4K_poc(parameters->POC, parameters->numresolution); + parameters->numpocs = init_4K_poc(parameters->POC, parameters->numresolution); break; case OPJ_OFF: /* do nothing */ diff --git a/source/blender/imbuf/intern/stereoimbuf.c b/source/blender/imbuf/intern/stereoimbuf.c index 5569e119b95..0d532b0e1fb 100644 --- a/source/blender/imbuf/intern/stereoimbuf.c +++ b/source/blender/imbuf/intern/stereoimbuf.c @@ -669,7 +669,7 @@ static void imb_stereo3d_squeeze_rect( /*************************** preparing to call the write functions **************************/ -static void imb_stereo3d_data_initialize(Stereo3DData *s3d_data, +static void imb_stereo3d_data_init(Stereo3DData *s3d_data, const bool is_float, const size_t x, const size_t y, @@ -709,7 +709,7 @@ int *IMB_stereo3d_from_rect(ImageFormatData *im_format, im_format->stereo3d_format.display_mode, false, x, y, &width, &height); r_rect = MEM_mallocN(channels * sizeof(int) * width * height, __func__); - imb_stereo3d_data_initialize( + imb_stereo3d_data_init( &s3d_data, is_float, x, y, channels, rect_left, rect_right, r_rect, NULL, NULL, NULL); imb_stereo3d_write_doit(&s3d_data, &im_format->stereo3d_format); imb_stereo3d_squeeze_rect(r_rect, &im_format->stereo3d_format, x, y, channels); @@ -733,7 +733,7 @@ float *IMB_stereo3d_from_rectf(ImageFormatData *im_format, im_format->stereo3d_format.display_mode, false, x, y, &width, &height); r_rectf = MEM_mallocN(channels * sizeof(float) * width * height, __func__); - imb_stereo3d_data_initialize( + imb_stereo3d_data_init( &s3d_data, is_float, x, y, channels, NULL, NULL, NULL, rectf_left, rectf_right, r_rectf); imb_stereo3d_write_doit(&s3d_data, &im_format->stereo3d_format); imb_stereo3d_squeeze_rectf(r_rectf, &im_format->stereo3d_format, x, y, channels); @@ -759,7 +759,7 @@ ImBuf *IMB_stereo3d_ImBuf(ImageFormatData *im_format, ImBuf *ibuf_left, ImBuf *i ibuf_stereo->flags = ibuf_left->flags; - imb_stereo3d_data_initialize(&s3d_data, + imb_stereo3d_data_init(&s3d_data, is_float, ibuf_left->x, ibuf_left->y, @@ -1286,7 +1286,7 @@ void IMB_ImBufFromStereo3d(Stereo3dFormat *s3d, &height); imb_stereo3d_unsqueeze_ImBuf(ibuf_stereo3d, s3d, width, height); - imb_stereo3d_data_initialize(&s3d_data, + imb_stereo3d_data_init(&s3d_data, is_float, ibuf_left->x, ibuf_left->y, @@ -1310,7 +1310,7 @@ void IMB_ImBufFromStereo3d(Stereo3dFormat *s3d, addzbufImBuf(ibuf_right); } - imb_stereo3d_data_initialize(&s3d_data, + imb_stereo3d_data_init(&s3d_data, is_float, ibuf_left->x, ibuf_left->y, diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h index 8734a73c07a..30eafb34ba6 100644 --- a/source/blender/makesdna/DNA_view2d_types.h +++ b/source/blender/makesdna/DNA_view2d_types.h @@ -137,7 +137,7 @@ enum { /* apply pixel offsets on y-axis when setting view matrices */ V2D_PIXELOFS_Y = (1 << 3), /* view settings need to be set still... */ - V2D_IS_INITIALISED = (1 << 10), + V2D_IS_INIT = (1 << 10), }; /* scroller flags for View2D (v2d->scroll) */ diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index a07b8f81d96..668818b17bb 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -198,8 +198,8 @@ typedef struct wmWindowManager { /* wmWindowManager.initialized */ enum { - WM_WINDOW_IS_INITIALIZED = (1 << 0), - WM_KEYCONFIG_IS_INITIALIZED = (1 << 1), + WM_WINDOW_IS_INIT = (1 << 0), + WM_KEYCONFIG_IS_INIT = (1 << 1), }; /* wmWindowManager.outliner_sync_select_dirty */ diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 826fc53dce4..026274e5b22 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -1548,7 +1548,6 @@ int main(int argc, char **argv) # pragma GCC poison int8_t #endif -#include "DNA_session_uuid_types.h" #include "DNA_ID.h" #include "DNA_action_types.h" #include "DNA_anim_types.h" @@ -1603,6 +1602,7 @@ int main(int argc, char **argv) #include "DNA_screen_types.h" #include "DNA_sdna_types.h" #include "DNA_sequence_types.h" +#include "DNA_session_uuid_types.h" #include "DNA_shader_fx_types.h" #include "DNA_simulation_types.h" #include "DNA_sound_types.h" diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 0b43a5a6653..d430b937031 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -345,6 +345,10 @@ if(WITH_XR_OPENXR) add_definitions(-DWITH_XR_OPENXR) endif() +if(WITH_GMP) + add_definitions(-DWITH_GMP) +endif() + # Build makesrna executable blender_include_dirs( . diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 045d098bf6a..6169b72a7fa 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -5146,7 +5146,7 @@ int main(int argc, char **argv) { int return_status = 0; - MEM_initialize_memleak_detection(); + MEM_init_memleak_detection(); MEM_set_error_callback(mem_error_cb); CLG_init(); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 56ad8e2677b..60b6cc40792 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -702,7 +702,7 @@ static float rna_CurveMapping_evaluateF(struct CurveMapping *cumap, static void rna_CurveMap_initialize(struct CurveMapping *cumap) { - BKE_curvemapping_initialize(cumap); + BKE_curvemapping_init(cumap); } #else diff --git a/source/blender/makesrna/intern/rna_curve_api.c b/source/blender/makesrna/intern/rna_curve_api.c index 1207f19b95f..94fdb130026 100644 --- a/source/blender/makesrna/intern/rna_curve_api.c +++ b/source/blender/makesrna/intern/rna_curve_api.c @@ -37,7 +37,7 @@ #ifdef RNA_RUNTIME static void rna_Curve_transform(Curve *cu, float *mat, bool shape_keys) { - BKE_curve_transform(cu, (float(*)[4])mat, shape_keys, true); + BKE_curve_transform(cu, (const float(*)[4])mat, shape_keys, true); DEG_id_tag_update(&cu->id, 0); } diff --git a/source/blender/makesrna/intern/rna_curveprofile.c b/source/blender/makesrna/intern/rna_curveprofile.c index ce91fc79085..ee1c659fcd5 100644 --- a/source/blender/makesrna/intern/rna_curveprofile.c +++ b/source/blender/makesrna/intern/rna_curveprofile.c @@ -146,7 +146,7 @@ static void rna_CurveProfile_evaluate(struct CurveProfile *profile, static void rna_CurveProfile_initialize(struct CurveProfile *profile, int segments_len) { - BKE_curveprofile_initialize(profile, (short)segments_len); + BKE_curveprofile_init(profile, (short)segments_len); } static void rna_CurveProfile_update(struct CurveProfile *profile) diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c index ab8f97ae3c2..3af783f1bb1 100644 --- a/source/blender/makesrna/intern/rna_fluid.c +++ b/source/blender/makesrna/intern/rna_fluid.c @@ -2048,6 +2048,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) prop, "Start", "Frame on which the simulation starts. This is the first frame that will be baked"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "cache_frame_end", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "cache_frame_end"); @@ -2057,6 +2058,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) prop, "End", "Frame on which the simulation stops. This is the last frame that will be baked"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "cache_frame_offset", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "cache_frame_offset"); @@ -2066,6 +2068,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) "Offset", "Frame offset that is used when loading the simulation from the cache. It is not considered " "when baking the simulation, only when loading it"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "cache_frame_pause_data", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_data"); @@ -2089,6 +2092,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) prop, NULL, "rna_Fluid_cachetype_mesh_set", "rna_Fluid_cachetype_mesh_itemf"); RNA_def_property_ui_text( prop, "File Format", "Select the file format to be used for caching surface data"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset"); prop = RNA_def_property(srna, "cache_data_format", PROP_ENUM, PROP_NONE); @@ -2098,6 +2102,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) prop, NULL, "rna_Fluid_cachetype_data_set", "rna_Fluid_cachetype_volume_itemf"); RNA_def_property_ui_text( prop, "File Format", "Select the file format to be used for caching volumetric data"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset"); prop = RNA_def_property(srna, "cache_particle_format", PROP_ENUM, PROP_NONE); @@ -2107,6 +2112,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) prop, NULL, "rna_Fluid_cachetype_particle_set", "rna_Fluid_cachetype_particle_itemf"); RNA_def_property_ui_text( prop, "File Format", "Select the file format to be used for caching particle data"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset"); prop = RNA_def_property(srna, "cache_noise_format", PROP_ENUM, PROP_NONE); @@ -2116,6 +2122,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) prop, NULL, "rna_Fluid_cachetype_noise_set", "rna_Fluid_cachetype_volume_itemf"); RNA_def_property_ui_text( prop, "File Format", "Select the file format to be used for caching noise data"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_noisecache_reset"); prop = RNA_def_property(srna, "cache_type", PROP_ENUM, PROP_NONE); @@ -2123,6 +2130,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, cache_types); RNA_def_property_enum_funcs(prop, NULL, "rna_Fluid_cachetype_set", NULL); RNA_def_property_ui_text(prop, "Type", "Change the cache type of the simulation"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_domain_data_reset"); prop = RNA_def_property(srna, "cache_resumable", PROP_BOOLEAN, PROP_NONE); @@ -2133,6 +2141,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) "Additional data will be saved so that the bake jobs can be resumed after pausing. Because " "more data will be written to disk it is recommended to avoid enabling this option when " "baking at high resolutions"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset"); prop = RNA_def_property(srna, "cache_directory", PROP_STRING, PROP_DIRPATH); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 899e1202aa7..44b85fae3cc 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1163,7 +1163,7 @@ static void rna_BevelModifier_update_segments(Main *bmain, Scene *scene, Pointer BevelModifierData *bmd = (BevelModifierData *)ptr->data; if (RNA_enum_get(ptr, "profile_type") == MOD_BEVEL_PROFILE_CUSTOM) { short segments = (short)RNA_int_get(ptr, "segments"); - BKE_curveprofile_initialize(bmd->custom_profile, segments); + BKE_curveprofile_init(bmd->custom_profile, segments); } rna_Modifier_update(bmain, scene, ptr); } diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 24c4818694f..fb2a60db0fd 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -231,7 +231,7 @@ static int rna_Area_ui_type_get(PointerRNA *ptr) * the area type is changing. * So manually do the lookup in those cases, but do not actually change area->type * since that prevents a proper exit when the area type is changing. - * Logic copied from `ED_area_initialize()`.*/ + * Logic copied from `ED_area_init()`.*/ SpaceType *type = area->type; if (type == NULL || area_changing) { type = BKE_spacetype_from_id(area_type); diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 0888470b933..94710436b64 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -75,7 +75,9 @@ static void initData(ModifierData *md) bmd->double_threshold = 1e-6f; bmd->operation = eBooleanModifierOp_Difference; +#ifdef WITH_GMP bmd->bm_flag = eBooleanModifierBMeshFlag_BMesh_Exact; +#endif } static bool isDisabled(const struct Scene *UNUSED(scene), @@ -312,7 +314,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * 0; } +#ifdef WITH_GMP bool use_exact = bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_Exact; +#else + bool use_exact = false; +#endif if (use_exact) { BM_mesh_boolean(bm, looptris, tottri, bm_face_isect_pair, NULL, false, bmd->operation); @@ -379,7 +385,9 @@ static void panel_draw(const bContext *C, Panel *panel) uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE); uiItemR(layout, &ptr, "double_threshold", 0, NULL, ICON_NONE); +#ifdef WITH_GMP uiItemR(layout, &ptr, "use_exact", 0, NULL, ICON_NONE); +#endif if (G.debug) { uiLayout *col = uiLayoutColumn(layout, true); diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 861d5ea7435..0d3468f4bb8 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -284,7 +284,7 @@ static void deformVerts_do(HookModifierData *hmd, } if (hmd->curfalloff) { - BKE_curvemapping_initialize(hmd->curfalloff); + BKE_curvemapping_init(hmd->curfalloff); } /* Generic data needed for applying per-vertex calculations (initialize all members) */ diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index cbe774e91da..2657e3d894a 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -236,7 +236,7 @@ static void warpModifier_do(WarpModifierData *wmd, } if (wmd->curfalloff) { - BKE_curvemapping_initialize(wmd->curfalloff); + BKE_curvemapping_init(wmd->curfalloff); } invert_m4_m4(obinv, ob->obmat); diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 54d3aa46344..8d6a8f25e22 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -83,7 +83,7 @@ void weightvg_do_map( } if (cmap && falloff_type == MOD_WVG_MAPPING_CURVE) { - BKE_curvemapping_initialize(cmap); + BKE_curvemapping_init(cmap); } /* Map each weight (vertex) to its new value, accordingly to the chosen mode. */ diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 8039856172a..6bb4f3dc1b5 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -72,7 +72,7 @@ static void initData(ModifierData *md) wmd->default_weight = 0.0f; wmd->cmap_curve = BKE_curvemapping_add(1, 0.0, 0.0, 1.0, 1.0); - BKE_curvemapping_initialize(wmd->cmap_curve); + BKE_curvemapping_init(wmd->cmap_curve); wmd->rem_threshold = 0.01f; wmd->add_threshold = 0.01f; diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index 9efbdc079e6..b2309abe32e 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -73,7 +73,7 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context), bNode *node, bNodeInstanceKey UNUSED(key)) { - BKE_curvemapping_initialize(node->storage); + BKE_curvemapping_init(node->storage); return NULL; /* unused return */ } diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 68f252cb092..06aaf9e74cb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -168,7 +168,7 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, CurveMapping *cumap = node->storage; - BKE_curvemapping_initialize(cumap); + BKE_curvemapping_init(cumap); BKE_curvemapping_table_RGBA(cumap, &array, &size); GPUNodeLink *tex = GPU_color_band(mat, size, array, &layer); diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index d42985ba041..70f7e731720 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -39,7 +39,7 @@ static void time_colorfn( fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1); } - BKE_curvemapping_initialize(node->storage); + BKE_curvemapping_init(node->storage); fac = BKE_curvemapping_evaluateF(node->storage, 0, fac); out[0] = CLAMPIS(fac, 0.0f, 1.0f); } diff --git a/source/blender/python/bmesh/CMakeLists.txt b/source/blender/python/bmesh/CMakeLists.txt index 818498fe7db..89df127075d 100644 --- a/source/blender/python/bmesh/CMakeLists.txt +++ b/source/blender/python/bmesh/CMakeLists.txt @@ -64,4 +64,8 @@ if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() +if(WITH_GMP) + add_definitions(-DWITH_GMP) +endif() + blender_add_lib(bf_python_bmesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c index 1379c0e557a..da7674eb7f9 100644 --- a/source/blender/python/gpu/gpu_py_api.c +++ b/source/blender/python/gpu/gpu_py_api.c @@ -43,9 +43,9 @@ /** \name Utils to invalidate functions * \{ */ -bool bpygpu_is_initialized_or_error(void) +bool bpygpu_is_init_or_error(void) { - if (!GPU_is_initialized()) { + if (!GPU_is_init()) { PyErr_SetString(PyExc_SystemError, "GPU functions for drawing are not available in background mode"); diff --git a/source/blender/python/gpu/gpu_py_api.h b/source/blender/python/gpu/gpu_py_api.h index e278bb63a49..916b1ac6e49 100644 --- a/source/blender/python/gpu/gpu_py_api.h +++ b/source/blender/python/gpu/gpu_py_api.h @@ -25,14 +25,14 @@ int bpygpu_ParsePrimType(PyObject *o, void *p); PyObject *BPyInit_gpu(void); -bool bpygpu_is_initialized_or_error(void); +bool bpygpu_is_init_or_error(void); #define BPYGPU_IS_INIT_OR_ERROR_OBJ \ - if (UNLIKELY(!bpygpu_is_initialized_or_error())) { \ + if (UNLIKELY(!bpygpu_is_init_or_error())) { \ return NULL; \ } \ ((void)0) #define BPYGPU_IS_INIT_OR_ERROR_INT \ - if (UNLIKELY(!bpygpu_is_initialized_or_error())) { \ + if (UNLIKELY(!bpygpu_is_init_or_error())) { \ return -1; \ } \ ((void)0) diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index f91afa414ce..585119a0eae 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -921,8 +921,11 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult * /* TODO, reloading the module isn't functional at the moment. */ static void bpy_module_free(void *mod); + +/* Defined in 'creator.c' when building as a Python module. */ extern int main_python_enter(int argc, const char **argv); extern void main_python_exit(void); + static struct PyModuleDef bpy_proxy_def = { PyModuleDef_HEAD_INIT, "bpy", /* m_name */ diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index f9d2e915fad..45b5362d40b 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -367,8 +367,8 @@ struct RenderPass *RE_pass_find_by_type(volatile struct RenderLayer *rl, #define RE_BAKE_AO 2 void RE_GetCameraWindow(struct Render *re, struct Object *camera, float mat[4][4]); -void RE_GetCameraWindowWithOverscan(struct Render *re, float mat[4][4], float overscan); -void RE_GetCameraModelMatrix(struct Render *re, struct Object *camera, float r_mat[4][4]); +void RE_GetCameraWindowWithOverscan(struct Render *re, float overscan, float r_winmat[4][4]); +void RE_GetCameraModelMatrix(struct Render *re, struct Object *camera, float r_modelmat[4][4]); struct Scene *RE_GetScene(struct Render *re); void RE_SetScene(struct Render *re, struct Scene *sce); diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 2e9f30397db..d631dd1a2ff 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -211,14 +211,14 @@ void RE_SetCamera(Render *re, Object *cam_ob) re_camera_params_get(re, ¶ms); } -void RE_GetCameraWindow(struct Render *re, struct Object *camera, float mat[4][4]) +void RE_GetCameraWindow(struct Render *re, struct Object *camera, float r_winmat[4][4]) { RE_SetCamera(re, camera); - copy_m4_m4(mat, re->winmat); + copy_m4_m4(r_winmat, re->winmat); } /* Must be called after RE_GetCameraWindow(), does not change re->winmat. */ -void RE_GetCameraWindowWithOverscan(struct Render *re, float mat[4][4], float overscan) +void RE_GetCameraWindowWithOverscan(struct Render *re, float overscan, float r_winmat[4][4]) { CameraParams params; params.is_ortho = re->winmat[3][3] != 0.0f; @@ -233,12 +233,12 @@ void RE_GetCameraWindowWithOverscan(struct Render *re, float mat[4][4], float ov params.viewplane.ymin -= overscan; params.viewplane.ymax += overscan; BKE_camera_params_compute_matrix(¶ms); - copy_m4_m4(mat, params.winmat); + copy_m4_m4(r_winmat, params.winmat); } -void RE_GetCameraModelMatrix(Render *re, struct Object *camera, float r_mat[4][4]) +void RE_GetCameraModelMatrix(Render *re, struct Object *camera, float r_modelmat[4][4]) { - BKE_camera_multiview_model_matrix(&re->r, camera, re->viewname, r_mat); + BKE_camera_multiview_model_matrix(&re->r, camera, re->viewname, r_modelmat); } /* ~~~~~~~~~~~~~~~~ part (tile) calculus ~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index ade80898131..fa53ad522a6 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1879,14 +1879,14 @@ const char *RE_GetActiveRenderView(Render *re) } /* evaluating scene options for general Blender render */ -static int render_initialize_from_main(Render *re, - const RenderData *rd, - Main *bmain, - Scene *scene, - ViewLayer *single_layer, - Object *camera_override, - int anim, - int anim_init) +static int render_init_from_main(Render *re, + const RenderData *rd, + Main *bmain, + Scene *scene, + ViewLayer *single_layer, + Object *camera_override, + int anim, + int anim_init) { int winx, winy; rcti disprect; @@ -2004,8 +2004,7 @@ void RE_RenderFrame(Render *re, scene->r.cfra = frame; - if (render_initialize_from_main( - re, &scene->r, bmain, scene, single_layer, camera_override, 0, 0)) { + if (render_init_from_main(re, &scene->r, bmain, scene, single_layer, camera_override, 0, 0)) { const RenderData rd = scene->r; MEM_reset_peak_memory(); @@ -2058,7 +2057,7 @@ void RE_RenderFrame(Render *re, void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, int render) { re->result_ok = 0; - if (render_initialize_from_main(re, &scene->r, bmain, scene, NULL, NULL, 0, 0)) { + if (render_init_from_main(re, &scene->r, bmain, scene, NULL, NULL, 0, 0)) { if (render) { do_render_3d(re); } @@ -2422,7 +2421,7 @@ void RE_RenderAnim(Render *re, (rd.im_format.views_format == R_IMF_VIEWS_INDIVIDUAL)); /* do not fully call for each frame, it initializes & pops output window */ - if (!render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1)) { + if (!render_init_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1)) { return; } @@ -2501,7 +2500,7 @@ void RE_RenderAnim(Render *re, render_update_depsgraph(re); /* only border now, todo: camera lens. (ton) */ - render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 1, 0); + render_init_from_main(re, &rd, bmain, scene, single_layer, camera_override, 1, 0); if (nfra != scene->r.cfra) { /* Skip this frame, but could update for physics and particles system. */ diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 8daad33b477..c49cf6203e0 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -557,7 +557,7 @@ static float density_falloff(PointDensityRangeData *pdr, int index, float square } if (pdr->density_curve && dist != 0.0f) { - BKE_curvemapping_initialize(pdr->density_curve); + BKE_curvemapping_init(pdr->density_curve); density = BKE_curvemapping_evaluateF(pdr->density_curve, 0, density / dist) * dist; } diff --git a/source/blender/simulation/intern/simulation_collect_influences.cc b/source/blender/simulation/intern/simulation_collect_influences.cc index c744defb7d5..c309d18c43a 100644 --- a/source/blender/simulation/intern/simulation_collect_influences.cc +++ b/source/blender/simulation/intern/simulation_collect_influences.cc @@ -674,12 +674,18 @@ class ParticleConditionAction : public ParticleAction { } if (action_true_ != nullptr) { - ParticleChunkContext chunk_context{true_indices.as_span(), context.particles.attributes}; + ParticleChunkContext chunk_context{context.particles.state, + true_indices.as_span(), + context.particles.attributes, + context.particles.integration}; ParticleActionContext action_context{context.solve_context, chunk_context}; action_true_->execute(action_context); } if (action_false_ != nullptr) { - ParticleChunkContext chunk_context{false_indices.as_span(), context.particles.attributes}; + ParticleChunkContext chunk_context{context.particles.state, + false_indices.as_span(), + context.particles.attributes, + context.particles.integration}; ParticleActionContext action_context{context.solve_context, chunk_context}; action_false_->execute(action_context); } @@ -753,6 +759,63 @@ static void optimize_function_network(CollectContext &context) // WM_clipboard_text_set(network.to_dot().c_str(), false); } +class AgeReachedEvent : public ParticleEvent { + private: + std::string attribute_name_; + + public: + AgeReachedEvent(std::string attribute_name) : attribute_name_(std::move(attribute_name)) + { + } + + void filter(ParticleEventFilterContext &context) const override + { + Span<float> birth_times = context.particles.attributes.get<float>("Birth Time"); + Span<int> has_been_triggered = context.particles.attributes.get<int>(attribute_name_); + const float age = 5.0f; + + const float end_time = context.particles.integration->end_time; + for (int i : context.particles.index_mask) { + if (has_been_triggered[i]) { + continue; + } + const float birth_time = birth_times[i]; + const float trigger_time = birth_time + age; + if (trigger_time > end_time) { + continue; + } + + const float duration = context.particles.integration->durations[i]; + TimeInterval interval(end_time - duration, duration); + const float time_factor = interval.safe_factor_at_time(trigger_time); + + context.factor_dst[i] = std::max<float>(0.0f, time_factor); + } + } + + void execute(ParticleActionContext &context) const override + { + MutableSpan<int> dead_states = context.particles.attributes.get<int>("Dead"); + MutableSpan<int> has_been_triggered = context.particles.attributes.get<int>(attribute_name_); + for (int i : context.particles.index_mask) { + dead_states[i] = true; + has_been_triggered[i] = 1; + } + } +}; + +static void collect_age_reached_events(CollectContext &context) +{ + /* TODO: Actually implement an Age Reached Event node. */ + std::string attribute_name = "Has Been Triggered"; + const AgeReachedEvent &event = context.resources.construct<AgeReachedEvent>(AT, attribute_name); + for (const DNode *dnode : context.particle_simulation_nodes) { + StringRefNull name = get_identifier(context, *dnode); + context.influences.particle_events.add_as(name, &event); + context.influences.particle_attributes_builder.lookup_as(name)->add<int>(attribute_name, 0); + } +} + void collect_simulation_influences(Simulation &simulation, ResourceCollector &resources, SimulationInfluences &r_influences, @@ -774,6 +837,7 @@ void collect_simulation_influences(Simulation &simulation, collect_emitters(context); collect_birth_events(context); collect_time_step_events(context); + collect_age_reached_events(context); optimize_function_network(context); diff --git a/source/blender/simulation/intern/simulation_solver.cc b/source/blender/simulation/intern/simulation_solver.cc index 3c159eb1c58..9f2766aa24f 100644 --- a/source/blender/simulation/intern/simulation_solver.cc +++ b/source/blender/simulation/intern/simulation_solver.cc @@ -121,6 +121,170 @@ static void ensure_attributes_exist(ParticleSimulationState *state, const Attrib } } +BLI_NOINLINE static void apply_remaining_diffs(ParticleChunkContext &context) +{ + BLI_assert(context.integration != nullptr); + MutableSpan<float3> positions = context.attributes.get<float3>("Position"); + MutableSpan<float3> velocities = context.attributes.get<float3>("Velocity"); + + for (int i : context.index_mask) { + positions[i] += context.integration->position_diffs[i]; + velocities[i] += context.integration->velocity_diffs[i]; + } +} + +BLI_NOINLINE static void find_next_event_per_particle( + SimulationSolveContext &solve_context, + ParticleChunkContext &particles, + Span<const ParticleEvent *> events, + MutableSpan<int> r_next_event_indices, + MutableSpan<float> r_time_factors_to_next_event) +{ + r_next_event_indices.fill_indices(particles.index_mask, -1); + r_time_factors_to_next_event.fill_indices(particles.index_mask, 1.0f); + + Array<float> time_factors(particles.index_mask.min_array_size(), -1.0f); + for (int event_index : events.index_range()) { + ParticleEventFilterContext event_context{solve_context, particles, time_factors}; + const ParticleEvent &event = *events[event_index]; + event.filter(event_context); + + for (int i : particles.index_mask) { + const float time_factor = time_factors[i]; + const float previously_smallest_time_factor = r_time_factors_to_next_event[i]; + if (time_factor >= 0.0f && time_factor <= previously_smallest_time_factor) { + r_time_factors_to_next_event[i] = time_factor; + r_next_event_indices[i] = event_index; + } + } + } +} + +BLI_NOINLINE static void forward_particles_to_next_event_or_end( + ParticleChunkContext &particles, Span<float> time_factors_to_next_event) +{ + MutableSpan<float3> positions = particles.attributes.get<float3>("Position"); + MutableSpan<float3> velocities = particles.attributes.get<float3>("Velocity"); + + MutableSpan<float3> position_diffs = particles.integration->position_diffs; + MutableSpan<float3> velocity_diffs = particles.integration->velocity_diffs; + MutableSpan<float> durations = particles.integration->durations; + + for (int i : particles.index_mask) { + const float time_factor = time_factors_to_next_event[i]; + positions[i] += position_diffs[i] * time_factor; + velocities[i] += velocity_diffs[i] * time_factor; + + const float remaining_time_factor = 1.0f - time_factor; + position_diffs[i] *= remaining_time_factor; + velocity_diffs[i] *= remaining_time_factor; + durations[i] *= remaining_time_factor; + } +} + +BLI_NOINLINE static void group_particles_by_event( + IndexMask mask, + Span<int> next_event_indices, + MutableSpan<Vector<int64_t>> r_particles_per_event) +{ + for (int i : mask) { + int event_index = next_event_indices[i]; + if (event_index >= 0) { + r_particles_per_event[event_index].append(i); + } + } +} + +BLI_NOINLINE static void execute_events(SimulationSolveContext &solve_context, + ParticleChunkContext &all_particles, + Span<const ParticleEvent *> events, + Span<Vector<int64_t>> particles_per_event) +{ + for (int event_index : events.index_range()) { + Span<int64_t> pindices = particles_per_event[event_index]; + if (pindices.is_empty()) { + continue; + } + + const ParticleEvent &event = *events[event_index]; + ParticleChunkContext particles{ + all_particles.state, pindices, all_particles.attributes, all_particles.integration}; + ParticleActionContext action_context{solve_context, particles}; + event.execute(action_context); + } +} + +BLI_NOINLINE static void find_unfinished_particles(IndexMask index_mask, + Span<float> time_factors_to_next_event, + Vector<int64_t> &r_unfinished_pindices) +{ + for (int i : index_mask) { + float time_factor = time_factors_to_next_event[i]; + if (time_factor < 1.0f) { + r_unfinished_pindices.append(i); + } + } +} + +BLI_NOINLINE static void simulate_to_next_event(SimulationSolveContext &solve_context, + ParticleChunkContext &particles, + Span<const ParticleEvent *> events, + Vector<int64_t> &r_unfinished_pindices) +{ + int array_size = particles.index_mask.min_array_size(); + Array<int> next_event_indices(array_size); + Array<float> time_factors_to_next_event(array_size); + + find_next_event_per_particle( + solve_context, particles, events, next_event_indices, time_factors_to_next_event); + + forward_particles_to_next_event_or_end(particles, time_factors_to_next_event); + + Array<Vector<int64_t>> particles_per_event(events.size()); + group_particles_by_event(particles.index_mask, next_event_indices, particles_per_event); + + execute_events(solve_context, particles, events, particles_per_event); + find_unfinished_particles( + particles.index_mask, time_factors_to_next_event, r_unfinished_pindices); +} + +BLI_NOINLINE static void simulate_with_max_n_events(SimulationSolveContext &solve_context, + ParticleSimulationState &state, + ParticleChunkContext &particles, + int max_events) +{ + Span<const ParticleEvent *> events = solve_context.influences.particle_events.lookup_as( + state.head.name); + if (events.size() == 0) { + apply_remaining_diffs(particles); + return; + } + + Vector<int64_t> unfininished_pindices = particles.index_mask.indices(); + for (int iteration : IndexRange(max_events)) { + UNUSED_VARS(iteration); + if (unfininished_pindices.is_empty()) { + break; + } + + Vector<int64_t> new_unfinished_pindices; + ParticleChunkContext remaining_particles{particles.state, + unfininished_pindices.as_span(), + particles.attributes, + particles.integration}; + simulate_to_next_event(solve_context, remaining_particles, events, new_unfinished_pindices); + unfininished_pindices = std::move(new_unfinished_pindices); + } + + if (!unfininished_pindices.is_empty()) { + ParticleChunkContext remaining_particles{particles.state, + unfininished_pindices.as_span(), + particles.attributes, + particles.integration}; + apply_remaining_diffs(remaining_particles); + } +} + BLI_NOINLINE static void simulate_particle_chunk(SimulationSolveContext &solve_context, ParticleSimulationState &state, MutableAttributesRef attributes, @@ -132,7 +296,7 @@ BLI_NOINLINE static void simulate_particle_chunk(SimulationSolveContext &solve_c Span<const ParticleAction *> begin_actions = solve_context.influences.particle_time_step_begin_actions.lookup_as(state.head.name); for (const ParticleAction *action : begin_actions) { - ParticleChunkContext particles{IndexMask(particle_amount), attributes}; + ParticleChunkContext particles{state, IndexMask(particle_amount), attributes}; ParticleActionContext action_context{solve_context, particles}; action->execute(action_context); } @@ -141,30 +305,32 @@ BLI_NOINLINE static void simulate_particle_chunk(SimulationSolveContext &solve_c Span<const ParticleForce *> forces = solve_context.influences.particle_forces.lookup_as( state.head.name); for (const ParticleForce *force : forces) { - ParticleChunkContext particles{IndexMask(particle_amount), attributes}; + ParticleChunkContext particles{state, IndexMask(particle_amount), attributes}; ParticleForceContext particle_force_context{solve_context, particles, force_vectors}; force->add_force(particle_force_context); } - MutableSpan<float3> positions = attributes.get<float3>("Position"); MutableSpan<float3> velocities = attributes.get<float3>("Velocity"); - MutableSpan<float> birth_times = attributes.get<float>("Birth Time"); - MutableSpan<int> dead_states = attributes.get<int>("Dead"); + Array<float3> position_diffs(particle_amount); + Array<float3> velocity_diffs(particle_amount); for (int i : IndexRange(particle_amount)) { const float time_step = remaining_durations[i]; - velocities[i] += force_vectors[i] * time_step; - positions[i] += velocities[i] * time_step; - - if (end_time - birth_times[i] > 2) { - dead_states[i] = true; - } + velocity_diffs[i] = force_vectors[i] * time_step; + position_diffs[i] = (velocities[i] + velocity_diffs[i] / 2.0f) * time_step; } + ParticleChunkIntegrationContext integration_context = { + position_diffs, velocity_diffs, remaining_durations, end_time}; + ParticleChunkContext particle_chunk_context{ + state, IndexMask(particle_amount), attributes, &integration_context}; + + simulate_with_max_n_events(solve_context, state, particle_chunk_context, 10); + Span<const ParticleAction *> end_actions = solve_context.influences.particle_time_step_end_actions.lookup_as(state.head.name); for (const ParticleAction *action : end_actions) { - ParticleChunkContext particles{IndexMask(particle_amount), attributes}; + ParticleChunkContext particles{state, IndexMask(particle_amount), attributes}; ParticleActionContext action_context{solve_context, particles}; action->execute(action_context); } @@ -326,7 +492,7 @@ void solve_simulation_time_step(Simulation &simulation, Span<const ParticleAction *> actions = influences.particle_birth_actions.lookup_as( state->head.name); for (const ParticleAction *action : actions) { - ParticleChunkContext chunk_context{IndexRange(attributes.size()), attributes}; + ParticleChunkContext chunk_context{*state, IndexRange(attributes.size()), attributes}; ParticleActionContext action_context{solve_context, chunk_context}; action->execute(action_context); } diff --git a/source/blender/simulation/intern/simulation_solver_influences.cc b/source/blender/simulation/intern/simulation_solver_influences.cc index 75c2c820651..3485d7c7bfb 100644 --- a/source/blender/simulation/intern/simulation_solver_influences.cc +++ b/source/blender/simulation/intern/simulation_solver_influences.cc @@ -32,6 +32,10 @@ ParticleAction::~ParticleAction() { } +ParticleEvent::~ParticleEvent() +{ +} + DependencyAnimations::~DependencyAnimations() { } diff --git a/source/blender/simulation/intern/simulation_solver_influences.hh b/source/blender/simulation/intern/simulation_solver_influences.hh index d3c515bb6a0..f7b8affd88d 100644 --- a/source/blender/simulation/intern/simulation_solver_influences.hh +++ b/source/blender/simulation/intern/simulation_solver_influences.hh @@ -45,6 +45,7 @@ using fn::MutableAttributesRef; struct ParticleEmitterContext; struct ParticleForceContext; struct ParticleActionContext; +struct ParticleEventFilterContext; class ParticleEmitter { public: @@ -64,11 +65,19 @@ class ParticleAction { virtual void execute(ParticleActionContext &context) const = 0; }; +class ParticleEvent { + public: + virtual ~ParticleEvent(); + virtual void filter(ParticleEventFilterContext &context) const = 0; + virtual void execute(ParticleActionContext &context) const = 0; +}; + struct SimulationInfluences { MultiValueMap<std::string, const ParticleForce *> particle_forces; MultiValueMap<std::string, const ParticleAction *> particle_birth_actions; MultiValueMap<std::string, const ParticleAction *> particle_time_step_begin_actions; MultiValueMap<std::string, const ParticleAction *> particle_time_step_end_actions; + MultiValueMap<std::string, const ParticleEvent *> particle_events; Map<std::string, AttributesInfoBuilder *> particle_attributes_builder; Vector<const ParticleEmitter *> particle_emitters; }; @@ -157,9 +166,37 @@ class ParticleAllocators { } }; +struct ParticleChunkIntegrationContext { + MutableSpan<float3> position_diffs; + MutableSpan<float3> velocity_diffs; + MutableSpan<float> durations; + float end_time; +}; + struct ParticleChunkContext { + ParticleSimulationState &state; IndexMask index_mask; MutableAttributesRef attributes; + ParticleChunkIntegrationContext *integration = nullptr; + + void update_diffs_after_velocity_change() + { + if (integration == nullptr) { + return; + } + + Span<float> remaining_durations = integration->durations; + MutableSpan<float3> position_diffs = integration->position_diffs; + Span<float3> velocities = attributes.get<float3>("Velocity"); + + for (int i : index_mask) { + const float duration = remaining_durations[i]; + /* This is certainly not a perfect way to "re-integrate" the velocity, but it should be good + * enough for most use cases. Changing the velocity in an instant is not physically correct + * anyway. */ + position_diffs[i] = velocities[i] * duration; + } + } }; struct ParticleEmitterContext { @@ -189,6 +226,12 @@ struct ParticleActionContext { ParticleChunkContext &particles; }; +struct ParticleEventFilterContext { + SimulationSolveContext &solve_context; + ParticleChunkContext &particles; + MutableSpan<float> factor_dst; +}; + } // namespace blender::sim #endif /* __SIM_SIMULATION_SOLVER_INFLUENCES_HH__ */ diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 2112477e62a..43c08a2b980 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -293,7 +293,7 @@ void WM_keyconfig_init(bContext *C) /* initialize only after python init is done, for keymaps that * use python operators */ - if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INITIALIZED) == 0) { + if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INIT) == 0) { /* create default key config, only initialize once, * it's persistent across sessions */ if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) { @@ -308,7 +308,7 @@ void WM_keyconfig_init(bContext *C) WM_keyconfig_update_tag(NULL, NULL); WM_keyconfig_update(wm); - wm->initialized |= WM_KEYCONFIG_IS_INITIALIZED; + wm->initialized |= WM_KEYCONFIG_IS_INIT; } } @@ -334,7 +334,7 @@ void WM_check(bContext *C) if (!G.background) { /* case: fileread */ - if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) { + if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) { WM_keyconfig_init(C); WM_autosave_init(wm); } @@ -345,9 +345,9 @@ void WM_check(bContext *C) /* case: fileread */ /* note: this runs in bg mode to set the screen context cb */ - if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) { - ED_screens_initialize(bmain, wm); - wm->initialized |= WM_WINDOW_IS_INITIALIZED; + if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) { + ED_screens_init(bmain, wm); + wm->initialized |= WM_WINDOW_IS_INIT; } } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index f431a6f431b..f39fc0aecf2 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -258,7 +258,7 @@ static void wm_window_match_keep_current_wm(const bContext *C, bScreen *screen = NULL; /* match oldwm to new dbase, only old files */ - wm->initialized &= ~WM_WINDOW_IS_INITIALIZED; + wm->initialized &= ~WM_WINDOW_IS_INIT; /* when loading without UI, no matching needed */ if (load_ui && (screen = CTX_wm_screen(C))) { diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index d7102a1e8af..f0ad5f1e9c6 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -363,7 +363,7 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname) WM_keyconfig_update(wm); BLI_strncpy(U.keyconfigstr, idname, sizeof(U.keyconfigstr)); - if (wm->initialized & WM_KEYCONFIG_IS_INITIALIZED) { + if (wm->initialized & WM_KEYCONFIG_IS_INIT) { U.runtime.is_dirty = true; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d1f65b6271b..1c277b27943 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2322,7 +2322,7 @@ static void radial_control_paint_curve(uint pos, Brush *br, float radius, int li GPU_line_width(2.0f); immUniformColor4f(0.8f, 0.8f, 0.8f, 0.85f); float step = (radius * 2.0f) / (float)line_segments; - BKE_curvemapping_initialize(br->curve); + BKE_curvemapping_init(br->curve); immBegin(GPU_PRIM_LINES, line_segments * 2); for (int i = 0; i < line_segments; i++) { float h1 = BKE_brush_curve_strength_clamped(br, fabsf((i * step) - radius), radius); @@ -2968,7 +2968,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even if (rc->subtype == PROP_ANGLE) { float initial_position[2] = {UNPACK2(rc->initial_mouse)}; float current_position[2] = {UNPACK2(rc->slow_mouse)}; - rc->dial = BLI_dial_initialize(initial_position, 0.0f); + rc->dial = BLI_dial_init(initial_position, 0.0f); /* immediately set the position to get a an initial direction */ BLI_dial_angle(rc->dial, current_position); } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index e444c5b2109..fc04323333b 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1206,7 +1206,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr /* Ghost now can call this function for life resizes, * but it should return if WM didn't initialize yet. * Can happen on file read (especially full size window). */ - if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) { + if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) { return 1; } if (!ghostwin) { diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 0c70ab2f64b..3b5df8d0a8f 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -79,10 +79,6 @@ if(WITH_TBB) link_directories(${LIBDIR}/tbb/lib) endif() -if(WITH_GMP) - blender_include_dirs(${GMP_INCLUDE_DIRS}) - link_directories(${LIBDIR}/gmp/lib) -endif() if(WITH_PYTHON) blender_include_dirs(../blender/python) @@ -119,6 +115,10 @@ if(WITH_XR_OPENXR) add_definitions(-DWITH_XR_OPENXR) endif() +if(WITH_GMP) + add_definitions(-DWITH_GMP) +endif() + # Setup the exe sources and buildinfo set(SRC creator.c @@ -713,7 +713,7 @@ elseif(WIN32) DESTINATION "." CONFIGURATIONS Debug ) - endif() + endif() if(WITH_WINDOWS_PDB) if(WITH_WINDOWS_STRIPPED_PDB) diff --git a/source/creator/creator.c b/source/creator/creator.c index 9268ed15923..3d76d832d9f 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -110,25 +110,10 @@ #include "creator_intern.h" /* own include */ /* Local Function prototypes. */ -#ifdef WITH_PYTHON_MODULE -int main_python_enter(int argc, const char **argv); -void main_python_exit(void); -#endif -#ifdef WITH_USD -/** - * Workaround to make it possible to pass a path at runtime to USD. - * - * USD requires some JSON files, and it uses a static constructor to determine the possible - * file-system paths to find those files. This made it impossible for Blender to pass a path to the - * USD library at runtime, as the constructor would run before Blender's main() function. We have - * patched USD (see usd.diff) to avoid that particular static constructor, and have an - * initialization function instead. - * - * This function is implemented in the USD source code, `pxr/base/lib/plug/initConfig.cpp`. - */ -void usd_initialise_plugin_path(const char *datafiles_usd_path); -#endif +/* -------------------------------------------------------------------- */ +/** \name Local Application State + * \{ */ /* written to by 'creator_args.c' */ struct ApplicationState app_state = { @@ -143,6 +128,8 @@ struct ApplicationState app_state = { }, }; +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Application Level Callbacks * @@ -199,11 +186,19 @@ static void callback_clg_fatal(void *fp) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Main Function +/** \name Blender as a Stand-Alone Python Module (bpy) + * + * While not officially supported, this can be useful for Python developers. + * See: https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule * \{ */ #ifdef WITH_PYTHON_MODULE -/* allow python module to call main */ + +/* Called in `bpy_interface.c` when building as a Python module. */ +int main_python_enter(int argc, const char **argv); +void main_python_exit(void); + +/* Rename the 'main' function, allowing Python initialization to call it. */ # define main main_python_enter static void *evil_C = NULL; @@ -211,8 +206,15 @@ static void *evil_C = NULL; /* Environment is not available in macOS shared libraries. */ # include <crt_externs.h> char **environ = NULL; -# endif -#endif +# endif /* __APPLE__ */ + +#endif /* WITH_PYTHON_MODULE */ + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Main Function + * \{ */ /** * Blender's main function responsibilities are: @@ -295,7 +297,7 @@ int main(int argc, break; } } - MEM_initialize_memleak_detection(); + MEM_init_memleak_detection(); } #ifdef BUILD_DATE @@ -441,10 +443,21 @@ int main(int argc, BKE_materials_init(); #ifdef WITH_USD + /* Workaround to make it possible to pass a path at runtime to USD. + * + * USD requires some JSON files, and it uses a static constructor to determine the possible + * file-system paths to find those files. This made it impossible for Blender to pass a path to + * the USD library at runtime, as the constructor would run before Blender's main() function. + * We have patched USD (see usd.diff) to avoid that particular static constructor, and have an + * initialization function instead. + * + * This function is implemented in the USD source code, `pxr/base/lib/plug/initConfig.cpp`. */ + extern void usd_initialise_plugin_path(const char *datafiles_usd_path); + /* Tell USD which directory to search for its JSON files. If 'datafiles/usd' * does not exist, the USD library will not be able to read or write any files. */ usd_initialise_plugin_path(BKE_appdir_folder_id(BLENDER_DATAFILES, "usd")); -#endif +#endif /* WITH_USD */ if (G.background == 0) { #ifndef WITH_PYTHON_MODULE @@ -488,7 +501,7 @@ int main(int argc, #ifdef WITH_FREESTYLE /* Initialize Freestyle. */ - FRS_initialize(); + FRS_init(); FRS_set_context(C); #endif |