From 37e4a311b0ad9da7177e50620efc3561e2dd7045 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Nov 2009 20:43:45 +0000 Subject: [PATCH] Math Lib * Convert all code to use new functions. * Branch maintainers may want to skip this commit, and run this conversion script instead, if they use a lot of math functions in new code: http://www.pasteall.org/9052/python --- source/blender/blenfont/intern/blf_font.c | 4 +- source/blender/blenkernel/BKE_cloth.h | 2 +- source/blender/blenkernel/BKE_constraint.h | 2 +- source/blender/blenkernel/intern/BME_tools.c | 96 +-- .../blender/blenkernel/intern/DerivedMesh.c | 58 +- source/blender/blenkernel/intern/action.c | 46 +- source/blender/blenkernel/intern/anim.c | 150 ++--- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/armature.c | 336 +++++----- source/blender/blenkernel/intern/boids.c | 360 +++++----- source/blender/blenkernel/intern/booleanops.c | 18 +- .../blenkernel/intern/booleanops_mesh.c | 4 +- source/blender/blenkernel/intern/brush.c | 10 +- source/blender/blenkernel/intern/bvhutils.c | 24 +- .../blender/blenkernel/intern/cdderivedmesh.c | 50 +- source/blender/blenkernel/intern/cloth.c | 10 +- source/blender/blenkernel/intern/collision.c | 54 +- source/blender/blenkernel/intern/colortools.c | 26 +- source/blender/blenkernel/intern/constraint.c | 616 +++++++++--------- source/blender/blenkernel/intern/curve.c | 122 ++-- source/blender/blenkernel/intern/customdata.c | 34 +- source/blender/blenkernel/intern/deform.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/displist.c | 46 +- source/blender/blenkernel/intern/effect.c | 120 ++-- source/blender/blenkernel/intern/exotic.c | 32 +- source/blender/blenkernel/intern/fcurve.c | 14 +- source/blender/blenkernel/intern/fluidsim.c | 8 +- source/blender/blenkernel/intern/fmodifier.c | 2 +- source/blender/blenkernel/intern/font.c | 16 +- source/blender/blenkernel/intern/gpencil.c | 2 +- source/blender/blenkernel/intern/image.c | 2 +- source/blender/blenkernel/intern/implicit.c | 14 +- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/lattice.c | 110 ++-- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/mball.c | 26 +- source/blender/blenkernel/intern/mesh.c | 22 +- source/blender/blenkernel/intern/modifier.c | 302 ++++----- source/blender/blenkernel/intern/multires.c | 46 +- source/blender/blenkernel/intern/node.c | 2 +- source/blender/blenkernel/intern/object.c | 154 ++--- source/blender/blenkernel/intern/particle.c | 382 +++++------ .../blenkernel/intern/particle_system.c | 326 ++++----- source/blender/blenkernel/intern/pointcache.c | 58 +- source/blender/blenkernel/intern/scene.c | 6 +- source/blender/blenkernel/intern/seqeffects.c | 2 +- source/blender/blenkernel/intern/shrinkwrap.c | 36 +- .../blender/blenkernel/intern/simple_deform.c | 8 +- source/blender/blenkernel/intern/sketch.c | 26 +- source/blender/blenkernel/intern/smoke.c | 62 +- source/blender/blenkernel/intern/softbody.c | 248 +++---- .../blender/blenkernel/intern/subsurf_ccg.c | 48 +- source/blender/blenkernel/intern/texture.c | 12 +- source/blender/blenkernel/intern/world.c | 2 +- source/blender/blenlib/intern/BLI_kdopbvh.c | 6 +- source/blender/blenlib/intern/BLI_kdtree.c | 12 +- source/blender/blenlib/intern/freetypefont.c | 12 +- source/blender/blenlib/intern/graph.c | 60 +- source/blender/blenlib/intern/jitter.c | 2 +- source/blender/blenlib/intern/scanfill.c | 14 +- source/blender/blenloader/intern/readfile.c | 8 +- source/blender/collada/DocumentExporter.cpp | 32 +- source/blender/collada/DocumentImporter.cpp | 62 +- source/blender/collada/collada_internal.h | 10 +- .../editors/animation/anim_channels_defines.c | 2 +- .../editors/animation/anim_channels_edit.c | 2 +- .../editors/animation/anim_ipo_utils.c | 2 +- source/blender/editors/animation/drivers.c | 2 +- .../blender/editors/animation/fmodifier_ui.c | 2 +- .../editors/animation/keyframes_draw.c | 2 +- .../editors/animation/keyframes_edit.c | 2 +- .../editors/animation/keyframes_general.c | 2 +- source/blender/editors/animation/keyframing.c | 12 +- source/blender/editors/animation/keyingsets.c | 2 +- .../blender/editors/armature/armature_ops.c | 2 +- .../blender/editors/armature/editarmature.c | 266 ++++---- .../editors/armature/editarmature_generate.c | 68 +- .../editors/armature/editarmature_retarget.c | 180 ++--- .../editors/armature/editarmature_sketch.c | 122 ++-- .../blender/editors/armature/meshlaplacian.c | 98 +-- source/blender/editors/armature/poseSlide.c | 10 +- source/blender/editors/armature/poselib.c | 2 +- source/blender/editors/armature/poseobject.c | 36 +- source/blender/editors/armature/reeb.c | 94 +-- source/blender/editors/curve/curve_ops.c | 2 +- source/blender/editors/curve/editcurve.c | 148 ++--- source/blender/editors/curve/editfont.c | 4 +- source/blender/editors/gpencil/drawgpencil.c | 10 +- .../editors/gpencil/editaction_gpencil.c | 2 +- .../blender/editors/gpencil/gpencil_buttons.c | 2 +- source/blender/editors/gpencil/gpencil_edit.c | 14 +- .../blender/editors/gpencil/gpencil_paint.c | 8 +- source/blender/editors/interface/interface.c | 4 +- .../editors/interface/interface_draw.c | 2 +- .../editors/interface/interface_handlers.c | 14 +- .../editors/interface/interface_icons.c | 2 +- .../editors/interface/interface_panel.c | 2 +- .../editors/interface/interface_regions.c | 2 +- .../editors/interface/interface_style.c | 2 +- .../editors/interface/interface_templates.c | 2 +- .../editors/interface/interface_widgets.c | 2 +- source/blender/editors/mesh/editface.c | 28 +- source/blender/editors/mesh/editmesh.c | 24 +- source/blender/editors/mesh/editmesh_add.c | 76 +-- source/blender/editors/mesh/editmesh_lib.c | 140 ++-- source/blender/editors/mesh/editmesh_loop.c | 4 +- source/blender/editors/mesh/editmesh_mods.c | 96 +-- source/blender/editors/mesh/editmesh_tools.c | 160 ++--- source/blender/editors/mesh/mesh_data.c | 4 +- source/blender/editors/mesh/mesh_ops.c | 2 +- source/blender/editors/mesh/meshtools.c | 40 +- source/blender/editors/metaball/mball_edit.c | 18 +- source/blender/editors/object/object_add.c | 6 +- .../editors/object/object_constraint.c | 20 +- source/blender/editors/object/object_edit.c | 12 +- source/blender/editors/object/object_hook.c | 46 +- .../blender/editors/object/object_modifier.c | 18 +- source/blender/editors/object/object_ops.c | 2 +- .../blender/editors/object/object_relations.c | 16 +- source/blender/editors/object/object_select.c | 4 +- .../blender/editors/object/object_shapekey.c | 2 +- .../blender/editors/object/object_transform.c | 88 +-- .../blender/editors/physics/particle_edit.c | 152 ++--- .../blender/editors/physics/particle_object.c | 22 +- .../blender/editors/physics/physics_fluid.c | 6 +- .../blender/editors/render/render_preview.c | 2 +- .../blender/editors/render/render_shading.c | 2 +- source/blender/editors/screen/area.c | 2 +- source/blender/editors/screen/glutil.c | 2 +- source/blender/editors/screen/screen_ops.c | 4 +- .../editors/sculpt_paint/paint_image.c | 294 ++++----- .../editors/sculpt_paint/paint_stroke.c | 2 +- .../editors/sculpt_paint/paint_utils.c | 14 +- .../editors/sculpt_paint/paint_vertex.c | 22 +- source/blender/editors/sculpt_paint/sculpt.c | 100 +-- .../editors/space_action/action_draw.c | 2 +- .../editors/space_action/action_edit.c | 2 +- .../editors/space_action/action_select.c | 2 +- .../editors/space_action/space_action.c | 2 +- source/blender/editors/space_api/space.c | 2 +- .../editors/space_buttons/space_buttons.c | 2 +- .../editors/space_console/space_console.c | 2 +- .../blender/editors/space_file/space_file.c | 2 +- .../editors/space_graph/graph_buttons.c | 2 +- .../blender/editors/space_graph/graph_draw.c | 2 +- .../blender/editors/space_graph/graph_edit.c | 2 +- .../editors/space_graph/graph_select.c | 2 +- .../blender/editors/space_graph/graph_utils.c | 2 +- .../blender/editors/space_graph/space_graph.c | 2 +- .../editors/space_image/image_buttons.c | 2 +- .../blender/editors/space_image/image_ops.c | 2 +- .../blender/editors/space_image/space_image.c | 2 +- .../blender/editors/space_info/space_info.c | 2 +- .../editors/space_logic/logic_buttons.c | 2 +- .../blender/editors/space_logic/space_logic.c | 2 +- .../blender/editors/space_nla/nla_buttons.c | 2 +- .../blender/editors/space_nla/nla_channels.c | 2 +- source/blender/editors/space_nla/nla_draw.c | 2 +- source/blender/editors/space_nla/nla_edit.c | 2 +- source/blender/editors/space_nla/nla_header.c | 2 +- source/blender/editors/space_nla/nla_ops.c | 2 +- source/blender/editors/space_nla/nla_select.c | 2 +- source/blender/editors/space_nla/space_nla.c | 2 +- source/blender/editors/space_node/drawnode.c | 2 +- source/blender/editors/space_node/node_draw.c | 2 +- source/blender/editors/space_node/node_edit.c | 4 +- .../blender/editors/space_node/space_node.c | 2 +- .../editors/space_outliner/space_outliner.c | 2 +- .../blender/editors/space_script/script_ops.c | 2 +- .../editors/space_script/space_script.c | 2 +- .../editors/space_sequencer/sequencer_add.c | 2 +- .../editors/space_sequencer/sequencer_draw.c | 2 +- .../editors/space_sequencer/sequencer_edit.c | 2 +- .../editors/space_sequencer/sequencer_ops.c | 2 +- .../space_sequencer/sequencer_select.c | 2 +- .../editors/space_sequencer/space_sequencer.c | 2 +- .../blender/editors/space_sound/space_sound.c | 2 +- .../blender/editors/space_text/space_text.c | 2 +- .../editors/space_view3d/drawarmature.c | 80 +-- .../blender/editors/space_view3d/drawmesh.c | 4 +- .../blender/editors/space_view3d/drawobject.c | 192 +++--- .../blender/editors/space_view3d/drawvolume.c | 8 +- .../editors/space_view3d/space_view3d.c | 2 +- .../editors/space_view3d/view3d_buttons.c | 56 +- .../editors/space_view3d/view3d_draw.c | 36 +- .../editors/space_view3d/view3d_edit.c | 168 ++--- .../editors/space_view3d/view3d_header.c | 8 +- .../blender/editors/space_view3d/view3d_ops.c | 2 +- .../editors/space_view3d/view3d_select.c | 24 +- .../editors/space_view3d/view3d_snap.c | 92 +-- .../editors/space_view3d/view3d_toolbar.c | 2 +- .../editors/space_view3d/view3d_view.c | 172 ++--- source/blender/editors/transform/transform.c | 456 ++++++------- .../editors/transform/transform_constraints.c | 114 ++-- .../editors/transform/transform_conversions.c | 288 ++++---- .../editors/transform/transform_generics.c | 82 +-- .../editors/transform/transform_input.c | 14 +- .../editors/transform/transform_manipulator.c | 180 ++--- .../blender/editors/transform/transform_ops.c | 2 +- .../transform/transform_orientations.c | 122 ++-- .../editors/transform/transform_snap.c | 226 +++---- source/blender/editors/uvedit/uvedit_draw.c | 90 +-- source/blender/editors/uvedit/uvedit_ops.c | 12 +- .../editors/uvedit/uvedit_parametrizer.c | 102 +-- .../editors/uvedit/uvedit_unwrap_ops.c | 44 +- source/blender/gpu/intern/gpu_buffers.c | 6 +- source/blender/gpu/intern/gpu_material.c | 46 +- source/blender/ikplugin/intern/ikplugin_api.c | 2 +- .../blender/ikplugin/intern/iksolver_plugin.c | 84 +-- .../blender/ikplugin/intern/itasc_plugin.cpp | 74 +-- source/blender/makesdna/DNA_action_types.h | 2 +- .../blender/makesdna/DNA_constraint_types.h | 2 +- source/blender/makesrna/intern/rna_armature.c | 2 +- source/blender/makesrna/intern/rna_mesh.c | 10 +- source/blender/makesrna/intern/rna_object.c | 10 +- .../blender/makesrna/intern/rna_object_api.c | 2 +- source/blender/makesrna/intern/rna_particle.c | 2 +- source/blender/makesrna/intern/rna_pose.c | 6 +- source/blender/nodes/intern/CMP_util.h | 2 +- .../nodes/intern/SHD_nodes/SHD_camera.c | 2 +- .../nodes/intern/SHD_nodes/SHD_curves.c | 2 +- .../nodes/intern/SHD_nodes/SHD_mapping.c | 2 +- .../nodes/intern/SHD_nodes/SHD_material.c | 4 +- .../nodes/intern/SHD_nodes/SHD_vectMath.c | 6 +- source/blender/nodes/intern/SHD_util.h | 2 +- .../nodes/intern/TEX_nodes/TEX_distance.c | 4 +- .../nodes/intern/TEX_nodes/TEX_rotate.c | 6 +- source/blender/nodes/intern/TEX_util.h | 2 +- source/blender/python/generic/Geometry.c | 10 +- source/blender/python/generic/Mathutils.c | 66 +- source/blender/python/generic/euler.c | 12 +- source/blender/python/generic/matrix.c | 48 +- source/blender/python/generic/quat.c | 44 +- source/blender/python/generic/vector.c | 8 +- .../render/intern/raytrace/rayobject.cpp | 16 +- .../intern/raytrace/rayobject_rtbuild.cpp | 2 +- .../render/intern/raytrace/rayobject_vbvh.cpp | 2 +- .../render/intern/source/convertblender.c | 424 ++++++------ source/blender/render/intern/source/envmap.c | 108 +-- .../render/intern/source/imagetexture.c | 2 +- .../blender/render/intern/source/initrender.c | 4 +- .../blender/render/intern/source/occlusion.c | 68 +- .../blender/render/intern/source/pipeline.c | 12 +- .../render/intern/source/pixelblending.c | 2 +- .../render/intern/source/pixelshading.c | 18 +- .../render/intern/source/pointdensity.c | 24 +- .../render/intern/source/rayobject_blibvh.c | 4 +- .../render/intern/source/rayobject_instance.c | 14 +- .../render/intern/source/rayobject_octree.c | 4 +- .../blender/render/intern/source/rayshade.c | 78 +-- .../blender/render/intern/source/rendercore.c | 36 +- .../render/intern/source/renderdatabase.c | 40 +- source/blender/render/intern/source/shadbuf.c | 40 +- .../blender/render/intern/source/shadeinput.c | 72 +- .../render/intern/source/shadeoutput.c | 60 +- source/blender/render/intern/source/sss.c | 10 +- source/blender/render/intern/source/strand.c | 38 +- source/blender/render/intern/source/sunsky.c | 12 +- source/blender/render/intern/source/texture.c | 128 ++-- .../render/intern/source/volume_precache.c | 10 +- .../blender/render/intern/source/volumetric.c | 66 +- .../blender/render/intern/source/voxeldata.c | 8 +- source/blender/render/intern/source/zbuf.c | 24 +- .../windowmanager/intern/wm_subwindow.c | 30 +- .../Converter/BL_ActionActuator.cpp | 6 +- .../Converter/BL_ArmatureActuator.cpp | 2 +- .../Converter/BL_ArmatureChannel.cpp | 58 +- .../Converter/BL_ArmatureConstraint.cpp | 10 +- .../Converter/BL_ArmatureObject.cpp | 10 +- .../Converter/BL_BlenderDataConversion.cpp | 14 +- .../gameengine/Converter/BL_MeshDeformer.cpp | 4 +- .../Converter/BL_ModifierDeformer.cpp | 2 +- .../Converter/BL_ShapeActionActuator.cpp | 2 +- .../gameengine/Converter/BL_ShapeDeformer.cpp | 2 +- .../gameengine/Converter/BL_SkinDeformer.cpp | 12 +- .../Converter/KX_BlenderSceneConverter.cpp | 12 +- source/gameengine/Ketsji/KX_Dome.cpp | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 8 +- .../gameengine/Ketsji/KX_IPO_SGController.cpp | 2 +- .../gameengine/VideoTexture/ImageRender.cpp | 48 +- 281 files changed, 5814 insertions(+), 5814 deletions(-) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 8721e49f06b..c1b54c393c7 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -46,7 +46,7 @@ #include "BLI_blenlib.h" #include "BLI_linklist.h" /* linknode */ #include "BLI_string.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BIF_gl.h" #include "BLF_api.h" @@ -459,7 +459,7 @@ static void blf_font_fill(FontBLF *font) font->pos[0]= 0.0f; font->pos[1]= 0.0f; font->angle= 0.0f; - Mat4One(font->mat); + unit_m4(font->mat); font->clip_rec.xmin= 0.0f; font->clip_rec.xmax= 0.0f; font->clip_rec.ymin= 0.0f; diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index e5b3adbd0c0..54dd82317fc 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -38,7 +38,7 @@ #include "BKE_DerivedMesh.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" #include "DNA_cloth_types.h" diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index 6446b48d553..f957c5e17d4 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -52,7 +52,7 @@ typedef struct bConstraintOb { float startmat[4][4]; /* original matrix (before constraint solving) */ short type; /* type of owner */ - short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_arithb.h) */ + short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_math.h) */ } bConstraintOb; /* ---------------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 32065ea5151..d92e8fe4227 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -42,7 +42,7 @@ #include "BKE_utildefines.h" #include "BKE_bmesh.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" /*split this all into a seperate bevel.c file in src*/ @@ -88,7 +88,7 @@ BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BME_Mesh *bm, BME_Ve else if (org != NULL) VECCOPY(vtd->org,org); if (vec != NULL) { VECCOPY(vtd->vec,vec); - Normalize(vtd->vec); + normalize_v3(vtd->vec); } vtd->loc = loc; @@ -261,7 +261,7 @@ static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge nv = BME_SEMV(bm,v,e,ne); if (nv == NULL) return NULL; VECSUB(nv->co,v2->co,v->co); - len = VecLength(nv->co); + len = len_v3(nv->co); VECADDFAC(nv->co,v->co,nv->co,len*percent); nv->flag = v->flag; nv->bweight = v->bweight; @@ -335,17 +335,17 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa /* compare the transform origins to see if we can use the vert co's; * if they belong to different origins, then we will use the origins to determine * the vector */ - if (VecCompare(vtd1->org,vtd2->org,0.000001f)) { + if (compare_v3v3(vtd1->org,vtd2->org,0.000001f)) { VECSUB(vec,v2->co,v1->co); - if (VecLength(vec) < 0.000001f) { - VecMulf(vec,0); + if (len_v3(vec) < 0.000001f) { + mul_v3_fl(vec,0); } return 0; } else { VECSUB(vec,vtd2->org,vtd1->org); - if (VecLength(vec) < 0.000001f) { - VecMulf(vec,0); + if (len_v3(vec) < 0.000001f) { + mul_v3_fl(vec,0); } return 1; } @@ -363,18 +363,18 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *td) { float factor, vec3[3], tmp[3],c1,c2; - Crossf(tmp,vec1,vec2); - Normalize(tmp); - factor = Inpf(up_vec,tmp); + cross_v3_v3v3(tmp,vec1,vec2); + normalize_v3(tmp); + factor = dot_v3v3(up_vec,tmp); if ((factor > 0 && is_forward) || (factor < 0 && !is_forward)) { - Crossf(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */ + cross_v3_v3v3(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */ } else { - Crossf(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */ + cross_v3_v3v3(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */ } - Normalize(vec3); - c1 = Inpf(vec3,vec1); - c2 = Inpf(vec1,vec1); + normalize_v3(vec3); + c1 = dot_v3v3(vec3,vec1); + c2 = dot_v3v3(vec1,vec1); if (fabs(c1) < 0.000001f || fabs(c2) < 0.000001f) { factor = 0.0f; } @@ -435,8 +435,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */ BME_bevel_get_vec(vec1,v1,v,td); BME_bevel_get_vec(vec2,v2,v,td); - Crossf(t_up_vec,vec1,vec2); - Normalize(t_up_vec); + cross_v3_v3v3(t_up_vec,vec1,vec2); + normalize_v3(t_up_vec); up_vec = t_up_vec; } else { @@ -486,8 +486,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B is_edge = BME_bevel_get_vec(vec1,v,v1,td); /* get the vector we will be projecting onto */ BME_bevel_get_vec(vec2,v,v2,td); /* get the vector we will be projecting parallel to */ - len = VecLength(vec1); - Normalize(vec1); + len = len_v3(vec1); + normalize_v3(vec1); vtd = BME_get_transdata(td, sv); vtd1 = BME_get_transdata(td, v); @@ -525,8 +525,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B } VECADDFAC(sv->co,v->co,vec1,dis); VECSUB(vec1,sv->co,vtd1->org); - dis = VecLength(vec1); - Normalize(vec1); + dis = len_v3(vec1); + normalize_v3(vec1); BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, maxfactor, vtd->max); return sv; @@ -545,10 +545,10 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran } else { VECCOPY(vec2,vtd1->vec); - VecMulf(vec2,vtd1->factor); - if (Inpf(vec1, vec1)) { - Projf(vec2,vec2,vec1); - fac1 = VecLength(vec2)/value; + mul_v3_fl(vec2,vtd1->factor); + if (dot_v3v3(vec1, vec1)) { + project_v3_v3v3(vec2,vec2,vec1); + fac1 = len_v3(vec2)/value; } else { fac1 = 0; @@ -560,10 +560,10 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran } else { VECCOPY(vec3,vtd2->vec); - VecMulf(vec3,vtd2->factor); - if (Inpf(vec1, vec1)) { - Projf(vec2,vec3,vec1); - fac2 = VecLength(vec2)/value; + mul_v3_fl(vec3,vtd2->factor); + if (dot_v3v3(vec1, vec1)) { + project_v3_v3v3(vec2,vec3,vec1); + fac2 = len_v3(vec2)/value; } else { fac2 = 0; @@ -571,7 +571,7 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran } if (fac1 || fac2) { - max = VecLength(vec1)/(fac1 + fac2); + max = len_v3(vec1)/(fac1 + fac2); if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) { *vtd1->max = max; } @@ -760,12 +760,12 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti for (i=0,ol=f->loopbase,l=ol->next; l->next!=ol; l=l->next) { BME_bevel_get_vec(vec1,l->next->v,ol->v,td); BME_bevel_get_vec(vec2,l->v,ol->v,td); - Crossf(vec3,vec2,vec1); + cross_v3_v3v3(vec3,vec2,vec1); VECADD(up_vec,up_vec,vec3); i++; } - VecMulf(up_vec,1.0f/i); - Normalize(up_vec); + mul_v3_fl(up_vec,1.0f/i); + normalize_v3(up_vec); for (i=0,len=f->len; inext) { if ((l->e->tflag1 & BME_BEVEL_BEVEL) && (l->e->tflag1 & BME_BEVEL_ORIG)) { @@ -791,10 +791,10 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti } else { VECCOPY(vec2,vtd1->vec); - VecMulf(vec2,vtd1->factor); - if (Inpf(vec1, vec1)) { - Projf(vec2,vec2,vec1); - fac1 = VecLength(vec2)/value; + mul_v3_fl(vec2,vtd1->factor); + if (dot_v3v3(vec1, vec1)) { + project_v3_v3v3(vec2,vec2,vec1); + fac1 = len_v3(vec2)/value; } else { fac1 = 0; @@ -805,17 +805,17 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti } else { VECCOPY(vec3,vtd2->vec); - VecMulf(vec3,vtd2->factor); - if (Inpf(vec1, vec1)) { - Projf(vec2,vec3,vec1); - fac2 = VecLength(vec2)/value; + mul_v3_fl(vec3,vtd2->factor); + if (dot_v3v3(vec1, vec1)) { + project_v3_v3v3(vec2,vec3,vec1); + fac2 = len_v3(vec2)/value; } else { fac2 = 0; } } if (fac1 || fac2) { - max = VecLength(vec1)/(fac1 + fac2); + max = len_v3(vec1)/(fac1 + fac2); if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) { *vtd1->max = max; } @@ -880,7 +880,7 @@ static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) { } VECSUB(vec1,v1->co,v->co); VECSUB(vec2,v2->co,v->co); - Crossf(vec3,vec1,vec2); + cross_v3_v3v3(vec3,vec1,vec2); l1 = l2; if (l1->v == v) { @@ -893,12 +893,12 @@ static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) { } VECSUB(vec1,v1->co,v->co); VECSUB(vec2,v2->co,v->co); - Crossf(vec4,vec2,vec1); + cross_v3_v3v3(vec4,vec2,vec1); - Normalize(vec3); - Normalize(vec4); + normalize_v3(vec3); + normalize_v3(vec4); - return Inpf(vec3,vec4); + return dot_v3v3(vec3,vec4); } static int BME_face_sharededges(BME_Poly *f1, BME_Poly *f2){ BME_Loop *l; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 11e58203bb3..f9abaa9da02 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -52,7 +52,7 @@ #include "DNA_space_types.h" #include "DNA_particle_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" @@ -619,20 +619,20 @@ static void emDM__calcFaceCent(EditFace *efa, float cent[3], float (*vertexCos)[ { if (vertexCos) { VECCOPY(cent, vertexCos[(int) efa->v1->tmp.l]); - VecAddf(cent, cent, vertexCos[(int) efa->v2->tmp.l]); - VecAddf(cent, cent, vertexCos[(int) efa->v3->tmp.l]); - if (efa->v4) VecAddf(cent, cent, vertexCos[(int) efa->v4->tmp.l]); + add_v3_v3v3(cent, cent, vertexCos[(int) efa->v2->tmp.l]); + add_v3_v3v3(cent, cent, vertexCos[(int) efa->v3->tmp.l]); + if (efa->v4) add_v3_v3v3(cent, cent, vertexCos[(int) efa->v4->tmp.l]); } else { VECCOPY(cent, efa->v1->co); - VecAddf(cent, cent, efa->v2->co); - VecAddf(cent, cent, efa->v3->co); - if (efa->v4) VecAddf(cent, cent, efa->v4->co); + add_v3_v3v3(cent, cent, efa->v2->co); + add_v3_v3v3(cent, cent, efa->v3->co); + if (efa->v4) add_v3_v3v3(cent, cent, efa->v4->co); } if (efa->v4) { - VecMulf(cent, 0.25f); + mul_v3_fl(cent, 0.25f); } else { - VecMulf(cent, 0.33333333333f); + mul_v3_fl(cent, 0.33333333333f); } } static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no), void *userData) @@ -1498,25 +1498,25 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob, if(efa->v4) { float *v4 = vertexCos[(int) efa->v4->tmp.l]; - CalcNormFloat4(v1, v2, v3, v4, no); - VecAddf(emdm->vertexNos[(int) efa->v4->tmp.l], emdm->vertexNos[(int) efa->v4->tmp.l], no); + normal_quad_v3( no,v1, v2, v3, v4); + add_v3_v3v3(emdm->vertexNos[(int) efa->v4->tmp.l], emdm->vertexNos[(int) efa->v4->tmp.l], no); } else { - CalcNormFloat(v1, v2, v3, no); + normal_tri_v3( no,v1, v2, v3); } - VecAddf(emdm->vertexNos[(int) efa->v1->tmp.l], emdm->vertexNos[(int) efa->v1->tmp.l], no); - VecAddf(emdm->vertexNos[(int) efa->v2->tmp.l], emdm->vertexNos[(int) efa->v2->tmp.l], no); - VecAddf(emdm->vertexNos[(int) efa->v3->tmp.l], emdm->vertexNos[(int) efa->v3->tmp.l], no); + add_v3_v3v3(emdm->vertexNos[(int) efa->v1->tmp.l], emdm->vertexNos[(int) efa->v1->tmp.l], no); + add_v3_v3v3(emdm->vertexNos[(int) efa->v2->tmp.l], emdm->vertexNos[(int) efa->v2->tmp.l], no); + add_v3_v3v3(emdm->vertexNos[(int) efa->v3->tmp.l], emdm->vertexNos[(int) efa->v3->tmp.l], no); } for(i=0, eve= em->verts.first; eve; i++, eve=eve->next) { float *no = emdm->vertexNos[i]; /* following Mesh convention; we use vertex coordinate itself * for normal in this case */ - if (Normalize(no)==0.0) { + if (normalize_v3(no)==0.0) { VECCOPY(no, vertexCos[i]); - Normalize(no); + normalize_v3(no); } } } @@ -2482,7 +2482,7 @@ int editmesh_get_first_deform_matrices(Object *ob, EditMesh *em, float (**deform defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); for(a=0; adeformMatricesEM(md, ob, em, dm, deformedVerts, defmats, @@ -2554,11 +2554,11 @@ void DM_add_tangent_layer(DerivedMesh *dm) if (mf->v4) { v4= &mvert[mf->v4]; - CalcNormFloat4(v4->co, v3->co, v2->co, v1->co, fno); + normal_quad_v3( fno,v4->co, v3->co, v2->co, v1->co); } else { v4= NULL; - CalcNormFloat(v3->co, v2->co, v1->co, fno); + normal_tri_v3( fno,v3->co, v2->co, v1->co); } if(mtface) { @@ -2569,11 +2569,11 @@ void DM_add_tangent_layer(DerivedMesh *dm) } else { uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; - spheremap(orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2], &uv[0][0], &uv[0][1]); - spheremap(orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2], &uv[1][0], &uv[1][1]); - spheremap(orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2], &uv[2][0], &uv[2][1]); + map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); + map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); + map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); if(v4) - spheremap(orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2], &uv[3][0], &uv[3][1]); + map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); } tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, fno, tang); @@ -2603,11 +2603,11 @@ void DM_add_tangent_layer(DerivedMesh *dm) } else { uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; - spheremap(orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2], &uv[0][0], &uv[0][1]); - spheremap(orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2], &uv[1][0], &uv[1][1]); - spheremap(orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2], &uv[2][0], &uv[2][1]); + map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); + map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); + map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); if(len==4) - spheremap(orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2], &uv[3][0], &uv[3][1]); + map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); } mf_vi[0]= mf->v1; @@ -2619,7 +2619,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) vtang= find_vertex_tangent(vtangents[mf_vi[j]], mtface ? tf->uv[j] : uv[j]); VECCOPY(tangent[j], vtang); - Normalize(tangent[j]); + normalize_v3(tangent[j]); } } diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 2505a3a70ac..358a482c3cf 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -64,7 +64,7 @@ #include "BKE_utildefines.h" #include "BIK_api.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" @@ -453,7 +453,7 @@ bPoseChannel *verify_pose_channel(bPose* pose, const char* name) chan->limitmax[0]= chan->limitmax[1]= chan->limitmax[2]= 180.0f; chan->stiffness[0]= chan->stiffness[1]= chan->stiffness[2]= 0.0f; chan->ikrotweight = chan->iklinweight = 0.0f; - Mat4One(chan->constinv); + unit_m4(chan->constinv); BLI_addtail(&pose->chanbase, chan); @@ -611,8 +611,8 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan pchan->rotAngle= chan->rotAngle; QUATCOPY(pchan->quat, chan->quat); pchan->rotmode= chan->rotmode; - Mat4CpyMat4(pchan->chan_mat, (float(*)[4])chan->chan_mat); - Mat4CpyMat4(pchan->pose_mat, (float(*)[4])chan->pose_mat); + copy_m4_m4(pchan->chan_mat, (float(*)[4])chan->chan_mat); + copy_m4_m4(pchan->pose_mat, (float(*)[4])chan->pose_mat); pchan->flag= chan->flag; con= chan->constraints.first; @@ -1013,8 +1013,8 @@ void copy_pose_result(bPose *to, bPose *from) for(pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) { pchanto= get_pose_channel(to, pchanfrom->name); if(pchanto) { - Mat4CpyMat4(pchanto->pose_mat, pchanfrom->pose_mat); - Mat4CpyMat4(pchanto->chan_mat, pchanfrom->chan_mat); + copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat); + copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat); /* used for local constraints */ VECCOPY(pchanto->loc, pchanfrom->loc); @@ -1040,9 +1040,9 @@ void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose, clear_workob(workob); /* init workob */ - Mat4CpyMat4(workob->obmat, ob->obmat); - Mat4CpyMat4(workob->parentinv, ob->parentinv); - Mat4CpyMat4(workob->constinv, ob->constinv); + copy_m4_m4(workob->obmat, ob->obmat); + copy_m4_m4(workob->parentinv, ob->parentinv); + copy_m4_m4(workob->constinv, ob->constinv); workob->parent= ob->parent; workob->track= ob->track; @@ -1109,7 +1109,7 @@ static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mo dstweight = 1.0F; } - VecLerpf(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight); + interp_v3_v3v3(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight); } @@ -1169,27 +1169,27 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, execute_action_ipo(achan, &pchan); /* store offset that moves src to location of pchan */ - VecSubf(vec, dpchan->loc, pchan.loc); + sub_v3_v3v3(vec, dpchan->loc, pchan.loc); - Mat4Mul3Vecfl(dpchan->bone->arm_mat, vec); + mul_mat3_m4_v3(dpchan->bone->arm_mat, vec); } } else { /* store offset that moves src to location of dst */ - VecSubf(vec, dpchan->loc, spchan->loc); - Mat4Mul3Vecfl(dpchan->bone->arm_mat, vec); + sub_v3_v3v3(vec, dpchan->loc, spchan->loc); + mul_mat3_m4_v3(dpchan->bone->arm_mat, vec); } /* if blending, we only add with factor scrweight */ - VecMulf(vec, srcweight); + mul_v3_fl(vec, srcweight); - VecAddf(dst->cyclic_offset, dst->cyclic_offset, vec); + add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, vec); } } } - VecAddf(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset); + add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset); } /* added "sizecorr" here, to allow armatures to be scaled and still have striding. @@ -1249,14 +1249,14 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip if (pdistNewNormalized <= 1) { // search for correction in positive path-direction where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */ - VecSubf(stride_offset, vec2, vec1); + sub_v3_v3v3(stride_offset, vec2, vec1); } else { // we reached the end of the path, search backwards instead where_on_path(ob, (pathdist-pdist)/path->totdist, vec2, dir); /* vec needs size 4 */ - VecSubf(stride_offset, vec1, vec2); + sub_v3_v3v3(stride_offset, vec1, vec2); } - Mat4Mul3Vecfl(ob->obmat, stride_offset); + mul_mat3_m4_v3(ob->obmat, stride_offset); return striptime; } } @@ -1295,10 +1295,10 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float } if(foundvert) { /* bring it into armature space */ - VecSubf(min, max, min); + sub_v3_v3v3(min, max, min); bone= get_named_bone(ob->data, strip->offs_bone); /* weak */ if(bone) { - Mat4Mul3Vecfl(bone->arm_mat, min); + mul_mat3_m4_v3(bone->arm_mat, min); /* dominant motion, cyclic_offset was cleared in rest_pose */ if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) { @@ -1549,7 +1549,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) } else if(blocktype==ID_AR) { /* apply stride offset to object */ - VecAddf(ob->obmat[3], ob->obmat[3], ob->pose->stride_offset); + add_v3_v3v3(ob->obmat[3], ob->obmat[3], ob->pose->stride_offset); } /* free */ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 79372eee468..e0a19da52ef 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -35,7 +35,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "DNA_listBase.h" @@ -134,11 +134,11 @@ void calc_curvepath(Object *ob) for(a=0; avec, bevp->vec); + sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec); else - VecSubf(xyz, (bevp+1)->vec, bevp->vec); + sub_v3_v3v3(xyz, (bevp+1)->vec, bevp->vec); - *fp= *(fp-1)+VecLength(xyz); + *fp= *(fp-1)+len_v3(xyz); bevp++; } @@ -176,11 +176,11 @@ void calc_curvepath(Object *ob) fac1= fac2/fac1; fac2= 1.0f-fac1; - VecLerpf(pp->vec, bevp->vec, bevpn->vec, fac2); + interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2); pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa; pp->radius= fac1*bevp->radius + fac2*bevpn->radius; - QuatInterpol(pp->quat, bevp->quat, bevpn->quat, fac2); - NormalQuat(pp->quat); + interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2); + normalize_qt(pp->quat); pp++; } @@ -284,20 +284,20 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, * to more then one index in data which can give divide by zero error */ /* totfac= data[0]+data[1]; - if(totfac>0.000001) QuatInterpol(q1, p0->quat, p1->quat, data[0] / totfac); + if(totfac>0.000001) interp_qt_qtqt(q1, p0->quat, p1->quat, data[0] / totfac); else QUATCOPY(q1, p1->quat); - NormalQuat(q1); + normalize_qt(q1); totfac= data[2]+data[3]; - if(totfac>0.000001) QuatInterpol(q2, p2->quat, p3->quat, data[2] / totfac); + if(totfac>0.000001) interp_qt_qtqt(q2, p2->quat, p3->quat, data[2] / totfac); else QUATCOPY(q1, p3->quat); - NormalQuat(q2); + normalize_qt(q2); totfac = data[0]+data[1]+data[2]+data[3]; - if(totfac>0.000001) QuatInterpol(quat, q1, q2, (data[0]+data[1]) / totfac); + if(totfac>0.000001) interp_qt_qtqt(quat, q1, q2, (data[0]+data[1]) / totfac); else QUATCOPY(quat, q2); - NormalQuat(quat); + normalize_qt(quat); */ // XXX - find some way to make quat interpolation work correctly, above code fails in rare but nasty cases. QUATCOPY(quat, p1->quat); @@ -317,8 +317,8 @@ static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], i BLI_addtail(lb, dob); dob->ob= ob; - Mat4CpyMat4(dob->mat, mat); - Mat4CpyMat4(dob->omat, ob->obmat); + copy_m4_m4(dob->mat, mat); + copy_m4_m4(dob->omat, ob->obmat); dob->origlay= ob->lay; dob->index= index; dob->type= type; @@ -352,20 +352,20 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i /* Group Dupli Offset, should apply after everything else */ if (group->dupli_ofs[0] || group->dupli_ofs[1] || group->dupli_ofs[2]) { - Mat4CpyMat4(tmat, go->ob->obmat); - VecSubf(tmat[3], tmat[3], group->dupli_ofs); - Mat4MulMat4(mat, tmat, ob->obmat); + copy_m4_m4(tmat, go->ob->obmat); + sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs); + mul_m4_m4m4(mat, tmat, ob->obmat); } else { - Mat4MulMat4(mat, go->ob->obmat, ob->obmat); + mul_m4_m4m4(mat, go->ob->obmat, ob->obmat); } dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated); dob->no_draw= (dob->origlay & group->layer)==0; if(go->ob->transflag & OB_DUPLI) { - Mat4CpyMat4(dob->ob->obmat, dob->mat); + copy_m4_m4(dob->ob->obmat, dob->mat); object_duplilist_recursive((ID *)group, scene, go->ob, lb, ob->obmat, level+1, animated); - Mat4CpyMat4(dob->ob->obmat, dob->omat); + copy_m4_m4(dob->ob->obmat, dob->omat); } } } @@ -402,7 +402,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, #endif // XXX old animation system where_is_object_time(scene, ob, (float)scene->r.cfra); dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated); - Mat4CpyMat4(dob->omat, copyob.obmat); + copy_m4_m4(dob->omat, copyob.obmat); } } @@ -430,11 +430,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n float vec[3], q2[4], mat[3][3], tmat[4][4], obmat[4][4]; VECCOPY(vec, co); - Mat4MulVecfl(vdd->pmat, vec); - VecSubf(vec, vec, vdd->pmat[3]); - VecAddf(vec, vec, vdd->obmat[3]); + mul_m4_v3(vdd->pmat, vec); + sub_v3_v3v3(vec, vec, vdd->pmat[3]); + add_v3_v3v3(vec, vec, vdd->obmat[3]); - Mat4CpyMat4(obmat, vdd->obmat); + copy_m4_m4(obmat, vdd->obmat); VECCOPY(obmat[3], vec); if(vdd->par->transflag & OB_DUPLIROT) { @@ -445,11 +445,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2]; } - vectoquat(vec, vdd->ob->trackflag, vdd->ob->upflag, q2); + vec_to_quat( q2,vec, vdd->ob->trackflag, vdd->ob->upflag); - QuatToMat3(q2, mat); - Mat4CpyMat4(tmat, obmat); - Mat4MulMat43(obmat, tmat, mat); + quat_to_mat3( mat,q2); + copy_m4_m4(tmat, obmat); + mul_m4_m4m3(obmat, tmat, mat); } dob= new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated); if(vdd->orco) @@ -457,10 +457,10 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n if(vdd->ob->transflag & OB_DUPLI) { float tmpmat[4][4]; - Mat4CpyMat4(tmpmat, vdd->ob->obmat); - Mat4CpyMat4(vdd->ob->obmat, obmat); /* pretend we are really this mat */ + copy_m4_m4(tmpmat, vdd->ob->obmat); + copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */ object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level+1, vdd->animated); - Mat4CpyMat4(vdd->ob->obmat, tmpmat); + copy_m4_m4(vdd->ob->obmat, tmpmat); } } @@ -478,7 +478,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl float vec[3], no[3], pmat[4][4]; int lay, totvert, a, oblay; - Mat4CpyMat4(pmat, par->obmat); + copy_m4_m4(pmat, par->obmat); /* simple preventing of too deep nested groups */ if(level>MAX_DUPLI_RECUR) return; @@ -533,9 +533,9 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl when par_space_mat is NULL ob->obmat can be used instead of ob__obmat */ if(par_space_mat) - Mat4MulMat4(vdd.obmat, ob->obmat, par_space_mat); + mul_m4_m4m4(vdd.obmat, ob->obmat, par_space_mat); else - Mat4CpyMat4(vdd.obmat, ob->obmat); + copy_m4_m4(vdd.obmat, ob->obmat); vdd.id= id; vdd.level= level; @@ -544,7 +544,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl vdd.ob= ob; vdd.scene= scene; vdd.par= par; - Mat4CpyMat4(vdd.pmat, pmat); + copy_m4_m4(vdd.pmat, pmat); /* mballs have a different dupli handling */ if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ @@ -596,7 +596,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa /* simple preventing of too deep nested groups */ if(level>MAX_DUPLI_RECUR) return; - Mat4CpyMat4(pmat, par->obmat); + copy_m4_m4(pmat, par->obmat); em = BKE_mesh_get_editmesh(me); if(em) { @@ -664,11 +664,11 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa when par_space_mat is NULL ob->obmat can be used instead of ob__obmat */ if(par_space_mat) - Mat4MulMat4(ob__obmat, ob->obmat, par_space_mat); + mul_m4_m4m4(ob__obmat, ob->obmat, par_space_mat); else - Mat4CpyMat4(ob__obmat, ob->obmat); + copy_m4_m4(ob__obmat, ob->obmat); - Mat3CpyMat4(imat, ob->parentinv); + copy_m3_m4(imat, ob->parentinv); /* mballs have a different dupli handling */ if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ @@ -686,34 +686,34 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa /* translation */ if(v4) - CalcCent4f(cent, v1, v2, v3, v4); + cent_quad_v3(cent, v1, v2, v3, v4); else - CalcCent3f(cent, v1, v2, v3); - Mat4MulVecfl(pmat, cent); + cent_tri_v3(cent, v1, v2, v3); + mul_m4_v3(pmat, cent); - VecSubf(cent, cent, pmat[3]); - VecAddf(cent, cent, ob__obmat[3]); + sub_v3_v3v3(cent, cent, pmat[3]); + add_v3_v3v3(cent, cent, ob__obmat[3]); - Mat4CpyMat4(obmat, ob__obmat); + copy_m4_m4(obmat, ob__obmat); VECCOPY(obmat[3], cent); /* rotation */ - triatoquat(v1, v2, v3, quat); - QuatToMat3(quat, mat); + tri_to_quat( quat,v1, v2, v3); + quat_to_mat3( mat,quat); /* scale */ if(par->transflag & OB_DUPLIFACES_SCALE) { - float size= v4? AreaQ3Dfl(v1, v2, v3, v4): AreaT3Dfl(v1, v2, v3); + float size= v4? area_quad_v3(v1, v2, v3, v4): area_tri_v3(v1, v2, v3); size= sqrt(size) * par->dupfacesca; - Mat3MulFloat(mat[0], size); + mul_m3_fl(mat[0], size); } - Mat3CpyMat3(mat3, mat); - Mat3MulMat3(mat, imat, mat3); + copy_m3_m3(mat3, mat); + mul_m3_m3m3(mat, imat, mat3); - Mat4CpyMat4(tmat, obmat); - Mat4MulMat43(obmat, tmat, mat); + copy_m4_m4(tmat, obmat); + mul_m4_m4m3(obmat, tmat, mat); dob= new_dupli_object(lb, ob, obmat, lay, a, OB_DUPLIFACES, animated); if(G.rendering) { @@ -744,10 +744,10 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa if(ob->transflag & OB_DUPLI) { float tmpmat[4][4]; - Mat4CpyMat4(tmpmat, ob->obmat); - Mat4CpyMat4(ob->obmat, obmat); /* pretend we are really this mat */ + copy_m4_m4(tmpmat, ob->obmat); + copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */ object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level+1, animated); - Mat4CpyMat4(ob->obmat, tmpmat); + copy_m4_m4(ob->obmat, tmpmat); } } @@ -935,22 +935,22 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if(psys_get_particle_state(&sim, a, &state, 0) == 0) continue; - QuatToMat4(state.rot, pamat); + quat_to_mat4( pamat,state.rot); VECCOPY(pamat[3], state.co); pamat[3][3]= 1.0f; } if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) { - Mat4MulMat4(tmat, oblist[b]->obmat, pamat); - Mat4MulFloat3((float *)tmat, size*scale); + mul_m4_m4m4(tmat, oblist[b]->obmat, pamat); + mul_mat3_m4_fl((float *)tmat, size*scale); if(par_space_mat) - Mat4MulMat4(mat, tmat, par_space_mat); + mul_m4_m4m4(mat, tmat, par_space_mat); else - Mat4CpyMat4(mat, tmat); + copy_m4_m4(mat, tmat); dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); - Mat4CpyMat4(dob->omat, obcopylist[b].obmat); + copy_m4_m4(dob->omat, obcopylist[b].obmat); if(G.rendering) psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco); } @@ -962,21 +962,21 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p VECCOPY(vec, obmat[3]); obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f; - Mat4CpyMat4(mat, pamat); + copy_m4_m4(mat, pamat); - Mat4MulMat4(tmat, obmat, mat); - Mat4MulFloat3((float *)tmat, size*scale); + mul_m4_m4m4(tmat, obmat, mat); + mul_mat3_m4_fl((float *)tmat, size*scale); if(part->draw & PART_DRAW_GLOBAL_OB) VECADD(tmat[3], tmat[3], vec); if(par_space_mat) - Mat4MulMat4(mat, tmat, par_space_mat); + mul_m4_m4m4(mat, tmat, par_space_mat); else - Mat4CpyMat4(mat, tmat); + copy_m4_m4(mat, tmat); dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated); - Mat4CpyMat4(dob->omat, oldobmat); + copy_m4_m4(dob->omat, oldobmat); if(G.rendering) psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco); } @@ -1037,7 +1037,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i /* simple preventing of too deep nested groups */ if(level>MAX_DUPLI_RECUR) return; - Mat4CpyMat4(pmat, par->obmat); + copy_m4_m4(pmat, par->obmat); /* in par the family name is stored, use this to find the other objects */ @@ -1062,9 +1062,9 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i vec[1]= fsize*(ct->yof - yof); vec[2]= 0.0; - Mat4MulVecfl(pmat, vec); + mul_m4_v3(pmat, vec); - Mat4CpyMat4(obmat, par->obmat); + copy_m4_m4(obmat, par->obmat); VECCOPY(obmat[3], vec); new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIVERTS, animated); @@ -1122,7 +1122,7 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas if (level==0) { for(dob= duplilist->first; dob; dob= dob->next) if(dob->type == OB_DUPLIGROUP) - Mat4CpyMat4(dob->ob->obmat, dob->mat); + copy_m4_m4(dob->ob->obmat, dob->mat); } } } @@ -1143,7 +1143,7 @@ void free_object_duplilist(ListBase *lb) for(dob= lb->first; dob; dob= dob->next) { dob->ob->lay= dob->origlay; - Mat4CpyMat4(dob->ob->obmat, dob->omat); + copy_m4_m4(dob->ob->obmat, dob->omat); } BLI_freelistN(lb); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 61e754ffbec..e2849825862 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dynstr.h" #include "DNA_anim_types.h" diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 25151714569..ab1f60ea6a6 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_armature_types.h" @@ -482,7 +482,7 @@ static void equalize_bezier(float *data, int desired) pdist[0]= 0.0f; for(a=0, fp= data; apose_mat[0]); - scale[1]= VecLength(pchan->pose_mat[1]); - scale[2]= VecLength(pchan->pose_mat[2]); + scale[0]= len_v3(pchan->pose_mat[0]); + scale[1]= len_v3(pchan->pose_mat[1]); + scale[2]= len_v3(pchan->pose_mat[2]); if(fabs(scale[0] - scale[1]) > 1e-6f || fabs(scale[1] - scale[2]) > 1e-6f) { - Mat4One(scalemat); + unit_m4(scalemat); scalemat[0][0]= scale[0]; scalemat[1][1]= scale[1]; scalemat[2][2]= scale[2]; - Mat4Invert(iscalemat, scalemat); + invert_m4_m4(iscalemat, scalemat); length *= scale[1]; doscale = 1; @@ -564,15 +564,15 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) last point = (0, length, 0) */ if(rest) { - Mat4Invert(imat, pchan->bone->arm_mat); + invert_m4_m4(imat, pchan->bone->arm_mat); } else if(doscale) { - Mat4CpyMat4(posemat, pchan->pose_mat); - Mat4Ortho(posemat); - Mat4Invert(imat, posemat); + copy_m4_m4(posemat, pchan->pose_mat); + normalize_m4(posemat); + invert_m4_m4(imat, posemat); } else - Mat4Invert(imat, pchan->pose_mat); + invert_m4_m4(imat, pchan->pose_mat); if(prev) { float difmat[4][4], result[3][3], imat3[3][3]; @@ -582,7 +582,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) VECCOPY(h1, prev->bone->arm_head) else VECCOPY(h1, prev->pose_head) - Mat4MulVecfl(imat, h1); + mul_m4_v3(imat, h1); if(prev->bone->segments>1) { /* if previous bone is B-bone too, use average handle direction */ @@ -590,21 +590,21 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) roll1= 0.0f; } - Normalize(h1); - VecMulf(h1, -hlength1); + normalize_v3(h1); + mul_v3_fl(h1, -hlength1); if(prev->bone->segments==1) { /* find the previous roll to interpolate */ if(rest) - Mat4MulMat4(difmat, prev->bone->arm_mat, imat); + mul_m4_m4m4(difmat, prev->bone->arm_mat, imat); else - Mat4MulMat4(difmat, prev->pose_mat, imat); - Mat3CpyMat4(result, difmat); // the desired rotation at beginning of next bone + mul_m4_m4m4(difmat, prev->pose_mat, imat); + copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone vec_roll_to_mat3(h1, 0.0f, mat3); // the result of vec_roll without roll - Mat3Inv(imat3, mat3); - Mat3MulMat3(mat3, result, imat3); // the matrix transforming vec_roll to desired roll + invert_m3_m3(imat3, mat3); + mul_m3_m3m3(mat3, result, imat3); // the matrix transforming vec_roll to desired roll roll1= (float)atan2(mat3[2][0], mat3[2][2]); } @@ -621,28 +621,28 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) VECCOPY(h2, next->bone->arm_tail) else VECCOPY(h2, next->pose_tail) - Mat4MulVecfl(imat, h2); + mul_m4_v3(imat, h2); /* if next bone is B-bone too, use average handle direction */ if(next->bone->segments>1); else h2[1]-= length; - Normalize(h2); + normalize_v3(h2); /* find the next roll to interpolate as well */ if(rest) - Mat4MulMat4(difmat, next->bone->arm_mat, imat); + mul_m4_m4m4(difmat, next->bone->arm_mat, imat); else - Mat4MulMat4(difmat, next->pose_mat, imat); - Mat3CpyMat4(result, difmat); // the desired rotation at beginning of next bone + mul_m4_m4m4(difmat, next->pose_mat, imat); + copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone vec_roll_to_mat3(h2, 0.0f, mat3); // the result of vec_roll without roll - Mat3Inv(imat3, mat3); - Mat3MulMat3(mat3, imat3, result); // the matrix transforming vec_roll to desired roll + invert_m3_m3(imat3, mat3); + mul_m3_m3m3(mat3, imat3, result); // the matrix transforming vec_roll to desired roll roll2= (float)atan2(mat3[2][0], mat3[2][2]); /* and only now negate handle */ - VecMulf(h2, -hlength2); + mul_v3_fl(h2, -hlength2); } else { h2[0]= 0.0f; h2[1]= -hlength2; h2[2]= 0.0f; @@ -662,15 +662,15 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) /* make transformation matrices for the segments for drawing */ for(a=0, fp= data[0]; asegments; a++, fp+=4) { - VecSubf(h1, fp+4, fp); + sub_v3_v3v3(h1, fp+4, fp); vec_roll_to_mat3(h1, fp[3], mat3); // fp[3] is roll - Mat4CpyMat3(result_array[a].mat, mat3); + copy_m4_m3(result_array[a].mat, mat3); VECCOPY(result_array[a].mat[3], fp); if(doscale) { /* correct for scaling when this matrix is used in scaled space */ - Mat4MulSerie(result_array[a].mat, iscalemat, result_array[a].mat, + mul_serie_m4(result_array[a].mat, iscalemat, result_array[a].mat, scalemat, NULL, NULL, NULL, NULL, NULL); } } @@ -701,26 +701,26 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion, int re /* first matrix is the inverse arm_mat, to bring points in local bone space for finding out which segment it belongs to */ - Mat4Invert(b_bone_mats[0].mat, bone->arm_mat); + invert_m4_m4(b_bone_mats[0].mat, bone->arm_mat); /* then we make the b_bone_mats: - first transform to local bone space - translate over the curve to the bbone mat space - transform with b_bone matrix - transform back into global space */ - Mat4One(tmat); + unit_m4(tmat); for(a=0; asegments; a++) { if(b_bone_rest) - Mat4Invert(tmat, b_bone_rest[a].mat); + invert_m4_m4(tmat, b_bone_rest[a].mat); else tmat[3][1] = -a*(bone->length/(float)bone->segments); - Mat4MulSerie(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat, + mul_serie_m4(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat, NULL, NULL, NULL); if(use_quaternion) - Mat4ToDQuat(bone->arm_mat, b_bone_mats[a+1].mat, &b_bone_dual_quats[a]); + mat4_to_dquat( &b_bone_dual_quats[a],bone->arm_mat, b_bone_mats[a+1].mat); } } @@ -743,13 +743,13 @@ static void b_bone_deform(bPoseChannel *pchan, Bone *bone, float *co, DualQuat * CLAMP(a, 0, bone->segments-1); if(dq) { - DQuatCpyDQuat(dq, &((DualQuat*)pchan->b_bone_dual_quats)[a]); + copy_dq_dq(dq, &((DualQuat*)pchan->b_bone_dual_quats)[a]); } else { - Mat4MulVecfl(b_bone[a+1].mat, co); + mul_m4_v3(b_bone[a+1].mat, co); if(defmat) - Mat3CpyMat4(defmat, b_bone[a+1].mat); + copy_m3_m4(defmat, b_bone[a+1].mat); } } @@ -761,10 +761,10 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl float pdelta[3]; float hsqr, a, l, rad; - VecSubf (bdelta, b2, b1); - l = Normalize (bdelta); + sub_v3_v3v3(bdelta, b2, b1); + l = normalize_v3(bdelta); - VecSubf (pdelta, vec, b1); + sub_v3_v3v3(pdelta, vec, b1); a = bdelta[0]*pdelta[0] + bdelta[1]*pdelta[1] + bdelta[2]*pdelta[2]; hsqr = ((pdelta[0]*pdelta[0]) + (pdelta[1]*pdelta[1]) + (pdelta[2]*pdelta[2])); @@ -809,12 +809,12 @@ static void pchan_deform_mat_add(bPoseChannel *pchan, float weight, float bbonem float wmat[3][3]; if(pchan->bone->segments>1) - Mat3CpyMat3(wmat, bbonemat); + copy_m3_m3(wmat, bbonemat); else - Mat3CpyMat4(wmat, pchan->chan_mat); + copy_m3_m4(wmat, pchan->chan_mat); - Mat3MulFloat((float*)wmat, weight); - Mat3AddMat3(mat, mat, wmat); + mul_m3_fl((float*)wmat, weight); + add_m3_m3m3(mat, mat, wmat); } static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, float mat[][3], float *co) @@ -840,12 +840,12 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo // applies on cop and bbonemat b_bone_deform(pchan, bone, cop, NULL, (mat)?bbonemat:NULL); else - Mat4MulVecfl(pchan->chan_mat, cop); + mul_m4_v3(pchan->chan_mat, cop); // Make this a delta from the base position - VecSubf (cop, cop, co); + sub_v3_v3v3(cop, cop, co); cop[0]*=fac; cop[1]*=fac; cop[2]*=fac; - VecAddf (vec, vec, cop); + add_v3_v3v3(vec, vec, cop); if(mat) pchan_deform_mat_add(pchan, fac, bbonemat, mat); @@ -853,10 +853,10 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo else { if(bone->segments>1) { b_bone_deform(pchan, bone, cop, &bbonedq, NULL); - DQuatAddWeighted(dq, &bbonedq, fac); + add_weighted_dq_dq(dq, &bbonedq, fac); } else - DQuatAddWeighted(dq, pchan->dual_quat, fac); + add_weighted_dq_dq(dq, pchan->dual_quat, fac); } } } @@ -879,7 +879,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua // applies on cop and bbonemat b_bone_deform(pchan, pchan->bone, cop, NULL, (mat)?bbonemat:NULL); else - Mat4MulVecfl(pchan->chan_mat, cop); + mul_m4_v3(pchan->chan_mat, cop); vec[0]+=(cop[0]-co[0])*weight; vec[1]+=(cop[1]-co[1])*weight; @@ -891,10 +891,10 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua else { if(pchan->bone->segments>1) { b_bone_deform(pchan, pchan->bone, cop, &bbonedq, NULL); - DQuatAddWeighted(dq, &bbonedq, weight); + add_weighted_dq_dq(dq, &bbonedq, weight); } else - DQuatAddWeighted(dq, pchan->dual_quat, weight); + add_weighted_dq_dq(dq, pchan->dual_quat, weight); } (*contrib)+=weight; @@ -923,10 +923,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, if(arm->edbo) return; - Mat4Invert(obinv, target->obmat); - Mat4CpyMat4(premat, target->obmat); - Mat4MulMat4(postmat, armOb->obmat, obinv); - Mat4Invert(premat, postmat); + invert_m4_m4(obinv, target->obmat); + copy_m4_m4(premat, target->obmat); + mul_m4_m4m4(postmat, armOb->obmat, obinv); + invert_m4_m4(premat, postmat); /* bone defmats are already in the channels, chan_mat */ @@ -944,7 +944,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, if(use_quaternion) { pchan->dual_quat= &dualquats[totchan++]; - Mat4ToDQuat(pchan->bone->arm_mat, pchan->chan_mat, pchan->dual_quat); + mat4_to_dquat( pchan->dual_quat,pchan->bone->arm_mat, pchan->chan_mat); } } } @@ -1013,7 +1013,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, vec= sumvec; if(defMats) { - Mat3Clr((float*)summat); + zero_m3((float*)summat); smat = summat; } } @@ -1050,7 +1050,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, co= prevCos?prevCos[i]:vertexCos[i]; /* Apply the object's matrix */ - Mat4MulVecfl(premat, co); + mul_m4_v3(premat, co); if(use_dverts && dvert && dvert->totweight) { // use weight groups ? int deformed = 0; @@ -1096,42 +1096,42 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, /* actually should be EPSILON? weight values and contrib can be like 10e-39 small */ if(contrib > 0.0001f) { if(use_quaternion) { - DQuatNormalize(dq, contrib); + normalize_dq(dq, contrib); if(armature_weight != 1.0f) { VECCOPY(dco, co); - DQuatMulVecfl(dq, dco, (defMats)? summat: NULL); - VecSubf(dco, dco, co); - VecMulf(dco, armature_weight); - VecAddf(co, co, dco); + mul_v3m3_dq( dco, (defMats)? summat: NULL,dq); + sub_v3_v3v3(dco, dco, co); + mul_v3_fl(dco, armature_weight); + add_v3_v3v3(co, co, dco); } else - DQuatMulVecfl(dq, co, (defMats)? summat: NULL); + mul_v3m3_dq( co, (defMats)? summat: NULL,dq); smat = summat; } else { - VecMulf(vec, armature_weight/contrib); - VecAddf(co, vec, co); + mul_v3_fl(vec, armature_weight/contrib); + add_v3_v3v3(co, vec, co); } if(defMats) { float pre[3][3], post[3][3], tmpmat[3][3]; - Mat3CpyMat4(pre, premat); - Mat3CpyMat4(post, postmat); - Mat3CpyMat3(tmpmat, defMats[i]); + copy_m3_m4(pre, premat); + copy_m3_m4(post, postmat); + copy_m3_m3(tmpmat, defMats[i]); if(!use_quaternion) /* quaternion already is scale corrected */ - Mat3MulFloat((float*)smat, armature_weight/contrib); + mul_m3_fl((float*)smat, armature_weight/contrib); - Mat3MulSerie(defMats[i], tmpmat, pre, smat, post, + mul_serie_m3(defMats[i], tmpmat, pre, smat, post, NULL, NULL, NULL, NULL); } } /* always, check above code */ - Mat4MulVecfl(postmat, co); + mul_m4_v3(postmat, co); /* interpolate with previous modifier position using weight group */ @@ -1165,7 +1165,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed) { - Mat4CpyMat4(M_accumulatedMatrix, bone->arm_mat); + copy_m4_m4(M_accumulatedMatrix, bone->arm_mat); } /* **************** Space to Space API ****************** */ @@ -1179,10 +1179,10 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) if (ob==NULL) return; /* get inverse of (armature) object's matrix */ - Mat4Invert(obmat, ob->obmat); + invert_m4_m4(obmat, ob->obmat); /* multiply given matrix by object's-inverse to find pose-space matrix */ - Mat4MulMat4(outmat, obmat, inmat); + mul_m4_m4m4(outmat, obmat, inmat); } /* Convert Wolrd-Space Location to Pose-Space Location @@ -1195,7 +1195,7 @@ void armature_loc_world_to_pose(Object *ob, float *inloc, float *outloc) float nLocMat[4][4]; /* build matrix for location */ - Mat4One(xLocMat); + unit_m4(xLocMat); VECCOPY(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ @@ -1217,24 +1217,24 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm /* get the inverse matrix of the pchan's transforms */ if (pchan->rotmode) - LocEulSizeToMat4(pc_trans, pchan->loc, pchan->eul, pchan->size); + loc_eul_size_to_mat4(pc_trans, pchan->loc, pchan->eul, pchan->size); else - LocQuatSizeToMat4(pc_trans, pchan->loc, pchan->quat, pchan->size); - Mat4Invert(inv_trans, pc_trans); + loc_quat_size_to_mat4(pc_trans, pchan->loc, pchan->quat, pchan->size); + invert_m4_m4(inv_trans, pc_trans); /* Remove the pchan's transforms from it's pose_mat. * This should leave behind the effects of restpose + * parenting + constraints */ - Mat4MulMat4(pc_posemat, inv_trans, pchan->pose_mat); + mul_m4_m4m4(pc_posemat, inv_trans, pchan->pose_mat); /* get the inverse of the leftovers so that we can remove * that component from the supplied matrix */ - Mat4Invert(inv_posemat, pc_posemat); + invert_m4_m4(inv_posemat, pc_posemat); /* get the new matrix */ - Mat4MulMat4(outmat, inmat, inv_posemat); + mul_m4_m4m4(outmat, inmat, inv_posemat); } /* Convert Pose-Space Location to Bone-Space Location @@ -1247,7 +1247,7 @@ void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc) float nLocMat[4][4]; /* build matrix for location */ - Mat4One(xLocMat); + unit_m4(xLocMat); VECCOPY(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ @@ -1263,8 +1263,8 @@ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float { float imat[4][4]; - Mat4Invert(imat, arm_mat); - Mat4MulMat4(delta_mat, pose_mat, imat); + invert_m4_m4(imat, arm_mat); + mul_m4_m4m4(delta_mat, pose_mat, imat); } /* **************** Rotation Mode Conversions ****************************** */ @@ -1280,33 +1280,33 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa if (newMode > 0) { /* to euler */ if (oldMode == ROT_MODE_AXISANGLE) { /* axis-angle to euler */ - AxisAngleToEulO(axis, *angle, eul, newMode); + axis_angle_to_eulO( eul, newMode,axis, *angle); } else if (oldMode == ROT_MODE_QUAT) { /* quat to euler */ - QuatToEulO(quat, eul, newMode); + quat_to_eulO( eul, newMode,quat); } /* else { no conversion needed } */ } else if (newMode == ROT_MODE_QUAT) { /* to quat */ if (oldMode == ROT_MODE_AXISANGLE) { /* axis angle to quat */ - AxisAngleToQuat(quat, axis, *angle); + axis_angle_to_quat(quat, axis, *angle); } else if (oldMode > 0) { /* euler to quat */ - EulOToQuat(eul, oldMode, quat); + eulO_to_quat( quat,eul, oldMode); } /* else { no conversion needed } */ } else if (newMode == ROT_MODE_AXISANGLE) { /* to axis-angle */ if (oldMode > 0) { /* euler to axis angle */ - EulOToAxisAngle(eul, oldMode, axis, angle); + eulO_to_axis_angle( axis, angle,eul, oldMode); } else if (oldMode == ROT_MODE_QUAT) { /* quat to axis angle */ - QuatToAxisAngle(quat, axis, angle); + quat_to_axis_angle( axis, angle,quat); } /* when converting to axis-angle, we need a special exception for the case when there is no axis */ @@ -1341,14 +1341,14 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa void mat3_to_vec_roll(float mat[][3], float *vec, float *roll) { if (vec) - VecCopyf(vec, mat[1]); + copy_v3_v3(vec, mat[1]); if (roll) { float vecmat[3][3], vecmatinv[3][3], rollmat[3][3]; vec_roll_to_mat3(mat[1], 0.0f, vecmat); - Mat3Inv(vecmatinv, vecmat); - Mat3MulMat3(rollmat, vecmatinv, mat); + invert_m3_m3(vecmatinv, vecmat); + mul_m3_m3m3(rollmat, vecmatinv, mat); *roll= (float)atan2(rollmat[2][0], rollmat[2][2]); } @@ -1363,26 +1363,26 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) float rMatrix[3][3], bMatrix[3][3]; VECCOPY (nor, vec); - Normalize (nor); + normalize_v3(nor); /* Find Axis & Amount for bone matrix*/ - Crossf (axis,target,nor); + cross_v3_v3v3(axis,target,nor); - if (Inpf(axis,axis) > 0.0000000000001) { + if (dot_v3v3(axis,axis) > 0.0000000000001) { /* if nor is *not* a multiple of target ... */ - Normalize (axis); + normalize_v3(axis); - theta= NormalizedVecAngle2(target, nor); + theta= angle_normalized_v3v3(target, nor); /* Make Bone matrix*/ - VecRotToMat3(axis, theta, bMatrix); + vec_rot_to_mat3( bMatrix,axis, theta); } else { /* if nor is a multiple of target ... */ float updown; /* point same direction, or opposite? */ - updown = ( Inpf (target,nor) > 0 ) ? 1.0f : -1.0f; + updown = ( dot_v3v3(target,nor) > 0 ) ? 1.0f : -1.0f; /* I think this should work ... */ bMatrix[0][0]=updown; bMatrix[0][1]=0.0; bMatrix[0][2]=0.0; @@ -1391,10 +1391,10 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) } /* Make Roll matrix*/ - VecRotToMat3(nor, roll, rMatrix); + vec_rot_to_mat3( rMatrix,nor, roll); /* Combine and output result*/ - Mat3MulMat3 (mat, rMatrix, bMatrix); + mul_m3_m3m3(mat, rMatrix, bMatrix); } @@ -1405,10 +1405,10 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) float vec[3]; /* Bone Space */ - VecSubf (vec, bone->tail, bone->head); + sub_v3_v3v3(vec, bone->tail, bone->head); vec_roll_to_mat3(vec, bone->roll, bone->bone_mat); - bone->length= VecLenf(bone->head, bone->tail); + bone->length= len_v3v3(bone->head, bone->tail); /* this is called on old file reading too... */ if(bone->xwidth==0.0) { @@ -1421,7 +1421,7 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) float offs_bone[4][4]; // yoffs(b-1) + root(b) + bonemat(b) /* bone transform itself */ - Mat4CpyMat3(offs_bone, bone->bone_mat); + copy_m4_m3(offs_bone, bone->bone_mat); /* The bone's root offset (is in the parent's coordinate system) */ VECCOPY(offs_bone[3], bone->head); @@ -1430,10 +1430,10 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) offs_bone[3][1]+= prevbone->length; /* Compose the matrix for this bone */ - Mat4MulMat4(bone->arm_mat, offs_bone, prevbone->arm_mat); + mul_m4_m4m4(bone->arm_mat, offs_bone, prevbone->arm_mat); } else { - Mat4CpyMat3(bone->arm_mat, bone->bone_mat); + copy_m4_m3(bone->arm_mat, bone->bone_mat); VECCOPY(bone->arm_mat[3], bone->head); } @@ -1441,8 +1441,8 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) VECCOPY(bone->arm_head, bone->arm_mat[3]); /* tail is in current local coord system */ VECCOPY(vec, bone->arm_mat[1]); - VecMulf(vec, bone->length); - VecAddf(bone->arm_tail, bone->arm_head, vec); + mul_v3_fl(vec, bone->length); + add_v3_v3v3(bone->arm_tail, bone->arm_head, vec); /* and the kiddies */ prevbone= bone; @@ -1824,7 +1824,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o /* step 1a: get xyz positions for the tail endpoint of the bone */ if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad) ) { /* convert the position to pose-space, then store it */ - Mat4MulVecfl(ob->imat, vec); + mul_m4_v3(ob->imat, vec); VECCOPY(poseTail, vec); /* set the new radius */ @@ -1834,7 +1834,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o /* step 1b: get xyz positions for the head endpoint of the bone */ if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad) ) { /* store the position, and convert it to pose space */ - Mat4MulVecfl(ob->imat, vec); + mul_m4_v3(ob->imat, vec); VECCOPY(poseHead, vec); /* set the new radius (it should be the average value) */ @@ -1845,8 +1845,8 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o * - splineVec: the vector direction that the spline applies on the bone * - scaleFac: the factor that the bone length is scaled by to get the desired amount */ - VecSubf(splineVec, poseTail, poseHead); - scaleFac= VecLength(splineVec) / pchan->bone->length; + sub_v3_v3v3(splineVec, poseTail, poseHead); + scaleFac= len_v3(splineVec) / pchan->bone->length; /* step 3: compute the shortest rotation needed to map from the bone rotation to the current axis * - this uses the same method as is used for the Damped Track Constraint (see the code there for details) @@ -1861,45 +1861,45 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o VECCOPY(rmat[0], pchan->pose_mat[0]); VECCOPY(rmat[1], pchan->pose_mat[1]); VECCOPY(rmat[2], pchan->pose_mat[2]); - Mat3Ortho(rmat); + normalize_m3(rmat); /* also, normalise the orientation imposed by the bone, now that we've extracted the scale factor */ - Normalize(splineVec); + normalize_v3(splineVec); /* calculate smallest axis-angle rotation necessary for getting from the * current orientation of the bone, to the spline-imposed direction */ - Crossf(raxis, rmat[1], splineVec); + cross_v3_v3v3(raxis, rmat[1], splineVec); - rangle= Inpf(rmat[1], splineVec); + rangle= dot_v3v3(rmat[1], splineVec); rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) ); /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first */ - AxisAngleToMat3(raxis, rangle, dmat); + axis_angle_to_mat3( dmat,raxis, rangle); /* combine these rotations so that the y-axis of the bone is now aligned as the spline dictates, * while still maintaining roll control from the existing bone animation */ - Mat3MulMat3(tmat, dmat, rmat); // m1, m3, m2 - Mat3Ortho(tmat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */ - Mat4CpyMat3(poseMat, tmat); + mul_m3_m3m3(tmat, dmat, rmat); // m1, m3, m2 + normalize_m3(tmat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */ + copy_m4_m3(poseMat, tmat); } /* step 4: set the scaling factors for the axes */ // TODO: include a no-scale option? { /* only multiply the y-axis by the scaling factor to get nice volume-preservation */ - VecMulf(poseMat[1], scaleFac); + mul_v3_fl(poseMat[1], scaleFac); /* set the scaling factors of the x and z axes from... */ switch (ikData->xzScaleMode) { case CONSTRAINT_SPLINEIK_XZS_RADIUS: { /* radius of curve */ - VecMulf(poseMat[0], radius); - VecMulf(poseMat[2], radius); + mul_v3_fl(poseMat[0], radius); + mul_v3_fl(poseMat[2], radius); } break; case CONSTRAINT_SPLINEIK_XZS_ORIGINAL: @@ -1908,11 +1908,11 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o float scale; /* x-axis scale */ - scale= VecLength(pchan->pose_mat[0]); - VecMulf(poseMat[0], scale); + scale= len_v3(pchan->pose_mat[0]); + mul_v3_fl(poseMat[0], scale); /* z-axis scale */ - scale= VecLength(pchan->pose_mat[2]); - VecMulf(poseMat[2], scale); + scale= len_v3(pchan->pose_mat[2]); + mul_v3_fl(poseMat[2], scale); } break; } @@ -1922,7 +1922,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o VECCOPY(poseMat[3], poseHead); /* finally, store the new transform */ - Mat4CpyMat4(pchan->pose_mat, poseMat); + copy_m4_m4(pchan->pose_mat, poseMat); VECCOPY(pchan->pose_head, poseHead); VECCOPY(pchan->pose_tail, poseTail); @@ -1974,26 +1974,26 @@ void chan_calc_mat(bPoseChannel *chan) float tmat[3][3]; /* get scaling matrix */ - SizeToMat3(chan->size, smat); + size_to_mat3( smat,chan->size); /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */ if (chan->rotmode > 0) { /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */ - EulOToMat3(chan->eul, chan->rotmode, rmat); + eulO_to_mat3( rmat,chan->eul, chan->rotmode); } else if (chan->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - not really that great for 3D-changing orientations */ - AxisAngleToMat3(chan->rotAxis, chan->rotAngle, rmat); + axis_angle_to_mat3( rmat,chan->rotAxis, chan->rotAngle); } else { /* quats are normalised before use to eliminate scaling issues */ - NormalQuat(chan->quat); // TODO: do this with local vars only! - QuatToMat3(chan->quat, rmat); + normalize_qt(chan->quat); // TODO: do this with local vars only! + quat_to_mat3( rmat,chan->quat); } /* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */ - Mat3MulMat3(tmat, rmat, smat); - Mat4CpyMat3(chan->chan_mat, tmat); + mul_m3_m3m3(tmat, rmat, smat); + copy_m4_m3(chan->chan_mat, tmat); /* prevent action channels breaking chains */ /* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */ @@ -2057,8 +2057,8 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha float mat4[4][4], mat3[3][3]; curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis); - Mat4CpyMat4(mat4, pchan->pose_mat); - Mat4MulMat34(pchan->pose_mat, mat3, mat4); + copy_m4_m4(mat4, pchan->pose_mat); + mul_m4_m3m4(pchan->pose_mat, mat3, mat4); } } @@ -2075,8 +2075,8 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha /* make a copy of starting conditions */ VECCOPY(loc, pchan->pose_mat[3]); - Mat4ToEul(pchan->pose_mat, eul); - Mat4ToSize(pchan->pose_mat, size); + mat4_to_eul( eul,pchan->pose_mat); + mat4_to_size( size,pchan->pose_mat); VECCOPY(eulo, eul); VECCOPY(sizeo, size); @@ -2086,14 +2086,14 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha nor[0] = BLI_gNoise(amod->noisesize, size[0]+ofs, size[1], size[2], 0, 0) - ofs; nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1]+ofs, size[2], 0, 0) - ofs; nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2]+ofs, 0, 0) - ofs; - VecAddf(size, size, nor); + add_v3_v3v3(size, size, nor); if (sizeo[0] != 0) - VecMulf(pchan->pose_mat[0], size[0] / sizeo[0]); + mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]); if (sizeo[1] != 0) - VecMulf(pchan->pose_mat[1], size[1] / sizeo[1]); + mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]); if (sizeo[2] != 0) - VecMulf(pchan->pose_mat[2], size[2] / sizeo[2]); + mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]); } if (amod->channels & 2) { /* for rotation */ @@ -2102,10 +2102,10 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2]+ofs, 0, 0) - ofs; compatible_eul(nor, eulo); - VecAddf(eul, eul, nor); + add_v3_v3v3(eul, eul, nor); compatible_eul(eul, eulo); - LocEulSizeToMat4(pchan->pose_mat, loc, eul, size); + loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size); } if (amod->channels & 1) { /* for location */ @@ -2113,7 +2113,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1]+ofs, loc[2], 0, 0) - ofs; nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2]+ofs, 0, 0) - ofs; - VecAddf(pchan->pose_mat[3], loc, nor); + add_v3_v3v3(pchan->pose_mat[3], loc, nor); } } } @@ -2148,7 +2148,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti float offs_bone[4][4]; // yoffs(b-1) + root(b) + bonemat(b) /* bone transform itself */ - Mat4CpyMat3(offs_bone, bone->bone_mat); + copy_m4_m3(offs_bone, bone->bone_mat); /* The bone's root offset (is in the parent's coordinate system) */ VECCOPY(offs_bone[3], bone->head); @@ -2161,39 +2161,39 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti float tmat[4][4]; /* the rotation of the parent restposition */ - Mat4CpyMat4(tmat, parbone->arm_mat); + copy_m4_m4(tmat, parbone->arm_mat); /* the location of actual parent transform */ VECCOPY(tmat[3], offs_bone[3]); offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; - Mat4MulVecfl(parchan->pose_mat, tmat[3]); + mul_m4_v3(parchan->pose_mat, tmat[3]); - Mat4MulSerie(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); } else if(bone->flag & BONE_NO_SCALE) { float orthmat[4][4]; /* get the official transform, but we only use the vector from it (optimize...) */ - Mat4MulSerie(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); VECCOPY(vec, pchan->pose_mat[3]); /* do this again, but with an ortho-parent matrix */ - Mat4CpyMat4(orthmat, parchan->pose_mat); - Mat4Ortho(orthmat); - Mat4MulSerie(pchan->pose_mat, orthmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); + copy_m4_m4(orthmat, parchan->pose_mat); + normalize_m4(orthmat); + mul_serie_m4(pchan->pose_mat, orthmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); /* copy correct transform */ VECCOPY(pchan->pose_mat[3], vec); } else - Mat4MulSerie(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); } else { - Mat4MulMat4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat); + mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat); /* only rootbones get the cyclic offset (unless user doesn't want that) */ if ((bone->flag & BONE_NO_CYCLICOFFSET) == 0) - VecAddf(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset); + add_v3_v3v3(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset); } /* do NLA strip modifiers - i.e. curve follow */ @@ -2229,8 +2229,8 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti VECCOPY(pchan->pose_head, pchan->pose_mat[3]); /* calculate tail */ VECCOPY(vec, pchan->pose_mat[1]); - VecMulf(vec, bone->length); - VecAddf(pchan->pose_tail, pchan->pose_head, vec); + mul_v3_fl(vec, bone->length); + add_v3_v3v3(pchan->pose_tail, pchan->pose_head, vec); } /* This only reads anim data from channels, and writes to channels */ @@ -2258,14 +2258,14 @@ void where_is_pose (Scene *scene, Object *ob) for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { bone= pchan->bone; if(bone) { - Mat4CpyMat4(pchan->pose_mat, bone->arm_mat); + copy_m4_m4(pchan->pose_mat, bone->arm_mat); VECCOPY(pchan->pose_head, bone->arm_head); VECCOPY(pchan->pose_tail, bone->arm_tail); } } } else { - Mat4Invert(ob->imat, ob->obmat); // imat is needed + invert_m4_m4(ob->imat, ob->obmat); // imat is needed /* 1. clear flags */ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { @@ -2303,8 +2303,8 @@ void where_is_pose (Scene *scene, Object *ob) /* calculating deform matrices */ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if(pchan->bone) { - Mat4Invert(imat, pchan->bone->arm_mat); - Mat4MulMat4(pchan->chan_mat, imat, pchan->pose_mat); + invert_m4_m4(imat, pchan->bone->arm_mat); + mul_m4_m4m4(pchan->chan_mat, imat, pchan->pose_mat); } } } diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 712fb13cfc0..389009cca76 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -43,7 +43,7 @@ #include "DNA_listBase.h" #include "BLI_rand.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" @@ -135,10 +135,10 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, /* estimate future location of target */ get_effector_data(eff, &efd, &epoint, 1); - VecMulf(efd.vel, efd.distance / (val->max_speed * bbd->timestep)); - VecAddf(efd.loc, efd.loc, efd.vel); - VecSubf(efd.vec_to_point, pa->prev_state.co, efd.loc); - efd.distance = VecLength(efd.vec_to_point); + mul_v3_fl(efd.vel, efd.distance / (val->max_speed * bbd->timestep)); + add_v3_v3v3(efd.loc, efd.loc, efd.vel); + sub_v3_v3v3(efd.vec_to_point, pa->prev_state.co, efd.loc); + efd.distance = len_v3(efd.vec_to_point); } if(rule->type == eBoidRuleType_Goal && boids->options & BOID_ALLOW_CLIMB && surface!=0.0f) { @@ -152,17 +152,17 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, priority > 2.0f * gabr->fear_factor) { /* detach from surface and try to fly away from danger */ VECCOPY(efd.vec_to_point, bpa->gravity); - VecMulf(efd.vec_to_point, -1.0f); + mul_v3_fl(efd.vec_to_point, -1.0f); } VECCOPY(bbd->wanted_co, efd.vec_to_point); - VecMulf(bbd->wanted_co, mul); + mul_v3_fl(bbd->wanted_co, mul); bbd->wanted_speed = val->max_speed * priority; /* with goals factor is approach velocity factor */ if(rule->type == eBoidRuleType_Goal && boids->landing_smoothness > 0.0f) { - float len2 = 2.0f*VecLength(pa->prev_state.vel); + float len2 = 2.0f*len_v3(pa->prev_state.vel); surface *= pa->size * boids->height; @@ -198,12 +198,12 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * float radius = val->personal_space * pa->size, ray_dir[3]; VECCOPY(col.co1, pa->prev_state.co); - VecAddf(col.co2, pa->prev_state.co, pa->prev_state.vel); - VecSubf(ray_dir, col.co2, col.co1); - VecMulf(ray_dir, acbr->look_ahead); + add_v3_v3v3(col.co2, pa->prev_state.co, pa->prev_state.vel); + sub_v3_v3v3(ray_dir, col.co2, col.co1); + mul_v3_fl(ray_dir, acbr->look_ahead); col.t = 0.0f; hit.index = -1; - hit.dist = col.ray_len = VecLength(ray_dir); + hit.dist = col.ray_len = len_v3(ray_dir); /* find out closest deflector object */ for(coll = bbd->sim->colliders->first; coll; coll=coll->next) { @@ -224,9 +224,9 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * VECCOPY(bbd->wanted_co, col.nor); - VecMulf(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size); + mul_v3_fl(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size); - bbd->wanted_speed = sqrt(t) * VecLength(pa->prev_state.vel); + bbd->wanted_speed = sqrt(t) * len_v3(pa->prev_state.vel); return 1; } @@ -235,39 +235,39 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * //check boids in own system if(acbr->options & BRULE_ACOLL_WITH_BOIDS) { - neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * VecLength(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn); + neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn); if(neighbors > 1) for(n=1; nprev_state.co); VECCOPY(vel1, pa->prev_state.vel); VECCOPY(co2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.co); VECCOPY(vel2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.vel); - VecSubf(loc, co1, co2); + sub_v3_v3v3(loc, co1, co2); - VecSubf(vec, vel1, vel2); + sub_v3_v3v3(vec, vel1, vel2); - inp = Inpf(vec,vec); + inp = dot_v3v3(vec,vec); /* velocities not parallel */ if(inp != 0.0f) { - t = -Inpf(loc, vec)/inp; + t = -dot_v3v3(loc, vec)/inp; /* cpa is not too far in the future so investigate further */ if(t > 0.0f && t < t_min) { VECADDFAC(co1, co1, vel1, t); VECADDFAC(co2, co2, vel2, t); - VecSubf(vec, co2, co1); + sub_v3_v3v3(vec, co2, co1); - len = Normalize(vec); + len = normalize_v3(vec); /* distance of cpa is close enough */ if(len < 2.0f * val->personal_space * pa->size) { t_min = t; - VecMulf(vec, VecLength(vel1)); - VecMulf(vec, (2.0f - t)/2.0f); - VecSubf(bbd->wanted_co, vel1, vec); - bbd->wanted_speed = VecLength(bbd->wanted_co); + mul_v3_fl(vec, len_v3(vel1)); + mul_v3_fl(vec, (2.0f - t)/2.0f); + sub_v3_v3v3(bbd->wanted_co, vel1, vec); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } } @@ -281,39 +281,39 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt); if(epsys) { - neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * VecLength(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn); + neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn); if(neighbors > 0) for(n=0; nprev_state.co); VECCOPY(vel1, pa->prev_state.vel); VECCOPY(co2, (epsys->particles + ptn[n].index)->prev_state.co); VECCOPY(vel2, (epsys->particles + ptn[n].index)->prev_state.vel); - VecSubf(loc, co1, co2); + sub_v3_v3v3(loc, co1, co2); - VecSubf(vec, vel1, vel2); + sub_v3_v3v3(vec, vel1, vel2); - inp = Inpf(vec,vec); + inp = dot_v3v3(vec,vec); /* velocities not parallel */ if(inp != 0.0f) { - t = -Inpf(loc, vec)/inp; + t = -dot_v3v3(loc, vec)/inp; /* cpa is not too far in the future so investigate further */ if(t > 0.0f && t < t_min) { VECADDFAC(co1, co1, vel1, t); VECADDFAC(co2, co2, vel2, t); - VecSubf(vec, co2, co1); + sub_v3_v3v3(vec, co2, co1); - len = Normalize(vec); + len = normalize_v3(vec); /* distance of cpa is close enough */ if(len < 2.0f * val->personal_space * pa->size) { t_min = t; - VecMulf(vec, VecLength(vel1)); - VecMulf(vec, (2.0f - t)/2.0f); - VecSubf(bbd->wanted_co, vel1, vec); - bbd->wanted_speed = VecLength(bbd->wanted_co); + mul_v3_fl(vec, len_v3(vel1)); + mul_v3_fl(vec, (2.0f - t)/2.0f); + sub_v3_v3v3(bbd->wanted_co, vel1, vec); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } } @@ -340,9 +340,9 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa int ret = 0; if(neighbors > 1 && ptn[1].dist!=0.0f) { - VecSubf(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co); - VecMulf(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist); - VecAddf(bbd->wanted_co, bbd->wanted_co, vec); + sub_v3_v3v3(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co); + mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); bbd->wanted_speed = val->max_speed; len = ptn[1].dist; ret = 1; @@ -357,9 +357,9 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa neighbors = BLI_kdtree_range_search(epsys->tree, 2.0f * val->personal_space * pa->size, pa->prev_state.co, NULL, &ptn); if(neighbors > 0 && ptn[0].dist < len) { - VecSubf(vec, pa->prev_state.co, ptn[0].co); - VecMulf(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist); - VecAddf(bbd->wanted_co, bbd->wanted_co, vec); + sub_v3_v3v3(vec, pa->prev_state.co, ptn[0].co); + mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); bbd->wanted_speed = val->max_speed; len = ptn[0].dist; ret = 1; @@ -380,19 +380,19 @@ static int rule_flock(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti if(neighbors > 1) { for(n=1; nsim->psys->particles[ptn[n].index].prev_state.co); - VecAddf(vec, vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel); + add_v3_v3v3(loc, loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co); + add_v3_v3v3(vec, vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel); } - VecMulf(loc, 1.0f/((float)neighbors - 1.0f)); - VecMulf(vec, 1.0f/((float)neighbors - 1.0f)); + mul_v3_fl(loc, 1.0f/((float)neighbors - 1.0f)); + mul_v3_fl(vec, 1.0f/((float)neighbors - 1.0f)); - VecSubf(loc, loc, pa->prev_state.co); - VecSubf(vec, vec, pa->prev_state.vel); + sub_v3_v3v3(loc, loc, pa->prev_state.co); + sub_v3_v3v3(vec, vec, pa->prev_state.vel); - VecAddf(bbd->wanted_co, bbd->wanted_co, vec); - VecAddf(bbd->wanted_co, bbd->wanted_co, loc); - bbd->wanted_speed = VecLength(bbd->wanted_co); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, loc); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } @@ -410,16 +410,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va float vec2[3], t; /* first check we're not blocking the leader*/ - VecSubf(vec, flbr->loc, flbr->oloc); - VecMulf(vec, 1.0f/bbd->timestep); + sub_v3_v3v3(vec, flbr->loc, flbr->oloc); + mul_v3_fl(vec, 1.0f/bbd->timestep); - VecSubf(loc, pa->prev_state.co, flbr->oloc); + sub_v3_v3v3(loc, pa->prev_state.co, flbr->oloc); - mul = Inpf(vec, vec); + mul = dot_v3v3(vec, vec); /* leader is not moving */ if(mul < 0.01) { - len = VecLength(loc); + len = len_v3(loc); /* too close to leader */ if(len < 2.0f * val->personal_space * pa->size) { VECCOPY(bbd->wanted_co, loc); @@ -428,16 +428,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va } } else { - t = Inpf(loc, vec)/mul; + t = dot_v3v3(loc, vec)/mul; /* possible blocking of leader in near future */ if(t > 0.0f && t < 3.0f) { VECCOPY(vec2, vec); - VecMulf(vec2, t); + mul_v3_fl(vec2, t); - VecSubf(vec2, loc, vec2); + sub_v3_v3v3(vec2, loc, vec2); - len = VecLength(vec2); + len = len_v3(vec2); if(len < 2.0f * val->personal_space * pa->size) { VECCOPY(bbd->wanted_co, vec2); @@ -454,15 +454,15 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va } else { VECCOPY(loc, flbr->oloc); - VecSubf(vec, flbr->loc, flbr->oloc); - VecMulf(vec, 1.0/bbd->timestep); + sub_v3_v3v3(vec, flbr->loc, flbr->oloc); + mul_v3_fl(vec, 1.0/bbd->timestep); } /* fac is seconds behind leader */ VECADDFAC(loc, loc, vec, -flbr->distance); - VecSubf(bbd->wanted_co, loc, pa->prev_state.co); - bbd->wanted_speed = VecLength(bbd->wanted_co); + sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } @@ -473,13 +473,13 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va for(i = 0; i< bbd->sim->psys->totpart; i+=n){ VECCOPY(vec, bbd->sim->psys->particles[i].prev_state.vel); - VecSubf(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co); + sub_v3_v3v3(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co); - mul = Inpf(vec, vec); + mul = dot_v3v3(vec, vec); /* leader is not moving */ if(mul < 0.01) { - len = VecLength(loc); + len = len_v3(loc); /* too close to leader */ if(len < 2.0f * val->personal_space * pa->size) { VECCOPY(bbd->wanted_co, loc); @@ -488,16 +488,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va } } else { - t = Inpf(loc, vec)/mul; + t = dot_v3v3(loc, vec)/mul; /* possible blocking of leader in near future */ if(t > 0.0f && t < t_min) { VECCOPY(vec2, vec); - VecMulf(vec2, t); + mul_v3_fl(vec2, t); - VecSubf(vec2, loc, vec2); + sub_v3_v3v3(vec2, loc, vec2); - len = VecLength(vec2); + len = len_v3(vec2); if(len < 2.0f * val->personal_space * pa->size) { t_min = t; @@ -524,8 +524,8 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va /* fac is seconds behind leader */ VECADDFAC(loc, loc, vec, -flbr->distance); - VecSubf(bbd->wanted_co, loc, pa->prev_state.co); - bbd->wanted_speed = VecLength(bbd->wanted_co); + sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co); + bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; } @@ -544,30 +544,30 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va bpa->wander[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); bpa->wander[2] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); - Normalize(bpa->wander); + normalize_v3(bpa->wander); VECCOPY(vec, bpa->wander); - QuatMulVecf(pa->prev_state.rot, vec); + mul_qt_v3(pa->prev_state.rot, vec); VECCOPY(bbd->wanted_co, pa->prev_state.ave); - VecMulf(bbd->wanted_co, 1.1f); + mul_v3_fl(bbd->wanted_co, 1.1f); - VecAddf(bbd->wanted_co, bbd->wanted_co, vec); + add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); /* leveling */ if(asbr->level > 0.0f) { - Projf(vec, bbd->wanted_co, bbd->sim->psys->part->acc); - VecMulf(vec, asbr->level); - VecSubf(bbd->wanted_co, bbd->wanted_co, vec); + project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->psys->part->acc); + mul_v3_fl(vec, asbr->level); + sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); } } else { VECCOPY(bbd->wanted_co, pa->prev_state.ave); /* may happen at birth */ - if(Inp2f(bbd->wanted_co,bbd->wanted_co)==0.0f) { + if(dot_v2v2(bbd->wanted_co,bbd->wanted_co)==0.0f) { bbd->wanted_co[0] = 2.0f*(0.5f - BLI_frand()); bbd->wanted_co[1] = 2.0f*(0.5f - BLI_frand()); bbd->wanted_co[2] = 2.0f*(0.5f - BLI_frand()); @@ -575,9 +575,9 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va /* leveling */ if(asbr->level > 0.0f) { - Projf(vec, bbd->wanted_co, bbd->sim->psys->part->acc); - VecMulf(vec, asbr->level); - VecSubf(bbd->wanted_co, bbd->wanted_co, vec); + project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->psys->part->acc); + mul_v3_fl(vec, asbr->level); + sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); } } @@ -641,20 +641,20 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti } /* decide action if enemy presence found */ if(e_strength > 0.0f) { - VecSubf(bbd->wanted_co, closest_enemy, pa->prev_state.co); + sub_v3_v3v3(bbd->wanted_co, closest_enemy, pa->prev_state.co); /* attack if in range */ if(closest_dist <= bbd->part->boids->range + pa->size + enemy_pa->size) { float damage = BLI_frand(); float enemy_dir[3] = {bbd->wanted_co[0],bbd->wanted_co[1],bbd->wanted_co[2]}; - Normalize(enemy_dir); + normalize_v3(enemy_dir); /* fight mode */ bbd->wanted_speed = 0.0f; /* must face enemy to fight */ - if(Inpf(pa->prev_state.ave, enemy_dir)>0.5f) { + if(dot_v3v3(pa->prev_state.ave, enemy_dir)>0.5f) { bpa = enemy_pa->boid; bpa->data.health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy); } @@ -669,7 +669,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti if(bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) { /* decide to flee */ if(closest_dist < fbr->flee_distance * fbr->distance) { - VecMulf(bbd->wanted_co, -1.0f); + mul_v3_fl(bbd->wanted_co, -1.0f); bbd->wanted_speed = val->max_speed; } else { /* wait for better odds */ @@ -735,7 +735,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro /* take surface velocity into account */ closest_point_on_surface(surmd, pa->state.co, x, NULL, v); - VecAddf(x, x, v); + add_v3_v3v3(x, x, v); /* get actual position on surface */ closest_point_on_surface(surmd, x, ground_co, ground_nor, NULL); @@ -754,12 +754,12 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro VECCOPY(col.co1, pa->state.co); VECCOPY(col.co2, pa->state.co); - VecAddf(col.co1, col.co1, zvec); - VecSubf(col.co2, col.co2, zvec); - VecSubf(ray_dir, col.co2, col.co1); + add_v3_v3v3(col.co1, col.co1, zvec); + sub_v3_v3v3(col.co2, col.co2, zvec); + sub_v3_v3v3(ray_dir, col.co2, col.co1); col.t = 0.0f; hit.index = -1; - hit.dist = col.ray_len = VecLength(ray_dir); + hit.dist = col.ray_len = len_v3(ray_dir); /* find out upmost deflector object */ for(coll = bbd->sim->colliders->first; coll; coll = coll->next){ @@ -772,9 +772,9 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro /* then use that object */ if(hit.index>=0) { t = hit.dist/col.ray_len; - VecLerpf(ground_co, col.co1, col.co2, t); + interp_v3_v3v3(ground_co, col.co1, col.co2, t); VECCOPY(ground_nor, col.nor); - Normalize(ground_nor); + normalize_v3(ground_nor); return col.hit_ob; } else { @@ -829,23 +829,23 @@ static void boid_climb(BoidSettings *boids, ParticleData *pa, float *surface_co, /* gather apparent gravity */ VECADDFAC(bpa->gravity, bpa->gravity, surface_nor, -1.0); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); /* raise boid it's size from surface */ - VecMulf(nor, pa->size * boids->height); - VecAddf(pa->state.co, surface_co, nor); + mul_v3_fl(nor, pa->size * boids->height); + add_v3_v3v3(pa->state.co, surface_co, nor); /* remove normal component from velocity */ - Projf(vel, pa->state.vel, surface_nor); - VecSubf(pa->state.vel, pa->state.vel, vel); + project_v3_v3v3(vel, pa->state.vel, surface_nor); + sub_v3_v3v3(pa->state.vel, pa->state.vel, vel); } static float boid_goal_signed_dist(float *boid_co, float *goal_co, float *goal_nor) { float vec[3]; - VecSubf(vec, boid_co, goal_co); + sub_v3_v3v3(vec, boid_co, goal_co); - return Inpf(vec, goal_nor); + return dot_v3v3(vec, goal_nor); } /* wanted_co is relative to boid location */ static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness) @@ -859,7 +859,7 @@ static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, if(boid_rules[rule->type](rule, bbd, val, pa)==0) return 0; - if(fuzziness < 0.0f || VecLenCompare(bbd->wanted_co, pa->prev_state.vel, fuzziness * VecLength(pa->prev_state.vel))==0) + if(fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co, pa->prev_state.vel, fuzziness * len_v3(pa->prev_state.vel))==0) return 1; else return 0; @@ -943,7 +943,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) int n = 0; for(rule = state->rules.first; rule; rule=rule->next) { if(apply_boid_rule(bbd, rule, &val, pa, -1.0f)) { - VecAddf(wanted_co, wanted_co, bbd->wanted_co); + add_v3_v3v3(wanted_co, wanted_co, bbd->wanted_co); wanted_speed += bbd->wanted_speed; n++; bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f; @@ -951,7 +951,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) } if(n > 1) { - VecMulf(wanted_co, 1.0f/(float)n); + mul_v3_fl(wanted_co, 1.0f/(float)n); wanted_speed /= (float)n; } @@ -971,12 +971,12 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) float cvel[3], dir[3]; VECCOPY(dir, pa->prev_state.ave); - Normalize2(dir); + normalize_v2(dir); VECCOPY(cvel, bbd->wanted_co); - Normalize2(cvel); + normalize_v2(cvel); - if(Inp2f(cvel, dir) > 0.95 / mul) + if(dot_v2v2(cvel, dir) > 0.95 / mul) bpa->data.mode = eBoidMode_Liftoff; } else if(val.jump_speed > 0.0f) { @@ -990,20 +990,20 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) float len; VECCOPY(dir, pa->prev_state.ave); - Normalize2(dir); + normalize_v2(dir); VECCOPY(cvel, bbd->wanted_co); - Normalize2(cvel); + normalize_v2(cvel); - len = Vec2Length(pa->prev_state.vel); + len = len_v2(pa->prev_state.vel); /* first of all, are we going in a suitable direction? */ /* or at a suitably slow speed */ - if(Inp2f(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) { + if(dot_v2v2(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) { /* try to reach goal at highest point of the parabolic path */ - cur_v = Vec2Length(pa->prev_state.vel); + cur_v = len_v2(pa->prev_state.vel); z_v = sasqrt(-2.0f * bbd->part->acc[2] * bbd->wanted_co[2]); - ground_v = Vec2Length(bbd->wanted_co)*sasqrt(-0.5f * bbd->part->acc[2] / bbd->wanted_co[2]); + ground_v = len_v2(bbd->wanted_co)*sasqrt(-0.5f * bbd->part->acc[2] / bbd->wanted_co[2]); len = sasqrt((ground_v-cur_v)*(ground_v-cur_v) + z_v*z_v); @@ -1014,11 +1014,11 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) VECCOPY(jump_v, dir); jump_v[2] = z_v; - VecMulf(jump_v, ground_v); + mul_v3_fl(jump_v, ground_v); - Normalize(jump_v); - VecMulf(jump_v, len); - Vec2Addf(jump_v, jump_v, pa->prev_state.vel); + normalize_v3(jump_v); + mul_v3_fl(jump_v, len); + add_v2_v2v2(jump_v, jump_v, pa->prev_state.vel); } } } @@ -1103,7 +1103,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) VECCOPY(old_dir, pa->prev_state.ave); VECCOPY(wanted_dir, bbd->wanted_co); - new_speed = Normalize(wanted_dir); + new_speed = normalize_v3(wanted_dir); /* first check if we have valid direction we want to go towards */ if(new_speed == 0.0f) { @@ -1111,39 +1111,39 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) } else { float old_dir2[2], wanted_dir2[2], nor[3], angle; - Vec2Copyf(old_dir2, old_dir); - Normalize2(old_dir2); - Vec2Copyf(wanted_dir2, wanted_dir); - Normalize2(wanted_dir2); + copy_v2_v2(old_dir2, old_dir); + normalize_v2(old_dir2); + copy_v2_v2(wanted_dir2, wanted_dir); + normalize_v2(wanted_dir2); /* choose random direction to turn if wanted velocity */ /* is directly behind regardless of z-coordinate */ - if(Inp2f(old_dir2, wanted_dir2) < -0.99f) { + if(dot_v2v2(old_dir2, wanted_dir2) < -0.99f) { wanted_dir[0] = 2.0f*(0.5f - BLI_frand()); wanted_dir[1] = 2.0f*(0.5f - BLI_frand()); wanted_dir[2] = 2.0f*(0.5f - BLI_frand()); - Normalize(wanted_dir); + normalize_v3(wanted_dir); } /* constrain direction with maximum angular velocity */ - angle = saacos(Inpf(old_dir, wanted_dir)); + angle = saacos(dot_v3v3(old_dir, wanted_dir)); angle = MIN2(angle, val.max_ave); - Crossf(nor, old_dir, wanted_dir); - VecRotToQuat(nor, angle, q); + cross_v3_v3v3(nor, old_dir, wanted_dir); + axis_angle_to_quat( q,nor, angle); VECCOPY(new_dir, old_dir); - QuatMulVecf(q, new_dir); - Normalize(new_dir); + mul_qt_v3(q, new_dir); + normalize_v3(new_dir); /* save direction in case resulting velocity too small */ - VecRotToQuat(nor, angle*dtime, q); + axis_angle_to_quat( q,nor, angle*dtime); VECCOPY(pa->state.ave, old_dir); - QuatMulVecf(q, pa->state.ave); - Normalize(pa->state.ave); + mul_qt_v3(q, pa->state.ave); + normalize_v3(pa->state.ave); } /* constrain speed with maximum acceleration */ - old_speed = VecLength(pa->prev_state.vel); + old_speed = len_v3(pa->prev_state.vel); if(bbd->wanted_speed < old_speed) new_speed = MAX2(bbd->wanted_speed, old_speed - val.max_acc); @@ -1152,11 +1152,11 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* combine direction and speed */ VECCOPY(new_vel, new_dir); - VecMulf(new_vel, new_speed); + mul_v3_fl(new_vel, new_speed); /* maintain minimum flying velocity if not landing */ if(level >= landing_level) { - float len2 = Inp2f(new_vel,new_vel); + float len2 = dot_v2v2(new_vel,new_vel); float root; len2 = MAX2(len2, val.min_speed*val.min_speed); @@ -1164,20 +1164,20 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) new_vel[2] = new_vel[2] < 0.0f ? -root : root; - Normalize2(new_vel); - Vec2Mulf(new_vel, sasqrt(len2)); + normalize_v2(new_vel); + mul_v2_fl(new_vel, sasqrt(len2)); } /* finally constrain speed to max speed */ - new_speed = Normalize(new_vel); - VecMulf(new_vel, MIN2(new_speed, val.max_speed)); + new_speed = normalize_v3(new_vel); + mul_v3_fl(new_vel, MIN2(new_speed, val.max_speed)); /* get acceleration from difference of velocities */ - VecSubf(acc, new_vel, pa->prev_state.vel); + sub_v3_v3v3(acc, new_vel, pa->prev_state.vel); /* break acceleration to components */ - Projf(tan_acc, acc, pa->prev_state.ave); - VecSubf(nor_acc, acc, tan_acc); + project_v3_v3v3(tan_acc, acc, pa->prev_state.ave); + sub_v3_v3v3(nor_acc, acc, tan_acc); } /* account for effectors */ @@ -1185,32 +1185,32 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) pdDoEffectors(bbd->sim->psys->effectors, bbd->sim->colliders, bbd->part->effector_weights, &epoint, force, NULL); if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) { - float length = Normalize(force); + float length = normalize_v3(force); length = MAX2(0.0f, length - boids->land_stick_force); - VecMulf(force, length); + mul_v3_fl(force, length); } - VecAddf(acc, acc, force); + add_v3_v3v3(acc, acc, force); /* store smoothed acceleration for nice banking etc. */ VECADDFAC(bpa->data.acc, bpa->data.acc, acc, dtime); - VecMulf(bpa->data.acc, 1.0f / (1.0f + dtime)); + mul_v3_fl(bpa->data.acc, 1.0f / (1.0f + dtime)); /* integrate new location & velocity */ /* by regarding the acceleration as a force at this stage we*/ /* can get better control allthough it's a bit unphysical */ - VecMulf(acc, 1.0f/pa_mass); + mul_v3_fl(acc, 1.0f/pa_mass); VECCOPY(dvec, acc); - VecMulf(dvec, dtime*dtime*0.5f); + mul_v3_fl(dvec, dtime*dtime*0.5f); VECCOPY(bvec, pa->prev_state.vel); - VecMulf(bvec, dtime); - VecAddf(dvec, dvec, bvec); - VecAddf(pa->state.co, pa->state.co, dvec); + mul_v3_fl(bvec, dtime); + add_v3_v3v3(dvec, dvec, bvec); + add_v3_v3v3(pa->state.co, pa->state.co, dvec); VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime); @@ -1224,9 +1224,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) float grav[3] = {0.0f, 0.0f, bbd->part->acc[2] < 0.0f ? -1.0f : 0.0f}; /* don't take forward acceleration into account (better banking) */ - if(Inpf(bpa->data.acc, pa->state.vel) > 0.0f) { - Projf(dvec, bpa->data.acc, pa->state.vel); - VecSubf(dvec, bpa->data.acc, dvec); + if(dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) { + project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel); + sub_v3_v3v3(dvec, bpa->data.acc, dvec); } else { VECCOPY(dvec, bpa->data.acc); @@ -1234,7 +1234,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* gather apparent gravity */ VECADDFAC(bpa->gravity, grav, dvec, -boids->banking); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); /* stick boid on goal when close enough */ if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) { @@ -1257,7 +1257,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* gather apparent gravity */ VECADDFAC(bpa->gravity, bpa->gravity, grav, dtime); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); if(boids->options & BOID_ALLOW_LAND) { /* stick boid on goal when close enough */ @@ -1289,15 +1289,15 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) ///* gather apparent gravity to r_ve */ //VECADDFAC(pa->r_ve, pa->r_ve, ground_nor, -1.0); - //Normalize(pa->r_ve); + //normalize_v3(pa->r_ve); ///* raise boid it's size from surface */ - //VecMulf(nor, pa->size * boids->height); - //VecAddf(pa->state.co, ground_co, nor); + //mul_v3_fl(nor, pa->size * boids->height); + //add_v3_v3v3(pa->state.co, ground_co, nor); ///* remove normal component from velocity */ - //Projf(v, pa->state.vel, ground_nor); - //VecSubf(pa->state.vel, pa->state.vel, v); + //project_v3_v3v3(v, pa->state.vel, ground_nor); + //sub_v3_v3v3(pa->state.vel, pa->state.vel, v); break; } case eBoidMode_OnLand: @@ -1323,19 +1323,19 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* Don't take gravity's strength in to account, */ /* otherwise amount of banking is hard to control. */ VECCOPY(grav, ground_nor); - VecMulf(grav, -1.0f); + mul_v3_fl(grav, -1.0f); - Projf(dvec, bpa->data.acc, pa->state.vel); - VecSubf(dvec, bpa->data.acc, dvec); + project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel); + sub_v3_v3v3(dvec, bpa->data.acc, dvec); /* gather apparent gravity */ VECADDFAC(bpa->gravity, grav, dvec, -boids->banking); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); } else { /* gather negative surface normal */ VECADDFAC(bpa->gravity, bpa->gravity, ground_nor, -1.0f); - Normalize(bpa->gravity); + normalize_v3(bpa->gravity); } break; } @@ -1343,36 +1343,36 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* save direction to state.ave unless the boid is falling */ /* (boids can't effect their direction when falling) */ - if(bpa->data.mode!=eBoidMode_Falling && VecLength(pa->state.vel) > 0.1*pa->size) { + if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1*pa->size) { VECCOPY(pa->state.ave, pa->state.vel); - Normalize(pa->state.ave); + normalize_v3(pa->state.ave); } /* apply damping */ if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) - VecMulf(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac); + mul_v3_fl(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac); /* calculate rotation matrix based on forward & down vectors */ if(bpa->data.mode == eBoidMode_InAir) { VECCOPY(mat[0], pa->state.ave); - Projf(dvec, bpa->gravity, pa->state.ave); - VecSubf(mat[2], bpa->gravity, dvec); - Normalize(mat[2]); + project_v3_v3v3(dvec, bpa->gravity, pa->state.ave); + sub_v3_v3v3(mat[2], bpa->gravity, dvec); + normalize_v3(mat[2]); } else { - Projf(dvec, pa->state.ave, bpa->gravity); - VecSubf(mat[0], pa->state.ave, dvec); - Normalize(mat[0]); + project_v3_v3v3(dvec, pa->state.ave, bpa->gravity); + sub_v3_v3v3(mat[0], pa->state.ave, dvec); + normalize_v3(mat[0]); VECCOPY(mat[2], bpa->gravity); } - VecMulf(mat[2], -1.0f); - Crossf(mat[1], mat[2], mat[0]); + mul_v3_fl(mat[2], -1.0f); + cross_v3_v3v3(mat[1], mat[2], mat[0]); /* apply rotation */ - Mat3ToQuat_is_ok(mat, q); - QuatCopy(pa->state.rot, q); + mat3_to_quat_is_ok( q,mat); + copy_qt_qt(pa->state.rot, q); } BoidRule *boid_new_rule(int type) diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c index 1f6457199fb..68e1f61a800 100644 --- a/source/blender/blenkernel/intern/booleanops.c +++ b/source/blender/blenkernel/intern/booleanops.c @@ -33,7 +33,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" @@ -104,7 +104,7 @@ static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) float global_pos[3]; /* boolean happens in global space, transform both with obmat */ - VecMat4MulVecfl( + mul_v3_m4v3( global_pos, iterator->ob->obmat, verts[iterator->pos].co @@ -327,11 +327,11 @@ static void InterpCSGFace( for (j = 0; j < nr; j++) { // get coordinate into the space of the original mesh if (mapmat) - VecMat4MulVecfl(obco, mapmat, co[j]); + mul_v3_m4v3(obco, mapmat, co[j]); else - VecCopyf(obco, co[j]); + copy_v3_v3(obco, co[j]); - InterpWeightsQ3Dfl(orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco, w[j]); + interp_weights_face_v3( w[j],orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco); } CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float*)w, 1, index); @@ -375,7 +375,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( // we have to map the vertex coordinates back in the coordinate frame // of the resulting object, since it was computed in world space - VecMat4MulVecfl(mvert->co, parinv, csgvert.position); + mul_v3_m4v3(mvert->co, parinv, csgvert.position); } // a hash table to remap materials to indices @@ -478,9 +478,9 @@ DerivedMesh *NewBooleanDerivedMesh_intern( // we map the final object back into ob's local coordinate space. For this // we need to compute the inverse transform from global to ob (inv_mat), // and the transform from ob to ob_select for use in interpolation (map_mat) - Mat4Invert(inv_mat, ob->obmat); - Mat4MulMat4(map_mat, ob_select->obmat, inv_mat); - Mat4Invert(inv_mat, ob_select->obmat); + invert_m4_m4(inv_mat, ob->obmat); + mul_m4_m4m4(map_mat, ob_select->obmat, inv_mat); + invert_m4_m4(inv_mat, ob_select->obmat); { // interface with the boolean module: diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 14e32873dbd..15a3d042622 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -47,7 +47,7 @@ #include "BKE_library.h" #include "BKE_material.h" -#include "BLI_arithb.h" +#include "BLI_math.h" /** * Implementation of boolean ops mesh interface. @@ -151,7 +151,7 @@ CSG_AddMeshToBlender( if (mesh == NULL) return 0; if (mesh->base == NULL) return 0; - Mat4Invert(inv_mat,mesh->base->object->obmat); + invert_m4_m4(inv_mat,mesh->base->object->obmat); // Create a new blender mesh object - using 'base' as // a template for the new object. diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 115d31b587c..ccee5a266f2 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -42,7 +42,7 @@ #include "RNA_access.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" @@ -845,8 +845,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl /* setup starting time, direction vector and accumulated time */ starttime= painter->accumtime; - Vec2Subf(dmousepos, pos, painter->lastmousepos); - len= Normalize2(dmousepos); + sub_v2_v2v2(dmousepos, pos, painter->lastmousepos); + len= normalize_v2(dmousepos); painter->accumtime += curtime - painter->lasttime; /* do paint op over unpainted time distance */ @@ -880,8 +880,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl /* setup starting distance, direction vector and accumulated distance */ startdistance= painter->accumdistance; - Vec2Subf(dmousepos, pos, painter->lastmousepos); - len= Normalize2(dmousepos); + sub_v2_v2v2(dmousepos, pos, painter->lastmousepos); + len= normalize_v2(dmousepos); painter->accumdistance += len; /* do paint op over unpainted distance */ diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index f2526231d50..5ee8210d256 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -45,7 +45,7 @@ #include "BKE_displist.h" #include "BKE_global.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_linklist.h" #include "MEM_guardedalloc.h" @@ -55,7 +55,7 @@ static float ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, con { float dist; - if(RayIntersectsTriangle((float*)ray->origin, (float*)ray->direction, (float*)v0, (float*)v1, (float*)v2, &dist, NULL)) + if(isect_ray_tri_v3((float*)ray->origin, (float*)ray->direction, (float*)v0, (float*)v1, (float*)v2, &dist, NULL)) return dist; return FLT_MAX; @@ -68,10 +68,10 @@ static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, con float p1[3]; float plane_normal[3], hit_point[3]; - CalcNormFloat((float*)v0, (float*)v1, (float*)v2, plane_normal); + normal_tri_v3( plane_normal,(float*)v0, (float*)v1, (float*)v2); VECADDFAC( p1, ray->origin, ray->direction, m_dist); - if(SweepingSphereIntersectsTriangleUV((float*)ray->origin, p1, radius, (float*)v0, (float*)v1, (float*)v2, &idist, hit_point)) + if(isect_sweeping_sphere_tri_v3((float*)ray->origin, p1, radius, (float*)v0, (float*)v1, (float*)v2, &idist, hit_point)) { return idist * m_dist; } @@ -384,9 +384,9 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const float w[3], x[3], y[3], z[3]; VECCOPY(w, v0); VECCOPY(x, e0); - VecMulf(x, S); + mul_v3_fl(x, S); VECCOPY(y, e1); - VecMulf(y, T); + mul_v3_fl(y, T); VECADD(z, w, x); VECADD(z, z, y); //VECSUB(d, p, z); @@ -430,7 +430,7 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float *co, nearest->index = index; nearest->dist = dist; VECCOPY(nearest->co, nearest_tmp); - CalcNormFloat(t0, t1, t2, nearest->no); + normal_tri_v3( nearest->no,t0, t1, t2); } t1 = t2; @@ -469,7 +469,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r hit->dist = dist; VECADDFAC(hit->co, ray->origin, ray->direction, dist); - CalcNormFloat(t0, t1, t2, hit->no); + normal_tri_v3( hit->no,t0, t1, t2); } t1 = t2; @@ -492,16 +492,16 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co, t0 = vert[ edge->v1 ].co; t1 = vert[ edge->v2 ].co; - PclosestVL3Dfl(nearest_tmp, co, t0, t1); - dist = VecLenf(nearest_tmp, co); + closest_to_line_segment_v3(nearest_tmp, co, t0, t1); + dist = len_v3v3(nearest_tmp, co); if(dist < nearest->dist) { nearest->index = index; nearest->dist = dist; VECCOPY(nearest->co, nearest_tmp); - VecSubf(nearest->no, t0, t1); - Normalize(nearest->no); + sub_v3_v3v3(nearest->no, t0, t1); + normalize_v3(nearest->no); } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 25f60a452cc..30d1b65cc8b 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -45,7 +45,7 @@ #include "BKE_multires.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" @@ -405,9 +405,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int, void *a /* TODO make this better (cache facenormals as layer?) */ float nor[3]; if(mface->v4) { - CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co, nor); + normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co); } else { - CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, nor); + normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co); } glNormal3fv(nor); } @@ -576,9 +576,9 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, else { float nor[3]; if(mf->v4) { - CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co, nor); + normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); } else { - CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, nor); + normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); } glNormal3fv(nor); } @@ -748,9 +748,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us else { float nor[3]; if(mf->v4) { - CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co, nor); + normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); } else { - CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, nor); + normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); } glNormal3fv(nor); } @@ -920,9 +920,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo /* TODO ideally a normal layer should always be available */ float nor[3]; if(mface->v4) { - CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co, nor); + normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co); } else { - CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, nor); + normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co); } glNormal3fv(nor); } @@ -1259,16 +1259,16 @@ static void cdDM_foreachMappedFaceCenter( orig = i; VECCOPY(cent, mv[mf->v1].co); - VecAddf(cent, cent, mv[mf->v2].co); - VecAddf(cent, cent, mv[mf->v3].co); + add_v3_v3v3(cent, cent, mv[mf->v2].co); + add_v3_v3v3(cent, cent, mv[mf->v3].co); if (mf->v4) { - CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co, no); - VecAddf(cent, cent, mv[mf->v4].co); - VecMulf(cent, 0.25f); + normal_quad_v3( no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); + add_v3_v3v3(cent, cent, mv[mf->v4].co); + mul_v3_fl(cent, 0.25f); } else { - CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, no); - VecMulf(cent, 0.33333333333f); + normal_tri_v3( no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); + mul_v3_fl(cent, 0.33333333333f); } func(userData, orig, cent, no); @@ -1616,24 +1616,24 @@ void CDDM_calc_normals(DerivedMesh *dm) float *f_no = face_nors[i]; if(mf->v4) - CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co, f_no); + normal_quad_v3( f_no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); else - CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, f_no); + normal_tri_v3( f_no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); - VecAddf(temp_nors[mf->v1], temp_nors[mf->v1], f_no); - VecAddf(temp_nors[mf->v2], temp_nors[mf->v2], f_no); - VecAddf(temp_nors[mf->v3], temp_nors[mf->v3], f_no); + add_v3_v3v3(temp_nors[mf->v1], temp_nors[mf->v1], f_no); + add_v3_v3v3(temp_nors[mf->v2], temp_nors[mf->v2], f_no); + add_v3_v3v3(temp_nors[mf->v3], temp_nors[mf->v3], f_no); if(mf->v4) - VecAddf(temp_nors[mf->v4], temp_nors[mf->v4], f_no); + add_v3_v3v3(temp_nors[mf->v4], temp_nors[mf->v4], f_no); } /* normalize vertex normals and assign */ for(i = 0; i < numVerts; i++, mv++) { float *no = temp_nors[i]; - if (Normalize(no) == 0.0) { + if (normalize_v3(no) == 0.0) { VECCOPY(no, mv->co); - Normalize(no); + normalize_v3(no); } mv->no[0] = (short)(no[0] * 32767.0); @@ -1844,7 +1844,7 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts mvert = CustomData_get_layer(&orig->vertData, CD_MVERT); mrdm->orco = MEM_callocN(sizeof(float) * 3 * orig->getNumVerts(orig), "multires orco"); for(i = 0; i < orig->getNumVerts(orig); ++i) - VecCopyf(mrdm->orco[i], mvert[i].co); + copy_v3_v3(mrdm->orco[i], mvert[i].co); } else DM_init(dm, numVerts, numEdges, numFaces); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 74f88a77e63..4a9cb237c01 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -403,7 +403,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul /* Get the current position. */ VECCOPY(verts->xconst, mvert[i].co); - Mat4MulVecfl(ob->obmat, verts->xconst); + mul_m4_v3(ob->obmat, verts->xconst); } effectors = pdInitEffectors(clmd->scene, ob, NULL, clmd->sim_parms->effector_weights); @@ -723,7 +723,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh * if (clmd->clothObject) { /* inverse matrix is not uptodate... */ - Mat4Invert (ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); mvert = CDDM_get_verts(dm); numverts = dm->getNumVerts(dm); @@ -731,7 +731,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh * for (i = 0; i < numverts; i++) { VECCOPY (mvert[i].co, cloth->verts[i].x); - Mat4MulVecfl (ob->imat, mvert[i].co); /* cloth is in global coords */ + mul_m4_v3(ob->imat, mvert[i].co); /* cloth is in global coords */ } } } @@ -867,7 +867,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d if(first) { VECCOPY ( verts->x, mvert[i].co ); - Mat4MulVecfl ( ob->obmat, verts->x ); + mul_m4_v3( ob->obmat, verts->x ); } /* no GUI interface yet */ @@ -884,7 +884,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d VECCOPY ( verts->xconst, verts->x ); VECCOPY ( verts->txold, verts->x ); VECCOPY ( verts->tx, verts->x ); - VecMulf ( verts->v, 0.0f ); + mul_v3_fl( verts->v, 0.0f ); verts->impulse_count = 0; VECCOPY ( verts->impulse, tnull ); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 8c664bc1a57..3d995d7b6e8 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -529,7 +529,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier // calculate tangential velocity VECCOPY ( temp, collpair->normal ); - VecMulf ( temp, magrelVel ); + mul_v3_fl( temp, magrelVel ); VECSUB ( vrel_t_pre, relativeVelocity, temp ); // Decrease in magnitude of relative tangential velocity due to coulomb friction @@ -539,7 +539,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier // Apply friction impulse. if ( magtangent > ALMOST_ZERO ) { - Normalize ( vrel_t_pre ); + normalize_v3( vrel_t_pre ); impulse = magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); // 2.0 * VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse ); @@ -681,7 +681,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) { VECCOPY ( collpair->normal, collpair->vector ); - Normalize ( collpair->normal ); + normalize_v3( collpair->normal ); collpair->distance = distance; collpair->flag = 0; @@ -778,7 +778,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo // calculate tangential velocity VECCOPY ( temp, collpair->normal ); - VecMulf ( temp, magrelVel ); + mul_v3_fl( temp, magrelVel ); VECSUB ( vrel_t_pre, relativeVelocity, temp ); // Decrease in magnitude of relative tangential velocity due to coulomb friction @@ -788,7 +788,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo // Apply friction impulse. if ( magtangent > ALMOST_ZERO ) { - Normalize ( vrel_t_pre ); + normalize_v3( vrel_t_pre ); impulse = 2.0 * magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse ); @@ -853,15 +853,15 @@ static void calculateEENormal(float *np1, float *np2, float *np3, float *np4,flo // printf("l1: %f, l1: %f, l2: %f, l2: %f\n", line1[0], line1[1], line2[0], line2[1]); - Crossf(out_normal, line1, line2); + cross_v3_v3v3(out_normal, line1, line2); - length = Normalize(out_normal); + length = normalize_v3(out_normal); if (length <= FLT_EPSILON) { // lines are collinear VECSUB(out_normal, np2, np1); - Normalize(out_normal); + normalize_v3(out_normal); } } @@ -901,7 +901,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float VECSUB(line1, np12, np11); VECSUB(line2, np22, np21); - Crossf(cross, line1, line2); + cross_v3_v3v3(cross, line1, line2); length = INPR(cross, cross); if (length < FLT_EPSILON) @@ -912,7 +912,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float *out_a1 = 0; calculateEENormal(np11, np12, np21, np22, out_normal); VECSUB(temp, np22, np21); - VecMulf(temp, *out_a2); + mul_v3_fl(temp, *out_a2); VECADD(temp2, temp, np21); VECADD(temp2, temp2, np11); return INPR(temp2, temp2); @@ -928,7 +928,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // return (np22 - (np11 + (np12 - np11) * out_a1)).lengthSquared(); VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(temp2, temp, np11); VECSUB(temp2, np22, temp2); return INPR(temp2, temp2); @@ -943,7 +943,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // return (np21 - (np11 + (np12 - np11) * out_a1)).lengthSquared(); VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(temp2, temp, np11); VECSUB(temp2, np21, temp2); return INPR(temp2, temp2); @@ -991,12 +991,12 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // p1= np11 + (np12 - np11) * out_a1; VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(p1, np11, temp); // p2 = np21 + (np22 - np21) * out_a2; VECSUB(temp, np22, np21); - VecMulf(temp, *out_a2); + mul_v3_fl(temp, *out_a2); VECADD(p2, np21, temp); calculateEENormal(np11, np12, np21, np22, out_normal); @@ -1022,7 +1022,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // p1 = np11 + (np12 - np11) * out_a1; VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(p1, np11, temp); *out_a2 = projectPointOntoLine(p1, np21, np22); @@ -1032,7 +1032,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // return (p1 - (np21 + (np22 - np21) * out_a2)).lengthSquared(); VECSUB(temp, np22, np21); - VecMulf(temp, *out_a2); + mul_v3_fl(temp, *out_a2); VECADD(temp, temp, np21); VECSUB(temp, p1, temp); return INPR(temp, temp); @@ -1044,7 +1044,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // p2 = np21 + (np22 - np21) * out_a2; VECSUB(temp, np22, np21); - VecMulf(temp, *out_a2); + mul_v3_fl(temp, *out_a2); VECADD(p2, np21, temp); *out_a1 = projectPointOntoLine(p2, np11, np12); @@ -1054,7 +1054,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float // return ((np11 + (np12 - np11) * out_a1) - p2).lengthSquared(); VECSUB(temp, np12, np11); - VecMulf(temp, *out_a1); + mul_v3_fl(temp, *out_a1); VECADD(temp, temp, np11); VECSUB(temp, temp, p2); return INPR(temp, temp); @@ -1217,16 +1217,16 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi float desiredVn; VECCOPY(vrel_1_to_2, verts1[edgecollpair.p11].tv); - VecMulf(vrel_1_to_2, 1.0 - a); + mul_v3_fl(vrel_1_to_2, 1.0 - a); VECCOPY(temp, verts1[edgecollpair.p12].tv); - VecMulf(temp, a); + mul_v3_fl(temp, a); VECADD(vrel_1_to_2, vrel_1_to_2, temp); VECCOPY(temp, verts1[edgecollpair.p21].tv); - VecMulf(temp, 1.0 - b); + mul_v3_fl(temp, 1.0 - b); VECCOPY(temp2, verts1[edgecollpair.p22].tv); - VecMulf(temp2, b); + mul_v3_fl(temp2, b); VECADD(temp, temp, temp2); VECSUB(vrel_1_to_2, vrel_1_to_2, temp); @@ -1237,7 +1237,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi if(out_normalVelocity < 0.0) { out_normalVelocity*= -1.0; - VecNegf(out_normal); + negate_v3(out_normal); } */ /* Inelastic repulsion impulse. */ @@ -1707,7 +1707,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl continue; } - length = Normalize ( temp ); + length = normalize_v3( temp ); if ( length < mindistance ) { @@ -1715,17 +1715,17 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) { - VecMulf ( temp, -correction ); + mul_v3_fl( temp, -correction ); VECADD ( verts[j].tx, verts[j].tx, temp ); } else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) { - VecMulf ( temp, correction ); + mul_v3_fl( temp, correction ); VECADD ( verts[i].tx, verts[i].tx, temp ); } else { - VecMulf ( temp, -correction*0.5 ); + mul_v3_fl( temp, -correction*0.5 ); VECADD ( verts[j].tx, verts[j].tx, temp ); VECSUB ( verts[i].tx, verts[i].tx, temp ); diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 8cd64ae2ece..f3448a60b5a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -52,7 +52,7 @@ #include "BKE_utildefines.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_threads.h" #include "IMB_imbuf.h" @@ -462,35 +462,35 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr) if(bezt[0].h2==HD_AUTO) { - hlen= VecLenf(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */ + hlen= len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */ /* clip handle point */ VECCOPY(vec, bezt[1].vec[0]); if(vec[0] < bezt[0].vec[1][0]) vec[0]= bezt[0].vec[1][0]; - VecSubf(vec, vec, bezt[0].vec[1]); - nlen= VecLength(vec); + sub_v3_v3v3(vec, vec, bezt[0].vec[1]); + nlen= len_v3(vec); if(nlen>FLT_EPSILON) { - VecMulf(vec, hlen/nlen); - VecAddf(bezt[0].vec[2], vec, bezt[0].vec[1]); - VecSubf(bezt[0].vec[0], bezt[0].vec[1], vec); + mul_v3_fl(vec, hlen/nlen); + add_v3_v3v3(bezt[0].vec[2], vec, bezt[0].vec[1]); + sub_v3_v3v3(bezt[0].vec[0], bezt[0].vec[1], vec); } } a= cuma->totpoint-1; if(bezt[a].h2==HD_AUTO) { - hlen= VecLenf(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */ + hlen= len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */ /* clip handle point */ VECCOPY(vec, bezt[a-1].vec[2]); if(vec[0] > bezt[a].vec[1][0]) vec[0]= bezt[a].vec[1][0]; - VecSubf(vec, vec, bezt[a].vec[1]); - nlen= VecLength(vec); + sub_v3_v3v3(vec, vec, bezt[a].vec[1]); + nlen= len_v3(vec); if(nlen>FLT_EPSILON) { - VecMulf(vec, hlen/nlen); - VecAddf(bezt[a].vec[0], vec, bezt[a].vec[1]); - VecSubf(bezt[a].vec[2], bezt[a].vec[1], vec); + mul_v3_fl(vec, hlen/nlen); + add_v3_v3v3(bezt[a].vec[0], vec, bezt[a].vec[1]); + sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec); } } } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index a319838a56f..55001f58d2f 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "DNA_armature_types.h" @@ -122,12 +122,12 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, cob->ob = ob; cob->type = datatype; cob->rotOrder = EULER_ORDER_DEFAULT; // TODO: when objects have rotation order too, use that - Mat4CpyMat4(cob->matrix, ob->obmat); + copy_m4_m4(cob->matrix, ob->obmat); } else - Mat4One(cob->matrix); + unit_m4(cob->matrix); - Mat4CpyMat4(cob->startmat, cob->matrix); + copy_m4_m4(cob->startmat, cob->matrix); } break; case CONSTRAINT_OBTYPE_BONE: @@ -148,18 +148,18 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, } /* matrix in world-space */ - Mat4MulMat4(cob->matrix, cob->pchan->pose_mat, ob->obmat); + mul_m4_m4m4(cob->matrix, cob->pchan->pose_mat, ob->obmat); } else - Mat4One(cob->matrix); + unit_m4(cob->matrix); - Mat4CpyMat4(cob->startmat, cob->matrix); + copy_m4_m4(cob->startmat, cob->matrix); } break; default: /* other types not yet handled */ - Mat4One(cob->matrix); - Mat4One(cob->startmat); + unit_m4(cob->matrix); + unit_m4(cob->startmat); break; } @@ -176,8 +176,8 @@ void constraints_clear_evalob (bConstraintOb *cob) return; /* calculate delta of constraints evaluation */ - Mat4Invert(imat, cob->startmat); - Mat4MulMat4(delta, imat, cob->matrix); + invert_m4_m4(imat, cob->startmat); + mul_m4_m4m4(delta, imat, cob->matrix); /* copy matrices back to source */ switch (cob->type) { @@ -186,10 +186,10 @@ void constraints_clear_evalob (bConstraintOb *cob) /* cob->ob might not exist! */ if (cob->ob) { /* copy new ob-matrix back to owner */ - Mat4CpyMat4(cob->ob->obmat, cob->matrix); + copy_m4_m4(cob->ob->obmat, cob->matrix); /* copy inverse of delta back to owner */ - Mat4Invert(cob->ob->constinv, delta); + invert_m4_m4(cob->ob->constinv, delta); } } break; @@ -198,10 +198,10 @@ void constraints_clear_evalob (bConstraintOb *cob) /* cob->ob or cob->pchan might not exist */ if (cob->ob && cob->pchan) { /* copy new pose-matrix back to owner */ - Mat4MulMat4(cob->pchan->pose_mat, cob->matrix, cob->ob->imat); + mul_m4_m4m4(cob->pchan->pose_mat, cob->matrix, cob->ob->imat); /* copy inverse of delta back to owner */ - Mat4Invert(cob->pchan->constinv, delta); + invert_m4_m4(cob->pchan->constinv, delta); } } break; @@ -235,9 +235,9 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 case CONSTRAINT_SPACE_WORLD: /* ---------- FROM WORLDSPACE ---------- */ { /* world to pose */ - Mat4Invert(imat, ob->obmat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, imat); + invert_m4_m4(imat, ob->obmat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, imat); /* use pose-space as stepping stone for other spaces... */ if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) { @@ -250,8 +250,8 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 { /* pose to world */ if (to == CONSTRAINT_SPACE_WORLD) { - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, ob->obmat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, ob->obmat); } /* pose to local */ else if (to == CONSTRAINT_SPACE_LOCAL) { @@ -260,7 +260,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 float offs_bone[4][4]; /* construct offs_bone the same way it is done in armature.c */ - Mat4CpyMat3(offs_bone, pchan->bone->bone_mat); + copy_m4_m3(offs_bone, pchan->bone->bone_mat); VECCOPY(offs_bone[3], pchan->bone->head); offs_bone[3][1]+= pchan->bone->parent->length; @@ -269,37 +269,37 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 float tmat[4][4]; /* the rotation of the parent restposition */ - Mat4CpyMat4(tmat, pchan->bone->parent->arm_mat); + copy_m4_m4(tmat, pchan->bone->parent->arm_mat); /* the location of actual parent transform */ VECCOPY(tmat[3], offs_bone[3]); offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; - Mat4MulVecfl(pchan->parent->pose_mat, tmat[3]); + mul_m4_v3(pchan->parent->pose_mat, tmat[3]); - Mat4MulMat4(diff_mat, offs_bone, tmat); - Mat4Invert(imat, diff_mat); + mul_m4_m4m4(diff_mat, offs_bone, tmat); + invert_m4_m4(imat, diff_mat); } else { /* pose_mat = par_pose_mat * bone_mat * chan_mat */ - Mat4MulMat4(diff_mat, offs_bone, pchan->parent->pose_mat); - Mat4Invert(imat, diff_mat); + mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat); + invert_m4_m4(imat, diff_mat); } } else { /* pose_mat = chan_mat * arm_mat */ - Mat4Invert(imat, pchan->bone->arm_mat); + invert_m4_m4(imat, pchan->bone->arm_mat); } - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, imat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, imat); } } /* pose to local with parent */ else if (to == CONSTRAINT_SPACE_PARLOCAL) { if (pchan->bone) { - Mat4Invert(imat, pchan->bone->arm_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, imat); + invert_m4_m4(imat, pchan->bone->arm_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, imat); } } } @@ -313,7 +313,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 float offs_bone[4][4]; /* construct offs_bone the same way it is done in armature.c */ - Mat4CpyMat3(offs_bone, pchan->bone->bone_mat); + copy_m4_m3(offs_bone, pchan->bone->bone_mat); VECCOPY(offs_bone[3], pchan->bone->head); offs_bone[3][1]+= pchan->bone->parent->length; @@ -322,29 +322,29 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 float tmat[4][4]; /* the rotation of the parent restposition */ - Mat4CpyMat4(tmat, pchan->bone->parent->arm_mat); + copy_m4_m4(tmat, pchan->bone->parent->arm_mat); /* the location of actual parent transform */ VECCOPY(tmat[3], offs_bone[3]); offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; - Mat4MulVecfl(pchan->parent->pose_mat, tmat[3]); + mul_m4_v3(pchan->parent->pose_mat, tmat[3]); - Mat4MulMat4(diff_mat, offs_bone, tmat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, diff_mat); + mul_m4_m4m4(diff_mat, offs_bone, tmat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, diff_mat); } else { /* pose_mat = par_pose_mat * bone_mat * chan_mat */ - Mat4MulMat4(diff_mat, offs_bone, pchan->parent->pose_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, diff_mat); + mul_m4_m4m4(diff_mat, offs_bone, pchan->parent->pose_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, diff_mat); } } else { - Mat4CpyMat4(diff_mat, pchan->bone->arm_mat); + copy_m4_m4(diff_mat, pchan->bone->arm_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, diff_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, diff_mat); } } @@ -359,9 +359,9 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 { /* local + parent to pose */ if (pchan->bone) { - Mat4CpyMat4(diff_mat, pchan->bone->arm_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, diff_mat, tempmat); + copy_m4_m4(diff_mat, pchan->bone->arm_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, diff_mat, tempmat); } /* use pose-space as stepping stone for other spaces */ @@ -379,19 +379,19 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* check if object has a parent - otherwise this won't work */ if (ob->parent) { /* 'subtract' parent's effects from owner */ - Mat4MulMat4(diff_mat, ob->parentinv, ob->parent->obmat); - Mat4Invert(imat, diff_mat); - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(mat, tempmat, imat); + mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat); + invert_m4_m4(imat, diff_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, imat); } } else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) { /* check that object has a parent - otherwise this won't work */ if (ob->parent) { /* 'add' parent's effect back to owner */ - Mat4CpyMat4(tempmat, mat); - Mat4MulMat4(diff_mat, ob->parentinv, ob->parent->obmat); - Mat4MulMat4(mat, tempmat, diff_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat); + mul_m4_m4m4(mat, tempmat, diff_mat); } } } @@ -412,7 +412,7 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f short freeDM = 0; /* initialize target matrix using target matrix */ - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); /* get index of vertex group */ dgroup = get_named_vertexgroup_num(ob, substring); @@ -454,8 +454,8 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f if (dvert[i].dw[j].def_nr == dgroup) { dm->getVertCo(dm, i, co); dm->getVertNo(dm, i, nor); - VecAddf(vec, vec, co); - VecAddf(normal, normal, nor); + add_v3_v3v3(vec, vec, co); + add_v3_v3v3(normal, normal, nor); count++; break; } @@ -466,8 +466,8 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f /* calculate averages of normal and coordinates */ if (count > 0) { - VecMulf(vec, 1.0f / count); - VecMulf(normal, 1.0f / count); + mul_v3_fl(vec, 1.0f / count); + mul_v3_fl(normal, 1.0f / count); } @@ -476,25 +476,25 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f * calc_manipulator_stats, V3D_MANIP_NORMAL case */ /* we need the transpose of the inverse for a normal... */ - Mat3CpyMat4(imat, ob->obmat); + copy_m3_m4(imat, ob->obmat); - Mat3Inv(tmat, imat); - Mat3Transp(tmat); - Mat3MulVecfl(tmat, normal); + invert_m3_m3(tmat, imat); + transpose_m3(tmat); + mul_m3_v3(tmat, normal); - Normalize(normal); + normalize_v3(normal); VECCOPY(plane, tmat[1]); VECCOPY(tmat[2], normal); - Crossf(tmat[0], normal, plane); - Crossf(tmat[1], tmat[2], tmat[0]); + cross_v3_v3v3(tmat[0], normal, plane); + cross_v3_v3v3(tmat[1], tmat[2], tmat[0]); - Mat4CpyMat3(mat, tmat); - Mat4Ortho(mat); + copy_m4_m3(mat, tmat); + normalize_m4(mat); /* apply the average coordinate as the new location */ - VecMat4MulVecfl(tvec, ob->obmat, vec); + mul_v3_m4v3(tvec, ob->obmat, vec); VECCOPY(mat[3], tvec); } } @@ -522,7 +522,7 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ int i, n; /* initialize target matrix using target matrix */ - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); /* get index of vertex group */ dgroup = get_named_vertexgroup_num(ob, substring); @@ -542,7 +542,7 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ else memcpy(tvec, bp->vec, 3*sizeof(float)); - VecAddf(vec, vec, tvec); + add_v3_v3v3(vec, vec, tvec); grouped++; break; @@ -556,8 +556,8 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ /* find average location, then multiply by ob->obmat to find world-space location */ if (grouped) - VecMulf(vec, 1.0f / grouped); - VecMat4MulVecfl(tvec, ob->obmat, vec); + mul_v3_fl(vec, 1.0f / grouped); + mul_v3_m4v3(tvec, ob->obmat, vec); /* copy new location to matrix */ VECCOPY(mat[3], tvec); @@ -569,7 +569,7 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, char *substring { /* Case OBJECT */ if (!strlen(substring)) { - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); constraint_mat_convertspace(ob, NULL, mat, from, to); } /* Case VERTEXGROUP */ @@ -601,23 +601,23 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, char *substring */ if (headtail < 0.000001) { /* skip length interpolation if set to head */ - Mat4MulMat4(mat, pchan->pose_mat, ob->obmat); + mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat); } else { float tempmat[4][4], loc[3]; /* interpolate along length of bone */ - VecLerpf(loc, pchan->pose_head, pchan->pose_tail, headtail); + interp_v3_v3v3(loc, pchan->pose_head, pchan->pose_tail, headtail); /* use interpolated distance for subtarget */ - Mat4CpyMat4(tempmat, pchan->pose_mat); - VecCopyf(tempmat[3], loc); + copy_m4_m4(tempmat, pchan->pose_mat); + copy_v3_v3(tempmat[3], loc); - Mat4MulMat4(mat, tempmat, ob->obmat); + mul_m4_m4m4(mat, tempmat, ob->obmat); } } else - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); /* convert matrix space as required */ constraint_mat_convertspace(ob, pchan, mat, from, to); @@ -666,7 +666,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain if (VALID_CONS_TARGET(ct)) constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } /* This following macro should be used for all standard single-target *_get_tars functions @@ -772,7 +772,7 @@ static void childof_new_data (void *cdata) data->flag = (CHILDOF_LOCX | CHILDOF_LOCY | CHILDOF_LOCZ | CHILDOF_ROTX |CHILDOF_ROTY | CHILDOF_ROTZ | CHILDOF_SIZEX | CHILDOF_SIZEY | CHILDOF_SIZEZ); - Mat4One(data->invmat); + unit_m4(data->invmat); } static int childof_get_tars (bConstraint *con, ListBase *list) @@ -813,16 +813,16 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float loco[3], eulo[3], sizo[3]; /* get offset (parent-inverse) matrix */ - Mat4CpyMat4(invmat, data->invmat); + copy_m4_m4(invmat, data->invmat); /* extract components of both matrices */ VECCOPY(loc, ct->matrix[3]); - Mat4ToEulO(ct->matrix, eul, ct->rotOrder); - Mat4ToSize(ct->matrix, size); + mat4_to_eulO( eul, ct->rotOrder,ct->matrix); + mat4_to_size( size,ct->matrix); VECCOPY(loco, invmat[3]); - Mat4ToEulO(invmat, eulo, cob->rotOrder); - Mat4ToSize(invmat, sizo); + mat4_to_eulO( eulo, cob->rotOrder,invmat); + mat4_to_size( sizo,invmat); /* disable channels not enabled */ if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f; @@ -836,19 +836,19 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f; /* make new target mat and offset mat */ - LocEulOSizeToMat4(ct->matrix, loc, eul, size, ct->rotOrder); - LocEulOSizeToMat4(invmat, loco, eulo, sizo, cob->rotOrder); + loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder); + loc_eulO_size_to_mat4(invmat, loco, eulo, sizo, cob->rotOrder); /* multiply target (parent matrix) by offset (parent inverse) to get * the effect of the parent that will be exherted on the owner */ - Mat4MulMat4(parmat, invmat, ct->matrix); + mul_m4_m4m4(parmat, invmat, ct->matrix); /* now multiply the parent matrix by the owner matrix to get the * the effect of this constraint (i.e. owner is 'parented' to parent) */ - Mat4CpyMat4(tempmat, cob->matrix); - Mat4MulMat4(cob->matrix, tempmat, parmat); + copy_m4_m4(tempmat, cob->matrix); + mul_m4_m4m4(cob->matrix, tempmat, parmat); } } @@ -929,14 +929,14 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh float neg = -1; int right_index; - VecCopyf(n, vec); - if (Normalize(n) == 0.0) { + copy_v3_v3(n, vec); + if (normalize_v3(n) == 0.0) { n[0] = 0.0; n[1] = 0.0; n[2] = 1.0; } if (axis > 2) axis -= 3; - else VecNegf(n); + else negate_v3(n); /* n specifies the transformation of the track axis */ if (flags & TARGET_Z_UP) { @@ -953,19 +953,19 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh } /* project the up vector onto the plane specified by n */ - Projf(proj, u, n); /* first u onto n... */ - VecSubf(proj, u, proj); /* then onto the plane */ + project_v3_v3v3(proj, u, n); /* first u onto n... */ + sub_v3_v3v3(proj, u, proj); /* then onto the plane */ /* proj specifies the transformation of the up axis */ - if (Normalize(proj) == 0.0) { /* degenerate projection */ + if (normalize_v3(proj) == 0.0) { /* degenerate projection */ proj[0] = 0.0; proj[1] = 1.0; proj[2] = 0.0; } /* Normalized cross product of n and proj specifies transformation of the right axis */ - Crossf(right, proj, n); - Normalize(right); + cross_v3_v3v3(right, proj, n); + normalize_v3(right); if (axis != upflag) { right_index = 3 - axis - upflag; @@ -1005,7 +1005,7 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float tmat[4][4]; /* Get size property, since ob->size is only the object's own relative size, not its global one */ - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); /* Clear the object's rotation */ cob->matrix[0][0]=size[0]; @@ -1021,13 +1021,13 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* targetmat[2] instead of ownermat[2] is passed to vectomat * for backwards compatability it seems... (Aligorith) */ - VecSubf(vec, cob->matrix[3], ct->matrix[3]); + sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); vectomat(vec, ct->matrix[2], (short)data->reserved1, (short)data->reserved2, data->flags, totmat); - Mat4CpyMat4(tmat, cob->matrix); - Mat4MulMat34(cob->matrix, totmat, tmat); + copy_m4_m4(tmat, cob->matrix); + mul_m4_m3m4(cob->matrix, totmat, tmat); } } @@ -1098,19 +1098,19 @@ static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstra Object *ob= cob->ob; if (ob == NULL) { - Mat4One(ct->matrix); + unit_m4(ct->matrix); } else { float vec[3]; /* move grabtarget into world space */ VECCOPY(vec, data->grabtarget); - Mat4MulVecfl(ob->obmat, vec); - Mat4CpyMat4(ct->matrix, ob->obmat); + mul_m4_v3(ob->obmat, vec); + copy_m4_m4(ct->matrix, ob->obmat); VECCOPY(ct->matrix[3], vec); } } else - Mat4One(ct->matrix); + unit_m4(ct->matrix); } } @@ -1177,8 +1177,8 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr float totmat[4][4]; float curvetime; - Mat4One(totmat); - Mat4One(ct->matrix); + unit_m4(totmat); + unit_m4(ct->matrix); /* note: when creating constraints that follow path, the curve gets the CU_PATH set now, * currently for paths to work it needs to go through the bevlist/displist system (ton) @@ -1212,34 +1212,34 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius) ) { if (data->followflag & FOLLOWPATH_FOLLOW) { - vectoquat(dir, (short) data->trackflag, (short) data->upflag, quat); + vec_to_quat( quat,dir, (short) data->trackflag, (short) data->upflag); - Normalize(dir); + normalize_v3(dir); q[0]= (float)cos(0.5*vec[3]); x1= (float)sin(0.5*vec[3]); q[1]= -x1*dir[0]; q[2]= -x1*dir[1]; q[3]= -x1*dir[2]; - QuatMul(quat, q, quat); + mul_qt_qtqt(quat, q, quat); - QuatToMat4(quat, totmat); + quat_to_mat4( totmat,quat); } if (data->followflag & FOLLOWPATH_RADIUS) { float tmat[4][4], rmat[4][4]; - Mat4Scale(tmat, radius); - Mat4MulMat4(rmat, totmat, tmat); - Mat4CpyMat4(totmat, rmat); + scale_m4_fl(tmat, radius); + mul_m4_m4m4(rmat, totmat, tmat); + copy_m4_m4(totmat, rmat); } VECCOPY(totmat[3], vec); - Mat4MulSerie(ct->matrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(ct->matrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); } } } else if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) @@ -1254,25 +1254,25 @@ static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase /* get Object local transform (loc/rot/size) to determine transformation from path */ //object_to_mat4(ob, obmat); - Mat4CpyMat4(obmat, cob->matrix); // FIXME!!! + copy_m4_m4(obmat, cob->matrix); // FIXME!!! /* get scaling of object before applying constraint */ - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); /* apply targetmat - containing location on path, and rotation */ - Mat4MulSerie(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL); /* un-apply scaling caused by path */ if ((data->followflag & FOLLOWPATH_RADIUS)==0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */ float obsize[3]; - Mat4ToSize(cob->matrix, obsize); + mat4_to_size( obsize,cob->matrix); if (obsize[0]) - VecMulf(cob->matrix[0], size[0] / obsize[0]); + mul_v3_fl(cob->matrix[0], size[0] / obsize[0]); if (obsize[1]) - VecMulf(cob->matrix[1], size[1] / obsize[1]); + mul_v3_fl(cob->matrix[1], size[1] / obsize[1]); if (obsize[2]) - VecMulf(cob->matrix[2], size[2] / obsize[2]); + mul_v3_fl(cob->matrix[2], size[2] / obsize[2]); } } } @@ -1350,9 +1350,9 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t float size[3]; VECCOPY(loc, cob->matrix[3]); - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); - Mat4ToEulO(cob->matrix, eul, cob->rotOrder); + mat4_to_eulO( eul, cob->rotOrder,cob->matrix); /* eulers: radians to degrees! */ eul[0] = (float)(eul[0] / M_PI * 180); @@ -1387,7 +1387,7 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t eul[1] = (float)(eul[1] / 180 * M_PI); eul[2] = (float)(eul[2] / 180 * M_PI); - LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder); + loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder); } static bConstraintTypeInfo CTI_ROTLIMIT = { @@ -1413,8 +1413,8 @@ static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * bSizeLimitConstraint *data = con->data; float obsize[3], size[3]; - Mat4ToSize(cob->matrix, size); - Mat4ToSize(cob->matrix, obsize); + mat4_to_size( size,cob->matrix); + mat4_to_size( obsize,cob->matrix); if (data->flag & LIMIT_XMIN) { if (size[0] < data->xmin) @@ -1442,11 +1442,11 @@ static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * } if (obsize[0]) - VecMulf(cob->matrix[0], size[0]/obsize[0]); + mul_v3_fl(cob->matrix[0], size[0]/obsize[0]); if (obsize[1]) - VecMulf(cob->matrix[1], size[1]/obsize[1]); + mul_v3_fl(cob->matrix[1], size[1]/obsize[1]); if (obsize[2]) - VecMulf(cob->matrix[2], size[2]/obsize[2]); + mul_v3_fl(cob->matrix[2], size[2]/obsize[2]); } static bConstraintTypeInfo CTI_SIZELIMIT = { @@ -1592,17 +1592,17 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float size[3]; VECCOPY(loc, cob->matrix[3]); - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); /* to allow compatible rotations, must get both rotations in the order of the owner... */ - Mat4ToEulO(ct->matrix, eul, cob->rotOrder); - Mat4ToEulO(cob->matrix, obeul, cob->rotOrder); + mat4_to_eulO( eul, cob->rotOrder,ct->matrix); + mat4_to_eulO( obeul, cob->rotOrder,cob->matrix); if ((data->flag & ROTLIKE_X)==0) eul[0] = obeul[0]; else { if (data->flag & ROTLIKE_OFFSET) - eulerO_rot(eul, obeul[0], 'x', cob->rotOrder); + rotate_eulO(eul, cob->rotOrder, 'x', obeul[0]); if (data->flag & ROTLIKE_X_INVERT) eul[0] *= -1; @@ -1612,7 +1612,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[1] = obeul[1]; else { if (data->flag & ROTLIKE_OFFSET) - eulerO_rot(eul, obeul[1], 'y', cob->rotOrder); + rotate_eulO(eul, cob->rotOrder, 'y', obeul[1]); if (data->flag & ROTLIKE_Y_INVERT) eul[1] *= -1; @@ -1622,14 +1622,14 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[2] = obeul[2]; else { if (data->flag & ROTLIKE_OFFSET) - eulerO_rot(eul, obeul[2], 'z', cob->rotOrder); + rotate_eulO(eul, cob->rotOrder, 'z', obeul[2]); if (data->flag & ROTLIKE_Z_INVERT) eul[2] *= -1; } compatible_eul(eul, obeul); - LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder); + loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder); } } @@ -1691,32 +1691,32 @@ static void sizelike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t if (VALID_CONS_TARGET(ct)) { float obsize[3], size[3]; - Mat4ToSize(ct->matrix, size); - Mat4ToSize(cob->matrix, obsize); + mat4_to_size( size,ct->matrix); + mat4_to_size( obsize,cob->matrix); if ((data->flag & SIZELIKE_X) && (obsize[0] != 0)) { if (data->flag & SIZELIKE_OFFSET) { size[0] += (obsize[0] - 1.0f); - VecMulf(cob->matrix[0], size[0] / obsize[0]); + mul_v3_fl(cob->matrix[0], size[0] / obsize[0]); } else - VecMulf(cob->matrix[0], size[0] / obsize[0]); + mul_v3_fl(cob->matrix[0], size[0] / obsize[0]); } if ((data->flag & SIZELIKE_Y) && (obsize[1] != 0)) { if (data->flag & SIZELIKE_OFFSET) { size[1] += (obsize[1] - 1.0f); - VecMulf(cob->matrix[1], size[1] / obsize[1]); + mul_v3_fl(cob->matrix[1], size[1] / obsize[1]); } else - VecMulf(cob->matrix[1], size[1] / obsize[1]); + mul_v3_fl(cob->matrix[1], size[1] / obsize[1]); } if ((data->flag & SIZELIKE_Z) && (obsize[2] != 0)) { if (data->flag & SIZELIKE_OFFSET) { size[2] += (obsize[2] - 1.0f); - VecMulf(cob->matrix[2], size[2] / obsize[2]); + mul_v3_fl(cob->matrix[2], size[2] / obsize[2]); } else - VecMulf(cob->matrix[2], size[2] / obsize[2]); + mul_v3_fl(cob->matrix[2], size[2] / obsize[2]); } } } @@ -1817,7 +1817,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT #endif } else if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) @@ -1912,7 +1912,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint short axis; /* initialise return matrix */ - Mat4One(ct->matrix); + unit_m4(ct->matrix); /* get the transform matrix of the target */ constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); @@ -1925,7 +1925,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint */ if (data->type < 10) { /* extract rotation (is in whatever space target should be in) */ - Mat4ToEul(tempmat, vec); + mat4_to_eul( vec,tempmat); vec[0] *= (float)(180.0/M_PI); vec[1] *= (float)(180.0/M_PI); vec[2] *= (float)(180.0/M_PI); @@ -1933,7 +1933,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint } else if (data->type < 20) { /* extract scaling (is in whatever space target should be in) */ - Mat4ToSize(tempmat, vec); + mat4_to_size( vec,tempmat); axis= data->type - 10; } else { @@ -1968,7 +1968,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint /* convert animation to matrices for use here */ chan_calc_mat(tchan); - Mat4CpyMat4(ct->matrix, tchan->chan_mat); + copy_m4_m4(ct->matrix, tchan->chan_mat); /* Clean up */ free_pose(pose); @@ -1998,8 +1998,8 @@ static void actcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar /* Nice and simple... we just need to multiply the matrices, as the get_target_matrix * function has already taken care of everything else. */ - Mat4CpyMat4(temp, cob->matrix); - Mat4MulMat4(cob->matrix, ct->matrix, temp); + copy_m4_m4(temp, cob->matrix); + mul_m4_m4m4(cob->matrix, ct->matrix, temp); } } @@ -2068,7 +2068,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * float mdet; /* Vector object -> target */ - VecSubf(vec, ct->matrix[3], cob->matrix[3]); + sub_v3_v3v3(vec, ct->matrix[3], cob->matrix[3]); switch (data->lockflag){ case LOCK_X: /* LOCK X */ { @@ -2076,71 +2076,71 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case TRACK_Y: /* LOCK X TRACK Y */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[0]); - VecSubf(totmat[1], vec, vec2); - Normalize(totmat[1]); + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; totmat[0][1] = cob->matrix[0][1]; totmat[0][2] = cob->matrix[0][2]; - Normalize(totmat[0]); + normalize_v3(totmat[0]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[2], totmat[0], totmat[1]); + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); } break; case TRACK_Z: /* LOCK X TRACK Z */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[0]); - VecSubf(totmat[2], vec, vec2); - Normalize(totmat[2]); + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; totmat[0][1] = cob->matrix[0][1]; totmat[0][2] = cob->matrix[0][2]; - Normalize(totmat[0]); + normalize_v3(totmat[0]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[1], totmat[2], totmat[0]); + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); } break; case TRACK_nY: /* LOCK X TRACK -Y */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[0]); - VecSubf(totmat[1], vec, vec2); - Normalize(totmat[1]); - VecNegf(totmat[1]); + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); + negate_v3(totmat[1]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; totmat[0][1] = cob->matrix[0][1]; totmat[0][2] = cob->matrix[0][2]; - Normalize(totmat[0]); + normalize_v3(totmat[0]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[2], totmat[0], totmat[1]); + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); } break; case TRACK_nZ: /* LOCK X TRACK -Z */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[0]); - VecSubf(totmat[2], vec, vec2); - Normalize(totmat[2]); - VecNegf(totmat[2]); + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); + negate_v3(totmat[2]); /* the x axis is fixed */ totmat[0][0] = cob->matrix[0][0]; totmat[0][1] = cob->matrix[0][1]; totmat[0][2] = cob->matrix[0][2]; - Normalize(totmat[0]); + normalize_v3(totmat[0]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[1], totmat[2], totmat[0]); + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); } break; default: @@ -2159,71 +2159,71 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case TRACK_X: /* LOCK Y TRACK X */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[1]); - VecSubf(totmat[0], vec, vec2); - Normalize(totmat[0]); + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; totmat[1][1] = cob->matrix[1][1]; totmat[1][2] = cob->matrix[1][2]; - Normalize(totmat[1]); + normalize_v3(totmat[1]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[2], totmat[0], totmat[1]); + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); } break; case TRACK_Z: /* LOCK Y TRACK Z */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[1]); - VecSubf(totmat[2], vec, vec2); - Normalize(totmat[2]); + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; totmat[1][1] = cob->matrix[1][1]; totmat[1][2] = cob->matrix[1][2]; - Normalize(totmat[1]); + normalize_v3(totmat[1]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[0], totmat[1], totmat[2]); + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); } break; case TRACK_nX: /* LOCK Y TRACK -X */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[1]); - VecSubf(totmat[0], vec, vec2); - Normalize(totmat[0]); - VecNegf(totmat[0]); + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); + negate_v3(totmat[0]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; totmat[1][1] = cob->matrix[1][1]; totmat[1][2] = cob->matrix[1][2]; - Normalize(totmat[1]); + normalize_v3(totmat[1]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[2], totmat[0], totmat[1]); + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); } break; case TRACK_nZ: /* LOCK Y TRACK -Z */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[1]); - VecSubf(totmat[2], vec, vec2); - Normalize(totmat[2]); - VecNegf(totmat[2]); + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); + negate_v3(totmat[2]); /* the y axis is fixed */ totmat[1][0] = cob->matrix[1][0]; totmat[1][1] = cob->matrix[1][1]; totmat[1][2] = cob->matrix[1][2]; - Normalize(totmat[1]); + normalize_v3(totmat[1]); /* the z axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[0], totmat[1], totmat[2]); + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); } break; default: @@ -2242,71 +2242,71 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case TRACK_X: /* LOCK Z TRACK X */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[2]); - VecSubf(totmat[0], vec, vec2); - Normalize(totmat[0]); + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; totmat[2][1] = cob->matrix[2][1]; totmat[2][2] = cob->matrix[2][2]; - Normalize(totmat[2]); + normalize_v3(totmat[2]); /* the x axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[1], totmat[2], totmat[0]); + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); } break; case TRACK_Y: /* LOCK Z TRACK Y */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[2]); - VecSubf(totmat[1], vec, vec2); - Normalize(totmat[1]); + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; totmat[2][1] = cob->matrix[2][1]; totmat[2][2] = cob->matrix[2][2]; - Normalize(totmat[2]); + normalize_v3(totmat[2]); /* the x axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[0], totmat[1], totmat[2]); + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); } break; case TRACK_nX: /* LOCK Z TRACK -X */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[2]); - VecSubf(totmat[0], vec, vec2); - Normalize(totmat[0]); - VecNegf(totmat[0]); + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); + negate_v3(totmat[0]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; totmat[2][1] = cob->matrix[2][1]; totmat[2][2] = cob->matrix[2][2]; - Normalize(totmat[2]); + normalize_v3(totmat[2]); /* the x axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[1], totmat[2], totmat[0]); + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); } break; case TRACK_nY: /* LOCK Z TRACK -Y */ { /* Projection of Vector on the plane */ - Projf(vec2, vec, cob->matrix[2]); - VecSubf(totmat[1], vec, vec2); - Normalize(totmat[1]); - VecNegf(totmat[1]); + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); + negate_v3(totmat[1]); /* the z axis is fixed */ totmat[2][0] = cob->matrix[2][0]; totmat[2][1] = cob->matrix[2][1]; totmat[2][2] = cob->matrix[2][2]; - Normalize(totmat[2]); + normalize_v3(totmat[2]); /* the x axis gets mapped onto a third orthogonal vector */ - Crossf(totmat[0], totmat[1], totmat[2]); + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); } break; default: @@ -2331,18 +2331,18 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * tmpmat[0][0] = cob->matrix[0][0];tmpmat[0][1] = cob->matrix[0][1];tmpmat[0][2] = cob->matrix[0][2]; tmpmat[1][0] = cob->matrix[1][0];tmpmat[1][1] = cob->matrix[1][1];tmpmat[1][2] = cob->matrix[1][2]; tmpmat[2][0] = cob->matrix[2][0];tmpmat[2][1] = cob->matrix[2][1];tmpmat[2][2] = cob->matrix[2][2]; - Normalize(tmpmat[0]); - Normalize(tmpmat[1]); - Normalize(tmpmat[2]); - Mat3Inv(invmat, tmpmat); - Mat3MulMat3(tmpmat, totmat, invmat); + normalize_v3(tmpmat[0]); + normalize_v3(tmpmat[1]); + normalize_v3(tmpmat[2]); + invert_m3_m3(invmat, tmpmat); + mul_m3_m3m3(tmpmat, totmat, invmat); totmat[0][0] = tmpmat[0][0];totmat[0][1] = tmpmat[0][1];totmat[0][2] = tmpmat[0][2]; totmat[1][0] = tmpmat[1][0];totmat[1][1] = tmpmat[1][1];totmat[1][2] = tmpmat[1][2]; totmat[2][0] = tmpmat[2][0];totmat[2][1] = tmpmat[2][1];totmat[2][2] = tmpmat[2][2]; - Mat4CpyMat4(tmat, cob->matrix); + copy_m4_m4(tmat, cob->matrix); - mdet = Det3x3( totmat[0][0],totmat[0][1],totmat[0][2], + mdet = determinant_m3( totmat[0][0],totmat[0][1],totmat[0][2], totmat[1][0],totmat[1][1],totmat[1][2], totmat[2][0],totmat[2][1],totmat[2][2]); if (mdet==0) { @@ -2352,7 +2352,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * } /* apply out transformaton to the object */ - Mat4MulMat34(cob->matrix, totmat, tmat); + mul_m4_m3m4(cob->matrix, totmat, tmat); } } @@ -2417,7 +2417,7 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * short clamp_surf= 0; /* calculate our current distance from the target */ - dist= VecLenf(cob->matrix[3], ct->matrix[3]); + dist= len_v3v3(cob->matrix[3], ct->matrix[3]); /* set distance (flag is only set when user demands it) */ if (data->dist == 0) @@ -2464,7 +2464,7 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* clamp to 'surface' (i.e. move owner so that dist == data->dist) */ if (clamp_surf) { /* simply interpolate along line formed by target -> owner */ - VecLerpf(dvec, ct->matrix[3], cob->matrix[3], sfac); + interp_v3_v3v3(dvec, ct->matrix[3], cob->matrix[3], sfac); /* copy new vector onto owner */ VECCOPY(cob->matrix[3], dvec); @@ -2538,27 +2538,27 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * float dist; /* store scaling before destroying obmat */ - Mat4ToSize(cob->matrix, size); + mat4_to_size( size,cob->matrix); /* store X orientation before destroying obmat */ xx[0] = cob->matrix[0][0]; xx[1] = cob->matrix[0][1]; xx[2] = cob->matrix[0][2]; - Normalize(xx); + normalize_v3(xx); /* store Z orientation before destroying obmat */ zz[0] = cob->matrix[2][0]; zz[1] = cob->matrix[2][1]; zz[2] = cob->matrix[2][2]; - Normalize(zz); + normalize_v3(zz); - VecSubf(vec, cob->matrix[3], ct->matrix[3]); + sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); vec[0] /= size[0]; vec[1] /= size[1]; vec[2] /= size[2]; - dist = Normalize(vec); - //dist = VecLenf( ob->obmat[3], targetmat[3]); + dist = normalize_v3(vec); + //dist = len_v3v3( ob->obmat[3], targetmat[3]); /* data->orglength==0 occurs on first run, and after 'R' button is clicked */ if (data->orglength == 0) @@ -2601,8 +2601,8 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * cob->matrix[2][1]=0; cob->matrix[2][2]=size[2]*scale[2]; - VecSubf(vec, cob->matrix[3], ct->matrix[3]); - Normalize(vec); + sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); + normalize_v3(vec); /* new Y aligns object target connection*/ totmat[1][0] = -vec[0]; @@ -2612,8 +2612,8 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case PLANE_X: /* build new Z vector */ /* othogonal to "new Y" "old X! plane */ - Crossf(orth, vec, xx); - Normalize(orth); + cross_v3_v3v3(orth, vec, xx); + normalize_v3(orth); /* new Z*/ totmat[2][0] = orth[0]; @@ -2621,8 +2621,8 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * totmat[2][2] = orth[2]; /* we decided to keep X plane*/ - Crossf(xx, orth, vec); - Normalize(xx); + cross_v3_v3v3(xx, orth, vec); + normalize_v3(xx); totmat[0][0] = xx[0]; totmat[0][1] = xx[1]; totmat[0][2] = xx[2]; @@ -2630,8 +2630,8 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * case PLANE_Z: /* build new X vector */ /* othogonal to "new Y" "old Z! plane */ - Crossf(orth, vec, zz); - Normalize(orth); + cross_v3_v3v3(orth, vec, zz); + normalize_v3(orth); /* new X */ totmat[0][0] = -orth[0]; @@ -2639,16 +2639,16 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * totmat[0][2] = -orth[2]; /* we decided to keep Z */ - Crossf(zz, orth, vec); - Normalize(zz); + cross_v3_v3v3(zz, orth, vec); + normalize_v3(zz); totmat[2][0] = zz[0]; totmat[2][1] = zz[1]; totmat[2][2] = zz[2]; break; } /* switch (data->plane) */ - Mat4CpyMat4(tmat, cob->matrix); - Mat4MulMat34(cob->matrix, totmat, tmat); + copy_m4_m4(tmat, cob->matrix); + mul_m4_m3m4(cob->matrix, totmat, tmat); } } @@ -2716,15 +2716,15 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar float val1, val2; int index; - Mat4CpyMat4(obmat, cob->matrix); - Mat4CpyMat4(tarmat, ct->matrix); + copy_m4_m4(obmat, cob->matrix); + copy_m4_m4(tarmat, ct->matrix); if (data->flag & MINMAX_USEROT) { /* take rotation of target into account by doing the transaction in target's localspace */ - Mat4Invert(imat, tarmat); - Mat4MulMat4(tmat, obmat, imat); - Mat4CpyMat4(obmat, tmat); - Mat4One(tarmat); + invert_m4_m4(imat, tarmat); + mul_m4_m4m4(tmat, obmat, imat); + copy_m4_m4(obmat, tmat); + unit_m4(tarmat); } switch (data->minmaxflag) { @@ -2775,8 +2775,8 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar } if (data->flag & MINMAX_USEROT) { /* get out of localspace */ - Mat4MulMat4(tmat, obmat, ct->matrix); - Mat4CpyMat4(cob->matrix, tmat); + mul_m4_m4m4(tmat, obmat, ct->matrix); + copy_m4_m4(cob->matrix, tmat); } else { VECCOPY(cob->matrix[3], obmat[3]); @@ -2900,7 +2900,7 @@ static void clampto_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain * might end up calling this... */ if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) @@ -2914,8 +2914,8 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float obmat[4][4], targetMatrix[4][4], ownLoc[3]; float curveMin[3], curveMax[3]; - Mat4CpyMat4(obmat, cob->matrix); - Mat4One(targetMatrix); + copy_m4_m4(obmat, cob->matrix); + unit_m4(targetMatrix); VECCOPY(ownLoc, obmat[3]); INIT_MINMAX(curveMin, curveMax) @@ -2931,7 +2931,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* 1. determine which axis to sample on? */ if (data->flag == CLAMPTO_AUTO) { float size[3]; - VecSubf(size, curveMax, curveMin); + sub_v3_v3v3(size, curveMax, curveMin); /* find axis along which the bounding box has the greatest * extent. Otherwise, default to the x-axis, as that is quite @@ -3004,10 +3004,10 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* 3. position on curve */ if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL) ) { - Mat4One(totmat); + unit_m4(totmat); VECCOPY(totmat[3], vec); - Mat4MulSerie(targetMatrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(targetMatrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); } } @@ -3082,22 +3082,22 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* obtain target effect */ switch (data->from) { case 2: /* scale */ - Mat4ToSize(ct->matrix, dvec); + mat4_to_size( dvec,ct->matrix); break; case 1: /* rotation (convert to degrees first) */ - Mat4ToEulO(ct->matrix, dvec, cob->rotOrder); + mat4_to_eulO( dvec, cob->rotOrder,ct->matrix); for (i=0; i<3; i++) dvec[i] = (float)(dvec[i] / M_PI * 180); break; default: /* location */ - VecCopyf(dvec, ct->matrix[3]); + copy_v3_v3(dvec, ct->matrix[3]); break; } /* extract components of owner's matrix */ VECCOPY(loc, cob->matrix[3]); - Mat4ToEulO(cob->matrix, eul, cob->rotOrder); - Mat4ToSize(cob->matrix, size); + mat4_to_eulO( eul, cob->rotOrder,cob->matrix); + mat4_to_size( size,cob->matrix); /* determine where in range current transforms lie */ if (data->expo) { @@ -3146,12 +3146,12 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * loc[i]= (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]))); /* add original location back on (so that it can still be moved) */ - VecAddf(loc, cob->matrix[3], loc); + add_v3_v3v3(loc, cob->matrix[3], loc); break; } /* apply to matrix */ - LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder); + loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder); } } @@ -3223,7 +3223,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr hit.index = -1; hit.dist = 100000.0f; //TODO should use FLT_MAX.. but normal projection doenst yet supports it - Mat4One(ct->matrix); + unit_m4(ct->matrix); if(target != NULL) { @@ -3249,8 +3249,8 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr BLI_bvhtree_find_nearest(treeData.tree, co, &nearest, treeData.nearest_callback, &treeData); - dist = VecLenf(co, nearest.co); - VecLerpf(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ + dist = len_v3v3(co, nearest.co); + interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ space_transform_invert(&transform, co); break; @@ -3265,7 +3265,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr break; } - Normalize(no); + normalize_v3(no); bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6); @@ -3295,7 +3295,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr } /* co is in local object coordinates, change it to global and update target position */ - VecMat4MulVecfl(co, cob->matrix, co); + mul_v3_m4v3(co, cob->matrix, co); VECCOPY(ct->matrix[3], co); } } @@ -3379,23 +3379,23 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * float rmat[3][3], tmat[4][4]; /* find the (unit) direction that the axis we're interested in currently points - * - Mat4Mul3Vecfl() only takes the 3x3 (rotation+scaling) components of the 4x4 matrix + * - mul_mat3_m4_v3() only takes the 3x3 (rotation+scaling) components of the 4x4 matrix * - the normalisation step at the end should take care of any unwanted scaling * left over in the 3x3 matrix we used */ VECCOPY(obvec, track_dir_vecs[data->trackflag]); - Mat4Mul3Vecfl(cob->matrix, obvec); + mul_mat3_m4_v3(cob->matrix, obvec); - if (Normalize(obvec) == 0.0f) { + if (normalize_v3(obvec) == 0.0f) { /* exceptional case - just use the track vector as appropriate */ VECCOPY(obvec, track_dir_vecs[data->trackflag]); } /* find the (unit) direction vector going from the owner to the target */ VECCOPY(obloc, cob->matrix[3]); - VecSubf(tarvec, ct->matrix[3], obloc); + sub_v3_v3v3(tarvec, ct->matrix[3], obloc); - if (Normalize(tarvec) == 0.0f) { + if (normalize_v3(tarvec) == 0.0f) { /* the target is sitting on the owner, so just make them use the same direction vectors */ // FIXME: or would it be better to use the pure direction vector? VECCOPY(tarvec, obvec); @@ -3410,23 +3410,23 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * * - the min/max wrappers around (obvec . tarvec) result (stored temporarily in rangle) * are used to ensure that the smallest angle is chosen */ - Crossf(raxis, obvec, tarvec); + cross_v3_v3v3(raxis, obvec, tarvec); - rangle= Inpf(obvec, tarvec); + rangle= dot_v3v3(obvec, tarvec); rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) ); /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first */ - AxisAngleToMat3(raxis, rangle, rmat); + axis_angle_to_mat3( rmat,raxis, rangle); /* rotate the owner in the way defined by this rotation matrix, then reapply the location since * we may have destroyed that in the process of multiplying the matrix */ - Mat4One(tmat); - Mat4MulMat34(tmat, rmat, cob->matrix); // m1, m3, m2 + unit_m4(tmat); + mul_m4_m3m4(tmat, rmat, cob->matrix); // m1, m3, m2 - Mat4CpyMat4(cob->matrix, tmat); + copy_m4_m4(cob->matrix, tmat); VECCOPY(cob->matrix[3], obloc); } } @@ -3510,7 +3510,7 @@ static void splineik_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrai * might end up calling this... */ if (ct) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } static bConstraintTypeInfo CTI_SPLINEIK = { @@ -3772,12 +3772,12 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, cob->ob= (Object *)ownerdata; cob->pchan= NULL; if (cob->ob) { - Mat4CpyMat4(cob->matrix, cob->ob->obmat); - Mat4CpyMat4(cob->startmat, cob->matrix); + copy_m4_m4(cob->matrix, cob->ob->obmat); + copy_m4_m4(cob->startmat, cob->matrix); } else { - Mat4One(cob->matrix); - Mat4One(cob->startmat); + unit_m4(cob->matrix); + unit_m4(cob->startmat); } } break; @@ -3786,12 +3786,12 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, cob->ob= NULL; /* this might not work at all :/ */ cob->pchan= (bPoseChannel *)ownerdata; if (cob->pchan) { - Mat4CpyMat4(cob->matrix, cob->pchan->pose_mat); - Mat4CpyMat4(cob->startmat, cob->matrix); + copy_m4_m4(cob->matrix, cob->pchan->pose_mat); + copy_m4_m4(cob->startmat, cob->matrix); } else { - Mat4One(cob->matrix); - Mat4One(cob->startmat); + unit_m4(cob->matrix); + unit_m4(cob->startmat); } } break; @@ -3808,7 +3808,7 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, if (ct) { if (cti->get_target_matrix) cti->get_target_matrix(con, cob, ct, ctime); - Mat4CpyMat4(mat, ct->matrix); + copy_m4_m4(mat, ct->matrix); } /* free targets + 'constraint-ob' */ @@ -3818,7 +3818,7 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, } else { /* invalid constraint - perhaps... */ - Mat4One(mat); + unit_m4(mat); } } @@ -3861,7 +3861,7 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) /* move owner matrix into right space */ constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace); - Mat4CpyMat4(oldmat, cob->matrix); + copy_m4_m4(oldmat, cob->matrix); /* prepare targets for constraint solving */ if (cti->get_constraint_targets) { @@ -3882,7 +3882,7 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) } else { for (ct= targets.first; ct; ct= ct->next) - Mat4One(ct->matrix); + unit_m4(ct->matrix); } } @@ -3899,21 +3899,21 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) /* Interpolate the enforcement, to blend result of constraint into final owner transform */ /* 1. Remove effects of original matrix from constraint solution ==> delta */ - Mat4Invert(imat, oldmat); - Mat4CpyMat4(solution, cob->matrix); - Mat4MulMat4(delta, solution, imat); + invert_m4_m4(imat, oldmat); + copy_m4_m4(solution, cob->matrix); + mul_m4_m4m4(delta, solution, imat); /* 2. If constraint influence is not full strength, then interpolate * identity_matrix --> delta_matrix to get the effect the constraint actually exerts */ if (enf < 1.0) { float identity[4][4]; - Mat4One(identity); - Mat4BlendMat4(delta, identity, delta, enf); + unit_m4(identity); + blend_m4_m4m4(delta, identity, delta, enf); } /* 3. Now multiply the delta by the matrix in use before the evaluation */ - Mat4MulMat4(cob->matrix, delta, oldmat); + mul_m4_m4m4(cob->matrix, delta, oldmat); /* move owner back into worldspace for next constraint/other business */ if ((con->flag & CONSTRAINT_SPACEONCE) == 0) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 1410e5d29c2..83e2e0c29d9 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -40,7 +40,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_object_types.h" #include "DNA_curve_types.h" @@ -992,7 +992,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float for(i=0; i<3; i++) { p[i]= (-6*t + 6)*p0[i] + (18*t - 12)*p1[i] + (-18*t + 6)*p2[i] + (6*t)*p3[i]; } - Normalize(p); + normalize_v3(p); p = (float *)(((char *)p)+stride); } } @@ -1598,7 +1598,7 @@ static void bevel_list_calc_bisect(BevList *bl) nr= bl->nr; while(nr--) { /* totally simple */ - VecBisect3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); + bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); bevp0= bevp1; bevp1= bevp2; @@ -1616,8 +1616,8 @@ static void bevel_list_flip_tangents(BevList *bl) nr= bl->nr; while(nr--) { - if(RAD2DEG(VecAngle2(bevp0->tan, bevp1->tan)) > 90) - VecNegf(bevp1->tan); + if(RAD2DEG(angle_v2v2(bevp0->tan, bevp1->tan)) > 90) + negate_v3(bevp1->tan); bevp0= bevp1; bevp1= bevp2; @@ -1637,9 +1637,9 @@ static void bevel_list_apply_tilt(BevList *bl) nr= bl->nr; while(nr--) { - AxisAngleToQuat(q, bevp1->dir, bevp1->alfa); - QuatMul(bevp1->quat, q, bevp1->quat); - NormalQuat(bevp1->quat); + axis_angle_to_quat(q, bevp1->dir, bevp1->alfa); + mul_qt_qtqt(bevp1->quat, q, bevp1->quat); + normalize_qt(bevp1->quat); bevp0= bevp1; bevp1= bevp2; @@ -1683,18 +1683,18 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) while(nr--) { /* interpolate quats */ float zaxis[3] = {0,0,1}, cross[3], q2[4]; - QuatInterpol(q, bevp0_quat, bevp2->quat, 0.5); - NormalQuat(q); + interp_qt_qtqt(q, bevp0_quat, bevp2->quat, 0.5); + normalize_qt(q); - QuatMulVecf(q, zaxis); - Crossf(cross, zaxis, bevp1->dir); - AxisAngleToQuat(q2, cross, NormalizedVecAngle2(zaxis, bevp1->dir)); - NormalQuat(q2); + mul_qt_v3(q, zaxis); + cross_v3_v3v3(cross, zaxis, bevp1->dir); + axis_angle_to_quat(q2, cross, angle_normalized_v3v3(zaxis, bevp1->dir)); + normalize_qt(q2); QUATCOPY(bevp0_quat, bevp1->quat); - QuatMul(q, q2, q); - QuatInterpol(bevp1->quat, bevp1->quat, q, 0.5); - NormalQuat(bevp1->quat); + mul_qt_qtqt(q, q2, q); + interp_qt_qtqt(bevp1->quat, bevp1->quat, q, 0.5); + normalize_qt(bevp1->quat); bevp0= bevp1; @@ -1716,8 +1716,8 @@ static void make_bevel_list_3D_zup(BevList *bl) nr= bl->nr; while(nr--) { /* totally simple */ - VecBisect3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); - vectoquat(bevp1->dir, 5, 1, bevp1->quat); + bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); + vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); bevp0= bevp1; bevp1= bevp2; @@ -1743,15 +1743,15 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) while(nr--) { if(nr+4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */ - vectoquat(bevp1->dir, 5, 1, bevp1->quat); + vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); } else { - float angle= NormalizedVecAngle2(bevp0->dir, bevp1->dir); + float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir); if(angle > 0.0f) { /* otherwise we can keep as is */ - Crossf(cross_tmp, bevp0->dir, bevp1->dir); - AxisAngleToQuat(q, cross_tmp, angle); - QuatMul(bevp1->quat, q, bevp0->quat); + cross_v3_v3v3(cross_tmp, bevp0->dir, bevp1->dir); + axis_angle_to_quat(q, cross_tmp, angle); + mul_qt_qtqt(bevp1->quat, q, bevp0->quat); } else { QUATCOPY(bevp1->quat, bevp0->quat); @@ -1788,26 +1788,26 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) bevp_last--; /* quats and vec's are normalized, should not need to re-normalize */ - QuatMulVecf(bevp_first->quat, vec_1); - QuatMulVecf(bevp_last->quat, vec_2); - Normalize(vec_1); - Normalize(vec_2); + mul_qt_v3(bevp_first->quat, vec_1); + mul_qt_v3(bevp_last->quat, vec_2); + normalize_v3(vec_1); + normalize_v3(vec_2); /* align the vector, can avoid this and it looks 98% OK but * better to align the angle quat roll's before comparing */ { - Crossf(cross_tmp, bevp_last->dir, bevp_first->dir); - angle = NormalizedVecAngle2(bevp_first->dir, bevp_last->dir); - AxisAngleToQuat(q, cross_tmp, angle); - QuatMulVecf(q, vec_2); + cross_v3_v3v3(cross_tmp, bevp_last->dir, bevp_first->dir); + angle = angle_normalized_v3v3(bevp_first->dir, bevp_last->dir); + axis_angle_to_quat(q, cross_tmp, angle); + mul_qt_v3(q, vec_2); } - angle= NormalizedVecAngle2(vec_1, vec_2); + angle= angle_normalized_v3v3(vec_1, vec_2); /* flip rotation if needs be */ - Crossf(cross_tmp, vec_1, vec_2); - Normalize(cross_tmp); - if(NormalizedVecAngle2(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI)) + cross_v3_v3v3(cross_tmp, vec_1, vec_2); + normalize_v3(cross_tmp); + if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI)) angle = -angle; bevp2= (BevPoint *)(bl+1); @@ -1818,8 +1818,8 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) while(nr--) { ang_fac= angle * (1.0f-((float)nr/bl->nr)); /* also works */ - AxisAngleToQuat(q, bevp1->dir, ang_fac); - QuatMul(bevp1->quat, q, bevp1->quat); + axis_angle_to_quat(q, bevp1->dir, ang_fac); + mul_qt_qtqt(bevp1->quat, q, bevp1->quat); bevp0= bevp1; bevp1= bevp2; @@ -1848,9 +1848,9 @@ static void make_bevel_list_3D_tangent(BevList *bl) nr= bl->nr; while(nr--) { - Crossf(cross_tmp, bevp1->tan, bevp1->dir); - Crossf(bevp1->tan, cross_tmp, bevp1->dir); - Normalize(bevp1->tan); + cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); + cross_v3_v3v3(bevp1->tan, cross_tmp, bevp1->dir); + normalize_v3(bevp1->tan); bevp0= bevp1; bevp1= bevp2; @@ -1872,9 +1872,9 @@ static void make_bevel_list_3D_tangent(BevList *bl) float cross_tmp[3]; float zero[3] = {0,0,0}; - Crossf(cross_tmp, bevp1->tan, bevp1->dir); - Normalize(cross_tmp); - triatoquat(zero, cross_tmp, bevp1->tan, bevp1->quat); /* XXX - could be faster */ + cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); + normalize_v3(cross_tmp); + tri_to_quat( bevp1->quat,zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ bevp0= bevp1; bevp1= bevp2; @@ -2280,14 +2280,14 @@ void makeBevelList(Object *ob) bevp1= bevp2+1; /* simple quat/dir */ - VecSubf(bevp1->dir, bevp1->vec, bevp2->vec); - Normalize(bevp1->dir); + sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp2->vec); + normalize_v3(bevp1->dir); - vectoquat(bevp1->dir, 5, 1, bevp1->quat); + vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); - AxisAngleToQuat(q, bevp1->dir, bevp1->alfa); - QuatMul(bevp1->quat, q, bevp1->quat); - NormalQuat(bevp1->quat); + axis_angle_to_quat(q, bevp1->dir, bevp1->alfa); + mul_qt_qtqt(bevp1->quat, q, bevp1->quat); + normalize_qt(bevp1->quat); VECCOPY(bevp2->dir, bevp1->dir); QUATCOPY(bevp2->quat, bevp1->quat); } @@ -2421,10 +2421,10 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) if(leftviolate || rightviolate) { /* align left handle */ float h1[3], h2[3]; - VecSubf(h1, p2-3, p2); - VecSubf(h2, p2, p2+3); - len1= Normalize(h1); - len2= Normalize(h2); + sub_v3_v3v3(h1, p2-3, p2); + sub_v3_v3v3(h2, p2, p2+3); + len1= normalize_v3(h1); + len2= normalize_v3(h2); vz= INPR(h1, h2); @@ -2460,8 +2460,8 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) *(p2+5)= *(p2+2)+dz1; } - len2= VecLenf(p2, p2+3); - len1= VecLenf(p2, p2-3); + len2= len_v3v3(p2, p2+3); + len1= len_v3v3(p2, p2-3); if(len1==0.0) len1=1.0; if(len2==0.0) len2=1.0; @@ -2588,18 +2588,18 @@ void autocalchandlesNurb(Nurb *nu, int flag) if(flag==0 || (bezt1->f1 & flag) ) { bezt1->h1= 0; /* distance too short: vectorhandle */ - if( VecLenf( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) { + if( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) { bezt1->h1= HD_VECT; leftsmall= 1; } else { /* aligned handle? */ - if(DistVL2Dfl(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) { + if(dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) { align= 1; bezt1->h1= HD_ALIGN; } /* or vector handle? */ - if(DistVL2Dfl(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001) + if(dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001) bezt1->h1= HD_VECT; } @@ -2608,7 +2608,7 @@ void autocalchandlesNurb(Nurb *nu, int flag) if(flag==0 || (bezt1->f3 & flag) ) { bezt1->h2= 0; /* distance too short: vectorhandle */ - if( VecLenf( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) { + if( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) { bezt1->h2= HD_VECT; rightsmall= 1; } @@ -2617,7 +2617,7 @@ void autocalchandlesNurb(Nurb *nu, int flag) if(align) bezt1->h2= HD_ALIGN; /* or vector handle? */ - if(DistVL2Dfl(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001) + if(dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001) bezt1->h2= HD_VECT; } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 28aaadea9c3..7b754025b6c 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -34,7 +34,7 @@ #include "BKE_customdata.h" #include "BKE_utildefines.h" // CLAMP -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_mempool.h" @@ -410,21 +410,21 @@ static void mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, fl vrat = v - y; uopp = 1 - urat; - VecCopyf(d[0], disps[y * st + x]); - VecCopyf(d[1], disps[y * st + x2]); - VecCopyf(d[2], disps[y2 * st + x]); - VecCopyf(d[3], disps[y2 * st + x2]); - VecMulf(d[0], uopp); - VecMulf(d[1], urat); - VecMulf(d[2], uopp); - VecMulf(d[3], urat); + copy_v3_v3(d[0], disps[y * st + x]); + copy_v3_v3(d[1], disps[y * st + x2]); + copy_v3_v3(d[2], disps[y2 * st + x]); + copy_v3_v3(d[3], disps[y2 * st + x2]); + mul_v3_fl(d[0], uopp); + mul_v3_fl(d[1], urat); + mul_v3_fl(d[2], uopp); + mul_v3_fl(d[3], urat); - VecAddf(d2[0], d[0], d[1]); - VecAddf(d2[1], d[2], d[3]); - VecMulf(d2[0], 1 - vrat); - VecMulf(d2[1], vrat); + add_v3_v3v3(d2[0], d[0], d[1]); + add_v3_v3v3(d2[1], d[2], d[3]); + mul_v3_fl(d2[0], 1 - vrat); + mul_v3_fl(d2[1], vrat); - VecAddf(out, d2[0], d2[1]); + add_v3_v3v3(out, d2[0], d2[1]); } static void layerSwap_mdisps(void *data, int *ci) @@ -440,7 +440,7 @@ static void layerSwap_mdisps(void *data, int *ci) for(y = 0; y < st; ++y) { for(x = 0; x < st; ++x) { - VecCopyf(d[(st - y - 1) * st + (st - x - 1)], s->disps[y * st + x]); + copy_v3_v3(d[(st - y - 1) * st + (st - x - 1)], s->disps[y * st + x]); } } @@ -462,7 +462,7 @@ static void layerInterp_mdisps(void **sources, float *weights, float *sub_weight /* Initialize the destination */ for(i = 0; i < d->totdisp; ++i) { float z[3] = {0,0,0}; - VecCopyf(d->disps[i], z); + copy_v3_v3(d->disps[i], z); } /* For now, some restrictions on the input */ @@ -493,7 +493,7 @@ static void layerInterp_mdisps(void **sources, float *weights, float *sub_weight float srcdisp[3]; mdisps_bilinear(srcdisp, s->disps, st, mid3[0], mid3[1]); - VecCopyf(d->disps[y * st + x], srcdisp); + copy_v3_v3(d->disps[y * st + x], srcdisp); } } } diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index b7949a6e06f..c1e45243bb5 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -59,7 +59,7 @@ #include "BKE_mesh.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 36568ee5667..8b848ac5371 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -34,7 +34,7 @@ #endif #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 64af08d6f6a..57d8de73002 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -56,7 +56,7 @@ #include "DNA_key_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_edgehash.h" @@ -220,12 +220,12 @@ void addnormalsDispList(Object *ob, ListBase *lb) for(; bnr; b++) { - CalcNormFloat4(v1, v3, v4, v2, nor); + normal_quad_v3( nor,v1, v3, v4, v2); - VecAddf(n1, n1, nor); - VecAddf(n2, n2, nor); - VecAddf(n3, n3, nor); - VecAddf(n4, n4, nor); + add_v3_v3v3(n1, n1, nor); + add_v3_v3v3(n2, n2, nor); + add_v3_v3v3(n3, n3, nor); + add_v3_v3v3(n4, n4, nor); v2= v1; v1+= 3; v4= v3; v3+= 3; @@ -236,7 +236,7 @@ void addnormalsDispList(Object *ob, ListBase *lb) a= dl->parts*dl->nr; v1= ndata; while(a--) { - Normalize(v1); + normalize_v3(v1); v1+= 3; } } @@ -475,11 +475,11 @@ static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, floa init_fastshade_shadeinput(re); RE_DataBase_GetView(re, tmat); - Mat4MulMat4(mat, ob->obmat, tmat); + mul_m4_m4m4(mat, ob->obmat, tmat); - Mat4Invert(tmat, mat); - Mat3CpyMat4(imat, tmat); - if(ob->transflag & OB_NEG_SCALE) Mat3MulFloat((float *)imat, -1.0); + invert_m4_m4(tmat, mat); + copy_m3_m4(imat, tmat); + if(ob->transflag & OB_NEG_SCALE) mul_m3_fl((float *)imat, -1.0); if (need_orco_r) *need_orco_r= 0; for(a=0; atotcol; a++) { @@ -563,7 +563,7 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - Normalize(vn); + normalize_v3(vn); } for (i=0; iv4) - CalcNormFloat4(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co, nor); + normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); else - CalcNormFloat(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, nor); + normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); } n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - Normalize(n1); + normalize_v3(n1); for (j=0; jflag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; VECCOPY(vec, mv->co); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); vec[0]+= 0.001*vn[0]; vec[1]+= 0.001*vn[1]; vec[2]+= 0.001*vn[2]; @@ -708,14 +708,14 @@ void shadeDispList(Scene *scene, Base *base) n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2]; n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2]; n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2]; - Normalize(n1); + normalize_v3(n1); fp= dl->verts; a= dl->nr; while(a--) { VECCOPY(vec, fp); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); fastshade(vec, n1, fp, ma, (char *)col1, NULL); @@ -731,12 +731,12 @@ void shadeDispList(Scene *scene, Base *base) while(a--) { VECCOPY(vec, fp); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - Normalize(n1); + normalize_v3(n1); fastshade(vec, n1, fp, ma, (char *)col1, NULL); @@ -769,13 +769,13 @@ void shadeDispList(Scene *scene, Base *base) a= dl->nr; while(a--) { VECCOPY(vec, fp); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); /* transpose ! */ n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - Normalize(n1); + normalize_v3(n1); fastshade(vec, n1, fp, ma, (char *)col1, NULL); @@ -1612,7 +1612,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) vec[1]= fp1[2]; vec[2]= 0.0; - QuatMulVecf(bevp->quat, vec); + mul_qt_v3(bevp->quat, vec); data[0]= bevp->vec[0] + fac*vec[0]; data[1]= bevp->vec[1] + fac*vec[1]; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 9b648e2c05c..6d63553396d 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -52,7 +52,7 @@ #include "DNA_texture_types.h" #include "DNA_scene_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_listbase.h" @@ -221,8 +221,8 @@ static void precalculate_effector(EffectorCache *eff) if(cu->path && cu->path->data) { where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius); - Mat4MulVecfl(eff->ob->obmat, eff->guide_loc); - Mat4Mul3Vecfl(eff->ob->obmat, eff->guide_dir); + mul_m4_v3(eff->ob->obmat, eff->guide_loc); + mul_mat3_m4_v3(eff->ob->obmat, eff->guide_dir); } } } @@ -433,8 +433,8 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect return visibility; VECCOPY(norm, efd->vec_to_point); - VecNegf(norm); - len = Normalize(norm); + negate_v3(norm); + len = normalize_v3(norm); // check all collision objects for(col = colls->first; col; col = col->next) @@ -520,7 +520,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi float falloff = weights ? weights->weight[0] * weights->weight[eff->pd->forcefield] : 1.0f; float fac, r_fac; - fac = Inpf(efd->nor, efd->vec_to_point2); + fac = dot_v3v3(efd->nor, efd->vec_to_point2); if(eff->pd->zdir == PFIELD_Z_POS && fac < 0.0f) falloff=0.0f; @@ -537,7 +537,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi break; VECADDFAC(temp, efd->vec_to_point, efd->nor, -fac); - r_fac= VecLength(temp); + r_fac= len_v3(temp); falloff*= falloff_func_rad(eff->pd, r_fac); break; case PFIELD_FALL_CONE: @@ -545,7 +545,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi if(falloff == 0.0f) break; - r_fac=saacos(fac/VecLength(efd->vec_to_point))*180.0f/(float)M_PI; + r_fac=saacos(fac/len_v3(efd->vec_to_point))*180.0f/(float)M_PI; falloff*= falloff_func_rad(eff->pd, r_fac); break; @@ -574,12 +574,12 @@ int closest_point_on_surface(SurfaceModifierData *surmd, float *co, float *surfa MFace *mface = CDDM_get_face(surmd->dm, nearest.index); VECCOPY(surface_vel, surmd->v[mface->v1].co); - VecAddf(surface_vel, surface_vel, surmd->v[mface->v2].co); - VecAddf(surface_vel, surface_vel, surmd->v[mface->v3].co); + add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v2].co); + add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v3].co); if(mface->v4) - VecAddf(surface_vel, surface_vel, surmd->v[mface->v4].co); + add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v4].co); - VecMulf(surface_vel, mface->v4 ? 0.25f : 0.333f); + mul_v3_fl(surface_vel, mface->v4 ? 0.25f : 0.333f); } return 1; } @@ -596,9 +596,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin float vec[3]; /* using velocity corrected location allows for easier sliding over effector surface */ - VecCopyf(vec, point->vel); - VecMulf(vec, point->vel_to_frame); - VecAddf(vec, vec, point->loc); + copy_v3_v3(vec, point->vel); + mul_v3_fl(vec, point->vel_to_frame); + add_v3_v3v3(vec, vec, point->loc); ret = closest_point_on_surface(eff->surmd, vec, efd->loc, efd->nor, real_velocity ? efd->vel : NULL); @@ -612,10 +612,10 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin dm->getVertCo(dm, *efd->index, efd->loc); dm->getVertNo(dm, *efd->index, efd->nor); - Mat4MulVecfl(eff->ob->obmat, efd->loc); - Mat4Mul3Vecfl(eff->ob->obmat, efd->nor); + mul_m4_v3(eff->ob->obmat, efd->loc); + mul_mat3_m4_v3(eff->ob->obmat, efd->nor); - Normalize(efd->nor); + normalize_v3(efd->nor); efd->size = 0.0f; @@ -660,15 +660,15 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin /* use z-axis as normal*/ VECCOPY(efd->nor, ob->obmat[2]); - Normalize(efd->nor); + normalize_v3(efd->nor); /* for vortex the shape chooses between old / new force */ if(eff->pd->shape == PFIELD_SHAPE_PLANE) { /* efd->loc is closes point on effector xy-plane */ float temp[3]; - VecSubf(temp, point->loc, ob->obmat[3]); - Projf(efd->loc, temp, efd->nor); - VecSubf(efd->loc, point->loc, efd->loc); + sub_v3_v3v3(temp, point->loc, ob->obmat[3]); + project_v3_v3v3(efd->loc, temp, efd->nor); + sub_v3_v3v3(efd->loc, point->loc, efd->loc); } else { VECCOPY(efd->loc, ob->obmat[3]); @@ -679,7 +679,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin where_is_object_time(eff->scene, ob, cfra - 1.0); - VecSubf(efd->vel, efd->vel, ob->obmat[3]); + sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]); } *eff->ob = obcopy; @@ -690,8 +690,8 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin } if(ret) { - VecSubf(efd->vec_to_point, point->loc, efd->loc); - efd->distance = VecLength(efd->vec_to_point); + sub_v3_v3v3(efd->vec_to_point, point->loc, efd->loc); + efd->distance = len_v3(efd->vec_to_point); if(eff->flag & PE_USE_NORMAL_DATA) { VECCOPY(efd->vec_to_point2, efd->vec_to_point); @@ -699,9 +699,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin } else { /* for some effectors we need the object center every time */ - VecSubf(efd->vec_to_point2, point->loc, eff->ob->obmat[3]); + sub_v3_v3v3(efd->vec_to_point2, point->loc, eff->ob->obmat[3]); VECCOPY(efd->nor2, eff->ob->obmat[2]); - Normalize(efd->nor2); + normalize_v3(efd->nor2); } } @@ -764,12 +764,12 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP VECCOPY(tex_co,point->loc); if(eff->pd->flag & PFIELD_TEX_2D) { - float fac=-Inpf(tex_co, efd->nor); + float fac=-dot_v3v3(tex_co, efd->nor); VECADDFAC(tex_co, tex_co, efd->nor, fac); } if(eff->pd->flag & PFIELD_TEX_OBJECT) { - Mat4Mul3Vecfl(eff->ob->obmat, tex_co); + mul_mat3_m4_v3(eff->ob->obmat, tex_co); } hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 1, result); @@ -815,11 +815,11 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP } if(eff->pd->flag & PFIELD_TEX_2D){ - float fac = -Inpf(force, efd->nor); + float fac = -dot_v3v3(force, efd->nor); VECADDFAC(force, force, efd->nor, fac); } - VecAddf(total_force, total_force, force); + add_v3_v3v3(total_force, total_force, force); } void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force) { @@ -844,51 +844,51 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * switch(pd->forcefield){ case PFIELD_WIND: VECCOPY(force, efd->nor); - VecMulf(force, strength * efd->falloff); + mul_v3_fl(force, strength * efd->falloff); break; case PFIELD_FORCE: - Normalize(force); - VecMulf(force, strength * efd->falloff); + normalize_v3(force); + mul_v3_fl(force, strength * efd->falloff); break; case PFIELD_VORTEX: /* old vortex force */ if(pd->shape == PFIELD_SHAPE_POINT) { - Crossf(force, efd->nor, efd->vec_to_point); - Normalize(force); - VecMulf(force, strength * efd->distance * efd->falloff); + cross_v3_v3v3(force, efd->nor, efd->vec_to_point); + normalize_v3(force); + mul_v3_fl(force, strength * efd->distance * efd->falloff); } else { /* new vortex force */ - Crossf(temp, efd->nor2, efd->vec_to_point2); - VecMulf(temp, strength * efd->falloff); + cross_v3_v3v3(temp, efd->nor2, efd->vec_to_point2); + mul_v3_fl(temp, strength * efd->falloff); - Crossf(force, efd->nor2, temp); - VecMulf(force, strength * efd->falloff); + cross_v3_v3v3(force, efd->nor2, temp); + mul_v3_fl(force, strength * efd->falloff); VECADDFAC(temp, temp, point->vel, -point->vel_to_sec); - VecAddf(force, force, temp); + add_v3_v3v3(force, force, temp); } break; case PFIELD_MAGNET: if(eff->pd->shape == PFIELD_SHAPE_POINT) /* magnetic field of a moving charge */ - Crossf(temp, efd->nor, efd->vec_to_point); + cross_v3_v3v3(temp, efd->nor, efd->vec_to_point); else - VecCopyf(temp, efd->nor); + copy_v3_v3(temp, efd->nor); - Normalize(temp); - VecMulf(temp, strength * efd->falloff); - Crossf(force, point->vel, temp); - VecMulf(force, point->vel_to_sec); + normalize_v3(temp); + mul_v3_fl(temp, strength * efd->falloff); + cross_v3_v3v3(force, point->vel, temp); + mul_v3_fl(force, point->vel_to_sec); break; case PFIELD_HARMONIC: - VecMulf(force, -strength * efd->falloff); - VecCopyf(temp, point->vel); - VecMulf(temp, -damp * 2.0f * (float)sqrt(fabs(strength)) * point->vel_to_sec); - VecAddf(force, force, temp); + mul_v3_fl(force, -strength * efd->falloff); + copy_v3_v3(temp, point->vel); + mul_v3_fl(temp, -damp * 2.0f * (float)sqrt(fabs(strength)) * point->vel_to_sec); + add_v3_v3v3(force, force, temp); break; case PFIELD_CHARGE: - VecMulf(force, point->charge * strength * efd->falloff); + mul_v3_fl(force, point->charge * strength * efd->falloff); break; case PFIELD_LENNARDJ: fac = pow((efd->size + point->size) / efd->distance, 6.0); @@ -898,7 +898,7 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * /* limit the repulsive term drastically to avoid huge forces */ fac = ((fac>2.0) ? 2.0 : fac); - VecMulf(force, strength * fac); + mul_v3_fl(force, strength * fac); break; case PFIELD_BOID: /* Boid field is handled completely in boids code. */ @@ -913,16 +913,16 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * force[0] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[0], temp[1], temp[2], 2,0,2); force[1] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[1], temp[2], temp[0], 2,0,2); force[2] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[2], temp[0], temp[1], 2,0,2); - VecMulf(force, strength * efd->falloff); + mul_v3_fl(force, strength * efd->falloff); break; case PFIELD_DRAG: VECCOPY(force, point->vel); - fac = Normalize(force) * point->vel_to_sec; + fac = normalize_v3(force) * point->vel_to_sec; strength = MIN2(strength, 2.0f); damp = MIN2(damp, 2.0f); - VecMulf(force, -efd->falloff * fac * (strength * fac + damp)); + mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp)); break; } @@ -937,12 +937,12 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * if(pd->flag & PFIELD_DO_ROTATION && point->ave && point->rot) { float xvec[3] = {1.0f, 0.0f, 0.0f}; float dave[3]; - QuatMulVecf(point->rot, xvec); - Crossf(dave, xvec, force); + mul_qt_v3(point->rot, xvec); + cross_v3_v3v3(dave, xvec, force); if(pd->f_flow != 0.0f) { VECADDFAC(dave, dave, point->ave, -pd->f_flow * efd->falloff); } - VecAddf(point->ave, point->ave, dave); + add_v3_v3v3(point->ave, point->ave, dave); } } diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 8827897a509..48a05c2f6a7 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -64,7 +64,7 @@ #include "BKE_utildefines.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BKE_blender.h" @@ -180,7 +180,7 @@ static void mesh_add_normals_flags(Mesh *me) v3= me->mvert+mface->v3; v4= me->mvert+mface->v4; - CalcNormFloat(v1->co, v2->co, v3->co, nor); + normal_tri_v3( nor,v1->co, v2->co, v3->co); sno[0]= 32767.0*nor[0]; sno[1]= 32767.0*nor[1]; sno[2]= 32767.0*nor[2]; @@ -1249,7 +1249,7 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb) VECCOPY(bp->vec, data); if(coordtype==4) { bp->vec[3]= data[3]; - VecMulf(bp->vec, 1.0f/data[3]); + mul_v3_fl(bp->vec, 1.0f/data[3]); } else bp->vec[3]= 1.0; data+= coordtype; @@ -1837,7 +1837,7 @@ static void write_vert_stl(Object *ob, MVert *verts, int index, FILE *fpSTL) float vert[3]; VECCOPY(vert, verts[(index)].co); - Mat4MulVecfl(ob->obmat, vert); + mul_m4_v3(ob->obmat, vert); if (ENDIAN_ORDER==B_ENDIAN) { SWITCH_INT(vert[0]); @@ -2174,7 +2174,7 @@ static void write_camera_vrml(FILE *fp, Object *ob) Camera *cam; if(ob==0) return; - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); fprintf(fp, "\tMatrixTransform {\n"); @@ -3031,10 +3031,10 @@ static void dxf_read_line(Scene *scene, int noob) { mvert= &me->mvert[(me->totvert-2)]; - VecSubf(mvert->co, cent, vcenter); + sub_v3_v3v3(mvert->co, cent, vcenter); mvert++; if (vspace) { VECCOPY(mvert->co, epoint); - } else VecSubf(mvert->co, epoint, vcenter); + } else sub_v3_v3v3(mvert->co, epoint, vcenter); mface= &(((MFace*)me->mface)[me->totface-1]); mface->v1= me->totvert-2; @@ -3237,7 +3237,7 @@ static void dxf_read_ellipse(Scene *scene, int noob) if (vspace) { VECCOPY(mvert->co, epoint); } else { - VecSubf(mvert->co, epoint, vcenter); + sub_v3_v3v3(mvert->co, epoint, vcenter); } if (v > 0) { @@ -3360,7 +3360,7 @@ static void dxf_read_arc(Scene *scene, int noob) if (vspace) { VECCOPY(mvert->co, epoint); } else { - VecSubf(mvert->co, epoint, vcenter); + sub_v3_v3v3(mvert->co, epoint, vcenter); } if (v > 0) { @@ -3470,7 +3470,7 @@ static void dxf_read_polyline(Scene *scene, int noob) { mvert= &me->mvert[me->totvert-1]; if (vspace) { VECCOPY(mvert->co, vert); - } else VecSubf(mvert->co, vert, vcenter); + } else sub_v3_v3v3(mvert->co, vert, vcenter); } /* make edges */ @@ -3556,7 +3556,7 @@ static void dxf_read_polyline(Scene *scene, int noob) { mvert= &me->mvert[(me->totvert-1)]; if (vspace) { VECCOPY(mvert->co, vert); - } else VecSubf(mvert->co, vert, vcenter); + } else sub_v3_v3v3(mvert->co, vert, vcenter); } else if (vflags & 128) { if(vids[2]==0) { @@ -3687,7 +3687,7 @@ static void dxf_read_lwpolyline(Scene *scene, int noob) { if (vspace) { VECCOPY(mvert->co, vert); } else { - VecSubf(mvert->co, vert, vcenter); + sub_v3_v3v3(mvert->co, vert, vcenter); } if (v > 0) { @@ -3859,20 +3859,20 @@ static void dxf_read_3dface(Scene *scene, int noob) ftmp=NULL; mvert= &me->mvert[(me->totvert-nverts)]; - VecSubf(mvert->co, cent, vcenter); + sub_v3_v3v3(mvert->co, cent, vcenter); mvert++; if (vspace) { VECCOPY(mvert->co, vert2); - } else VecSubf(mvert->co, vert2, vcenter); + } else sub_v3_v3v3(mvert->co, vert2, vcenter); mvert++; if (vspace) { VECCOPY(mvert->co, vert3); - } else VecSubf(mvert->co, vert3, vcenter); + } else sub_v3_v3v3(mvert->co, vert3, vcenter); if (nverts==4) { mvert++; if (vspace) { VECCOPY(mvert->co, vert4); - } else VecSubf(mvert->co, vert4, vcenter); + } else sub_v3_v3v3(mvert->co, vert4, vcenter); } mface= &(((MFace*)me->mface)[me->totface-1]); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 0ecd1fe912b..a1e6570608f 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -43,7 +43,7 @@ #include "DNA_anim_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_noise.h" #include "BKE_fcurve.h" @@ -924,11 +924,11 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) } /* use the final posed locations */ - Mat4ToQuat(pchan->pose_mat, q1); - Mat4ToQuat(pchan2->pose_mat, q2); + mat4_to_quat( q1,pchan->pose_mat); + mat4_to_quat( q2,pchan2->pose_mat); - QuatInv(q1); - QuatMul(quat, q1, q2); + invert_qt(q1); + mul_qt_qtqt(quat, q1, q2); angle = 2.0f * (saacos(quat[0])); angle= ABS(angle); @@ -1017,13 +1017,13 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o) if (d > 0.0) { t= sqrt(d); - o[0]= (float)(Sqrt3d(-q+t) + Sqrt3d(-q-t) - a); + o[0]= (float)(sqrt3d(-q+t) + sqrt3d(-q-t) - a); if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1; else return 0; } else if (d == 0.0) { - t= Sqrt3d(-q); + t= sqrt3d(-q); o[0]= (float)(2*t - a); if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++; diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index aa163b821c8..9453c2a0ad1 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -40,7 +40,7 @@ #include "DNA_particle_types.h" #include "DNA_scene_types.h" // N_T -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_cdderivedmesh.h" @@ -563,13 +563,13 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], float vec[3]; VECCOPY(vec, mvert[0].co); - Mat4MulVecfl(obmat, vec); + mul_m4_v3(obmat, vec); bbsx = vec[0]; bbsy = vec[1]; bbsz = vec[2]; bbex = vec[0]; bbey = vec[1]; bbez = vec[2]; for(i = 1; i < totvert; i++) { VECCOPY(vec, mvert[i].co); - Mat4MulVecfl(obmat, vec); + mul_m4_v3(obmat, vec); if(vec[0] < bbsx){ bbsx= vec[0]; } if(vec[1] < bbsy){ bbsy= vec[1]; } @@ -626,7 +626,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, verts = MEM_callocN( totvert*3*sizeof(float), "elbeemmesh_vertices"); for(i=0; iobmat, &verts[i*3]); } + if(useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i*3]); } } *vertices = verts; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 4e79f6238b5..f70de4983e3 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -41,7 +41,7 @@ #include "DNA_anim_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_noise.h" #include "BKE_fcurve.h" diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 4e05bf45d3d..e2dccf02b40 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_vfontdata.h" @@ -968,12 +968,12 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) float minx, maxx, miny, maxy; float timeofs, sizefac; - Mat4Invert(imat, ob->obmat); - Mat3CpyMat4(imat3, imat); + invert_m4_m4(imat, ob->obmat); + copy_m3_m4(imat3, imat); - Mat3CpyMat4(cmat, cu->textoncurve->obmat); - Mat3MulMat3(cmat, cmat, imat3); - sizefac= Normalize(cmat[0])/cu->fsize; + copy_m3_m4(cmat, cu->textoncurve->obmat); + mul_m3_m3m3(cmat, cmat, imat3); + sizefac= normalize_v3(cmat[0])/cu->fsize; minx=miny= 1.0e20f; maxx=maxy= -1.0e20f; @@ -1042,7 +1042,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL); where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec, NULL, NULL); - VecMulf(vec, sizefac); + mul_v3_fl(vec, sizefac); ct->rot= (float)(M_PI-atan2(rotvec[1], rotvec[0])); @@ -1196,7 +1196,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) vecyo[0] = ct->xof; vecyo[1] = ct->yof; vecyo[2] = 0; - Mat4MulVecfl(ob->obmat, vecyo); + mul_m4_v3(ob->obmat, vecyo); VECCOPY(ob->loc, vecyo); outta = 1; cu->sepchar = 0; diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 43c4137e73e..5023d87cef8 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -36,7 +36,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_listBase.h" diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index efe53f6f8ef..0452b38a2e5 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -61,7 +61,7 @@ #include "DNA_sequence_types.h" #include "DNA_userdef_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index de215ae4af9..073b4e80ae7 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1550,28 +1550,28 @@ static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, CalcFloat(lX[mfaces[i].v1],lX[mfaces[i].v2],lX[mfaces[i].v3],triunnormal); VECCOPY(trinormal, triunnormal); - Normalize(trinormal); + normalize_v3(trinormal); // add wind from v1 VECCOPY(tmp, trinormal); - VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal)); + mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal)); VECADDS(lF[mfaces[i].v1], lF[mfaces[i].v1], tmp, factor); // add wind from v2 VECCOPY(tmp, trinormal); - VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal)); + mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal)); VECADDS(lF[mfaces[i].v2], lF[mfaces[i].v2], tmp, factor); // add wind from v3 VECCOPY(tmp, trinormal); - VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal)); + mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal)); VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor); // add wind from v4 if(mfaces[i].v4) { VECCOPY(tmp, trinormal); - VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal)); + mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal)); VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor); } } @@ -1652,7 +1652,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase if(verts [i].flags & CLOTH_VERT_FLAG_PINNED) { VECSUB(id->V[i], verts[i].xconst, verts[i].xold); - // VecMulf(id->V[i], clmd->sim_parms->stepsPerFrame); + // mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame); } } } @@ -1725,7 +1725,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase VECCOPY(id->Xnew[i], verts[i].tx); VECCOPY(id->Vnew[i], verts[i].tv); - VecMulf(id->Vnew[i], clmd->sim_parms->stepsPerFrame); + mul_v3_fl(id->Vnew[i], clmd->sim_parms->stepsPerFrame); } } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 5dc26143533..9e9a1719952 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -70,7 +70,7 @@ #include "DNA_world_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dynstr.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index c53101299c6..dc548edbb25 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_armature_types.h" #include "DNA_mesh_types.h" @@ -155,10 +155,10 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) /* prevent using deformed locations */ freedisplist(<Ob->disp); - Mat4CpyMat4(mat, ltOb->obmat); - Mat4One(ltOb->obmat); + copy_m4_m4(mat, ltOb->obmat); + unit_m4(ltOb->obmat); lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew*vNew*wNew, NULL); - Mat4CpyMat4(ltOb->obmat, mat); + copy_m4_m4(ltOb->obmat, mat); lt->typeu = typeu; lt->typev = typev; @@ -310,18 +310,18 @@ void init_latt_deform(Object *oblatt, Object *ob) /* for example with a particle system: ob==0 */ if(ob==NULL) { /* in deformspace, calc matrix */ - Mat4Invert(lt->latmat, oblatt->obmat); + invert_m4_m4(lt->latmat, oblatt->obmat); /* back: put in deform array */ - Mat4Invert(imat, lt->latmat); + invert_m4_m4(imat, lt->latmat); } else { /* in deformspace, calc matrix */ - Mat4Invert(imat, oblatt->obmat); - Mat4MulMat4(lt->latmat, ob->obmat, imat); + invert_m4_m4(imat, oblatt->obmat); + mul_m4_m4m4(lt->latmat, ob->obmat, imat); /* back: put in deform array */ - Mat4Invert(imat, lt->latmat); + invert_m4_m4(imat, lt->latmat); } for(w=0,fw=lt->fw; wpntsw; w++,fw+=lt->dw) { @@ -337,7 +337,7 @@ void init_latt_deform(Object *oblatt, Object *ob) fp[2] = bp->vec[2] - fw; } - Mat4Mul3Vecfl(imat, fp); + mul_mat3_m4_v3(imat, fp); } } } @@ -356,7 +356,7 @@ void calc_latt_deform(Object *ob, float *co, float weight) /* co is in local coords, treat with latmat */ VECCOPY(vec, co); - Mat4MulVecfl(lt->latmat, vec); + mul_m4_v3(lt->latmat, vec); /* u v w coords */ @@ -456,15 +456,15 @@ typedef struct { static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc) { - Mat4Invert(ob->imat, ob->obmat); - Mat4MulMat4(cd->objectspace, par->obmat, ob->imat); - Mat4Invert(cd->curvespace, cd->objectspace); - Mat3CpyMat4(cd->objectspace3, cd->objectspace); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_m4m4(cd->objectspace, par->obmat, ob->imat); + invert_m4_m4(cd->curvespace, cd->objectspace); + copy_m3_m4(cd->objectspace3, cd->objectspace); // offset vector for 'no smear' if(dloc) { - Mat4Invert(par->imat, par->obmat); - VecMat4MulVecfl(cd->dloc, par->imat, ob->obmat[3]); + invert_m4_m4(par->imat, par->obmat); + mul_v3_m4v3(cd->dloc, par->imat, ob->obmat[3]); } else cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f; @@ -497,15 +497,15 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, float dvec[3]; if(ctime < 0.0) { - VecSubf(dvec, path->data[1].vec, path->data[0].vec); - VecMulf(dvec, ctime*(float)path->len); + sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec); + mul_v3_fl(dvec, ctime*(float)path->len); VECADD(vec, vec, dvec); if(quat) QUATCOPY(quat, path->data[0].quat); if(radius) *radius= path->data[0].radius; } else if(ctime > 1.0) { - VecSubf(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec); - VecMulf(dvec, (ctime-1.0)*(float)path->len); + sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec); + mul_v3_fl(dvec, (ctime-1.0)*(float)path->len); VECADD(vec, vec, dvec); if(quat) QUATCOPY(quat, path->data[path->len-1].quat); if(radius) *radius= path->data[path->len-1].radius; @@ -570,28 +570,28 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C dir[cd->no_rot_axis-1]= 0.0f; /* -1 for compatibility with old track defines */ - vectoquat(dir, axis-1, upflag, quat); + vec_to_quat( quat,dir, axis-1, upflag); /* the tilt */ if(loc[3]!=0.0) { - Normalize(dir); + normalize_v3(dir); q[0]= (float)cos(0.5*loc[3]); fac= (float)sin(0.5*loc[3]); q[1]= -fac*dir[0]; q[2]= -fac*dir[1]; q[3]= -fac*dir[2]; - QuatMul(quat, q, quat); + mul_qt_qtqt(quat, q, quat); } #endif - static float q_x90d[4] = {0.70710676908493, 0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; AxisAngleToQuat(q, rot_axis, 90 * (M_PI / 180)); - static float q_y90d[4] = {0.70710676908493, 0.0, 0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; AxisAngleToQuat(q, rot_axis, 90 * (M_PI / 180)); - static float q_z90d[4] = {0.70710676908493, 0.0, 0.0, 0.70710676908493}; // float rot_axis[3]= {0,0,2}; AxisAngleToQuat(q, rot_axis, 90 * (M_PI / 180)); + static float q_x90d[4] = {0.70710676908493, 0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180)); + static float q_y90d[4] = {0.70710676908493, 0.0, 0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180)); + static float q_z90d[4] = {0.70710676908493, 0.0, 0.0, 0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180)); - static float q_nx90d[4] = {0.70710676908493, -0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; AxisAngleToQuat(q, rot_axis, -90 * (M_PI / 180)); - static float q_ny90d[4] = {0.70710676908493, 0.0, -0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; AxisAngleToQuat(q, rot_axis, -90 * (M_PI / 180)); - static float q_nz90d[4] = {0.70710676908493, 0.0, 0.0, -0.70710676908493}; // float rot_axis[3]= {0,0,2}; AxisAngleToQuat(q, rot_axis, -90 * (M_PI / 180)); + static float q_nx90d[4] = {0.70710676908493, -0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180)); + static float q_ny90d[4] = {0.70710676908493, 0.0, -0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180)); + static float q_nz90d[4] = {0.70710676908493, 0.0, 0.0, -0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180)); if(cd->no_rot_axis) { /* set by caller */ @@ -602,12 +602,12 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C VECCOPY(dir_flat, dir); dir_flat[cd->no_rot_axis-1]= 0.0f; - Normalize(dir); - Normalize(dir_flat); + normalize_v3(dir); + normalize_v3(dir_flat); - RotationBetweenVectorsToQuat(q, dir, dir_flat); /* Could this be done faster? */ + rotation_between_vecs_to_quat(q, dir, dir_flat); /* Could this be done faster? */ - QuatMul(new_quat, q, new_quat); + mul_qt_qtqt(new_quat, q, new_quat); } @@ -624,14 +624,14 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C switch(axis) { case MOD_CURVE_POSX: - QuatMul(quat, new_quat, q_y90d); + mul_qt_qtqt(quat, new_quat, q_y90d); cent[0]= 0.0; cent[1]= co[2]; cent[2]= co[1]; break; case MOD_CURVE_NEGX: - QuatMul(quat, new_quat, q_ny90d); + mul_qt_qtqt(quat, new_quat, q_ny90d); cent[0]= 0.0; cent[1]= -co[1]; @@ -639,28 +639,28 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C break; case MOD_CURVE_POSY: - QuatMul(quat, new_quat, q_x90d); + mul_qt_qtqt(quat, new_quat, q_x90d); cent[0]= co[2]; cent[1]= 0.0; cent[2]= -co[0]; break; case MOD_CURVE_NEGY: - QuatMul(quat, new_quat, q_nx90d); + mul_qt_qtqt(quat, new_quat, q_nx90d); cent[0]= -co[0]; cent[1]= 0.0; cent[2]= -co[2]; break; case MOD_CURVE_POSZ: - QuatMul(quat, new_quat, q_z90d); + mul_qt_qtqt(quat, new_quat, q_z90d); cent[0]= co[1]; cent[1]= -co[0]; cent[2]= 0.0; break; case MOD_CURVE_NEGZ: - QuatMul(quat, new_quat, q_nz90d); + mul_qt_qtqt(quat, new_quat, q_nz90d); cent[0]= co[0]; cent[1]= -co[1]; @@ -670,11 +670,11 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C /* scale if enabled */ if(cu->flag & CU_PATH_RADIUS) - VecMulf(cent, radius); + mul_v3_fl(cent, radius); /* local rotation */ - NormalQuat(quat); - QuatMulVecf(quat, cent); + normalize_qt(quat); + mul_qt_v3(quat, cent); /* translation */ VECADD(co, cent, loc); @@ -739,7 +739,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh for(j = 0; j < dvert->totweight; j++) { if(dvert->dw[j].def_nr == index) { - Mat4MulVecfl(cd.curvespace, vertexCos[a]); + mul_m4_v3(cd.curvespace, vertexCos[a]); DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); break; } @@ -754,9 +754,9 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh if(dvert->dw[j].def_nr == index) { VECCOPY(vec, vertexCos[a]); calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); - VecLerpf(vertexCos[a], vertexCos[a], vec, + interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, dvert->dw[j].weight); - Mat4MulVecfl(cd.objectspace, vertexCos[a]); + mul_m4_v3(cd.objectspace, vertexCos[a]); break; } } @@ -766,13 +766,13 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh INIT_MINMAX(cd.dmin, cd.dmax); for(a = 0; a < numVerts; a++) { - Mat4MulVecfl(cd.curvespace, vertexCos[a]); + mul_m4_v3(cd.curvespace, vertexCos[a]); DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); } for(a = 0; a < numVerts; a++) { calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); - Mat4MulVecfl(cd.objectspace, vertexCos[a]); + mul_m4_v3(cd.objectspace, vertexCos[a]); } } cu->flag = flag; @@ -787,7 +787,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco float quat[4]; if(cuOb->type != OB_CURVE) { - Mat3One(mat); + unit_m3(mat); return; } @@ -797,18 +797,18 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco VECCOPY(cd.dmin, orco); VECCOPY(cd.dmax, orco); - Mat4MulVecfl(cd.curvespace, vec); + mul_m4_v3(cd.curvespace, vec); if(calc_curve_deform(scene, cuOb, vec, target->trackflag+1, &cd, quat)) { float qmat[3][3]; - QuatToMat3(quat, qmat); - Mat3MulMat3(mat, qmat, cd.objectspace3); + quat_to_mat3( qmat,quat); + mul_m3_m3m3(mat, qmat, cd.objectspace3); } else - Mat3One(mat); + unit_m3(mat); - Mat4MulVecfl(cd.objectspace, vec); + mul_m4_v3(cd.objectspace, vec); } @@ -939,7 +939,7 @@ void outside_lattice(Lattice *lt) bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1]; bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2]; - VecMulf(bp->vec, 0.3333333f); + mul_v3_fl(bp->vec, 0.3333333f); } } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index c2260e1e761..a3e0ab04991 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -46,7 +46,7 @@ #include "DNA_userdef_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_animsys.h" #include "BKE_blender.h" diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 3ca7dac4bc9..d731ab4230b 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -47,7 +47,7 @@ #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" @@ -436,7 +436,7 @@ Object *find_basis_mball(Scene *scene, Object *basis) void calc_mballco(MetaElem *ml, float *vec) { if(ml->mat) { - Mat4MulVecfl((float ( * )[4])ml->mat, vec); + mul_m4_v3((float ( * )[4])ml->mat, vec); } } @@ -448,7 +448,7 @@ float densfunc(MetaElem *ball, float x, float y, float z) vec[0]= x; vec[1]= y; vec[2]= z; - Mat4MulVecfl((float ( * )[4])ball->imat, vec); + mul_m4_v3((float ( * )[4])ball->imat, vec); dx= vec[0]; dy= vec[1]; dz= vec[2]; @@ -1508,8 +1508,8 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ int a, obnr, zero_size=0; char obname[32]; - Mat4CpyMat4(obmat, ob->obmat); /* to cope with duplicators from next_object */ - Mat4Invert(obinv, ob->obmat); + copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from next_object */ + invert_m4_m4(obinv, ob->obmat); a= 0; splitIDname(ob->id.name+2, obname, &obnr); @@ -1581,15 +1581,15 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ if(ml->s > 10.0) ml->s = 10.0; /* Rotation of MetaElem is stored in quat */ - QuatToMat4(ml->quat, temp3); + quat_to_mat4( temp3,ml->quat); /* Translation of MetaElem */ - Mat4One(temp2); + unit_m4(temp2); temp2[3][0]= ml->x; temp2[3][1]= ml->y; temp2[3][2]= ml->z; - Mat4MulMat4(temp1, temp3, temp2); + mul_m4_m4m4(temp1, temp3, temp2); /* make a copy because of duplicates */ mainb[a]= new_pgn_element(sizeof(MetaElem)); @@ -1600,12 +1600,12 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ imat= new_pgn_element(4*4*sizeof(float)); /* mat is the matrix to transform from mball into the basis-mball */ - Mat4Invert(obinv, obmat); - Mat4MulMat4(temp2, bob->obmat, obinv); + invert_m4_m4(obinv, obmat); + mul_m4_m4m4(temp2, bob->obmat, obinv); /* MetaBall transformation */ - Mat4MulMat4(mat, temp1, temp2); + mul_m4_m4m4(mat, temp1, temp2); - Mat4Invert(imat,mat); + invert_m4_m4(imat,mat); mainb[a]->rad2= ml->rad*ml->rad; @@ -1648,7 +1648,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ /* transformation of Metalem bb */ for(i=0; i<8; i++) - Mat4MulVecfl((float ( * )[4])mat, mainb[a]->bb->vec[i]); + mul_m4_v3((float ( * )[4])mat, mainb[a]->bb->vec[i]); /* find max and min of transformed bb */ for(i=0; i<8; i++){ diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 6ef557ca879..d5c597b802c 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -70,7 +70,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" @@ -1086,7 +1086,7 @@ void mesh_to_curve(Scene *scene, Object *ob) /* add points */ vl= polyline.first; for (i=0, bp=nu->bp; i < totpoly; i++, bp++, vl=(VertLink *)vl->next) { - VecCopyf(bp->vec, mverts[vl->index].co); + copy_v3_v3(bp->vec, mverts[vl->index].co); bp->f1= SELECT; bp->radius = bp->weight = 1.0; } @@ -1146,23 +1146,23 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float *f_no= &fnors[i*3]; if (mf->v4) - CalcNormFloat4(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co, f_no); + normal_quad_v3( f_no,mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co); else - CalcNormFloat(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, f_no); + normal_tri_v3( f_no,mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co); - VecAddf(tnorms[mf->v1], tnorms[mf->v1], f_no); - VecAddf(tnorms[mf->v2], tnorms[mf->v2], f_no); - VecAddf(tnorms[mf->v3], tnorms[mf->v3], f_no); + add_v3_v3v3(tnorms[mf->v1], tnorms[mf->v1], f_no); + add_v3_v3v3(tnorms[mf->v2], tnorms[mf->v2], f_no); + add_v3_v3v3(tnorms[mf->v3], tnorms[mf->v3], f_no); if (mf->v4) - VecAddf(tnorms[mf->v4], tnorms[mf->v4], f_no); + add_v3_v3v3(tnorms[mf->v4], tnorms[mf->v4], f_no); } for (i=0; ico); - Normalize(no); + normalize_v3(no); } mv->no[0]= (short)(no[0]*32767.0); @@ -1262,7 +1262,7 @@ UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned next= iterv->next; uv2= (tf+iterv->f)->uv[iterv->tfindex]; - Vec2Subf(uvdiff, uv2, uv); + sub_v2_v2v2(uvdiff, uv2, uv); if(fabs(uv[0]-uv2[0]) < limit[0] && fabs(uv[1]-uv2[1]) < limit[1]) { diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 3c9fd4b8817..744c9712248 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -41,7 +41,7 @@ #include "float.h" #include "ctype.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdopbvh.h" #include "BLI_kdtree.h" @@ -1187,7 +1187,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if(amd->end_cap && amd->end_cap != ob) end_cap = amd->end_cap->derivedFinal; - Mat4One(offset); + unit_m4(offset); indexMap = MEM_callocN(sizeof(*indexMap) * dm->getNumVerts(dm), "indexmap"); @@ -1197,7 +1197,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, maxVerts = dm->getNumVerts(dm); if(amd->offset_type & MOD_ARR_OFF_CONST) - VecAddf(offset[3], offset[3], amd->offset); + add_v3_v3v3(offset[3], offset[3], amd->offset); if(amd->offset_type & MOD_ARR_OFF_RELATIVE) { for(j = 0; j < 3; j++) offset[3][j] += amd->scale[j] * vertarray_size(src_mvert, @@ -1209,14 +1209,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float result_mat[4][4]; if(ob) - Mat4Invert(obinv, ob->obmat); + invert_m4_m4(obinv, ob->obmat); else - Mat4One(obinv); + unit_m4(obinv); - Mat4MulSerie(result_mat, offset, + mul_serie_m4(result_mat, offset, obinv, amd->offset_ob->obmat, NULL, NULL, NULL, NULL, NULL); - Mat4CpyMat4(offset, result_mat); + copy_m4_m4(offset, result_mat); } if(amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) { @@ -1226,7 +1226,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float scale; object_to_mat3(amd->curve_ob, tmp_mat); - scale = Mat3ToScalef(tmp_mat); + scale = mat3_to_scale(tmp_mat); if(!cu->path) { cu->flag |= CU_PATH; // needed for path & bevlist @@ -1241,7 +1241,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, prescribed length */ if(amd->fit_type == MOD_ARR_FITLENGTH || amd->fit_type == MOD_ARR_FITCURVE) { - float dist = sqrt(Inpf(offset[3], offset[3])); + float dist = sqrt(dot_v3v3(offset[3], offset[3])); if(dist > 1e-6f) /* this gives length = first copy start to last copy end @@ -1274,11 +1274,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, result = CDDM_from_template(dm, finalVerts, finalEdges, finalFaces); /* calculate the offset matrix of the final copy (for merging) */ - Mat4One(final_offset); + unit_m4(final_offset); for(j=0; j < count - 1; j++) { - Mat4MulMat4(tmp_mat, final_offset, offset); - Mat4CpyMat4(final_offset, tmp_mat); + mul_m4_m4m4(tmp_mat, final_offset, offset); + copy_m4_m4(final_offset, tmp_mat); } numVerts = numEdges = numFaces = 0; @@ -1314,7 +1314,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if((count > 1) && (amd->flags & MOD_ARR_MERGE)) { float tmp_co[3]; VECCOPY(tmp_co, mv->co); - Mat4MulVecfl(offset, tmp_co); + mul_m4_v3(offset, tmp_co); for(j = 0; j < maxVerts; j++) { /* if vertex already merged, don't use it */ @@ -1322,15 +1322,15 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, inMV = &src_mvert[j]; /* if this vert is within merge limit, merge */ - if(VecLenCompare(tmp_co, inMV->co, amd->merge_dist)) { + if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) { indexMap[i].merge = j; /* test for merging with final copy of merge target */ if(amd->flags & MOD_ARR_MERGEFINAL) { VECCOPY(tmp_co, inMV->co); inMV = &src_mvert[i]; - Mat4MulVecfl(final_offset, tmp_co); - if(VecLenCompare(tmp_co, inMV->co, amd->merge_dist)) + mul_m4_v3(final_offset, tmp_co); + if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) indexMap[i].merge_final = 1; } break; @@ -1347,7 +1347,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, *mv2 = *mv; numVerts++; - Mat4MulVecfl(offset, co); + mul_m4_v3(offset, co); VECCOPY(mv2->co, co); } } else if(indexMap[i].merge != i && indexMap[i].merge_final) { @@ -1504,7 +1504,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, cap_medge = start_cap->getEdgeArray(start_cap); cap_mface = start_cap->getFaceArray(start_cap); - Mat4Invert(startoffset, offset); + invert_m4_m4(startoffset, offset); vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, "arrayModifier_doArray vert_map"); @@ -1520,12 +1520,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, int j; VECCOPY(tmp_co, mv->co); - Mat4MulVecfl(startoffset, tmp_co); + mul_m4_v3(startoffset, tmp_co); for(j = 0; j < maxVerts; j++) { in_mv = &src_mvert[j]; /* if this vert is within merge limit, merge */ - if(VecLenCompare(tmp_co, in_mv->co, amd->merge_dist)) { + if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { vert_map[i] = calc_mapping(indexMap, j, 0); merged = 1; break; @@ -1536,7 +1536,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if(!merged) { DM_copy_vert_data(start_cap, result, i, numVerts, 1); mvert[numVerts] = *mv; - Mat4MulVecfl(startoffset, mvert[numVerts].co); + mul_m4_v3(startoffset, mvert[numVerts].co); origindex[numVerts] = ORIGINDEX_NONE; vert_map[i] = numVerts; @@ -1605,7 +1605,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, cap_medge = end_cap->getEdgeArray(end_cap); cap_mface = end_cap->getFaceArray(end_cap); - Mat4MulMat4(endoffset, final_offset, offset); + mul_m4_m4m4(endoffset, final_offset, offset); vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, "arrayModifier_doArray vert_map"); @@ -1621,12 +1621,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, int j; VECCOPY(tmp_co, mv->co); - Mat4MulVecfl(offset, tmp_co); + mul_m4_v3(offset, tmp_co); for(j = 0; j < maxVerts; j++) { in_mv = &src_mvert[j]; /* if this vert is within merge limit, merge */ - if(VecLenCompare(tmp_co, in_mv->co, amd->merge_dist)) { + if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { vert_map[i] = calc_mapping(indexMap, j, count - 1); merged = 1; break; @@ -1637,7 +1637,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if(!merged) { DM_copy_vert_data(end_cap, result, i, numVerts, 1); mvert[numVerts] = *mv; - Mat4MulVecfl(endoffset, mvert[numVerts].co); + mul_m4_v3(endoffset, mvert[numVerts].co); origindex[numVerts] = ORIGINDEX_NONE; vert_map[i] = numVerts; @@ -1921,9 +1921,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, if (mmd->mirror_ob) { float obinv[4][4]; - Mat4Invert(obinv, mmd->mirror_ob->obmat); - Mat4MulMat4(mtx, ob->obmat, obinv); - Mat4Invert(imtx, mtx); + invert_m4_m4(obinv, mmd->mirror_ob->obmat); + mul_m4_m4m4(mtx, ob->obmat, obinv); + invert_m4_m4(imtx, mtx); } for(i = 0; i < maxVerts; i++) { @@ -1934,10 +1934,10 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, dm->getVert(dm, i, &inMV); - VecCopyf(co, inMV.co); + copy_v3_v3(co, inMV.co); if (mmd->mirror_ob) { - VecMat4MulVecfl(co, mtx, co); + mul_v3_m4v3(co, mtx, co); } isShared = ABS(co[axis])<=tolerance; @@ -1955,9 +1955,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, if(isShared) { co[axis] = 0; if (mmd->mirror_ob) { - VecMat4MulVecfl(co, imtx, co); + mul_v3_m4v3(co, imtx, co); } - VecCopyf(mv->co, co); + copy_v3_v3(mv->co, co); mv->flag |= ME_VERT_MERGED; } else { @@ -1969,9 +1969,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, co[axis] = -co[axis]; if (mmd->mirror_ob) { - VecMat4MulVecfl(co, imtx, co); + mul_v3_m4v3(co, imtx, co); } - VecCopyf(mv2->co, co); + copy_v3_v3(mv2->co, co); if (mmd->flag & MOD_MIR_VGROUP){ dvert = DM_get_vert_data(result, numVerts, CD_MDEFORMVERT); @@ -2477,12 +2477,12 @@ static SmoothMesh *smoothmesh_from_derivedmesh(DerivedMesh *dm) if(face->edges[2]->verts[1]->oldIndex == mf.v3) face->flip[2] = 1; face->edges[3] = BLI_edgehash_lookup(edges, mf.v4, mf.v1); if(face->edges[3]->verts[1]->oldIndex == mf.v4) face->flip[3] = 1; - CalcNormFloat4(v1.co, v2.co, v3.co, v4.co, face->normal); + normal_quad_v3( face->normal,v1.co, v2.co, v3.co, v4.co); } else { face->edges[2] = BLI_edgehash_lookup(edges, mf.v3, mf.v1); if(face->edges[2]->verts[1]->oldIndex == mf.v3) face->flip[2] = 1; face->edges[3] = NULL; - CalcNormFloat(v1.co, v2.co, v3.co, face->normal); + normal_tri_v3( face->normal,v1.co, v2.co, v3.co); } for(j = 0; j < SMOOTHFACE_MAX_EDGES && face->edges[j]; j++) { @@ -3179,7 +3179,7 @@ static void tag_and_count_extra_edges(SmoothMesh *mesh, float split_angle, /* we know the edge has 2 faces, so check the angle */ SmoothFace *face1 = edge->faces->link; SmoothFace *face2 = edge->faces->next->link; - float edge_angle_cos = Inpf(face1->normal, + float edge_angle_cos = dot_v3v3(face1->normal, face2->normal); if(edge_angle_cos < threshold) { @@ -3575,7 +3575,7 @@ static void get_texture_coords(DisplaceModifierData *dmd, Object *ob, if(texmapping == MOD_DISP_MAP_OBJECT) { if(dmd->map_object) - Mat4Invert(mapob_imat, dmd->map_object->obmat); + invert_m4_m4(mapob_imat, dmd->map_object->obmat); else /* if there is no map object, default to local */ texmapping = MOD_DISP_MAP_LOCAL; } @@ -3641,12 +3641,12 @@ static void get_texture_coords(DisplaceModifierData *dmd, Object *ob, break; case MOD_DISP_MAP_GLOBAL: VECCOPY(*texco, *co); - Mat4MulVecfl(ob->obmat, *texco); + mul_m4_v3(ob->obmat, *texco); break; case MOD_DISP_MAP_OBJECT: VECCOPY(*texco, *co); - Mat4MulVecfl(ob->obmat, *texco); - Mat4MulVecfl(mapob_imat, *texco); + mul_m4_v3(ob->obmat, *texco); + mul_m4_v3(mapob_imat, *texco); break; } } @@ -3917,7 +3917,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* convert coords to world space */ for(i = 0, co = coords; i < numVerts; ++i, ++co) - Mat4MulVecfl(ob->obmat, *co); + mul_m4_v3(ob->obmat, *co); /* calculate a projection matrix and normal for each projector */ for(i = 0; i < num_projectors; ++i) { @@ -3925,7 +3925,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, float offsetmat[4][4]; Camera *cam = NULL; /* calculate projection matrix */ - Mat4Invert(projectors[i].projmat, projectors[i].ob->obmat); + invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat); if(projectors[i].ob->type == OB_CAMERA) { cam = (Camera *)projectors[i].ob->data; @@ -3947,8 +3947,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, xmin = -xmax; ymin = -ymax; - i_window(xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend, perspmat); - Mat4MulMat4(tmpmat, projectors[i].projmat, perspmat); + perspective_m4( perspmat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend); + mul_m4_m4m4(tmpmat, projectors[i].projmat, perspmat); } else if(cam->type == CAM_ORTHO) { float orthomat[4][4]; float xmax; @@ -3966,15 +3966,15 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, xmin = -xmax; ymin = -ymax; - i_ortho(xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend, orthomat); - Mat4MulMat4(tmpmat, projectors[i].projmat, orthomat); + orthographic_m4( orthomat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend); + mul_m4_m4m4(tmpmat, projectors[i].projmat, orthomat); } } else { - Mat4CpyMat4(tmpmat, projectors[i].projmat); + copy_m4_m4(tmpmat, projectors[i].projmat); } - Mat4One(offsetmat); - Mat4MulFloat3(offsetmat[0], 0.5); + unit_m4(offsetmat); + mul_mat3_m4_fl(offsetmat[0], 0.5); offsetmat[3][0] = offsetmat[3][1] = offsetmat[3][2] = 0.5; if (cam) { @@ -3990,19 +3990,19 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } } - Mat4MulMat4(projectors[i].projmat, tmpmat, offsetmat); + mul_m4_m4m4(projectors[i].projmat, tmpmat, offsetmat); /* calculate worldspace projector normal (for best projector test) */ projectors[i].normal[0] = 0; projectors[i].normal[1] = 0; projectors[i].normal[2] = 1; - Mat4Mul3Vecfl(projectors[i].ob->obmat, projectors[i].normal); + mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal); } /* if only one projector, project coords to UVs */ if(num_projectors == 1) for(i = 0, co = coords; i < numVerts; ++i, ++co) - Mat4MulVec3Project(projectors[0].projmat, *co); + mul_project_m4_v4(projectors[0].projmat, *co); mface = dm->getFaceArray(dm); numFaces = dm->getNumFaces(dm); @@ -4039,19 +4039,19 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* get the untransformed face normal */ if(mf->v4) { VECCOPY(co4, coords[mf->v4]); - CalcNormFloat4(co1, co2, co3, co4, face_no); + normal_quad_v3( face_no,co1, co2, co3, co4); } else { - CalcNormFloat(co1, co2, co3, face_no); + normal_tri_v3( face_no,co1, co2, co3); } /* find the projector which the face points at most directly * (projector normal with largest dot product is best) */ - best_dot = Inpf(projectors[0].normal, face_no); + best_dot = dot_v3v3(projectors[0].normal, face_no); best_projector = &projectors[0]; for(j = 1; j < num_projectors; ++j) { - float tmp_dot = Inpf(projectors[j].normal, + float tmp_dot = dot_v3v3(projectors[j].normal, face_no); if(tmp_dot > best_dot) { best_dot = tmp_dot; @@ -4059,11 +4059,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } } - Mat4MulVec3Project(best_projector->projmat, co1); - Mat4MulVec3Project(best_projector->projmat, co2); - Mat4MulVec3Project(best_projector->projmat, co3); + mul_project_m4_v4(best_projector->projmat, co1); + mul_project_m4_v4(best_projector->projmat, co2); + mul_project_m4_v4(best_projector->projmat, co3); if(mf->v4) - Mat4MulVec3Project(best_projector->projmat, co4); + mul_project_m4_v4(best_projector->projmat, co4); /* apply transformed coords as UVs */ tface->uv[0][0] = co1[0]; @@ -4358,11 +4358,11 @@ static void smoothModifier_do( if (uctmp[idx1] < 255) { uctmp[idx1]++; - VecAddf(v1, v1, fvec); + add_v3_v3v3(v1, v1, fvec); } if (uctmp[idx2] < 255) { uctmp[idx2]++; - VecAddf(v2, v2, fvec); + add_v3_v3v3(v2, v2, fvec); } } @@ -4576,14 +4576,14 @@ static void castModifier_sphere_do( * we use its location, transformed to ob's local space */ if (ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4Invert(ctrl_ob->imat, ctrl_ob->obmat); - Mat4MulMat4(mat, ob->obmat, ctrl_ob->imat); - Mat4Invert(imat, mat); + invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat); + mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat); + invert_m4_m4(imat, mat); } - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); VECCOPY(center, ctrl_ob->obmat[3]); - Mat4MulVecfl(ob->imat, center); + mul_m4_v3(ob->imat, center); } /* now we check which options the user wants */ @@ -4618,7 +4618,7 @@ static void castModifier_sphere_do( if(len <= 0) { for (i = 0; i < numVerts; i++) { - len += VecLenf(center, vertexCos[i]); + len += len_v3v3(center, vertexCos[i]); } len /= numVerts; @@ -4640,9 +4640,9 @@ static void castModifier_sphere_do( VECCOPY(tmp_co, vertexCos[i]); if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(mat, tmp_co); + mul_m4_v3(mat, tmp_co); } else { - VecSubf(tmp_co, tmp_co, center); + sub_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4652,7 +4652,7 @@ static void castModifier_sphere_do( vec[2] = 0.0f; if (has_radius) { - if (VecLength(vec) > cmd->radius) continue; + if (len_v3(vec) > cmd->radius) continue; } for (j = 0; j < dvert[i].totweight; ++j) { @@ -4666,7 +4666,7 @@ static void castModifier_sphere_do( fac = fac_orig * dw->weight; facm = 1.0f - fac; - Normalize(vec); + normalize_v3(vec); if (flag & MOD_CAST_X) tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; @@ -4677,9 +4677,9 @@ static void castModifier_sphere_do( if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(imat, tmp_co); + mul_m4_v3(imat, tmp_co); } else { - VecAddf(tmp_co, tmp_co, center); + add_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4695,9 +4695,9 @@ static void castModifier_sphere_do( VECCOPY(tmp_co, vertexCos[i]); if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(mat, tmp_co); + mul_m4_v3(mat, tmp_co); } else { - VecSubf(tmp_co, tmp_co, center); + sub_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4707,10 +4707,10 @@ static void castModifier_sphere_do( vec[2] = 0.0f; if (has_radius) { - if (VecLength(vec) > cmd->radius) continue; + if (len_v3(vec) > cmd->radius) continue; } - Normalize(vec); + normalize_v3(vec); if (flag & MOD_CAST_X) tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; @@ -4721,9 +4721,9 @@ static void castModifier_sphere_do( if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(imat, tmp_co); + mul_m4_v3(imat, tmp_co); } else { - VecAddf(tmp_co, tmp_co, center); + add_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4778,14 +4778,14 @@ static void castModifier_cuboid_do( if (ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4Invert(ctrl_ob->imat, ctrl_ob->obmat); - Mat4MulMat4(mat, ob->obmat, ctrl_ob->imat); - Mat4Invert(imat, mat); + invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat); + mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat); + invert_m4_m4(imat, mat); } - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); VECCOPY(center, ctrl_ob->obmat[3]); - Mat4MulVecfl(ob->imat, center); + mul_m4_v3(ob->imat, center); } if((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) { @@ -4814,7 +4814,7 @@ static void castModifier_cuboid_do( DO_MINMAX(center, min, max); for (i = 0; i < numVerts; i++) { - VecSubf(vec, vertexCos[i], center); + sub_v3_v3v3(vec, vertexCos[i], center); DO_MINMAX(vec, min, max); } } @@ -4857,9 +4857,9 @@ static void castModifier_cuboid_do( VECCOPY(tmp_co, vertexCos[i]); if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(mat, tmp_co); + mul_m4_v3(mat, tmp_co); } else { - VecSubf(tmp_co, tmp_co, center); + sub_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4895,7 +4895,7 @@ static void castModifier_cuboid_do( if (tmp_co[2] > 0.0f) octant += 4; /* apex is the bb's vertex at the chosen octant */ - VecCopyf(apex, bb[octant]); + copy_v3_v3(apex, bb[octant]); /* find which bb plane is closest to this vertex ... */ d[0] = tmp_co[0] / apex[0]; @@ -4933,9 +4933,9 @@ static void castModifier_cuboid_do( if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(imat, tmp_co); + mul_m4_v3(imat, tmp_co); } else { - VecAddf(tmp_co, tmp_co, center); + add_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4953,9 +4953,9 @@ static void castModifier_cuboid_do( VECCOPY(tmp_co, vertexCos[i]); if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(mat, tmp_co); + mul_m4_v3(mat, tmp_co); } else { - VecSubf(tmp_co, tmp_co, center); + sub_v3_v3v3(tmp_co, tmp_co, center); } } @@ -4970,7 +4970,7 @@ static void castModifier_cuboid_do( if (tmp_co[1] > 0.0f) octant += 2; if (tmp_co[2] > 0.0f) octant += 4; - VecCopyf(apex, bb[octant]); + copy_v3_v3(apex, bb[octant]); d[0] = tmp_co[0] / apex[0]; d[1] = tmp_co[1] / apex[1]; @@ -5001,9 +5001,9 @@ static void castModifier_cuboid_do( if(ctrl_ob) { if(flag & MOD_CAST_USE_OB_TRANSFORM) { - Mat4MulVecfl(imat, tmp_co); + mul_m4_v3(imat, tmp_co); } else { - VecAddf(tmp_co, tmp_co, center); + add_v3_v3v3(tmp_co, tmp_co, center); } } @@ -5168,7 +5168,7 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob, if(texmapping == MOD_WAV_MAP_OBJECT) { if(wmd->map_object) - Mat4Invert(wmd->map_object->imat, wmd->map_object->obmat); + invert_m4_m4(wmd->map_object->imat, wmd->map_object->obmat); else /* if there is no map object, default to local */ texmapping = MOD_WAV_MAP_LOCAL; } @@ -5234,12 +5234,12 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob, break; case MOD_WAV_MAP_GLOBAL: VECCOPY(*texco, *co); - Mat4MulVecfl(ob->obmat, *texco); + mul_m4_v3(ob->obmat, *texco); break; case MOD_WAV_MAP_OBJECT: VECCOPY(*texco, *co); - Mat4MulVecfl(ob->obmat, *texco); - Mat4MulVecfl(wmd->map_object->imat, *texco); + mul_m4_v3(ob->obmat, *texco); + mul_m4_v3(wmd->map_object->imat, *texco); break; } } @@ -5265,8 +5265,8 @@ static void waveModifier_do(WaveModifierData *md, if(wmd->objectcenter){ float mat[4][4]; /* get the control object's location in local coordinates */ - Mat4Invert(ob->imat, ob->obmat); - Mat4MulMat4(mat, wmd->objectcenter->obmat, ob->imat); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_m4m4(mat, wmd->objectcenter->obmat, ob->imat); wmd->startx = mat[3][0]; wmd->starty = mat[3][1]; @@ -5655,14 +5655,14 @@ static void hookModifier_deformVerts( /* get world-space matrix of target, corrected for the space the verts are in */ if (hmd->subtarget[0] && pchan) { /* bone target if there's a matching pose-channel */ - Mat4MulMat4(dmat, pchan->pose_mat, hmd->object->obmat); + mul_m4_m4m4(dmat, pchan->pose_mat, hmd->object->obmat); } else { /* just object target */ - Mat4CpyMat4(dmat, hmd->object->obmat); + copy_m4_m4(dmat, hmd->object->obmat); } - Mat4Invert(ob->imat, ob->obmat); - Mat4MulSerie(mat, ob->imat, dmat, hmd->parentinv, + invert_m4_m4(ob->imat, ob->obmat); + mul_serie_m4(mat, ob->imat, dmat, hmd->parentinv, NULL, NULL, NULL, NULL, NULL); /* vertex indices? */ @@ -5692,29 +5692,29 @@ static void hookModifier_deformVerts( if(orig_index == index) { co = vertexCos[j]; if(hmd->falloff != 0.0) { - float len = VecLenf(co, hmd->cent); + float len = len_v3v3(co, hmd->cent); if(len > hmd->falloff) fac = 0.0; else if(len > 0.0) fac *= sqrt(1.0 - len / hmd->falloff); } if(fac != 0.0) { - VecMat4MulVecfl(vec, mat, co); - VecLerpf(co, co, vec, fac); + mul_v3_m4v3(vec, mat, co); + interp_v3_v3v3(co, co, vec, fac); } } } } else { if(hmd->falloff != 0.0) { - float len = VecLenf(co, hmd->cent); + float len = len_v3v3(co, hmd->cent); if(len > hmd->falloff) fac = 0.0; else if(len > 0.0) fac *= sqrt(1.0 - len / hmd->falloff); } if(fac != 0.0) { - VecMat4MulVecfl(vec, mat, co); - VecLerpf(co, co, vec, fac); + mul_v3_m4v3(vec, mat, co); + interp_v3_v3v3(co, co, vec, fac); } } } @@ -5753,14 +5753,14 @@ static void hookModifier_deformVerts( float *co = vertexCos[i]; if(hmd->falloff != 0.0) { - float len = VecLenf(co, hmd->cent); + float len = len_v3v3(co, hmd->cent); if(len > hmd->falloff) fac = 0.0; else if(len > 0.0) fac *= sqrt(1.0 - len / hmd->falloff); } - VecMat4MulVecfl(vec, mat, co); - VecLerpf(co, co, vec, fac); + mul_v3_m4v3(vec, mat, co); + interp_v3_v3v3(co, co, vec, fac); } } } @@ -6096,7 +6096,7 @@ static void collisionModifier_deformVerts( for ( i = 0; i < numverts; i++ ) { // we save global positions - Mat4MulVecfl ( ob->obmat, collmd->x[i].co ); + mul_m4_v3( ob->obmat, collmd->x[i].co ); } collmd->xnew = MEM_dupallocN(collmd->x); // frame end position @@ -6126,7 +6126,7 @@ static void collisionModifier_deformVerts( for ( i = 0; i < numverts; i++ ) { // we save global positions - Mat4MulVecfl ( ob->obmat, collmd->xnew[i].co ); + mul_m4_v3( ob->obmat, collmd->xnew[i].co ); } memcpy(collmd->current_xnew, collmd->x, numverts*sizeof(MVert)); @@ -6272,14 +6272,14 @@ static void surfaceModifier_deformVerts( /* convert to global coordinates and calculate velocity */ for(i = 0, x = surmd->x, v = surmd->v; idm, i)->co; - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); if(init) v->co[0] = v->co[1] = v->co[2] = 0.0f; else - VecSubf(v->co, vec, x->co); + sub_v3_v3v3(v->co, vec, x->co); - VecCopyf(x->co, vec); + copy_v3_v3(x->co, vec); } surmd->cfra = md->scene->r.cfra; @@ -6713,7 +6713,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier( psys_get_particle_on_path(&sim, first_particle + i/totvert, &state,1); - Normalize(state.vel); + normalize_v3(state.vel); /* TODO: incremental rotations somehow */ if(state.vel[axis] < -0.9999 || state.vel[axis] > 0.9999) { @@ -6724,10 +6724,10 @@ static DerivedMesh * particleInstanceModifier_applyModifier( float temp[3] = {0.0f,0.0f,0.0f}; temp[axis] = 1.0f; - Crossf(cross, temp, state.vel); + cross_v3_v3v3(cross, temp, state.vel); /* state.vel[axis] is the only component surviving from a dot product with the axis */ - VecRotToQuat(cross,saacos(state.vel[axis]),state.rot); + axis_angle_to_quat(state.rot,cross,saacos(state.vel[axis])); } } @@ -6736,9 +6736,9 @@ static DerivedMesh * particleInstanceModifier_applyModifier( psys_get_particle_state(&sim, first_particle + i/totvert, &state,1); } - QuatMulVecf(state.rot,mv->co); + mul_qt_v3(state.rot,mv->co); if(pimd->flag & eParticleInstanceFlag_UseSize) - VecMulf(mv->co, size[i/totvert]); + mul_v3_fl(mv->co, size[i/totvert]); VECADD(mv->co,mv->co,state.co); } @@ -6901,14 +6901,14 @@ static void explodeModifier_createFacepa(ExplodeModifierData *emd, /* set face-particle-indexes to nearest particle to face center */ for(i=0,fa=mface; iv1].co,mvert[fa->v2].co); - VecAddf(center,center,mvert[fa->v3].co); + add_v3_v3v3(center,mvert[fa->v1].co,mvert[fa->v2].co); + add_v3_v3v3(center,center,mvert[fa->v3].co); if(fa->v4){ - VecAddf(center,center,mvert[fa->v4].co); - VecMulf(center,0.25); + add_v3_v3v3(center,center,mvert[fa->v4].co); + mul_v3_fl(center,0.25); } else - VecMulf(center,0.3333f); + mul_v3_fl(center,0.3333f); p= BLI_kdtree_find_nearest(tree,center,NULL,NULL); @@ -7080,7 +7080,7 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive mv=CDDM_get_vert(splitdm,i); VECADD(dupve->co,dupve->co,mv->co); - VecMulf(dupve->co,0.5); + mul_v3_fl(dupve->co,0.5); } BLI_edgehashIterator_free(ehi); @@ -7296,7 +7296,7 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive VECADD(dupve->co,dupve->co,mv->co); mv=CDDM_get_vert(splitdm,mf->v4); VECADD(dupve->co,dupve->co,mv->co); - VecMulf(dupve->co,0.25); + mul_v3_fl(dupve->co,0.25); df1=CDDM_get_face(splitdm,curdupface); @@ -7472,7 +7472,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, /*dupvert= CDDM_get_verts(explode);*/ /* getting back to object space */ - Mat4Invert(imat,ob->obmat); + invert_m4_m4(imat,ob->obmat); psmd->psys->lattice = psys_get_lattice(&sim); @@ -7499,23 +7499,23 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, /* get particle state */ psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc0,nor,0,0,0,0); - Mat4MulVecfl(ob->obmat,loc0); + mul_m4_v3(ob->obmat,loc0); state.time=cfra; psys_get_particle_state(&sim, i, &state, 1); vertco=CDDM_get_vert(explode,v)->co; - Mat4MulVecfl(ob->obmat,vertco); + mul_m4_v3(ob->obmat,vertco); VECSUB(vertco,vertco,loc0); /* apply rotation, size & location */ - QuatMulVecf(state.rot,vertco); - VecMulf(vertco,pa->size); + mul_qt_v3(state.rot,vertco); + mul_v3_fl(vertco,pa->size); VECADD(vertco,vertco,state.co); - Mat4MulVecfl(imat,vertco); + mul_m4_v3(imat,vertco); } } BLI_edgehashIterator_free(ehi); @@ -7881,11 +7881,11 @@ static void meshdeformModifier_do( return; /* compute matrices to go in and out of cage object space */ - Mat4Invert(imat, mmd->object->obmat); - Mat4MulMat4(cagemat, ob->obmat, imat); - Mat4MulMat4(cmat, cagemat, mmd->bindmat); - Mat4Invert(iobmat, cmat); - Mat3CpyMat4(icagemat, iobmat); + invert_m4_m4(imat, mmd->object->obmat); + mul_m4_m4m4(cagemat, ob->obmat, imat); + mul_m4_m4m4(cmat, cagemat, mmd->bindmat); + invert_m4_m4(iobmat, cmat); + copy_m3_m4(icagemat, iobmat); /* bind weights if needed */ if(!mmd->bindcos) { @@ -7919,7 +7919,7 @@ static void meshdeformModifier_do( VECCOPY(co, cagemvert[a].co); if(G.rt != 527) { - Mat4MulVecfl(mmd->bindmat, co); + mul_m4_v3(mmd->bindmat, co); /* compute difference with world space bind coord */ VECSUB(dco[a], co, bindcos[a]); } @@ -7973,7 +7973,7 @@ static void meshdeformModifier_do( if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) { /* transform coordinate into cage's local space */ VECCOPY(co, vertexCos[b]); - Mat4MulVecfl(cagemat, co); + mul_m4_v3(cagemat, co); totweight= meshdeform_dynamic_bind(mmd, dco, co); } else { @@ -7990,8 +7990,8 @@ static void meshdeformModifier_do( } if(totweight > 0.0f) { - VecMulf(co, fac/totweight); - Mat3MulVecfl(icagemat, co); + mul_v3_fl(co, fac/totweight); + mul_m3_v3(icagemat, co); if(G.rt != 527) VECADD(vertexCos[b], vertexCos[b], co) else @@ -8082,7 +8082,7 @@ static DerivedMesh *multiresModifier_applyModifier(ModifierData *md, Object *ob, int i; MVert *dst = CDDM_get_verts(final); for(i = 0; i < mmd->undo_verts_tot; ++i) { - VecCopyf(dst[i].co, mmd->undo_verts[i].co); + copy_v3_v3(dst[i].co, mmd->undo_verts[i].co); } CDDM_calc_normals(final); @@ -8363,10 +8363,10 @@ static void shapekeyModifier_deformMatricesEM( int a; if(kb && kb->totelem==numVerts && kb!=key->refkey) { - Mat3Scale(scale, kb->curval); + scale_m3_fl(scale, kb->curval); for(a=0; atotvert; ++i) - VecCopyf(mvert[i].co, src_me->mvert[i].co); + copy_v3_v3(mvert[i].co, src_me->mvert[i].co); mrdm->needsFree = 1; MultiresDM_mark_as_modified(mrdm); mrdm->release(mrdm); @@ -178,9 +178,9 @@ int multiresModifier_reshape(MultiresModifierData *mmd, Object *dst, Object *src static void Mat3FromColVecs(float mat[][3], float v1[3], float v2[3], float v3[3]) { - VecCopyf(mat[0], v1); - VecCopyf(mat[1], v2); - VecCopyf(mat[2], v3); + copy_v3_v3(mat[0], v1); + copy_v3_v3(mat[1], v2); + copy_v3_v3(mat[2], v3); } static DerivedMesh *multires_subdisp_pre(DerivedMesh *mrdm, int distance, int simple) @@ -233,7 +233,7 @@ static void multires_subdisp(DerivedMesh *orig, Object *ob, DerivedMesh *final, if(!addverts) { for(i = 0; i < totvert; ++i) { float z[3] = {0,0,0}; - VecCopyf(mvd[i].co, z); + copy_v3_v3(mvd[i].co, z); } } @@ -424,7 +424,7 @@ void multiresModifier_del_levels(struct MultiresModifierData *mmd, struct Object for(j = 0, y = 0; y < st; y += skip) { for(x = 0; x < st; x += skip) { - VecCopyf(disps[j], mdisps[i].disps[y * st + x]); + copy_v3_v3(disps[j], mdisps[i].disps[y * st + x]); ++j; } } @@ -998,27 +998,27 @@ static void calc_disp_mat(MultiresDisplacer *d, float mat[3][3]) if(u < 0) { u = multires_index_at_loc(d->face_index, d->x - 1, d->y, d, &d->edges_primary); - VecSubf(t1, base->co, d->subco[u].co); + sub_v3_v3v3(t1, base->co, d->subco[u].co); } else - VecSubf(t1, d->subco[u].co, base->co); + sub_v3_v3v3(t1, d->subco[u].co, base->co); if(v < 0) { v = multires_index_at_loc(d->face_index, d->x, d->y - 1, d, &d->edges_primary); - VecSubf(t2, base->co, d->subco[v].co); + sub_v3_v3v3(t2, base->co, d->subco[v].co); } else - VecSubf(t2, d->subco[v].co, base->co); + sub_v3_v3v3(t2, d->subco[v].co, base->co); //printf("uu=%d, vv=%d\n", u, v); - Normalize(t1); - Normalize(t2); + normalize_v3(t1); + normalize_v3(t2); Mat3FromColVecs(mat, t1, t2, norm); if(d->invert) { - Mat3Inv(inv, mat); - Mat3CpyMat3(mat, inv); + invert_m3_m3(inv, mat); + copy_m3_m3(mat, inv); } } @@ -1033,23 +1033,23 @@ static void multires_displace(MultiresDisplacer *d, float co[3]) data = d->grid->disps[(d->y * d->spacing) * d->disp_st + (d->x * d->spacing)]; if(d->invert) - VecSubf(disp, co, subco->co); + sub_v3_v3v3(disp, co, subco->co); else - VecCopyf(disp, data); + copy_v3_v3(disp, data); /* Apply ts matrix to displacement */ calc_disp_mat(d, mat); - Mat3MulVecfl(mat, disp); + mul_m3_v3(mat, disp); if(d->invert) { - VecCopyf(data, disp); + copy_v3_v3(data, disp); } else { if(d->type == 4 || d->type == 5) - VecMulf(disp, d->weight); - VecAddf(co, co, disp); + mul_v3_fl(disp, d->weight); + add_v3_v3v3(co, co, disp); } if(d->type == 2) { @@ -1200,7 +1200,7 @@ static void multiresModifier_update(DerivedMesh *dm) /* Subtract the original vertex cos from the new vertex cos */ verts_new = CDDM_get_verts(dm); for(i = 0; i < dm->getNumVerts(dm); ++i) - VecSubf(verts_new[i].co, verts_new[i].co, cur_lvl_orig_verts[i].co); + sub_v3_v3v3(verts_new[i].co, verts_new[i].co, cur_lvl_orig_verts[i].co); final = multires_subdisp_pre(dm, totlvl - lvl, 0); @@ -1579,7 +1579,7 @@ void multires_load_old(DerivedMesh *dm, Multires *mr) /* Transfer verts */ for(i = 0; i < totvert; ++i) - VecCopyf(vdst[i].co, vsrc[vvmap[i]].co); + copy_v3_v3(vdst[i].co, vsrc[vvmap[i]].co); MEM_freeN(vvmap); } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index f6d6bb14b7e..708ef9829e1 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -53,7 +53,7 @@ #include "BKE_text.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ba8d41f54bb..f363b7d9a0a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -70,7 +70,7 @@ #include "DNA_world_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BKE_utildefines.h" @@ -740,13 +740,13 @@ float dof_camera(Object *ob) return 0.0f; if (cam->dof_ob) { /* too simple, better to return the distance on the view axis only - * return VecLenf(ob->obmat[3], cam->dof_ob->obmat[3]); */ + * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */ float mat[4][4], obmat[4][4]; - Mat4CpyMat4(obmat, ob->obmat); - Mat4Ortho(obmat); - Mat4Invert(ob->imat, obmat); - Mat4MulMat4(mat, cam->dof_ob->obmat, ob->imat); + copy_m4_m4(obmat, ob->obmat); + normalize_m4(obmat); + invert_m4_m4(ob->imat, obmat); + mul_m4_m4m4(mat, cam->dof_ob->obmat, ob->imat); return (float)fabs(mat[3][2]); } return cam->YF_dofdist; @@ -965,8 +965,8 @@ Object *add_only_object(int type, char *name) /* ob->transflag= OB_QUAT; */ #if 0 /* not used yet */ - QuatOne(ob->quat); - QuatOne(ob->dquat); + unit_qt(ob->quat); + unit_qt(ob->dquat); #endif ob->col[0]= ob->col[1]= ob->col[2]= 1.0; @@ -976,9 +976,9 @@ Object *add_only_object(int type, char *name) ob->rot[0]= ob->rot[1]= ob->rot[2]= 0.0; ob->size[0]= ob->size[1]= ob->size[2]= 1.0; - Mat4One(ob->constinv); - Mat4One(ob->parentinv); - Mat4One(ob->obmat); + unit_m4(ob->constinv); + unit_m4(ob->parentinv); + unit_m4(ob->obmat); ob->dt= OB_SHADED; ob->empty_drawtype= OB_ARROWS; ob->empty_drawsize= 1.0; @@ -1464,7 +1464,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) } ob->parent= target->parent; /* libdata */ - Mat4CpyMat4(ob->parentinv, target->parentinv); + copy_m4_m4(ob->parentinv, target->parentinv); /* copy animdata stuff - drivers only for now... */ if ((target->adt) && (target->adt->drivers.first)) { @@ -1588,7 +1588,7 @@ void object_scale_to_mat3(Object *ob, float mat[][3]) vec[0]= ob->size[0]+ob->dsize[0]; vec[1]= ob->size[1]+ob->dsize[1]; vec[2]= ob->size[2]+ob->dsize[2]; - SizeToMat3(vec, mat); + size_to_mat3( mat,vec); } // TODO: this should take rotation orders into account later... @@ -1599,29 +1599,29 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) /* initialise the delta-rotation matrix, which will get (pre)multiplied * with the rotation matrix to yield the appropriate rotation */ - Mat3One(dmat); + unit_m3(dmat); /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */ if (ob->rotmode > 0) { /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */ - EulOToMat3(ob->rot, ob->rotmode, rmat); - EulOToMat3(ob->drot, ob->rotmode, dmat); + eulO_to_mat3( rmat,ob->rot, ob->rotmode); + eulO_to_mat3( dmat,ob->drot, ob->rotmode); } else if (ob->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - not really that great for 3D-changing orientations */ - AxisAngleToMat3(ob->rotAxis, ob->rotAngle, rmat); - AxisAngleToMat3(ob->drotAxis, ob->drotAngle, dmat); + axis_angle_to_mat3( rmat,ob->rotAxis, ob->rotAngle); + axis_angle_to_mat3( dmat,ob->drotAxis, ob->drotAngle); } else { /* quats are normalised before use to eliminate scaling issues */ - NormalQuat(ob->quat); - QuatToMat3(ob->quat, rmat); - QuatToMat3(ob->dquat, dmat); + normalize_qt(ob->quat); + quat_to_mat3( rmat,ob->quat); + quat_to_mat3( dmat,ob->dquat); } /* combine these rotations */ // XXX is this correct? if errors, change the order of multiplication... - Mat3MulMat3(mat, dmat, rmat); + mul_m3_m3m3(mat, dmat, rmat); } void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ @@ -1635,7 +1635,7 @@ void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ /* rot */ object_rot_to_mat3(ob, rmat); - Mat3MulMat3(mat, rmat, smat); + mul_m3_m3m3(mat, rmat, smat); } void object_to_mat4(Object *ob, float mat[][4]) @@ -1644,7 +1644,7 @@ void object_to_mat4(Object *ob, float mat[][4]) object_to_mat3(ob, tmat); - Mat4CpyMat3(mat, tmat); + copy_m4_m3(mat, tmat); mat[3][0]= ob->loc[0] + ob->dloc[0]; mat[3][1]= ob->loc[1] + ob->dloc[1]; @@ -1659,7 +1659,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) float q[4], vec[4], dir[3], quat[4], radius, x1, ctime; float timeoffs = 0.0, sf_orig = 0.0; - Mat4One(mat); + unit_m4(mat); cu= par->data; if(cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */ @@ -1707,25 +1707,25 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) if( where_on_path(par, ctime, vec, dir, NULL, &radius) ) { if(cu->flag & CU_FOLLOW) { - vectoquat(dir, ob->trackflag, ob->upflag, quat); + vec_to_quat( quat,dir, ob->trackflag, ob->upflag); /* the tilt */ - Normalize(dir); + normalize_v3(dir); q[0]= (float)cos(0.5*vec[3]); x1= (float)sin(0.5*vec[3]); q[1]= -x1*dir[0]; q[2]= -x1*dir[1]; q[3]= -x1*dir[2]; - QuatMul(quat, q, quat); + mul_qt_qtqt(quat, q, quat); - QuatToMat4(quat, mat); + quat_to_mat4( mat,quat); } if(cu->flag & CU_PATH_RADIUS) { float tmat[4][4], rmat[4][4]; - Mat4Scale(tmat, radius); - Mat4MulMat4(rmat, mat, tmat); - Mat4CpyMat4(mat, rmat); + scale_m4_fl(tmat, radius); + mul_m4_m4m4(rmat, mat, tmat); + copy_m4_m4(mat, rmat); } VECCOPY(mat[3], vec); @@ -1739,7 +1739,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) float vec[3]; if (par->type!=OB_ARMATURE) { - Mat4One(mat); + unit_m4(mat); return; } @@ -1747,17 +1747,17 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) pchan= get_pose_channel(par->pose, ob->parsubstr); if (!pchan){ printf ("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name+2, ob->parsubstr); - Mat4One(mat); + unit_m4(mat); return; } /* get bone transform */ - Mat4CpyMat4(mat, pchan->pose_mat); + copy_m4_m4(mat, pchan->pose_mat); /* but for backwards compatibility, the child has to move to the tail */ VECCOPY(vec, mat[1]); - VecMulf(vec, pchan->bone->length); - VecAddf(mat[3], mat[3], vec); + mul_v3_fl(vec, pchan->bone->length); + add_v3_v3v3(mat[3], mat[3], vec); } static void give_parvert(Object *par, int nr, float *vec) @@ -1794,7 +1794,7 @@ static void give_parvert(Object *par, int nr, float *vec) for(i = 0; i < numVerts; ++i, ++index) { if(*index == nr) { dm->getVertCo(dm, i, co); - VecAddf(vec, vec, co); + add_v3_v3v3(vec, vec, co); count++; } } @@ -1802,7 +1802,7 @@ static void give_parvert(Object *par, int nr, float *vec) if (count==0) { /* keep as 0,0,0 */ } else if(count > 0) { - VecMulf(vec, 1.0f / count); + mul_v3_fl(vec, 1.0f / count); } else { /* use first index if its out of range */ dm->getVertCo(dm, 0, vec); @@ -1886,7 +1886,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4]) float cmat[3][3], v1[3], v2[3], v3[3], q[4]; /* in local ob space */ - Mat4One(mat); + unit_m4(mat); if (ELEM4(par->type, OB_MESH, OB_SURF, OB_CURVE, OB_LATTICE)) { @@ -1894,17 +1894,17 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4]) give_parvert(par, ob->par2, v2); give_parvert(par, ob->par3, v3); - triatoquat(v1, v2, v3, q); - QuatToMat3(q, cmat); - Mat4CpyMat3(mat, cmat); + tri_to_quat( q,v1, v2, v3); + quat_to_mat3( cmat,q); + copy_m4_m3(mat, cmat); if(ob->type==OB_CURVE) { VECCOPY(mat[3], v1); } else { - VecAddf(mat[3], v1, v2); - VecAddf(mat[3], mat[3], v3); - VecMulf(mat[3], 0.3333333f); + add_v3_v3v3(mat[3], v1, v2); + add_v3_v3v3(mat[3], mat[3], v3); + mul_v3_fl(mat[3], 0.3333333f); } } } @@ -1992,8 +1992,8 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) } /* set negative scale flag in object */ - Crossf(vec, ob->obmat[0], ob->obmat[1]); - if( Inpf(vec, ob->obmat[2]) < 0.0 ) ob->transflag |= OB_NEG_SCALE; + cross_v3_v3v3(vec, ob->obmat[0], ob->obmat[1]); + if( dot_v3v3(vec, ob->obmat[2]) < 0.0 ) ob->transflag |= OB_NEG_SCALE; else ob->transflag &= ~OB_NEG_SCALE; } @@ -2007,7 +2007,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ object_to_mat4(ob, locmat); - if(ob->partype & PARSLOW) Mat4CpyMat4(slowmat, obmat); + if(ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat); switch(ob->partype & PARTYPE) { case PAROBJECT: @@ -2019,43 +2019,43 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ } } - if(ok) Mat4MulSerie(totmat, par->obmat, tmat, + if(ok) mul_serie_m4(totmat, par->obmat, tmat, NULL, NULL, NULL, NULL, NULL, NULL); - else Mat4CpyMat4(totmat, par->obmat); + else copy_m4_m4(totmat, par->obmat); break; case PARBONE: ob_parbone(ob, par, tmat); - Mat4MulSerie(totmat, par->obmat, tmat, + mul_serie_m4(totmat, par->obmat, tmat, NULL, NULL, NULL, NULL, NULL, NULL); break; case PARVERT1: - Mat4One(totmat); + unit_m4(totmat); if (simul){ VECCOPY(totmat[3], par->obmat[3]); } else{ give_parvert(par, ob->par1, vec); - VecMat4MulVecfl(totmat[3], par->obmat, vec); + mul_v3_m4v3(totmat[3], par->obmat, vec); } break; case PARVERT3: ob_parvert3(ob, par, tmat); - Mat4MulSerie(totmat, par->obmat, tmat, + mul_serie_m4(totmat, par->obmat, tmat, NULL, NULL, NULL, NULL, NULL, NULL); break; case PARSKEL: - Mat4CpyMat4(totmat, par->obmat); + copy_m4_m4(totmat, par->obmat); break; } // total - Mat4MulSerie(tmat, totmat, ob->parentinv, + mul_serie_m4(tmat, totmat, ob->parentinv, NULL, NULL, NULL, NULL, NULL, NULL); - Mat4MulSerie(obmat, tmat, locmat, + mul_serie_m4(obmat, tmat, locmat, NULL, NULL, NULL, NULL, NULL, NULL); if (simul) { @@ -2063,7 +2063,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ } else{ // external usable originmat - Mat3CpyMat4(originmat, tmat); + copy_m3_m4(originmat, tmat); // origin, voor help line if( (ob->partype & 15)==PARSKEL ) { @@ -2082,9 +2082,9 @@ void solve_tracking (Object *ob, float targetmat[][4]) float totmat[3][3]; float tmat[4][4]; - VecSubf(vec, ob->obmat[3], targetmat[3]); - vectoquat(vec, ob->trackflag, ob->upflag, quat); - QuatToMat3(quat, totmat); + sub_v3_v3v3(vec, ob->obmat[3], targetmat[3]); + vec_to_quat( quat,vec, ob->trackflag, ob->upflag); + quat_to_mat3( totmat,quat); if(ob->parent && (ob->transflag & OB_POWERTRACK)) { /* 'temporal' : clear parent info */ @@ -2097,9 +2097,9 @@ void solve_tracking (Object *ob, float targetmat[][4]) tmat[3][2]= ob->obmat[3][2]; tmat[3][3]= ob->obmat[3][3]; } - else Mat4CpyMat4(tmat, ob->obmat); + else copy_m4_m4(tmat, ob->obmat); - Mat4MulMat34(ob->obmat, totmat, tmat); + mul_m4_m3m4(ob->obmat, totmat, tmat); } @@ -2171,9 +2171,9 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob) { clear_workob(workob); - Mat4One(workob->obmat); - Mat4One(workob->parentinv); - Mat4One(workob->constinv); + unit_m4(workob->obmat); + unit_m4(workob->parentinv); + unit_m4(workob->constinv); workob->parent= ob->parent; workob->track= ob->track; @@ -2261,7 +2261,7 @@ void minmax_object(Object *ob, float *min, float *max) bb= *(cu->bb); for(a=0; a<8; a++) { - Mat4MulVecfl(ob->obmat, bb.vec[a]); + mul_m4_v3(ob->obmat, bb.vec[a]); DO_MINMAX(bb.vec[a], min, max); } break; @@ -2270,10 +2270,10 @@ void minmax_object(Object *ob, float *min, float *max) bPoseChannel *pchan; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { VECCOPY(vec, pchan->pose_head); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); DO_MINMAX(vec, min, max); VECCOPY(vec, pchan->pose_tail); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); DO_MINMAX(vec, min, max); } break; @@ -2286,7 +2286,7 @@ void minmax_object(Object *ob, float *min, float *max) bb = *mesh_get_bb(ob); for(a=0; a<8; a++) { - Mat4MulVecfl(ob->obmat, bb.vec[a]); + mul_m4_v3(ob->obmat, bb.vec[a]); DO_MINMAX(bb.vec[a], min, max); } } @@ -2298,11 +2298,11 @@ void minmax_object(Object *ob, float *min, float *max) DO_MINMAX(ob->obmat[3], min, max); VECCOPY(vec, ob->obmat[3]); - VecAddf(vec, vec, ob->size); + add_v3_v3v3(vec, vec, ob->size); DO_MINMAX(vec, min, max); VECCOPY(vec, ob->obmat[3]); - VecSubf(vec, vec, ob->size); + sub_v3_v3v3(vec, vec, ob->size); DO_MINMAX(vec, min, max); break; } @@ -2353,11 +2353,11 @@ void object_handle_update(Scene *scene, Object *ob) // printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); if(ob->proxy_from->proxy_group) {/* transform proxy into group space */ Object *obg= ob->proxy_from->proxy_group; - Mat4Invert(obg->imat, obg->obmat); - Mat4MulMat4(ob->obmat, ob->proxy_from->obmat, obg->imat); + invert_m4_m4(obg->imat, obg->obmat); + mul_m4_m4m4(ob->obmat, ob->proxy_from->obmat, obg->imat); } else - Mat4CpyMat4(ob->obmat, ob->proxy_from->obmat); + copy_m4_m4(ob->obmat, ob->proxy_from->obmat); } else where_is_object(scene, ob); @@ -2538,7 +2538,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3 v1 = triangle_indexes[i][0]; v2 = triangle_indexes[i][1]; v3 = triangle_indexes[i][2]; - result = RayIntersectsTriangle(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL); + result = isect_ray_tri_v3(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL); } return result; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 24d6b229297..e241d5808cd 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -51,7 +51,7 @@ #include "DNA_smoke_types.h" #include "DNA_texture_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_kdtree.h" @@ -618,12 +618,12 @@ static float psys_render_projected_area(ParticleSystem *psys, float *center, flo /* transform to view space */ VECCOPY(co, center); co[3]= 1.0f; - Mat4MulVec4fl(data->viewmat, co); + mul_m4_v4(data->viewmat, co); /* compute two vectors orthogonal to view vector */ VECCOPY(view, co); - Normalize(view); - VecOrthoBasisf(view, ortho1, ortho2); + normalize_v3(view); + ortho_basis_v3v3_v3( ortho1, ortho2,view); /* compute on screen minification */ w= co[2]*data->winmat[2][3] + data->winmat[3][3]; @@ -637,7 +637,7 @@ static float psys_render_projected_area(ParticleSystem *psys, float *center, flo /* viewport of the screen test */ /* project point on screen */ - Mat4MulVec4fl(data->winmat, co); + mul_m4_v4(data->winmat, co); if(co[3] != 0.0f) { co[0]= 0.5f*data->winx*(1.0f + co[0]/co[3]); co[1]= 0.5f*data->winy*(1.0f + co[1]/co[3]); @@ -698,9 +698,9 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float psys->pathcachebufs.first = psys->pathcachebufs.last = NULL; psys->childcachebufs.first = psys->childcachebufs.last = NULL; - Mat4CpyMat4(data->winmat, winmat); - Mat4MulMat4(data->viewmat, ob->obmat, viewmat); - Mat4MulMat4(data->mat, data->viewmat, winmat); + copy_m4_m4(data->winmat, winmat); + mul_m4_m4m4(data->viewmat, ob->obmat, viewmat); + mul_m4_m4m4(data->mat, data->viewmat, winmat); data->winx= winx; data->winy= winy; @@ -828,11 +828,11 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) if(mf->v4) { VECCOPY(co4, mvert[mf->v4].co); VECADD(facecenter[b], facecenter[b], co4); - facearea[b] += AreaQ3Dfl(co1, co2, co3, co4); + facearea[b] += area_quad_v3(co1, co2, co3, co4); facetotvert[b] += 4; } else { - facearea[b] += AreaT3Dfl(co1, co2, co3); + facearea[b] += area_tri_v3(co1, co2, co3); facetotvert[b] += 3; } } @@ -840,7 +840,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) for(a=0; a 0) - VecMulf(facecenter[a], 1.0f/facetotvert[a]); + mul_v3_fl(facecenter[a], 1.0f/facetotvert[a]); /* for conversion from BU area / pixel area to reference screen size */ mesh_get_texspace(me, 0, 0, size); @@ -1007,7 +1007,7 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic float t[4]; if(type<0) { - VecfCubicInterpol(keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt, result->co, result->vel); + interp_cubic_v3( result->co, result->vel,keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt); } else { key_curve_position_weights(dt, t, type); @@ -1280,9 +1280,9 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData /* convert velocity to timestep size */ if(pind->keyed || pind->cache || point_vel){ - VecMulf(keys[1].vel, dfra / frs_sec); - VecMulf(keys[2].vel, dfra / frs_sec); - QuatInterpol(result->rot,keys[1].rot,keys[2].rot,keytime); + mul_v3_fl(keys[1].vel, dfra / frs_sec); + mul_v3_fl(keys[2].vel, dfra / frs_sec); + interp_qt_qtqt(result->rot,keys[1].rot,keys[2].rot,keytime); } /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0,1]->[k2,k3] (k1 & k4 used for cardinal & bspline interpolation)*/ @@ -1292,7 +1292,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData /* the velocity needs to be converted back from cubic interpolation */ if(pind->keyed || pind->cache || point_vel) - VecMulf(result->vel, frs_sec / dfra); + mul_v3_fl(result->vel, frs_sec / dfra); } /************************************************/ /* Particles on a dm */ @@ -1312,14 +1312,14 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or VECCOPY(n1,(mvert+mface->v1)->no); VECCOPY(n2,(mvert+mface->v2)->no); VECCOPY(n3,(mvert+mface->v3)->no); - Normalize(n1); - Normalize(n2); - Normalize(n3); + normalize_v3(n1); + normalize_v3(n2); + normalize_v3(n3); if(mface->v4) { v4= (mvert+mface->v4)->co; VECCOPY(n4,(mvert+mface->v4)->no); - Normalize(n4); + normalize_v3(n4); vec[0]= w[0]*v1[0] + w[1]*v2[0] + w[2]*v3[0] + w[3]*v4[0]; vec[1]= w[0]*v1[1] + w[1]*v2[1] + w[2]*v3[1] + w[3]*v4[1]; @@ -1332,7 +1332,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2] + w[3]*n4[2]; } else - CalcNormFloat4(v1,v2,v3,v4,nor); + normal_quad_v3(nor,v1,v2,v3,v4); } } else { @@ -1347,7 +1347,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2]; } else - CalcNormFloat(v1,v2,v3,nor); + normal_tri_v3(nor,v1,v2,v3); } } @@ -1361,11 +1361,11 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or } else{ uv1= tuv[0]; uv2= tuv[1]; uv3= tuv[2]; uv4= tuv[3]; - spheremap(v1[0], v1[1], v1[2], uv1, uv1+1); - spheremap(v2[0], v2[1], v2[2], uv2, uv2+1); - spheremap(v3[0], v3[1], v3[2], uv3, uv3+1); + map_to_sphere( uv1, uv1+1,v1[0], v1[1], v1[2]); + map_to_sphere( uv2, uv2+1,v2[0], v2[1], v2[2]); + map_to_sphere( uv3, uv3+1,v3[0], v3[1], v3[2]); if(v4) - spheremap(v4[0], v4[1], v4[2], uv4, uv4+1); + map_to_sphere( uv4, uv4+1,v4[0], v4[1], v4[2]); } if(v4){ @@ -1375,8 +1375,8 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or t1= uv3[1] - uv1[1]; t2= uv4[1] - uv1[1]; - VecSubf(e1, v3, v1); - VecSubf(e2, v4, v1); + sub_v3_v3v3(e1, v3, v1); + sub_v3_v3v3(e2, v4, v1); } else{ s1= uv2[0] - uv1[0]; @@ -1385,8 +1385,8 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or t1= uv2[1] - uv1[1]; t2= uv3[1] - uv1[1]; - VecSubf(e1, v2, v1); - VecSubf(e2, v3, v1); + sub_v3_v3v3(e1, v2, v1); + sub_v3_v3v3(e2, v3, v1); } vtan[0] = (s1*e2[0] - s2*e1[0]); @@ -1411,7 +1411,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2] + w[3]*o4[2]; if(ornor) - CalcNormFloat4(o1, o2, o3, o4, ornor); + normal_quad_v3( ornor,o1, o2, o3, o4); } else { orco[0]= w[0]*o1[0] + w[1]*o2[0] + w[2]*o3[0]; @@ -1419,7 +1419,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2]; if(ornor) - CalcNormFloat(o1, o2, o3, ornor); + normal_tri_v3( ornor,o1, o2, o3); } } else { @@ -1517,10 +1517,10 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, float *w, float if(quad) { v[3][0]= osface->uv[3][0]; v[3][1]= osface->uv[3][1]; v[3][2]= 0.0f; - MeanValueWeights(v, 4, co, neww); + interp_weights_poly_v3( neww,v, 4, co); } else { - MeanValueWeights(v, 3, co, neww); + interp_weights_poly_v3( neww,v, 3, co); neww[3]= 0.0f; } } @@ -1566,10 +1566,10 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, float * /* check that this intersects - Its possible this misses :/ - * could also check its not between */ if(quad) { - if(IsectPQ2Df(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) + if(isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) return findex; } - else if(IsectPT2Df(uv, faceuv[0], faceuv[1], faceuv[2])) + else if(isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2])) return findex; } } @@ -1582,10 +1582,10 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, float * /* check that this intersects - Its possible this misses :/ - * could also check its not between */ if(quad) { - if(IsectPQ2Df(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) + if(isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3])) return findex; } - else if(IsectPT2Df(uv, faceuv[0], faceuv[1], faceuv[2])) + else if(isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2])) return findex; } } @@ -1678,7 +1678,7 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache if(nor) { dm->getVertNo(dm,mapindex,nor); - Normalize(nor); + normalize_v3(nor); } if(orco) @@ -1686,7 +1686,7 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache if(ornor) { dm->getVertNo(dm,mapindex,nor); - Normalize(nor); + normalize_v3(nor); } if(utan && vtan) { @@ -1711,8 +1711,8 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache if(nor) VECCOPY(nor,tmpnor); - Normalize(tmpnor); - VecMulf(tmpnor,-foffset); + normalize_v3(tmpnor); + mul_v3_fl(tmpnor,-foffset); VECADD(vec,vec,tmpnor); } else @@ -1835,42 +1835,42 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo if(par_rot) QUATCOPY(q2,par_rot) else - vectoquat(par->vel,axis,(axis+1)%3, q2); - QuatMulVecf(q2,vec); - VecMulf(vec,amplitude); + vec_to_quat( q2,par->vel,axis,(axis+1)%3); + mul_qt_v3(q2,vec); + mul_v3_fl(vec,amplitude); VECADD(state->co,state->co,vec); VECSUB(vec,state->co,par->co); if(t!=0.0) - VecRotToQuat(par->vel,t,q1); + axis_angle_to_quat(q1,par->vel,t); - QuatMulVecf(q1,vec); + mul_qt_v3(q1,vec); VECADD(state->co,par->co,vec); break; case PART_KINK_RADIAL: VECSUB(vec,state->co,par->co); - Normalize(vec); - VecMulf(vec,amplitude*(float)sin(t)); + normalize_v3(vec); + mul_v3_fl(vec,amplitude*(float)sin(t)); VECADD(state->co,state->co,vec); break; case PART_KINK_WAVE: vec[axis]=1.0; if(obmat) - Mat4Mul3Vecfl(obmat,vec); + mul_mat3_m4_v3(obmat,vec); if(par_rot) - QuatMulVecf(par_rot,vec); + mul_qt_v3(par_rot,vec); - Projf(q1,vec,par->vel); + project_v3_v3v3(q1,vec,par->vel); VECSUB(vec,vec,q1); - Normalize(vec); + normalize_v3(vec); - VecMulf(vec,amplitude*(float)sin(t)); + mul_v3_fl(vec,amplitude*(float)sin(t)); VECADD(state->co,state->co,vec); break; @@ -1884,46 +1884,46 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo if(par_rot) QUATCOPY(q2,par_rot) else - vectoquat(par->vel,axis,(axis+1)%3,q2); - QuatMulVecf(q2,y_vec); - QuatMulVecf(q2,z_vec); + vec_to_quat(q2,par->vel,axis,(axis+1)%3); + mul_qt_v3(q2,y_vec); + mul_qt_v3(q2,z_vec); VECSUB(vec_from_par,state->co,par->co); VECCOPY(vec_one,vec_from_par); - radius=Normalize(vec_one); + radius=normalize_v3(vec_one); - inp_y=Inpf(y_vec,vec_one); - inp_z=Inpf(z_vec,vec_one); + inp_y=dot_v3v3(y_vec,vec_one); + inp_z=dot_v3v3(z_vec,vec_one); if(inp_y>0.5){ VECCOPY(state_co,y_vec); - VecMulf(y_vec,amplitude*(float)cos(t)); - VecMulf(z_vec,amplitude/2.0f*(float)sin(2.0f*t)); + mul_v3_fl(y_vec,amplitude*(float)cos(t)); + mul_v3_fl(z_vec,amplitude/2.0f*(float)sin(2.0f*t)); } else if(inp_z>0.0){ VECCOPY(state_co,z_vec); - VecMulf(state_co,(float)sin(M_PI/3.0f)); + mul_v3_fl(state_co,(float)sin(M_PI/3.0f)); VECADDFAC(state_co,state_co,y_vec,-0.5f); - VecMulf(y_vec,-amplitude*(float)cos(t + M_PI/3.0f)); - VecMulf(z_vec,amplitude/2.0f*(float)cos(2.0f*t + M_PI/6.0f)); + mul_v3_fl(y_vec,-amplitude*(float)cos(t + M_PI/3.0f)); + mul_v3_fl(z_vec,amplitude/2.0f*(float)cos(2.0f*t + M_PI/6.0f)); } else{ VECCOPY(state_co,z_vec); - VecMulf(state_co,-(float)sin(M_PI/3.0f)); + mul_v3_fl(state_co,-(float)sin(M_PI/3.0f)); VECADDFAC(state_co,state_co,y_vec,-0.5f); - VecMulf(y_vec,amplitude*(float)-sin(t+M_PI/6.0f)); - VecMulf(z_vec,amplitude/2.0f*(float)-sin(2.0f*t+M_PI/3.0f)); + mul_v3_fl(y_vec,amplitude*(float)-sin(t+M_PI/6.0f)); + mul_v3_fl(z_vec,amplitude/2.0f*(float)-sin(2.0f*t+M_PI/3.0f)); } - VecMulf(state_co,amplitude); + mul_v3_fl(state_co,amplitude); VECADD(state_co,state_co,par->co); VECSUB(vec_from_par,state->co,state_co); - length=Normalize(vec_from_par); - VecMulf(vec_from_par,MIN2(length,amplitude/2.0f)); + length=normalize_v3(vec_from_par); + mul_v3_fl(vec_from_par,MIN2(length,amplitude/2.0f)); VECADD(state_co,par->co,y_vec); VECADD(state_co,state_co,z_vec); @@ -1934,7 +1934,7 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo if(tco,state->co,state_co,shape); + interp_v3_v3v3(state->co,state->co,state_co,shape); } else{ VECCOPY(state->co,state_co); @@ -1958,7 +1958,7 @@ static void do_clump(ParticleKey *state, ParticleKey *par, float time, float clu clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time,(double)cpow); else clump = clumpfac*pa_clump*(float)pow((double)time,(double)cpow); - VecLerpf(state->co,state->co,par->co,clump); + interp_v3_v3v3(state->co,state->co,par->co,clump); } } void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) @@ -1990,7 +1990,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) VECSUB(efd.vec_to_point, state.co, eff->guide_loc); VECCOPY(efd.nor, eff->guide_dir); - efd.distance = VecLength(efd.vec_to_point); + efd.distance = len_v3(efd.vec_to_point); VECCOPY(data->vec_to_point, efd.vec_to_point); data->strength = effector_falloff(eff, &efd, &point, weights); @@ -2037,33 +2037,33 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) return 0; } - Mat4MulVecfl(eff->ob->obmat, guidevec); - Mat4Mul3Vecfl(eff->ob->obmat, guidedir); + mul_m4_v3(eff->ob->obmat, guidevec); + mul_mat3_m4_v3(eff->ob->obmat, guidedir); - Normalize(guidedir); + normalize_v3(guidedir); VECCOPY(vec_to_point, data->vec_to_point); if(guidetime != 0.0){ /* curve direction */ - Crossf(temp, eff->guide_dir, guidedir); - angle = Inpf(eff->guide_dir, guidedir)/(VecLength(eff->guide_dir)); + cross_v3_v3v3(temp, eff->guide_dir, guidedir); + angle = dot_v3v3(eff->guide_dir, guidedir)/(len_v3(eff->guide_dir)); angle = saacos(angle); - VecRotToQuat(temp, angle, rot2); - QuatMulVecf(rot2, vec_to_point); + axis_angle_to_quat( rot2,temp, angle); + mul_qt_v3(rot2, vec_to_point); /* curve tilt */ - VecRotToQuat(guidedir, guidevec[3] - eff->guide_loc[3], rot2); - QuatMulVecf(rot2, vec_to_point); + axis_angle_to_quat( rot2,guidedir, guidevec[3] - eff->guide_loc[3]); + mul_qt_v3(rot2, vec_to_point); } /* curve taper */ if(cu->taperobj) - VecMulf(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0), 100)); + mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0), 100)); else{ /* curve size*/ if(cu->flag & CU_PATH_RADIUS) { - VecMulf(vec_to_point, radius); + mul_v3_fl(vec_to_point, radius); } } par.co[0] = par.co[1] = par.co[2] = 0.0f; @@ -2081,13 +2081,13 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) if(totstrength != 0.0){ if(totstrength > 1.0) - VecMulf(effect, 1.0f / totstrength); + mul_v3_fl(effect, 1.0f / totstrength); CLAMP(totstrength, 0.0, 1.0); //VECADD(effect,effect,pa_zero); - VecLerpf(state->co, state->co, effect, totstrength); + interp_v3_v3v3(state->co, state->co, effect, totstrength); - Normalize(veffect); - VecMulf(veffect, VecLength(state->vel)); + normalize_v3(veffect); + mul_v3_fl(veffect, len_v3(state->vel)); VECCOPY(state->vel, veffect); return 1; } @@ -2102,7 +2102,7 @@ static void do_rough(float *loc, float mat[4][4], float t, float fac, float size if((float)fabs((float)(-1.5+loc[0]+loc[1]+loc[2]))<1.5f*thres) return; VECCOPY(rco,loc); - VecMulf(rco,t); + mul_v3_fl(rco,t); rough[0]=-1.0f+2.0f*BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2,0,2); rough[1]=-1.0f+2.0f*BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2,0,2); rough[2]=-1.0f+2.0f*BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2,0,2); @@ -2117,10 +2117,10 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float float roughfac; roughfac=fac*(float)pow((double)t,shape); - Vec2Copyf(rough,loc); + copy_v2_v2(rough,loc); rough[0]=-1.0f+2.0f*rough[0]; rough[1]=-1.0f+2.0f*rough[1]; - Vec2Mulf(rough,roughfac); + mul_v2_fl(rough,roughfac); VECADDFAC(state->co,state->co,mat[0],rough[0]); VECADDFAC(state->co,state->co,mat[1],rough[1]); @@ -2142,23 +2142,23 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK pd_point_from_particle(sim, sim->psys->particles+i, &eff_key, &epoint); pdDoEffectors(sim->psys->effectors, sim->colliders, sim->psys->part->effector_weights, &epoint, force, NULL); - VecMulf(force, effector*pow((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); + mul_v3_fl(force, effector*pow((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); - VecAddf(force, force, vec); + add_v3_v3v3(force, force, vec); - Normalize(force); + normalize_v3(force); VECADDFAC(ca->co, (ca-1)->co, force, *length); if(k < steps) { - VecSubf(vec, (ca+1)->co, ca->co); - *length = VecLength(vec); + sub_v3_v3v3(vec, (ca+1)->co, ca->co); + *length = len_v3(vec); } } static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *state, float max_length, float *cur_length, float length, float *dvec) { if(*cur_length + length > max_length){ - VecMulf(dvec, (max_length - *cur_length) / length); + mul_v3_fl(dvec, (max_length - *cur_length) / length); VECADD(state->co, (state - 1)->co, dvec); keys->steps = k; /* something over the maximum step value */ @@ -2172,13 +2172,13 @@ static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *st static void offset_child(ChildParticle *cpa, ParticleKey *par, ParticleKey *child, float flat, float radius) { VECCOPY(child->co,cpa->fuv); - VecMulf(child->co,radius); + mul_v3_fl(child->co,radius); child->co[0]*=flat; VECCOPY(child->vel,par->vel); - QuatMulVecf(par->rot,child->co); + mul_qt_v3(par->rot,child->co); QUATCOPY(child->rot,par->rot); @@ -2247,14 +2247,14 @@ static void get_strand_normal(Material *ma, float *surfnor, float surfdist, floa return; if(ma->mode & MA_STR_SURFDIFF) { - Crossf(cross, surfnor, nor); - Crossf(nstrand, nor, cross); + cross_v3_v3v3(cross, surfnor, nor); + cross_v3_v3v3(nstrand, nor, cross); blend= INPR(nstrand, surfnor); CLAMP(blend, 0.0f, 1.0f); - VecLerpf(vnor, nstrand, surfnor, blend); - Normalize(vnor); + interp_v3_v3v3(vnor, nstrand, surfnor, blend); + normalize_v3(vnor); } else VECCOPY(vnor, nor) @@ -2262,8 +2262,8 @@ static void get_strand_normal(Material *ma, float *surfnor, float surfdist, floa if(ma->strand_surfnor > 0.0f) { if(ma->strand_surfnor > surfdist) { blend= (ma->strand_surfnor - surfdist)/ma->strand_surfnor; - VecLerpf(vnor, vnor, surfnor, blend); - Normalize(vnor); + interp_v3_v3v3(vnor, vnor, surfnor, blend); + normalize_v3(vnor); } } @@ -2440,7 +2440,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if(part->path_start==0.0f) { /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */ VECCOPY(cpa_1st,co); - Mat4MulVecfl(ob->obmat,cpa_1st); + mul_m4_v3(ob->obmat,cpa_1st); } pa = psys->particles + cpa->parent; @@ -2538,8 +2538,8 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle do_path_effectors(&ctx->sim, cpa->pa[0], state, k, ctx->steps, keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec); } else { - VecSubf(eff_vec,(state+1)->co,state->co); - eff_length= VecLength(eff_vec); + sub_v3_v3v3(eff_vec,(state+1)->co,state->co); + eff_length= len_v3(eff_vec); } } } @@ -2599,17 +2599,17 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle // } // if(itotpart) - // VecLerpf(state->co, (pcache[i] + k)->co, state->co, branchfac); + // interp_v3_v3v3(state->co, (pcache[i] + k)->co, state->co, branchfac); // else // /* this is not threadsafe, but should only happen for // * branching particles particles, which are not threaded */ - // VecLerpf(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac); + // interp_v3_v3v3(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac); //} /* we have to correct velocity because of kink & clump */ if(k>1){ VECSUB((state-1)->vel,state->co,(state-2)->co); - VecMulf((state-1)->vel,0.5); + mul_v3_fl((state-1)->vel,0.5); if(ctx->ma && (part->draw & PART_DRAW_MAT_COL)) get_strand_normal(ctx->ma, ornor, cur_length, (state-1)->vel); @@ -2841,9 +2841,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* dynamic hair is in object space */ /* keyed and baked are allready in global space */ if(hair_dm) - Mat4MulVecfl(sim->ob->obmat, result.co); + mul_m4_v3(sim->ob->obmat, result.co); else if(!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) - Mat4MulVecfl(hairmat, result.co); + mul_m4_v3(hairmat, result.co); VECCOPY(ca->co, result.co); VECCOPY(ca->col, col); @@ -2851,8 +2851,8 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /*--modify paths and calculate rotation & velocity--*/ - VecSubf(vec,(cache[p]+1)->co,cache[p]->co); - length = VecLength(vec); + sub_v3_v3v3(vec,(cache[p]+1)->co,cache[p]->co); + length = len_v3(vec); effector= 1.0f; if(vg_effector) @@ -2882,7 +2882,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* calculate initial tangent for incremental rotations */ VECSUB(tangent, ca->co, (ca - 1)->co); VECCOPY(prev_tangent, tangent); - Normalize(prev_tangent); + normalize_v3(prev_tangent); /* First rotation is based on emitting face orientation. */ /* This is way better than having flipping rotations resulting */ @@ -2890,13 +2890,13 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* It's not an ideal solution though since it disregards the */ /* initial tangent, but taking that in to account will allow */ /* the possibility of flipping again. -jahka */ - Mat3ToQuat_is_ok(rotmat, (ca-1)->rot); + mat3_to_quat_is_ok( (ca-1)->rot,rotmat); } else { VECSUB(tangent, ca->co, (ca - 1)->co); - Normalize(tangent); + normalize_v3(tangent); - cosangle= Inpf(tangent, prev_tangent); + cosangle= dot_v3v3(tangent, prev_tangent); /* note we do the comparison on cosangle instead of * angle, since floating point accuracy makes it give @@ -2906,9 +2906,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) } else { angle= saacos(cosangle); - Crossf(normal, prev_tangent, tangent); - VecRotToQuat(normal, angle, q); - QuatMul((ca - 1)->rot, q, (ca - 2)->rot); + cross_v3_v3v3(normal, prev_tangent, tangent); + axis_angle_to_quat( q,normal, angle); + mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot); } VECCOPY(prev_tangent, tangent); @@ -3034,7 +3034,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* non-hair points are allready in global space */ if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { - Mat4MulVecfl(hairmat, result.co); + mul_m4_v3(hairmat, result.co); /* create rotations for proper creation of children */ if(k) { @@ -3044,7 +3044,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* calculate initial tangent for incremental rotations */ VECSUB(tangent, ca->co, (ca - 1)->co); VECCOPY(prev_tangent, tangent); - Normalize(prev_tangent); + normalize_v3(prev_tangent); /* First rotation is based on emitting face orientation. */ /* This is way better than having flipping rotations resulting */ @@ -3052,13 +3052,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* It's not an ideal solution though since it disregards the */ /* initial tangent, but taking that in to account will allow */ /* the possibility of flipping again. -jahka */ - Mat3ToQuat_is_ok(rotmat, (ca-1)->rot); + mat3_to_quat_is_ok( (ca-1)->rot,rotmat); } else { VECSUB(tangent, ca->co, (ca - 1)->co); - Normalize(tangent); + normalize_v3(tangent); - cosangle= Inpf(tangent, prev_tangent); + cosangle= dot_v3v3(tangent, prev_tangent); /* note we do the comparison on cosangle instead of * angle, since floating point accuracy makes it give @@ -3068,9 +3068,9 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } else { angle= saacos(cosangle); - Crossf(normal, prev_tangent, tangent); - VecRotToQuat(normal, angle, q); - QuatMul((ca - 1)->rot, q, (ca - 2)->rot); + cross_v3_v3v3(normal, prev_tangent, tangent); + axis_angle_to_quat( q,normal, angle); + mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot); } VECCOPY(prev_tangent, tangent); @@ -3094,13 +3094,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } else{ keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - VecLerpf(ca->col, sel_col, nosel_col, keytime); + interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime); } } else{ if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - VecLerpf(ca->col, nosel_col, sel_col, keytime); + interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime); } else{ VECCOPY(ca->col, nosel_col); @@ -3144,12 +3144,12 @@ static void key_from_object(Object *ob, ParticleKey *key){ VECADD(key->vel,key->vel,key->co); - Mat4MulVecfl(ob->obmat,key->co); - Mat4MulVecfl(ob->obmat,key->vel); - Mat4ToQuat(ob->obmat,q); + mul_m4_v3(ob->obmat,key->co); + mul_m4_v3(ob->obmat,key->vel); + mat4_to_quat(q,ob->obmat); VECSUB(key->vel,key->vel,key->co); - QuatMul(key->rot,q,key->rot); + mul_qt_qtqt(key->rot,q,key->rot); } #endif @@ -3161,7 +3161,7 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat mat[3][3]= 1.0f; /* first axis is the normal */ - CalcNormFloat(v1, v2, v3, mat[2]); + normal_tri_v3( mat[2],v1, v2, v3); /* second axis along (1, 0) in uv space */ if(uv) { @@ -3180,18 +3180,18 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat mat[1][0]= w1*(v2[0] - v1[0]) + w2*(v3[0] - v1[0]); mat[1][1]= w1*(v2[1] - v1[1]) + w2*(v3[1] - v1[1]); mat[1][2]= w1*(v2[2] - v1[2]) + w2*(v3[2] - v1[2]); - Normalize(mat[1]); + normalize_v3(mat[1]); } else mat[1][0]= mat[1][1]= mat[1][2]= 0.0f; } else { - VecSubf(mat[1], v2, v1); - Normalize(mat[1]); + sub_v3_v3v3(mat[1], v2, v1); + normalize_v3(mat[1]); } /* third as a cross product */ - Crossf(mat[0], mat[1], mat[2]); + cross_v3_v3v3(mat[0], mat[1], mat[2]); } static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float mat[][4], int orco) @@ -3203,7 +3203,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m int i = pa->num_dmcache==DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache; - if (i==-1 || i >= dm->getNumFaces(dm)) { Mat4One(mat); return; } + if (i==-1 || i >= dm->getNumFaces(dm)) { unit_m4(mat); return; } mface=dm->getFaceData(dm,i,CD_MFACE); osface=dm->getFaceData(dm,i,CD_ORIGSPACE); @@ -3252,8 +3252,8 @@ void psys_vec_rot_to_face(DerivedMesh *dm, ParticleData *pa, float *vec) float mat[4][4]; psys_face_mat(0, dm, pa, mat, 0); - Mat4Transp(mat); /* cheap inverse for rotation matrix */ - Mat4Mul3Vecfl(mat, vec); + transpose_m4(mat); /* cheap inverse for rotation matrix */ + mul_mat3_m4_v3(mat, vec); } void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleData *pa, float hairmat[][4]) @@ -3262,7 +3262,7 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa psys_mat_hair_to_object(ob, dm, from, pa, facemat); - Mat4MulMat4(hairmat, facemat, ob->obmat); + mul_m4_m4m4(hairmat, facemat, ob->obmat); } /************************************************/ @@ -3849,8 +3849,8 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * if(!keyed && !cached) { if((pa->flag & PARS_REKEY)==0) { psys_mat_hair_to_global(sim->ob, sim->psmd->dm, part->from, pa, hairmat); - Mat4MulVecfl(hairmat, state->co); - Mat4Mul3Vecfl(hairmat, state->vel); + mul_m4_v3(hairmat, state->co); + mul_mat3_m4_v3(hairmat, state->vel); if(sim->psys->effectors && (part->flag & PART_CHILD_GUIDE)==0) { do_guides(sim->psys->effectors, state, p, state->time); @@ -3863,7 +3863,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * } } else if(totchild){ - //Mat4Invert(imat,ob->obmat); + //invert_m4_m4(imat,ob->obmat); cpa=psys->child+p-totpart; @@ -3902,7 +3902,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */ //VECCOPY(cpa_1st,co); - //Mat4MulVecfl(ob->obmat,cpa_1st); + //mul_m4_v3(ob->obmat,cpa_1st); pa = psys->particles + cpa->parent; @@ -3979,22 +3979,22 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* try to estimate correct velocity */ if(vel){ ParticleKey tstate; - float length = VecLength(state->vel); + float length = len_v3(state->vel); if(t>=0.001f){ tstate.time=t-0.001f; psys_get_particle_on_path(sim,p,&tstate,0); VECSUB(state->vel,state->co,tstate.co); - Normalize(state->vel); + normalize_v3(state->vel); } else{ tstate.time=t+0.001f; psys_get_particle_on_path(sim,p,&tstate,0); VECSUB(state->vel,tstate.co,state->co); - Normalize(state->vel); + normalize_v3(state->vel); } - VecMulf(state->vel, length); + mul_v3_fl(state->vel, length); } } } @@ -4101,16 +4101,16 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta keytime = (state->time - keys[1].time) / dfra; /* convert velocity to timestep size */ - VecMulf(keys[1].vel, dfra * timestep); - VecMulf(keys[2].vel, dfra * timestep); + mul_v3_fl(keys[1].vel, dfra * timestep); + mul_v3_fl(keys[2].vel, dfra * timestep); psys_interpolate_particle(-1, keys, keytime, state, 1); /* convert back to real velocity */ - VecMulf(state->vel, 1.0f / (dfra * timestep)); + mul_v3_fl(state->vel, 1.0f / (dfra * timestep)); - VecLerpf(state->ave, keys[1].ave, keys[2].ave, keytime); - QuatInterpol(state->rot, keys[1].rot, keys[2].rot, keytime); + interp_v3_v3v3(state->ave, keys[1].ave, keys[2].ave, keytime); + interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime); } } else { @@ -4184,8 +4184,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa float loc[3], nor[3], vec[3], side[3], len, obrotmat[4][4], qmat[4][4]; float xvec[3] = {-1.0, 0.0, 0.0}, q[4]; - VecSubf(vec, (cache+cache->steps-1)->co, cache->co); - len= Normalize(vec); + sub_v3_v3v3(vec, (cache+cache->steps-1)->co, cache->co); + len= normalize_v3(vec); if(pa) psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0); @@ -4198,17 +4198,17 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa if(!pa) pa= psys->particles+cpa->pa[0]; - vectoquat(xvec, ob->trackflag, ob->upflag, q); - QuatToMat4(q, obrotmat); + vec_to_quat( q,xvec, ob->trackflag, ob->upflag); + quat_to_mat4( obrotmat,q); obrotmat[3][3]= 1.0f; - QuatToMat4(pa->state.rot, qmat); - Mat4MulMat4(mat, obrotmat, qmat); + quat_to_mat4( qmat,pa->state.rot); + mul_m4_m4m4(mat, obrotmat, qmat); } else { /* make sure that we get a proper side vector */ - if(fabs(Inpf(nor,vec))>0.999999) { - if(fabs(Inpf(nor,xvec))>0.999999) { + if(fabs(dot_v3v3(nor,vec))>0.999999) { + if(fabs(dot_v3v3(nor,xvec))>0.999999) { nor[0] = 0.0f; nor[1] = 1.0f; nor[2] = 0.0f; @@ -4219,11 +4219,11 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa nor[2] = 0.0f; } } - Crossf(side, nor, vec); - Normalize(side); - Crossf(nor, vec, side); + cross_v3_v3v3(side, nor, vec); + normalize_v3(side); + cross_v3_v3v3(nor, vec, side); - Mat4One(mat); + unit_m4(mat); VECCOPY(mat[0], vec); VECCOPY(mat[1], side); VECCOPY(mat[2], nor); @@ -4244,62 +4244,62 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] if(bb->lock && (bb->align == PART_BB_VIEW)) { VECCOPY(xvec, bb->ob->obmat[0]); - Normalize(xvec); + normalize_v3(xvec); VECCOPY(yvec, bb->ob->obmat[1]); - Normalize(yvec); + normalize_v3(yvec); VECCOPY(zvec, bb->ob->obmat[2]); - Normalize(zvec); + normalize_v3(zvec); } else if(bb->align == PART_BB_VEL) { float temp[3]; VECCOPY(temp, bb->vel); - Normalize(temp); + normalize_v3(temp); VECSUB(zvec, bb->ob->obmat[3], bb->vec); if(bb->lock) { - float fac = -Inpf(zvec, temp); + float fac = -dot_v3v3(zvec, temp); VECADDFAC(zvec, zvec, temp, fac); } - Normalize(zvec); + normalize_v3(zvec); - Crossf(xvec,temp,zvec); - Normalize(xvec); + cross_v3_v3v3(xvec,temp,zvec); + normalize_v3(xvec); - Crossf(yvec,zvec,xvec); + cross_v3_v3v3(yvec,zvec,xvec); } else { VECSUB(zvec, bb->ob->obmat[3], bb->vec); if(bb->lock) zvec[bb->align] = 0.0f; - Normalize(zvec); + normalize_v3(zvec); if(bb->align < PART_BB_VIEW) - Crossf(xvec, onevec, zvec); + cross_v3_v3v3(xvec, onevec, zvec); else - Crossf(xvec, bb->ob->obmat[1], zvec); - Normalize(xvec); + cross_v3_v3v3(xvec, bb->ob->obmat[1], zvec); + normalize_v3(xvec); - Crossf(yvec,zvec,xvec); + cross_v3_v3v3(yvec,zvec,xvec); } VECCOPY(tvec, xvec); VECCOPY(tvec2, yvec); - VecMulf(xvec, cos(bb->tilt * (float)M_PI)); - VecMulf(tvec2, sin(bb->tilt * (float)M_PI)); + mul_v3_fl(xvec, cos(bb->tilt * (float)M_PI)); + mul_v3_fl(tvec2, sin(bb->tilt * (float)M_PI)); VECADD(xvec, xvec, tvec2); - VecMulf(yvec, cos(bb->tilt * (float)M_PI)); - VecMulf(tvec, -sin(bb->tilt * (float)M_PI)); + mul_v3_fl(yvec, cos(bb->tilt * (float)M_PI)); + mul_v3_fl(tvec, -sin(bb->tilt * (float)M_PI)); VECADD(yvec, yvec, tvec); - VecMulf(xvec, bb->size); - VecMulf(yvec, bb->size); + mul_v3_fl(xvec, bb->size); + mul_v3_fl(yvec, bb->size); VECADDFAC(center, bb->vec, xvec, bb->offset[0]); VECADDFAC(center, center, yvec, bb->offset[1]); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index d66c990cbe1..075c6f6207f 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -54,7 +54,7 @@ #include "BLI_rand.h" #include "BLI_jitter.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" @@ -405,7 +405,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) min[2]-=d/2.0f; for(i=0,mv=mvert; ico,min); + sub_v3_v3v3(vec,mv->co,min); vec[0]/=delta[0]; vec[1]/=delta[1]; vec[2]/=delta[2]; @@ -447,7 +447,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) VECCOPY(v2,mvert[mface->v2].co); VECCOPY(v3,mvert[mface->v3].co); - if(AxialLineIntersectsTriangle(a,co1, co2, v2, v3, v1, &lambda)){ + if(isect_axial_line_tri_v3(a,co1, co2, v2, v3, v1, &lambda)){ if(from==PART_FROM_FACE) (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; else /* store number of intersections */ @@ -457,7 +457,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) if(mface->v4){ VECCOPY(v4,mvert[mface->v4].co); - if(AxialLineIntersectsTriangle(a,co1, co2, v4, v1, v3, &lambda)){ + if(isect_axial_line_tri_v3(a,co1, co2, v4, v1, v3, &lambda)){ if(from==PART_FROM_FACE) (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; else @@ -577,10 +577,10 @@ static void psys_uv_to_w(float u, float v, int quad, float *w) if(quad) { vert[3][0]= 0.0f; vert[3][1]= 1.0f; vert[3][2]= 0.0f; - MeanValueWeights(vert, 4, co, w); + interp_weights_poly_v3( w,vert, 4, co); } else { - MeanValueWeights(vert, 3, co, w); + interp_weights_poly_v3( w,vert, 3, co); w[3]= 0.0f; } } @@ -669,8 +669,8 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData psys_interpolate_face(mvert,mface,0,0,pa->fuv,co1,nor,0,0,0,0); - Normalize(nor); - VecMulf(nor,-100.0); + normalize_v3(nor); + mul_v3_fl(nor,-100.0); VECADD(co2,co1,nor); @@ -684,7 +684,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData v2=mvert[mface->v2].co; v3=mvert[mface->v3].co; - if(LineIntersectsTriangle(co1, co2, v2, v3, v1, &cur_d, 0)){ + if(isect_line_tri_v3(co1, co2, v2, v3, v1, &cur_d, 0)){ if(cur_dfoffset=cur_d*50.0f; /* to the middle of volume */ @@ -694,7 +694,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData if(mface->v4){ v4=mvert[mface->v4].co; - if(LineIntersectsTriangle(co1, co2, v4, v1, v3, &cur_d, 0)){ + if(isect_line_tri_v3(co1, co2, v4, v1, v3, &cur_d, 0)){ if(cur_dfoffset=cur_d*50.0f; /* to the middle of volume */ @@ -776,18 +776,18 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData // int min_seam=0, near_vert=0; // /* find closest seam */ // for(i=0; itotseam; i++, seam++){ - // VecSubf(temp,co1,seam->v0); - // inp=Inpf(temp,seam->dir)/seam->length2; + // sub_v3_v3v3(temp,co1,seam->v0); + // inp=dot_v3v3(temp,seam->dir)/seam->length2; // if(inp<0.0f){ - // cur_len=VecLenf(co1,seam->v0); + // cur_len=len_v3v3(co1,seam->v0); // } // else if(inp>1.0f){ - // cur_len=VecLenf(co1,seam->v1); + // cur_len=len_v3v3(co1,seam->v1); // } // else{ - // VecCopyf(temp2,seam->dir); - // VecMulf(temp2,inp); - // cur_len=VecLenf(temp,temp2); + // copy_v3_v3(temp2,seam->dir); + // mul_v3_fl(temp2,inp); + // cur_len=len_v3v3(temp,temp2); // } // if(cur_lenseams+min_seam; // - // VecCopyf(temp,seam->v0); + // copy_v3_v3(temp,seam->v0); // // if(near_vert){ // if(near_vert==-1) - // VecSubf(tan,co1,seam->v0); + // sub_v3_v3v3(tan,co1,seam->v0); // else{ - // VecSubf(tan,co1,seam->v1); - // VecCopyf(temp,seam->v1); + // sub_v3_v3v3(tan,co1,seam->v1); + // copy_v3_v3(temp,seam->v1); // } - // Normalize(tan); + // normalize_v3(tan); // } // else{ - // VecCopyf(tan,seam->tan); - // VecSubf(temp2,co1,temp); - // if(Inpf(tan,temp2)<0.0f) - // VecNegf(tan); + // copy_v3_v3(tan,seam->tan); + // sub_v3_v3v3(temp2,co1,temp); + // if(dot_v3v3(tan,temp2)<0.0f) + // negate_v3(tan); // } // for(w=0; wflag&ME_SEAM){ - // VecCopyf(cur_seam->v0,(mvert+ed->v1)->co); - // VecCopyf(cur_seam->v1,(mvert+ed->v2)->co); + // copy_v3_v3(cur_seam->v0,(mvert+ed->v1)->co); + // copy_v3_v3(cur_seam->v1,(mvert+ed->v2)->co); - // VecSubf(cur_seam->dir,cur_seam->v1,cur_seam->v0); + // sub_v3_v3v3(cur_seam->dir,cur_seam->v1,cur_seam->v0); - // cur_seam->length2=VecLength(cur_seam->dir); + // cur_seam->length2=len_v3(cur_seam->dir); // cur_seam->length2*=cur_seam->length2; // temp[0]=(float)((mvert+ed->v1)->no[0]); @@ -1004,12 +1004,12 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, // temp2[1]=(float)((mvert+ed->v2)->no[1]); // temp2[2]=(float)((mvert+ed->v2)->no[2]); - // VecAddf(cur_seam->nor,temp,temp2); - // Normalize(cur_seam->nor); + // add_v3_v3v3(cur_seam->nor,temp,temp2); + // normalize_v3(cur_seam->nor); - // Crossf(cur_seam->tan,cur_seam->dir,cur_seam->nor); + // cross_v3_v3v3(cur_seam->tan,cur_seam->dir,cur_seam->nor); - // Normalize(cur_seam->tan); + // normalize_v3(cur_seam->tan); // cur_seam++; // } @@ -1035,7 +1035,7 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, cpa->fuv[0]=2.0f*BLI_frand()-1.0f; cpa->fuv[1]=2.0f*BLI_frand()-1.0f; cpa->fuv[2]=2.0f*BLI_frand()-1.0f; - length=VecLength(cpa->fuv); + length=len_v3(cpa->fuv); } cpa->num=-1; @@ -1176,10 +1176,10 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, v4= (MVert*)dm->getVertData(dm,mf->v4,CD_MVERT); VECCOPY(co4, v4->co); } - cur= AreaQ3Dfl(co1, co2, co3, co4); + cur= area_quad_v3(co1, co2, co3, co4); } else - cur= AreaT3Dfl(co1, co2, co3); + cur= area_tri_v3(co1, co2, co3); if(cur>maxweight) maxweight=cur; @@ -1682,7 +1682,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f); r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f); r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f); - NormalQuat(r_rot); + normalize_qt(r_rot); r_phase = PSYS_FRAND(p + 20); @@ -1699,15 +1699,15 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, psys_get_particle_state(&tsim, pa->num, &state, 1); psys_get_from_key(&state, loc, nor, rot, 0); - QuatMulVecf(rot, vtan); - QuatMulVecf(rot, utan); + mul_qt_v3(rot, vtan); + mul_qt_v3(rot, utan); VECCOPY(p_vel, state.vel); - speed=Normalize(p_vel); - VecMulf(p_vel, Inpf(r_vel, p_vel)); + speed=normalize_v3(p_vel); + mul_v3_fl(p_vel, dot_v3v3(r_vel, p_vel)); VECSUB(p_vel, r_vel, p_vel); - Normalize(p_vel); - VecMulf(p_vel, speed); + normalize_v3(p_vel); + mul_v3_fl(p_vel, speed); VECCOPY(pa->fuv, loc); /* abusing pa->fuv (not used for "from particle") for storing emit location */ } @@ -1731,46 +1731,46 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* particles live in global space so */ /* let's convert: */ /* -location */ - Mat4MulVecfl(ob->obmat,loc); + mul_m4_v3(ob->obmat,loc); /* -normal */ - Mat4Mul3Vecfl(ob->obmat,nor); - Normalize(nor); + mul_mat3_m4_v3(ob->obmat,nor); + normalize_v3(nor); /* -tangent */ if(part->tanfac!=0.0){ //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f; float phase=0.0f; - VecMulf(vtan,-(float)cos(M_PI*(part->tanphase+phase))); + mul_v3_fl(vtan,-(float)cos(M_PI*(part->tanphase+phase))); fac=-(float)sin(M_PI*(part->tanphase+phase)); VECADDFAC(vtan,vtan,utan,fac); - Mat4Mul3Vecfl(ob->obmat,vtan); + mul_mat3_m4_v3(ob->obmat,vtan); VECCOPY(utan,nor); - VecMulf(utan,Inpf(vtan,nor)); + mul_v3_fl(utan,dot_v3v3(vtan,nor)); VECSUB(vtan,vtan,utan); - Normalize(vtan); + normalize_v3(vtan); } /* -velocity */ if(part->randfac!=0.0){ - Mat4Mul3Vecfl(ob->obmat,r_vel); - Normalize(r_vel); + mul_mat3_m4_v3(ob->obmat,r_vel); + normalize_v3(r_vel); } /* -angular velocity */ if(part->avemode==PART_AVE_RAND){ - Mat4Mul3Vecfl(ob->obmat,r_ave); - Normalize(r_ave); + mul_mat3_m4_v3(ob->obmat,r_ave); + normalize_v3(r_ave); } /* -rotation */ if(part->randrotfac != 0.0f){ - Mat4ToQuat(ob->obmat,rot); - QuatMul(r_rot,r_rot,rot); + mat4_to_quat(rot,ob->obmat); + mul_qt_qtqt(r_rot,r_rot,rot); } } @@ -1785,8 +1785,8 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* boids store direction in ave */ if(fabs(nor[2])==1.0f) { - VecSubf(pa->state.ave, loc, ob->obmat[3]); - Normalize(pa->state.ave); + sub_v3_v3v3(pa->state.ave, loc, ob->obmat[3]); + normalize_v3(pa->state.ave); } else { VECCOPY(pa->state.ave, nor); @@ -1799,17 +1799,17 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, bpa->gravity[2] = sim->scene->physics_settings.gravity[2]; /* calculate rotation matrix */ - Projf(dvec, r_vel, pa->state.ave); - VecSubf(mat[0], pa->state.ave, dvec); - Normalize(mat[0]); + project_v3_v3v3(dvec, r_vel, pa->state.ave); + sub_v3_v3v3(mat[0], pa->state.ave, dvec); + normalize_v3(mat[0]); VECCOPY(mat[2], r_vel); - VecMulf(mat[2], -1.0f); - Normalize(mat[2]); - Crossf(mat[1], mat[2], mat[0]); + mul_v3_fl(mat[2], -1.0f); + normalize_v3(mat[2]); + cross_v3_v3v3(mat[1], mat[2], mat[0]); /* apply rotation */ - Mat3ToQuat_is_ok(mat, q); - QuatCopy(pa->state.rot, q); + mat3_to_quat_is_ok( q,mat); + copy_qt_qt(pa->state.rot, q); bpa->data.health = part->boids->health; bpa->data.mode = eBoidMode_InAir; @@ -1828,7 +1828,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* *emitter velocity */ if(dtime!=0.0 && part->obfac!=0.0){ VECSUB(vel,loc,pa->state.co); - VecMulf(vel,part->obfac/dtime); + mul_v3_fl(vel,part->obfac/dtime); } /* *emitter normal */ @@ -1843,17 +1843,17 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* *emitter object orientation */ if(part->ob_vel[0]!=0.0) { VECCOPY(vec, ob->obmat[0]); - Normalize(vec); + normalize_v3(vec); VECADDFAC(vel, vel, vec, part->ob_vel[0]); } if(part->ob_vel[1]!=0.0) { VECCOPY(vec, ob->obmat[1]); - Normalize(vec); + normalize_v3(vec); VECADDFAC(vel, vel, vec, part->ob_vel[1]); } if(part->ob_vel[2]!=0.0) { VECCOPY(vec, ob->obmat[2]); - Normalize(vec); + normalize_v3(vec); VECADDFAC(vel, vel, vec, part->ob_vel[2]); } @@ -1874,7 +1874,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, // ptex.ivel*=icu->curval; //} - VecMulf(vel,ptex.ivel); + mul_v3_fl(vel,ptex.ivel); VECCOPY(pa->state.vel,vel); @@ -1889,10 +1889,10 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* create vector into which rotation is aligned */ switch(part->rotmode){ case PART_ROT_NOR: - VecCopyf(rot_vec, nor); + copy_v3_v3(rot_vec, nor); break; case PART_ROT_VEL: - VecCopyf(rot_vec, vel); + copy_v3_v3(rot_vec, vel); break; case PART_ROT_GLOB_X: case PART_ROT_GLOB_Y: @@ -1902,28 +1902,28 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, case PART_ROT_OB_X: case PART_ROT_OB_Y: case PART_ROT_OB_Z: - VecCopyf(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]); + copy_v3_v3(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]); break; } /* create rotation quat */ - VecNegf(rot_vec); - vectoquat(rot_vec, OB_POSX, OB_POSZ, q2); + negate_v3(rot_vec); + vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ); /* randomize rotation quat */ if(part->randrotfac!=0.0f) - QuatInterpol(rot, q2, r_rot, part->randrotfac); + interp_qt_qtqt(rot, q2, r_rot, part->randrotfac); else - QuatCopy(rot,q2); + copy_qt_qt(rot,q2); /* rotation phase */ phasefac = part->phasefac; if(part->randphasefac != 0.0f) phasefac += part->randphasefac * r_phase; - VecRotToQuat(x_vec, phasefac*(float)M_PI, q_phase); + axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI); /* combine base rotation & phase */ - QuatMul(pa->state.rot, rot, q_phase); + mul_qt_qtqt(pa->state.rot, rot, q_phase); } /* -angular velocity */ @@ -1939,13 +1939,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, VECCOPY(pa->state.ave,r_ave); break; } - Normalize(pa->state.ave); - VecMulf(pa->state.ave,part->avefac); + normalize_v3(pa->state.ave); + mul_v3_fl(pa->state.ave,part->avefac); //icu=find_ipocurve(psys->part->ipo,PART_EMIT_AVE); //if(icu){ // calc_icu(icu,100*((pa->time-part->sta)/(part->end-part->sta))); - // VecMulf(pa->state.ave,icu->curval); + // mul_v3_fl(pa->state.ave,icu->curval); //} } } @@ -2157,7 +2157,7 @@ static void set_keyed_keys(ParticleSimulationData *sim) // } // } // else{ -// dist=VecLenf(pa->state.co, re->state.co); +// dist=len_v3v3(pa->state.co, re->state.co); // if(dist <= re->size){ // if(pa->alive==PARS_UNBORN){ // pa->time=re->time; @@ -2168,12 +2168,12 @@ static void set_keyed_keys(ParticleSimulationData *sim) // float vec[3]; // VECSUB(vec,pa->state.co, re->state.co); // if(birth==0) -// VecMulf(vec,(float)pow(1.0f-dist/re->size,part->reactshape)); +// mul_v3_fl(vec,(float)pow(1.0f-dist/re->size,part->reactshape)); // VECADDFAC(pa->state.vel,pa->state.vel,vec,part->reactfac); // VECADDFAC(pa->state.vel,pa->state.vel,re->state.vel,part->partfac); // } // if(birth) -// VecMulf(pa->state.vel,(float)pow(1.0f-dist/re->size,part->reactshape)); +// mul_v3_fl(pa->state.vel,(float)pow(1.0f-dist/re->size,part->reactshape)); // } // } // } @@ -2301,7 +2301,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra /* calculate air-particle interaction */ if(part->dragfac!=0.0f){ - fac=-part->dragfac*pa->size*pa->size*VecLength(states[i].vel); + fac=-part->dragfac*pa->size*pa->size*len_v3(states[i].vel); VECADDFAC(force,force,states[i].vel,fac); } @@ -2313,7 +2313,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra } /* force to acceleration*/ - VecMulf(force,1.0f/pa_mass); + mul_v3_fl(force,1.0f/pa_mass); /* add global acceleration (gravitation) */ if(sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY @@ -2321,7 +2321,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra && (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) { float gravity[3]; VECCOPY(gravity, sim->scene->physics_settings.gravity); - VecMulf(gravity, part->effector_weights->global_gravity); + mul_v3_fl(gravity, part->effector_weights->global_gravity); VECADD(force,force,gravity); } @@ -2348,9 +2348,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra switch(i){ case 0: VECCOPY(dx[0],states->vel); - VecMulf(dx[0],dtime); + mul_v3_fl(dx[0],dtime); VECCOPY(dv[0],force); - VecMulf(dv[0],dtime); + mul_v3_fl(dv[0],dtime); VECADDFAC(states[1].co,states->co,dx[0],0.5f); VECADDFAC(states[1].vel,states->vel,dv[0],0.5f); @@ -2358,18 +2358,18 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra break; case 1: VECADDFAC(dx[1],states->vel,dv[0],0.5f); - VecMulf(dx[1],dtime); + mul_v3_fl(dx[1],dtime); VECCOPY(dv[1],force); - VecMulf(dv[1],dtime); + mul_v3_fl(dv[1],dtime); VECADDFAC(states[2].co,states->co,dx[1],0.5f); VECADDFAC(states[2].vel,states->vel,dv[1],0.5f); break; case 2: VECADDFAC(dx[2],states->vel,dv[1],0.5f); - VecMulf(dx[2],dtime); + mul_v3_fl(dx[2],dtime); VECCOPY(dv[2],force); - VecMulf(dv[2],dtime); + mul_v3_fl(dv[2],dtime); VECADD(states[3].co,states->co,dx[2]); VECADD(states[3].vel,states->vel,dv[2]); @@ -2377,9 +2377,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra break; case 3: VECADD(dx[3],states->vel,dv[2]); - VecMulf(dx[3],dtime); + mul_v3_fl(dx[3],dtime); VECCOPY(dv[3],force); - VecMulf(dv[3],dtime); + mul_v3_fl(dv[3],dtime); VECADDFAC(pa->state.co,states->co,dx[0],1.0f/6.0f); VECADDFAC(pa->state.co,pa->state.co,dx[1],1.0f/3.0f); @@ -2397,7 +2397,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra /* damp affects final velocity */ if(part->dampfac!=0.0) - VecMulf(pa->state.vel,1.0f-part->dampfac); + mul_v3_fl(pa->state.vel,1.0f-part->dampfac); VECCOPY(pa->state.ave, states->ave); @@ -2414,7 +2414,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra VECCOPY(pa->state.co,tkey.co); /* guides don't produce valid velocity */ VECSUB(pa->state.vel,tkey.co,pa->prev_state.co); - VecMulf(pa->state.vel,1.0f/dtime); + mul_v3_fl(pa->state.vel,1.0f/dtime); pa->state.time=tkey.time; } } @@ -2426,35 +2426,35 @@ static void rotate_particle(ParticleSettings *part, ParticleData *pa, float dfra if((part->flag & PART_ROT_DYN)==0){ if(part->avemode==PART_AVE_SPIN){ float angle; - float len1 = VecLength(pa->prev_state.vel); - float len2 = VecLength(pa->state.vel); + float len1 = len_v3(pa->prev_state.vel); + float len2 = len_v3(pa->state.vel); if(len1==0.0f || len2==0.0f) pa->state.ave[0]=pa->state.ave[1]=pa->state.ave[2]=0.0f; else{ - Crossf(pa->state.ave,pa->prev_state.vel,pa->state.vel); - Normalize(pa->state.ave); - angle=Inpf(pa->prev_state.vel,pa->state.vel)/(len1*len2); - VecMulf(pa->state.ave,saacos(angle)/dtime); + cross_v3_v3v3(pa->state.ave,pa->prev_state.vel,pa->state.vel); + normalize_v3(pa->state.ave); + angle=dot_v3v3(pa->prev_state.vel,pa->state.vel)/(len1*len2); + mul_v3_fl(pa->state.ave,saacos(angle)/dtime); } - VecRotToQuat(pa->state.vel,dtime*part->avefac,rot2); + axis_angle_to_quat(rot2,pa->state.vel,dtime*part->avefac); } } - rotfac=VecLength(pa->state.ave); - if(rotfac==0.0){ /* QuatOne (in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */ + rotfac=len_v3(pa->state.ave); + if(rotfac==0.0){ /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */ rot1[0]=1.0; rot1[1]=rot1[2]=rot1[3]=0; } else{ - VecRotToQuat(pa->state.ave,rotfac*dtime,rot1); + axis_angle_to_quat(rot1,pa->state.ave,rotfac*dtime); } - QuatMul(pa->state.rot,rot1,pa->prev_state.rot); - QuatMul(pa->state.rot,rot2,pa->state.rot); + mul_qt_qtqt(pa->state.rot,rot1,pa->prev_state.rot); + mul_qt_qtqt(pa->state.rot,rot2,pa->state.rot); /* keep rotation quat in good health */ - NormalQuat(pa->state.rot); + normalize_qt(pa->state.rot); } /* convert from triangle barycentric weights to quad mean value weights */ @@ -2471,7 +2471,7 @@ static void intersect_dm_quad_weights(float *v1, float *v2, float *v3, float *v4 co[1]= v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2] + v4[1]*w[3]; co[2]= v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2] + v4[2]*w[3]; - MeanValueWeights(vert, 4, co, w); + interp_weights_poly_v3( w,vert, 4, co); } /* check intersection with a derivedmesh */ @@ -2537,18 +2537,18 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos DO_MINMAX(v3,min,max); if(mface->v4) DO_MINMAX(v4,min,max) - if(AabbIntersectAabb(min,max,p_min,p_max)==0) + if(isect_aabb_aabb_v3(min,max,p_min,p_max)==0) continue; } else{ VECCOPY(min, face_minmax+6*i); VECCOPY(max, face_minmax+6*i+3); - if(AabbIntersectAabb(min,max,p_min,p_max)==0) + if(isect_aabb_aabb_v3(min,max,p_min,p_max)==0) continue; } if(radius>0.0f){ - if(SweepingSphereIntersectsTriangleUV(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)){ + if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)){ if(cur_d<*min_d){ *min_d=cur_d; VECCOPY(ipoint,cur_ipoint); @@ -2557,7 +2557,7 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos } } if(mface->v4){ - if(SweepingSphereIntersectsTriangleUV(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)){ + if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)){ if(cur_d<*min_d){ *min_d=cur_d; VECCOPY(ipoint,cur_ipoint); @@ -2568,7 +2568,7 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos } } else{ - if(LineIntersectsTriangle(co1, co2, v1, v2, v3, &cur_d, cur_uv)){ + if(isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)){ if(cur_d<*min_d){ *min_d=cur_d; min_w[0]= 1.0 - cur_uv[0] - cur_uv[1]; @@ -2582,7 +2582,7 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos } } if(mface->v4){ - if(LineIntersectsTriangle(co1, co2, v1, v3, v4, &cur_d, cur_uv)){ + if(isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)){ if(cur_d<*min_d){ *min_d=cur_d; min_w[0]= 1.0 - cur_uv[0] - cur_uv[1]; @@ -2618,7 +2618,7 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B VECCOPY(vel, v[ face->v1 ].co); VECADD(vel, vel, v[ face->v2 ].co); VECADD(vel, vel, v[ face->v3 ].co); - VecMulf(vel, 0.33334f); + mul_v3_fl(vel, 0.33334f); /* substract face velocity, in other words convert to a coordinate system where only the particle moves */ @@ -2628,16 +2628,16 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B do { if(ray->radius == 0.0f) { - if(LineIntersectsTriangle(co1, co2, t0, t1, t2, &t, uv)) { + if(isect_line_tri_v3(co1, co2, t0, t1, t2, &t, uv)) { if(t >= 0.0f && t < hit->dist/col->ray_len) { hit->dist = col->ray_len * t; hit->index = index; /* calculate normal that's facing the particle */ - CalcNormFloat(t0, t1, t2, col->nor); + normal_tri_v3( col->nor,t0, t1, t2); VECSUB(temp, co2, co1); - if(Inpf(col->nor, temp) > 0.0f) - VecNegf(col->nor); + if(dot_v3v3(col->nor, temp) > 0.0f) + negate_v3(col->nor); VECCOPY(col->vel,vel); @@ -2647,15 +2647,15 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B } } else { - if(SweepingSphereIntersectsTriangleUV(co1, co2, ray->radius, t0, t1, t2, &t, ipoint)) { + if(isect_sweeping_sphere_tri_v3(co1, co2, ray->radius, t0, t1, t2, &t, ipoint)) { if(t >=0.0f && t < hit->dist/col->ray_len) { hit->dist = col->ray_len * t; hit->index = index; - VecLerpf(temp, co1, co2, t); + interp_v3_v3v3(temp, co1, co2, t); VECSUB(col->nor, temp, ipoint); - Normalize(col->nor); + normalize_v3(col->nor); VECCOPY(col->vel,vel); @@ -2706,7 +2706,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo VECSUB(ray_dir, col.co2, col.co1); hit.index = -1; - hit.dist = col.ray_len = VecLength(ray_dir); + hit.dist = col.ray_len = len_v3(ray_dir); /* even if particle is stationary we want to check for moving colliders */ /* if hit.dist is zero the bvhtree_ray_cast will just ignore everything */ @@ -2738,10 +2738,10 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo float t = hit.dist/col.ray_len; /* time of collision between this iteration */ float dt = col.t + t * (1.0f - col.t); /* time of collision between frame change*/ - VecLerpf(co, col.co1, col.co2, t); + interp_v3_v3v3(co, col.co1, col.co2, t); VECSUB(vec, col.co2, col.co1); - VecMulf(col.vel, 1.0f-col.t); + mul_v3_fl(col.vel, 1.0f-col.t); /* particle dies in collision */ if(through == 0 && (part->flag & PART_DIE_ON_COL || pd->flag & PDEFLE_KILL_PART)) { @@ -2752,9 +2752,9 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f)); VECCOPY(pa->state.co, co); - VecLerpf(pa->state.vel, pa->prev_state.vel, pa->state.vel, dt); - QuatInterpol(pa->state.rot, pa->prev_state.rot, pa->state.rot, dt); - VecLerpf(pa->state.ave, pa->prev_state.ave, pa->state.ave, dt); + interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, dt); + interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, dt); + interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, dt); /* particle is dead so we don't need to calculate further */ deflections=max_deflections; @@ -2772,13 +2772,13 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo CLAMP(frict,0.0,1.0); /* treat normal & tangent components separately */ - inp = Inpf(col.nor, vec); - inp_v = Inpf(col.nor, col.vel); + inp = dot_v3v3(col.nor, vec); + inp_v = dot_v3v3(col.nor, col.vel); VECADDFAC(tan_vec, vec, col.nor, -inp); VECADDFAC(tan_vel, col.vel, col.nor, -inp_v); if((part->flag & PART_ROT_DYN)==0) - VecLerpf(tan_vec, tan_vec, tan_vel, frict); + interp_v3_v3v3(tan_vec, tan_vec, tan_vel, frict); VECCOPY(nor_vec, col.nor); inp *= 1.0f - damp; @@ -2788,9 +2788,9 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* special case for object hitting the particle from behind */ if(through==0 && ((inp_v>0 && inp>0 && inp_v>inp) || (inp_v<0 && inp<0 && inp_v linear velocity - slightly more physical and looks even nicer than before */ if(part->flag & PART_ROT_DYN) { @@ -2800,37 +2800,37 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo VECSUB(surface_vel, tan_vec, tan_vel); /* direction of rolling friction */ - Crossf(rot_vel, pa->state.ave, col.nor); + cross_v3_v3v3(rot_vel, pa->state.ave, col.nor); /* convert to current dt */ - VecMulf(rot_vel, (timestep*dfra) * (1.0f - col.t)); - VecMulf(rot_vel, pa->size); + mul_v3_fl(rot_vel, (timestep*dfra) * (1.0f - col.t)); + mul_v3_fl(rot_vel, pa->size); /* apply sliding friction */ VECSUB(surface_vel, surface_vel, rot_vel); VECCOPY(friction, surface_vel); - VecMulf(surface_vel, 1.0 - frict); - VecMulf(friction, frict); + mul_v3_fl(surface_vel, 1.0 - frict); + mul_v3_fl(friction, frict); /* sliding changes angular velocity */ - Crossf(dave, col.nor, friction); - VecMulf(dave, 1.0f/MAX2(pa->size, 0.001)); + cross_v3_v3v3(dave, col.nor, friction); + mul_v3_fl(dave, 1.0f/MAX2(pa->size, 0.001)); /* we assume rolling friction is around 0.01 of sliding friction */ - VecMulf(rot_vel, 1.0 - frict*0.01); + mul_v3_fl(rot_vel, 1.0 - frict*0.01); /* change in angular velocity has to be added to the linear velocity too */ - Crossf(dvel, dave, col.nor); - VecMulf(dvel, pa->size); + cross_v3_v3v3(dvel, dave, col.nor); + mul_v3_fl(dvel, pa->size); VECADD(rot_vel, rot_vel, dvel); VECADD(surface_vel, surface_vel, rot_vel); VECADD(tan_vec, surface_vel, tan_vel); /* convert back to normal time */ - VecMulf(dave, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); + mul_v3_fl(dave, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); - VecMulf(pa->state.ave, 1.0 - frict*0.01); + mul_v3_fl(pa->state.ave, 1.0 - frict*0.01); VECADD(pa->state.ave, pa->state.ave, dave); } @@ -2839,7 +2839,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* calculate velocity from collision vector */ VECCOPY(vel, vec); - VecMulf(vel, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); + mul_v3_fl(vel, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); /* make sure we don't hit the current face again */ VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f)); @@ -2854,15 +2854,15 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* store state for reactors */ //VECCOPY(reaction_state.co, co); - //VecLerpf(reaction_state.vel, pa->prev_state.vel, pa->state.vel, dt); - //QuatInterpol(reaction_state.rot, pa->prev_state.rot, pa->state.rot, dt); + //interp_v3_v3v3(reaction_state.vel, pa->prev_state.vel, pa->state.vel, dt); + //interp_qt_qtqt(reaction_state.rot, pa->prev_state.rot, pa->state.rot, dt); /* set coordinates for next iteration */ VECCOPY(col.co1, co); VECADDFAC(col.co2, co, vec, 1.0f - t); col.t = dt; - if(VecLength(vec) < 0.001 && VecLength(pa->state.vel) < 0.001) { + if(len_v3(vec) < 0.001 && len_v3(pa->state.vel) < 0.001) { /* kill speed to stop slipping */ VECCOPY(pa->state.vel,zerovec); VECCOPY(pa->state.co, co); @@ -3011,7 +3011,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) VECSUB(temp, key->co, (key+1)->co); VECCOPY(mvert->co, key->co); VECADD(mvert->co, mvert->co, temp); - Mat4MulVecfl(hairmat, mvert->co); + mul_m4_v3(hairmat, mvert->co); mvert++; medge->v1 = pa->hair_index - 1; @@ -3030,7 +3030,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) } VECCOPY(mvert->co, key->co); - Mat4MulVecfl(hairmat, mvert->co); + mul_m4_v3(hairmat, mvert->co); mvert++; if(k) { @@ -3105,7 +3105,7 @@ static void save_hair(ParticleSimulationData *sim, float cfra){ PARTICLE_P; int totpart; - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); psys->lattice= psys_get_lattice(sim); @@ -3125,8 +3125,8 @@ static void save_hair(ParticleSimulationData *sim, float cfra){ key += pa->totkey; /* convert from global to geometry space */ - VecCopyf(key->co, pa->state.co); - Mat4MulVecfl(ob->imat, key->co); + copy_v3_v3(key->co, pa->state.co); + mul_m4_v3(ob->imat, key->co); if(pa->totkey) { VECSUB(key->co, key->co, root->co); @@ -3941,6 +3941,6 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) system_step(&sim, cfra); /* save matrix for duplicators */ - Mat4Invert(psys->imat, ob->obmat); + invert_m4_m4(psys->imat, ob->obmat); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 68f0e33a98f..c2798b4a746 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -170,12 +170,12 @@ static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, f dfra = cfra2 - cfra1; - VecMulf(keys[1].vel, dfra); - VecMulf(keys[2].vel, dfra); + mul_v3_fl(keys[1].vel, dfra); + mul_v3_fl(keys[2].vel, dfra); psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); - VecMulf(keys->vel, 1.0f / dfra); + mul_v3_fl(keys->vel, 1.0f / dfra); VECCOPY(bp->pos, keys->co); VECCOPY(bp->vec, keys->vel); @@ -255,18 +255,18 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr /* determine velocity from previous location */ if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { if(cfra > pa->prev_state.time) { - VecSubf(pa->state.vel, pa->state.co, pa->prev_state.co); - VecMulf(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); + sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co); + mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); } else { - VecSubf(pa->state.vel, pa->prev_state.co, pa->state.co); - VecMulf(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); + sub_v3_v3v3(pa->state.vel, pa->prev_state.co, pa->state.co); + mul_v3_fl(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); } } /* determine rotation from velocity */ if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { - vectoquat(pa->state.vel, OB_NEGX, OB_POSZ, pa->state.rot); + vec_to_quat( pa->state.rot,pa->state.vel, OB_NEGX, OB_POSZ); } } static void ptcache_interpolate_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) @@ -292,18 +292,18 @@ static void ptcache_interpolate_particle(int index, void *psys_v, void **data, f /* determine velocity from previous location */ if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { if(keys[1].time > keys[2].time) { - VecSubf(keys[2].vel, keys[1].co, keys[2].co); - VecMulf(keys[2].vel, (keys[1].time - keys[2].time) / frs_sec); + sub_v3_v3v3(keys[2].vel, keys[1].co, keys[2].co); + mul_v3_fl(keys[2].vel, (keys[1].time - keys[2].time) / frs_sec); } else { - VecSubf(keys[2].vel, keys[2].co, keys[1].co); - VecMulf(keys[2].vel, (keys[2].time - keys[1].time) / frs_sec); + sub_v3_v3v3(keys[2].vel, keys[2].co, keys[1].co); + mul_v3_fl(keys[2].vel, (keys[2].time - keys[1].time) / frs_sec); } } /* determine rotation from velocity */ if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { - vectoquat(keys[2].vel, OB_NEGX, OB_POSZ, keys[2].rot); + vec_to_quat( keys[2].rot,keys[2].vel, OB_NEGX, OB_POSZ); } if(cfra > pa->time) @@ -311,13 +311,13 @@ static void ptcache_interpolate_particle(int index, void *psys_v, void **data, f dfra = cfra2 - cfra1; - VecMulf(keys[1].vel, dfra / frs_sec); - VecMulf(keys[2].vel, dfra / frs_sec); + mul_v3_fl(keys[1].vel, dfra / frs_sec); + mul_v3_fl(keys[2].vel, dfra / frs_sec); psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); - QuatInterpol(pa->state.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra); + interp_qt_qtqt(pa->state.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra); - VecMulf(pa->state.vel, frs_sec / dfra); + mul_v3_fl(pa->state.vel, frs_sec / dfra); pa->state.time = cfra; } @@ -425,18 +425,18 @@ static int ptcache_totwrite_particle(void *psys_v) // /* determine velocity from previous location */ // if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { // if(cfra > pa->prev_state.time) { -// VecSubf(pa->state.vel, pa->state.co, pa->prev_state.co); -// VecMulf(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); +// sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co); +// mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); // } // else { -// VecSubf(pa->state.vel, pa->prev_state.co, pa->state.co); -// VecMulf(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); +// sub_v3_v3v3(pa->state.vel, pa->prev_state.co, pa->state.co); +// mul_v3_fl(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); // } // } // // /* determine rotation from velocity */ // if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { -// vectoquat(pa->state.vel, OB_POSX, OB_POSZ, pa->state.rot); +// vec_to_quat( pa->state.rot,pa->state.vel, OB_POSX, OB_POSZ); // } //} //static void ptcache_interpolate_particle_stream(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) @@ -461,13 +461,13 @@ static int ptcache_totwrite_particle(void *psys_v) // // dfra = cfra2 - cfra1; // -// VecMulf(keys[1].vel, dfra / frs_sec); -// VecMulf(keys[2].vel, dfra / frs_sec); +// mul_v3_fl(keys[1].vel, dfra / frs_sec); +// mul_v3_fl(keys[2].vel, dfra / frs_sec); // // psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); -// QuatInterpol(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra); +// interp_qt_qtqt(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra); // -// VecMulf(pa->state.vel, frs_sec / dfra); +// mul_v3_fl(pa->state.vel, frs_sec / dfra); // // pa->state.time = cfra; //} @@ -525,12 +525,12 @@ static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, flo dfra = cfra2 - cfra1; - VecMulf(keys[1].vel, dfra); - VecMulf(keys[2].vel, dfra); + mul_v3_fl(keys[1].vel, dfra); + mul_v3_fl(keys[2].vel, dfra); psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); - VecMulf(keys->vel, 1.0f / dfra); + mul_v3_fl(keys->vel, 1.0f / dfra); VECCOPY(vert->x, keys->co); VECCOPY(vert->v, keys->vel); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 280311eee06..91fd0bac400 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -89,7 +89,7 @@ #include "BPY_extern.h" #endif -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" //XXX #include "nla.h" @@ -654,7 +654,7 @@ int next_object(Scene *scene, int val, Base **base, Object **ob) /* handle dupli's */ if(dupob) { - Mat4CpyMat4(dupob->ob->obmat, dupob->mat); + copy_m4_m4(dupob->ob->obmat, dupob->mat); (*base)->flag |= OB_FROMDUPLI; *ob= dupob->ob; @@ -667,7 +667,7 @@ int next_object(Scene *scene, int val, Base **base, Object **ob) (*base)->flag &= ~OB_FROMDUPLI; for(dupob= duplilist->first; dupob; dupob= dupob->next) { - Mat4CpyMat4(dupob->ob->obmat, dupob->omat); + copy_m4_m4(dupob->ob->obmat, dupob->omat); } free_object_duplilist(duplilist); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 078258092f7..a175ddf975a 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -38,7 +38,7 @@ #include "DNA_sequence_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_global.h" #include "BKE_plugin_types.h" diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index efb7db04029..c9bf29ed29c 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -51,7 +51,7 @@ #include "BKE_mesh.h" #include "BKE_subsurf.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" #include "BLI_editVert.h" @@ -116,31 +116,31 @@ DerivedMesh *object_get_derived_final(struct Scene *scene, Object *ob, CustomDat void space_transform_from_matrixs(SpaceTransform *data, float local[4][4], float target[4][4]) { float itarget[4][4]; - Mat4Invert(itarget, target); - Mat4MulSerie(data->local2target, itarget, local, 0, 0, 0, 0, 0, 0); - Mat4Invert(data->target2local, data->local2target); + invert_m4_m4(itarget, target); + mul_serie_m4(data->local2target, itarget, local, 0, 0, 0, 0, 0, 0); + invert_m4_m4(data->target2local, data->local2target); } void space_transform_apply(const SpaceTransform *data, float *co) { - VecMat4MulVecfl(co, ((SpaceTransform*)data)->local2target, co); + mul_v3_m4v3(co, ((SpaceTransform*)data)->local2target, co); } void space_transform_invert(const SpaceTransform *data, float *co) { - VecMat4MulVecfl(co, ((SpaceTransform*)data)->target2local, co); + mul_v3_m4v3(co, ((SpaceTransform*)data)->target2local, co); } static void space_transform_apply_normal(const SpaceTransform *data, float *no) { - Mat4Mul3Vecfl( ((SpaceTransform*)data)->local2target, no); - Normalize(no); // TODO: could we just determine de scale value from the matrix? + mul_mat3_m4_v3( ((SpaceTransform*)data)->local2target, no); + normalize_v3(no); // TODO: could we just determine de scale value from the matrix? } static void space_transform_invert_normal(const SpaceTransform *data, float *no) { - Mat4Mul3Vecfl(((SpaceTransform*)data)->target2local, no); - Normalize(no); // TODO: could we just determine de scale value from the matrix? + mul_mat3_m4_v3(((SpaceTransform*)data)->target2local, no); + normalize_v3(no); // TODO: could we just determine de scale value from the matrix? } /* @@ -223,7 +223,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) VECCOPY(tmp_co, nearest.co); space_transform_invert(&calc->local2target, tmp_co); - VecLerpf(co, co, tmp_co, weight); //linear interpolation + interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation } } @@ -258,7 +258,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa space_transform_apply_normal( transf, tmp_no ); no = tmp_no; - hit_tmp.dist *= Mat4ToScalef( ((SpaceTransform*)transf)->local2target ); + hit_tmp.dist *= mat4_to_scale( ((SpaceTransform*)transf)->local2target ); } else { @@ -285,7 +285,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa space_transform_invert( transf, hit_tmp.co ); space_transform_invert_normal( transf, hit_tmp.no ); - hit_tmp.dist = VecLenf( (float*)vert, hit_tmp.co ); + hit_tmp.dist = len_v3v3( (float*)vert, hit_tmp.co ); } memcpy(hit, &hit_tmp, sizeof(hit_tmp) ); @@ -331,7 +331,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) proj_axis[1] = 1.0f; if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) proj_axis[2] = 1.0f; - Normalize(proj_axis); + normalize_v3(proj_axis); //Invalid projection direction if(INPR(proj_axis, proj_axis) < FLT_EPSILON) @@ -364,7 +364,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S { VECCOPY(tmp_co, calc->vert[i].co); if(calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) - NormalShortToFloat(tmp_no, calc->vert[i].no); + normal_short_to_float_v3(tmp_no, calc->vert[i].no); else VECCOPY(tmp_no, proj_axis); } @@ -403,7 +403,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S if(hit.index != -1) { - VecLerpf(co, co, hit.co, weight); + interp_v3_v3v3(co, co, hit.co, weight); } } } @@ -486,14 +486,14 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position float dist = sasqrt( nearest.dist ); if(dist > FLT_EPSILON) - VecLerpf(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation + interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation else VECCOPY( tmp_co, nearest.co ); } //Convert the coordinates back to mesh coordinates space_transform_invert(&calc->local2target, tmp_co); - VecLerpf(co, co, tmp_co, weight); //linear interpolation + interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation } } diff --git a/source/blender/blenkernel/intern/simple_deform.c b/source/blender/blenkernel/intern/simple_deform.c index 2978a6f7f01..b2920615f5a 100644 --- a/source/blender/blenkernel/intern/simple_deform.c +++ b/source/blender/blenkernel/intern/simple_deform.c @@ -35,7 +35,7 @@ #include "BKE_lattice.h" #include "BKE_deform.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_shrinkwrap.h" #include @@ -171,8 +171,8 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, s } else { - Mat4CpyMat4(transf->local2target, smd->origin->obmat); - Mat4Invert(transf->target2local, transf->local2target); + copy_m4_m4(transf->local2target, smd->origin->obmat); + invert_m4_m4(transf->target2local, transf->local2target); } } @@ -246,7 +246,7 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, s axis_limit(limit_axis, smd_limit, co, dcut); simpleDeform_callback(smd_factor, dcut, co); //Apply deform - VecLerpf(vertexCos[i], vertexCos[i], co, weight); //Use vertex weight has coef of linear interpolation + interp_v3_v3v3(vertexCos[i], vertexCos[i], co, weight); //Use vertex weight has coef of linear interpolation if(transf) space_transform_invert(transf, vertexCos[i]); } diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 8deae7e8e10..a41c7747b1a 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -30,7 +30,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_sketch.h" #include "BKE_utildefines.h" @@ -73,7 +73,7 @@ void sk_initPoint(SK_Point *pt, SK_DrawData *dd, float *no) if (no) { VECCOPY(pt->no, no); - Normalize(pt->no); + normalize_v3(pt->no); } else { @@ -235,7 +235,7 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f total = end - start; - VecSubf(delta_p, p_end, p_start); + sub_v3_v3v3(delta_p, p_end, p_start); prev = stk->points + start; next = stk->points + end; @@ -259,8 +259,8 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f float *p = stk->points[start + 1 + i].p; VECCOPY(p, delta_p); - VecMulf(p, delta); - VecAddf(p, p, p_start); + mul_v3_fl(p, delta); + add_v3_v3v3(p, p, p_start); } } @@ -320,9 +320,9 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) VECCOPY(normal, stk->points[start].no); - VecSubf(distance, stk->points[end].p, stk->points[start].p); - Projf(normal, distance, normal); - limit = Normalize(normal); + sub_v3_v3v3(distance, stk->points[end].p, stk->points[start].p); + project_v3_v3v3(normal, distance, normal); + limit = normalize_v3(normal); for (i = 1; i < total - 1; i++) { @@ -330,14 +330,14 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) float offset[3]; float *p = stk->points[start + i].p; - VecSubf(distance, p, stk->points[start].p); - Projf(distance, distance, normal); + sub_v3_v3v3(distance, p, stk->points[start].p); + project_v3_v3v3(distance, distance, normal); VECCOPY(offset, normal); - VecMulf(offset, d); + mul_v3_fl(offset, d); - VecSubf(p, p, distance); - VecAddf(p, p, offset); + sub_v3_v3v3(p, p, distance); + add_v3_v3v3(p, p, offset); } } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index b7fe0bdfc98..0a106b1920d 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -44,7 +44,7 @@ #include "BLI_rand.h" #include "BLI_jitter.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" @@ -150,7 +150,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive float tmp[3]; VECCOPY(tmp, verts[i].co); - Mat4MulVecfl(ob->obmat, tmp); + mul_m4_v3(ob->obmat, tmp); // min BB min[0] = MIN2(min[0], tmp[0]); @@ -262,8 +262,8 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // bvhtree_from_mesh_faces(smd->flow->bvh, dm, 0.0, 2, 6); // copy obmat - // Mat4CpyMat4(smd->flow->mat, ob->obmat); - // Mat4CpyMat4(smd->flow->mat_old, ob->obmat); + // copy_m4_m4(smd->flow->mat, ob->obmat); + // copy_m4_m4(smd->flow->mat_old, ob->obmat); } */ @@ -283,8 +283,8 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive SmokeCollSettings *scs = smd->coll; // copy obmat - Mat4CpyMat4(scs->mat, ob->obmat); - Mat4CpyMat4(scs->mat_old, ob->obmat); + copy_m4_m4(scs->mat, ob->obmat); + copy_m4_m4(scs->mat_old, ob->obmat); fill_scs_points(ob, dm, scs); } @@ -332,7 +332,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) { float tmpvec[3]; VECCOPY(tmpvec, mvert[i].co); - Mat4MulVecfl (ob->obmat, tmpvec); + mul_m4_v3(ob->obmat, tmpvec); VECCOPY(&scs->points[i * 3], tmpvec); } @@ -358,10 +358,10 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) VECSUB(side2, mvert[ mface[i].v3 ].co, mvert[ mface[i].v1 ].co); } - Crossf(trinormorg, side1, side2); - Normalize(trinormorg); + cross_v3_v3v3(trinormorg, side1, side2); + normalize_v3(trinormorg); VECCOPY(trinorm, trinormorg); - VecMulf(trinorm, 0.25 * cell_len); + mul_v3_fl(trinorm, 0.25 * cell_len); for(j = 0; j <= divs1; j++) { @@ -390,9 +390,9 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) VECCOPY(p3, mvert[ mface[i].v3 ].co); } - VecMulf(p1, (1.0-uf-vf)); - VecMulf(p2, uf); - VecMulf(p3, vf); + mul_v3_fl(p1, (1.0-uf-vf)); + mul_v3_fl(p2, uf); + mul_v3_fl(p3, vf); VECADD(p, p1, p2); VECADD(p, p, p3); @@ -403,7 +403,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) // mMovPoints.push_back(p + trinorm); VECCOPY(tmpvec, p); VECADD(tmpvec, tmpvec, trinorm); - Mat4MulVecfl (ob->obmat, tmpvec); + mul_m4_v3(ob->obmat, tmpvec); VECCOPY(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], tmpvec); newdivs++; @@ -413,7 +413,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) // mMovPoints.push_back(p - trinorm); VECCOPY(tmpvec, p); VECSUB(tmpvec, tmpvec, trinorm); - Mat4MulVecfl (ob->obmat, tmpvec); + mul_m4_v3(ob->obmat, tmpvec); VECCOPY(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], tmpvec); newdivs++; } @@ -466,11 +466,11 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int int divs1=0, divs2=0, divs3=0; VECCOPY(p0, verts[faces[i].v1].co); - Mat4MulVecfl (ob->obmat, p0); + mul_m4_v3(ob->obmat, p0); VECCOPY(p1, verts[faces[i].v2].co); - Mat4MulVecfl (ob->obmat, p1); + mul_m4_v3(ob->obmat, p1); VECCOPY(p2, verts[faces[i].v3].co); - Mat4MulVecfl (ob->obmat, p2); + mul_m4_v3(ob->obmat, p2); VECSUB(side1, p1, p0); VECSUB(side2, p2, p0); @@ -478,12 +478,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int if(INPR(side1, side1) > fsTri*fsTri) { - float tmp = Normalize(side1); + float tmp = normalize_v3(side1); divs1 = (int)ceil(tmp/fsTri); } if(INPR(side2, side2) > fsTri*fsTri) { - float tmp = Normalize(side2); + float tmp = normalize_v3(side2); divs2 = (int)ceil(tmp/fsTri); /* @@ -505,11 +505,11 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int facecounter++; VECCOPY(p0, verts[faces[i].v3].co); - Mat4MulVecfl (ob->obmat, p0); + mul_m4_v3(ob->obmat, p0); VECCOPY(p1, verts[faces[i].v4].co); - Mat4MulVecfl (ob->obmat, p1); + mul_m4_v3(ob->obmat, p1); VECCOPY(p2, verts[faces[i].v1].co); - Mat4MulVecfl (ob->obmat, p2); + mul_m4_v3(ob->obmat, p2); VECSUB(side1, p1, p0); VECSUB(side2, p2, p0); @@ -517,12 +517,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int if(INPR(side1, side1) > fsTri*fsTri) { - float tmp = Normalize(side1); + float tmp = normalize_v3(side1); divs1 = (int)ceil(tmp/fsTri); } if(INPR(side2, side2) > fsTri*fsTri) { - float tmp = Normalize(side2); + float tmp = normalize_v3(side2); divs2 = (int)ceil(tmp/fsTri); } @@ -849,7 +849,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue; else if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue; // VECCOPY(pos, pa->state.co); - // Mat4MulVecfl (ob->imat, pos); + // mul_m4_v3(ob->imat, pos); // 1. get corresponding cell get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, pa->state.co, cell, 0); // check if cell is valid (in the domain boundary) @@ -1105,8 +1105,8 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM // rigid movement support /* - Mat4CpyMat4(smd->flow->mat_old, smd->flow->mat); - Mat4CpyMat4(smd->flow->mat, ob->obmat); + copy_m4_m4(smd->flow->mat_old, smd->flow->mat); + copy_m4_m4(smd->flow->mat, ob->obmat); */ } else if(scene->r.cfra < smd->time) @@ -1131,8 +1131,8 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smd->coll->dm = CDDM_copy(dm); // rigid movement support - Mat4CpyMat4(smd->coll->mat_old, smd->coll->mat); - Mat4CpyMat4(smd->coll->mat, ob->obmat); + copy_m4_m4(smd->coll->mat_old, smd->coll->mat); + copy_m4_m4(smd->coll->mat, ob->obmat); } else if(scene->r.cfra < smd->time) { @@ -1378,7 +1378,7 @@ static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int float tmp[3]; VECSUB(tmp, pos, p0); - VecMulf(tmp, 1.0 / dx); + mul_v3_fl(tmp, 1.0 / dx); if(correct) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 6e986325f55..0a68ad6e803 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -66,7 +66,7 @@ variables on the UI for now #include "DNA_scene_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_ghash.h" #include "BLI_threads.h" @@ -265,7 +265,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) /* ah yeah, put the verices to global coords once */ /* and determine the ortho BB on the fly */ for(i=0; i < pccd_M->totvert; i++){ - Mat4MulVecfl(ob->obmat, pccd_M->mvert[i].co); + mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); @@ -362,7 +362,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) /* ah yeah, put the verices to global coords once */ /* and determine the ortho BB on the fly */ for(i=0; i < pccd_M->totvert; i++){ - Mat4MulVecfl(ob->obmat, pccd_M->mvert[i].co); + mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); @@ -1059,8 +1059,8 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa /* calculate face normal once again SIGH */ VECSUB(edge1, face_v1, face_v2); VECSUB(edge2, face_v3, face_v2); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); hash = vertexowner->soft->scratch->colliderhash; @@ -1103,14 +1103,14 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa while(a){ VECCOPY(nv1,mvert[a-1].co); if(mprevvert){ - VecMulf(nv1,time); + mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[a-1].co); } /* origin to face_v2*/ VECSUB(nv1, nv1, face_v2); - facedist = Inpf(nv1,d_nvect); + facedist = dot_v3v3(nv1,d_nvect); if (ABS(facedist) 0){ df = (outerfacethickness-facedist)/outerfacethickness; @@ -1218,17 +1218,17 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa VECCOPY(nv4,mvert[mface->v4].co); } if (mprevvert){ - VecMulf(nv1,time); + mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); - VecMulf(nv2,time); + mul_v3_fl(nv2,time); Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); - VecMulf(nv3,time); + mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); if (mface->v4){ - VecMulf(nv4,time); + mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } } @@ -1237,12 +1237,12 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa /* switch origin to be nv2*/ VECSUB(edge1, nv1, nv2); VECSUB(edge2, nv3, nv2); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); if ( - LineIntersectsTriangle(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) || - LineIntersectsTriangle(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) || - LineIntersectsTriangle(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ + isect_line_tri_v3(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) || + isect_line_tri_v3(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) || + isect_line_tri_v3(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ Vec3PlusStVec(force,-0.5f,d_nvect); *damp=tune*ob->pd->pdef_sbdamp; deflected = 2; @@ -1251,13 +1251,13 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa /* switch origin to be nv4 */ VECSUB(edge1, nv3, nv4); VECSUB(edge2, nv1, nv4); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); if ( - /* LineIntersectsTriangle(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) || + /* isect_line_tri_v3(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) || we did that edge allready */ - LineIntersectsTriangle(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) || - LineIntersectsTriangle(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ + isect_line_tri_v3(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) || + isect_line_tri_v3(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ Vec3PlusStVec(force,-0.5f,d_nvect); *damp=tune*ob->pd->pdef_sbdamp; deflected = 2; @@ -1380,7 +1380,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa aabbmax[1] = MAX2(edge_v1[1],edge_v2[1]); aabbmax[2] = MAX2(edge_v1[2],edge_v2[2]); - el = VecLenf(edge_v1,edge_v2); + el = len_v3v3(edge_v1,edge_v2); hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); @@ -1446,17 +1446,17 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa VECCOPY(nv4,mvert[mface->v4].co); } if (mprevvert){ - VecMulf(nv1,time); + mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); - VecMulf(nv2,time); + mul_v3_fl(nv2,time); Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); - VecMulf(nv3,time); + mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); if (mface->v4){ - VecMulf(nv4,time); + mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } } @@ -1466,15 +1466,15 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa VECSUB(edge1, nv1, nv2); VECSUB(edge2, nv3, nv2); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); - if ( LineIntersectsTriangle(edge_v1, edge_v2, nv1, nv2, nv3, &t, NULL)){ + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); + if ( isect_line_tri_v3(edge_v1, edge_v2, nv1, nv2, nv3, &t, NULL)){ float v1[3],v2[3]; float intrusiondepth,i1,i2; VECSUB(v1, edge_v1, nv2); VECSUB(v2, edge_v2, nv2); - i1 = Inpf(v1,d_nvect); - i2 = Inpf(v2,d_nvect); + i1 = dot_v3v3(v1,d_nvect); + i2 = dot_v3v3(v2,d_nvect); intrusiondepth = -MIN2(i1,i2)/el; Vec3PlusStVec(force,intrusiondepth,d_nvect); *damp=ob->pd->pdef_sbdamp; @@ -1485,15 +1485,15 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa VECSUB(edge1, nv3, nv4); VECSUB(edge2, nv1, nv4); - Crossf(d_nvect, edge2, edge1); - Normalize(d_nvect); - if (LineIntersectsTriangle( edge_v1, edge_v2,nv1, nv3, nv4, &t, NULL)){ + cross_v3_v3v3(d_nvect, edge2, edge1); + normalize_v3(d_nvect); + if (isect_line_tri_v3( edge_v1, edge_v2,nv1, nv3, nv4, &t, NULL)){ float v1[3],v2[3]; float intrusiondepth,i1,i2; VECSUB(v1, edge_v1, nv4); VECSUB(v2, edge_v2, nv4); - i1 = Inpf(v1,d_nvect); - i2 = Inpf(v2,d_nvect); + i1 = dot_v3v3(v1,d_nvect); + i2 = dot_v3v3(v2,d_nvect); intrusiondepth = -MIN2(i1,i2)/el; @@ -1531,7 +1531,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, if (ob->softflag & OB_SB_EDGECOLL){ if ( sb_detect_edge_collisionCached (sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos, &damp,feedback,ob->lay,ob,timenow)){ - VecAddf(bs->ext_force,bs->ext_force,feedback); + add_v3_v3v3(bs->ext_force,bs->ext_force,feedback); bs->flag |= BSF_INTERSECT; //bs->cf=damp; bs->cf=sb->choke*0.01f; @@ -1550,30 +1550,30 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, EffectedPoint epoint; float speed[3]={0.0f,0.0f,0.0f}; float pos[3]; - VecMidf(pos, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos); - VecMidf(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec); + mid_v3_v3v3(pos, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos); + mid_v3_v3v3(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec); pd_point_from_soft(scene, pos, vel, -1, &epoint); pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); - VecMulf(speed,windfactor); - VecAddf(vel,vel,speed); + mul_v3_fl(speed,windfactor); + add_v3_v3v3(vel,vel,speed); } /* media in rest */ else{ VECADD(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec); } - f = Normalize(vel); + f = normalize_v3(vel); f = -0.0001f*f*f*sb->aeroedge; /* (todo) add a nice angle dependant function done for now BUT */ /* still there could be some nice drag/lift function, but who needs it */ VECSUB(sp, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos); - Projf(pr,vel,sp); + project_v3_v3v3(pr,vel,sp); VECSUB(vel,vel,pr); - Normalize(vel); + normalize_v3(vel); if (ob->softflag & OB_SB_AERO_ANGLE){ - Normalize(sp); - Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(Inpf(vel,sp))),vel); + normalize_v3(sp); + Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(dot_v3v3(vel,sp))),vel); } else{ Vec3PlusStVec(bs->ext_force,f,vel); // to keep compatible with 2.45 release files @@ -1671,15 +1671,15 @@ static int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,fl { float mindist,cp; int winner =1; - mindist = ABS(Inpf(pos,a)); + mindist = ABS(dot_v3v3(pos,a)); - cp = ABS(Inpf(pos,b)); + cp = ABS(dot_v3v3(pos,b)); if ( mindist < cp ){ mindist = cp; winner =2; } - cp = ABS(Inpf(pos,c)); + cp = ABS(dot_v3v3(pos,c)); if (mindist < cp ){ mindist = cp; winner =3; @@ -1805,17 +1805,17 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], VECSUB(vv4,nv4,mprevvert[mface->v4].co); } - VecMulf(nv1,time); + mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); - VecMulf(nv2,time); + mul_v3_fl(nv2,time); Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); - VecMulf(nv3,time); + mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); if (mface->v4){ - VecMulf(nv4,time); + mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } } @@ -1826,14 +1826,14 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], VECSUB(edge2, nv3, nv2); VECSUB(dv1,opco,nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */ - Crossf(d_nvect, edge2, edge1); - n_mag = Normalize(d_nvect); - facedist = Inpf(dv1,d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + n_mag = normalize_v3(d_nvect); + facedist = dot_v3v3(dv1,d_nvect); // so rules are // if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ - if (point_in_tri_prism(opco, nv1, nv2, nv3) ){ + if (isect_point_tri_prism_v3(opco, nv1, nv2, nv3) ){ force_mag_norm =(float)exp(-ee*facedist); if (facedist > outerfacethickness*ff) force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness); @@ -1863,12 +1863,12 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], VECSUB(edge2, nv1, nv4); VECSUB(dv1,opco,nv4); /* abuse dv1 to have vertex in question at *origin* of triangle */ - Crossf(d_nvect, edge2, edge1); - n_mag = Normalize(d_nvect); - facedist = Inpf(dv1,d_nvect); + cross_v3_v3v3(d_nvect, edge2, edge1); + n_mag = normalize_v3(d_nvect); + facedist = dot_v3v3(dv1,d_nvect); if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ - if (point_in_tri_prism(opco, nv1, nv3, nv4) ){ + if (isect_point_tri_prism_v3(opco, nv1, nv3, nv4) ){ force_mag_norm =(float)exp(-ee*facedist); if (facedist > outerfacethickness*ff) force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness); @@ -1898,45 +1898,45 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], { // see if 'outer' hits an edge float dist; - PclosestVL3Dfl(ve, opco, nv1, nv2); + closest_to_line_segment_v3(ve, opco, nv1, nv2); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, deflected=1; } - PclosestVL3Dfl(ve, opco, nv2, nv3); + closest_to_line_segment_v3(ve, opco, nv2, nv3); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, deflected=1; } - PclosestVL3Dfl(ve, opco, nv3, nv1); + closest_to_line_segment_v3(ve, opco, nv3, nv1); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, deflected=1; } if (mface->v4){ /* quad */ - PclosestVL3Dfl(ve, opco, nv3, nv4); + closest_to_line_segment_v3(ve, opco, nv3, nv4); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, deflected=1; } - PclosestVL3Dfl(ve, opco, nv1, nv4); + closest_to_line_segment_v3(ve, opco, nv1, nv4); VECSUB(ve,opco,ve); - dist = Normalize(ve); + dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, @@ -1974,12 +1974,12 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } BLI_ghashIterator_free(ihash); - if (cavel) VecMulf(avel,1.0f/(float)cavel); + if (cavel) mul_v3_fl(avel,1.0f/(float)cavel); VECCOPY(vel,avel); if (ci) *intrusion /= ci; if (deflected){ VECCOPY(facenormal,force); - Normalize(facenormal); + normalize_v3(facenormal); } return deflected; } @@ -2060,8 +2060,8 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo } /* do bp1 <--> bp2 elastic */ - VecSubf(dir,bp1->pos,bp2->pos); - distance = Normalize(dir); + sub_v3_v3v3(dir,bp1->pos,bp2->pos); + distance = normalize_v3(dir); if (bs->len < distance) iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ else @@ -2092,10 +2092,10 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo Vec3PlusStVec(bp1->force,(bs->len - distance)*forcefactor,dir); /* do bp1 <--> bp2 viscous */ - VecSubf(dvel,bp1->vec,bp2->vec); + sub_v3_v3v3(dvel,bp1->vec,bp2->vec); kd = sb->infrict * sb_fric_force_scale(ob); - absvel = Normalize(dvel); - projvel = Inpf(dir,dvel); + absvel = normalize_v3(dvel); + projvel = dot_v3v3(dir,dvel); kd *= absvel * projvel; Vec3PlusStVec(bp1->force,-kd,dir); @@ -2169,11 +2169,11 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo for(c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) { compare = (obp->colball + bp->colball); - VecSubf(def, bp->pos, obp->pos); + sub_v3_v3v3(def, bp->pos, obp->pos); /* rather check the AABBoxes before ever calulating the real distance */ /* mathematically it is completly nuts, but performace is pretty much (3) times faster */ if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue; - distance = Normalize(def); + distance = normalize_v3(def); if (distance < compare ){ /* exclude body points attached with a spring */ attached = 0; @@ -2186,16 +2186,16 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if (!attached){ float f = bstune/(distance) + bstune/(compare*compare)*distance - 2.0f*bstune/compare ; - VecMidf(velcenter, bp->vec, obp->vec); - VecSubf(dvel,velcenter,bp->vec); - VecMulf(dvel,bp->mass); + mid_v3_v3v3(velcenter, bp->vec, obp->vec); + sub_v3_v3v3(dvel,velcenter,bp->vec); + mul_v3_fl(dvel,bp->mass); Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); Vec3PlusStVec(bp->force,sb->balldamp,dvel); /* exploit force(a,b) == -force(b,a) part2/2 */ - VecSubf(dvel,velcenter,obp->vec); - VecMulf(dvel,bp->mass); + sub_v3_v3v3(dvel,velcenter,obp->vec); + mul_v3_fl(dvel,bp->mass); Vec3PlusStVec(obp->force,sb->balldamp,dvel); Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); @@ -2213,16 +2213,16 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if(ob->softflag & OB_SB_GOAL) { /* true elastic goal */ float ks,kd; - VecSubf(auxvect,bp->pos,bp->origT); + sub_v3_v3v3(auxvect,bp->pos,bp->origT); ks = 1.0f/(1.0f- bp->goal*sb->goalspring)-1.0f ; bp->force[0]+= -ks*(auxvect[0]); bp->force[1]+= -ks*(auxvect[1]); bp->force[2]+= -ks*(auxvect[2]); /* calulate damping forces generated by goals*/ - VecSubf(velgoal,bp->origS, bp->origE); + sub_v3_v3v3(velgoal,bp->origS, bp->origE); kd = sb->goalfrict * sb_fric_force_scale(ob) ; - VecAddf(auxvect,velgoal,bp->vec); + add_v3_v3v3(auxvect,velgoal,bp->vec); if (forcetime > 0.0 ) { /* make sure friction does not become rocket motor on time reversal */ bp->force[0]-= kd * (auxvect[0]); @@ -2241,8 +2241,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if (sb && scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ float gravity[3]; VECCOPY(gravity, scene->physics_settings.gravity); - VecMulf(gravity, sb_grav_force_scale(ob)*bp->mass*sb->effector_weights->global_gravity); /* individual mass of node here */ - VecAddf(bp->force, bp->force, gravity); + mul_v3_fl(gravity, sb_grav_force_scale(ob)*bp->mass*sb->effector_weights->global_gravity); /* individual mass of node here */ + add_v3_v3v3(bp->force, bp->force, gravity); } /* particle field & vortex */ @@ -2256,7 +2256,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); /* apply forcefield*/ - VecMulf(force,fieldfactor* eval_sb_fric_force_scale); + mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); VECADD(bp->force, bp->force, force); /* BP friction in moving media */ @@ -2309,7 +2309,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo for(b=bp->nofsprings;b>0;b--){ bs = sb->bspring + bp->springs[b-1]; if (do_springcollision || do_aero){ - VecAddf(bp->force,bp->force,bs->ext_force); + add_v3_v3v3(bp->force,bp->force,bs->ext_force); if (bs->flag & BSF_INTERSECT) bp->choke = bs->cf; @@ -2478,7 +2478,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ VECCOPY(gravity, scene->physics_settings.gravity); - VecMulf(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity); + mul_v3_fl(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity); } /* check conditions for various options */ @@ -2538,13 +2538,13 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa //if ((bp->octantflag & obp->octantflag) == 0) continue; compare = (obp->colball + bp->colball); - VecSubf(def, bp->pos, obp->pos); + sub_v3_v3v3(def, bp->pos, obp->pos); /* rather check the AABBoxes before ever calulating the real distance */ /* mathematically it is completly nuts, but performace is pretty much (3) times faster */ if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue; - distance = Normalize(def); + distance = normalize_v3(def); if (distance < compare ){ /* exclude body points attached with a spring */ attached = 0; @@ -2557,9 +2557,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (!attached){ float f = tune/(distance) + tune/(compare*compare)*distance - 2.0f*tune/compare ; - VecMidf(velcenter, bp->vec, obp->vec); - VecSubf(dvel,velcenter,bp->vec); - VecMulf(dvel,bp->mass); + mid_v3_v3v3(velcenter, bp->vec, obp->vec); + sub_v3_v3v3(dvel,velcenter,bp->vec); + mul_v3_fl(dvel,bp->mass); Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); Vec3PlusStVec(bp->force,sb->balldamp,dvel); @@ -2589,8 +2589,8 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa } /* exploit force(a,b) == -force(b,a) part2/2 */ - VecSubf(dvel,velcenter,obp->vec); - VecMulf(dvel,(bp->mass+obp->mass)/2.0f); + sub_v3_v3v3(dvel,velcenter,obp->vec); + mul_v3_fl(dvel,(bp->mass+obp->mass)/2.0f); Vec3PlusStVec(obp->force,sb->balldamp,dvel); Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); @@ -2609,7 +2609,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* do goal stuff */ if(ob->softflag & OB_SB_GOAL) { /* true elastic goal */ - VecSubf(auxvect,bp->pos,bp->origT); + sub_v3_v3v3(auxvect,bp->pos,bp->origT); ks = 1.0f/(1.0f- bp->goal*sb->goalspring)-1.0f ; bp->force[0]+= -ks*(auxvect[0]); bp->force[1]+= -ks*(auxvect[1]); @@ -2624,9 +2624,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* calulate damping forces generated by goals*/ - VecSubf(velgoal,bp->origS, bp->origE); + sub_v3_v3v3(velgoal,bp->origS, bp->origE); kd = sb->goalfrict * sb_fric_force_scale(ob) ; - VecAddf(auxvect,velgoal,bp->vec); + add_v3_v3v3(auxvect,velgoal,bp->vec); if (forcetime > 0.0 ) { /* make sure friction does not become rocket motor on time reversal */ bp->force[0]-= kd * (auxvect[0]); @@ -2634,7 +2634,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa bp->force[2]-= kd * (auxvect[2]); if(nl_flags & NLF_BUILD){ //int ia =3*(sb->totpoint-a); - Normalize(auxvect); + normalize_v3(auxvect); /* depending on my vel */ //dfdv_goal(ia,ia,kd*forcetime); } @@ -2663,7 +2663,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); /* apply forcefield*/ - VecMulf(force,fieldfactor* eval_sb_fric_force_scale); + mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); VECADD(bp->force, bp->force, force); /* BP friction in moving media */ @@ -2750,7 +2750,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa for(b=bp->nofsprings;b>0;b--){ bs = sb->bspring + bp->springs[b-1]; if (do_springcollision || do_aero){ - VecAddf(bp->force,bp->force,bs->ext_force); + add_v3_v3v3(bp->force,bp->force,bs->ext_force); if (bs->flag & BSF_INTERSECT) bp->choke = bs->cf; @@ -2882,7 +2882,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* the ( ... )' operator denotes derivate respective time */ /* the euler step for velocity then becomes */ /* v(t + dt) = v(t) + a(t) * dt */ - VecMulf(bp->force,timeovermass);/* individual mass of node here */ + mul_v3_fl(bp->force,timeovermass);/* individual mass of node here */ /* some nasty if's to have heun in here too */ VECCOPY(dv,bp->force); @@ -2909,17 +2909,17 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* so here is (x)'= v(elocity) */ /* the euler step for location then becomes */ /* x(t + dt) = x(t) + v(t~) * dt */ - VecMulf(dx,forcetime); + mul_v3_fl(dx,forcetime); /* the freezer coming sooner or later */ /* - if ((Inpf(dx,dx)force,bp->force)force,bp->force)frozen /=2; } else{ bp->frozen =MIN2(bp->frozen*1.05f,1.0f); } - VecMulf(dx,bp->frozen); + mul_v3_fl(dx,bp->frozen); */ /* again some nasty if's to have heun in here too */ if (mode ==1){ @@ -2940,10 +2940,10 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * we don't want to end up in deep space so we add some to balance that out */ if (bp->choke2 > 0.0f){ - VecMulf(bp->vec,(1.0f - bp->choke2)); + mul_v3_fl(bp->vec,(1.0f - bp->choke2)); } if (bp->choke > 0.0f){ - VecMulf(bp->vec,(1.0f - bp->choke)); + mul_v3_fl(bp->vec,(1.0f - bp->choke)); } } @@ -2959,7 +2959,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * if (bp->flag & SBF_DOFUZZY) fuzzy =1; } /*for*/ - if (sb->totpoint) VecMulf(cm,1.0f/sb->totpoint); + if (sb->totpoint) mul_v3_fl(cm,1.0f/sb->totpoint); if (sb->scratch){ VECCOPY(sb->scratch->aabbmin,aabbmin); VECCOPY(sb->scratch->aabbmax,aabbmax); @@ -3100,7 +3100,7 @@ static void apply_spring_memory(Object *ob) bs = &sb->bspring[a]; bp1 =&sb->bpoint[bs->v1]; bp2 =&sb->bpoint[bs->v2]; - l = VecLenf(bp1->pos,bp2->pos); + l = len_v3v3(bp1->pos,bp2->pos); r = bs->len/l; if (( r > 1.05f) || (r < 0.95)){ bs->len = ((100.0f - b) * bs->len + b*l)/100.0f; @@ -3192,7 +3192,7 @@ static void springs_from_mesh(Object *ob) bp= ob->soft->bpoint; for(a=0; atotvert; a++, bp++) { VECCOPY(bp->origS, me->mvert[a].co); - Mat4MulVecfl(ob->obmat, bp->origS); + mul_m4_v3(ob->obmat, bp->origS); } } @@ -3203,7 +3203,7 @@ static void springs_from_mesh(Object *ob) } for(a=0; atotspring; a++) { BodySpring *bs = &sb->bspring[a]; - bs->len= scale*VecLenf(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS); + bs->len= scale*len_v3v3(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS); } } } @@ -3341,10 +3341,10 @@ static float globallen(float *v1,float *v2,Object *ob) { float p1[3],p2[3]; VECCOPY(p1,v1); - Mat4MulVecfl(ob->obmat, p1); + mul_m4_v3(ob->obmat, p1); VECCOPY(p2,v2); - Mat4MulVecfl(ob->obmat, p2); - return VecLenf(p1,p2); + mul_m4_v3(ob->obmat, p2); + return len_v3v3(p1,p2); } static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object *ob) @@ -3573,12 +3573,12 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, int a; /* inverse matrix is not uptodate... */ - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); for(a=0; apos); if(local==0) - Mat4MulVecfl(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */ + mul_m4_v3(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */ } } @@ -3706,7 +3706,7 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo /* copy the position of the goals at desired end time */ VECCOPY(bp->origE, vertexCos[a]); /* vertexCos came from local world, go global */ - Mat4MulVecfl(ob->obmat, bp->origE); + mul_m4_v3(ob->obmat, bp->origE); /* just to be save give bp->origT a defined value will be calulated in interpolate_exciter()*/ VECCOPY(bp->origT, bp->origE); @@ -3720,7 +3720,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int for(a=0,bp=sb->bpoint; apos, vertexCos[a]); - Mat4MulVecfl(ob->obmat, bp->pos); /* yep, sofbody is global coords*/ + mul_m4_v3(ob->obmat, bp->pos); /* yep, sofbody is global coords*/ VECCOPY(bp->origS, bp->pos); VECCOPY(bp->origE, bp->pos); VECCOPY(bp->origT, bp->pos); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 6e95fe7ebc7..cb2e2c437bf 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -54,7 +54,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_linklist.h" #include "BLI_memarena.h" #include "BLI_edgehash.h" @@ -561,7 +561,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, } DM_interp_vert_data(dm, result, vertIdx, weight[0][0], numVerts, i); - VecCopyf(mvert->co, ccgSubSurf_getFaceCenterData(f)); + copy_v3_v3(mvert->co, ccgSubSurf_getFaceCenterData(f)); *origIndex = ORIGINDEX_NONE; ++mvert; ++origIndex; @@ -579,7 +579,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, w[nextS] = weight[x][0][2]; w[otherS] = weight[x][0][3]; DM_interp_vert_data(dm, result, vertIdx, w, numVerts, i); - VecCopyf(mvert->co, + copy_v3_v3(mvert->co, ccgSubSurf_getFaceGridEdgeData(ss, f, S, x)); *origIndex = ORIGINDEX_NONE; @@ -602,7 +602,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, w[nextS] = weight[y * gridFaces + x][0][2]; w[otherS] = weight[y * gridFaces + x][0][3]; DM_interp_vert_data(dm, result, vertIdx, w, numVerts, i); - VecCopyf(mvert->co, + copy_v3_v3(mvert->co, ccgSubSurf_getFaceGridData(ss, f, S, x, y)); *origIndex = ORIGINDEX_NONE; ++mvert; @@ -633,7 +633,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, w[1] = (float) x / (edgeSize - 1); w[0] = 1 - w[1]; DM_interp_vert_data(dm, result, vertIdx, w, 2, i); - VecCopyf(mvert->co, ccgSubSurf_getEdgeData(ss, e, x)); + copy_v3_v3(mvert->co, ccgSubSurf_getEdgeData(ss, e, x)); *origIndex = ORIGINDEX_NONE; ++mvert; ++origIndex; @@ -651,7 +651,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, vertIdx = GET_INT_FROM_POINTER(ccgSubSurf_getVertVertHandle(v)); DM_copy_vert_data(dm, result, vertIdx, i, 1); - VecCopyf(mvert->co, ccgSubSurf_getVertData(ss, v)); + copy_v3_v3(mvert->co, ccgSubSurf_getVertData(ss, v)); *((int*)ccgSubSurf_getVertUserData(ss, v)) = i; *origIndex = ccgDM_getVertMapIndex(ss, v); @@ -1016,19 +1016,19 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) offset = vertNum - ccgdm->faceMap[i].startVert; if(offset < 1) { - VecCopyf(mv->co, ccgSubSurf_getFaceCenterData(f)); + copy_v3_v3(mv->co, ccgSubSurf_getFaceCenterData(f)); } else if(offset < gridSideEnd) { offset -= 1; grid = offset / gridSideVerts; x = offset % gridSideVerts + 1; - VecCopyf(mv->co, ccgSubSurf_getFaceGridEdgeData(ss, f, grid, x)); + copy_v3_v3(mv->co, ccgSubSurf_getFaceGridEdgeData(ss, f, grid, x)); } else if(offset < gridInternalEnd) { offset -= gridSideEnd; grid = offset / gridInternalVerts; offset %= gridInternalVerts; y = offset / gridSideVerts + 1; x = offset % gridSideVerts + 1; - VecCopyf(mv->co, ccgSubSurf_getFaceGridData(ss, f, grid, x, y)); + copy_v3_v3(mv->co, ccgSubSurf_getFaceGridData(ss, f, grid, x, y)); } } else if((vertNum < ccgdm->vertMap[0].startVert) && (ccgSubSurf_getNumEdges(ss) > 0)) { /* this vert comes from edge data */ @@ -1043,14 +1043,14 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) e = ccgdm->edgeMap[i].edge; x = vertNum - ccgdm->edgeMap[i].startVert + 1; - VecCopyf(mv->co, ccgSubSurf_getEdgeData(ss, e, x)); + copy_v3_v3(mv->co, ccgSubSurf_getEdgeData(ss, e, x)); } else { /* this vert comes from vert data */ CCGVert *v; i = vertNum - ccgdm->vertMap[0].startVert; v = ccgdm->vertMap[i].vert; - VecCopyf(mv->co, ccgSubSurf_getVertData(ss, v)); + copy_v3_v3(mv->co, ccgSubSurf_getVertData(ss, v)); } } @@ -1188,11 +1188,11 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) CCGFace *f = ccgdm->faceMap[index].face; int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f); - VecCopyf(mvert[i++].co, ccgSubSurf_getFaceCenterData(f)); + copy_v3_v3(mvert[i++].co, ccgSubSurf_getFaceCenterData(f)); for(S = 0; S < numVerts; S++) { for(x = 1; x < gridSize - 1; x++) { - VecCopyf(mvert[i++].co, + copy_v3_v3(mvert[i++].co, ccgSubSurf_getFaceGridEdgeData(ss, f, S, x)); } } @@ -1200,7 +1200,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for(S = 0; S < numVerts; S++) { for(y = 1; y < gridSize - 1; y++) { for(x = 1; x < gridSize - 1; x++) { - VecCopyf(mvert[i++].co, + copy_v3_v3(mvert[i++].co, ccgSubSurf_getFaceGridData(ss, f, S, x, y)); } } @@ -1213,7 +1213,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) int x; for(x = 1; x < edgeSize - 1; x++) { - VecCopyf(mvert[i++].co, ccgSubSurf_getEdgeData(ss, e, x)); + copy_v3_v3(mvert[i++].co, ccgSubSurf_getEdgeData(ss, e, x)); } } @@ -1221,7 +1221,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for(index = 0; index < totvert; index++) { CCGVert *v = ccgdm->vertMap[index].vert; - VecCopyf(mvert[i].co, ccgSubSurf_getVertData(ss, v)); + copy_v3_v3(mvert[i].co, ccgSubSurf_getVertData(ss, v)); i++; } @@ -1397,18 +1397,18 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) { CCGFace *f = faceMap2[index]; int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f); - VecCopyf(cos[i++], ccgSubSurf_getFaceCenterData(f)); + copy_v3_v3(cos[i++], ccgSubSurf_getFaceCenterData(f)); for (S=0; Ssize[0]= texmap->size[1]= texmap->size[2]= 1.0f; texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f; - Mat4One(texmap->mat); + unit_m4(texmap->mat); return texmap; } @@ -224,16 +224,16 @@ void init_mapping(TexMapping *texmap) { float eul[3], smat[3][3], rmat[3][3], mat[3][3]; - SizeToMat3(texmap->size, smat); + size_to_mat3( smat,texmap->size); eul[0]= (M_PI/180.0f)*texmap->rot[0]; eul[1]= (M_PI/180.0f)*texmap->rot[1]; eul[2]= (M_PI/180.0f)*texmap->rot[2]; - EulToMat3(eul, rmat); + eul_to_mat3( rmat,eul); - Mat3MulMat3(mat, rmat, smat); + mul_m3_m3m3(mat, rmat, smat); - Mat4CpyMat3(texmap->mat, mat); + copy_m4_m3(texmap->mat, mat); VECCOPY(texmap->mat[3], texmap->loc); } diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index c75c9272e5c..b5f8bc81b81 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -42,7 +42,7 @@ #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index eea49254a0e..75eb9b3bb28 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -37,7 +37,7 @@ #include "BKE_utildefines.h" #include "BLI_kdopbvh.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #ifdef _OPENMP #include @@ -1578,7 +1578,7 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float VECCOPY(data.ray.direction, dir); data.ray.radius = radius; - Normalize(data.ray.direction); + normalize_v3(data.ray.direction); for(i=0; i<3; i++) { @@ -1635,7 +1635,7 @@ float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, fl data.ray.origin[1] = light_start[1]; data.ray.origin[2] = light_start[2]; - Normalize(data.ray.direction); + normalize_v3(data.ray.direction); VECCOPY(data.ray_dot_axis, data.ray.direction); dist = ray_nearest_hit(&data, bv); diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index ccf79ed42dc..abf61bfb734 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_kdtree.h" #define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } @@ -76,8 +76,8 @@ void BLI_kdtree_insert(KDTree *tree, int index, float *co, float *nor) KDTreeNode *node= &tree->nodes[tree->totnode++]; node->index= index; - VecCopyf(node->co, co); - if(nor) VecCopyf(node->nor, nor); + copy_v3_v3(node->co, co); + if(nor) copy_v3_v3(node->nor, nor); } static KDTreeNode *kdtree_balance(KDTreeNode *nodes, int totnode, int axis) @@ -225,7 +225,7 @@ int BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest * if(nearest) { nearest->index= min_node->index; nearest->dist= sqrt(min_dist); - VecCopyf(nearest->co, min_node->co); + copy_v3_v3(nearest->co, min_node->co); } if(stack != defaultstack) @@ -249,7 +249,7 @@ static void add_nearest(KDTreeNearest *ptn, int *found, int n, int index, float ptn[i].index= index; ptn[i].dist= dist; - VecCopyf(ptn[i].co, co); + copy_v3_v3(ptn[i].co, co); } /* finds the nearest n entries in tree to specified coordinates */ @@ -366,7 +366,7 @@ static void add_in_range(KDTreeNearest **ptn, int found, int *totfoundstack, int to->index = index; to->dist = sqrt(dist); - VecCopyf(to->co, co); + copy_v3_v3(to->co, co); } int BLI_kdtree_range_search(KDTree *tree, float range, float *co, float *nor, KDTreeNearest **nearest) { diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index cb5632df569..f2727f6f259 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -45,7 +45,7 @@ #include "BLI_vfontdata.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" //XXX #include "BIF_toolbox.h" @@ -256,11 +256,11 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf // VecLenf, see if there's a distance between the three points // VecLenf again, to check the angle between the handles // finally, check if one of them is a vector handle - if((DistVL2Dfl(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001) && - (VecLenf(bezt->vec[0], bezt->vec[1]) > 0.0001) && - (VecLenf(bezt->vec[1], bezt->vec[2]) > 0.0001) && - (VecLenf(bezt->vec[0], bezt->vec[2]) > 0.0002) && - (VecLenf(bezt->vec[0], bezt->vec[2]) > MAX2(VecLenf(bezt->vec[0], bezt->vec[1]), VecLenf(bezt->vec[1], bezt->vec[2]))) && + if((dist_to_line_v2(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001) && + (len_v3v3(bezt->vec[0], bezt->vec[1]) > 0.0001) && + (len_v3v3(bezt->vec[1], bezt->vec[2]) > 0.0001) && + (len_v3v3(bezt->vec[0], bezt->vec[2]) > 0.0002) && + (len_v3v3(bezt->vec[0], bezt->vec[2]) > MAX2(len_v3v3(bezt->vec[0], bezt->vec[1]), len_v3v3(bezt->vec[1], bezt->vec[2]))) && bezt->h1 != HD_VECT && bezt->h2 != HD_VECT) { bezt->h1= bezt->h2= HD_ALIGN; diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index 49a3cad53f1..fd6bb1a2014 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -30,7 +30,7 @@ #include "BLI_graph.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" @@ -267,7 +267,7 @@ void BLI_removeDoubleNodes(BGraph *graph, float limit) { for(node_replaced = graph->nodes.first; node_replaced; node_replaced = node_replaced->next) { - if (node_replaced != node_src && VecLenf(node_replaced->p, node_src->p) <= limit) + if (node_replaced != node_src && len_v3v3(node_replaced->p, node_src->p) <= limit) { BLI_replaceNode(graph, node_src, node_replaced); } @@ -283,7 +283,7 @@ BNode * BLI_FindNodeByPosition(BGraph *graph, float *p, float limit) for(node = graph->nodes.first; node; node = node->next) { - float distance = VecLenf(p, node->p); + float distance = len_v3v3(p, node->p); if (distance <= limit && (closest_node == NULL || distance < min_distance)) { closest_node = node; @@ -526,10 +526,10 @@ void BLI_mirrorAlongAxis(float v[3], float center[3], float axis[3]) { float dv[3], pv[3]; - VecSubf(dv, v, center); - Projf(pv, dv, axis); - VecMulf(pv, -2); - VecAddf(v, v, pv); + sub_v3_v3v3(dv, v, center); + project_v3_v3v3(pv, dv, axis); + mul_v3_fl(pv, -2); + add_v3_v3v3(v, v, pv); } static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, int total, float axis[3], float limit, int group) @@ -546,7 +546,7 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, for (j = i + 1; j < total; j++) { - float angle = Inpf(ring[i].n, ring[j].n); + float angle = dot_v3v3(ring[i].n, ring[j].n); /* map negative values to 1..2 */ if (angle < 0) @@ -579,8 +579,8 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, float p[3]; int j = (i + 1) % total; /* next arc in the circular list */ - VecAddf(tangent, ring[i].n, ring[j].n); - Crossf(normal, tangent, axis); + add_v3_v3v3(tangent, ring[i].n, ring[j].n); + cross_v3_v3v3(normal, tangent, axis); node1 = BLI_otherNode(ring[i].arc, root_node); node2 = BLI_otherNode(ring[j].arc, root_node); @@ -589,7 +589,7 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, BLI_mirrorAlongAxis(p, root_node->p, normal); /* check if it's within limit before continuing */ - if (VecLenf(node1->p, p) > limit) + if (len_v3v3(node1->p, p) > limit) { symmetric = 0; } @@ -658,11 +658,11 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo unit->arc = connectedArc; /* project the node to node vector on the symmetry plane */ - VecSubf(unit->n, otherNode->p, root_node->p); - Projf(vec, unit->n, axis); - VecSubf(unit->n, unit->n, vec); + sub_v3_v3v3(unit->n, otherNode->p, root_node->p); + project_v3_v3v3(vec, unit->n, axis); + sub_v3_v3v3(unit->n, unit->n, vec); - Normalize(unit->n); + normalize_v3(unit->n); unit++; } @@ -780,9 +780,9 @@ static void flagAxialSymmetry(BNode *root_node, BNode *end_node, BArc *arc, int arc->symmetry_group = group; - VecSubf(vec, end_node->p, root_node->p); + sub_v3_v3v3(vec, end_node->p, root_node->p); - if (Inpf(vec, root_node->symmetry_axis) < 0) + if (dot_v3v3(vec, root_node->symmetry_axis) < 0) { arc->symmetry_flag |= SYM_SIDE_NEGATIVE; } @@ -796,26 +796,26 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo { float nor[3], vec[3], p[3]; - VecSubf(p, node1->p, root_node->p); - Crossf(nor, p, axis); + sub_v3_v3v3(p, node1->p, root_node->p); + cross_v3_v3v3(nor, p, axis); - VecSubf(p, root_node->p, node2->p); - Crossf(vec, p, axis); - VecAddf(vec, vec, nor); + sub_v3_v3v3(p, root_node->p, node2->p); + cross_v3_v3v3(vec, p, axis); + add_v3_v3v3(vec, vec, nor); - Crossf(nor, vec, axis); + cross_v3_v3v3(nor, vec, axis); if (abs(nor[0]) > abs(nor[1]) && abs(nor[0]) > abs(nor[2]) && nor[0] < 0) { - VecNegf(nor); + negate_v3(nor); } else if (abs(nor[1]) > abs(nor[0]) && abs(nor[1]) > abs(nor[2]) && nor[1] < 0) { - VecNegf(nor); + negate_v3(nor); } else if (abs(nor[2]) > abs(nor[1]) && abs(nor[2]) > abs(nor[0]) && nor[2] < 0) { - VecNegf(nor); + negate_v3(nor); } /* mirror node2 along axis */ @@ -823,7 +823,7 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo BLI_mirrorAlongAxis(p, root_node->p, nor); /* check if it's within limit before continuing */ - if (VecLenf(node1->p, p) <= limit) + if (len_v3v3(node1->p, p) <= limit) { /* mark node as symmetric physically */ VECCOPY(root_node->symmetry_axis, nor); @@ -905,12 +905,12 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int /* If arc is on the axis */ else if (connectedArc->symmetry_level == level) { - VecAddf(axis, axis, connectedArc->head->p); - VecSubf(axis, axis, connectedArc->tail->p); + add_v3_v3v3(axis, axis, connectedArc->head->p); + sub_v3_v3v3(axis, axis, connectedArc->tail->p); } } - Normalize(axis); + normalize_v3(axis); /* Split between axial and radial symmetry */ if (count == 2) diff --git a/source/blender/blenlib/intern/jitter.c b/source/blender/blenlib/intern/jitter.c index fd658765802..e7933ee98a2 100644 --- a/source/blender/blenlib/intern/jitter.c +++ b/source/blender/blenlib/intern/jitter.c @@ -34,7 +34,7 @@ #include #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BLI_jitter.h" diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index bd9ed85efa2..e54382c9392 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -40,7 +40,7 @@ #include "DNA_listBase.h" #include "DNA_mesh_types.h" #include "BLI_editVert.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_scanfill.h" #include "BLI_callbacks.h" @@ -432,13 +432,13 @@ static void testvertexnearedge(void) eed= filledgebase.first; while(eed) { if(eve!=eed->v1 && eve!=eed->v2 && eve->xs==eed->f1) { - if(FloatCompare(eve->co,eed->v1->co, COMPLIMIT)) { + if(compare_v3v3(eve->co,eed->v1->co, COMPLIMIT)) { ed1->v2= eed->v1; eed->v1->h++; eve->h= 0; break; } - else if(FloatCompare(eve->co,eed->v2->co, COMPLIMIT)) { + else if(compare_v3v3(eve->co,eed->v2->co, COMPLIMIT)) { ed1->v2= eed->v2; eed->v2->h++; eve->h= 0; @@ -450,7 +450,7 @@ static void testvertexnearedge(void) vec2[0]= eed->v2->co[cox]; vec2[1]= eed->v2->co[coy]; if(boundinsideEV(eed,eve)) { - dist= DistVL2Dfl(vec1,vec2,vec3); + dist= dist_to_line_v2(vec1,vec2,vec3); if(distv1, eve); @@ -819,12 +819,12 @@ int BLI_edgefill(int mode, int mat_nr) eve= fillvertbase.first; while(eve) { if(v2) { - if( FloatCompare(v2, eve->co, COMPLIMIT)==0) { - len= CalcNormFloat(v1, v2, eve->co, norm); + if( compare_v3v3(v2, eve->co, COMPLIMIT)==0) { + len= normal_tri_v3( norm,v1, v2, eve->co); if(len != 0.0) break; } } - else if(FloatCompare(v1, eve->co, COMPLIMIT)==0) { + else if(compare_v3v3(v1, eve->co, COMPLIMIT)==0) { v2= eve->co; } eve= eve->next; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f6e216b36e8..0082bfd546e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -102,7 +102,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_storage_types.h" // for relname flags #include "BKE_animsys.h" @@ -8464,7 +8464,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } /* correctly initialise constinv matrix */ - Mat4One(ob->constinv); + unit_m4(ob->constinv); if (ob->type == OB_ARMATURE) { if (ob->pose) { @@ -8494,7 +8494,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } /* correctly initialise constinv matrix */ - Mat4One(pchan->constinv); + unit_m4(pchan->constinv); } } } @@ -9899,7 +9899,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* Add default gravity to scenes */ for(sce= main->scene.first; sce; sce= sce->id.next) { if((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 - && VecLength(sce->physics_settings.gravity) == 0.0f) { + && len_v3(sce->physics_settings.gravity) == 0.0f) { sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f; sce->physics_settings.gravity[2] = -9.81f; diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index b626635d021..fac7b2c882a 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -37,7 +37,7 @@ extern "C" #include "BKE_image.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_string.h" #include "BLI_listbase.h" @@ -87,7 +87,7 @@ extern "C" // This function assumes that quat is normalized. // The following document was used as reference: // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm -void QuatToAxisAngle(float *q, float *axis, float *angle) +void quat_to_axis_angle( float *axis, float *angle,float *q) { // quat to axis angle *angle = 2 * acos(q[0]); @@ -666,11 +666,11 @@ protected: if (parent_mat) { float invpar[4][4]; - Mat4Invert(invpar, parent_mat); - Mat4MulMat4(local, mat, invpar); + invert_m4_m4(invpar, parent_mat); + mul_m4_m4m4(local, mat, invpar); } else { - Mat4CpyMat4(local, mat); + copy_m4_m4(local, mat); } TransformBase::decompose(local, loc, rot, size); @@ -681,9 +681,9 @@ protected: float axis[3]; float angle; double angle_deg; - EulToQuat(rot, quat); - NormalQuat(quat); - QuatToAxisAngle(quat, axis, &angle); + eul_to_quat( quat,rot); + normalize_qt(quat); + quat_to_axis_angle( axis, &angle,quat); angle_deg = angle * 180.0f / M_PI; node.addRotate(axis[0], axis[1], axis[2], angle_deg); */ @@ -901,12 +901,12 @@ private: bPoseChannel *parchan = get_pose_channel(ob_arm->pose, bone->parent->name); float invpar[4][4]; - Mat4Invert(invpar, parchan->pose_mat); - Mat4MulMat4(mat, pchan->pose_mat, invpar); + invert_m4_m4(invpar, parchan->pose_mat); + mul_m4_m4m4(mat, pchan->pose_mat, invpar); } else { // get world-space from armature-space - Mat4MulMat4(mat, pchan->pose_mat, ob_arm->obmat); + mul_m4_m4m4(mat, pchan->pose_mat, ob_arm->obmat); } TransformWriter::add_node_transform(node, mat, NULL); @@ -1059,9 +1059,9 @@ private: float inv_bind_mat[4][4]; // make world-space matrix, pose_mat is armature-space - Mat4MulMat4(world, pchan->pose_mat, ob_arm->obmat); + mul_m4_m4m4(world, pchan->pose_mat, ob_arm->obmat); - Mat4Invert(mat, world); + invert_m4_m4(mat, world); converter.mat4_to_dae(inv_bind_mat, mat); source.appendValues(inv_bind_mat); @@ -1241,9 +1241,9 @@ public: if (ob->type == OB_MESH && is_skinned_mesh) // for skinned mesh we write obmat in - Mat4One(mat); + unit_m4(mat); else - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); TransformWriter::add_node_transform(node, mat, ob->parent ? ob->parent->obmat : NULL); @@ -2048,7 +2048,7 @@ public: float eul[3]; - QuatToEul(quat, eul); + quat_to_eul( eul,quat); for (int k = 0; k < 3; k++) create_bezt(eulcu[k], frame, eul[k]); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 0aa69d11949..aae1738381f 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -50,7 +50,7 @@ extern "C" #include "BKE_depsgraph.h" #include "BLI_util.h" #include "BKE_displist.h" -#include "BLI_arithb.h" +#include "BLI_math.h" } #include "BKE_armature.h" #include "BKE_mesh.h" @@ -62,7 +62,7 @@ extern "C" #include "BKE_utildefines.h" #include "BKE_action.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_string.h" @@ -186,7 +186,7 @@ public: float cur[4][4]; float copy[4][4]; - Mat4One(mat); + unit_m4(mat); for (int i = 0; i < node->getTransformations().getCount(); i++) { @@ -199,7 +199,7 @@ public: COLLADAFW::Translate *tra = (COLLADAFW::Translate*)tm; COLLADABU::Math::Vector3& t = tra->getTranslation(); - Mat4One(cur); + unit_m4(cur); cur[3][0] = (float)t[0]; cur[3][1] = (float)t[1]; cur[3][2] = (float)t[2]; @@ -214,16 +214,16 @@ public: float quat[4]; float rot_copy[3][3]; float mat[3][3]; - AxisAngleToQuat(quat, axis, angle); + axis_angle_to_quat(quat, axis, angle); - QuatToMat4(quat, cur); + quat_to_mat4( cur,quat); } break; case COLLADAFW::Transformation::SCALE: { COLLADABU::Math::Vector3& s = ((COLLADAFW::Scale*)tm)->getScale(); float size[3] = {(float)s[0], (float)s[1], (float)s[2]}; - SizeToMat4(size, cur); + size_to_mat4( cur,size); } break; case COLLADAFW::Transformation::MATRIX: @@ -237,8 +237,8 @@ public: break; } - Mat4CpyMat4(copy, mat); - Mat4MulMat4(mat, cur, copy); + copy_m4_m4(copy, mat); + mul_m4_m4m4(mat, cur, copy); if (animation_map) { // AnimationList that drives this Transformation @@ -346,7 +346,7 @@ private: ob_arm(skin.ob_arm), controller_uid(skin.controller_uid) { - Mat4CpyMat4(bind_shape_matrix, (float (*)[4])skin.bind_shape_matrix); + copy_m4_m4(bind_shape_matrix, (float (*)[4])skin.bind_shape_matrix); transfer_uint_array_data_const(skin.joints_per_vertex, joints_per_vertex); transfer_uint_array_data_const(skin.weight_indices, weight_indices); @@ -438,7 +438,7 @@ private: std::vector::iterator it; for (it = joint_data.begin(); it != joint_data.end(); it++) { if ((*it).joint_uid == uid) { - Mat4CpyMat4(inv_bind_mat, (*it).inv_bind_mat); + copy_m4_m4(inv_bind_mat, (*it).inv_bind_mat); return true; } } @@ -491,8 +491,8 @@ private: // we need armature matrix here... where do we get it from I wonder... // root node/joint? or node with ? float parmat[4][4]; - Mat4One(parmat); - Mat4Invert(ob->parentinv, parmat); + unit_m4(parmat); + invert_m4_m4(ob->parentinv, parmat); // create all vertex groups std::vector::iterator it; @@ -574,7 +574,7 @@ private: if (skin.get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) { // get original world-space matrix - Mat4Invert(mat, joint_inv_bind_mat); + invert_m4_m4(mat, joint_inv_bind_mat); } // create a bone even if there's no joint data for it (i.e. it has no influence) else { @@ -585,9 +585,9 @@ private: // get world-space if (parent) - Mat4MulMat4(mat, obmat, parent_mat); + mul_m4_m4m4(mat, obmat, parent_mat); else - Mat4CpyMat4(mat, obmat); + copy_m4_m4(mat, obmat); } // TODO rename from Node "name" attrs later @@ -597,21 +597,21 @@ private: if (parent) bone->parent = parent; // set head - VecCopyf(bone->head, mat[3]); + copy_v3_v3(bone->head, mat[3]); // set tail, don't set it to head because 0-length bones are not allowed float vec[3] = {0.0f, 0.5f, 0.0f}; - VecAddf(bone->tail, bone->head, vec); + add_v3_v3v3(bone->tail, bone->head, vec); // set parent tail if (parent && totchild == 1) { - VecCopyf(parent->tail, bone->head); + copy_v3_v3(parent->tail, bone->head); // XXX increase this to prevent "very" small bones? const float epsilon = 0.000001f; // derive leaf bone length - float length = VecLenf(parent->head, parent->tail); + float length = len_v3v3(parent->head, parent->tail); if ((length < leaf_bone_length || totbone == 0) && length > epsilon) { leaf_bone_length = length; } @@ -625,20 +625,20 @@ private: #if 0 // and which row in mat is bone direction float vec[3]; - VecSubf(vec, parent->tail, parent->head); + sub_v3_v3v3(vec, parent->tail, parent->head); #ifdef COLLADA_DEBUG - printvecf("tail - head", vec); - printmatrix4("matrix", parent_mat); + print_v3("tail - head", vec); + print_m4("matrix", parent_mat); #endif for (int i = 0; i < 3; i++) { #ifdef COLLADA_DEBUG char *axis_names[] = {"X", "Y", "Z"}; - printf("%s-axis length is %f\n", axis_names[i], VecLength(parent_mat[i])); + printf("%s-axis length is %f\n", axis_names[i], len_v3(parent_mat[i])); #endif - float angle = VecAngle2(vec, parent_mat[i]); + float angle = angle_v2v2(vec, parent_mat[i]); if (angle < min_angle) { #ifdef COLLADA_DEBUG - printvecf("picking", parent_mat[i]); + print_v3("picking", parent_mat[i]); printf("^ %s axis of %s's matrix\n", axis_names[i], get_dae_name(node)); #endif bone_direction_row = i; @@ -665,7 +665,7 @@ private: LeafBone leaf; leaf.bone = bone; - Mat4CpyMat4(leaf.mat, mat); + copy_m4_m4(leaf.mat, mat); BLI_strncpy(leaf.name, bone->name, sizeof(leaf.name)); leaf_bones.push_back(leaf); @@ -682,10 +682,10 @@ private: // pointing up float vec[3] = {0.0f, 0.0f, 1.0f}; - VecMulf(vec, leaf_bone_length); + mul_v3_fl(vec, leaf_bone_length); - VecCopyf(leaf.bone->tail, leaf.bone->head); - VecAddf(leaf.bone->tail, leaf.bone->head, vec); + copy_v3_v3(leaf.bone->tail, leaf.bone->head); + add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); } } @@ -2200,7 +2200,7 @@ public: float quat[4]; - EulToQuat(eul, quat); + eul_to_quat( quat,eul); for (int k = 0; k < 4; k++) create_bezt(quatcu[k], frame, quat[k]); diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h index c0d74505f72..32c3e7af874 100644 --- a/source/blender/collada/collada_internal.h +++ b/source/blender/collada/collada_internal.h @@ -39,8 +39,8 @@ public: void mat4_to_dae(float out[][4], float in[][4]) { - Mat4CpyMat4(out, in); - Mat4Transp(out); + copy_m4_m4(out, in); + transpose_m4(out); } void mat4_to_dae_double(double out[][4], float in[][4]) @@ -60,9 +60,9 @@ class TransformBase public: void decompose(float mat[][4], float *loc, float *rot, float *size) { - Mat4ToSize(mat, size); - Mat4ToEul(mat, rot); - VecCopyf(loc, mat[3]); + mat4_to_size( size,mat); + mat4_to_eul( rot,mat); + copy_v3_v3(loc, mat[3]); } }; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index e8bfbf7fe52..ca400973363 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_listBase.h" #include "DNA_anim_types.h" diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 1e5f1eac867..57a0f469458 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_listBase.h" #include "DNA_anim_types.h" diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index d707ea0a2c4..98b6d0e7097 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -40,7 +40,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_key_types.h" diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 13f38dae6ea..ac2eec6fd21 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dynstr.h" #include "DNA_anim_types.h" diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 65c73355ad7..872722607ce 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -47,7 +47,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 019ece64132..a84ca580a15 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dlrbTree.h" #include "DNA_listBase.h" diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 7a167cb6c0c..d4ec78ace16 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -32,7 +32,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 3ad6ddf2c6f..9d3fc7a0fc4 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -33,7 +33,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 0412ee89e51..17a7dd91ed8 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dynstr.h" #include "DNA_anim_types.h" @@ -617,7 +617,7 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ else if (strstr(identifier, "rotation")) { float eul[3]; - Mat4ToEul(ob->obmat, eul); + mat4_to_eul( eul,ob->obmat); return eul[array_index]; } } @@ -632,7 +632,7 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ * be safe. Therefore, the active object is passed here, and in many cases, this * will be what owns the pose-channel that is getting this anyway. */ - Mat4CpyMat4(tmat, pchan->pose_mat); + copy_m4_m4(tmat, pchan->pose_mat); constraint_mat_convertspace(ob, pchan, tmat, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_LOCAL); /* Loc, Rot/Quat keyframes are supported... */ @@ -647,14 +647,14 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ float eul[3]; /* euler-rotation test before standard rotation, as standard rotation does quats */ - Mat4ToEulO(tmat, eul, pchan->rotmode); + mat4_to_eulO( eul, pchan->rotmode,tmat); return eul[array_index]; } else if (strstr(identifier, "rotation_quaternion")) { float trimat[3][3], quat[4]; - Mat3CpyMat4(trimat, tmat); - Mat3ToQuat_is_ok(trimat, quat); + copy_m3_m4(trimat, tmat); + mat3_to_quat_is_ok( quat,trimat); return quat[array_index]; } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 0f4f29d0091..520247b77c1 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dynstr.h" #include "DNA_anim_types.h" diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index e49e3d99c49..560a1458dfd 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -39,7 +39,7 @@ #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_context.h" diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 6dad0b6e90f..f89caa7b2c1 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -51,7 +51,7 @@ #include "DNA_curve_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_ghash.h" @@ -185,13 +185,13 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone eBone->roll= 0.0f; /* roll fixing */ - VecSubf(delta, eBone->tail, eBone->head); + sub_v3_v3v3(delta, eBone->tail, eBone->head); vec_roll_to_mat3(delta, 0.0f, postmat); - Mat3CpyMat4(premat, curBone->arm_mat); + copy_m3_m4(premat, curBone->arm_mat); - Mat3Inv(imat, postmat); - Mat3MulMat3(difmat, imat, premat); + invert_m3_m3(imat, postmat); + mul_m3_m3m3(difmat, imat, premat); eBone->roll = (float)atan2(difmat[2][0], difmat[2][2]); @@ -250,19 +250,19 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) if (ebone) { /* Get the ebone premat */ - VecSubf(delta, ebone->tail, ebone->head); + sub_v3_v3v3(delta, ebone->tail, ebone->head); vec_roll_to_mat3(delta, ebone->roll, premat); /* Get the bone postmat */ - Mat3CpyMat4(postmat, curBone->arm_mat); + copy_m3_m4(postmat, curBone->arm_mat); - Mat3Inv(imat, premat); - Mat3MulMat3(difmat, imat, postmat); + invert_m3_m3(imat, premat); + mul_m3_m3m3(difmat, imat, postmat); #if 0 printf ("Bone %s\n", curBone->name); - printmatrix4("premat", premat); - printmatrix4("postmat", postmat); - printmatrix4("difmat", difmat); + print_m4("premat", premat); + print_m4("postmat", postmat); + print_m4("difmat", difmat); printf ("Roll = %f\n", (-atan2(difmat[2][0], difmat[2][2]) * (180.0/M_PI))); #endif curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]); @@ -287,7 +287,7 @@ void ED_armature_from_edit(Object *obedit) /* remove zero sized bones, this gives instable restposes */ for (eBone=arm->edbo->first; eBone; eBone= neBone) { - float len= VecLenf(eBone->head, eBone->tail); + float len= len_v3v3(eBone->head, eBone->tail); neBone= eBone->next; if (len <= 0.000001f) { /* FLT_EPSILON is too large? */ EditBone *fBone; @@ -350,22 +350,22 @@ void ED_armature_from_edit(Object *obedit) float delta[3]; /* Get the parent's matrix (rotation only) */ - VecSubf(delta, eBone->parent->tail, eBone->parent->head); + sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head); vec_roll_to_mat3(delta, eBone->parent->roll, M_parentRest); /* Get this bone's matrix (rotation only) */ - VecSubf(delta, eBone->tail, eBone->head); + sub_v3_v3v3(delta, eBone->tail, eBone->head); vec_roll_to_mat3(delta, eBone->roll, M_boneRest); /* Invert the parent matrix */ - Mat3Inv(iM_parentRest, M_parentRest); + invert_m3_m3(iM_parentRest, M_parentRest); /* Get the new head and tail */ - VecSubf(newBone->head, eBone->head, eBone->parent->tail); - VecSubf(newBone->tail, eBone->tail, eBone->parent->tail); + sub_v3_v3v3(newBone->head, eBone->head, eBone->parent->tail); + sub_v3_v3v3(newBone->tail, eBone->tail, eBone->parent->tail); - Mat3MulVecfl(iM_parentRest, newBone->head); - Mat3MulVecfl(iM_parentRest, newBone->tail); + mul_m3_v3(iM_parentRest, newBone->head); + mul_m3_v3(iM_parentRest, newBone->tail); } } /* ...otherwise add this bone to the armature's bonebase */ @@ -390,15 +390,15 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) { EditBone *ebone; bArmature *arm= ob->data; - float scale = Mat4ToScalef(mat); /* store the scale of the matrix here to use on envelopes */ + float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */ /* Put the armature into editmode */ ED_armature_to_edit(ob); /* Do the rotations */ for (ebone = arm->edbo->first; ebone; ebone=ebone->next){ - Mat4MulVecfl(mat, ebone->head); - Mat4MulVecfl(mat, ebone->tail); + mul_m4_v3(mat, ebone->head); + mul_m4_v3(mat, ebone->tail); ebone->rad_head *= scale; ebone->rad_tail *= scale; @@ -429,8 +429,8 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) if (centermode == 2) { float *fp= give_cursor(scene, v3d); VECCOPY(cent, fp); - Mat4Invert(ob->imat, ob->obmat); - Mat4MulVecfl(ob->imat, cent); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_v3(ob->imat, cent); } else { INIT_MINMAX(min, max); @@ -447,8 +447,8 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) /* Do the adjustments */ for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { - VecSubf(ebone->head, ebone->head, cent); - VecSubf(ebone->tail, ebone->tail, cent); + sub_v3_v3v3(ebone->head, ebone->head, cent); + sub_v3_v3v3(ebone->tail, ebone->tail, cent); } /* Turn the list into an armature */ @@ -456,9 +456,9 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode) /* Adjust object location for new centerpoint */ if(centermode && obedit==NULL) { - Mat3CpyMat4(omat, ob->obmat); + copy_m3_m4(omat, ob->obmat); - Mat3MulVecfl(omat, cent); + mul_m3_v3(omat, cent); ob->loc[0] += cent[0]; ob->loc[1] += cent[1]; ob->loc[2] += cent[2]; @@ -524,7 +524,7 @@ static void applyarmature_fix_boneparents (Scene *scene, Object *armob) ED_object_apply_obmat(ob); what_does_parent(scene, ob, &workob); - Mat4Invert(ob->parentinv, workob.obmat); + invert_m4_m4(ob->parentinv, workob.obmat); } } } @@ -572,16 +572,16 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) float delta[3], eul[3]; /* obtain new auto y-rotation */ - VecSubf(delta, curbone->tail, curbone->head); + sub_v3_v3v3(delta, curbone->tail, curbone->head); vec_roll_to_mat3(delta, 0.0f, premat); - Mat3Inv(imat, premat); + invert_m3_m3(imat, premat); /* get pchan 'visual' matrix */ - Mat3CpyMat4(pmat, pchan->pose_mat); + copy_m3_m4(pmat, pchan->pose_mat); /* remove auto from visual and get euler rotation */ - Mat3MulMat3(tmat, imat, pmat); - Mat3ToEul(tmat, eul); + mul_m3_m3m3(tmat, imat, pmat); + mat3_to_eul( eul,tmat); /* just use this euler-y as new roll value */ curbone->roll= eul[1]; @@ -769,8 +769,8 @@ int join_armature_exec(bContext *C, wmOperator *op) //BASACT->flag &= ~OB_MODE_POSE; /* Find the difference matrix */ - Mat4Invert(oimat, ob->obmat); - Mat4MulMat4(mat, base->object->obmat, oimat); + invert_m4_m4(oimat, ob->obmat); + mul_m4_m4m4(mat, base->object->obmat, oimat); /* Copy bones and posechannels from the object to the edit armature */ for (pchan=opose->chanbase.first; pchan; pchan=pchann) { @@ -790,23 +790,23 @@ int join_armature_exec(bContext *C, wmOperator *op) float delta[3]; /* Get the premat */ - VecSubf(delta, curbone->tail, curbone->head); + sub_v3_v3v3(delta, curbone->tail, curbone->head); vec_roll_to_mat3(delta, curbone->roll, temp); - Mat4One(premat); /* Mat4MulMat34 only sets 3x3 part */ - Mat4MulMat34(premat, temp, mat); + unit_m4(premat); /* Mat4MulMat34 only sets 3x3 part */ + mul_m4_m3m4(premat, temp, mat); - Mat4MulVecfl(mat, curbone->head); - Mat4MulVecfl(mat, curbone->tail); + mul_m4_v3(mat, curbone->head); + mul_m4_v3(mat, curbone->tail); /* Get the postmat */ - VecSubf(delta, curbone->tail, curbone->head); + sub_v3_v3v3(delta, curbone->tail, curbone->head); vec_roll_to_mat3(delta, curbone->roll, temp); - Mat4CpyMat3(postmat, temp); + copy_m4_m3(postmat, temp); /* Find the roll */ - Mat4Invert(imat, premat); - Mat4MulMat4(difmat, postmat, imat); + invert_m4_m4(imat, premat); + mul_m4_m4m4(difmat, postmat, imat); curbone->roll -= (float)atan2(difmat[2][0], difmat[2][2]); } @@ -1997,16 +1997,16 @@ float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3]) float mat[3][3], nor[3], up_axis[3], vec[3]; float roll; - VecSubf(nor, bone->tail, bone->head); + sub_v3_v3v3(nor, bone->tail, bone->head); vec_roll_to_mat3(nor, 0, mat); VECCOPY(up_axis, mat[2]); - roll = NormalizedVecAngle2(new_up_axis, up_axis); + roll = angle_normalized_v3v3(new_up_axis, up_axis); - Crossf(vec, up_axis, new_up_axis); + cross_v3_v3v3(vec, up_axis, new_up_axis); - if (Inpf(vec, nor) < 0) + if (dot_v3v3(vec, nor) < 0) { roll = -roll; } @@ -2023,21 +2023,21 @@ void auto_align_ebone_zaxisup(Scene *scene, View3D *v3d, EditBone *ebone) float targetmat[3][3], imat[3][3], diffmat[3][3]; /* Find the current bone matrix */ - VecSubf(delta, ebone->tail, ebone->head); + sub_v3_v3v3(delta, ebone->tail, ebone->head); vec_roll_to_mat3(delta, 0.0f, curmat); /* Make new matrix based on y axis & z-up */ VECCOPY(yaxis, curmat[1]); - Mat3One(targetmat); + unit_m3(targetmat); VECCOPY(targetmat[0], xaxis); VECCOPY(targetmat[1], yaxis); VECCOPY(targetmat[2], zaxis); - Mat3Ortho(targetmat); + normalize_m3(targetmat); /* Find the difference between the two matrices */ - Mat3Inv(imat, targetmat); - Mat3MulMat3(diffmat, imat, curmat); + invert_m3_m3(imat, targetmat); + mul_m3_m3m3(diffmat, imat, curmat); // old-method... let's see if using mat3_to_vec_roll is more accurate //ebone->roll = atan2(diffmat[2][0], diffmat[2][2]); @@ -2055,28 +2055,28 @@ void auto_align_ebone_tocursor(Scene *scene, View3D *v3d, EditBone *ebone) float vec[3]; /* find the current bone matrix as a 4x4 matrix (in Armature Space) */ - VecSubf(delta, ebone->tail, ebone->head); + sub_v3_v3v3(delta, ebone->tail, ebone->head); vec_roll_to_mat3(delta, ebone->roll, curmat); - Mat4CpyMat3(mat, curmat); + copy_m4_m3(mat, curmat); VECCOPY(mat[3], ebone->head); /* multiply bone-matrix by object matrix (so that bone-matrix is in WorldSpace) */ - Mat4MulMat4(tmat, mat, obedit->obmat); - Mat4Invert(imat, tmat); + mul_m4_m4m4(tmat, mat, obedit->obmat); + invert_m4_m4(imat, tmat); /* find position of cursor relative to bone */ - VecMat4MulVecfl(vec, imat, cursor); + mul_v3_m4v3(vec, imat, cursor); /* check that cursor is in usable position */ if ((IS_EQ(vec[0], 0)==0) && (IS_EQ(vec[2], 0)==0)) { /* Compute a rotation matrix around y */ rot[1] = (float)atan2(vec[0], vec[2]); rot[0] = rot[2] = 0.0f; - EulToMat4(rot, rmat); + eul_to_mat4( rmat,rot); /* Multiply the bone matrix by rotation matrix. This should be new bone-matrix */ - Mat4MulMat4(tmat, rmat, mat); - Mat3CpyMat4(curmat, tmat); + mul_m4_m4m4(tmat, rmat, mat); + copy_m3_m4(curmat, tmat); /* Now convert from new bone-matrix, back to a roll value (in radians) */ mat3_to_vec_roll(curmat, delta, &ebone->roll); @@ -2278,16 +2278,16 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) VECCOPY(curs, give_cursor(scene, v3d)); /* Get inverse point for head and orientation for tail */ - Mat4Invert(obedit->imat, obedit->obmat); - Mat4MulVecfl(obedit->imat, curs); + invert_m4_m4(obedit->imat, obedit->obmat); + mul_m4_v3(obedit->imat, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - Mat3CpyMat4(obmat, rv3d->viewmat); - else Mat3One(obmat); + copy_m3_m4(obmat, rv3d->viewmat); + else unit_m3(obmat); - Mat3CpyMat4(viewmat, obedit->obmat); - Mat3MulMat3(totmat, obmat, viewmat); - Mat3Inv(imat, totmat); + copy_m3_m4(viewmat, obedit->obmat); + mul_m3_m3m3(totmat, obmat, viewmat); + invert_m3_m3(imat, totmat); ED_armature_deselectall(obedit, 0, 0); @@ -2297,9 +2297,9 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) VECCOPY(bone->head, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - VecAddf(bone->tail, bone->head, imat[1]); // bone with unit length 1 + add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else - VecAddf(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z + add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z } @@ -2375,16 +2375,16 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *op) curs= give_cursor(scene, v3d); VECCOPY(newbone->tail, curs); - VecSubf(newbone->tail, newbone->tail, obedit->obmat[3]); + sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]); if (a==1) newbone->tail[0]= -newbone->tail[0]; - Mat3CpyMat4(mat, obedit->obmat); - Mat3Inv(imat, mat); - Mat3MulVecfl(imat, newbone->tail); + copy_m3_m4(mat, obedit->obmat); + invert_m3_m3(imat, mat); + mul_m3_v3(imat, newbone->tail); - newbone->length= VecLenf(newbone->head, newbone->tail); + newbone->length= len_v3v3(newbone->head, newbone->tail); newbone->rad_tail= newbone->length*0.05f; newbone->dist= newbone->length*0.25f; @@ -2429,7 +2429,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e if(mval[0]!=IS_CLIPPED) { window_to_3d_delta(ar, dvec, mval[0]-mx, mval[1]-my); - VecSubf(fp, fp, dvec); + sub_v3_v3v3(fp, fp, dvec); } else { @@ -2885,7 +2885,7 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) } for (ebp= points->first; ebp; ebp= ebp->next) { - if (VecEqual(ebp->vec, vec)) { + if (equals_v3v3(ebp->vec, vec)) { if (eb_tail) { if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) { /* so this bone's tail owner is this bone */ @@ -2969,8 +2969,8 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) fp= give_cursor(scene, v3d); VECCOPY (curs, fp); - Mat4Invert(obedit->imat, obedit->obmat); - Mat4MulVecfl(obedit->imat, curs); + invert_m4_m4(obedit->imat, obedit->obmat); + mul_m4_v3(obedit->imat, curs); /* Create a bone */ newbone= add_points_bone(obedit, ebp->vec, curs); @@ -3005,14 +3005,14 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) /* get cursor location */ VECCOPY(curs, fp); - Mat4Invert(obedit->imat, obedit->obmat); - Mat4MulVecfl(obedit->imat, curs); + invert_m4_m4(obedit->imat, obedit->obmat); + mul_m4_v3(obedit->imat, curs); /* get distances */ - VecSubf(vecA, ebp->vec, curs); - VecSubf(vecB, ebp2->vec, curs); - distA= VecLength(vecA); - distB= VecLength(vecB); + sub_v3_v3v3(vecA, ebp->vec, curs); + sub_v3_v3v3(vecB, ebp2->vec, curs); + distA= len_v3(vecA); + distB= len_v3(vecB); /* compare distances - closer one therefore acts as direction for bone to go */ headtail= (distA < distB) ? 2 : 1; @@ -3494,16 +3494,16 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) VECCOPY(curs, give_cursor(CTX_data_scene(C),CTX_wm_view3d(C))); /* Get inverse point for head and orientation for tail */ - Mat4Invert(obedit->imat, obedit->obmat); - Mat4MulVecfl(obedit->imat, curs); + invert_m4_m4(obedit->imat, obedit->obmat); + mul_m4_v3(obedit->imat, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - Mat3CpyMat4(obmat, rv3d->viewmat); - else Mat3One(obmat); + copy_m3_m4(obmat, rv3d->viewmat); + else unit_m3(obmat); - Mat3CpyMat4(viewmat, obedit->obmat); - Mat3MulMat3(totmat, obmat, viewmat); - Mat3Inv(imat, totmat); + copy_m3_m4(viewmat, obedit->obmat); + mul_m3_m3m3(totmat, obmat, viewmat); + invert_m3_m3(imat, totmat); ED_armature_deselectall(obedit, 0, 0); @@ -3513,9 +3513,9 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) VECCOPY(bone->head, curs); if(rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - VecAddf(bone->tail, bone->head, imat[1]); // bone with unit length 1 + add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else - VecAddf(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z + add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, obedit); @@ -3748,7 +3748,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *op) * - connected flag is only set if points are coincidental */ ebo->parent= child; - if ((child) && VecEqual(ebo->head, child->tail)) + if ((child) && equals_v3v3(ebo->head, child->tail)) ebo->flag |= BONE_CONNECTED; else ebo->flag &= ~BONE_CONNECTED; @@ -3834,12 +3834,12 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo if (mode == ARM_PAR_CONNECT) { /* Connected: Child bones will be moved to the parent tip */ selbone->flag |= BONE_CONNECTED; - VecSubf(offset, actbone->tail, selbone->head); + sub_v3_v3v3(offset, actbone->tail, selbone->head); VECCOPY(selbone->head, actbone->tail); selbone->rad_head= actbone->rad_tail; - VecAddf(selbone->tail, selbone->tail, offset); + add_v3_v3v3(selbone->tail, selbone->tail, offset); /* offset for all its children */ for (ebone = edbo->first; ebone; ebone=ebone->next) { @@ -3847,8 +3847,8 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo for (par= ebone->parent; par; par= par->parent) { if (par==selbone) { - VecAddf(ebone->head, ebone->head, offset); - VecAddf(ebone->tail, ebone->tail, offset); + add_v3_v3v3(ebone->head, ebone->head, offset); + add_v3_v3v3(ebone->tail, ebone->tail, offset); break; } } @@ -4199,13 +4199,13 @@ static void fix_connected_bone(EditBone *ebone) { float diff[3]; - if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) || VecEqual(ebone->parent->tail, ebone->head)) + if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) || equals_v3v3(ebone->parent->tail, ebone->head)) return; /* if the parent has moved we translate child's head and tail accordingly*/ - VecSubf(diff, ebone->parent->tail, ebone->head); - VecAddf(ebone->head, ebone->head, diff); - VecAddf(ebone->tail, ebone->tail, diff); + sub_v3_v3v3(diff, ebone->parent->tail, ebone->head); + add_v3_v3v3(ebone->head, ebone->head, diff); + add_v3_v3v3(ebone->tail, ebone->tail, diff); return; } @@ -4227,14 +4227,14 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb { float selboneaxis[3], actboneaxis[3], length; - VecSubf(actboneaxis, actbone->tail, actbone->head); - Normalize(actboneaxis); + sub_v3_v3v3(actboneaxis, actbone->tail, actbone->head); + normalize_v3(actboneaxis); - VecSubf(selboneaxis, selbone->tail, selbone->head); - length = VecLength(selboneaxis); + sub_v3_v3v3(selboneaxis, selbone->tail, selbone->head); + length = len_v3(selboneaxis); - VecMulf(actboneaxis, length); - VecAddf(selbone->tail, selbone->head, actboneaxis); + mul_v3_fl(actboneaxis, length); + add_v3_v3v3(selbone->tail, selbone->head, actboneaxis); selbone->roll = actbone->roll; /* if the bone being aligned has connected descendants they must be moved @@ -4720,10 +4720,10 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m /* compute root and tip */ if (bbone) { VECCOPY(root[j], bbone[segments].mat[3]); - Mat4MulVecfl(bone->arm_mat, root[j]); + mul_m4_v3(bone->arm_mat, root[j]); if ((segments+1) < bone->segments) { VECCOPY(tip[j], bbone[segments+1].mat[3]) - Mat4MulVecfl(bone->arm_mat, tip[j]); + mul_m4_v3(bone->arm_mat, tip[j]); } else VECCOPY(tip[j], bone->arm_tail) @@ -4733,8 +4733,8 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m VECCOPY(tip[j], bone->arm_tail); } - Mat4MulVecfl(par->obmat, root[j]); - Mat4MulVecfl(par->obmat, tip[j]); + mul_m4_v3(par->obmat, root[j]); + mul_m4_v3(par->obmat, tip[j]); /* set selected */ if (wpmode) { @@ -4788,7 +4788,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m for (i=0; i < mesh->totvert; i++) { if (!vertsfilled) VECCOPY(verts[i], mesh->mvert[i].co) - Mat4MulVecfl(ob->obmat, verts[i]); + mul_m4_v3(ob->obmat, verts[i]); } /* compute the weights based on gathered vertices and bones */ @@ -4798,7 +4798,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m } else { envelope_bone_weighting(ob, mesh, verts, numbones, bonelist, dgrouplist, - dgroupflip, root, tip, selected, Mat4ToScalef(par->obmat)); + dgroupflip, root, tip, selected, mat4_to_scale(par->obmat)); } /* free the memory allocated */ @@ -4969,10 +4969,10 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op) if (pchan->rotmode == ROT_MODE_QUAT) { QUATCOPY(quat1, pchan->quat); - QuatToEul(pchan->quat, oldeul); + quat_to_eul( oldeul,pchan->quat); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { - AxisAngleToEulO(pchan->rotAxis, pchan->rotAngle, oldeul, EULER_ORDER_DEFAULT); + axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,pchan->rotAxis, pchan->rotAngle); } else { VECCOPY(oldeul, pchan->eul); @@ -4988,14 +4988,14 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op) eul[2]= oldeul[2]; if (pchan->rotmode == ROT_MODE_QUAT) { - EulToQuat(eul, pchan->quat); + eul_to_quat( pchan->quat,eul); /* quaternions flip w sign to accumulate rotations correctly */ if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) { - QuatMulf(pchan->quat, -1.0f); + mul_qt_fl(pchan->quat, -1.0f); } } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { - EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, &pchan->rotAngle); + eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,eul, EULER_ORDER_DEFAULT); } else { VECCOPY(pchan->eul, eul); @@ -5618,13 +5618,13 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode current = iter->p; - VecSubf(vec1, previous, parent->head); - VecSubf(vec2, current, previous); + sub_v3_v3v3(vec1, previous, parent->head); + sub_v3_v3v3(vec2, current, previous); - len1 = Normalize(vec1); - len2 = Normalize(vec2); + len1 = normalize_v3(vec1); + len2 = normalize_v3(vec2); - if (len1 > 0.0f && len2 > 0.0f && Inpf(vec1, vec2) < angleLimit) + if (len1 > 0.0f && len2 > 0.0f && dot_v3v3(vec1, vec2) < angleLimit) { VECCOPY(parent->tail, previous); @@ -5685,18 +5685,18 @@ float arcLengthRatio(ReebArc *arc) float embedLength = 0.0f; int i; - arcLength = VecLenf(arc->head->p, arc->tail->p); + arcLength = len_v3v3(arc->head->p, arc->tail->p); if (arc->bcount > 0) { /* Add the embedding */ for ( i = 1; i < arc->bcount; i++) { - embedLength += VecLenf(arc->buckets[i - 1].p, arc->buckets[i].p); + embedLength += len_v3v3(arc->buckets[i - 1].p, arc->buckets[i].p); } /* Add head and tail -> embedding vectors */ - embedLength += VecLenf(arc->head->p, arc->buckets[0].p); - embedLength += VecLenf(arc->tail->p, arc->buckets[arc->bcount - 1].p); + embedLength += len_v3v3(arc->head->p, arc->buckets[0].p); + embedLength += len_v3v3(arc->tail->p, arc->buckets[arc->bcount - 1].p); } else { @@ -5756,8 +5756,8 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) /* Copy orientation from source */ VECCOPY(dst->loc, src->obmat[3]); - Mat4ToEul(src->obmat, dst->rot); - Mat4ToSize(src->obmat, dst->size); + mat4_to_eul( dst->rot,src->obmat); + mat4_to_size( dst->size,src->obmat); where_is_object(scene, obedit); diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index d327ed34839..124528811c7 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -39,7 +39,7 @@ #include "DNA_armature_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_graph.h" #include "BKE_utildefines.h" @@ -52,18 +52,18 @@ void setBoneRollFromNormal(EditBone *bone, float *no, float invmat[][4], float tmat[][3]) { - if (no != NULL && !VecIsNull(no)) + if (no != NULL && !is_zero_v3(no)) { float tangent[3], vec[3], normal[3]; VECCOPY(normal, no); - Mat3MulVecfl(tmat, normal); + mul_m3_v3(tmat, normal); - VecSubf(tangent, bone->tail, bone->head); - Projf(vec, tangent, normal); - VecSubf(normal, normal, vec); + sub_v3_v3v3(tangent, bone->tail, bone->head); + project_v3_v3v3(vec, tangent, normal); + sub_v3_v3v3(normal, normal, vec); - Normalize(normal); + normalize_v3(normal); bone->roll = ED_rollBoneToVector(bone, normal); } @@ -86,11 +86,11 @@ float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], fl float v[3]; IT_peek(iter, i); - VecSubf(v, iter->p, v0); - avg_t += Inpf(v, n); + sub_v3_v3v3(v, iter->p, v0); + avg_t += dot_v3v3(v, n); } - avg_t /= Inpf(n, n); + avg_t /= dot_v3v3(n, n); avg_t += 1.0f; /* adding start (0) and end (1) values */ avg_t /= len; @@ -101,14 +101,14 @@ float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], fl float dt; IT_peek(iter, i); - VecSubf(v, iter->p, v0); - Projf(d, v, n); - VecSubf(v, v, d); + sub_v3_v3v3(v, iter->p, v0); + project_v3_v3v3(d, v, n); + sub_v3_v3v3(v, v, d); - dt = VecLength(d) - avg_t; + dt = len_v3(d) - avg_t; s_t += dt * dt; - s_xyz += Inpf(v, v); + s_xyz += dot_v3v3(v, v); } /* adding start(0) and end(1) values to s_t */ @@ -143,7 +143,7 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta IT_peek(iter, i); v2 = iter->p; - stroke_length += VecLenf(v1, v2); + stroke_length += len_v3v3(v1, v2); v1 = v2; } @@ -165,7 +165,7 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta IT_peek(iter, i); v2 = iter->p; - current_length += VecLenf(v1, v2); + current_length += len_v3v3(v1, v2); if (current_length >= length_threshold) { @@ -194,7 +194,7 @@ int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, in { /* Calculate normal */ IT_peek(iter, i); - VecSubf(n, iter->p, head); + sub_v3_v3v3(n, iter->p, head); if (calcArcCorrelation(iter, start, i, start_p, n) < correlation_threshold) { @@ -226,7 +226,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st vec1 = iter->p; /* If lengthLimit hits the current segment */ - if (VecLenf(vec1, head) > lengthLimit) + if (len_v3v3(vec1, head) > lengthLimit) { if (same == 0) { @@ -234,13 +234,13 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st float a, b, c, f; /* Solve quadratic distance equation */ - VecSubf(dv, vec1, vec0); - a = Inpf(dv, dv); + sub_v3_v3v3(dv, vec1, vec0); + a = dot_v3v3(dv, dv); - VecSubf(off, vec0, head); - b = 2 * Inpf(dv, off); + sub_v3_v3v3(off, vec0, head); + b = 2 * dot_v3v3(dv, off); - c = Inpf(off, off) - (lengthLimit * lengthLimit); + c = dot_v3v3(off, off) - (lengthLimit * lengthLimit); f = (-b + (float)sqrt(b * b - 4 * a * c)) / (2 * a); @@ -249,8 +249,8 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st if (isnan(f) == 0 && f < 1.0f) { VECCOPY(p, dv); - VecMulf(p, f); - VecAddf(p, p, vec0); + mul_v3_fl(p, f); + add_v3_v3v3(p, p, vec0); } else { @@ -261,12 +261,12 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st { float dv[3]; - VecSubf(dv, vec1, vec0); - Normalize(dv); + sub_v3_v3v3(dv, vec1, vec0); + normalize_v3(dv); VECCOPY(p, dv); - VecMulf(p, lengthLimit); - VecAddf(p, p, head); + mul_v3_fl(p, lengthLimit); + add_v3_v3v3(p, p, head); } return i - 1; /* restart at lower bound */ @@ -321,8 +321,8 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase * } /* going to next bone, fix parent */ - Mat4MulVecfl(invmat, parent->tail); - Mat4MulVecfl(invmat, parent->head); + mul_m4_v3(invmat, parent->tail); + mul_m4_v3(invmat, parent->head); setBoneRollFromNormal(parent, normal, invmat, tmat); parent = child; // new child is next parent @@ -342,8 +342,8 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase * } /* fix last bone */ - Mat4MulVecfl(invmat, parent->tail); - Mat4MulVecfl(invmat, parent->head); + mul_m4_v3(invmat, parent->tail); + mul_m4_v3(invmat, parent->head); setBoneRollFromNormal(parent, iter->no, invmat, tmat); lastBone = parent; diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 824e7be94d9..946b7398773 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -48,7 +48,7 @@ #include "DNA_view3d_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_ghash.h" #include "BLI_graph.h" @@ -162,7 +162,7 @@ void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3]) { float mat[3][3], nor[3]; - VecSubf(nor, bone->tail, bone->head); + sub_v3_v3v3(nor, bone->tail, bone->head); vec_roll_to_mat3(nor, roll, mat); VECCOPY(up_axis, mat[2]); @@ -173,35 +173,35 @@ float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float nor[3], new_up_axis[3], x_axis[3], z_axis[3]; VECCOPY(new_up_axis, old_up_axis); - QuatMulVecf(qrot, new_up_axis); + mul_qt_v3(qrot, new_up_axis); - VecSubf(nor, bone->tail, bone->head); + sub_v3_v3v3(nor, bone->tail, bone->head); - Crossf(x_axis, nor, aligned_axis); - Crossf(z_axis, x_axis, nor); + cross_v3_v3v3(x_axis, nor, aligned_axis); + cross_v3_v3v3(z_axis, x_axis, nor); - Normalize(new_up_axis); - Normalize(x_axis); - Normalize(z_axis); + normalize_v3(new_up_axis); + normalize_v3(x_axis); + normalize_v3(z_axis); - if (Inpf(new_up_axis, x_axis) < 0) + if (dot_v3v3(new_up_axis, x_axis) < 0) { - VecMulf(x_axis, -1); + mul_v3_fl(x_axis, -1); } - if (Inpf(new_up_axis, z_axis) < 0) + if (dot_v3v3(new_up_axis, z_axis) < 0) { - VecMulf(z_axis, -1); + mul_v3_fl(z_axis, -1); } - if (NormalizedVecAngle2(x_axis, new_up_axis) < NormalizedVecAngle2(z_axis, new_up_axis)) + if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) { - RotationBetweenVectorsToQuat(qroll, new_up_axis, x_axis); /* set roll rotation quat */ + rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */ return ED_rollBoneToVector(bone, x_axis); } else { - RotationBetweenVectorsToQuat(qroll, new_up_axis, z_axis); /* set roll rotation quat */ + rotation_between_vecs_to_quat(qroll, new_up_axis, z_axis); /* set roll rotation quat */ return ED_rollBoneToVector(bone, z_axis); } } @@ -220,11 +220,11 @@ float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float if (previous->bone) { - VecSubf(vec_first, previous->bone->tail, previous->bone->head); + sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head); } else if (previous->prev->bone) { - VecSubf(vec_first, edge->bone->head, previous->prev->bone->tail); + sub_v3_v3v3(vec_first, edge->bone->head, previous->prev->bone->tail); } else { @@ -232,25 +232,25 @@ float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis); } - VecSubf(vec_second, edge->bone->tail, edge->bone->head); + sub_v3_v3v3(vec_second, edge->bone->tail, edge->bone->head); - Normalize(vec_first); - Normalize(vec_second); + normalize_v3(vec_first); + normalize_v3(vec_second); - Crossf(normal, vec_first, vec_second); - Normalize(normal); + cross_v3_v3v3(normal, vec_first, vec_second); + normalize_v3(normal); - AxisAngleToQuat(qroll, vec_second, edge->up_angle); + axis_angle_to_quat(qroll, vec_second, edge->up_angle); - QuatMulVecf(qroll, normal); + mul_qt_v3(qroll, normal); VECCOPY(new_up_axis, edge->up_axis); - QuatMulVecf(qrot, new_up_axis); + mul_qt_v3(qrot, new_up_axis); - Normalize(new_up_axis); + normalize_v3(new_up_axis); /* real qroll between normal and up_axis */ - RotationBetweenVectorsToQuat(qroll, new_up_axis, normal); + rotation_between_vecs_to_quat(qroll, new_up_axis, normal); return ED_rollBoneToVector(edge->bone, normal); } @@ -261,9 +261,9 @@ float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]) float new_up_axis[3]; VECCOPY(new_up_axis, old_up_axis); - QuatMulVecf(qrot, new_up_axis); + mul_qt_v3(qrot, new_up_axis); - Normalize(new_up_axis); + normalize_v3(new_up_axis); return ED_rollBoneToVector(bone, new_up_axis); } @@ -431,7 +431,7 @@ static void RIG_appendEdgeToArc(RigArc *arc, RigEdge *edge) RIG_calculateEdgeAngles(last_edge, edge); } - edge->length = VecLenf(edge->head, edge->tail); + edge->length = len_v3v3(edge->head, edge->tail); arc->length += edge->length; @@ -675,22 +675,22 @@ static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second) { float vec_first[3], vec_second[3]; - VecSubf(vec_first, edge_first->tail, edge_first->head); - VecSubf(vec_second, edge_second->tail, edge_second->head); + sub_v3_v3v3(vec_first, edge_first->tail, edge_first->head); + sub_v3_v3v3(vec_second, edge_second->tail, edge_second->head); - Normalize(vec_first); - Normalize(vec_second); + normalize_v3(vec_first); + normalize_v3(vec_second); - edge_first->angle = NormalizedVecAngle2(vec_first, vec_second); + edge_first->angle = angle_normalized_v3v3(vec_first, vec_second); if (edge_second->bone != NULL) { float normal[3]; - Crossf(normal, vec_first, vec_second); - Normalize(normal); + cross_v3_v3v3(normal, vec_first, vec_second); + normalize_v3(normal); - edge_second->up_angle = NormalizedVecAngle2(normal, edge_second->up_axis); + edge_second->up_angle = angle_normalized_v3v3(normal, edge_second->up_axis); } } @@ -715,27 +715,27 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link) float offset[3]; int flag = 0; - VecSubf(offset, ctrl->bone->head, link->head); + sub_v3_v3v3(offset, ctrl->bone->head, link->head); /* if root matches, check for direction too */ - if (Inpf(offset, offset) < 0.0001) + if (dot_v3v3(offset, offset) < 0.0001) { float vbone[3], vparent[3]; flag |= RIG_CTRL_FIT_ROOT; - VecSubf(vbone, ctrl->bone->tail, ctrl->bone->head); - VecSubf(vparent, link->tail, link->head); + sub_v3_v3v3(vbone, ctrl->bone->tail, ctrl->bone->head); + sub_v3_v3v3(vparent, link->tail, link->head); /* test for opposite direction */ - if (Inpf(vbone, vparent) > 0) + if (dot_v3v3(vbone, vparent) > 0) { float nor[3]; float len; - Crossf(nor, vbone, vparent); + cross_v3_v3v3(nor, vbone, vparent); - len = Inpf(nor, nor); + len = dot_v3v3(nor, nor); if (len < 0.0001) { flag |= RIG_CTRL_FIT_BONE; @@ -869,8 +869,8 @@ static void RIG_reconnectControlBones(RigGraph *rg) { int fit = 0; - fit = VecLenf(ctrl->bone->head, edge->bone->head) < 0.0001; - fit = fit || VecLenf(ctrl->bone->tail, edge->bone->tail) < 0.0001; + fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001; + fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001; if (fit) { @@ -1026,13 +1026,13 @@ static void RIG_reconnectControlBones(RigGraph *rg) /* don't link with parent */ if (bone->parent != ctrl->bone) { - if (VecLenf(ctrl->bone->tail, bone->head) < 0.01) + if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01) { ctrl->tail_mode = TL_HEAD; ctrl->link_tail = bone; break; } - else if (VecLenf(ctrl->bone->tail, bone->tail) < 0.01) + else if (len_v3v3(ctrl->bone->tail, bone->tail) < 0.01) { ctrl->tail_mode = TL_TAIL; ctrl->link_tail = bone; @@ -1132,7 +1132,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) if (first_edge->bone == NULL) { - if (first_edge->bone == NULL && VecLenf(first_edge->tail, arc->head->p) <= 0.001) + if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001) { BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); @@ -1262,7 +1262,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) if (last_edge->bone == NULL) { - if (VecLenf(last_edge->head, arc->tail->p) <= 0.001) + if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001) { BLI_remlink(&arc->edges, last_edge); MEM_freeN(last_edge); @@ -1438,7 +1438,7 @@ void RIG_printNode(RigNode *node, char name[]) else if (node->symmetry_flag & SYM_RADIAL) printf("Symmetry RADIAL\n"); - printvecf("symmetry axis", node->symmetry_axis); + print_v3("symmetry axis", node->symmetry_axis); } } @@ -1464,7 +1464,7 @@ void RIG_printCtrl(RigControl *ctrl, char *indent) printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!"); sprintf(text, "%soffset", indent); - printvecf(text, ctrl->offset); + print_v3(text, ctrl->offset); printf("%sFlag: %i\n", indent, ctrl->flag); } @@ -1761,15 +1761,15 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize) tail_vec = ctrl->link_tail->head; } - VecSubf(v1, ctrl->bone->tail, ctrl->bone->head); - VecSubf(v2, tail_vec, ctrl->bone->head); + sub_v3_v3v3(v1, ctrl->bone->tail, ctrl->bone->head); + sub_v3_v3v3(v2, tail_vec, ctrl->bone->head); VECCOPY(ctrl->bone->tail, tail_vec); - RotationBetweenVectorsToQuat(qtail, v1, v2); - QuatMul(ctrl->qrot, qtail, ctrl->qrot); + rotation_between_vecs_to_quat(qtail, v1, v2); + mul_qt_qtqt(ctrl->qrot, qtail, ctrl->qrot); - resize = VecLength(v2) / VecLenf(ctrl->head, ctrl->tail); + resize = len_v3(v2) / len_v3v3(ctrl->head, ctrl->tail); } ctrl->bone->roll = rollBoneByQuat(ctrl->bone, ctrl->up_axis, ctrl->qrot); @@ -1801,10 +1801,10 @@ static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], f float parent_offset[3], tail_offset[3]; VECCOPY(parent_offset, ctrl->offset); - VecMulf(parent_offset, resize); - QuatMulVecf(qrot, parent_offset); + mul_v3_fl(parent_offset, resize); + mul_qt_v3(qrot, parent_offset); - VecAddf(ctrl->bone->head, head, parent_offset); + add_v3_v3v3(ctrl->bone->head, head, parent_offset); ctrl->flag |= RIG_CTRL_HEAD_DONE; @@ -1812,11 +1812,11 @@ static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], f if (ctrl->tail_mode == TL_NONE) { - VecSubf(tail_offset, ctrl->tail, ctrl->head); - VecMulf(tail_offset, resize); - QuatMulVecf(qrot, tail_offset); + sub_v3_v3v3(tail_offset, ctrl->tail, ctrl->head); + mul_v3_fl(tail_offset, resize); + mul_qt_v3(qrot, tail_offset); - VecAddf(ctrl->bone->tail, ctrl->bone->head, tail_offset); + add_v3_v3v3(ctrl->bone->tail, ctrl->bone->head, tail_offset); ctrl->flag |= RIG_CTRL_TAIL_DONE; } @@ -1835,20 +1835,20 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec bone = edge->bone; - VecSubf(v1, edge->tail, edge->head); - VecSubf(v2, vec1, vec0); + sub_v3_v3v3(v1, edge->tail, edge->head); + sub_v3_v3v3(v2, vec1, vec0); - l1 = Normalize(v1); - l2 = Normalize(v2); + l1 = normalize_v3(v1); + l2 = normalize_v3(v2); resize = l2 / l1; - RotationBetweenVectorsToQuat(qrot, v1, v2); + rotation_between_vecs_to_quat(qrot, v1, v2); VECCOPY(bone->head, vec0); VECCOPY(bone->tail, vec1); - if (!VecIsNull(up_axis)) + if (!is_zero_v3(up_axis)) { float qroll[4]; @@ -1862,10 +1862,10 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec } else { - QuatOne(qroll); + unit_qt(qroll); } - QuatMul(qrot, qroll, qrot); + mul_qt_qtqt(qrot, qroll, qrot); } else { @@ -1979,9 +1979,9 @@ static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0, if (distance_weight > 0) { - VecSubf(v1, vec0, vec1); + sub_v3_v3v3(v1, vec0, vec1); - v1_inpf = Inpf(v1, v1); + v1_inpf = dot_v3v3(v1, v1); if (v1_inpf > 0) { @@ -1992,11 +1992,11 @@ static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0, bucket = IT_peek(iter, j); - VecSubf(v2, bucket->p, vec1); + sub_v3_v3v3(v2, bucket->p, vec1); - Crossf(c, v1, v2); + cross_v3_v3v3(c, v1, v2); - dist = Inpf(c, c) / v1_inpf; + dist = dot_v3v3(c, c) / v1_inpf; max_dist = dist > max_dist ? dist : max_dist; } @@ -2020,9 +2020,9 @@ static float costAngle(float original_angle, float vec_first[3], float vec_secon { float current_angle; - if (!VecIsNull(vec_first) && !VecIsNull(vec_second)) + if (!is_zero_v3(vec_first) && !is_zero_v3(vec_second)) { - current_angle = saacos(Inpf(vec_first, vec_second)); + current_angle = saacos(dot_v3v3(vec_first, vec_second)); return angle_weight * fabs(current_angle - original_angle); } @@ -2056,8 +2056,8 @@ static float calcCostLengthDistance(BArcIterator *iter, float **vec_cache, RigEd float vec[3]; float length; - VecSubf(vec, vec2, vec1); - length = Normalize(vec); + sub_v3_v3v3(vec, vec2, vec1); + length = normalize_v3(vec); return costLength(edge->length, length) + costDistance(iter, vec1, vec2, i1, i2); } @@ -2069,15 +2069,15 @@ static float calcCostAngleLengthDistance(BArcIterator *iter, float **vec_cache, float length2; float new_cost = 0; - VecSubf(vec_second, vec2, vec1); - length2 = Normalize(vec_second); + sub_v3_v3v3(vec_second, vec2, vec1); + length2 = normalize_v3(vec_second); /* Angle cost */ if (edge->prev) { - VecSubf(vec_first, vec1, vec0); - Normalize(vec_first); + sub_v3_v3v3(vec_first, vec1, vec0); + normalize_v3(vec_first); new_cost += costAngle(edge->prev->angle, vec_first, vec_second, angle_weight); } @@ -2352,13 +2352,13 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri { vec1 = bucket->p; - embedding_length += VecLenf(vec0, vec1); + embedding_length += len_v3v3(vec0, vec1); vec0 = vec1; bucket = IT_next(iter); } - embedding_length += VecLenf(node_end->p, vec1); + embedding_length += len_v3v3(node_end->p, vec1); /* fit bones */ initArcIterator(iter, earc, node_start); @@ -2377,7 +2377,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri while (bucket && new_bone_length > length) { - length += VecLenf(previous_vec, vec1); + length += len_v3v3(previous_vec, vec1); bucket = IT_next(iter); previous_vec = vec1; vec1 = bucket->p; diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index b3dd8f35137..7bb2fa9009d 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -39,7 +39,7 @@ #include "RNA_access.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_graph.h" #include "BLI_ghash.h" @@ -416,10 +416,10 @@ ReebNode *sk_pointToNode(SK_Point *pt, float imat[][4], float tmat[][3]) node = MEM_callocN(sizeof(ReebNode), "reeb node"); VECCOPY(node->p, pt->p); - Mat4MulVecfl(imat, node->p); + mul_m4_v3(imat, node->p); VECCOPY(node->no, pt->no); - Mat3MulVecfl(tmat, node->no); + mul_m3_v3(tmat, node->no); return node; } @@ -439,10 +439,10 @@ ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[][4], float tmat[][3]) for (i = 0; i < arc->bcount; i++) { VECCOPY(arc->buckets[i].p, stk->points[i + 1].p); - Mat4MulVecfl(imat, arc->buckets[i].p); + mul_m4_v3(imat, arc->buckets[i].p); VECCOPY(arc->buckets[i].no, stk->points[i + 1].no); - Mat3MulVecfl(tmat, arc->buckets[i].no); + mul_m3_v3(tmat, arc->buckets[i].no); } return arc; @@ -457,10 +457,10 @@ void sk_retargetStroke(bContext *C, SK_Stroke *stk) ReebArc *arc; RigGraph *rg; - Mat4Invert(imat, obedit->obmat); + invert_m4_m4(imat, obedit->obmat); - Mat3CpyMat4(tmat, obedit->obmat); - Mat3Transp(tmat); + copy_m3_m4(tmat, obedit->obmat); + transpose_m3(tmat); arc = sk_strokeToArc(stk, imat, tmat); @@ -505,16 +505,16 @@ void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float size) float vec1[3], vec2[3] = {0, 0, 1}, axis[3]; float angle, length; - VecSubf(vec1, pt1->p, pt0->p); - length = Normalize(vec1); - Crossf(axis, vec2, vec1); + sub_v3_v3v3(vec1, pt1->p, pt0->p); + length = normalize_v3(vec1); + cross_v3_v3v3(axis, vec2, vec1); - if (VecIsNull(axis)) + if (is_zero_v3(axis)) { axis[1] = 1; } - angle = NormalizedVecAngle2(vec2, vec1); + angle = angle_normalized_v3v3(vec2, vec1); glRotatef(angle * 180 / M_PI + 180, axis[0], axis[1], axis[2]); @@ -528,14 +528,14 @@ void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float height) glPushMatrix(); - Crossf(axis, vec2, pt->no); + cross_v3_v3v3(axis, vec2, pt->no); - if (VecIsNull(axis)) + if (is_zero_v3(axis)) { axis[1] = 1; } - angle = NormalizedVecAngle2(vec2, pt->no); + angle = angle_normalized_v3v3(vec2, pt->no); glRotatef(angle * 180 / M_PI, axis[0], axis[1], axis[2]); @@ -576,8 +576,8 @@ void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end) float d_rgb[3] = {1, 1, 1}; VECCOPY(rgb, color); - VecSubf(d_rgb, d_rgb, rgb); - VecMulf(d_rgb, 1.0f / (float)stk->nb_points); + sub_v3_v3v3(d_rgb, d_rgb, rgb); + mul_v3_fl(d_rgb, 1.0f / (float)stk->nb_points); for (i = 0; i < stk->nb_points; i++) { @@ -614,7 +614,7 @@ void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end) glPopMatrix(); - VecAddf(rgb, rgb, d_rgb); + add_v3_v3v3(rgb, rgb, d_rgb); } } @@ -756,7 +756,7 @@ SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short if ((bone->flag & BONE_CONNECTED) == 0) { VECCOPY(vec, bone->head); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); project_short_noclip(ar, vec, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -772,7 +772,7 @@ SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short VECCOPY(vec, bone->tail); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); project_short_noclip(ar, vec, pval); pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -977,13 +977,13 @@ float sk_distanceDepth(bContext *C, float p1[3], float p2[3]) float vec[3]; float distance; - VecSubf(vec, p1, p2); + sub_v3_v3v3(vec, p1, p2); - Projf(vec, vec, rv3d->viewinv[2]); + project_v3_v3v3(vec, vec, rv3d->viewinv[2]); - distance = VecLength(vec); + distance = len_v3(vec); - if (Inpf(rv3d->viewinv[2], vec) > 0) + if (dot_v3v3(rv3d->viewinv[2], vec) > 0) { distance *= -1; } @@ -1000,19 +1000,19 @@ void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float float progress = 0; int i; - progress = VecLenf(stk->points[start].p, stk->points[start - 1].p); + progress = len_v3v3(stk->points[start].p, stk->points[start - 1].p); for (i = start; i <= end; i++) { float ray_start[3], ray_normal[3]; - float delta = VecLenf(stk->points[i].p, stk->points[i + 1].p); + float delta = len_v3v3(stk->points[i].p, stk->points[i + 1].p); float pval[2]; project_float(ar, stk->points[i].p, pval); viewray(ar, v3d, pval, ray_start, ray_normal); - VecMulf(ray_normal, distance * progress / length); - VecAddf(stk->points[i].p, stk->points[i].p, ray_normal); + mul_v3_fl(ray_normal, distance * progress / length); + add_v3_v3v3(stk->points[i].p, stk->points[i].p, ray_normal); progress += delta ; } @@ -1037,7 +1037,7 @@ void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_DrawData /* method taken from editview.c - mouse_cursor() */ project_short_noclip(ar, fp, cval); window_to_3d_delta(ar, dvec, cval[0] - dd->mval[0], cval[1] - dd->mval[1]); - VecSubf(vec, fp, dvec); + sub_v3_v3v3(vec, fp, dvec); } int sk_getStrokeDrawPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd) @@ -1132,9 +1132,9 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok { p2->flag = 1; - VecAddf(vec, p1->p, p2->p); - VecMulf(vec, 0.5f); - new_size = VecLenf(p1->p, p2->p); + add_v3_v3v3(vec, p1->p, p2->p); + mul_v3_fl(vec, 0.5f); + new_size = len_v3v3(p1->p, p2->p); } else { @@ -1149,7 +1149,7 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok break; } - new_dist = VecLenf(last_p, vec); + new_dist = len_v3v3(last_p, vec); if (new_dist < dist) { @@ -1248,7 +1248,7 @@ int sk_addStrokeSnapPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_Dra length = 0; for (i = stk->nb_points - 2; i > 0; i--) { - length += VecLenf(stk->points[i].p, stk->points[i + 1].p); + length += len_v3v3(stk->points[i].p, stk->points[i + 1].p); total++; if (stk->points[i].mode == PT_SNAP || stk->points[i].type == PT_EXACT) { @@ -1494,10 +1494,10 @@ void sk_convertStroke(bContext *C, SK_Stroke *stk) head = NULL; - Mat4Invert(invmat, obedit->obmat); + invert_m4_m4(invmat, obedit->obmat); - Mat3CpyMat4(tmat, obedit->obmat); - Mat3Transp(tmat); + copy_m3_m4(tmat, obedit->obmat); + transpose_m3(tmat); for (i = 0; i < stk->nb_points; i++) { @@ -1543,8 +1543,8 @@ void sk_convertStroke(bContext *C, SK_Stroke *stk) VECCOPY(bone->head, head->p); VECCOPY(bone->tail, pt->p); - Mat4MulVecfl(invmat, bone->head); - Mat4MulVecfl(invmat, bone->tail); + mul_m4_v3(invmat, bone->head); + mul_m4_v3(invmat, bone->tail); setBoneRollFromNormal(bone, head->no, invmat, tmat); } @@ -1624,7 +1624,7 @@ int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture) project_float(ar, gesture->points[g_i].p, g_p1); project_float(ar, gesture->points[g_i + 1].p, g_p2); - if (LineIntersectLineStrict(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) + if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); @@ -1633,9 +1633,9 @@ int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture) isect->after = s_i + 1; isect->stroke = gesture; - VecSubf(isect->p, gesture->points[s_i + 1].p, gesture->points[s_i].p); - VecMulf(isect->p, lambda); - VecAddf(isect->p, isect->p, gesture->points[s_i].p); + sub_v3_v3v3(isect->p, gesture->points[s_i + 1].p, gesture->points[s_i].p); + mul_v3_fl(isect->p, lambda); + add_v3_v3v3(isect->p, isect->p, gesture->points[s_i].p); BLI_addtail(list, isect); @@ -1711,7 +1711,7 @@ int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Strok project_float(ar, gesture->points[g_i].p, g_p1); project_float(ar, gesture->points[g_i + 1].p, g_p2); - if (LineIntersectLineStrict(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) + if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); float ray_start[3], ray_end[3]; @@ -1727,7 +1727,7 @@ int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Strok mval[1] = vi[1]; viewline(ar, v3d, mval, ray_start, ray_end); - LineIntersectLine( stk->points[s_i].p, + isect_line_line_v3( stk->points[s_i].p, stk->points[s_i + 1].p, ray_start, ray_end, @@ -1768,7 +1768,7 @@ int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture) float n[3]; /* Calculate normal */ - VecSubf(n, gesture->points[i].p, vec); + sub_v3_v3v3(n, gesture->points[i].p, vec); if (calcArcCorrelation(iter, j, i, vec, n) < CORRELATION_THRESHOLD) { @@ -1818,10 +1818,10 @@ int sk_detectTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) float s1[3], s2[3]; float angle; - VecSubf(s1, gest->segments->points[1].p, gest->segments->points[0].p); - VecSubf(s2, gest->segments->points[2].p, gest->segments->points[1].p); + sub_v3_v3v3(s1, gest->segments->points[1].p, gest->segments->points[0].p); + sub_v3_v3v3(s2, gest->segments->points[2].p, gest->segments->points[1].p); - angle = RAD2DEG(VecAngle2(s1, s2)); + angle = RAD2DEG(angle_v2v2(s1, s2)); if (angle > 60 && angle < 120) { @@ -1837,7 +1837,7 @@ void sk_applyTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) SK_Intersection *isect; float trim_dir[3]; - VecSubf(trim_dir, gest->segments->points[2].p, gest->segments->points[1].p); + sub_v3_v3v3(trim_dir, gest->segments->points[2].p, gest->segments->points[1].p); for (isect = gest->intersections.first; isect; isect = isect->next) { @@ -1849,10 +1849,10 @@ void sk_applyTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) VECCOPY(pt.p, isect->p); VECCOPY(pt.no, isect->stroke->points[isect->before].no); - VecSubf(stroke_dir, isect->stroke->points[isect->after].p, isect->stroke->points[isect->before].p); + sub_v3_v3v3(stroke_dir, isect->stroke->points[isect->after].p, isect->stroke->points[isect->before].p); /* same direction, trim end */ - if (Inpf(stroke_dir, trim_dir) > 0) + if (dot_v3v3(stroke_dir, trim_dir) > 0) { sk_replaceStrokePoint(isect->stroke, &pt, isect->after); sk_trimStroke(isect->stroke, 0, isect->after); @@ -1936,10 +1936,10 @@ int sk_detectDeleteGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) float s1[3], s2[3]; float angle; - VecSubf(s1, gest->segments->points[1].p, gest->segments->points[0].p); - VecSubf(s2, gest->segments->points[2].p, gest->segments->points[1].p); + sub_v3_v3v3(s1, gest->segments->points[1].p, gest->segments->points[0].p); + sub_v3_v3v3(s2, gest->segments->points[2].p, gest->segments->points[1].p); - angle = RAD2DEG(VecAngle2(s1, s2)); + angle = RAD2DEG(angle_v2v2(s1, s2)); if (angle > 120) { @@ -2062,16 +2062,16 @@ int sk_detectReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) if (isect->gesture_index < isect->next->gesture_index) { - VecSubf(start_v, isect->p, gest->stk->points[0].p); - VecSubf(end_v, sk_lastStrokePoint(gest->stk)->p, isect->next->p); + sub_v3_v3v3(start_v, isect->p, gest->stk->points[0].p); + sub_v3_v3v3(end_v, sk_lastStrokePoint(gest->stk)->p, isect->next->p); } else { - VecSubf(start_v, isect->next->p, gest->stk->points[0].p); - VecSubf(end_v, sk_lastStrokePoint(gest->stk)->p, isect->p); + sub_v3_v3v3(start_v, isect->next->p, gest->stk->points[0].p); + sub_v3_v3v3(end_v, sk_lastStrokePoint(gest->stk)->p, isect->p); } - angle = RAD2DEG(VecAngle2(start_v, end_v)); + angle = RAD2DEG(angle_v2v2(start_v, end_v)); if (angle > 120) { diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 9847bdc3283..b9019410348 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -40,7 +40,7 @@ #include "DNA_modifier_types.h" #include "DNA_scene_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_memarena.h" @@ -151,16 +151,16 @@ static float cotan_weight(float *v1, float *v2, float *v3) { float a[3], b[3], c[3], clen; - VecSubf(a, v2, v1); - VecSubf(b, v3, v1); - Crossf(c, a, b); + sub_v3_v3v3(a, v2, v1); + sub_v3_v3v3(b, v3, v1); + cross_v3_v3v3(c, a, b); - clen = VecLength(c); + clen = len_v3(c); if (clen == 0.0f) return 0.0f; - return Inpf(a, b)/clen; + return dot_v3v3(a, b)/clen; } static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3) @@ -177,21 +177,21 @@ static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3 t2= cotan_weight(v2, v3, v1); t3= cotan_weight(v3, v1, v2); - if(RAD2DEG(VecAngle3(v2, v1, v3)) > 90) obtuse= 1; - else if(RAD2DEG(VecAngle3(v1, v2, v3)) > 90) obtuse= 2; - else if(RAD2DEG(VecAngle3(v1, v3, v2)) > 90) obtuse= 3; + if(RAD2DEG(angle_v3v3v3(v2, v1, v3)) > 90) obtuse= 1; + else if(RAD2DEG(angle_v3v3v3(v1, v2, v3)) > 90) obtuse= 2; + else if(RAD2DEG(angle_v3v3v3(v1, v3, v2)) > 90) obtuse= 3; if (obtuse > 0) { - area= AreaT3Dfl(v1, v2, v3); + area= area_tri_v3(v1, v2, v3); varea[i1] += (obtuse == 1)? area: area*0.5; varea[i2] += (obtuse == 2)? area: area*0.5; varea[i3] += (obtuse == 3)? area: area*0.5; } else { - len1= VecLenf(v2, v3); - len2= VecLenf(v1, v3); - len3= VecLenf(v1, v2); + len1= len_v3v3(v2, v3); + len2= len_v3v3(v1, v3); + len3= len_v3v3(v1, v2); t1 *= len1*len1; t2 *= len2*len2; @@ -446,7 +446,7 @@ static int heat_ray_bone_visible(LaplacianSystem *sys, int vertex, int bone) VECCOPY(isec.start, sys->heat.verts[vertex]); - PclosestVL3Dfl(end, isec.start, sys->heat.root[bone], sys->heat.tip[bone]); + closest_to_line_segment_v3(end, isec.start, sys->heat.root[bone], sys->heat.tip[bone]); VECSUB(isec.vec, end, isec.start); isec.labda = 1.0f - 1e-5; @@ -462,11 +462,11 @@ static float heat_bone_distance(LaplacianSystem *sys, int vertex, int bone) float closest[3], d[3], dist, cosine; /* compute euclidian distance */ - PclosestVL3Dfl(closest, sys->heat.verts[vertex], + closest_to_line_segment_v3(closest, sys->heat.verts[vertex], sys->heat.root[bone], sys->heat.tip[bone]); - VecSubf(d, sys->heat.verts[vertex], closest); - dist= Normalize(d); + sub_v3_v3v3(d, sys->heat.verts[vertex], closest); + dist= normalize_v3(d); /* if the vertex normal does not point along the bone, increase distance */ cosine= INPR(d, sys->heat.vnors[vertex]); @@ -536,15 +536,15 @@ void heat_calc_vnormals(LaplacianSystem *sys) v2= (*face)[1]; v3= (*face)[2]; - CalcNormFloat(sys->verts[v1], sys->verts[v2], sys->verts[v3], fnor); + normal_tri_v3( fnor,sys->verts[v1], sys->verts[v2], sys->verts[v3]); - VecAddf(sys->heat.vnors[v1], sys->heat.vnors[v1], fnor); - VecAddf(sys->heat.vnors[v2], sys->heat.vnors[v2], fnor); - VecAddf(sys->heat.vnors[v3], sys->heat.vnors[v3], fnor); + add_v3_v3v3(sys->heat.vnors[v1], sys->heat.vnors[v1], fnor); + add_v3_v3v3(sys->heat.vnors[v2], sys->heat.vnors[v2], fnor); + add_v3_v3v3(sys->heat.vnors[v3], sys->heat.vnors[v3], fnor); } for(a=0; atotvert; a++) - Normalize(sys->heat.vnors[a]); + normalize_v3(sys->heat.vnors[a]); } static void heat_laplacian_create(LaplacianSystem *sys) @@ -746,8 +746,8 @@ static void rigid_add_half_edge_to_R(LaplacianSystem *sys, EditVert *v1, EditVer float e[3], e_[3]; int i; - VecSubf(e, sys->rigid.origco[v1->tmp.l], sys->rigid.origco[v2->tmp.l]); - VecSubf(e_, v1->co, v2->co); + sub_v3_v3v3(e, sys->rigid.origco[v1->tmp.l], sys->rigid.origco[v2->tmp.l]); + sub_v3_v3v3(e_, v1->co, v2->co); /* formula (5) */ for (i=0; i<3; i++) { @@ -767,9 +767,9 @@ static void rigid_orthogonalize_R(float R[][3]) { HMatrix M, Q, S; - Mat4CpyMat3(M, R); + copy_m4_m3(M, R); polar_decomp(M, Q, S); - Mat3CpyMat4(R, Q); + copy_m3_m4(R, Q); } static void rigid_add_half_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditVert *v2, float w) @@ -780,15 +780,15 @@ static void rigid_add_half_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditV if (sys->vpinned[v1->tmp.l]) return; - Mat3AddMat3(Rsum, sys->rigid.R[v1->tmp.l], sys->rigid.R[v2->tmp.l]); - Mat3Transp(Rsum); + add_m3_m3m3(Rsum, sys->rigid.R[v1->tmp.l], sys->rigid.R[v2->tmp.l]); + transpose_m3(Rsum); - VecSubf(rhs, sys->rigid.origco[v1->tmp.l], sys->rigid.origco[v2->tmp.l]); - Mat3MulVecfl(Rsum, rhs); - VecMulf(rhs, 0.5f); - VecMulf(rhs, w); + sub_v3_v3v3(rhs, sys->rigid.origco[v1->tmp.l], sys->rigid.origco[v2->tmp.l]); + mul_m3_v3(Rsum, rhs); + mul_v3_fl(rhs, 0.5f); + mul_v3_fl(rhs, w); - VecAddf(sys->rigid.rhs[v1->tmp.l], sys->rigid.rhs[v1->tmp.l], rhs); + add_v3_v3v3(sys->rigid.rhs[v1->tmp.l], sys->rigid.rhs[v1->tmp.l], rhs); } static void rigid_add_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditVert *v2, float w) @@ -916,7 +916,7 @@ void rigid_deform_begin(EditMesh *em) sys->rigid.origco = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformCo"); for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) - VecCopyf(sys->rigid.origco[a], eve->co); + copy_v3_v3(sys->rigid.origco[a], eve->co); sys->areaweights= 0; sys->storeweights= 1; @@ -940,7 +940,7 @@ void rigid_deform_end(int cancel) if(cancel) for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) if(!eve->pinned) - VecCopyf(eve->co, sys->rigid.origco[a]); + copy_v3_v3(eve->co, sys->rigid.origco[a]); if(sys->rigid.R) MEM_freeN(sys->rigid.R); if(sys->rigid.rhs) MEM_freeN(sys->rigid.rhs); @@ -1034,7 +1034,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], VECSUB(edge2, vert2, vert0); /* begin calculating determinant - also used to calculate U parameter */ - Crossf(pvec, dir, edge2); + cross_v3_v3v3(pvec, dir, edge2); /* if determinant is near zero, ray lies in plane of triangle */ det = INPR(edge1, pvec); @@ -1052,7 +1052,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], return 0; /* prepare to test V parameter */ - Crossf(qvec, tvec, edge1); + cross_v3_v3v3(qvec, tvec, edge1); /* calculate V parameter and test bounds */ v = INPR(dir, qvec) * inv_det; @@ -1158,20 +1158,20 @@ static int meshdeform_intersect(MeshDeformBind *mdb, Isect *isec) hit = meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); if(hit) { - CalcNormFloat(face[0], face[1], face[2], nor); + normal_tri_v3( nor,face[0], face[1], face[2]); } else { hit= meshdeform_tri_intersect(isec->start, end, face[0], face[2], face[3], co, uvw); - CalcNormFloat(face[0], face[2], face[3], nor); + normal_tri_v3( nor,face[0], face[2], face[3]); } } else { hit= meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); - CalcNormFloat(face[0], face[1], face[2], nor); + normal_tri_v3( nor,face[0], face[1], face[2]); } if(hit) { - len= VecLenf(isec->start, co)/VecLenf(isec->start, end); + len= len_v3v3(isec->start, co)/len_v3v3(isec->start, end); if(len < isec->labda) { isec->labda= len; isec->hit.face = mface; @@ -1219,7 +1219,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float isect->co[1]= co1[1] + isec.vec[1]*len; isect->co[2]= co1[2] + isec.vec[2]*len; - isect->len= VecLenf(co1, isect->co); + isect->len= len_v3v3(co1, isect->co); if(isect->len < MESHDEFORM_LEN_THRESHOLD) isect->len= MESHDEFORM_LEN_THRESHOLD; @@ -1237,7 +1237,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float VECCOPY(vert[1], cagecos[mface->v2]); VECCOPY(vert[2], cagecos[mface->v3]); if(mface->v4) VECCOPY(vert[3], cagecos[mface->v4]); - MeanValueWeights(vert, isect->nvert, isect->co, isect->uvw); + interp_weights_poly_v3( isect->uvw,vert, isect->nvert, isect->co); return isect; } @@ -1260,7 +1260,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) VECCOPY(start, co); VECSUB(dir, outside, start); - Normalize(dir); + normalize_v3(dir); isect = meshdeform_ray_tree_intersect(mdb, start, outside); if(isect && !isect->facing) @@ -1650,7 +1650,7 @@ static void meshdeform_matrix_solve(MeshDeformBind *mdb) for(b=0; btotvert; b++) { if(mdb->inside[b]) { VECCOPY(vec, mdb->vertexcos[b]); - Mat4MulVecfl(mdb->cagemat, vec); + mul_m4_v3(mdb->cagemat, vec); gridvec[0]= (vec[0] - mdb->min[0] - mdb->halfwidth[0])/mdb->width[0]; gridvec[1]= (vec[1] - mdb->min[1] - mdb->halfwidth[1])/mdb->width[1]; gridvec[2]= (vec[2] - mdb->min[2] - mdb->halfwidth[2])/mdb->width[2]; @@ -1720,7 +1720,7 @@ void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, float mdb.cagedm= mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH); mdb.totcagevert= mdb.cagedm->getNumVerts(mdb.cagedm); mdb.cagecos= MEM_callocN(sizeof(*mdb.cagecos)*mdb.totcagevert, "MeshDeformBindCos"); - Mat4CpyMat4(mdb.cagemat, cagemat); + copy_m4_m4(mdb.cagemat, cagemat); mvert= mdb.cagedm->getVertArray(mdb.cagedm); for(a=0; abindcos= (float*)mdb.cagecos; mmd->totvert= mdb.totvert; mmd->totcagevert= mdb.totcagevert; - Mat4CpyMat4(mmd->bindmat, mmd->object->obmat); + copy_m4_m4(mmd->bindmat, mmd->object->obmat); if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) { mmd->totinfluence= 0; @@ -1868,7 +1868,7 @@ void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, float /* transform bindcos to world space */ for(a=0; aobject->obmat, mmd->bindcos+a*3); + mul_m4_v3(mmd->object->obmat, mmd->bindcos+a*3); /* free */ mdb.cagedm->release(mdb.cagedm); diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 1e0df79d0e6..e5d334e4d06 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_dlrbTree.h" @@ -461,7 +461,7 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl) /* perform blending */ if (pso->mode == POSESLIDE_BREAKDOWN) { /* just perform the interpol between quat_prev and quat_next using pso->percentage as a guide */ - QuatInterpol(pchan->quat, quat_prev, quat_next, pso->percentage); + interp_qt_qtqt(pchan->quat, quat_prev, quat_next, pso->percentage); } else { float quat_interp[4], quat_orig[4]; @@ -470,16 +470,16 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl) /* perform this blending several times until a satisfactory result is reached */ while (iters-- > 0) { /* calculate the interpolation between the endpoints */ - QuatInterpol(quat_interp, quat_prev, quat_next, (cframe-pso->prevFrame) / (pso->nextFrame-pso->prevFrame) ); + interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe-pso->prevFrame) / (pso->nextFrame-pso->prevFrame) ); /* make a copy of the original rotation */ QUATCOPY(quat_orig, pchan->quat); /* tricky interpolations - mode-dependent blending between original and new */ if (pso->mode == POSESLIDE_RELAX) // xxx this was the original code, so should work fine - QuatInterpol(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f); + interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f); else // I'm just guessing here... - QuatInterpol(pchan->quat, quat_orig, quat_interp, 6.0f/5.0f); + interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 6.0f/5.0f); } } } diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 565a4782377..0837e9cb48a 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_dlrbTree.h" diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index d7741c2a5ef..18750d96f86 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -33,7 +33,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" @@ -279,7 +279,7 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob) VECCOPY(fp, pchan->pose_tail); } - Mat4MulVecfl(ob->obmat, fp); + mul_m4_v3(ob->obmat, fp); } } } @@ -405,7 +405,7 @@ static int pose_calculate_paths_exec (bContext *C, wmOperator *op) VECCOPY(fp, pchan->pose_tail); } - Mat4MulVecfl(ob->obmat, fp); + mul_m4_v3(ob->obmat, fp); } } } @@ -814,13 +814,13 @@ void pose_copy_menu(Scene *scene) float tmp_quat[4]; /* need to convert to quat first (in temp var)... */ - Mat4ToQuat(delta_mat, tmp_quat); - QuatToAxisAngle(tmp_quat, pchan->rotAxis, &pchan->rotAngle); + mat4_to_quat( tmp_quat,delta_mat); + quat_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,tmp_quat); } else if (pchan->rotmode == ROT_MODE_QUAT) - Mat4ToQuat(delta_mat, pchan->quat); + mat4_to_quat( pchan->quat,delta_mat); else - Mat4ToEulO(delta_mat, pchan->eul, pchan->rotmode); + mat4_to_eulO( pchan->eul, pchan->rotmode,delta_mat); } break; case 11: /* Visual Size */ @@ -828,7 +828,7 @@ void pose_copy_menu(Scene *scene) float delta_mat[4][4], size[4]; armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); - Mat4ToSize(delta_mat, size); + mat4_to_size( size,delta_mat); VECCOPY(pchan->size, size); } } @@ -1020,23 +1020,23 @@ static int pose_paste_exec (bContext *C, wmOperator *op) else if (pchan->rotmode > 0) { /* quat/axis-angle to euler */ if (chan->rotmode == ROT_MODE_AXISANGLE) - AxisAngleToEulO(chan->rotAxis, chan->rotAngle, pchan->eul, pchan->rotmode); + axis_angle_to_eulO( pchan->eul, pchan->rotmode,chan->rotAxis, chan->rotAngle); else - QuatToEulO(chan->quat, pchan->eul, pchan->rotmode); + quat_to_eulO( pchan->eul, pchan->rotmode,chan->quat); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { /* quat/euler to axis angle */ if (chan->rotmode > 0) - EulOToAxisAngle(chan->eul, chan->rotmode, pchan->rotAxis, &pchan->rotAngle); + eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,chan->eul, chan->rotmode); else - QuatToAxisAngle(chan->quat, pchan->rotAxis, &pchan->rotAngle); + quat_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,chan->quat); } else { /* euler/axis-angle to quat */ if (chan->rotmode > 0) - EulOToQuat(chan->eul, chan->rotmode, pchan->quat); + eulO_to_quat( pchan->quat,chan->eul, chan->rotmode); else - AxisAngleToQuat(pchan->quat, chan->rotAxis, pchan->rotAngle); + axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle); } /* paste flipped pose? */ @@ -1051,10 +1051,10 @@ static int pose_paste_exec (bContext *C, wmOperator *op) else if (pchan->rotmode == ROT_MODE_AXISANGLE) { float eul[3]; - AxisAngleToEulO(pchan->rotAxis, pchan->rotAngle, eul, EULER_ORDER_DEFAULT); + axis_angle_to_eulO( eul, EULER_ORDER_DEFAULT,pchan->rotAxis, pchan->rotAngle); eul[1]*= -1; eul[2]*= -1; - EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, &pchan->rotAngle); + eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,eul, EULER_ORDER_DEFAULT); // experimental method (uncomment to test): #if 0 @@ -1066,10 +1066,10 @@ static int pose_paste_exec (bContext *C, wmOperator *op) else { float eul[3]; - QuatToEul(pchan->quat, eul); + quat_to_eul( eul,pchan->quat); eul[1]*= -1; eul[2]*= -1; - EulToQuat(eul, pchan->quat); + eul_to_quat( pchan->quat,eul); } } diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 132d9edf8d0..05b0dc267ff 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -45,7 +45,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_edgehash.h" #include "BLI_ghash.h" @@ -498,12 +498,12 @@ void repositionNodes(ReebGraph *rg) float p[3]; VECCOPY(p, ((ReebArc*)arc)->buckets[0].p); - VecMulf(p, 1.0f / arc->head->degree); - VecAddf(arc->head->p, arc->head->p, p); + mul_v3_fl(p, 1.0f / arc->head->degree); + add_v3_v3v3(arc->head->p, arc->head->p, p); VECCOPY(p, ((ReebArc*)arc)->buckets[((ReebArc*)arc)->bcount - 1].p); - VecMulf(p, 1.0f / arc->tail->degree); - VecAddf(arc->tail->p, arc->tail->p, p); + mul_v3_fl(p, 1.0f / arc->tail->degree); + add_v3_v3v3(arc->tail->p, arc->tail->p, p); } } } @@ -634,15 +634,15 @@ void verifyMultiResolutionLinks(ReebGraph *rg, int level) void addVertToBucket(EmbedBucket *b, float co[3]) { b->nv++; - VecLerpf(b->p, b->p, co, 1.0f / b->nv); + interp_v3_v3v3(b->p, b->p, co, 1.0f / b->nv); } void removeVertFromBucket(EmbedBucket *b, float co[3]) { - VecMulf(b->p, (float)b->nv); - VecSubf(b->p, b->p, co); + mul_v3_fl(b->p, (float)b->nv); + sub_v3_v3v3(b->p, b->p, co); b->nv--; - VecMulf(b->p, 1.0f / (float)b->nv); + mul_v3_fl(b->p, 1.0f / (float)b->nv); } void mergeBuckets(EmbedBucket *bDst, EmbedBucket *bSrc) @@ -650,7 +650,7 @@ void mergeBuckets(EmbedBucket *bDst, EmbedBucket *bSrc) if (bDst->nv > 0 && bSrc->nv > 0) { bDst->nv += bSrc->nv; - VecLerpf(bDst->p, bDst->p, bSrc->p, (float)bSrc->nv / (float)(bDst->nv)); + interp_v3_v3v3(bDst->p, bDst->p, bSrc->p, (float)bSrc->nv / (float)(bDst->nv)); } else if (bSrc->nv > 0) { @@ -797,7 +797,7 @@ static void interpolateBuckets(ReebArc *arc, float *start_p, float *end_p, int s { EmbedBucket *empty = arc->buckets + j; empty->nv = 1; - VecLerpf(empty->p, start_p, end_p, (float)(j - start_index + 1) / total); + interp_v3_v3v3(empty->p, start_p, end_p, (float)(j - start_index + 1) / total); } } @@ -873,20 +873,20 @@ static void ExtendArcBuckets(ReebArc *arc) previous = iter->p, IT_next(iter) ) { - average_length += VecLenf(previous, iter->p); + average_length += len_v3v3(previous, iter->p); } average_length /= (arc->bcount - 1); first_bucket = arc->buckets; last_bucket = arc->buckets + (arc->bcount - 1); - length = VecLenf(first_bucket->p, arc->head->p); + length = len_v3v3(first_bucket->p, arc->head->p); if (length > 2 * average_length) { padding_head = (int)floor(length / average_length); } - length = VecLenf(last_bucket->p, arc->tail->p); + length = len_v3v3(last_bucket->p, arc->tail->p); if (length > 2 * average_length) { padding_tail = (int)floor(length / average_length); @@ -945,12 +945,12 @@ void calculateArcLength(ReebArc *arc) { vec1 = iter->p; - arc->length += VecLenf(vec0, vec1); + arc->length += len_v3v3(vec0, vec1); vec0 = vec1; } - arc->length += VecLenf(arc->tail->p, vec1); + arc->length += len_v3v3(arc->tail->p, vec1); } void calculateGraphLength(ReebGraph *rg) @@ -982,8 +982,8 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) float normal[3]; int j = i + 1; - VecAddf(tangent, ring[i].n, ring[j].n); - Crossf(normal, tangent, axis); + add_v3_v3v3(tangent, ring[i].n, ring[j].n); + cross_v3_v3v3(normal, tangent, axis); node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node); node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node); @@ -993,7 +993,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) /* mirror first node and mix with the second */ BLI_mirrorAlongAxis(node1->p, root_node->p, normal); - VecLerpf(node2->p, node2->p, node1->p, 1.0f / (j + 1)); + interp_v3_v3v3(node2->p, node2->p, node1->p, 1.0f / (j + 1)); /* Merge buckets * there shouldn't be any null arcs here, but just to be safe @@ -1030,7 +1030,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) /* mirror on axis */ BLI_mirrorAlongAxis(bucket1->p, root_node->p, normal); /* add bucket2 in bucket1 */ - VecLerpf(bucket2->p, bucket2->p, bucket1->p, (float)bucket1->nv / (float)(bucket2->nv)); + interp_v3_v3v3(bucket2->p, bucket2->p, bucket1->p, (float)bucket1->nv / (float)(bucket2->nv)); } } } @@ -1044,8 +1044,8 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) float normal[3]; int j = i - 1; - VecAddf(tangent, ring[i].n, ring[j].n); - Crossf(normal, tangent, axis); + add_v3_v3v3(tangent, ring[i].n, ring[j].n); + cross_v3_v3v3(normal, tangent, axis); node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node); node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node); @@ -1111,8 +1111,8 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr BLI_mirrorAlongAxis(p, root_node->p, nor); /* average with node1 */ - VecAddf(node1->p, node1->p, p); - VecMulf(node1->p, 0.5f); + add_v3_v3v3(node1->p, node1->p, p); + mul_v3_fl(node1->p, 0.5f); /* mirror back on node2 */ VECCOPY(node2->p, node1->p); @@ -1153,7 +1153,7 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr /* mirror on axis */ BLI_mirrorAlongAxis(bucket2->p, root_node->p, nor); /* add bucket2 in bucket1 */ - VecLerpf(bucket1->p, bucket1->p, bucket2->p, (float)bucket2->nv / (float)(bucket1->nv)); + interp_v3_v3v3(bucket1->p, bucket1->p, bucket2->p, (float)bucket2->nv / (float)(bucket1->nv)); /* copy and mirror back to bucket2 */ bucket2->nv = bucket1->nv; @@ -1200,8 +1200,8 @@ void postprocessGraph(ReebGraph *rg, char mode) for(index = 1; index < bcount - 1; index++) { - VecLerpf(buckets[index].p, buckets[index].p, buckets[index - 1].p, fac1 / (fac1 + fac2)); - VecLerpf(buckets[index].p, buckets[index].p, buckets[index + 1].p, fac3 / (fac1 + fac2 + fac3)); + interp_v3_v3v3(buckets[index].p, buckets[index].p, buckets[index - 1].p, fac1 / (fac1 + fac2)); + interp_v3_v3v3(buckets[index].p, buckets[index].p, buckets[index + 1].p, fac3 / (fac1 + fac2 + fac3)); } } } @@ -1339,7 +1339,7 @@ int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) { if (end_node->subgraph_index != subgraph) { - float distance = VecLenf(start_node->p, end_node->p); + float distance = len_v3v3(start_node->p, end_node->p); if (distance < threshold && distance < min_distance) { @@ -1597,7 +1597,7 @@ void filterNullReebGraph(ReebGraph *rg) blend = (float)newNode->degree / (float)(newNode->degree + removedNode->degree); // blending factors - VecLerpf(newNode->p, removedNode->p, newNode->p, blend); + interp_v3_v3v3(newNode->p, removedNode->p, newNode->p, blend); filterArc(rg, newNode, removedNode, arc, 0); @@ -1808,16 +1808,16 @@ int filterSmartReebGraph(ReebGraph *rg, float threshold) VECCOPY(midpoint, vec1); - distance = VecLenf(midpoint, efa->cent); + distance = len_v3v3(midpoint, efa->cent); if (min_distance == -1 || distance < min_distance) { min_distance = distance; - VecSubf(tangent, vec1, vec0); - Normalize(tangent); + sub_v3_v3v3(tangent, vec1, vec0); + normalize_v3(tangent); - angle = Inpf(tangent, efa->n); + angle = dot_v3v3(tangent, efa->n); } previous = bucket; @@ -1829,7 +1829,7 @@ int filterSmartReebGraph(ReebGraph *rg, float threshold) efa->tmp.fp = saacos(fabs(angle)); #endif #else - VecAddf(avg_vec, avg_vec, efa->n); + add_v3_v3v3(avg_vec, avg_vec, efa->n); #endif } @@ -1837,8 +1837,8 @@ int filterSmartReebGraph(ReebGraph *rg, float threshold) #if 0 avg_angle /= total; #else - VecMulf(avg_vec, 1.0 / total); - avg_angle = Inpf(avg_vec, avg_vec); + mul_v3_fl(avg_vec, 1.0 / total); + avg_angle = dot_v3v3(avg_vec, avg_vec); #endif arc->angle = avg_angle; @@ -2064,8 +2064,8 @@ void REEB_exportGraph(ReebGraph *rg, int count) fprintf(f, "b nv:%i %f %f %f\n", arc->buckets[i].nv, arc->buckets[i].p[0], arc->buckets[i].p[1], arc->buckets[i].p[2]); } - VecAddf(p, arc->tail->p, arc->head->p); - VecMulf(p, 0.5f); + add_v3_v3v3(p, arc->tail->p, arc->head->p); + mul_v3_fl(p, 0.5f); fprintf(f, "angle %0.3f %0.3f %0.3f %0.3f %i\n", p[0], p[1], p[2], arc->angle, BLI_ghash_size(arc->faces)); exportNode(f, "v2", arc->tail); @@ -2501,7 +2501,7 @@ ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) float co[3]; float f = (arc->buckets[i].val - offset) / len; - VecLerpf(co, v1->p, v2->p, f); + interp_v3_v3v3(co, v1->p, v2->p, f); addVertToBucket(&(arc->buckets[i]), co); } #endif @@ -2690,16 +2690,16 @@ static float cotan_weight(float *v1, float *v2, float *v3) { float a[3], b[3], c[3], clen; - VecSubf(a, v2, v1); - VecSubf(b, v3, v1); - Crossf(c, a, b); + sub_v3_v3v3(a, v2, v1); + sub_v3_v3v3(b, v3, v1); + cross_v3_v3v3(c, a, b); - clen = VecLength(c); + clen = len_v3(c); if (clen == 0.0f) return 0.0f; - return Inpf(a, b)/clen; + return dot_v3v3(a, b)/clen; } void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2, int e3) @@ -3077,7 +3077,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) { if (eed->v1->h == 0 && eed->v2->h == 0) { - eed->tmp.fp = VecLenf(eed->v1->co, eed->v2->co); + eed->tmp.fp = len_v3v3(eed->v1->co, eed->v2->co); } } @@ -3112,7 +3112,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) /* vertex is already processed and distance is smaller than current minimum */ if (closest_eve->f1 == 1) { - float distance = VecLenf(closest_eve->co, eve->co); + float distance = len_v3v3(closest_eve->co, eve->co); if (distance < min_distance) { min_distance = distance; @@ -3688,7 +3688,7 @@ void REEB_draw() if (G.scene->toolsettings->skgen_options & SKGEN_DISP_INDEX) { - VecLerpf(vec, arc->head->p, arc->tail->p, 0.5f); + interp_v3_v3v3(vec, arc->head->p, arc->tail->p, 0.5f); s += sprintf(s, "%i (%i-%i-%i) ", i, arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group); if (G.scene->toolsettings->skgen_options & SKGEN_DISP_WEIGHT) diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 929e3514990..4c5bcb71499 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -40,7 +40,7 @@ #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_context.h" diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index a58439051e9..7801168dd83 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dynstr.h" #include "BLI_rand.h" @@ -525,7 +525,7 @@ static void rotateflagNurb(ListBase *editnurb, short flag, float *cent, float ro bp->vec[0]-=cent[0]; bp->vec[1]-=cent[1]; bp->vec[2]-=cent[2]; - Mat3MulVecfl(rotmat, bp->vec); + mul_m3_v3(rotmat, bp->vec); bp->vec[0]+=cent[0]; bp->vec[1]+=cent[1]; bp->vec[2]+=cent[2]; @@ -549,9 +549,9 @@ static void translateflagNurb(ListBase *editnurb, short flag, float *vec) a= nu->pntsu; bezt= nu->bezt; while(a--) { - if(bezt->f1 & flag) VecAddf(bezt->vec[0], bezt->vec[0], vec); - if(bezt->f2 & flag) VecAddf(bezt->vec[1], bezt->vec[1], vec); - if(bezt->f3 & flag) VecAddf(bezt->vec[2], bezt->vec[2], vec); + if(bezt->f1 & flag) add_v3_v3v3(bezt->vec[0], bezt->vec[0], vec); + if(bezt->f2 & flag) add_v3_v3v3(bezt->vec[1], bezt->vec[1], vec); + if(bezt->f3 & flag) add_v3_v3v3(bezt->vec[2], bezt->vec[2], vec); bezt++; } } @@ -559,7 +559,7 @@ static void translateflagNurb(ListBase *editnurb, short flag, float *vec) a= nu->pntsu*nu->pntsv; bp= nu->bp; while(a--) { - if(bp->f1 & flag) VecAddf(bp->vec, bp->vec, vec); + if(bp->f1 & flag) add_v3_v3v3(bp->vec, bp->vec, vec); bp++; } } @@ -1868,18 +1868,18 @@ static int subdivide_exec(bContext *C, wmOperator *op) memcpy(beztn, bezt, sizeof(BezTriple)); /* midpoint subdividing */ - VecMidf(vec, prevbezt->vec[1], prevbezt->vec[2]); - VecMidf(vec+3, prevbezt->vec[2], bezt->vec[0]); - VecMidf(vec+6, bezt->vec[0], bezt->vec[1]); + mid_v3_v3v3(vec, prevbezt->vec[1], prevbezt->vec[2]); + mid_v3_v3v3(vec+3, prevbezt->vec[2], bezt->vec[0]); + mid_v3_v3v3(vec+6, bezt->vec[0], bezt->vec[1]); - VecMidf(vec+9, vec, vec+3); - VecMidf(vec+12, vec+3, vec+6); + mid_v3_v3v3(vec+9, vec, vec+3); + mid_v3_v3v3(vec+12, vec+3, vec+6); /* change handle of prev beztn */ VECCOPY((beztn-1)->vec[2], vec); /* new point */ VECCOPY(beztn->vec[0], vec+9); - VecMidf(beztn->vec[1], vec+9, vec+12); + mid_v3_v3v3(beztn->vec[1], vec+9, vec+12); VECCOPY(beztn->vec[2], vec+12); /* handle of next bezt */ if(a==0 && (nu->flagu & CU_CYCLIC)) {VECCOPY(beztnew->vec[0], vec+6);} @@ -2662,10 +2662,10 @@ static void make_selection_list_nurb(ListBase *editnurb) bp= nu->bp; a= nu->pntsu; while(a--) { - VecAddf(nus->vec, nus->vec, bp->vec); + add_v3_v3v3(nus->vec, nus->vec, bp->vec); bp++; } - VecMulf(nus->vec, 1.0/(float)nu->pntsu); + mul_v3_fl(nus->vec, 1.0/(float)nu->pntsu); } @@ -2684,13 +2684,13 @@ static void make_selection_list_nurb(ListBase *editnurb) nustest= nbase.first; while(nustest) { - dist= VecLenf(nustest->vec, ((NurbSort *)nsortbase.first)->vec); + dist= len_v3v3(nustest->vec, ((NurbSort *)nsortbase.first)->vec); if(distvec, ((NurbSort *)nsortbase.last)->vec); + dist= len_v3v3(nustest->vec, ((NurbSort *)nsortbase.last)->vec); if(distpntsv; v++, bp1+=nu1->pntsu, bp2+=nu2->pntsu) { - len1+= VecLenf(bp1->vec, bp2->vec); + len1+= len_v3v3(bp1->vec, bp2->vec); } bp1= nu1->bp + nu1->pntsu-1; @@ -2782,7 +2782,7 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu len2= 0.0; for(v=0; vpntsv; v++, bp1+=nu1->pntsu, bp2-=nu2->pntsu) { - len2+= VecLenf(bp1->vec, bp2->vec); + len2+= len_v3v3(bp1->vec, bp2->vec); } /* merge */ @@ -3136,13 +3136,13 @@ static int spin_nurb(bContext *C, Scene *scene, Object *obedit, float *dvec, sho float persmat[3][3], persinv[3][3]; short a,ok, changed= 0; - if(mode != 2 && rv3d) Mat3CpyMat4(persmat, rv3d->viewmat); - else Mat3One(persmat); - Mat3Inv(persinv, persmat); + if(mode != 2 && rv3d) copy_m3_m4(persmat, rv3d->viewmat); + else unit_m3(persmat); + invert_m3_m3(persinv, persmat); /* imat and center and size */ - Mat3CpyMat4(bmat, obedit->obmat); - Mat3Inv(imat, bmat); + copy_m3_m4(bmat, obedit->obmat); + invert_m3_m3(imat, bmat); if(v3d) { curs= give_cursor(scene, v3d); @@ -3151,8 +3151,8 @@ static int spin_nurb(bContext *C, Scene *scene, Object *obedit, float *dvec, sho else cent[0]= cent[1]= cent[2]= 0.0f; - VecSubf(cent, cent, obedit->obmat[3]); - Mat3MulVecfl(imat,cent); + sub_v3_v3v3(cent, cent, obedit->obmat[3]); + mul_m3_v3(imat,cent); if(dvec || mode==2 || !rv3d) { n[0]=n[1]= 0.0; @@ -3161,7 +3161,7 @@ static int spin_nurb(bContext *C, Scene *scene, Object *obedit, float *dvec, sho n[0]= rv3d->viewinv[2][0]; n[1]= rv3d->viewinv[2][1]; n[2]= rv3d->viewinv[2][2]; - Normalize(n); + normalize_v3(n); } phi= M_PI/8.0; @@ -3170,27 +3170,27 @@ static int spin_nurb(bContext *C, Scene *scene, Object *obedit, float *dvec, sho q[1]= n[0]*si; q[2]= n[1]*si; q[3]= n[2]*si; - QuatToMat3(q, cmat); - Mat3MulMat3(tmat, cmat, bmat); - Mat3MulMat3(rotmat, imat, tmat); + quat_to_mat3( cmat,q); + mul_m3_m3m3(tmat, cmat, bmat); + mul_m3_m3m3(rotmat, imat, tmat); - Mat3One(scalemat1); + unit_m3(scalemat1); scalemat1[0][0]= sqrt(2.0); scalemat1[1][1]= sqrt(2.0); - Mat3MulMat3(tmat,persmat,bmat); - Mat3MulMat3(cmat,scalemat1,tmat); - Mat3MulMat3(tmat,persinv,cmat); - Mat3MulMat3(scalemat1,imat,tmat); + mul_m3_m3m3(tmat,persmat,bmat); + mul_m3_m3m3(cmat,scalemat1,tmat); + mul_m3_m3m3(tmat,persinv,cmat); + mul_m3_m3m3(scalemat1,imat,tmat); - Mat3One(scalemat2); + unit_m3(scalemat2); scalemat2[0][0]/= sqrt(2.0); scalemat2[1][1]/= sqrt(2.0); - Mat3MulMat3(tmat,persmat,bmat); - Mat3MulMat3(cmat,scalemat2,tmat); - Mat3MulMat3(tmat,persinv,cmat); - Mat3MulMat3(scalemat2,imat,tmat); + mul_m3_m3m3(tmat,persmat,bmat); + mul_m3_m3m3(cmat,scalemat2,tmat); + mul_m3_m3m3(tmat,persinv,cmat); + mul_m3_m3m3(scalemat2,imat,tmat); ok= 1; @@ -3216,7 +3216,7 @@ static int spin_nurb(bContext *C, Scene *scene, Object *obedit, float *dvec, sho } } if(dvec) { - Mat3MulVecfl(bmat,dvec); + mul_m3_v3(bmat,dvec); translateflagNurb(editnurb, 1,dvec); } } @@ -3275,8 +3275,8 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) BPoint *bp, *newbp = NULL; float mat[3][3],imat[3][3], temp[3]; - Mat3CpyMat4(mat, obedit->obmat); - Mat3Inv(imat,mat); + copy_m3_m4(mat, obedit->obmat); + invert_m3_m3(imat,mat); findselectedNurbvert(editnurb, &nu, &bezt, &bp); if(bezt==0 && bp==0) return OPERATOR_CANCELLED; @@ -3322,11 +3322,11 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) } else { VECCOPY(newbezt->vec[1], location); - VecSubf(newbezt->vec[1],newbezt->vec[1], obedit->obmat[3]); - Mat3MulVecfl(imat,newbezt->vec[1]); - VecSubf(temp, newbezt->vec[1],temp); - VecAddf(newbezt->vec[0], bezt->vec[0],temp); - VecAddf(newbezt->vec[2], bezt->vec[2],temp); + sub_v3_v3v3(newbezt->vec[1],newbezt->vec[1], obedit->obmat[3]); + mul_m3_v3(imat,newbezt->vec[1]); + sub_v3_v3v3(temp, newbezt->vec[1],temp); + add_v3_v3v3(newbezt->vec[0], bezt->vec[0],temp); + add_v3_v3v3(newbezt->vec[2], bezt->vec[2],temp); calchandlesNurb(nu); } } @@ -3368,8 +3368,8 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) } else { VECCOPY(newbp->vec, location); - VecSubf(newbp->vec, newbp->vec, obedit->obmat[3]); - Mat3MulVecfl(imat,newbp->vec); + sub_v3_v3v3(newbp->vec, newbp->vec, obedit->obmat[3]); + mul_m3_v3(imat,newbp->vec); newbp->vec[3]= 1.0; } } @@ -4633,7 +4633,7 @@ int join_curve_exec(bContext *C, wmOperator *op) tempbase.first= tempbase.last= 0; /* trasnform all selected curves inverse in obact */ - Mat4Invert(imat, ob->obmat); + invert_m4_m4(imat, ob->obmat); CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { if(base->object->type==ob->type) { @@ -4643,7 +4643,7 @@ int join_curve_exec(bContext *C, wmOperator *op) if(cu->nurb.first) { /* watch it: switch order here really goes wrong */ - Mat4MulMat4(cmat, base->object->obmat, imat); + mul_m4_m4m4(cmat, base->object->obmat, imat); nu= cu->nurb.first; while(nu) { @@ -4653,16 +4653,16 @@ int join_curve_exec(bContext *C, wmOperator *op) if( (bezt= newnu->bezt) ) { a= newnu->pntsu; while(a--) { - Mat4MulVecfl(cmat, bezt->vec[0]); - Mat4MulVecfl(cmat, bezt->vec[1]); - Mat4MulVecfl(cmat, bezt->vec[2]); + mul_m4_v3(cmat, bezt->vec[0]); + mul_m4_v3(cmat, bezt->vec[1]); + mul_m4_v3(cmat, bezt->vec[2]); bezt++; } } if( (bp= newnu->bp) ) { a= newnu->pntsu*nu->pntsv; while(a--) { - Mat4MulVecfl(cmat, bp->vec); + mul_m4_v3(cmat, bp->vec); bp++; } } @@ -4716,7 +4716,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) /* imat and center and size */ if(obedit) { - Mat3CpyMat4(mat, obedit->obmat); + copy_m3_m4(mat, obedit->obmat); if(v3d) { curs= give_cursor(scene, v3d); VECCOPY(cent, curs); @@ -4730,16 +4730,16 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) if(rv3d) { if (!newname && (U.flag & USER_ADD_VIEWALIGNED)) - Mat3CpyMat4(imat, rv3d->viewmat); + copy_m3_m4(imat, rv3d->viewmat); else - Mat3One(imat); + unit_m3(imat); - Mat3MulVecfl(imat, cent); - Mat3MulMat3(cmat, imat, mat); - Mat3Inv(imat, cmat); + mul_m3_v3(imat, cent); + mul_m3_m3m3(cmat, imat, mat); + invert_m3_m3(imat, cmat); } else - Mat3One(imat); + unit_m3(imat); setflagsNurb(editnurb, 0); } @@ -4779,7 +4779,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bezt->vec[0][1]+= -0.5*grid; bezt->vec[2][0]+= -0.5*grid; bezt->vec[2][1]+= 0.5*grid; - for(a=0;a<3;a++) Mat3MulVecfl(imat, bezt->vec[a]); + for(a=0;a<3;a++) mul_m3_v3(imat, bezt->vec[a]); bezt++; bezt->h1= bezt->h2= HD_ALIGN; @@ -4790,7 +4790,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) VECCOPY(bezt->vec[a], cent); } bezt->vec[1][0]+= grid; - for(a=0;a<3;a++) Mat3MulVecfl(imat, bezt->vec[a]); + for(a=0;a<3;a++) mul_m3_v3(imat, bezt->vec[a]); calchandlesNurb(nu); } @@ -4821,7 +4821,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bp->vec[0]+= 1.5*grid; bp= nu->bp; - for(a=0;a<4;a++, bp++) Mat3MulVecfl(imat,bp->vec); + for(a=0;a<4;a++, bp++) mul_m3_v3(imat,bp->vec); if(cutype==CU_NURBS) { nu->knotsu= 0; /* makeknots allocates */ @@ -4856,7 +4856,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bp->vec[0]+= 2.0*grid; bp= nu->bp; - for(a=0;a<5;a++, bp++) Mat3MulVecfl(imat,bp->vec); + for(a=0;a<5;a++, bp++) mul_m3_v3(imat,bp->vec); if(cutype==CU_NURBS) { nu->knotsu= 0; /* makeknots allocates */ @@ -4883,7 +4883,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][0]+= -grid; - for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]); + for(a=0;a<3;a++) mul_m3_v3(imat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; bezt++; @@ -4893,7 +4893,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][1]+= grid; - for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]); + for(a=0;a<3;a++) mul_m3_v3(imat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; bezt++; @@ -4903,7 +4903,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][0]+= grid; - for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]); + for(a=0;a<3;a++) mul_m3_v3(imat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; bezt++; @@ -4913,7 +4913,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][1]+= -grid; - for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]); + for(a=0;a<3;a++) mul_m3_v3(imat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; calchandlesNurb(nu); @@ -4940,7 +4940,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) } if(a & 1) bp->vec[3]= 0.25*sqrt(2.0); else bp->vec[3]= 1.0; - Mat3MulVecfl(imat,bp->vec); + mul_m3_v3(imat,bp->vec); bp->radius = bp->weight = 1.0; bp++; @@ -4977,7 +4977,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) if(a==1 || a==2) if(b==1 || b==2) { bp->vec[2]+= grid; } - Mat3MulVecfl(imat,bp->vec); + mul_m3_v3(imat,bp->vec); bp->vec[3]= 1.0; bp++; } @@ -5000,7 +5000,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ vec[0]=vec[1]= 0.0; vec[2]= -grid; - Mat3MulVecfl(imat, vec); + mul_m3_v3(imat, vec); translateflagNurb(editnurb, 1, vec); extrudeflagNurb(editnurb, 1); vec[0]= -2*vec[0]; @@ -5042,7 +5042,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bp->vec[2]+= nurbcircle[a][1]*grid; if(a & 1) bp->vec[3]= 0.5*sqrt(2.0); else bp->vec[3]= 1.0; - Mat3MulVecfl(imat,bp->vec); + mul_m3_v3(imat,bp->vec); bp++; } nu->flagu= 4; diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 6ebc9c8a1c9..b6b0289e871 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_curve_types.h" #include "DNA_object_types.h" @@ -541,7 +541,7 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines) offset[2] = 0; if(rv3d) - Mat4Mul3Vecfl(rv3d->viewinv, offset); + mul_mat3_m4_v3(rv3d->viewinv, offset); txt_add_object(C, line, 1, offset); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index dcd57efa926..9a0187dde04 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -37,7 +37,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_gpencil_types.h" @@ -326,7 +326,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness, /* calculate gradient and normal - 'angle'=(ny/nx) */ m1[1]= s1[1] - s0[1]; m1[0]= s1[0] - s0[0]; - Normalize2(m1); + normalize_v2(m1); m2[1]= -m1[0]; m2[0]= m1[1]; @@ -374,7 +374,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness, /* calculate gradient of bisector (as average of normals) */ mb[0]= (pm[0] + m2[0]) / 2; mb[1]= (pm[1] + m2[1]) / 2; - Normalize2(mb); + normalize_v2(mb); /* calculate gradient to apply * - as basis, use just pthick * bisector gradient @@ -382,7 +382,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness, */ mt[0]= mb[0] * pthick; mt[1]= mb[1] * pthick; - athick= Vec2Length(mt); + athick= len_v2(mt); dfac= pthick - (athick * 2); if ( ((athick * 2) < pthick) && (IS_EQ(athick, pthick)==0) ) { @@ -442,7 +442,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness, } /* store stroke's 'natural' normal for next stroke to use */ - Vec2Copyf(pm, m2); + copy_v2_v2(pm, m2); } glEnd(); diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index beb4ed06810..88ceba88827 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -33,7 +33,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_listBase.h" diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index b25de4d5f1d..4da5ec02ddc 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -32,7 +32,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_gpencil_types.h" diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 6b76c48e1bf..1358ed80f7a 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -37,7 +37,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_listBase.h" @@ -368,7 +368,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi if (gps->flag & GP_STROKE_3DSPACE) { /* directly use 3d-coordinates */ - VecCopyf(p3d, &pt->x); + copy_v3_v3(p3d, &pt->x); } else { float *fp= give_cursor(scene, v3d); @@ -393,7 +393,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi */ project_short_noclip(ar, fp, mval); window_to_3d(ar, dvec, mval[0]-mx, mval[1]-my); - VecSubf(p3d, fp, dvec); + sub_v3_v3v3(p3d, fp, dvec); } } @@ -424,7 +424,7 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur /* get coordinates to add at */ gp_strokepoint_convertcoords(C, gps, pt, p3d); - VecCopyf(bp->vec, p3d); + copy_v3_v3(bp->vec, p3d); /* set settings */ bp->f1= SELECT; @@ -460,9 +460,9 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C gp_strokepoint_convertcoords(C, gps, pt, p3d); /* TODO: maybe in future the handles shouldn't be in same place */ - VecCopyf(bezt->vec[0], p3d); - VecCopyf(bezt->vec[1], p3d); - VecCopyf(bezt->vec[2], p3d); + copy_v3_v3(bezt->vec[0], p3d); + copy_v3_v3(bezt->vec[1], p3d); + copy_v3_v3(bezt->vec[2], p3d); /* set settings */ bezt->h1= bezt->h2= HD_FREE; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 92ae2400666..64e68fab508 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_gpencil.h" #include "BKE_context.h" @@ -169,11 +169,11 @@ static void gp_get_3d_reference (tGPsdata *p, float *vec) /* active Object * - use relative distance of 3D-cursor from object center */ - VecSubf(vec, fp, ob->loc); + sub_v3_v3v3(vec, fp, ob->loc); } else { /* use 3D-cursor */ - VecCopyf(vec, fp); + copy_v3_v3(vec, fp); } } @@ -228,7 +228,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[]) /* method taken from editview.c - mouse_cursor() */ project_short_noclip(p->ar, rvec, mval); window_to_3d_delta(p->ar, dvec, mval[0]-mx, mval[1]-my); - VecSubf(out, rvec, dvec); + sub_v3_v3v3(out, rvec, dvec); } /* 2d - on 'canvas' (assume that p->v2d is set) */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index fcc41e4f533..51c38ee859f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -38,7 +38,7 @@ #include "DNA_texture_types.h" #include "DNA_userdef_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" @@ -988,7 +988,7 @@ static void ui_do_active_linklines(uiBlock *block, short *mval) v3[0]= line->to->x1; v3[1]= (line->to->y1+line->to->y2)/2.0; - fac= PdistVL2Dfl(v1, v2, v3); + fac= dist_to_line_segment_v2(v1, v2, v3); if(fac < mindist) { mindist= fac; act= line; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 59a1933fa4a..a233a84e6c8 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -37,7 +37,7 @@ #include "DNA_texture_types.h" #include "DNA_userdef_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_colortools.h" #include "BKE_texture.h" diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index f085e7054a3..6adee174400 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -38,7 +38,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "PIL_time.h" @@ -2652,7 +2652,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i fp[2]= -sqrt( radsq-dx*dx-dy*dy ); } } - Normalize(fp); + normalize_v3(fp); data->draglastx= mx; data->draglasty= my; @@ -4486,14 +4486,14 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men newp[0]= mx; newp[1]= my; - if(Vec2Lenf(oldp, newp) < 4.0f) + if(len_v2v2(oldp, newp) < 4.0f) return menu->dotowards; closer= 0; - closer |= IsectPT2Df(newp, oldp, p1, p2); - closer |= IsectPT2Df(newp, oldp, p2, p3); - closer |= IsectPT2Df(newp, oldp, p3, p4); - closer |= IsectPT2Df(newp, oldp, p4, p1); + closer |= isect_point_tri_v2(newp, oldp, p1, p2); + closer |= isect_point_tri_v2(newp, oldp, p2, p3); + closer |= isect_point_tri_v2(newp, oldp, p3, p4); + closer |= isect_point_tri_v2(newp, oldp, p4, p1); if(!closer) menu->dotowards= 0; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 90f15d7992e..23a0ff7d223 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -40,7 +40,7 @@ #include "GPU_extensions.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_storage_types.h" diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 20cd6ebf971..e73a4fbe977 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -37,7 +37,7 @@ #include "PIL_time.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index e3b7d173961..388b83cff11 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -35,7 +35,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_ghash.h" diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 5c058889107..2e8d2a8cb2b 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -35,7 +35,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_rect.h" #include "BLI_string.h" diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index a35da38ea66..111f0df6d3d 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -497,7 +497,7 @@ void uiTemplatePathBuilder(uiLayout *layout, bContext *C, PointerRNA *ptr, char #include "UI_resources.h" #include "ED_util.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_listbase.h" #include "ED_object.h" diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 00b72786e68..88a67c25478 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -35,7 +35,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_rect.h" diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 0042ad9483b..5d94fb32438 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -32,7 +32,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_heap.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" @@ -453,7 +453,7 @@ int minmax_tface(Scene *scene, float *min, float *max) me= get_mesh(ob); if(me==0 || me->mtface==0) return ok; - Mat3CpyMat4(bmat, ob->obmat); + copy_m3_m4(bmat, ob->obmat); mv= me->mvert; mf= me->mface; @@ -463,24 +463,24 @@ int minmax_tface(Scene *scene, float *min, float *max) continue; VECCOPY(vec, (mv+mf->v1)->co); - Mat3MulVecfl(bmat, vec); - VecAddf(vec, vec, ob->obmat[3]); + mul_m3_v3(bmat, vec); + add_v3_v3v3(vec, vec, ob->obmat[3]); DO_MINMAX(vec, min, max); VECCOPY(vec, (mv+mf->v2)->co); - Mat3MulVecfl(bmat, vec); - VecAddf(vec, vec, ob->obmat[3]); + mul_m3_v3(bmat, vec); + add_v3_v3v3(vec, vec, ob->obmat[3]); DO_MINMAX(vec, min, max); VECCOPY(vec, (mv+mf->v3)->co); - Mat3MulVecfl(bmat, vec); - VecAddf(vec, vec, ob->obmat[3]); + mul_m3_v3(bmat, vec); + add_v3_v3v3(vec, vec, ob->obmat[3]); DO_MINMAX(vec, min, max); if (mf->v4) { VECCOPY(vec, (mv+mf->v4)->co); - Mat3MulVecfl(bmat, vec); - VecAddf(vec, vec, ob->obmat[3]); + mul_m3_v3(bmat, vec); + add_v3_v3v3(vec, vec, ob->obmat[3]); DO_MINMAX(vec, min, max); } ok= 1; @@ -500,11 +500,11 @@ static float edgetag_cut_cost(EditMesh *em, int e1, int e2, int vert) EditVert *v2 = EM_get_vert_for_index( (eed2->v1->tmp.l == vert)? eed2->v2->tmp.l: eed2->v1->tmp.l ); float cost, d1[3], d2[3]; - cost = VecLenf(v1->co, v->co); - cost += VecLenf(v->co, v2->co); + cost = len_v3v3(v1->co, v->co); + cost += len_v3v3(v->co, v2->co); - VecSubf(d1, v->co, v1->co); - VecSubf(d2, v2->co, v->co); + sub_v3_v3v3(d1, v->co, v1->co); + sub_v3_v3v3(d2, v2->co, v->co); cost = cost + 0.5f*cost*(2.0f - fabs(d1[0]*d2[0] + d1[1]*d2[1] + d1[2]*d2[2])); diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 81d565a9ba4..bdb1df3b5c1 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -49,7 +49,7 @@ #include "DNA_userdef_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_dynstr.h" #include "BLI_rand.h" @@ -411,12 +411,12 @@ EditFace *addfacelist(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *v3, Ed em->totface++; if(efa->v4) { - CalcNormFloat4(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co, efa->n); - CalcCent4f(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); + normal_quad_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); + cent_quad_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); } else { - CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, efa->n); - CalcCent3f(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co); + normal_tri_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co); + cent_tri_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co); } return efa; @@ -614,13 +614,13 @@ static void edge_normal_compare(EditEdge *eed, EditFace *efa1) inp= efa1->n[0]*efa2->n[0] + efa1->n[1]*efa2->n[1] + efa1->n[2]*efa2->n[2]; if(inp<0.999 && inp >-0.999) eed->f2= 1; - if(efa1->v4) CalcCent4f(cent1, efa1->v1->co, efa1->v2->co, efa1->v3->co, efa1->v4->co); - else CalcCent3f(cent1, efa1->v1->co, efa1->v2->co, efa1->v3->co); - if(efa2->v4) CalcCent4f(cent2, efa2->v1->co, efa2->v2->co, efa2->v3->co, efa2->v4->co); - else CalcCent3f(cent2, efa2->v1->co, efa2->v2->co, efa2->v3->co); + if(efa1->v4) cent_quad_v3(cent1, efa1->v1->co, efa1->v2->co, efa1->v3->co, efa1->v4->co); + else cent_tri_v3(cent1, efa1->v1->co, efa1->v2->co, efa1->v3->co); + if(efa2->v4) cent_quad_v3(cent2, efa2->v1->co, efa2->v2->co, efa2->v3->co, efa2->v4->co); + else cent_tri_v3(cent2, efa2->v1->co, efa2->v2->co, efa2->v3->co); - VecSubf(cent1, cent2, cent1); - Normalize(cent1); + sub_v3_v3v3(cent1, cent2, cent1); + normalize_v3(cent1); inp= cent1[0]*efa1->n[0] + cent1[1]*efa1->n[1] + cent1[2]*efa1->n[2]; if(inp < -0.001 ) eed->f1= 1; @@ -1004,7 +1004,7 @@ void load_editMesh(Scene *scene, Object *ob) /* vertex normal */ VECCOPY(nor, eve->no); - VecMulf(nor, 32767.0); + mul_v3_fl(nor, 32767.0); VECCOPY(mvert->no, nor); /* note: it used to remove me->dvert when it was not in use, cancelled diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 5905b2021ea..fbe72a54e70 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -49,7 +49,7 @@ #include "RNA_access.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BKE_context.h" @@ -147,40 +147,40 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) done= 0; for(eed= vc.em->edges.first; eed; eed= eed->next) { if( (eed->v1->f & SELECT)+(eed->v2->f & SELECT) == SELECT ) { - if(eed->v1->f & SELECT) VecSubf(vec, eed->v1->co, eed->v2->co); - else VecSubf(vec, eed->v2->co, eed->v1->co); - VecAddf(nor, nor, vec); + if(eed->v1->f & SELECT) sub_v3_v3v3(vec, eed->v1->co, eed->v2->co); + else sub_v3_v3v3(vec, eed->v2->co, eed->v1->co); + add_v3_v3v3(nor, nor, vec); done= 1; } } - if(done) Normalize(nor); + if(done) normalize_v3(nor); /* center */ - VecAddf(cent, min, max); - VecMulf(cent, 0.5f); + add_v3_v3v3(cent, min, max); + mul_v3_fl(cent, 0.5f); VECCOPY(min, cent); - Mat4MulVecfl(vc.obedit->obmat, min); // view space + mul_m4_v3(vc.obedit->obmat, min); // view space view3d_get_view_aligned_coordinate(&vc, min, event->mval); - Mat4Invert(vc.obedit->imat, vc.obedit->obmat); - Mat4MulVecfl(vc.obedit->imat, min); // back in object space + invert_m4_m4(vc.obedit->imat, vc.obedit->obmat); + mul_m4_v3(vc.obedit->imat, min); // back in object space - VecSubf(min, min, cent); + sub_v3_v3v3(min, min, cent); /* calculate rotation */ - Mat3One(mat); + unit_m3(mat); if(done) { float dot; VECCOPY(vec, min); - Normalize(vec); + normalize_v3(vec); dot= INPR(vec, nor); if( fabs(dot)<0.999) { float cross[3], si, q1[4]; - Crossf(cross, nor, vec); - Normalize(cross); + cross_v3_v3v3(cross, nor, vec); + normalize_v3(cross); dot= 0.5f*saacos(dot); si= (float)sin(dot); q1[0]= (float)cos(dot); @@ -188,7 +188,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) q1[2]= cross[1]*si; q1[3]= cross[2]*si; - QuatToMat3(q1, mat); + quat_to_mat3( mat,q1); } } @@ -207,12 +207,12 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) eve= addvertlist(vc.em, 0, NULL); - Mat3CpyMat4(mat, vc.obedit->obmat); - Mat3Inv(imat, mat); + copy_m3_m4(mat, vc.obedit->obmat); + invert_m3_m3(imat, mat); VECCOPY(eve->co, min); - Mat3MulVecfl(imat, eve->co); - VecSubf(eve->co, eve->co, vc.obedit->obmat[3]); + mul_m3_v3(imat, eve->co); + sub_v3_v3v3(eve->co, eve->co, vc.obedit->obmat[3]); eve->f= SELECT; } @@ -1011,7 +1011,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se vec[0]= dia*phi; vec[1]= - dia; vec[2]= 0.0f; - Mat4MulVecfl(mat,vec); + mul_m4_v3(mat,vec); eve= addvertlist(em, vec, NULL); eve->f= 1+2+4; if (a) { @@ -1022,7 +1022,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se /* extrude and translate */ vec[0]= vec[2]= 0.0; vec[1]= dia*phid; - Mat4Mul3Vecfl(mat, vec); + mul_mat3_m4_v3(mat, vec); for(a=0;averts.first; while(eve) { if(eve->f & SELECT) { - Mat4MulVecfl(mat,eve->co); + mul_m4_v3(mat,eve->co); } eve= eve->next; } @@ -1111,7 +1111,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se eve= em->verts.first; while(eve) { if(eve->f & 2) { - Mat4MulVecfl(mat,eve->co); + mul_m4_v3(mat,eve->co); } eve= eve->next; } @@ -1150,7 +1150,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se /* and now do imat */ for(eve= em->verts.first; eve; eve= eve->next) { if(eve->f & SELECT) { - Mat4MulVecfl(mat,eve->co); + mul_m4_v3(mat,eve->co); } } recalc_editnormals(em); @@ -1170,7 +1170,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se vec[1]= dia*cos(phi); vec[2]= b?depth:-depth; - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); eve= addvertlist(em, vec, NULL); eve->f= SELECT; if(a==0) { @@ -1187,12 +1187,12 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se if(type == PRIM_CONE || (fill && !ELEM(type, PRIM_PLANE, PRIM_CUBE))) { vec[0]= vec[1]= 0.0f; vec[2]= type==PRIM_CONE ? depth : -depth; - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); vdown= addvertlist(em, vec, NULL); if((ext || type==PRIM_CONE) && fill) { vec[0]= vec[1]= 0.0f; vec[2]= type==PRIM_CONE ? -depth : depth; - Mat4MulVecfl(mat,vec); + mul_m4_v3(mat,vec); vtop= addvertlist(em, vec, NULL); } } else { @@ -1281,25 +1281,25 @@ static float new_primitive_matrix(bContext *C, int view_align, float primmat[][4 RegionView3D *rv3d= ED_view3d_context_rv3d(C); float *curs, mat[3][3], vmat[3][3], cmat[3][3], imat[3][3]; - Mat4One(primmat); + unit_m4(primmat); if(rv3d && view_align) { - Mat3CpyMat4(vmat, rv3d->viewmat); + copy_m3_m4(vmat, rv3d->viewmat); } else - Mat3One(vmat); + unit_m3(vmat); /* inverse transform for view and object */ - Mat3CpyMat4(mat, obedit->obmat); - Mat3MulMat3(cmat, vmat, mat); - Mat3Inv(imat, cmat); - Mat4CpyMat3(primmat, imat); + copy_m3_m4(mat, obedit->obmat); + mul_m3_m3m3(cmat, vmat, mat); + invert_m3_m3(imat, cmat); + copy_m4_m3(primmat, imat); /* center */ curs= give_cursor(scene, v3d); VECCOPY(primmat[3], curs); VECSUB(primmat[3], primmat[3], obedit->obmat[3]); - Mat3Inv(imat, mat); - Mat3MulVecfl(imat, primmat[3]); + invert_m3_m3(imat, mat); + mul_m3_v3(imat, primmat[3]); if(v3d) return v3d->grid; return 1.0f; diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index e1b63022dd4..544dd790dc8 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -47,7 +47,7 @@ editmesh_lib: generic (no UI, no menus) operations/evaluators for editmesh data #include "DNA_windowmanager_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BKE_customdata.h" @@ -272,14 +272,14 @@ void EM_editselection_center(float *center, EditSelection *ese) { if (ese->type==EDITVERT) { EditVert *eve= ese->data; - VecCopyf(center, eve->co); + copy_v3_v3(center, eve->co); } else if (ese->type==EDITEDGE) { EditEdge *eed= ese->data; - VecAddf(center, eed->v1->co, eed->v2->co); - VecMulf(center, 0.5); + add_v3_v3v3(center, eed->v1->co, eed->v2->co); + mul_v3_fl(center, 0.5); } else if (ese->type==EDITFACE) { EditFace *efa= ese->data; - VecCopyf(center, efa->cent); + copy_v3_v3(center, efa->cent); } } @@ -287,26 +287,26 @@ void EM_editselection_normal(float *normal, EditSelection *ese) { if (ese->type==EDITVERT) { EditVert *eve= ese->data; - VecCopyf(normal, eve->no); + copy_v3_v3(normal, eve->no); } else if (ese->type==EDITEDGE) { EditEdge *eed= ese->data; float plane[3]; /* need a plane to correct the normal */ float vec[3]; /* temp vec storage */ - VecAddf(normal, eed->v1->no, eed->v2->no); - VecSubf(plane, eed->v2->co, eed->v1->co); + add_v3_v3v3(normal, eed->v1->no, eed->v2->no); + sub_v3_v3v3(plane, eed->v2->co, eed->v1->co); /* the 2 vertex normals will be close but not at rightangles to the edge for rotate about edge we want them to be at right angles, so we need to do some extra colculation to correct the vert normals, we need the plane for this */ - Crossf(vec, normal, plane); - Crossf(normal, plane, vec); - Normalize(normal); + cross_v3_v3v3(vec, normal, plane); + cross_v3_v3v3(normal, plane, vec); + normalize_v3(normal); } else if (ese->type==EDITFACE) { EditFace *efa= ese->data; - VecCopyf(normal, efa->n); + copy_v3_v3(normal, efa->n); } } @@ -321,7 +321,7 @@ void EM_editselection_plane(float *plane, EditSelection *ese) if (ese->prev) { /*use previously selected data to make a usefull vertex plane */ EM_editselection_center(vec, ese->prev); - VecSubf(plane, vec, eve->co); + sub_v3_v3v3(plane, vec, eve->co); } else { /* make a fake plane thats at rightangles to the normal we cant make a crossvec from a vec thats the same as the vec @@ -330,7 +330,7 @@ void EM_editselection_plane(float *plane, EditSelection *ese) if (eve->no[0]<0.5) vec[0]=1; else if (eve->no[1]<0.5) vec[1]=1; else vec[2]=1; - Crossf(plane, eve->no, vec); + cross_v3_v3v3(plane, eve->no, vec); } } else if (ese->type==EDITEDGE) { EditEdge *eed= ese->data; @@ -341,41 +341,41 @@ void EM_editselection_plane(float *plane, EditSelection *ese) (running along the edge).. to flip less often. at least its more pradictable */ if (eed->v2->co[1] > eed->v1->co[1]) /*check which to do first */ - VecSubf(plane, eed->v2->co, eed->v1->co); + sub_v3_v3v3(plane, eed->v2->co, eed->v1->co); else - VecSubf(plane, eed->v1->co, eed->v2->co); + sub_v3_v3v3(plane, eed->v1->co, eed->v2->co); } else if (ese->type==EDITFACE) { EditFace *efa= ese->data; float vec[3]; if (efa->v4) { /*if its a quad- set the plane along the 2 longest edges.*/ float vecA[3], vecB[3]; - VecSubf(vecA, efa->v4->co, efa->v3->co); - VecSubf(vecB, efa->v1->co, efa->v2->co); - VecAddf(plane, vecA, vecB); + sub_v3_v3v3(vecA, efa->v4->co, efa->v3->co); + sub_v3_v3v3(vecB, efa->v1->co, efa->v2->co); + add_v3_v3v3(plane, vecA, vecB); - VecSubf(vecA, efa->v1->co, efa->v4->co); - VecSubf(vecB, efa->v2->co, efa->v3->co); - VecAddf(vec, vecA, vecB); + sub_v3_v3v3(vecA, efa->v1->co, efa->v4->co); + sub_v3_v3v3(vecB, efa->v2->co, efa->v3->co); + add_v3_v3v3(vec, vecA, vecB); /*use the biggest edge length*/ if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]) - VecCopyf(plane, vec); + copy_v3_v3(plane, vec); } else { /*start with v1-2 */ - VecSubf(plane, efa->v1->co, efa->v2->co); + sub_v3_v3v3(plane, efa->v1->co, efa->v2->co); /*test the edge between v2-3, use if longer */ - VecSubf(vec, efa->v2->co, efa->v3->co); + sub_v3_v3v3(vec, efa->v2->co, efa->v3->co); if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]) - VecCopyf(plane, vec); + copy_v3_v3(plane, vec); /*test the edge between v1-3, use if longer */ - VecSubf(vec, efa->v3->co, efa->v1->co); + sub_v3_v3v3(vec, efa->v3->co, efa->v1->co); if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]) - VecCopyf(plane, vec); + copy_v3_v3(plane, vec); } } - Normalize(plane); + normalize_v3(plane); } @@ -908,9 +908,9 @@ void EM_free_data_layer(EditMesh *em, CustomData *data, int type) static void add_normal_aligned(float *nor, float *add) { if( INPR(nor, add) < -0.9999f) - VecSubf(nor, nor, add); + sub_v3_v3v3(nor, nor, add); else - VecAddf(nor, nor, add); + add_v3_v3v3(nor, nor, add); } static void set_edge_directions_f2(EditMesh *em, int val) @@ -1097,7 +1097,7 @@ short extrudeflag_edges_indiv(EditMesh *em, short flag, float *nor) } } } - Normalize(nor); + normalize_v3(nor); /* set correct selection */ EM_clear_flag_all(em, SELECT); @@ -1216,20 +1216,20 @@ static short extrudeflag_edge(Object *obedit, EditMesh *em, short flag, float *n float mtx[4][4]; if (mmd->mirror_ob) { float imtx[4][4]; - Mat4Invert(imtx, mmd->mirror_ob->obmat); - Mat4MulMat4(mtx, obedit->obmat, imtx); + invert_m4_m4(imtx, mmd->mirror_ob->obmat); + mul_m4_m4m4(mtx, obedit->obmat, imtx); } for (eed= em->edges.first; eed; eed= eed->next) { if(eed->f2 == 1) { float co1[3], co2[3]; - VecCopyf(co1, eed->v1->co); - VecCopyf(co2, eed->v2->co); + copy_v3_v3(co1, eed->v1->co); + copy_v3_v3(co2, eed->v2->co); if (mmd->mirror_ob) { - VecMat4MulVecfl(co1, mtx, co1); - VecMat4MulVecfl(co2, mtx, co2); + mul_v3_m4v3(co1, mtx, co1); + mul_v3_m4v3(co2, mtx, co2); } if (mmd->flag & MOD_MIR_AXIS_X) @@ -1380,7 +1380,7 @@ static short extrudeflag_edge(Object *obedit, EditMesh *em, short flag, float *n } } - Normalize(nor); // translation normal grab + normalize_v3(nor); // translation normal grab /* step 7: redo selection */ EM_clear_flag_all(em, SELECT); @@ -1503,20 +1503,20 @@ short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor) float mtx[4][4]; if (mmd->mirror_ob) { float imtx[4][4]; - Mat4Invert(imtx, mmd->mirror_ob->obmat); - Mat4MulMat4(mtx, obedit->obmat, imtx); + invert_m4_m4(imtx, mmd->mirror_ob->obmat); + mul_m4_m4m4(mtx, obedit->obmat, imtx); } for (eed= em->edges.first; eed; eed= eed->next) { if(eed->f2 == 2) { float co1[3], co2[3]; - VecCopyf(co1, eed->v1->co); - VecCopyf(co2, eed->v2->co); + copy_v3_v3(co1, eed->v1->co); + copy_v3_v3(co2, eed->v2->co); if (mmd->mirror_ob) { - VecMat4MulVecfl(co1, mtx, co1); - VecMat4MulVecfl(co2, mtx, co2); + mul_v3_m4v3(co1, mtx, co1); + mul_v3_m4v3(co2, mtx, co2); } if (mmd->flag & MOD_MIR_AXIS_X) @@ -1652,7 +1652,7 @@ short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor) efa= nextvl; } - Normalize(nor); // for grab + normalize_v3(nor); // for grab /* for all vertices with eve->tmp.v!=0 if eve->f1==1: make edge @@ -1704,7 +1704,7 @@ void rotateflag(EditMesh *em, short flag, float *cent, float rotmat[][3]) eve->co[0]-=cent[0]; eve->co[1]-=cent[1]; eve->co[2]-=cent[2]; - Mat3MulVecfl(rotmat,eve->co); + mul_m3_v3(rotmat,eve->co); eve->co[0]+=cent[0]; eve->co[1]+=cent[1]; eve->co[2]+=cent[2]; @@ -1913,24 +1913,24 @@ void recalc_editnormals(EditMesh *em) for(efa= em->faces.first; efa; efa=efa->next) { if(efa->v4) { - CalcNormFloat4(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co, efa->n); - CalcCent4f(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); - VecAddf(efa->v4->no, efa->v4->no, efa->n); + normal_quad_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); + cent_quad_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); + add_v3_v3v3(efa->v4->no, efa->v4->no, efa->n); } else { - CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, efa->n); - CalcCent3f(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co); + normal_tri_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co); + cent_tri_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co); } - VecAddf(efa->v1->no, efa->v1->no, efa->n); - VecAddf(efa->v2->no, efa->v2->no, efa->n); - VecAddf(efa->v3->no, efa->v3->no, efa->n); + add_v3_v3v3(efa->v1->no, efa->v1->no, efa->n); + add_v3_v3v3(efa->v2->no, efa->v2->no, efa->n); + add_v3_v3v3(efa->v3->no, efa->v3->no, efa->n); } /* following Mesh convention; we use vertex coordinate itself for normal in this case */ for(eve= em->verts.first; eve; eve=eve->next) { - if (Normalize(eve->no)==0.0) { + if (normalize_v3(eve->no)==0.0) { VECCOPY(eve->no, eve->co); - Normalize(eve->no); + normalize_v3(eve->no); } } } @@ -1996,8 +1996,8 @@ int convex(float *v1, float *v2, float *v3, float *v4) float nor[3], nor1[3], nor2[3], vec[4][2]; /* define projection, do both trias apart, quad is undefined! */ - CalcNormFloat(v1, v2, v3, nor1); - CalcNormFloat(v1, v3, v4, nor2); + normal_tri_v3( nor1,v1, v2, v3); + normal_tri_v3( nor2,v1, v3, v4); nor[0]= ABS(nor1[0]) + ABS(nor2[0]); nor[1]= ABS(nor1[1]) + ABS(nor2[1]); nor[2]= ABS(nor1[2]) + ABS(nor2[2]); @@ -2022,7 +2022,7 @@ int convex(float *v1, float *v2, float *v3, float *v4) } /* linetests, the 2 diagonals have to instersect to be convex */ - if( IsectLL2Df(vec[0], vec[2], vec[1], vec[3]) > 0 ) return 1; + if( isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0 ) return 1; return 0; } @@ -2037,22 +2037,22 @@ int convex(float *v1, float *v2, float *v3, float *v4) float EM_face_area(EditFace *efa) { - if(efa->v4) return AreaQ3Dfl(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); - else return AreaT3Dfl(efa->v1->co, efa->v2->co, efa->v3->co); + if(efa->v4) return area_quad_v3(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); + else return area_tri_v3(efa->v1->co, efa->v2->co, efa->v3->co); } float EM_face_perimeter(EditFace *efa) { if(efa->v4) return - VecLenf(efa->v1->co, efa->v2->co)+ - VecLenf(efa->v2->co, efa->v3->co)+ - VecLenf(efa->v3->co, efa->v4->co)+ - VecLenf(efa->v4->co, efa->v1->co); + len_v3v3(efa->v1->co, efa->v2->co)+ + len_v3v3(efa->v2->co, efa->v3->co)+ + len_v3v3(efa->v3->co, efa->v4->co)+ + len_v3v3(efa->v4->co, efa->v1->co); else return - VecLenf(efa->v1->co, efa->v2->co)+ - VecLenf(efa->v2->co, efa->v3->co)+ - VecLenf(efa->v3->co, efa->v1->co); + len_v3v3(efa->v1->co, efa->v2->co)+ + len_v3v3(efa->v2->co, efa->v3->co)+ + len_v3v3(efa->v3->co, efa->v1->co); } void EM_fgon_flags(EditMesh *em) @@ -2240,7 +2240,7 @@ UvVertMap *EM_make_uv_vert_map(EditMesh *em, int selected, int do_face_idx_array tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); uv2 = tf->uv[iterv->tfindex]; - Vec2Subf(uvdiff, uv2, uv); + sub_v2_v2v2(uvdiff, uv2, uv); if(fabs(uv[0]-uv2[0]) < limit[0] && fabs(uv[1]-uv2[1]) < limit[1]) { if(lastv) lastv->next= next; diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index 3dc9c81a213..fd665f07767 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -49,7 +49,7 @@ editmesh_loop: tools with own drawing subloops, select, knife, subdiv #include "DNA_windowmanager_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_ghash.h" @@ -672,7 +672,7 @@ static int knife_cut_exec(bContext *C, wmOperator *op) scr = MEM_mallocN(sizeof(float)*2, "Vertex Screen Coordinates"); VECCOPY(co, eve->co); co[3]= 1.0; - Mat4MulVec4fl(obedit->obmat, co); + mul_m4_v4(obedit->obmat, co); project_float(ar, co, scr); BLI_ghash_insert(gh, eve, scr); eve->f1 = 0; /*store vertex intersection flag here*/ diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 737f658d46f..93bfdb37581 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -53,7 +53,7 @@ editmesh_mods.c, UI level access, no geometry changes #include "DNA_view3d_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_rand.h" @@ -488,7 +488,7 @@ static void findnearestedge__doClosest(void *userData, EditEdge *eed, int x0, in v2[0] = x1; v2[1] = y1; - distance= PdistVL2Dfl(data->mval, v1, v2); + distance= dist_to_line_segment_v2(data->mval, v1, v2); if(eed->f & SELECT) distance+=5; if(distance < data->dist) { @@ -499,7 +499,7 @@ static void findnearestedge__doClosest(void *userData, EditEdge *eed, int x0, in vec[0]= eed->v1->co[0] + labda*(eed->v2->co[0] - eed->v1->co[0]); vec[1]= eed->v1->co[1] + labda*(eed->v2->co[1] - eed->v1->co[1]); vec[2]= eed->v1->co[2] + labda*(eed->v2->co[2] - eed->v1->co[2]); - Mat4MulVecfl(data->vc.obedit->obmat, vec); + mul_m4_v3(data->vc.obedit->obmat, vec); if(view3d_test_clipping(data->vc.rv3d, vec)==0) { data->dist = distance; @@ -825,7 +825,7 @@ static int similar_face_select__internal(Scene *scene, EditMesh *em, int mode) float angle; for(efa= em->faces.first; efa; efa= efa->next) { if (!(efa->f & SELECT) && !efa->h) { - angle= RAD2DEG(VecAngle2(base_efa->n, efa->n)); + angle= RAD2DEG(angle_v2v2(base_efa->n, efa->n)); if (angle/180.0<=thresh) { EM_select_face(efa, 1); selcount++; @@ -837,12 +837,12 @@ static int similar_face_select__internal(Scene *scene, EditMesh *em, int mode) } } else if (mode==SIMFACE_COPLANAR) { /* same planer */ float angle, base_dot, dot; - base_dot= Inpf(base_efa->cent, base_efa->n); + base_dot= dot_v3v3(base_efa->cent, base_efa->n); for(efa= em->faces.first; efa; efa= efa->next) { if (!(efa->f & SELECT) && !efa->h) { - angle= RAD2DEG(VecAngle2(base_efa->n, efa->n)); + angle= RAD2DEG(angle_v2v2(base_efa->n, efa->n)); if (angle/180.0<=thresh) { - dot=Inpf(efa->cent, base_efa->n); + dot=dot_v3v3(efa->cent, base_efa->n); if (fabs(base_dot-dot) <= thresh) { EM_select_face(efa, 1); selcount++; @@ -916,7 +916,7 @@ static int similar_edge_select__internal(ToolSettings *ts, EditMesh *em, int mod if (mode==SIMEDGE_LENGTH) { /*store length*/ for(eed= em->edges.first; eed; eed= eed->next) { if (!eed->h) /* dont calc data for hidden edges*/ - eed->tmp.fp= VecLenf(eed->v1->co, eed->v2->co); + eed->tmp.fp= len_v3v3(eed->v1->co, eed->v2->co); } } else if (mode==SIMEDGE_FACE) { /*store face users*/ EditFace *efa; @@ -959,7 +959,7 @@ static int similar_edge_select__internal(ToolSettings *ts, EditMesh *em, int mod else if (eed->f2==0) /* first access, assign the face */ eed->tmp.f= efa; else if (eed->f2==1) /* second, we assign the angle*/ - eed->tmp.fp= RAD2DEG(VecAngle2(eed->tmp.f->n, efa->n))/180; + eed->tmp.fp= RAD2DEG(angle_v2v2(eed->tmp.f->n, efa->n))/180; eed->f2++; /* f2==0 no face assigned. f2==1 one face found. f2==2 angle calculated.*/ } j++; @@ -985,11 +985,11 @@ static int similar_edge_select__internal(ToolSettings *ts, EditMesh *em, int mod } } else if (mode==SIMEDGE_DIR) { /* same direction */ float base_dir[3], dir[3], angle; - VecSubf(base_dir, base_eed->v1->co, base_eed->v2->co); + sub_v3_v3v3(base_dir, base_eed->v1->co, base_eed->v2->co); for(eed= em->edges.first; eed; eed= eed->next) { if (!(eed->f & SELECT) && !eed->h) { - VecSubf(dir, eed->v1->co, eed->v2->co); - angle= RAD2DEG(VecAngle2(base_dir, dir)); + sub_v3_v3v3(dir, eed->v1->co, eed->v2->co); + angle= RAD2DEG(angle_v2v2(base_dir, dir)); if (angle>90) /* use the smallest angle between the edges */ angle= fabs(angle-180.0f); @@ -1161,7 +1161,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) float angle; for(eve= em->verts.first; eve; eve= eve->next) { if (!(eve->f & SELECT) && !eve->h) { - angle= RAD2DEG(VecAngle2(base_eve->no, eve->no)); + angle= RAD2DEG(angle_v2v2(base_eve->no, eve->no)); if (angle/180.0<=thresh) { eve->f |= SELECT; selcount++; @@ -1388,34 +1388,34 @@ void EM_mesh_copy_edge(EditMesh *em, short type) break; case 3: /* copy length */ - eed_len_act = VecLenf(eed_act->v1->co, eed_act->v2->co); + eed_len_act = len_v3v3(eed_act->v1->co, eed_act->v2->co); for(eed=em->edges.first; eed; eed=eed->next) { if (eed->f & SELECT && eed != eed_act) { - eed_len = VecLenf(eed->v1->co, eed->v2->co); + eed_len = len_v3v3(eed->v1->co, eed->v2->co); if (eed_len == eed_len_act) continue; /* if this edge is zero length we cont do anything with it*/ if (eed_len == 0.0f) continue; if (eed_len_act == 0.0f) { - VecAddf(vec_mid, eed->v1->co, eed->v2->co); - VecMulf(vec_mid, 0.5); + add_v3_v3v3(vec_mid, eed->v1->co, eed->v2->co); + mul_v3_fl(vec_mid, 0.5); VECCOPY(eed->v1->co, vec_mid); VECCOPY(eed->v2->co, vec_mid); } else { /* copy the edge length */ - VecAddf(vec_mid, eed->v1->co, eed->v2->co); - VecMulf(vec_mid, 0.5); + add_v3_v3v3(vec_mid, eed->v1->co, eed->v2->co); + mul_v3_fl(vec_mid, 0.5); /* SCALE 1 */ - VecSubf(vec, eed->v1->co, vec_mid); - VecMulf(vec, eed_len_act/eed_len); - VecAddf(eed->v1->co, vec, vec_mid); + sub_v3_v3v3(vec, eed->v1->co, vec_mid); + mul_v3_fl(vec, eed_len_act/eed_len); + add_v3_v3v3(eed->v1->co, vec, vec_mid); /* SCALE 2 */ - VecSubf(vec, eed->v2->co, vec_mid); - VecMulf(vec, eed_len_act/eed_len); - VecAddf(eed->v2->co, vec, vec_mid); + sub_v3_v3v3(vec, eed->v2->co, vec_mid); + mul_v3_fl(vec, eed_len_act/eed_len); + add_v3_v3v3(eed->v2->co, vec, vec_mid); } change = 1; } @@ -3873,7 +3873,7 @@ void righthandfaces(EditMesh *em, int select) /* makes faces righthand turning * while(efa) { if(efa->f1) { - CalcCent3f(cent, efa->v1->co, efa->v2->co, efa->v3->co); + cent_tri_v3(cent, efa->v1->co, efa->v2->co, efa->v3->co); cent[0]= cent[0]*cent[0] + cent[1]*cent[1] + cent[2]*cent[2]; if(cent[0]>maxx) { @@ -3882,7 +3882,7 @@ void righthandfaces(EditMesh *em, int select) /* makes faces righthand turning * tria_nr= 0; } if(efa->v4) { - CalcCent3f(cent, efa->v1->co, efa->v3->co, efa->v4->co); + cent_tri_v3(cent, efa->v1->co, efa->v3->co, efa->v4->co); cent[0]= cent[0]*cent[0] + cent[1]*cent[1] + cent[2]*cent[2]; if(cent[0]>maxx) { @@ -3901,11 +3901,11 @@ void righthandfaces(EditMesh *em, int select) /* makes faces righthand turning * /* set first face correct: calc normal */ if(tria_nr==1) { - CalcNormFloat(startvl->v1->co, startvl->v3->co, startvl->v4->co, nor); - CalcCent3f(cent, startvl->v1->co, startvl->v3->co, startvl->v4->co); + normal_tri_v3( nor,startvl->v1->co, startvl->v3->co, startvl->v4->co); + cent_tri_v3(cent, startvl->v1->co, startvl->v3->co, startvl->v4->co); } else { - CalcNormFloat(startvl->v1->co, startvl->v2->co, startvl->v3->co, nor); - CalcCent3f(cent, startvl->v1->co, startvl->v2->co, startvl->v3->co); + normal_tri_v3( nor,startvl->v1->co, startvl->v2->co, startvl->v3->co); + cent_tri_v3(cent, startvl->v1->co, startvl->v2->co, startvl->v3->co); } /* first normal is oriented this way or the other */ if(select) { @@ -4115,9 +4115,9 @@ void faceselect_align_view_to_selected(View3D *v3d, RegionView3D *rv3d, Mesh *me v3= me->mvert[mf->v3].co; if (mf->v4) { float *v4= me->mvert[mf->v4].co; - CalcNormFloat4(v1, v2, v3, v4, fno); + normal_quad_v3( fno,v1, v2, v3, v4); } else { - CalcNormFloat(v1, v2, v3, fno); + normal_tri_v3( fno,v1, v2, v3); } norm[0]+= fno[0]; @@ -4140,18 +4140,18 @@ static void face_getnormal_obspace(Object *obedit, EditFace *efa, float *fno) float vec[4][3]; VECCOPY(vec[0], efa->v1->co); - Mat4Mul3Vecfl(obedit->obmat, vec[0]); + mul_mat3_m4_v3(obedit->obmat, vec[0]); VECCOPY(vec[1], efa->v2->co); - Mat4Mul3Vecfl(obedit->obmat, vec[1]); + mul_mat3_m4_v3(obedit->obmat, vec[1]); VECCOPY(vec[2], efa->v3->co); - Mat4Mul3Vecfl(obedit->obmat, vec[2]); + mul_mat3_m4_v3(obedit->obmat, vec[2]); if(efa->v4) { VECCOPY(vec[3], efa->v4->co); - Mat4Mul3Vecfl(obedit->obmat, vec[3]); + mul_mat3_m4_v3(obedit->obmat, vec[3]); - CalcNormFloat4(vec[0], vec[1], vec[2], vec[3], fno); + normal_quad_v3( fno,vec[0], vec[1], vec[2], vec[3]); } - else CalcNormFloat(vec[0], vec[1], vec[2], fno); + else normal_tri_v3( fno,vec[0], vec[1], vec[2]); } @@ -4187,7 +4187,7 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, wmOperator *o if (eve->f & SELECT) { if (leve) { float tno[3]; - CalcNormFloat(cent, leve->co, eve->co, tno); + normal_tri_v3( tno,cent, leve->co, eve->co); /* XXX, fixme, should be flipped intp a * consistent direction. -zr @@ -4200,7 +4200,7 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, wmOperator *o } } - Mat4Mul3Vecfl(obedit->obmat, norm); + mul_mat3_m4_v3(obedit->obmat, norm); view3d_align_axis_to_vector(v3d, rv3d, axis, norm); } else if (nselverts==2) { /* Align view to edge (or 2 verts) */ @@ -4217,7 +4217,7 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, wmOperator *o leve= eve; } } - Mat4Mul3Vecfl(obedit->obmat, norm); + mul_mat3_m4_v3(obedit->obmat, norm); view3d_align_axis_to_vector(v3d, rv3d, axis, norm); } else if (nselverts==1) { /* Align view to vert normal */ @@ -4231,7 +4231,7 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, wmOperator *o break; /* we know this is the only selected vert, so no need to keep looking */ } } - Mat4Mul3Vecfl(obedit->obmat, norm); + mul_mat3_m4_v3(obedit->obmat, norm); view3d_align_axis_to_vector(v3d, rv3d, axis, norm); } } @@ -4312,11 +4312,11 @@ static int smooth_vertex(bContext *C, wmOperator *op) if((eed->v1->f & SELECT) && eed->v1->f1<255) { eed->v1->f1++; - VecAddf(eed->v1->tmp.p, eed->v1->tmp.p, fvec); + add_v3_v3v3(eed->v1->tmp.p, eed->v1->tmp.p, fvec); } if((eed->v2->f & SELECT) && eed->v2->f1<255) { eed->v2->f1++; - VecAddf(eed->v2->tmp.p, eed->v2->tmp.p, fvec); + add_v3_v3v3(eed->v2->tmp.p, eed->v2->tmp.p, fvec); } } eed= eed->next; @@ -4435,7 +4435,7 @@ void vertexnoise(Object *obedit, EditMesh *em) vec[1]= 0.2*(b2-BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1]+ofs, eve->co[2])); vec[2]= 0.2*(b2-BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2]+ofs)); - VecAddf(eve->co, eve->co, vec); + add_v3_v3v3(eve->co, eve->co, vec); } else { float tin, dum; @@ -4466,8 +4466,8 @@ void flipface(EditMesh *em, EditFace *efa) EM_data_interp_from_faces(em, efa, NULL, efa, 0, 2, 1, 3); } - if(efa->v4) CalcNormFloat4(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co, efa->n); - else CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, efa->n); + if(efa->v4) normal_quad_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); + else normal_tri_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index cea7ec33d3a..c59fb01ec99 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -58,7 +58,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise #include "RNA_access.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_rand.h" #include "BLI_ghash.h" @@ -150,7 +150,7 @@ static void convert_to_triface(EditMesh *em, int direction) if(efa->v4) { if(efa->f & SELECT) { /* choose shortest diagonal for split */ - fac= VecLenf(efa->v1->co, efa->v3->co) - VecLenf(efa->v2->co, efa->v4->co); + fac= len_v3v3(efa->v1->co, efa->v3->co) - len_v3v3(efa->v2->co, efa->v4->co); /* this makes sure exact squares get split different in both cases */ if( (direction==0 && fac0.0f) ) { efan= EM_face_from_faces(em, efa, NULL, 0, 1, 2, -1); @@ -689,8 +689,8 @@ void extrude_mesh(Scene *scene, Object *obedit, EditMesh *em, wmOperator *op) else { // initTransform(TFM_TRANSLATION, CTX_NO_PET|CTX_NO_MIRROR); if(transmode=='n') { - Mat4MulVecfl(obedit->obmat, nor); - VecSubf(nor, nor, obedit->obmat[3]); + mul_m4_v3(obedit->obmat, nor); + sub_v3_v3v3(nor, nor, obedit->obmat[3]); // BIF_setSingleAxisConstraint(nor, "along normal"); } // Transform(); @@ -816,15 +816,15 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op) dvec[0]= rv3d->persinv[2][0]; dvec[1]= rv3d->persinv[2][1]; dvec[2]= rv3d->persinv[2][2]; - Normalize(dvec); + normalize_v3(dvec); dvec[0]*= offs; dvec[1]*= offs; dvec[2]*= offs; /* base correction */ - Mat3CpyMat4(bmat, obedit->obmat); - Mat3Inv(tmat, bmat); - Mat3MulVecfl(tmat, dvec); + copy_m3_m4(bmat, obedit->obmat); + invert_m3_m3(tmat, bmat); + mul_m3_v3(tmat, dvec); for(a=0; aptr, "center", cent); /* imat and center and size */ - Mat3CpyMat4(bmat, obedit->obmat); - Mat3Inv(imat,bmat); + copy_m3_m4(bmat, obedit->obmat); + invert_m3_m3(imat,bmat); cent[0]-= obedit->obmat[3][0]; cent[1]-= obedit->obmat[3][1]; cent[2]-= obedit->obmat[3][2]; - Mat3MulVecfl(imat, cent); + mul_m3_v3(imat, cent); phi= degr*M_PI/360.0; phi/= steps; if(ts->editbutflag & B_CLOCKWISE) phi= -phi; RNA_float_get_array(op->ptr, "axis", n); - Normalize(n); + normalize_v3(n); q[0]= (float)cos(phi); si= (float)sin(phi); q[1]= n[0]*si; q[2]= n[1]*si; q[3]= n[2]*si; - QuatToMat3(q, cmat); + quat_to_mat3( cmat,q); - Mat3MulMat3(tmat,cmat,bmat); - Mat3MulMat3(bmat,imat,tmat); + mul_m3_m3m3(tmat,cmat,bmat); + mul_m3_m3m3(bmat,imat,tmat); if(dupli==0) if(ts->editbutflag & B_KEEPORIG) @@ -917,7 +917,7 @@ static int spin_mesh(bContext *C, wmOperator *op, float *dvec, int steps, float rotateflag(em, SELECT, cent, bmat); if(dvec) { - Mat3MulVecfl(bmat,dvec); + mul_m3_v3(bmat,dvec); translateflag(em, SELECT, dvec); } } @@ -1362,8 +1362,8 @@ static void alter_co(float *co, EditEdge *edge, float smooth, float fractal, int /* we calculate an offset vector vec1[], to be added to *co */ float len, fac, nor[3], nor1[3], nor2[3]; - VecSubf(nor, edge->v1->co, edge->v2->co); - len= 0.5f*Normalize(nor); + sub_v3_v3v3(nor, edge->v1->co, edge->v2->co); + len= 0.5f*normalize_v3(nor); VECCOPY(nor1, edge->v1->no); VECCOPY(nor2, edge->v2->no); @@ -1394,18 +1394,18 @@ static void alter_co(float *co, EditEdge *edge, float smooth, float fractal, int co[2] += vec1[2]; } else if(beauty & B_SPHERE) { /* subdivide sphere */ - Normalize(co); + normalize_v3(co); co[0]*= smooth; co[1]*= smooth; co[2]*= smooth; } if(beauty & B_FRACTAL) { - fac= fractal*VecLenf(edge->v1->co, edge->v2->co); + fac= fractal*len_v3v3(edge->v1->co, edge->v2->co); vec1[0]= fac*(float)(0.5-BLI_drand()); vec1[1]= fac*(float)(0.5-BLI_drand()); vec1[2]= fac*(float)(0.5-BLI_drand()); - VecAddf(co, co, vec1); + add_v3_v3v3(co, co, vec1); } } @@ -1446,7 +1446,7 @@ static EditVert *subdivide_edge_addvert(EditMesh *em, EditEdge *edge, float smoo ev->no[0] = (edge->v2->no[0]-edge->v1->no[0])*percent + edge->v1->no[0]; ev->no[1] = (edge->v2->no[1]-edge->v1->no[1])*percent + edge->v1->no[1]; ev->no[2] = (edge->v2->no[2]-edge->v1->no[2])*percent + edge->v1->no[2]; - Normalize(ev->no); + normalize_v3(ev->no); return ev; } @@ -1475,11 +1475,11 @@ static void facecopy(EditMesh *em, EditFace *source, EditFace *target) target->flag = source->flag; target->h = source->h; - InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v1->co, w[0]); - InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v2->co, w[1]); - InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v3->co, w[2]); + interp_weights_face_v3( w[0],v1, v2, v3, v4, target->v1->co); + interp_weights_face_v3( w[1],v1, v2, v3, v4, target->v2->co); + interp_weights_face_v3( w[2],v1, v2, v3, v4, target->v3->co); if (target->v4) - InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v4->co, w[3]); + interp_weights_face_v3( w[3],v1, v2, v3, v4, target->v4->co); CustomData_em_interp(&em->fdata, &source->data, NULL, (float*)w, 1, target->data); } @@ -2623,15 +2623,15 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float VECCOPY(v2mat, ef->v2->co); VECCOPY(v3mat, ef->v3->co); VECCOPY(v4mat, ef->v4->co); - Mat4Mul3Vecfl(obedit->obmat, v1mat); - Mat4Mul3Vecfl(obedit->obmat, v2mat); - Mat4Mul3Vecfl(obedit->obmat, v3mat); - Mat4Mul3Vecfl(obedit->obmat, v4mat); + mul_mat3_m4_v3(obedit->obmat, v1mat); + mul_mat3_m4_v3(obedit->obmat, v2mat); + mul_mat3_m4_v3(obedit->obmat, v3mat); + mul_mat3_m4_v3(obedit->obmat, v4mat); - length[0] = VecLenf(v1mat, v2mat); - length[1] = VecLenf(v2mat, v3mat); - length[2] = VecLenf(v3mat, v4mat); - length[3] = VecLenf(v4mat, v1mat); + length[0] = len_v3v3(v1mat, v2mat); + length[1] = len_v3v3(v2mat, v3mat); + length[2] = len_v3v3(v3mat, v4mat); + length[3] = len_v3v3(v4mat, v1mat); sort[0] = ef->e1; sort[1] = ef->e2; sort[2] = ef->e3; @@ -3121,43 +3121,43 @@ static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert minarea, maxarea, areaA, areaB; /*First Test: Normal difference*/ - CalcNormFloat(v1->co, v2->co, v3->co, noA1); - CalcNormFloat(v1->co, v3->co, v4->co, noA2); + normal_tri_v3( noA1,v1->co, v2->co, v3->co); + normal_tri_v3( noA2,v1->co, v3->co, v4->co); if(noA1[0] == noA2[0] && noA1[1] == noA2[1] && noA1[2] == noA2[2]) normalADiff = 0.0; - else normalADiff = RAD2DEG(VecAngle2(noA1, noA2)); + else normalADiff = RAD2DEG(angle_v2v2(noA1, noA2)); //if(!normalADiff) normalADiff = 179; - CalcNormFloat(v2->co, v3->co, v4->co, noB1); - CalcNormFloat(v4->co, v1->co, v2->co, noB2); + normal_tri_v3( noB1,v2->co, v3->co, v4->co); + normal_tri_v3( noB2,v4->co, v1->co, v2->co); if(noB1[0] == noB2[0] && noB1[1] == noB2[1] && noB1[2] == noB2[2]) normalBDiff = 0.0; - else normalBDiff = RAD2DEG(VecAngle2(noB1, noB2)); + else normalBDiff = RAD2DEG(angle_v2v2(noB1, noB2)); //if(!normalBDiff) normalBDiff = 179; measure += (normalADiff/360) + (normalBDiff/360); if(measure > limit) return measure; /*Second test: Colinearity*/ - VecSubf(edgeVec1, v1->co, v2->co); - VecSubf(edgeVec2, v2->co, v3->co); - VecSubf(edgeVec3, v3->co, v4->co); - VecSubf(edgeVec4, v4->co, v1->co); + sub_v3_v3v3(edgeVec1, v1->co, v2->co); + sub_v3_v3v3(edgeVec2, v2->co, v3->co); + sub_v3_v3v3(edgeVec3, v3->co, v4->co); + sub_v3_v3v3(edgeVec4, v4->co, v1->co); diff = 0.0; diff = ( - fabs(RAD2DEG(VecAngle2(edgeVec1, edgeVec2)) - 90) + - fabs(RAD2DEG(VecAngle2(edgeVec2, edgeVec3)) - 90) + - fabs(RAD2DEG(VecAngle2(edgeVec3, edgeVec4)) - 90) + - fabs(RAD2DEG(VecAngle2(edgeVec4, edgeVec1)) - 90)) / 360; + fabs(RAD2DEG(angle_v2v2(edgeVec1, edgeVec2)) - 90) + + fabs(RAD2DEG(angle_v2v2(edgeVec2, edgeVec3)) - 90) + + fabs(RAD2DEG(angle_v2v2(edgeVec3, edgeVec4)) - 90) + + fabs(RAD2DEG(angle_v2v2(edgeVec4, edgeVec1)) - 90)) / 360; if(!diff) return 0.0; measure += diff; if(measure > limit) return measure; /*Third test: Concavity*/ - areaA = AreaT3Dfl(v1->co, v2->co, v3->co) + AreaT3Dfl(v1->co, v3->co, v4->co); - areaB = AreaT3Dfl(v2->co, v3->co, v4->co) + AreaT3Dfl(v4->co, v1->co, v2->co); + areaA = area_tri_v3(v1->co, v2->co, v3->co) + area_tri_v3(v1->co, v3->co, v4->co); + areaB = area_tri_v3(v2->co, v3->co, v4->co) + area_tri_v3(v4->co, v1->co, v2->co); if(areaA <= areaB) minarea = areaA; else minarea = areaB; @@ -4370,9 +4370,9 @@ useless: } if(prop == 0) { - len = VecLenf(upVert->co,downVert->co)*((perc+1)/2); + len = len_v3v3(upVert->co,downVert->co)*((perc+1)/2); if(flip == 1) { - len = VecLenf(upVert->co,downVert->co) - len; + len = len_v3v3(upVert->co,downVert->co) - len; } } @@ -4387,7 +4387,7 @@ useless: } else { - len = MIN2(perc, VecLenf(upVert->co,downVert->co)); + len = MIN2(perc, len_v3v3(upVert->co,downVert->co)); len = MAX2(len, 0); } } @@ -4405,13 +4405,13 @@ useless: tempsv = BLI_ghash_lookup(vertgh,ev); tempev = editedge_getOtherVert((perc>=0)?tempsv->up:tempsv->down, ev); - VecLerpf(ev->co, tempsv->origvert.co, tempev->co, fabs(perc)); + interp_v3_v3v3(ev->co, tempsv->origvert.co, tempev->co, fabs(perc)); if (0) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) { for (uvlay_idx=0; uvlay_idxfuv_list && suv->uv_up && suv->uv_down) { - Vec2Lerpf(uv_tmp, suv->origuv, (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc)); + interp_v2_v2v2(uv_tmp, suv->origuv, (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc)); fuv_link = suv->fuv_list; while (fuv_link) { VECCOPY2D(((float *)fuv_link->link), uv_tmp); @@ -4431,17 +4431,17 @@ useless: float newlen; ev = look->link; tempsv = BLI_ghash_lookup(vertgh,ev); - newlen = (len / VecLenf(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co)); + newlen = (len / len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co)); if(newlen > 1.0) {newlen = 1.0;} if(newlen < 0.0) {newlen = 0.0;} if(flip == 0) { - VecLerpf(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen)); + interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen)); if (0) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) { /* dont do anything if no UVs */ for (uvlay_idx=0; uvlay_idxfuv_list && suv->uv_up && suv->uv_down) { - Vec2Lerpf(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen)); + interp_v2_v2v2(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen)); fuv_link = suv->fuv_list; while (fuv_link) { VECCOPY2D(((float *)fuv_link->link), uv_tmp); @@ -4451,14 +4451,14 @@ useless: } } } else{ - VecLerpf(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen)); + interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen)); if (0) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) { /* dont do anything if no UVs */ for (uvlay_idx=0; uvlay_idxfuv_list && suv->uv_up && suv->uv_down) { - Vec2Lerpf(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen)); + interp_v2_v2v2(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen)); fuv_link = suv->fuv_list; while (fuv_link) { VECCOPY2D(((float *)fuv_link->link), uv_tmp); @@ -4768,7 +4768,7 @@ static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *c mvalf[0]= (float)mval[0]; mvalf[1]= (float)mval[1]; - return PdistVL2Dfl(mvalf, vec1, vec2); + return dist_to_line_segment_v2(mvalf, vec1, vec2); } /* helper for below */ @@ -5120,11 +5120,11 @@ static int blend_from_shape_exec(bContext *C, wmOperator *op) VECCOPY(co, data + eve->keyindex*3); if(add) { - VecMulf(co, blend); - VecAddf(eve->co, eve->co, co); + mul_v3_fl(co, blend); + add_v3_v3v3(eve->co, eve->co, co); } else - VecLerpf(eve->co, eve->co, co, blend); + interp_v3_v3v3(eve->co, eve->co, co, blend); blended= 1; } @@ -5737,7 +5737,7 @@ static void em_snap_to_center(EditMesh *em) for (eve=em->verts.first; eve; eve=eve->next) { if (eve->f & SELECT) { - VecAddf(cent, cent, eve->co); + add_v3_v3v3(cent, cent, eve->co); i++; } } @@ -5745,7 +5745,7 @@ static void em_snap_to_center(EditMesh *em) if (!i) return; - VecMulf(cent, 1.0f / (float)i); + mul_v3_fl(cent, 1.0f / (float)i); for (eve=em->verts.first; eve; eve=eve->next) { if (eve->f & SELECT) { @@ -5762,11 +5762,11 @@ static void em_snap_to_cursor(EditMesh *em, bContext *C) EditVert *eve; float co[3], *vco, invmat[4][4]; - Mat4Invert(invmat, ob->obmat); + invert_m4_m4(invmat, ob->obmat); vco = give_cursor(scene, v3d); VECCOPY(co, vco); - Mat4MulVecfl(invmat, co); + mul_m4_v3(invmat, co); for (eve=em->verts.first; eve; eve=eve->next) { if (eve->f & SELECT) { @@ -5987,7 +5987,7 @@ static int select_vertex_path_exec(bContext *C, wmOperator *op) newpe = MEM_mallocN(sizeof(PathEdge), "Path Edge"); newpe->v = ((PathNode*)eed->v2->tmp.p)->u; if(physical){ - newpe->w = VecLenf(eed->v1->co, eed->v2->co); + newpe->w = len_v3v3(eed->v1->co, eed->v2->co); } else newpe->w = 1; newpe->next = 0; @@ -5999,7 +5999,7 @@ static int select_vertex_path_exec(bContext *C, wmOperator *op) newpe = MEM_mallocN(sizeof(PathEdge), "Path Edge"); newpe->v = ((PathNode*)eed->v1->tmp.p)->u; if(physical){ - newpe->w = VecLenf(eed->v1->co, eed->v2->co); + newpe->w = len_v3v3(eed->v1->co, eed->v2->co); } else newpe->w = 1; newpe->next = 0; @@ -6813,20 +6813,20 @@ static void beauty_fill(EditMesh *em) * the area divided by the total edge lengths */ - len1= VecLenf(v1->co, v2->co); - len2= VecLenf(v2->co, v3->co); - len3= VecLenf(v3->co, v4->co); - len4= VecLenf(v4->co, v1->co); - len5= VecLenf(v1->co, v3->co); - len6= VecLenf(v2->co, v4->co); + len1= len_v3v3(v1->co, v2->co); + len2= len_v3v3(v2->co, v3->co); + len3= len_v3v3(v3->co, v4->co); + len4= len_v3v3(v4->co, v1->co); + len5= len_v3v3(v1->co, v3->co); + len6= len_v3v3(v2->co, v4->co); - opp1= AreaT3Dfl(v1->co, v2->co, v3->co); - opp2= AreaT3Dfl(v1->co, v3->co, v4->co); + opp1= area_tri_v3(v1->co, v2->co, v3->co); + opp2= area_tri_v3(v1->co, v3->co, v4->co); fac1= opp1/(len1+len2+len5) + opp2/(len3+len4+len5); - opp1= AreaT3Dfl(v2->co, v3->co, v4->co); - opp2= AreaT3Dfl(v2->co, v4->co, v1->co); + opp1= area_tri_v3(v2->co, v3->co, v4->co); + opp2= area_tri_v3(v2->co, v4->co, v1->co); fac2= opp1/(len2+len3+len6) + opp2/(len4+len1+len6); diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index f786a4a6c0b..eb6927cec65 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -50,7 +50,7 @@ #include "BKE_mesh.h" #include "BKE_report.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_edgehash.h" @@ -571,7 +571,7 @@ void ED_mesh_transform(Mesh *me, float *mat) MVert *mvert= me->mvert; for(i= 0; i < me->totvert; i++, mvert++) - Mat4MulVecfl((float (*)[4])mat, mvert->co); + mul_m4_v3((float (*)[4])mat, mvert->co); mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); } diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 9f16e7adbf8..ffa9dde4493 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -39,7 +39,7 @@ #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 18125207eca..5313b68be9b 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -51,7 +51,7 @@ #include "DNA_windowmanager_types.h" #include "DNA_world_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_ghash.h" @@ -305,7 +305,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) faceofs= 0; /* inverse transform for all selected meshes in this object */ - Mat4Invert(imat, ob->obmat); + invert_m4_m4(imat, ob->obmat); CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { /* only join if this is a mesh */ @@ -342,11 +342,11 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* if this is the object we're merging into, no need to do anything */ if(base->object != ob) { /* watch this: switch matmul order really goes wrong */ - Mat4MulMat4(cmat, base->object->obmat, imat); + mul_m4_m4m4(cmat, base->object->obmat, imat); /* transform vertex coordinates into new space */ for(a=0, mv=mvert; a < me->totvert; a++, mv++) { - Mat4MulVecfl(cmat, mv->co); + mul_m4_v3(cmat, mv->co); } /* for each shapekey in destination mesh: @@ -366,7 +366,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) fp2= ((float *)(okb->data)); for(a=0; a < me->totvert; a++, fp1+=3, fp2+=3) { VECCOPY(fp1, fp2); - Mat4MulVecfl(cmat, fp1); + mul_m4_v3(cmat, fp1); } } else { @@ -633,15 +633,15 @@ void sort_faces(Scene *scene, View3D *v3d) float cur[3]; if (event == 1) - Mat4MulMat4(mat, OBACT->obmat, rv3d->viewmat); /* apply the view matrix to the object matrix */ + mul_m4_m4m4(mat, OBACT->obmat, rv3d->viewmat); /* apply the view matrix to the object matrix */ else if (event == 2) { /* sort from cursor */ if( v3d && v3d->localvd ) { VECCOPY(cur, v3d->cursor); } else { VECCOPY(cur, scene->cursor); } - Mat4Invert(mat, OBACT->obmat); - Mat4MulVecfl(mat, cur); + invert_m4_m4(mat, OBACT->obmat); + mul_m4_v3(mat, cur); } mf= me->mface; @@ -655,21 +655,21 @@ void sort_faces(Scene *scene, View3D *v3d) else face_sort_floats[i] = reverse; } else { /* find the faces center */ - VecAddf(vec, (me->mvert+mf->v1)->co, (me->mvert+mf->v2)->co); + add_v3_v3v3(vec, (me->mvert+mf->v1)->co, (me->mvert+mf->v2)->co); if (mf->v4) { - VecAddf(vec, vec, (me->mvert+mf->v3)->co); - VecAddf(vec, vec, (me->mvert+mf->v4)->co); - VecMulf(vec, 0.25f); + add_v3_v3v3(vec, vec, (me->mvert+mf->v3)->co); + add_v3_v3v3(vec, vec, (me->mvert+mf->v4)->co); + mul_v3_fl(vec, 0.25f); } else { - VecAddf(vec, vec, (me->mvert+mf->v3)->co); - VecMulf(vec, 1.0f/3.0f); + add_v3_v3v3(vec, vec, (me->mvert+mf->v3)->co); + mul_v3_fl(vec, 1.0f/3.0f); } /* done */ if (event == 1) { /* sort on view axis */ - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); face_sort_floats[i] = vec[2] * reverse; } else { /* distance from cursor*/ - face_sort_floats[i] = VecLenf(cur, vec) * reverse; /* back to front */ + face_sort_floats[i] = len_v3v3(cur, vec) * reverse; /* back to front */ } } } @@ -811,12 +811,12 @@ static intptr_t mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co) /* does mesh verts and editmode, code looks potential dangerous, octree should really be filled OK! */ if(mvert) { vec= (mvert+(*bt)->index[a]-1)->co; - if(FloatCompare(vec, co, MOC_THRESH)) + if(compare_v3v3(vec, co, MOC_THRESH)) return (*bt)->index[a]-1; } else { EditVert *eve= (EditVert *)((*bt)->index[a]); - if(FloatCompare(eve->co, co, MOC_THRESH)) + if(compare_v3v3(eve->co, co, MOC_THRESH)) return (*bt)->index[a]; } } @@ -881,12 +881,12 @@ intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode) MeshOctree.offs[1]-= MOC_THRESH; MeshOctree.offs[2]-= MOC_THRESH; - VecSubf(MeshOctree.div, max, min); + sub_v3_v3v3(MeshOctree.div, max, min); MeshOctree.div[0]+= 2*MOC_THRESH; /* and divide with 2 threshold unit more extra (try 8x8 unit grid on paint) */ MeshOctree.div[1]+= 2*MOC_THRESH; MeshOctree.div[2]+= 2*MOC_THRESH; - VecMulf(MeshOctree.div, 1.0f/MOC_RES); + mul_v3_fl(MeshOctree.div, 1.0f/MOC_RES); if(MeshOctree.div[0]==0.0f) MeshOctree.div[0]= 1.0f; if(MeshOctree.div[1]==0.0f) MeshOctree.div[1]= 1.0f; if(MeshOctree.div[2]==0.0f) MeshOctree.div[2]= 1.0f; diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index f335e47188f..3751f8875f6 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "DNA_meta_types.h" @@ -116,7 +116,7 @@ MetaElem *add_metaball_primitive(bContext *C, int type, int newname) ml= ml->next; } - Mat3CpyMat4(mat, obedit->obmat); + copy_m3_m4(mat, obedit->obmat); if(v3d) { curs= give_cursor(scene, v3d); VECCOPY(cent, curs); @@ -130,16 +130,16 @@ MetaElem *add_metaball_primitive(bContext *C, int type, int newname) if (rv3d) { if (!(newname) || U.flag & USER_ADD_VIEWALIGNED) - Mat3CpyMat4(imat, rv3d->viewmat); + copy_m3_m4(imat, rv3d->viewmat); else - Mat3One(imat); - Mat3MulVecfl(imat, cent); - Mat3MulMat3(cmat, imat, mat); - Mat3Inv(imat,cmat); - Mat3MulVecfl(imat, cent); + unit_m3(imat); + mul_m3_v3(imat, cent); + mul_m3_m3m3(cmat, imat, mat); + invert_m3_m3(imat,cmat); + mul_m3_v3(imat, cent); } else - Mat3One(imat); + unit_m3(imat); ml= MEM_callocN(sizeof(MetaElem), "metaelem"); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 5378ee47f89..61377d76c56 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -46,7 +46,7 @@ #include "DNA_view3d_types.h" #include "DNA_vfont_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_listbase.h" #include "BKE_anim.h" @@ -126,7 +126,7 @@ void ED_object_base_init_from_view(bContext *C, Base *base, int view_align) RegionView3D *rv3d = CTX_wm_region_view3d(C); if(rv3d) { rv3d->viewquat[0]= -rv3d->viewquat[0]; - QuatToEul(rv3d->viewquat, ob->rot); + quat_to_eul( ob->rot,rv3d->viewquat); rv3d->viewquat[0]= -rv3d->viewquat[0]; } } @@ -928,7 +928,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base) ob->disp.first= ob->disp.last= NULL; ob->transflag &= ~OB_DUPLI; - Mat4CpyMat4(ob->obmat, dob->mat); + copy_m4_m4(ob->obmat, dob->mat); ED_object_apply_obmat(ob); } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 35b11571a61..2d98a284df0 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -33,7 +33,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dynstr.h" #include "DNA_action_types.h" @@ -577,7 +577,7 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) float imat[4][4], tmat[4][4]; /* make copy of pchan's original pose-mat (for use later) */ - Mat4CpyMat4(pmat, pchan->pose_mat); + copy_m4_m4(pmat, pchan->pose_mat); /* disable constraint for pose to be solved without it */ cinf= con->enforce; @@ -590,9 +590,9 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) * pchan->pose_mat from the original pchan->pose_mat, thus determining * the effect of the constraint */ - Mat4Invert(imat, pchan->pose_mat); - Mat4MulMat4(tmat, imat, pmat); - Mat4Invert(data->invmat, tmat); + invert_m4_m4(imat, pchan->pose_mat); + mul_m4_m4m4(tmat, imat, pmat); + invert_m4_m4(data->invmat, tmat); /* recalculate pose with new inv-mat */ con->enforce= cinf; @@ -604,10 +604,10 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) * NOTE: what_does_parent uses a static workob defined in object.c */ what_does_parent(scene, ob, &workob); - Mat4Invert(data->invmat, workob.obmat); + invert_m4_m4(data->invmat, workob.obmat); } else - Mat4One(data->invmat); + unit_m4(data->invmat); WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); @@ -637,7 +637,7 @@ static int childof_clear_inverse_exec (bContext *C, wmOperator *op) bChildOfConstraint *data= (bChildOfConstraint *)con->data; /* simply clear the matrix */ - Mat4One(data->invmat); + unit_m4(data->invmat); WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); @@ -1052,9 +1052,9 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o * if adding a target for an IK Constraint */ if (con_type == CONSTRAINT_TYPE_KINEMATIC) - VecMat4MulVecfl(obt->loc, obact->obmat, pchanact->pose_tail); + mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_tail); else - VecMat4MulVecfl(obt->loc, obact->obmat, pchanact->pose_head); + mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_head); } else VECCOPY(obt->loc, obact->obmat[3]); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0cfdd914222..7bb345bf46c 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -67,7 +67,7 @@ #include "DNA_modifier_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_ghash.h" #include "BLI_rand.h" @@ -161,16 +161,16 @@ void ED_object_apply_obmat(Object *ob) /* from obmat to loc rot size */ if(ob==NULL) return; - Mat3CpyMat4(mat, ob->obmat); + copy_m3_m4(mat, ob->obmat); VECCOPY(ob->loc, ob->obmat[3]); - Mat3ToEul(mat, ob->rot); - EulToMat3(ob->rot, tmat); + mat3_to_eul( ob->rot,mat); + eul_to_mat3( tmat,ob->rot); - Mat3Inv(imat, tmat); + invert_m3_m3(imat, tmat); - Mat3MulMat3(tmat, imat, mat); + mul_m3_m3m3(tmat, imat, mat); ob->size[0]= tmat[0][0]; ob->size[1]= tmat[1][1]; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 22a6329a097..91aebc8b149 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -30,7 +30,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_listbase.h" #include "BLI_string.h" @@ -77,12 +77,12 @@ static int return_editmesh_indexar(EditMesh *em, int *tot, int **indexar, float for(eve= em->verts.first; eve; eve= eve->next) { if(eve->f & SELECT) { *index= nr; index++; - VecAddf(cent, cent, eve->co); + add_v3_v3v3(cent, cent, eve->co); } nr++; } - VecMulf(cent, 1.0f/(float)totvert); + mul_v3_fl(cent, 1.0f/(float)totvert); return totvert; } @@ -105,7 +105,7 @@ static int return_editmesh_vgroup(Object *obedit, EditMesh *em, char *name, floa for(i=0; itotweight; i++){ if(dvert->dw[i].def_nr == (obedit->actdef-1)) { totvert++; - VecAddf(cent, cent, eve->co); + add_v3_v3v3(cent, cent, eve->co); } } } @@ -113,7 +113,7 @@ static int return_editmesh_vgroup(Object *obedit, EditMesh *em, char *name, floa if(totvert) { bDeformGroup *defGroup = BLI_findlink(&obedit->defbase, obedit->actdef-1); strcpy(name, defGroup->name); - VecMulf(cent, 1.0f/(float)totvert); + mul_v3_fl(cent, 1.0f/(float)totvert); return 1; } } @@ -170,14 +170,14 @@ static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar if(bp->f1 & SELECT) { if(bp->hide==0) { *index= nr; index++; - VecAddf(cent, cent, bp->vec); + add_v3_v3v3(cent, cent, bp->vec); } } bp++; nr++; } - VecMulf(cent, 1.0f/(float)totvert); + mul_v3_fl(cent, 1.0f/(float)totvert); return totvert; } @@ -243,17 +243,17 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo while(a--) { if(bezt->f1 & SELECT) { *index= nr; index++; - VecAddf(cent, cent, bezt->vec[0]); + add_v3_v3v3(cent, cent, bezt->vec[0]); } nr++; if(bezt->f2 & SELECT) { *index= nr; index++; - VecAddf(cent, cent, bezt->vec[1]); + add_v3_v3v3(cent, cent, bezt->vec[1]); } nr++; if(bezt->f3 & SELECT) { *index= nr; index++; - VecAddf(cent, cent, bezt->vec[2]); + add_v3_v3v3(cent, cent, bezt->vec[2]); } nr++; bezt++; @@ -265,7 +265,7 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo while(a--) { if(bp->f1 & SELECT) { *index= nr; index++; - VecAddf(cent, cent, bp->vec); + add_v3_v3v3(cent, cent, bp->vec); } nr++; bp++; @@ -273,7 +273,7 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo } } - VecMulf(cent, 1.0f/(float)totvert); + mul_v3_fl(cent, 1.0f/(float)totvert); return totvert; } @@ -465,7 +465,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode) ob->lay= newbase->lay; /* transform cent to global coords for loc */ - VecMat4MulVecfl(ob->loc, obedit->obmat, cent); + mul_v3_m4v3(ob->loc, obedit->obmat, cent); /* restore, add_object sets active */ BASACT= base; @@ -489,7 +489,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode) hmd->object= ob; hmd->indexar= indexar; - VecCopyf(hmd->cent, cent); + copy_v3_v3(hmd->cent, cent); hmd->totindex= tot; BLI_strncpy(hmd->name, name, 32); @@ -501,9 +501,9 @@ void add_hook(Scene *scene, View3D *v3d, int mode) where_is_object(scene, ob); - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); /* apparently this call goes from right to left... */ - Mat4MulSerie(hmd->parentinv, ob->imat, obedit->obmat, NULL, + mul_serie_m4(hmd->parentinv, ob->imat, obedit->obmat, NULL, NULL, NULL, NULL, NULL, NULL); } } @@ -520,9 +520,9 @@ void add_hook(Scene *scene, View3D *v3d, int mode) // FIXME: this is now OBJECT_OT_hook_reset operator where_is_object(scene, ob); /* ob is hook->parent */ - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); /* this call goes from right to left... */ - Mat4MulSerie(hmd->parentinv, ob->imat, obedit->obmat, NULL, + mul_serie_m4(hmd->parentinv, ob->imat, obedit->obmat, NULL, NULL, NULL, NULL, NULL, NULL); } @@ -577,8 +577,8 @@ void hookmenu(Scene *scene, View3D *v3d) if (event==1) { if(hmd->object) { - Mat4Invert(hmd->object->imat, hmd->object->obmat); - Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); + invert_m4_m4(hmd->object->imat, hmd->object->obmat); + mul_serie_m4(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); changed= 1; DAG_id_flush_update(&ob->id, OB_RECALC_DATA); @@ -589,14 +589,14 @@ void hookmenu(Scene *scene, View3D *v3d) where_is_object(scene, ob); - Mat3CpyMat4(bmat, ob->obmat); - Mat3Inv(imat, bmat); + copy_m3_m4(bmat, ob->obmat); + invert_m3_m3(imat, bmat); curs= give_cursor(scene, v3d); hmd->cent[0]= curs[0]-ob->obmat[3][0]; hmd->cent[1]= curs[1]-ob->obmat[3][1]; hmd->cent[2]= curs[2]-ob->obmat[3][2]; - Mat3MulVecfl(imat, hmd->cent); + mul_m3_v3(imat, hmd->cent); changed= 1; DAG_id_flush_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 0683cb6842f..f3588a91984 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -40,7 +40,7 @@ #include "DNA_object_force.h" #include "DNA_scene_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_listbase.h" #include "BKE_action.h" @@ -841,14 +841,14 @@ static int hook_reset_exec(bContext *C, wmOperator *op) float imat[4][4], mat[4][4]; /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */ - Mat4MulMat4(mat, pchan->pose_mat, hmd->object->obmat); + mul_m4_m4m4(mat, pchan->pose_mat, hmd->object->obmat); - Mat4Invert(imat, mat); - Mat4MulSerie(hmd->parentinv, imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); + invert_m4_m4(imat, mat); + mul_serie_m4(hmd->parentinv, imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); } else { - Mat4Invert(hmd->object->imat, hmd->object->obmat); - Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); + invert_m4_m4(hmd->object->imat, hmd->object->obmat); + mul_serie_m4(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); } } @@ -879,11 +879,11 @@ static int hook_recenter_exec(bContext *C, wmOperator *op) HookModifierData *hmd= ptr.data; float bmat[3][3], imat[3][3]; - Mat3CpyMat4(bmat, ob->obmat); - Mat3Inv(imat, bmat); + copy_m3_m4(bmat, ob->obmat); + invert_m3_m3(imat, bmat); VECSUB(hmd->cent, scene->cursor, ob->obmat[3]); - Mat3MulVecfl(imat, hmd->cent); + mul_m3_v3(imat, hmd->cent); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index ccb6e8cdea3..75a95323ce1 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -39,7 +39,7 @@ #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_context.h" diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index cbd1e1be8d5..95b874e7145 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -48,7 +48,7 @@ #include "DNA_view3d_types.h" #include "DNA_world_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_listbase.h" #include "BLI_string.h" @@ -221,7 +221,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) /* inverse parent matrix */ what_does_parent(scene, ob, &workob); - Mat4Invert(ob->parentinv, workob.obmat); + invert_m4_m4(ob->parentinv, workob.obmat); } else { ob->partype= PARVERT1; @@ -229,7 +229,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) /* inverse parent matrix */ what_does_parent(scene, ob, &workob); - Mat4Invert(ob->parentinv, workob.obmat); + invert_m4_m4(ob->parentinv, workob.obmat); } } } @@ -451,7 +451,7 @@ static int parent_clear_exec(bContext *C, wmOperator *op) ED_object_apply_obmat(ob); } else if(type == 2) - Mat4One(ob->parentinv); + unit_m4(ob->parentinv); ob->recalc |= OB_RECALC; } @@ -617,7 +617,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) add_constraint_to_object(con, ob); get_constraint_target_matrix(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra - give_timeoffset(ob)); - VecSubf(vec, ob->obmat[3], cmat[3]); + sub_v3_v3v3(vec, ob->obmat[3], cmat[3]); ob->loc[0] = vec[0]; ob->loc[1] = vec[1]; @@ -637,12 +637,12 @@ static int parent_set_exec(bContext *C, wmOperator *op) ob->partype= PARSKEL; - Mat4Invert(ob->parentinv, workob.obmat); + invert_m4_m4(ob->parentinv, workob.obmat); } else { /* calculate inverse parent matrix */ what_does_parent(scene, ob, &workob); - Mat4Invert(ob->parentinv, workob.obmat); + invert_m4_m4(ob->parentinv, workob.obmat); } ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA; @@ -734,7 +734,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) } else { /* clear inverse matrix and also the object location */ - Mat4One(ob->parentinv); + unit_m4(ob->parentinv); memset(ob->loc, 0, 3*sizeof(float)); /* set recalc flags */ diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 47730496296..20f3ea3df9e 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -40,7 +40,7 @@ #include "DNA_scene_types.h" #include "DNA_texture_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_rand.h" #include "BLI_string.h" @@ -524,7 +524,7 @@ static short select_grouped_color(bContext *C, Object *ob) char changed = 0; CTX_DATA_BEGIN(C, Base*, base, selectable_bases) { - if (!(base->flag & SELECT) && (FloatCompare(base->object->col, ob->col, 0.005f))) { + if (!(base->flag & SELECT) && (compare_v3v3(base->object->col, ob->col, 0.005f))) { ED_base_object_select(base, BA_SELECT); changed = 1; } diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index f52927a1a00..878c61aac48 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_action_types.h" #include "DNA_curve_types.h" diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 0c09e0a03de..48db13c0709 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -38,7 +38,7 @@ #include "DNA_screen_types.h" #include "DNA_view3d_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_listbase.h" @@ -159,10 +159,10 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) if (ob->rotmode == ROT_MODE_QUAT) { QUATCOPY(quat1, ob->quat); - QuatToEul(ob->quat, oldeul); + quat_to_eul( oldeul,ob->quat); } else if (ob->rotmode == ROT_MODE_AXISANGLE) { - AxisAngleToEulO(ob->rotAxis, ob->rotAngle, oldeul, EULER_ORDER_DEFAULT); + axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,ob->rotAxis, ob->rotAngle); } else { VECCOPY(oldeul, ob->rot); @@ -178,14 +178,14 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) eul[2]= oldeul[2]; if (ob->rotmode == ROT_MODE_QUAT) { - EulToQuat(eul, ob->quat); + eul_to_quat( ob->quat,eul); /* quaternions flip w sign to accumulate rotations correctly */ if ((quat1[0]<0.0f && ob->quat[0]>0.0f) || (quat1[0]>0.0f && ob->quat[0]<0.0f)) { - QuatMulf(ob->quat, -1.0f); + mul_qt_fl(ob->quat, -1.0f); } } else if (ob->rotmode == ROT_MODE_AXISANGLE) { - EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, ob->rotAxis, &ob->rotAngle); + eulO_to_axis_angle( ob->rotAxis, &ob->rotAngle,eul, EULER_ORDER_DEFAULT); } else { VECCOPY(ob->rot, eul); @@ -290,12 +290,12 @@ static int object_origin_clear_exec(bContext *C, wmOperator *op) v1= ob->loc; v3= ob->parentinv[3]; - Mat3CpyMat4(mat, ob->parentinv); + copy_m3_m4(mat, ob->parentinv); VECCOPY(v3, v1); v3[0]= -v3[0]; v3[1]= -v3[1]; v3[2]= -v3[2]; - Mat3MulVecfl(mat, v3); + mul_m3_v3(mat, v3); } ob->recalc |= OB_RECALC_OB; } @@ -338,7 +338,7 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob ) if(ob_child->parent == ob) { ED_object_apply_obmat(ob_child); what_does_parent(scene, ob_child, &workob); - Mat4Invert(ob_child->parentinv, workob.obmat); + invert_m4_m4(ob_child->parentinv, workob.obmat); } } } @@ -402,20 +402,20 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo else if(apply_rot) object_rot_to_mat3(ob, rsmat); else - Mat3One(rsmat); + unit_m3(rsmat); - Mat4CpyMat3(mat, rsmat); + copy_m4_m3(mat, rsmat); /* calculate translation */ if(apply_loc) { - VecCopyf(mat[3], ob->loc); + copy_v3_v3(mat[3], ob->loc); if(!(apply_scale && apply_rot)) { /* correct for scale and rotation that is still applied */ object_to_mat3(ob, obmat); - Mat3Inv(iobmat, obmat); - Mat3MulMat3(tmat, rsmat, iobmat); - Mat3MulVecfl(tmat, mat[3]); + invert_m3_m3(iobmat, obmat); + mul_m3_m3m3(tmat, rsmat, iobmat); + mul_m3_v3(tmat, mat[3]); } } @@ -426,7 +426,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo /* adjust data */ mvert= me->mvert; for(a=0; atotvert; a++, mvert++) - Mat4MulVecfl(mat, mvert->co); + mul_m4_v3(mat, mvert->co); if(me->key) { KeyBlock *kb; @@ -435,7 +435,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo float *fp= kb->data; for(a=0; atotelem; a++, fp+=3) - Mat4MulVecfl(mat, fp); + mul_m4_v3(mat, fp); } } @@ -448,15 +448,15 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { cu= ob->data; - scale = Mat3ToScalef(rsmat); + scale = mat3_to_scale(rsmat); for(nu=cu->nurb.first; nu; nu=nu->next) { if(nu->type == CU_BEZIER) { a= nu->pntsu; for(bezt= nu->bezt; a--; bezt++) { - Mat4MulVecfl(mat, bezt->vec[0]); - Mat4MulVecfl(mat, bezt->vec[1]); - Mat4MulVecfl(mat, bezt->vec[2]); + mul_m4_v3(mat, bezt->vec[0]); + mul_m4_v3(mat, bezt->vec[1]); + mul_m4_v3(mat, bezt->vec[2]); bezt->radius *= scale; bezt++; } @@ -464,7 +464,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo else { a= nu->pntsu*nu->pntsv; for(bp= nu->bp; a--; bp++) - Mat4MulVecfl(mat, bp->vec); + mul_m4_v3(mat, bp->vec); } } } @@ -503,8 +503,8 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *op) where_is_object(scene, ob); VECCOPY(ob->loc, ob->obmat[3]); - Mat4ToSize(ob->obmat, ob->size); - Mat4ToEul(ob->obmat, ob->rot); + mat4_to_size( ob->size,ob->obmat); + mat4_to_eul( ob->rot,ob->obmat); where_is_object(scene, ob); @@ -709,7 +709,7 @@ static int object_center_set_exec(bContext *C, wmOperator *op) } if(v3d->around==V3D_CENTROID) { - VecMulf(cent, 1.0f/(float)total); + mul_v3_fl(cent, 1.0f/(float)total); } else { cent[0]= (min[0]+max[0])/2.0f; @@ -718,7 +718,7 @@ static int object_center_set_exec(bContext *C, wmOperator *op) } for(eve= em->verts.first; eve; eve= eve->next) { - VecSubf(eve->co, eve->co, cent); + sub_v3_v3v3(eve->co, eve->co, cent); } recalc_editnormals(em); @@ -748,8 +748,8 @@ static int object_center_set_exec(bContext *C, wmOperator *op) } else { if(centermode==2) { VECCOPY(cent, give_cursor(scene, v3d)); - Mat4Invert(ob->imat, ob->obmat); - Mat4MulVecfl(ob->imat, cent); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_v3(ob->imat, cent); } else { INIT_MINMAX(min, max); mvert= me->mvert; @@ -764,7 +764,7 @@ static int object_center_set_exec(bContext *C, wmOperator *op) mvert= me->mvert; for(a=0; atotvert; a++, mvert++) { - VecSubf(mvert->co, mvert->co, cent); + sub_v3_v3v3(mvert->co, mvert->co, cent); } if (me->key) { @@ -773,7 +773,7 @@ static int object_center_set_exec(bContext *C, wmOperator *op) float *fp= kb->data; for (a=0; atotelem; a++, fp+=3) { - VecSubf(fp, fp, cent); + sub_v3_v3v3(fp, fp, cent); } } } @@ -781,10 +781,10 @@ static int object_center_set_exec(bContext *C, wmOperator *op) me->flag |= ME_ISDONE; if(centermode) { - Mat3CpyMat4(omat, ob->obmat); + copy_m3_m4(omat, ob->obmat); VECCOPY(centn, cent); - Mat3MulVecfl(omat, centn); + mul_m3_v3(omat, centn); ob->loc[0]+= centn[0]; ob->loc[1]+= centn[1]; ob->loc[2]+= centn[2]; @@ -802,9 +802,9 @@ static int object_center_set_exec(bContext *C, wmOperator *op) ob_other->flag |= OB_DONE; ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA; - Mat3CpyMat4(omat, ob_other->obmat); + copy_m3_m4(omat, ob_other->obmat); VECCOPY(centn, cent); - Mat3MulVecfl(omat, centn); + mul_m3_v3(omat, centn); ob_other->loc[0]+= centn[0]; ob_other->loc[1]+= centn[1]; ob_other->loc[2]+= centn[2]; @@ -815,7 +815,7 @@ static int object_center_set_exec(bContext *C, wmOperator *op) if(tme && (tme->flag & ME_ISDONE)==0) { mvert= tme->mvert; for(a=0; atotvert; a++, mvert++) { - VecSubf(mvert->co, mvert->co, cent); + sub_v3_v3v3(mvert->co, mvert->co, cent); } if (tme->key) { @@ -824,7 +824,7 @@ static int object_center_set_exec(bContext *C, wmOperator *op) float *fp= kb->data; for (a=0; atotelem; a++, fp+=3) { - VecSubf(fp, fp, cent); + sub_v3_v3v3(fp, fp, cent); } } } @@ -858,8 +858,8 @@ static int object_center_set_exec(bContext *C, wmOperator *op) } else { if(centermode==2) { VECCOPY(cent, give_cursor(scene, v3d)); - Mat4Invert(ob->imat, ob->obmat); - Mat4MulVecfl(ob->imat, cent); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_v3(ob->imat, cent); /* don't allow Z change if curve is 2D */ if( !( cu->flag & CU_3D ) ) @@ -884,23 +884,23 @@ static int object_center_set_exec(bContext *C, wmOperator *op) if(nu->type == CU_BEZIER) { a= nu->pntsu; while (a--) { - VecSubf(nu->bezt[a].vec[0], nu->bezt[a].vec[0], cent); - VecSubf(nu->bezt[a].vec[1], nu->bezt[a].vec[1], cent); - VecSubf(nu->bezt[a].vec[2], nu->bezt[a].vec[2], cent); + sub_v3_v3v3(nu->bezt[a].vec[0], nu->bezt[a].vec[0], cent); + sub_v3_v3v3(nu->bezt[a].vec[1], nu->bezt[a].vec[1], cent); + sub_v3_v3v3(nu->bezt[a].vec[2], nu->bezt[a].vec[2], cent); } } else { a= nu->pntsu*nu->pntsv; while (a--) - VecSubf(nu->bp[a].vec, nu->bp[a].vec, cent); + sub_v3_v3v3(nu->bp[a].vec, nu->bp[a].vec, cent); } nu= nu->next; } if(centermode && obedit==NULL) { - Mat3CpyMat4(omat, ob->obmat); + copy_m3_m4(omat, ob->obmat); - Mat3MulVecfl(omat, cent); + mul_m3_v3(omat, cent); ob->loc[0]+= cent[0]; ob->loc[1]+= cent[1]; ob->loc[2]+= cent[2]; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 75c56575474..b5007ff72ce 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -60,7 +60,7 @@ #include "BKE_utildefines.h" #include "BKE_pointcache.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_kdtree.h" @@ -587,13 +587,13 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected if(pset->selectmode==SCE_SELECT_PATH) selected= 0; - Mat4One(imat); - Mat4One(mat); + unit_m4(imat); + unit_m4(mat); LOOP_VISIBLE_POINTS { if(edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(data->ob, psmd->dm, psys->part->from, psys->particles + p, mat); - Mat4Invert(imat,mat); + invert_m4_m4(imat,mat); } if(pset->selectmode==SCE_SELECT_END) { @@ -698,7 +698,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) key = pa->hair; psys_mat_hair_to_orco(ob, psmd->dm, psys->part->from, pa, mat); VECCOPY(co, key->co); - Mat4MulVecfl(mat, co); + mul_m4_v3(mat, co); BLI_kdtree_insert(tree, p, co, NULL); } @@ -712,7 +712,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) key = pa->hair; psys_mat_hair_to_orco(ob, psmd->dm, psys->part->from, pa, mat); VECCOPY(co, key->co); - Mat4MulVecfl(mat, co); + mul_m4_v3(mat, co); co[0]= -co[0]; index= BLI_kdtree_find_nearest(tree, co, NULL, &nearest); @@ -785,7 +785,7 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys /* mirror positions and tags */ psys_mat_hair_to_orco(ob, dm, psys->part->from, pa, mat); psys_mat_hair_to_orco(ob, dm, psys->part->from, mpa, mmat); - Mat4Invert(immat, mmat); + invert_m4_m4(immat, mmat); hkey=pa->hair; mhkey=mpa->hair; @@ -793,9 +793,9 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys mkey= mpoint->keys; for(k=0; ktotkey; k++, hkey++, mhkey++, key++, mkey++) { VECCOPY(mhkey->co, hkey->co); - Mat4MulVecfl(mat, mhkey->co); + mul_m4_v3(mat, mhkey->co); mhkey->co[0]= -mhkey->co[0]; - Mat4MulVecfl(immat, mhkey->co); + mul_m4_v3(immat, mhkey->co); if(key->flag & PEK_TAG) mkey->flag |= PEK_TAG; @@ -867,12 +867,12 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) psys_mat_hair_to_object(ob, psmd->dm, psys->part->from, psys->particles + p, hairmat); LOOP_KEYS { - Mat4MulVecfl(hairmat, key->co); + mul_m4_v3(hairmat, key->co); } LOOP_KEYS { if(k==0) { - dist_1st = VecLenf((key+1)->co, key->co); + dist_1st = len_v3v3((key+1)->co, key->co); dist_1st *= 0.75f * pset->emitterdist; } else { @@ -881,32 +881,32 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) vec=edit->emitter_cosnos +index*6; nor=vec+3; - VecSubf(dvec, key->co, vec); + sub_v3_v3v3(dvec, key->co, vec); - dot=Inpf(dvec,nor); + dot=dot_v3v3(dvec,nor); VECCOPY(dvec,nor); if(dot>0.0f) { if(dotco,key->co,dvec); + normalize_v3(dvec); + mul_v3_fl(dvec,dist_1st-dot); + add_v3_v3v3(key->co,key->co,dvec); } } else { - Normalize(dvec); - VecMulf(dvec,dist_1st-dot); - VecAddf(key->co,key->co,dvec); + normalize_v3(dvec); + mul_v3_fl(dvec,dist_1st-dot); + add_v3_v3v3(key->co,key->co,dvec); } if(k==1) dist_1st*=1.3333f; } } - Mat4Invert(hairimat,hairmat); + invert_m4_m4(hairimat,hairmat); LOOP_KEYS { - Mat4MulVecfl(hairimat, key->co); + mul_m4_v3(hairimat, key->co); } } } @@ -927,10 +927,10 @@ void PE_apply_lengths(Scene *scene, PTCacheEdit *edit) LOOP_EDITED_POINTS { LOOP_KEYS { if(k) { - VecSubf(dv1, key->co, (key - 1)->co); - Normalize(dv1); - VecMulf(dv1, (key - 1)->length); - VecAddf(key->co, (key - 1)->co, dv1); + sub_v3_v3v3(dv1, key->co, (key - 1)->co); + normalize_v3(dv1); + mul_v3_fl(dv1, (key - 1)->length); + add_v3_v3v3(key->co, (key - 1)->co, dv1); } } } @@ -970,19 +970,19 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit) for(; ktotkey; k++, key++) { if(k) { - VecSubf(dv0, (key - 1)->co, key->co); - tlen= Normalize(dv0); - VecMulf(dv0, (mul * (tlen - (key - 1)->length))); + sub_v3_v3v3(dv0, (key - 1)->co, key->co); + tlen= normalize_v3(dv0); + mul_v3_fl(dv0, (mul * (tlen - (key - 1)->length))); } if(k < point->totkey - 1) { - VecSubf(dv2, (key + 1)->co, key->co); - tlen= Normalize(dv2); - VecMulf(dv2, mul * (tlen - key->length)); + sub_v3_v3v3(dv2, (key + 1)->co, key->co); + tlen= normalize_v3(dv2); + mul_v3_fl(dv2, mul * (tlen - key->length)); } if(k) { - VecAddf((key-1)->co,(key-1)->co,dv1); + add_v3_v3v3((key-1)->co,(key-1)->co,dv1); } VECADD(dv1,dv0,dv2); @@ -1001,7 +1001,7 @@ static void recalc_lengths(PTCacheEdit *edit) LOOP_EDITED_POINTS { key= point->keys; for(k=0; ktotkey-1; k++, key++) { - key->length= VecLenf(key->co, (key + 1)->co); + key->length= len_v3v3(key->co, (key + 1)->co); } } } @@ -1055,12 +1055,12 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys) VECADD(vec,vec,mvert->co); VECADD(nor,nor,mvert->no); - VecMulf(vec,0.25); + mul_v3_fl(vec,0.25); } else - VecMulf(vec,0.3333f); + mul_v3_fl(vec,0.3333f); - Normalize(nor); + normalize_v3(nor); BLI_kdtree_insert(edit->emitter_field, i, vec, NULL); } @@ -1114,7 +1114,7 @@ static void update_world_cos(Object *ob, PTCacheEdit *edit) LOOP_KEYS { VECCOPY(key->world_co,key->co); if(!(psys->flag & PSYS_GLOBAL_HAIR)) - Mat4MulVecfl(hairmat, key->world_co); + mul_m4_v3(hairmat, key->world_co); } } } @@ -1142,7 +1142,7 @@ static void update_velocities(Object *ob, PTCacheEdit *edit) if(point->totkey>2) { VECSUB(vec1, (key+1)->co, (key+2)->co); - Projf(vec2, vec1, key->vel); + project_v3_v3v3(vec2, vec1, key->vel); VECSUB(vec2, vec1, vec2); VECADDFAC(key->vel, key->vel, vec2, 0.5f); } @@ -1157,7 +1157,7 @@ static void update_velocities(Object *ob, PTCacheEdit *edit) if(point->totkey>2) { VECSUB(vec1, (key-2)->co, (key-1)->co); - Projf(vec2, vec1, key->vel); + project_v3_v3v3(vec2, vec1, key->vel); VECSUB(vec2, vec1, vec2); VECADDFAC(key->vel, key->vel, vec2, 0.5f); } @@ -1170,7 +1170,7 @@ static void update_velocities(Object *ob, PTCacheEdit *edit) VECSUB(key->vel, (key+1)->co, (key-1)->co); } - VecMulf(key->vel, frs_sec/dfra); + mul_v3_fl(key->vel, frs_sec/dfra); } } } @@ -1537,7 +1537,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short select) if(!PE_start_edit(edit)) return OPERATOR_CANCELLED; - Mat4One(mat); + unit_m4(mat); LOOP_VISIBLE_POINTS { if(edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) @@ -1546,7 +1546,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short select) if(pset->selectmode==SCE_SELECT_POINT) { LOOP_KEYS { VECCOPY(co, key->co); - Mat4MulVecfl(mat, co); + mul_m4_v3(mat, co); project_short(ar, co, vertco); if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1])) { if(select && !(key->flag & PEK_SELECT)) { @@ -1564,7 +1564,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short select) key= point->keys + point->totkey - 1; VECCOPY(co, key->co); - Mat4MulVecfl(mat, co); + mul_m4_v3(mat, co); project_short(ar, co,vertco); if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1])) { if(select && !(key->flag & PEK_SELECT)) { @@ -2255,7 +2255,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) LOOP_SELECTED_POINTS { psys_mat_hair_to_object(ob, psmd->dm, psys->part->from, psys->particles+p, mat); VECCOPY(co, point->keys->co); - Mat4MulVecfl(mat, co); + mul_m4_v3(mat, co); BLI_kdtree_insert(tree, p, co, NULL); } @@ -2265,7 +2265,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) LOOP_SELECTED_POINTS { psys_mat_hair_to_object(ob, psmd->dm, psys->part->from, psys->particles+p, mat); VECCOPY(co, point->keys->co); - Mat4MulVecfl(mat, co); + mul_m4_v3(mat, co); totn= BLI_kdtree_find_n_nearest(tree,10,co,NULL,nearest); @@ -2736,8 +2736,8 @@ static void brush_comb(PEData *data, float mat[][4], float imat[][4], int point_ fac= (float)pow((double)(1.0f - data->dist / data->rad), (double)data->combfac); VECCOPY(cvec,data->dvec); - Mat4Mul3Vecfl(imat,cvec); - VecMulf(cvec, fac); + mul_mat3_m4_v3(imat,cvec); + mul_v3_fl(cvec, fac); VECADD(key->co, key->co, cvec); (data->edit->points + point_index)->flag |= PEP_EDIT_RECALC; @@ -2854,7 +2854,7 @@ static void brush_length(PEData *data, int point_index) else { VECSUB(dvec,key->co,pvec); VECCOPY(pvec,key->co); - VecMulf(dvec,data->growfac); + mul_v3_fl(dvec,data->growfac); VECADD(key->co,(key-1)->co,dvec); } } @@ -2873,25 +2873,25 @@ static void brush_puff(PEData *data, int point_index) if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(data->ob, data->dm, psys->part->from, psys->particles + point_index, mat); - Mat4Invert(imat,mat); + invert_m4_m4(imat,mat); } else { - Mat4One(mat); - Mat4One(imat); + unit_m4(mat); + unit_m4(imat); } LOOP_KEYS { if(k==0) { /* find root coordinate and normal on emitter */ VECCOPY(co, key->co); - Mat4MulVecfl(mat, co); + mul_m4_v3(mat, co); point_index= BLI_kdtree_find_nearest(edit->emitter_field, co, NULL, NULL); if(point_index == -1) return; VECCOPY(rootco, co); - VecCopyf(nor, &edit->emitter_cosnos[point_index*6+3]); - Normalize(nor); + copy_v3_v3(nor, &edit->emitter_cosnos[point_index*6+3]); + normalize_v3(nor); length= 0.0f; fac= (float)pow((double)(1.0f - data->dist / data->rad), (double)data->pufffac); @@ -2903,8 +2903,8 @@ static void brush_puff(PEData *data, int point_index) /* compute position as if hair was standing up straight */ VECCOPY(lastco, co); VECCOPY(co, key->co); - Mat4MulVecfl(mat, co); - length += VecLenf(lastco, co); + mul_m4_v3(mat, co); + length += len_v3v3(lastco, co); VECADDFAC(kco, rootco, nor, length); @@ -2913,7 +2913,7 @@ static void brush_puff(PEData *data, int point_index) VECADDFAC(co, co, dco, fac); VECCOPY(key->co, co); - Mat4MulVecfl(imat, key->co); + mul_m4_v3(imat, key->co); } } @@ -2925,8 +2925,8 @@ static void brush_smooth_get(PEData *data, float mat[][4], float imat[][4], int if(key_index) { float dvec[3]; - VecSubf(dvec,key->co,(key-1)->co); - Mat4Mul3Vecfl(mat,dvec); + sub_v3_v3v3(dvec,key->co,(key-1)->co); + mul_mat3_m4_v3(mat,dvec); VECADD(data->vec,data->vec,dvec); data->tot++; } @@ -2938,12 +2938,12 @@ static void brush_smooth_do(PEData *data, float mat[][4], float imat[][4], int p if(key_index) { VECCOPY(vec,data->vec); - Mat4Mul3Vecfl(imat,vec); + mul_mat3_m4_v3(imat,vec); - VecSubf(dvec,key->co,(key-1)->co); + sub_v3_v3v3(dvec,key->co,(key-1)->co); VECSUB(dvec,vec,dvec); - VecMulf(dvec,data->smoothfac); + mul_v3_fl(dvec,data->smoothfac); VECADD(key->co,key->co,dvec); } @@ -2969,7 +2969,7 @@ static int brush_add(PEData *data, short number) short size= pset->brush[PE_BRUSH_ADD].size; short size2= size*size; DerivedMesh *dm=0; - Mat4Invert(imat,ob->obmat); + invert_m4_m4(imat,ob->obmat); if(psys->flag & PSYS_GLOBAL_HAIR) return 0; @@ -2995,8 +2995,8 @@ static int brush_add(PEData *data, short number) mco[1]= data->mval[1] + dmy; viewline(data->vc.ar, data->vc.v3d, mco, co1, co2); - Mat4MulVecfl(imat,co1); - Mat4MulVecfl(imat,co2); + mul_m4_v3(imat,co1); + mul_m4_v3(imat,co2); min_d=2.0; /* warning, returns the derived mesh face */ @@ -3102,18 +3102,18 @@ static int brush_add(PEData *data, short number) key[0].time= hkey->time/ 100.0f; psys_get_particle_on_path(&sim, ptn[0].index, key, 0); - VecMulf(key[0].co, weight[0]); + mul_v3_fl(key[0].co, weight[0]); if(maxw>1) { key[1].time= key[0].time; psys_get_particle_on_path(&sim, ptn[1].index, key + 1, 0); - VecMulf(key[1].co, weight[1]); + mul_v3_fl(key[1].co, weight[1]); VECADD(key[0].co, key[0].co, key[1].co); if(maxw>2) { key[2].time= key[0].time; psys_get_particle_on_path(&sim, ptn[2].index, key + 2, 0); - VecMulf(key[2].co, weight[2]); + mul_v3_fl(key[2].co, weight[2]); VECADD(key[0].co, key[0].co, key[2].co); } } @@ -3134,8 +3134,8 @@ static int brush_add(PEData *data, short number) } for(k=0, hkey=pa->hair; ktotaddkey; k++, hkey++) { psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); - Mat4Invert(imat,hairmat); - Mat4MulVecfl(imat, hkey->co); + invert_m4_m4(imat,hairmat); + mul_m4_v3(imat, hkey->co); } } @@ -3250,7 +3250,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) else data.combfac= 1.0f - data.combfac; - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); window_to_3d_delta(ar, vec, dx, dy); data.dvec= vec; @@ -3320,7 +3320,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.pufffac= 1.0f - data.pufffac; data.invert= (brush->invert ^ flip); - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); foreach_mouse_hit_point(&data, brush_puff, selected); } @@ -3356,12 +3356,12 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.smoothfac= (float)(brush->strength / 100.0f); - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); foreach_mouse_hit_key(&data, brush_smooth_get, selected); if(data.tot) { - VecMulf(data.vec, 1.0f / (float)data.tot); + mul_v3_fl(data.vec, 1.0f / (float)data.tot); foreach_mouse_hit_key(&data, brush_smooth_do, selected); } @@ -3784,7 +3784,7 @@ int PE_minmax(Scene *scene, float *min, float *max) if(psys) psmd= psys_get_modifier(ob, psys); else - Mat4One(mat); + unit_m4(mat); LOOP_VISIBLE_POINTS { if(psys) @@ -3792,7 +3792,7 @@ int PE_minmax(Scene *scene, float *min, float *max) LOOP_SELECTED_KEYS { VECCOPY(co, key->co); - Mat4MulVecfl(mat, co); + mul_m4_v3(mat, co); DO_MINMAX(co, min, max); ok= 1; } diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index d763c0500d2..1ef3ffa6c34 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -37,7 +37,7 @@ #include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_listbase.h" #include "BKE_context.h" @@ -548,7 +548,7 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); for(k=0,key=pa->hair; ktotkey; k++,key++) { - Mat4MulVecfl(hairmat,key->co); + mul_m4_v3(hairmat,key->co); if(ekey) { ekey->flag &= ~PEK_USE_WCO; @@ -638,7 +638,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) /* convert to global coordinates */ for (i=0; iobmat, CDDM_get_vert(dm, i)->co); + mul_m4_v3(ob->obmat, CDDM_get_vert(dm, i)->co); bvhtree_from_mesh_faces(&bvhtree, dm, 0.0, 2, 6); @@ -657,21 +657,21 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) mface = CDDM_get_face(dm,nearest.index); - VecCopyf(v[0], CDDM_get_vert(dm,mface->v1)->co); - VecCopyf(v[1], CDDM_get_vert(dm,mface->v2)->co); - VecCopyf(v[2], CDDM_get_vert(dm,mface->v3)->co); + copy_v3_v3(v[0], CDDM_get_vert(dm,mface->v1)->co); + copy_v3_v3(v[1], CDDM_get_vert(dm,mface->v2)->co); + copy_v3_v3(v[2], CDDM_get_vert(dm,mface->v3)->co); if(mface->v4) { - VecCopyf(v[3], CDDM_get_vert(dm,mface->v4)->co); - MeanValueWeights(v, 4, nearest.co, pa->fuv); + copy_v3_v3(v[3], CDDM_get_vert(dm,mface->v4)->co); + interp_weights_poly_v3( pa->fuv,v, 4, nearest.co); } else - MeanValueWeights(v, 3, nearest.co, pa->fuv); + interp_weights_poly_v3( pa->fuv,v, 3, nearest.co); pa->num = nearest.index; pa->num_dmcache = psys_particle_dm_face_lookup(ob,psmd->dm,pa->num,pa->fuv,NULL); psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); - Mat4Invert(imat,hairmat); + invert_m4_m4(imat,hairmat); VECSUB(vec, nearest.co, key->co); @@ -682,7 +682,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) for(k=0,key=pa->hair; ktotkey; k++,key++) { VECADD(key->co, key->co, vec); - Mat4MulVecfl(imat,key->co); + mul_m4_v3(imat,key->co); if(ekey) { ekey->flag |= PEK_USE_WCO; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index b72c4991094..e5d553dacc7 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -62,7 +62,7 @@ #include "BLI_blenlib.h" #include "BLI_threads.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_blender.h" #include "BKE_context.h" @@ -839,8 +839,8 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *ob) } // init trafo matrix - Mat4CpyMat4(domainMat, fsDomain->obmat); - if(!Mat4Invert(invDomMat, domainMat)) { + copy_m4_m4(domainMat, fsDomain->obmat); + if(!invert_m4_m4(invDomMat, domainMat)) { snprintf(debugStrBuffer,256,"fluidsimBake::error - Invalid obj matrix?\n"); elbeemDebugOut(debugStrBuffer); BKE_report(reports, RPT_ERROR, "Invalid object matrix."); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 92380a56d3d..74e1cca5579 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -42,7 +42,7 @@ #include "BLO_readfile.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index a9023194271..59b220dec63 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -52,7 +52,7 @@ #include "BKE_utildefines.h" #include "BKE_world.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_listbase.h" diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index be76e153fae..0f22b3041fb 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -35,7 +35,7 @@ #include "DNA_userdef_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_context.h" diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 1445c6b5cf8..742fab07bcc 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -37,7 +37,7 @@ #include "BKE_utildefines.h" #include "BKE_colortools.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_threads.h" #include "BIF_gl.h" diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 5cc2039393a..0df7b326834 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -31,7 +31,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_dlrbTree.h" @@ -400,7 +400,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) for(az= sa->actionzones.first; az; az= az->next) { if(BLI_in_rcti(&az->rect, x, y)) { if(az->type == AZONE_AREA) { - if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y)) + if(isect_point_tri_v2_int(az->x1, az->y1, az->x2, az->y2, x, y)) break; } else if(az->type == AZONE_REGION) { diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 929f854242f..e34330c2e42 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -40,7 +40,7 @@ #ifdef WIN32 #include "BLI_winstuff.h" #endif -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_linklist.h" @@ -669,7 +669,7 @@ static int project_paint_PickFace(const ProjPaintState *ps, float pt[2], float w v2= ps->screenCoords[mf->v2]; v3= ps->screenCoords[mf->v3]; - if (IsectPT2Df(pt, v1, v2, v3)) { + if (isect_point_tri_v2(pt, v1, v2, v3)) { if (ps->is_ortho) z_depth= VecZDepthOrtho(pt, v1, v2, v3, w_tmp); else z_depth= VecZDepthPersp(pt, v1, v2, v3, w_tmp); @@ -683,7 +683,7 @@ static int project_paint_PickFace(const ProjPaintState *ps, float pt[2], float w else if (mf->v4) { v4= ps->screenCoords[mf->v4]; - if (IsectPT2Df(pt, v1, v3, v4)) { + if (isect_point_tri_v2(pt, v1, v3, v4)) { if (ps->is_ortho) z_depth= VecZDepthOrtho(pt, v1, v3, v4, w_tmp); else z_depth= VecZDepthPersp(pt, v1, v3, v4, w_tmp); @@ -734,10 +734,10 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float tf = ps->dm_mtface + face_index; if (side == 0) { - Vec2Lerp3f(uv, tf->uv[0], tf->uv[1], tf->uv[2], w); + interp_v2_v2v2v2(uv, tf->uv[0], tf->uv[1], tf->uv[2], w); } else { /* QUAD */ - Vec2Lerp3f(uv, tf->uv[0], tf->uv[2], tf->uv[3], w); + interp_v2_v2v2v2(uv, tf->uv[0], tf->uv[2], tf->uv[3], w); } ibuf = tf->tpage->ibufs.first; /* we must have got the imbuf before getting here */ @@ -818,7 +818,7 @@ static int project_paint_occlude_ptv(float pt[3], float v1[3], float v2[3], floa return 0; /* do a 2D point in try intersection */ - if (!IsectPT2Df(pt, v1, v2, v3)) + if (!isect_point_tri_v2(pt, v1, v2, v3)) return 0; /* we know there is */ @@ -858,10 +858,10 @@ static int project_paint_occlude_ptv_clip( } /* Test if we're in the clipped area, */ - if (side) VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); - else VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); + if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); + else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); - Mat4MulVecfl(ps->ob->obmat, wco); + mul_m4_v3(ps->ob->obmat, wco); if(!view3d_test_clipping(ps->rv3d, wco)) { return 1; } @@ -1162,51 +1162,51 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl } /* face edge directions */ - Vec2Subf(dir1, puv[1], puv[0]); - Vec2Subf(dir2, puv[2], puv[1]); - Normalize2(dir1); - Normalize2(dir2); + sub_v2_v2v2(dir1, puv[1], puv[0]); + sub_v2_v2v2(dir2, puv[2], puv[1]); + normalize_v2(dir1); + normalize_v2(dir2); if (is_quad) { - Vec2Subf(dir3, puv[3], puv[2]); - Vec2Subf(dir4, puv[0], puv[3]); - Normalize2(dir3); - Normalize2(dir4); + sub_v2_v2v2(dir3, puv[3], puv[2]); + sub_v2_v2v2(dir4, puv[0], puv[3]); + normalize_v2(dir3); + normalize_v2(dir4); } else { - Vec2Subf(dir3, puv[0], puv[2]); - Normalize2(dir3); + sub_v2_v2v2(dir3, puv[0], puv[2]); + normalize_v2(dir3); } if (is_quad) { - a1 = AngleToLength(NormalizedVecAngle2_2D(dir4, dir1)); - a2 = AngleToLength(NormalizedVecAngle2_2D(dir1, dir2)); - a3 = AngleToLength(NormalizedVecAngle2_2D(dir2, dir3)); - a4 = AngleToLength(NormalizedVecAngle2_2D(dir3, dir4)); + a1 = shell_angle_to_dist(angle_normalized_v2v2(dir4, dir1)); + a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2)); + a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3)); + a4 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir4)); } else { - a1 = AngleToLength(NormalizedVecAngle2_2D(dir3, dir1)); - a2 = AngleToLength(NormalizedVecAngle2_2D(dir1, dir2)); - a3 = AngleToLength(NormalizedVecAngle2_2D(dir2, dir3)); + a1 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir1)); + a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2)); + a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3)); } if (is_quad) { - Vec2Subf(no1, dir4, dir1); - Vec2Subf(no2, dir1, dir2); - Vec2Subf(no3, dir2, dir3); - Vec2Subf(no4, dir3, dir4); - Normalize2(no1); - Normalize2(no2); - Normalize2(no3); - Normalize2(no4); - Vec2Mulf(no1, a1*scaler); - Vec2Mulf(no2, a2*scaler); - Vec2Mulf(no3, a3*scaler); - Vec2Mulf(no4, a4*scaler); - Vec2Addf(outset_uv[0], puv[0], no1); - Vec2Addf(outset_uv[1], puv[1], no2); - Vec2Addf(outset_uv[2], puv[2], no3); - Vec2Addf(outset_uv[3], puv[3], no4); + sub_v2_v2v2(no1, dir4, dir1); + sub_v2_v2v2(no2, dir1, dir2); + sub_v2_v2v2(no3, dir2, dir3); + sub_v2_v2v2(no4, dir3, dir4); + normalize_v2(no1); + normalize_v2(no2); + normalize_v2(no3); + normalize_v2(no4); + mul_v2_fl(no1, a1*scaler); + mul_v2_fl(no2, a2*scaler); + mul_v2_fl(no3, a3*scaler); + mul_v2_fl(no4, a4*scaler); + add_v2_v2v2(outset_uv[0], puv[0], no1); + add_v2_v2v2(outset_uv[1], puv[1], no2); + add_v2_v2v2(outset_uv[2], puv[2], no3); + add_v2_v2v2(outset_uv[3], puv[3], no4); outset_uv[0][0] *= ibuf_x_inv; outset_uv[0][1] *= ibuf_y_inv; @@ -1220,18 +1220,18 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl outset_uv[3][1] *= ibuf_y_inv; } else { - Vec2Subf(no1, dir3, dir1); - Vec2Subf(no2, dir1, dir2); - Vec2Subf(no3, dir2, dir3); - Normalize2(no1); - Normalize2(no2); - Normalize2(no3); - Vec2Mulf(no1, a1*scaler); - Vec2Mulf(no2, a2*scaler); - Vec2Mulf(no3, a3*scaler); - Vec2Addf(outset_uv[0], puv[0], no1); - Vec2Addf(outset_uv[1], puv[1], no2); - Vec2Addf(outset_uv[2], puv[2], no3); + sub_v2_v2v2(no1, dir3, dir1); + sub_v2_v2v2(no2, dir1, dir2); + sub_v2_v2v2(no3, dir2, dir3); + normalize_v2(no1); + normalize_v2(no2); + normalize_v2(no3); + mul_v2_fl(no1, a1*scaler); + mul_v2_fl(no2, a2*scaler); + mul_v2_fl(no3, a3*scaler); + add_v2_v2v2(outset_uv[0], puv[0], no1); + add_v2_v2v2(outset_uv[1], puv[1], no2); + add_v2_v2v2(outset_uv[2], puv[2], no3); outset_uv[0][0] *= ibuf_x_inv; outset_uv[0][1] *= ibuf_y_inv; @@ -1288,7 +1288,7 @@ static float lambda_cp_line2(const float p[2], const float l1[2], const float l2 h[0] = p[0] - l1[0]; h[1] = p[1] - l1[1]; - return(Inp2f(u, h)/Inp2f(u, u)); + return(dot_v2v2(u, h)/dot_v2v2(u, u)); } @@ -1304,7 +1304,7 @@ static void screen_px_from_ortho( float w[3]) { BarycentricWeights2f(uv, uv1co, uv2co, uv3co, w); - VecLerp3f(pixelScreenCo, v1co, v2co, v3co, w); + interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w); } /* same as screen_px_from_ortho except we need to take into account @@ -1338,7 +1338,7 @@ static void screen_px_from_persp( } /* done re-weighting */ - VecLerp3f(pixelScreenCo, v1co, v2co, v3co, w); + interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w); } static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const float w[3], int side, unsigned char rgba_ub[4], float rgba_f[4]) @@ -1356,7 +1356,7 @@ static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const uvCo3 = (float *)tf_other->uv[2]; } - Vec2Lerp3f(uv_other, uvCo1, uvCo2, uvCo3, w); + interp_v2_v2v2v2(uv_other, uvCo1, uvCo2, uvCo3, w); /* use */ uvco_to_wrapped_pxco(uv_other, ibuf_other->x, ibuf_other->y, &x, &y); @@ -1432,11 +1432,11 @@ float project_paint_uvpixel_mask( no[0] = w[0]*no1[0] + w[1]*no2[0] + w[2]*no3[0]; no[1] = w[0]*no1[1] + w[1]*no2[1] + w[2]*no3[1]; no[2] = w[0]*no1[2] + w[1]*no2[2] + w[2]*no3[2]; - Normalize(no); + normalize_v3(no); /* now we can use the normal as a mask */ if (ps->is_ortho) { - angle = NormalizedVecAngle2((float *)ps->viewDir, no); + angle = angle_normalized_v3v3((float *)ps->viewDir, no); } else { /* Annoying but for the perspective view we need to get the pixels location in 3D space :/ */ @@ -1456,9 +1456,9 @@ float project_paint_uvpixel_mask( viewDirPersp[0] = (ps->viewPos[0] - (w[0]*co1[0] + w[1]*co2[0] + w[2]*co3[0])); viewDirPersp[1] = (ps->viewPos[1] - (w[0]*co1[1] + w[1]*co2[1] + w[2]*co3[1])); viewDirPersp[2] = (ps->viewPos[2] - (w[0]*co1[2] + w[1]*co2[2] + w[2]*co3[2])); - Normalize(viewDirPersp); + normalize_v3(viewDirPersp); - angle = NormalizedVecAngle2(viewDirPersp, no); + angle = angle_normalized_v3v3(viewDirPersp, no); } if (angle >= ps->normal_angle) { @@ -1578,7 +1578,7 @@ static ProjPixel *project_paint_uvpixel_init( } else { float co[2]; - Vec2Subf(co, projPixel->projCoSS, (float *)ps->cloneOffset); + sub_v2_v2v2(co, projPixel->projCoSS, (float *)ps->cloneOffset); /* no need to initialize the bucket, we're only checking buckets faces and for this * the faces are alredy initialized in project_paint_delayed_face_init(...) */ @@ -1769,20 +1769,20 @@ static void scale_quad(float insetCos[4][3], float *origCos[4], const float inse cent[1] = (origCos[0][1] + origCos[1][1] + origCos[2][1] + origCos[3][1]) / 4.0f; cent[2] = (origCos[0][2] + origCos[1][2] + origCos[2][2] + origCos[3][2]) / 4.0f; - VecSubf(insetCos[0], origCos[0], cent); - VecSubf(insetCos[1], origCos[1], cent); - VecSubf(insetCos[2], origCos[2], cent); - VecSubf(insetCos[3], origCos[3], cent); + sub_v3_v3v3(insetCos[0], origCos[0], cent); + sub_v3_v3v3(insetCos[1], origCos[1], cent); + sub_v3_v3v3(insetCos[2], origCos[2], cent); + sub_v3_v3v3(insetCos[3], origCos[3], cent); - VecMulf(insetCos[0], inset); - VecMulf(insetCos[1], inset); - VecMulf(insetCos[2], inset); - VecMulf(insetCos[3], inset); + mul_v3_fl(insetCos[0], inset); + mul_v3_fl(insetCos[1], inset); + mul_v3_fl(insetCos[2], inset); + mul_v3_fl(insetCos[3], inset); - VecAddf(insetCos[0], insetCos[0], cent); - VecAddf(insetCos[1], insetCos[1], cent); - VecAddf(insetCos[2], insetCos[2], cent); - VecAddf(insetCos[3], insetCos[3], cent); + add_v3_v3v3(insetCos[0], insetCos[0], cent); + add_v3_v3v3(insetCos[1], insetCos[1], cent); + add_v3_v3v3(insetCos[2], insetCos[2], cent); + add_v3_v3v3(insetCos[3], insetCos[3], cent); } @@ -1793,17 +1793,17 @@ static void scale_tri(float insetCos[4][3], float *origCos[4], const float inset cent[1] = (origCos[0][1] + origCos[1][1] + origCos[2][1]) / 3.0f; cent[2] = (origCos[0][2] + origCos[1][2] + origCos[2][2]) / 3.0f; - VecSubf(insetCos[0], origCos[0], cent); - VecSubf(insetCos[1], origCos[1], cent); - VecSubf(insetCos[2], origCos[2], cent); + sub_v3_v3v3(insetCos[0], origCos[0], cent); + sub_v3_v3v3(insetCos[1], origCos[1], cent); + sub_v3_v3v3(insetCos[2], origCos[2], cent); - VecMulf(insetCos[0], inset); - VecMulf(insetCos[1], inset); - VecMulf(insetCos[2], inset); + mul_v3_fl(insetCos[0], inset); + mul_v3_fl(insetCos[1], inset); + mul_v3_fl(insetCos[2], inset); - VecAddf(insetCos[0], insetCos[0], cent); - VecAddf(insetCos[1], insetCos[1], cent); - VecAddf(insetCos[2], insetCos[2], cent); + add_v3_v3v3(insetCos[0], insetCos[0], cent); + add_v3_v3v3(insetCos[1], insetCos[1], cent); + add_v3_v3v3(insetCos[2], insetCos[2], cent); } @@ -1891,22 +1891,22 @@ static void rect_to_uvspace_ortho( uv[0] = bucket_bounds->xmax; uv[1] = bucket_bounds->ymin; BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w); //uv[0] = bucket_bounds->xmax; // set above uv[1] = bucket_bounds->ymax; BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w); uv[0] = bucket_bounds->xmin; //uv[1] = bucket_bounds->ymax; // set above BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w); //uv[0] = bucket_bounds->xmin; // set above uv[1] = bucket_bounds->ymin; BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w); } /* same as above but use BarycentricWeightsPersp2f */ @@ -1925,22 +1925,22 @@ static void rect_to_uvspace_persp( uv[0] = bucket_bounds->xmax; uv[1] = bucket_bounds->ymin; BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w); //uv[0] = bucket_bounds->xmax; // set above uv[1] = bucket_bounds->ymax; BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w); uv[0] = bucket_bounds->xmin; //uv[1] = bucket_bounds->ymax; // set above BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w); //uv[0] = bucket_bounds->xmin; // set above uv[1] = bucket_bounds->ymin; BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w); } /* This works as we need it to but we can save a few steps and not use it */ @@ -1967,7 +1967,7 @@ static float angle_2d_clockwise(const float p1[2], const float p2[2], const floa /* limit must be a fraction over 1.0f */ static int IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2], float limit) { - return ((AreaF2Dfl(pt,v1,v2) + AreaF2Dfl(pt,v2,v3) + AreaF2Dfl(pt,v3,v1)) / (AreaF2Dfl(v1,v2,v3))) < limit; + return ((area_tri_v2(pt,v1,v2) + area_tri_v2(pt,v2,v3) + area_tri_v2(pt,v3,v1)) / (area_tri_v2(v1,v2,v3))) < limit; } /* Clip the face by a bucket and set the uv-space bucket_bounds_uv @@ -2184,13 +2184,13 @@ static void project_bucket_clip_face( if (is_ortho) { for(i=0; i<(*tot); i++) { BarycentricWeights2f(isectVCosSS[i], v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); } } else { for(i=0; i<(*tot); i++) { BarycentricWeightsPersp2f(isectVCosSS[i], v1coSS, v2coSS, v3coSS, w); - Vec2Lerp3f(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); + interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); } } } @@ -2445,8 +2445,8 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* a pitty we need to get the worldspace pixel location here */ if(ps->rv3d->rflag & RV3D_CLIPPING) { - VecLerp3f(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w); - Mat4MulVecfl(ps->ob->obmat, wco); + interp_v3_v3v3v3(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w); + mul_m4_v3(ps->ob->obmat, wco); if(view3d_test_clipping(ps->rv3d, wco)) { continue; /* Watch out that no code below this needs to run */ } @@ -2567,7 +2567,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i line_clip_rect2f(bucket_bounds, vCoSS[fidx1], vCoSS[fidx2], bucket_clip_edges[0], bucket_clip_edges[1]) ) { - ftot = Vec2Lenf(vCoSS[fidx1], vCoSS[fidx2]); /* screenspace edge length */ + ftot = len_v2v2(vCoSS[fidx1], vCoSS[fidx2]); /* screenspace edge length */ if (ftot > 0.0f) { /* avoid div by zero */ if (mf->v4) { @@ -2575,19 +2575,19 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i else side= 0; } - fac1 = Vec2Lenf(vCoSS[fidx1], bucket_clip_edges[0]) / ftot; - fac2 = Vec2Lenf(vCoSS[fidx1], bucket_clip_edges[1]) / ftot; + fac1 = len_v2v2(vCoSS[fidx1], bucket_clip_edges[0]) / ftot; + fac2 = len_v2v2(vCoSS[fidx1], bucket_clip_edges[1]) / ftot; - Vec2Lerpf(seam_subsection[0], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac1); - Vec2Lerpf(seam_subsection[1], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac2); + interp_v2_v2v2(seam_subsection[0], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac1); + interp_v2_v2v2(seam_subsection[1], tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2], fac2); - Vec2Lerpf(seam_subsection[2], outset_uv[fidx1], outset_uv[fidx2], fac2); - Vec2Lerpf(seam_subsection[3], outset_uv[fidx1], outset_uv[fidx2], fac1); + interp_v2_v2v2(seam_subsection[2], outset_uv[fidx1], outset_uv[fidx2], fac2); + interp_v2_v2v2(seam_subsection[3], outset_uv[fidx1], outset_uv[fidx2], fac1); /* if the bucket_clip_edges values Z values was kept we could avoid this * Inset needs to be added so occlusion tests wont hit adjacent faces */ - VecLerpf(edge_verts_inset_clip[0], insetCos[fidx1], insetCos[fidx2], fac1); - VecLerpf(edge_verts_inset_clip[1], insetCos[fidx1], insetCos[fidx2], fac2); + interp_v3_v3v3(edge_verts_inset_clip[0], insetCos[fidx1], insetCos[fidx2], fac1); + interp_v3_v3v3(edge_verts_inset_clip[1], insetCos[fidx1], insetCos[fidx2], fac2); if (pixel_bounds_uv(seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3], &bounds_px, ibuf->x, ibuf->y, 1)) { @@ -2604,7 +2604,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i uv[0] = (float)x / ibuf_xf; /* use offset uvs instead */ /* test we're inside uvspace bucket and triangle bounds */ - if (IsectPQ2Df(uv, seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3])) { + if (isect_point_quad_v2(uv, seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3])) { /* We need to find the closest point along the face edge, * getting the screen_px_from_*** wont work because our actual location @@ -2621,11 +2621,11 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i fac = lambda_cp_line2(uv, seam_subsection[0], seam_subsection[1]); if (fac < 0.0f) { VECCOPY(pixelScreenCo, edge_verts_inset_clip[0]); } else if (fac > 1.0f) { VECCOPY(pixelScreenCo, edge_verts_inset_clip[1]); } - else { VecLerpf(pixelScreenCo, edge_verts_inset_clip[0], edge_verts_inset_clip[1], fac); } + else { interp_v3_v3v3(pixelScreenCo, edge_verts_inset_clip[0], edge_verts_inset_clip[1], fac); } if (!is_ortho) { pixelScreenCo[3] = 1.0f; - Mat4MulVec4fl((float(*)[4])ps->projectMat, pixelScreenCo); /* cast because of const */ + mul_m4_v4((float(*)[4])ps->projectMat, pixelScreenCo); /* cast because of const */ pixelScreenCo[0] = (float)(ps->ar->winx/2.0f)+(ps->ar->winx/2.0f)*pixelScreenCo[0]/pixelScreenCo[3]; pixelScreenCo[1] = (float)(ps->ar->winy/2.0f)+(ps->ar->winy/2.0f)*pixelScreenCo[1]/pixelScreenCo[3]; pixelScreenCo[2] = pixelScreenCo[2]/pixelScreenCo[3]; /* Use the depth for bucket point occlusion */ @@ -2661,10 +2661,10 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* a pitty we need to get the worldspace pixel location here */ if(ps->rv3d->rflag & RV3D_CLIPPING) { - if (side) VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); - else VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); + if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); + else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); - Mat4MulVecfl(ps->ob->obmat, wco); + mul_m4_v3(ps->ob->obmat, wco); if(view3d_test_clipping(ps->rv3d, wco)) { continue; /* Watch out that no code below this needs to run */ } @@ -2824,23 +2824,23 @@ static int project_bucket_face_isect(ProjPaintState *ps, float min[2], float max p4[0] = bucket_bounds.xmax; p4[1] = bucket_bounds.ymin; if (mf->v4) { - if( IsectPQ2Df(p1, v1, v2, v3, v4) || IsectPQ2Df(p2, v1, v2, v3, v4) || IsectPQ2Df(p3, v1, v2, v3, v4) || IsectPQ2Df(p4, v1, v2, v3, v4) || + if( isect_point_quad_v2(p1, v1, v2, v3, v4) || isect_point_quad_v2(p2, v1, v2, v3, v4) || isect_point_quad_v2(p3, v1, v2, v3, v4) || isect_point_quad_v2(p4, v1, v2, v3, v4) || /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */ - (IsectLL2Df(p1, p2, v1, v2) || IsectLL2Df(p1, p2, v2, v3) || IsectLL2Df(p1, p2, v3, v4)) || - (IsectLL2Df(p2, p3, v1, v2) || IsectLL2Df(p2, p3, v2, v3) || IsectLL2Df(p2, p3, v3, v4)) || - (IsectLL2Df(p3, p4, v1, v2) || IsectLL2Df(p3, p4, v2, v3) || IsectLL2Df(p3, p4, v3, v4)) || - (IsectLL2Df(p4, p1, v1, v2) || IsectLL2Df(p4, p1, v2, v3) || IsectLL2Df(p4, p1, v3, v4)) + (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3) || isect_line_line_v2(p1, p2, v3, v4)) || + (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3) || isect_line_line_v2(p2, p3, v3, v4)) || + (isect_line_line_v2(p3, p4, v1, v2) || isect_line_line_v2(p3, p4, v2, v3) || isect_line_line_v2(p3, p4, v3, v4)) || + (isect_line_line_v2(p4, p1, v1, v2) || isect_line_line_v2(p4, p1, v2, v3) || isect_line_line_v2(p4, p1, v3, v4)) ) { return 1; } } else { - if( IsectPT2Df(p1, v1, v2, v3) || IsectPT2Df(p2, v1, v2, v3) || IsectPT2Df(p3, v1, v2, v3) || IsectPT2Df(p4, v1, v2, v3) || + if( isect_point_tri_v2(p1, v1, v2, v3) || isect_point_tri_v2(p2, v1, v2, v3) || isect_point_tri_v2(p3, v1, v2, v3) || isect_point_tri_v2(p4, v1, v2, v3) || /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */ - (IsectLL2Df(p1, p2, v1, v2) || IsectLL2Df(p1, p2, v2, v3)) || - (IsectLL2Df(p2, p3, v1, v2) || IsectLL2Df(p2, p3, v2, v3)) || - (IsectLL2Df(p3, p4, v1, v2) || IsectLL2Df(p3, p4, v2, v3)) || - (IsectLL2Df(p4, p1, v1, v2) || IsectLL2Df(p4, p1, v2, v3)) + (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3)) || + (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3)) || + (isect_line_line_v2(p3, p4, v1, v2) || isect_line_line_v2(p3, p4, v2, v3)) || + (isect_line_line_v2(p4, p1, v1, v2) || isect_line_line_v2(p4, p1, v2, v3)) ) { return 1; } @@ -3000,18 +3000,18 @@ static void project_paint_begin(ProjPaintState *ps) view3d_get_object_project_mat(ps->rv3d, ps->ob, ps->projectMat); /* viewDir - object relative */ - Mat4Invert(ps->ob->imat, ps->ob->obmat); - Mat3CpyMat4(mat, ps->rv3d->viewinv); - Mat3MulVecfl(mat, ps->viewDir); - Mat3CpyMat4(mat, ps->ob->imat); - Mat3MulVecfl(mat, ps->viewDir); - Normalize(ps->viewDir); + invert_m4_m4(ps->ob->imat, ps->ob->obmat); + copy_m3_m4(mat, ps->rv3d->viewinv); + mul_m3_v3(mat, ps->viewDir); + copy_m3_m4(mat, ps->ob->imat); + mul_m3_v3(mat, ps->viewDir); + normalize_v3(ps->viewDir); /* viewPos - object relative */ VECCOPY(ps->viewPos, ps->rv3d->viewinv[3]); - Mat3CpyMat4(mat, ps->ob->imat); - Mat3MulVecfl(mat, ps->viewPos); - VecAddf(ps->viewPos, ps->viewPos, ps->ob->imat[3]); + copy_m3_m4(mat, ps->ob->imat); + mul_m3_v3(mat, ps->viewPos); + add_v3_v3v3(ps->viewPos, ps->viewPos, ps->ob->imat[3]); { /* only use these for running 'get_view3d_viewplane' */ rctf viewplane; @@ -3045,7 +3045,7 @@ static void project_paint_begin(ProjPaintState *ps) if (ps->is_ortho) { for(a=0; a < ps->dm_totvert; a++, projScreenCo++) { VECCOPY((*projScreenCo), ps->dm_mvert[a].co); - Mat4MulVecfl(ps->projectMat, (*projScreenCo)); + mul_m4_v3(ps->projectMat, (*projScreenCo)); /* screen space, not clamped */ (*projScreenCo)[0] = (float)(ps->ar->winx/2.0f)+(ps->ar->winx/2.0f)*(*projScreenCo)[0]; @@ -3058,7 +3058,7 @@ static void project_paint_begin(ProjPaintState *ps) VECCOPY((*projScreenCo), ps->dm_mvert[a].co); (*projScreenCo)[3] = 1.0f; - Mat4MulVec4fl(ps->projectMat, (*projScreenCo)); + mul_m4_v4(ps->projectMat, (*projScreenCo)); if ((*projScreenCo)[3] > ps->clipsta) { @@ -3152,14 +3152,14 @@ static void project_paint_begin(ProjPaintState *ps) no[2] = (float)(v->no[2] / 32767.0f); if (ps->is_ortho) { - if (NormalizedVecAngle2(ps->viewDir, no) >= ps->normal_angle) { /* 1 vert of this face is towards us */ + if (angle_normalized_v3v3(ps->viewDir, no) >= ps->normal_angle) { /* 1 vert of this face is towards us */ ps->vertFlags[a] |= PROJ_VERT_CULL; } } else { - VecSubf(viewDirPersp, ps->viewPos, v->co); - Normalize(viewDirPersp); - if (NormalizedVecAngle2(viewDirPersp, no) >= ps->normal_angle) { /* 1 vert of this face is towards us */ + sub_v3_v3v3(viewDirPersp, ps->viewPos, v->co); + normalize_v3(viewDirPersp); + if (angle_normalized_v3v3(viewDirPersp, no) >= ps->normal_angle) { /* 1 vert of this face is towards us */ ps->vertFlags[a] |= PROJ_VERT_CULL; } } @@ -3298,10 +3298,10 @@ static void project_paint_begin_clone(ProjPaintState *ps, int mouse[2]) float projCo[4]; float *curs= give_cursor(ps->scene, ps->v3d); VECCOPY(projCo, curs); - Mat4MulVecfl(ps->ob->imat, projCo); + mul_m4_v3(ps->ob->imat, projCo); projCo[3] = 1.0f; - Mat4MulVec4fl(ps->projectMat, projCo); + mul_m4_v4(ps->projectMat, projCo); ps->cloneOffset[0] = mouse[0] - ((float)(ps->ar->winx/2.0f)+(ps->ar->winx/2.0f)*projCo[0]/projCo[3]); ps->cloneOffset[1] = mouse[1] - ((float)(ps->ar->winy/2.0f)+(ps->ar->winy/2.0f)*projCo[1]/projCo[3]); } @@ -3742,7 +3742,7 @@ static void *do_projectpaint_thread(void *ph_v) projPixel = (ProjPixel *)node->link; - /*dist = Vec2Lenf(projPixel->projCoSS, pos);*/ /* correct but uses a sqrtf */ + /*dist = len_v2v2(projPixel->projCoSS, pos);*/ /* correct but uses a sqrtf */ dist_nosqrt = Vec2Lenf_nosqrt(projPixel->projCoSS, pos); /*if (dist < s->brush->size) {*/ /* correct but uses a sqrtf */ @@ -3811,7 +3811,7 @@ static void *do_projectpaint_thread(void *ph_v) } break; case PAINT_TOOL_SMEAR: - Vec2Subf(co, projPixel->projCoSS, pos_ofs); + sub_v2_v2v2(co, projPixel->projCoSS, pos_ofs); if (is_floatbuf) do_projectpaint_smear_f(ps, projPixel, rgba, alpha, mask, smearArena, &smearPixels_f, co); else do_projectpaint_smear(ps, projPixel, rgba, alpha, mask, smearArena, &smearPixels, co); @@ -4200,14 +4200,14 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, float *lastpos, float *p static int texpaint_break_stroke(float *prevuv, float *fwuv, float *bkuv, float *uv) { float d1[2], d2[2]; - float mismatch = Vec2Lenf(fwuv, uv); - float len1 = Vec2Lenf(prevuv, fwuv); - float len2 = Vec2Lenf(bkuv, uv); + float mismatch = len_v2v2(fwuv, uv); + float len1 = len_v2v2(prevuv, fwuv); + float len2 = len_v2v2(bkuv, uv); - Vec2Subf(d1, fwuv, prevuv); - Vec2Subf(d2, uv, bkuv); + sub_v2_v2v2(d1, fwuv, prevuv); + sub_v2_v2v2(d2, uv, bkuv); - return ((Inp2f(d1, d2) < 0.0f) || (mismatch > MAX2(len1, len2)*2)); + return ((dot_v2v2(d1, d2) < 0.0f) || (mismatch > MAX2(len1, len2)*2)); } /* ImagePaint Common */ diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 6e256bee7f2..0b86034958f 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -41,7 +41,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "PIL_time.h" diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 15104068350..24d9e0f4bc1 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -13,7 +13,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_brush.h" #include "BKE_context.h" @@ -43,9 +43,9 @@ static void imapaint_project(Object *ob, float *model, float *proj, float *co, f VECCOPY(pco, co); pco[3]= 1.0f; - Mat4MulVecfl(ob->obmat, pco); - Mat4MulVecfl((float(*)[4])model, pco); - Mat4MulVec4fl((float(*)[4])proj, pco); + mul_m4_v3(ob->obmat, pco); + mul_m4_v3((float(*)[4])model, pco); + mul_m4_v4((float(*)[4])proj, pco); } static void imapaint_tri_weights(Object *ob, float *v1, float *v2, float *v3, float *co, float *w) @@ -79,15 +79,15 @@ static void imapaint_tri_weights(Object *ob, float *v1, float *v2, float *v3, fl wmat[0][1]= pv1[1]; wmat[1][1]= pv2[1]; wmat[2][1]= pv3[1]; wmat[0][2]= pv1[3]; wmat[1][2]= pv2[3]; wmat[2][2]= pv3[3]; - Mat3Inv(invwmat, wmat); - Mat3MulVecfl(invwmat, h); + invert_m3_m3(invwmat, wmat); + mul_m3_v3(invwmat, h); VECCOPY(w, h); /* w is still divided by perspdiv, make it sum to one */ divw= w[0] + w[1] + w[2]; if(divw != 0.0f) - VecMulf(w, 1.0f/divw); + mul_v3_fl(w, 1.0f/divw); } /* compute uv coordinates of mouse in face */ diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 2045397f3c9..35723769f88 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -42,7 +42,7 @@ #include "IMB_imbuf_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_ghash.h" #include "DNA_anim_types.h" @@ -1379,9 +1379,9 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event) // if(ob->lay & v3d->lay); else error("Active object is not in this layer"); /* imat for normals */ - Mat4MulMat4(mat, ob->obmat, wpd->vc.rv3d->viewmat); - Mat4Invert(imat, mat); - Mat3CpyMat4(wpd->wpimat, imat); + mul_m4_m4m4(mat, ob->obmat, wpd->vc.rv3d->viewmat); + invert_m4_m4(imat, mat); + copy_m3_m4(wpd->wpimat, imat); /* if mirror painting, find the other group */ if(me->editflag & ME_EDIT_MIRROR_X) { @@ -1437,7 +1437,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P mval[0]-= vc->ar->winrct.xmin; mval[1]-= vc->ar->winrct.ymin; - Mat4SwapMat4(wpd->vc.rv3d->persmat, mat); + swap_m4m4(wpd->vc.rv3d->persmat, mat); /* which faces are involved */ if(wp->flag & VP_AREA) { @@ -1562,7 +1562,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P } } - Mat4SwapMat4(vc->rv3d->persmat, mat); + swap_m4m4(vc->rv3d->persmat, mat); DAG_id_flush_update(ob->data, OB_RECALC_DATA); ED_region_tag_redraw(vc->ar); @@ -1795,9 +1795,9 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface); /* some old cruft to sort out later */ - Mat4MulMat4(mat, ob->obmat, vpd->vc.rv3d->viewmat); - Mat4Invert(imat, mat); - Mat3CpyMat4(vpd->vpimat, imat); + mul_m4_m4m4(mat, ob->obmat, vpd->vc.rv3d->viewmat); + invert_m4_m4(imat, mat); + copy_m3_m4(vpd->vpimat, imat); return 1; } @@ -1871,14 +1871,14 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P else totindex= 0; } - Mat4SwapMat4(vc->rv3d->persmat, mat); + swap_m4m4(vc->rv3d->persmat, mat); for(index=0; indextotface) vpaint_paint_face(vp, vpd, ob, indexar[index]-1, mval); } - Mat4SwapMat4(vc->rv3d->persmat, mat); + swap_m4m4(vc->rv3d->persmat, mat); /* was disabled because it is slow, but necessary for blur */ if(vp->mode == VP_BLUR) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index c4c7f436f12..7575464fd57 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -32,7 +32,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" @@ -256,12 +256,12 @@ static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], cons { float fno[3] = {no[0], no[1], no[2]}; - Normalize(fno); + normalize_v3(fno); - if((Inpf(view_vec, fno)) > 0) { - VecAddf(out, out, fno); + if((dot_v3v3(view_vec, fno)) > 0) { + add_v3_v3v3(out, out, fno); } else { - VecAddf(out_flip, out_flip, fno); /* out_flip is used when out is {0,0,0} */ + add_v3_v3v3(out_flip, out_flip, fno); /* out_flip is used when out is {0,0,0} */ } } @@ -291,7 +291,7 @@ static void calc_area_normal(Sculpt *sd, SculptSession *ss, float out[3], const VECCOPY(out, out_flip); } - Normalize(out); + normalize_v3(out); if(out_dir) { out[0] = out_dir[0] * view + out[0] * (10-view); @@ -299,7 +299,7 @@ static void calc_area_normal(Sculpt *sd, SculptSession *ss, float out[3], const out[2] = out_dir[2] * view + out[2] * (10-view); } - Normalize(out); + normalize_v3(out); } static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_verts) @@ -349,7 +349,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) /* Don't modify corner vertices */ if(ncount==1) { - VecCopyf(avg, ss->mvert[vert].co); + copy_v3_v3(avg, ss->mvert[vert].co); return; } @@ -365,7 +365,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) for(i=0; i<(f->v4?4:3); ++i) { if(i != skip && (ncount!=2 || BLI_countlist(&ss->fmap[(&f->v1)[i]]) <= 2)) { - VecAddf(avg, avg, ss->mvert[(&f->v1)[i]].co); + add_v3_v3v3(avg, avg, ss->mvert[(&f->v1)[i]].co); ++total; } } @@ -374,9 +374,9 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) } if(total>0) - VecMulf(avg, 1.0f / total); + mul_v3_fl(avg, 1.0f / total); else - VecCopyf(avg, ss->mvert[vert].co); + copy_v3_v3(avg, ss->mvert[vert].co); } static void do_smooth_brush(Sculpt *s, SculptSession *ss, const ListBase* active_verts) @@ -443,14 +443,14 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss) float grab_delta[3]; float *buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->vertices ):0; - VecCopyf(grab_delta, ss->cache->grab_delta_symmetry); + copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry); while(node) { float *co= ss->mvert[node->Index].co; - VecCopyf(add, grab_delta); - VecMulf(add, node->Fade); - VecAddf(add, add, co); + copy_v3_v3(add, grab_delta); + mul_v3_fl(add, node->Fade); + add_v3_v3v3(add, add, co); if( buffer != 0 ) { IndexLink *cur = &ss->drawobject->indices[node->Index]; @@ -526,11 +526,11 @@ static void do_inflate_brush(Sculpt *s, SculptSession *ss, const ListBase *activ add[0]= no[0]/ 32767.0f; add[1]= no[1]/ 32767.0f; add[2]= no[2]/ 32767.0f; - VecMulf(add, node->Fade * ss->cache->radius); + mul_v3_fl(add, node->Fade * ss->cache->radius); add[0]*= ss->cache->scale[0]; add[1]*= ss->cache->scale[1]; add[2]*= ss->cache->scale[2]; - VecAddf(add, add, co); + add_v3_v3v3(add, add, co); if( buffer != 0 ) { IndexLink *cur = &ss->drawobject->indices[node->Index]; @@ -567,8 +567,8 @@ static void calc_flatten_center(SculptSession *ss, ActiveData *node, float co[3] co[0] = co[1] = co[2] = 0.0f; for(i = 0; i < FLATTEN_SAMPLE_SIZE; ++i) - VecAddf(co, co, ss->mvert[outer[i]->Index].co); - VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE); + add_v3_v3v3(co, co, ss->mvert[outer[i]->Index].co); + mul_v3_fl(co, 1.0f / FLATTEN_SAMPLE_SIZE); } /* Projects a point onto a plane along the plane's normal */ @@ -577,12 +577,12 @@ static void point_plane_project(float intr[3], float co[3], float plane_normal[3 float p1[3], sub1[3], sub2[3]; /* Find the intersection between squash-plane and vertex (along the area normal) */ - VecSubf(p1, co, plane_normal); - VecSubf(sub1, plane_center, p1); - VecSubf(sub2, co, p1); - VecSubf(intr, co, p1); - VecMulf(intr, Inpf(plane_normal, sub1) / Inpf(plane_normal, sub2)); - VecAddf(intr, intr, p1); + sub_v3_v3v3(p1, co, plane_normal); + sub_v3_v3v3(sub1, plane_center, p1); + sub_v3_v3v3(sub2, co, p1); + sub_v3_v3v3(intr, co, p1); + mul_v3_fl(intr, dot_v3v3(plane_normal, sub1) / dot_v3v3(plane_normal, sub2)); + add_v3_v3v3(intr, intr, p1); } static int plane_point_side(float co[3], float plane_normal[3], float plane_center[3], int flip) @@ -590,8 +590,8 @@ static int plane_point_side(float co[3], float plane_normal[3], float plane_cent float delta[3]; float d; - VecSubf(delta, co, plane_center); - d = Inpf(plane_normal, delta); + sub_v3_v3v3(delta, co, plane_center); + d = dot_v3v3(plane_normal, delta); if(flip) d = -d; @@ -629,22 +629,22 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase /* Find the intersection between squash-plane and vertex (along the area normal) */ point_plane_project(intr, co, area_normal, cntr); - VecSubf(val, intr, co); + sub_v3_v3v3(val, intr, co); if(clay) { if(bstr > FLT_EPSILON) - VecMulf(val, node->Fade / bstr); + mul_v3_fl(val, node->Fade / bstr); else - VecMulf(val, node->Fade); + mul_v3_fl(val, node->Fade); /* Clay displacement */ val[0]+=area_normal[0] * ss->cache->scale[0]*node->Fade; val[1]+=area_normal[1] * ss->cache->scale[1]*node->Fade; val[2]+=area_normal[2] * ss->cache->scale[2]*node->Fade; } else - VecMulf(val, fabs(node->Fade)); + mul_v3_fl(val, fabs(node->Fade)); - VecAddf(val, val, co); + add_v3_v3v3(val, val, co); if( buffer != 0 ) { IndexLink *cur = &ss->drawobject->indices[node->Index]; @@ -747,7 +747,7 @@ static float tex_strength(Sculpt *sd, SculptSession *ss, float *point, const flo /* If the active area is being applied for symmetry, flip it across the symmetry axis in order to project it. This insures that the brush texture will be oriented correctly. */ - VecCopyf(flip, point); + copy_v3_v3(flip, point); flip_coord(flip, flip, ss->cache->symmetry); projectf(ss->cache->mats, flip, point_2d); @@ -852,7 +852,7 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) if(ss->multires || ss->projverts[i].inside) { //vert= ss->vertexcosnos ? &ss->vertexcosnos[i*6] : a->verts[i].co; vert= ss->mvert[i].co; - av_dist= VecLenf(ss->cache->location, vert); + av_dist= len_v3v3(ss->cache->location, vert); if(av_dist < cache->radius) { adata= (ActiveData*)MEM_mallocN(sizeof(ActiveData), "ActiveData"); @@ -911,7 +911,7 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) for(; adata; adata= adata->next) if(adata->Index < keyblock->totelem) - VecCopyf(&co[adata->Index*3], me->mvert[adata->Index].co); + copy_v3_v3(&co[adata->Index*3], me->mvert[adata->Index].co); } } @@ -940,8 +940,8 @@ static void do_symmetrical_brush_actions(Sculpt *sd, SculptSession *ss) const char symm = sd->flags & 7; int i; - VecCopyf(cache->location, cache->true_location); - VecCopyf(cache->grab_delta_symmetry, cache->grab_delta); + copy_v3_v3(cache->location, cache->true_location); + copy_v3_v3(cache->grab_delta_symmetry, cache->grab_delta); cache->symmetry = 0; do_brush_action(sd, ss, cache); @@ -963,15 +963,15 @@ static void add_face_normal(vec3f *norm, MVert *mvert, const MFace* face, float vec3f s1, s2; float final[3]; - VecSubf(&s1.x,&a.x,&b.x); - VecSubf(&s2.x,&c.x,&b.x); + sub_v3_v3v3(&s1.x,&a.x,&b.x); + sub_v3_v3v3(&s2.x,&c.x,&b.x); final[0] = s1.y * s2.z - s1.z * s2.y; final[1] = s1.z * s2.x - s1.x * s2.z; final[2] = s1.x * s2.y - s1.y * s2.x; if(fn) - VecCopyf(fn, final); + copy_v3_v3(fn, final); norm->x+= final[0]; norm->y+= final[1]; @@ -994,7 +994,7 @@ static void update_damaged_vert(SculptSession *ss, ListBase *lb) add_face_normal(&norm, ss->mvert, &ss->mface[face->index], fn); face= face->next; } - Normalize(&norm.x); + normalize_v3(&norm.x); ss->mvert[vert->Index].no[0]=norm.x*32767; ss->mvert[vert->Index].no[1]=norm.y*32767; @@ -1010,9 +1010,9 @@ static void update_damaged_vert(SculptSession *ss, ListBase *lb) else { float norm[3]; if( ss->mface[i].v4 ) - CalcNormFloat4(ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co, ss->mvert[ss->mface[i].v4].co, norm); + normal_quad_v3( norm,ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co, ss->mvert[ss->mface[i].v4].co); else - CalcNormFloat(ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co, norm); + normal_tri_v3( norm,ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co); VECCOPY(&buffer[(cur->element-cur->element%3)*3],norm); VECCOPY(&buffer[(cur->element-cur->element%3+1)*3],norm); VECCOPY(&buffer[(cur->element-cur->element%3+2)*3],norm); @@ -1259,7 +1259,7 @@ static float unproject_brush_radius(SculptSession *ss, float offset) view3d_unproject(ss->cache->mats, brush_edge, ss->cache->initial_mouse[0] + offset, ss->cache->initial_mouse[1], ss->cache->depth); - return VecLenf(ss->cache->true_location, brush_edge); + return len_v3v3(ss->cache->true_location, brush_edge); } static void sculpt_cache_free(StrokeCache *cache) @@ -1318,7 +1318,7 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte ss->mesh_co_orig= MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy"); for(i = 0; i < ss->totvert; ++i) - VecCopyf(ss->mesh_co_orig[i], ss->mvert[i].co); + copy_v3_v3(ss->mesh_co_orig[i], ss->mvert[i].co); } if(brush->flag & BRUSH_ANCHORED) { @@ -1333,7 +1333,7 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte float *fn = ss->face_normals; cache->face_norms= MEM_mallocN(sizeof(float) * 3 * ss->totface, "Sculpt face norms"); for(i = 0; i < ss->totface; ++i, fn += 3) - VecCopyf(cache->face_norms[i], fn); + copy_v3_v3(cache->face_norms[i], fn); } } } @@ -1400,8 +1400,8 @@ static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, PointerR if(brush->sculpt_tool == SCULPT_TOOL_GRAB) { view3d_unproject(cache->mats, grab_location, cache->mouse[0], cache->mouse[1], cache->depth); if(!cache->first_time) - VecSubf(cache->grab_delta, grab_location, cache->old_grab_location); - VecCopyf(cache->old_grab_location, grab_location); + sub_v3_v3v3(cache->grab_delta, grab_location, cache->old_grab_location); + copy_v3_v3(cache->old_grab_location, grab_location); } } @@ -1477,7 +1477,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) buffer= (float *)GPU_buffer_lock(ss->drawobject->normals); for(i = 0; i < ss->totvert; ++i) { - VecCopyf(ss->mvert[i].co, ss->mesh_co_orig[i]); + copy_v3_v3(ss->mvert[i].co, ss->mesh_co_orig[i]); ss->mvert[i].no[0] = cache->orig_norms[i][0]; ss->mvert[i].no[1] = cache->orig_norms[i][1]; ss->mvert[i].no[2] = cache->orig_norms[i][2]; @@ -1495,7 +1495,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) if(ss->face_normals) { float *fn = ss->face_normals; for(i = 0; i < ss->totface; ++i, fn += 3) - VecCopyf(fn, cache->face_norms[i]); + copy_v3_v3(fn, cache->face_norms[i]); } if(brush->sculpt_tool == SCULPT_TOOL_LAYER) diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 7f2e1bd09e4..77cfc2cd484 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" /* Types --------------------------------------------------------------- */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 0bcf4b037cb..a7c012fc654 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index cc8688031b0..c4f2e40e958 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dlrbTree.h" #include "DNA_anim_types.h" diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 07de15a26b4..870a67de330 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_colortools.h" diff --git a/source/blender/editors/space_api/space.c b/source/blender/editors/space_api/space.c index 3112cfffb22..5318eb33b1f 100644 --- a/source/blender/editors/space_api/space.c +++ b/source/blender/editors/space_api/space.c @@ -32,7 +32,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_screen.h" diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index f05c652c39d..2c918bd9b30 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -38,7 +38,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_colortools.h" diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index c6565eb6ecc..3dca5a4db4b 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_colortools.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 91d917acfe7..576736f026f 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -43,7 +43,7 @@ #include "BLO_readfile.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BLI_storage_types.h" diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index a4c98ecbf8e..38289e98391 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 40b7c071141..6e0878972f8 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -42,7 +42,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index b467d7b4ca0..2088ee4030c 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 09fde389f6f..8d2e2921b7f 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index ee4e371e1f1..40fe3393a60 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 342afab7534..f076bb5549e 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -38,7 +38,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 87b6ec8bb71..a184ea2b2c4 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -44,7 +44,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_rand.h" diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 8d7295e9f20..9ef7a4d9ae4 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -50,7 +50,7 @@ #include "BKE_report.h" #include "BKE_screen.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "IMB_imbuf.h" diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 36d1573a12c..8478b40092f 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -40,7 +40,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_rand.h" diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 518553c9a7a..c28e86a6fa6 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index c8f96fe3373..e159af65c74 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 836ac4c6659..62ed6a0a769 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -40,7 +40,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_screen.h" diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index b193b89d65a..3d43265b862 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 07dc3f0ad89..a9380c03346 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -53,7 +53,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_animsys.h" diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index b21f37ab678..c32058545fb 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -56,7 +56,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BLI_dlrbTree.h" diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index e53ccd004db..12e43465a29 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -42,7 +42,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_animsys.h" diff --git a/source/blender/editors/space_nla/nla_header.c b/source/blender/editors/space_nla/nla_header.c index a2524a1b2dc..0c0deaf75ef 100644 --- a/source/blender/editors/space_nla/nla_header.c +++ b/source/blender/editors/space_nla/nla_header.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_animsys.h" diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 6c940f32c24..d210016d201 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_animsys.h" diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 7c8f2aef9d0..801434c4794 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -41,7 +41,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_animsys.h" diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 5f2f75b7b6f..743f6e24d05 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_animsys.h" diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 110fb709db8..9a17a43620f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -32,7 +32,7 @@ #include #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_ID.h" #include "DNA_node_types.h" diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index b45b27f426a..d63b6403028 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -48,7 +48,7 @@ #include "DNA_text_types.h" #include "DNA_userdef_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 9eabf834a76..81c6490fda6 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -64,7 +64,7 @@ #include "BIF_gl.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_storage_types.h" @@ -2154,7 +2154,7 @@ static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) for(i=0; i 0) + if(isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) return 1; } return 0; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 46461eff76b..d8c6272dd77 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -40,7 +40,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_colortools.h" diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 93fdc96e9f7..5c6a8701f18 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -43,7 +43,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_colortools.h" diff --git a/source/blender/editors/space_script/script_ops.c b/source/blender/editors/space_script/script_ops.c index bf0a7e5769e..fd87705648f 100644 --- a/source/blender/editors/space_script/script_ops.c +++ b/source/blender/editors/space_script/script_ops.c @@ -37,7 +37,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index eae0f77d0e1..fc2f10670df 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_colortools.h" diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index bd5259ddb52..824dbd1caa8 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -38,7 +38,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_storage_types.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 76bed3772b1..ff9edeaeb4b 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -31,7 +31,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index bf7d0e78c92..a44b59d1377 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_storage_types.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 3e2f05f2901..94b79fdf685 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -38,7 +38,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 381d9241094..2ead426c18a 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -38,7 +38,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_curve_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 206070b7095..ed532edb0ec 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_colortools.h" diff --git a/source/blender/editors/space_sound/space_sound.c b/source/blender/editors/space_sound/space_sound.c index 7cd9988eea0..314e711234a 100644 --- a/source/blender/editors/space_sound/space_sound.c +++ b/source/blender/editors/space_sound/space_sound.c @@ -38,7 +38,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_colortools.h" diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index e9cd2644ba6..0b30587c521 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -39,7 +39,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_colortools.h" diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index fca7d6d7a9f..4c2fc1c5015 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -51,7 +51,7 @@ #include "DNA_userdef_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_dlrbTree.h" #include "BKE_animsys.h" @@ -510,36 +510,36 @@ static void draw_bone_solid_octahedral(void) glBegin(GL_TRIANGLES); /* bottom */ - CalcNormFloat(vec[2], vec[1], vec[0], nor); + normal_tri_v3( nor,vec[2], vec[1], vec[0]); glNormal3fv(nor); glVertex3fv(vec[2]); glVertex3fv(vec[1]); glVertex3fv(vec[0]); - CalcNormFloat(vec[3], vec[2], vec[0], nor); + normal_tri_v3( nor,vec[3], vec[2], vec[0]); glNormal3fv(nor); glVertex3fv(vec[3]); glVertex3fv(vec[2]); glVertex3fv(vec[0]); - CalcNormFloat(vec[4], vec[3], vec[0], nor); + normal_tri_v3( nor,vec[4], vec[3], vec[0]); glNormal3fv(nor); glVertex3fv(vec[4]); glVertex3fv(vec[3]); glVertex3fv(vec[0]); - CalcNormFloat(vec[1], vec[4], vec[0], nor); + normal_tri_v3( nor,vec[1], vec[4], vec[0]); glNormal3fv(nor); glVertex3fv(vec[1]); glVertex3fv(vec[4]); glVertex3fv(vec[0]); /* top */ - CalcNormFloat(vec[5], vec[1], vec[2], nor); + normal_tri_v3( nor,vec[5], vec[1], vec[2]); glNormal3fv(nor); glVertex3fv(vec[5]); glVertex3fv(vec[1]); glVertex3fv(vec[2]); - CalcNormFloat(vec[5], vec[2], vec[3], nor); + normal_tri_v3( nor,vec[5], vec[2], vec[3]); glNormal3fv(nor); glVertex3fv(vec[5]); glVertex3fv(vec[2]); glVertex3fv(vec[3]); - CalcNormFloat(vec[5], vec[3], vec[4], nor); + normal_tri_v3( nor,vec[5], vec[3], vec[4]); glNormal3fv(nor); glVertex3fv(vec[5]); glVertex3fv(vec[3]); glVertex3fv(vec[4]); - CalcNormFloat(vec[5], vec[4], vec[1], nor); + normal_tri_v3( nor,vec[5], vec[4], vec[1]); glNormal3fv(nor); glVertex3fv(vec[5]); glVertex3fv(vec[4]); glVertex3fv(vec[1]); @@ -642,7 +642,7 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], int boneflag /* figure out the sizes of spheres */ if (ebone) { /* this routine doesn't call get_matrix_editbone() that calculates it */ - ebone->length = VecLenf(ebone->head, ebone->tail); + ebone->length = len_v3v3(ebone->head, ebone->tail); length= ebone->length; tail= ebone->rad_tail; @@ -669,19 +669,19 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], int boneflag /* ***** draw it ***** */ /* move vector to viewspace */ - VecSubf(dirvec, tailvec, headvec); - Mat4Mul3Vecfl(smat, dirvec); + sub_v3_v3v3(dirvec, tailvec, headvec); + mul_mat3_m4_v3(smat, dirvec); /* clear zcomp */ dirvec[2]= 0.0f; /* move vector back */ - Mat4Mul3Vecfl(imat, dirvec); + mul_mat3_m4_v3(imat, dirvec); - if (0.0f != Normalize(dirvec)) { + if (0.0f != normalize_v3(dirvec)) { float norvec[3], vec1[3], vec2[3], vec[3]; int a; - //VecMulf(dirvec, head); - Crossf(norvec, dirvec, imat[2]); + //mul_v3_fl(dirvec, head); + cross_v3_v3v3(norvec, dirvec, imat[2]); glBegin(GL_QUAD_STRIP); @@ -752,7 +752,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], int armflag, /* figure out the sizes of spheres */ if (ebone) { /* this routine doesn't call get_matrix_editbone() that calculates it */ - ebone->length = VecLenf(ebone->head, ebone->tail); + ebone->length = len_v3v3(ebone->head, ebone->tail); length= ebone->length; tail= ebone->rad_tail; @@ -807,25 +807,25 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], int armflag, else UI_ThemeColor(TH_WIRE); } - VecSubf(dirvec, tailvec, headvec); + sub_v3_v3v3(dirvec, tailvec, headvec); /* move vector to viewspace */ - Mat4Mul3Vecfl(smat, dirvec); + mul_mat3_m4_v3(smat, dirvec); /* clear zcomp */ dirvec[2]= 0.0f; /* move vector back */ - Mat4Mul3Vecfl(imat, dirvec); + mul_mat3_m4_v3(imat, dirvec); - if (0.0f != Normalize(dirvec)) { + if (0.0f != normalize_v3(dirvec)) { float norvech[3], norvect[3], vec[3]; VECCOPY(vec, dirvec); - VecMulf(dirvec, head); - Crossf(norvech, dirvec, imat[2]); + mul_v3_fl(dirvec, head); + cross_v3_v3v3(norvech, dirvec, imat[2]); - VecMulf(vec, tail); - Crossf(norvect, vec, imat[2]); + mul_v3_fl(vec, tail); + cross_v3_v3v3(norvect, vec, imat[2]); if (id != -1) glLoadName(id | BONESEL_BONE); @@ -1463,12 +1463,12 @@ static void draw_pose_dofs(Object *ob) glTranslatef(posetrans[0], posetrans[1], posetrans[2]); if (pchan->parent) { - Mat4CpyMat4(mat, pchan->parent->pose_mat); + copy_m4_m4(mat, pchan->parent->pose_mat); mat[3][0]= mat[3][1]= mat[3][2]= 0.0f; glMultMatrixf(mat); } - Mat4CpyMat3(mat, pchan->bone->bone_mat); + copy_m4_m3(mat, pchan->bone->bone_mat); glMultMatrixf(mat); scale= bone->length*pchan->size[1]; @@ -1555,8 +1555,8 @@ static void bone_matrix_translate_y(float mat[][4], float y) float trans[3]; VECCOPY(trans, mat[1]); - VecMulf(trans, y); - VecAddf(mat[3], mat[3], trans); + mul_v3_fl(trans, y); + add_v3_v3v3(mat[3], mat[3], trans); } /* assumes object is Armature with pose */ @@ -1582,8 +1582,8 @@ static void draw_pose_channels(Scene *scene, View3D *v3d, ARegion *ar, Base *bas if (arm->drawtype==ARM_ENVELOPE) { /* precalc inverse matrix for drawing screen aligned */ wmGetMatrix(smat); - Mat4MulFloat3(smat[0], 1.0f/VecLength(ob->obmat[0])); - Mat4Invert(imat, smat); + mul_mat3_m4_fl(smat[0], 1.0f/len_v3(ob->obmat[0])); + invert_m4_m4(imat, smat); /* and draw blended distances */ if (arm->flag & ARM_POSEMODE) { @@ -1874,14 +1874,14 @@ static void draw_pose_channels(Scene *scene, View3D *v3d, ARegion *ar, Base *bas /* Draw names of bone */ if (arm->flag & ARM_DRAWNAMES) { - VecMidf(vec, pchan->pose_head, pchan->pose_tail); + mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail); view3d_cached_text_draw_add(vec[0], vec[1], vec[2], pchan->name, 10); } /* Draw additional axes on the bone tail */ if ( (arm->flag & ARM_DRAWAXES) && (arm->flag & ARM_POSEMODE) ) { glPushMatrix(); - Mat4CpyMat4(bmat, pchan->pose_mat); + copy_m4_m4(bmat, pchan->pose_mat); bone_matrix_translate_y(bmat, pchan->bone->length); glMultMatrixf(bmat); @@ -1908,14 +1908,14 @@ static void get_matrix_editbone(EditBone *eBone, float bmat[][4]) float mat[3][3]; /* Compose the parent transforms (i.e. their translations) */ - VecSubf(delta, eBone->tail, eBone->head); + sub_v3_v3v3(delta, eBone->tail, eBone->head); eBone->length = (float)sqrt(delta[0]*delta[0] + delta[1]*delta[1] +delta[2]*delta[2]); vec_roll_to_mat3(delta, eBone->roll, mat); - Mat4CpyMat3(bmat, mat); + copy_m4_m3(bmat, mat); - VecAddf(bmat[3], bmat[3], eBone->head); + add_v3_v3v3(bmat[3], bmat[3], eBone->head); } static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) @@ -1931,8 +1931,8 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) if(arm->drawtype==ARM_ENVELOPE) { /* precalc inverse matrix for drawing screen aligned */ wmGetMatrix(smat); - Mat4MulFloat3(smat[0], 1.0f/VecLength(ob->obmat[0])); - Mat4Invert(imat, smat); + mul_mat3_m4_fl(smat[0], 1.0f/len_v3(ob->obmat[0])); + invert_m4_m4(imat, smat); /* and draw blended distances */ glEnable(GL_BLEND); @@ -2070,7 +2070,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) /* Draw name */ if (arm->flag & ARM_DRAWNAMES) { - VecMidf(vec, eBone->head, eBone->tail); + mid_v3_v3v3(vec, eBone->head, eBone->tail); glRasterPos3fv(vec); view3d_cached_text_draw_add(vec[0], vec[1], vec[2], eBone->name, 10); } @@ -2243,7 +2243,7 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, ARegion *ar, Object *ob) view3d_cached_text_draw_add(fp[0], fp[1], fp[2], str, 0); } else if ((a > stepsize) && (a < len-stepsize)) { - if ((VecEqual(fp, fp-(stepsize*3))==0) || (VecEqual(fp, fp+(stepsize*3))==0)) { + if ((equals_v3v3(fp, fp-(stepsize*3))==0) || (equals_v3v3(fp, fp+(stepsize*3))==0)) { sprintf(str, "%d", (a+sfra)); view3d_cached_text_draw_add(fp[0], fp[1], fp[2], str, 0); } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 365b9ff03f7..bf73e70367c 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -31,7 +31,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" @@ -614,7 +614,7 @@ void draw_mesh_text(Scene *scene, Object *ob, int glsl) if (!mf_smooth) { float nor[3]; - CalcNormFloat(v1, v2, v3, nor); + normal_tri_v3( nor,v1, v2, v3); glNormal3fv(nor); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 22fd77afd88..339dc830016 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -65,7 +65,7 @@ #include "DNA_world_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_edgehash.h" #include "BLI_rand.h" @@ -152,7 +152,7 @@ static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr) /* clipplanes in eye space */ if(rv3d->rflag & RV3D_CLIPPING) { VECCOPY(vec4, vec); - Mat4MulVecfl(rv3d->viewmatob, vec4); + mul_m4_v3(rv3d->viewmatob, vec4); if(view3d_test_clipping(rv3d, vec4)) return; } @@ -160,7 +160,7 @@ static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr) VECCOPY(vec4, vec); vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmatob, vec4); + mul_m4_v4(rv3d->persmatob, vec4); /* clipplanes in window space */ if( vec4[3]>BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */ @@ -189,7 +189,7 @@ static void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr) VECCOPY(vec4, vec); vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmatob, vec4); + mul_m4_v4(rv3d->persmatob, vec4); if( vec4[3]>BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); @@ -456,8 +456,8 @@ void drawcircball(int mode, float *cent, float rad, float tmat[][4]) VECCOPY(vx, tmat[0]); VECCOPY(vy, tmat[1]); - VecMulf(vx, rad); - VecMulf(vy, rad); + mul_v3_fl(vx, rad); + mul_v3_fl(vy, rad); glBegin(mode); for(a=0; afirst; vos; vos= vos->next) { if(mat) - Mat4MulVecfl(mat, vos->vec); + mul_m4_v3(mat, vos->vec); view3d_project_short_clip(ar, vos->vec, vos->mval); if(vos->mval[0]!=IS_CLIPPED) tot++; @@ -674,7 +674,7 @@ static void drawshadbuflimits(Lamp *la, float mat[][4]) lavec[0]= -mat[2][0]; lavec[1]= -mat[2][1]; lavec[2]= -mat[2][2]; - Normalize(lavec); + normalize_v3(lavec); sta[0]= mat[3][0]+ la->clipsta*lavec[0]; sta[1]= mat[3][1]+ la->clipsta*lavec[1]; @@ -705,13 +705,13 @@ static void spotvolume(float *lvec, float *vvec, float inp) /* camera is at 0,0,0 */ float temp[3],plane[3],mat1[3][3],mat2[3][3],mat3[3][3],mat4[3][3],q[4],co,si,angle; - Normalize(lvec); - Normalize(vvec); /* is this the correct vector ? */ + normalize_v3(lvec); + normalize_v3(vvec); /* is this the correct vector ? */ - Crossf(temp,vvec,lvec); /* equation for a plane through vvec en lvec */ - Crossf(plane,lvec,temp); /* a plane perpendicular to this, parrallel with lvec */ + cross_v3_v3v3(temp,vvec,lvec); /* equation for a plane through vvec en lvec */ + cross_v3_v3v3(plane,lvec,temp); /* a plane perpendicular to this, parrallel with lvec */ - Normalize(plane); + normalize_v3(plane); /* now we've got two equations: one of a cone and one of a plane, but we have three unknowns. We remove one unkown by rotating the plane to z=0 (the plane normal) */ @@ -724,7 +724,7 @@ static void spotvolume(float *lvec, float *vvec, float inp) q[1] = plane[1] ; q[2] = -plane[0] ; q[3] = 0 ; - Normalize(&q[1]); + normalize_v3(&q[1]); angle = saacos(plane[2])/2.0; co = cos(angle); @@ -735,7 +735,7 @@ static void spotvolume(float *lvec, float *vvec, float inp) q[2] *= si; q[3] = 0; - QuatToMat3(q,mat1); + quat_to_mat3(mat1,q); /* rotate lamp vector now over acos(inp) degrees */ @@ -743,7 +743,7 @@ static void spotvolume(float *lvec, float *vvec, float inp) vvec[1] = lvec[1] ; vvec[2] = lvec[2] ; - Mat3One(mat2); + unit_m3(mat2); co = inp; si = sqrt(1-inp*inp); @@ -751,17 +751,17 @@ static void spotvolume(float *lvec, float *vvec, float inp) mat2[1][0] = -si; mat2[0][1] = si; mat2[1][1] = co; - Mat3MulMat3(mat3,mat2,mat1); + mul_m3_m3m3(mat3,mat2,mat1); mat2[1][0] = si; mat2[0][1] = -si; - Mat3MulMat3(mat4,mat2,mat1); - Mat3Transp(mat1); + mul_m3_m3m3(mat4,mat2,mat1); + transpose_m3(mat1); - Mat3MulMat3(mat2,mat1,mat3); - Mat3MulVecfl(mat2,lvec); - Mat3MulMat3(mat2,mat1,mat4); - Mat3MulVecfl(mat2,vvec); + mul_m3_m3m3(mat2,mat1,mat3); + mul_m3_v3(mat2,lvec); + mul_m3_m3m3(mat2,mat1,mat4); + mul_m3_v3(mat2,vvec); return; } @@ -789,9 +789,9 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob) lampsize= pixsize*((float)U.obcenter_dia*0.5f); /* and view aligned matrix: */ - Mat4CpyMat4(imat, rv3d->viewinv); - Normalize(imat[0]); - Normalize(imat[1]); + copy_m4_m4(imat, rv3d->viewinv); + normalize_v3(imat[0]); + normalize_v3(imat[1]); /* for AA effects */ glGetFloatv(GL_CURRENT_COLOR, curcol); @@ -835,13 +835,13 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob) short axis; /* setup a 45 degree rotation matrix */ - VecRotToMat3(imat[2], M_PI/4.0f, mat); + vec_rot_to_mat3( mat,imat[2], M_PI/4.0f); /* vectors */ VECCOPY(v1, imat[0]); - VecMulf(v1, circrad*1.2f); + mul_v3_fl(v1, circrad*1.2f); VECCOPY(v2, imat[0]); - VecMulf(v2, circrad*2.5f); + mul_v3_fl(v2, circrad*2.5f); /* center */ glTranslatef(vec[0], vec[1], vec[2]); @@ -852,8 +852,8 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob) for (axis=0; axis<8; axis++) { glVertex3fv(v1); glVertex3fv(v2); - Mat3MulVecfl(mat, v1); - Mat3MulVecfl(mat, v2); + mul_m3_v3(mat, v1); + mul_m3_v3(mat, v2); } glEnd(); @@ -1144,11 +1144,11 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob if(flag==0) { if(cam->flag & (CAM_SHOWLIMITS+CAM_SHOWMIST)) { wmLoadMatrix(rv3d->viewmat); - Mat4CpyMat4(vec, ob->obmat); - Mat4Ortho(vec); + copy_m4_m4(vec, ob->obmat); + normalize_m4(vec); wmMultMatrix(vec); - Mat4SwapMat4(rv3d->persmat, tmat); + swap_m4m4(rv3d->persmat, tmat); wmGetSingleMatrix(rv3d->persmat); if(cam->flag & CAM_SHOWLIMITS) { @@ -1161,7 +1161,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob if(cam->flag & CAM_SHOWMIST) if(wrld) draw_limit_line(wrld->miststa, wrld->miststa+wrld->mistdist, 0xFFFFFF); - Mat4SwapMat4(rv3d->persmat, tmat); + swap_m4m4(rv3d->persmat, tmat); } } } @@ -2271,13 +2271,13 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E z= 0.5f*(v1[2]+v2[2]); if(v3d->flag & V3D_GLOBAL_STATS) { - Mat4MulVecfl(ob->obmat, v1); - Mat4MulVecfl(ob->obmat, v2); + mul_m4_v3(ob->obmat, v1); + mul_m4_v3(ob->obmat, v2); } if(unit->system) - bUnit_AsString(val, sizeof(val), VecLenf(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); + bUnit_AsString(val, sizeof(val), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); else - sprintf(val, conv_float, VecLenf(v1, v2)); + sprintf(val, conv_float, len_v3v3(v1, v2)); view3d_cached_text_draw_add(x, y, z, val, 0); } @@ -2302,16 +2302,16 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E VECCOPY(v4, efa->v4->co); } if(v3d->flag & V3D_GLOBAL_STATS) { - Mat4MulVecfl(ob->obmat, v1); - Mat4MulVecfl(ob->obmat, v2); - Mat4MulVecfl(ob->obmat, v3); - if (efa->v4) Mat4MulVecfl(ob->obmat, v4); + mul_m4_v3(ob->obmat, v1); + mul_m4_v3(ob->obmat, v2); + mul_m4_v3(ob->obmat, v3); + if (efa->v4) mul_m4_v3(ob->obmat, v4); } if (efa->v4) - area= AreaQ3Dfl(v1, v2, v3, v4); + area= area_quad_v3(v1, v2, v3, v4); else - area = AreaT3Dfl(v1, v2, v3); + area = area_tri_v3(v1, v2, v3); if(unit->system) bUnit_AsString(val, sizeof(val), area*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); // XXX should be B_UNIT_AREA @@ -2343,10 +2343,10 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E VECCOPY(v4, v3); } if(v3d->flag & V3D_GLOBAL_STATS) { - Mat4MulVecfl(ob->obmat, v1); - Mat4MulVecfl(ob->obmat, v2); - Mat4MulVecfl(ob->obmat, v3); - Mat4MulVecfl(ob->obmat, v4); + mul_m4_v3(ob->obmat, v1); + mul_m4_v3(ob->obmat, v2); + mul_m4_v3(ob->obmat, v3); + mul_m4_v3(ob->obmat, v4); } e1= efa->e1; @@ -2358,30 +2358,30 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E if( (e4->f & e1->f & SELECT) || (G.moving && (efa->v1->f & SELECT)) ) { /* Vec 1 */ - sprintf(val,"%.3f", RAD2DEG(VecAngle3(v4, v1, v2))); - VecLerpf(fvec, efa->cent, efa->v1->co, 0.8f); + sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v4, v1, v2))); + interp_v3_v3v3(fvec, efa->cent, efa->v1->co, 0.8f); view3d_cached_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0); } if( (e1->f & e2->f & SELECT) || (G.moving && (efa->v2->f & SELECT)) ) { /* Vec 2 */ - sprintf(val,"%.3f", RAD2DEG(VecAngle3(v1, v2, v3))); - VecLerpf(fvec, efa->cent, efa->v2->co, 0.8f); + sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v1, v2, v3))); + interp_v3_v3v3(fvec, efa->cent, efa->v2->co, 0.8f); view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } if( (e2->f & e3->f & SELECT) || (G.moving && (efa->v3->f & SELECT)) ) { /* Vec 3 */ if(efa->v4) - sprintf(val,"%.3f", RAD2DEG(VecAngle3(v2, v3, v4))); + sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v2, v3, v4))); else - sprintf(val,"%.3f", RAD2DEG(VecAngle3(v2, v3, v1))); - VecLerpf(fvec, efa->cent, efa->v3->co, 0.8f); + sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v2, v3, v1))); + interp_v3_v3v3(fvec, efa->cent, efa->v3->co, 0.8f); view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } /* Vec 4 */ if(efa->v4) { if( (e3->f & e4->f & SELECT) || (G.moving && (efa->v4->f & SELECT)) ) { - sprintf(val,"%.3f", RAD2DEG(VecAngle3(v3, v4, v1))); - VecLerpf(fvec, efa->cent, efa->v4->co, 0.8f); + sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v3, v4, v1))); + interp_v3_v3v3(fvec, efa->cent, efa->v4->co, 0.8f); view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } } @@ -3434,7 +3434,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix { vec[0]=2.0f*pixsize; vec[1]=vec[2]=0.0; - QuatMulVecf(state->rot,vec); + mul_qt_v3(state->rot,vec); if(draw_as==PART_DRAW_AXIS) { cd[1]=cd[2]=cd[4]=cd[5]=0.0; cd[0]=cd[3]=1.0; @@ -3462,7 +3462,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix vec[1]=2.0f*pixsize; vec[0]=vec[2]=0.0; - QuatMulVecf(state->rot,vec); + mul_qt_v3(state->rot,vec); if(draw_as==PART_DRAW_AXIS){ VECCOPY(vec2,state->co); } @@ -3474,7 +3474,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix vec[2]=2.0f*pixsize; vec[0]=vec[1]=0.0; - QuatMulVecf(state->rot,vec); + mul_qt_v3(state->rot,vec); if(draw_as==PART_DRAW_AXIS){ VECCOPY(vec2,state->co); } @@ -3489,9 +3489,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix case PART_DRAW_LINE: { VECCOPY(vec,state->vel); - Normalize(vec); + normalize_v3(vec); if(draw & PART_DRAW_VEL_LENGTH) - VecMulf(vec,VecLength(state->vel)); + mul_v3_fl(vec,len_v3(state->vel)); VECADDFAC(pdd->vd,state->co,vec,-draw_line[0]); pdd->vd+=3; VECADDFAC(pdd->vd,state->co,vec,draw_line[1]); pdd->vd+=3; if(cd) { @@ -3649,7 +3649,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) { float mat[4][4]; - Mat4MulMat4(mat, psys->imat, ob->obmat); + mul_m4_m4m4(mat, psys->imat, ob->obmat); wmMultMatrix(mat); } @@ -3671,9 +3671,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv break; case PART_DRAW_CIRC: /* calculate view aligned matrix: */ - Mat4CpyMat4(imat, rv3d->viewinv); - Normalize(imat[0]); - Normalize(imat[1]); + copy_m4_m4(imat, rv3d->viewinv); + normalize_v3(imat[0]); + normalize_v3(imat[1]); /* no break! */ case PART_DRAW_CROSS: case PART_DRAW_AXIS: @@ -3729,9 +3729,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv break; } if(part->draw & PART_DRAW_SIZE && part->draw_as!=PART_DRAW_CIRC){ - Mat4CpyMat4(imat, rv3d->viewinv); - Normalize(imat[0]); - Normalize(imat[1]); + copy_m4_m4(imat, rv3d->viewinv); + normalize_v3(imat[0]); + normalize_v3(imat[1]); } if(!create_cdata && pdd && pdd->cdata) { @@ -3903,7 +3903,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv psys_get_particle_on_path(&sim,a,&state,need_v); if(psys->parent) - Mat4MulVecfl(psys->parent->obmat, state.co); + mul_m4_v3(psys->parent->obmat, state.co); /* create actiual particle data */ if(draw_as == PART_DRAW_BB) { @@ -3923,7 +3923,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv state.time=cfra; if(psys_get_particle_state(&sim,a,&state,0)){ if(psys->parent) - Mat4MulVecfl(psys->parent->obmat, state.co); + mul_m4_v3(psys->parent->obmat, state.co); /* create actiual particle data */ if(draw_as == PART_DRAW_BB) { @@ -3946,7 +3946,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv VECCOPY(pdd->ved,state.co); pdd->ved+=3; VECCOPY(vel,state.vel); - VecMulf(vel,timestep); + mul_v3_fl(vel,timestep); VECADD(pdd->ved,state.co,vel); pdd->ved+=3; @@ -4566,10 +4566,10 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, float vec_a[3] = { fac,0, 0}; // Offset perpendicular to the curve float vec_b[3] = {-fac,0, 0}; // Delta along the curve - QuatMulVecf(bevp->quat, vec_a); - QuatMulVecf(bevp->quat, vec_b); - VecAddf(vec_a, vec_a, bevp->vec); - VecAddf(vec_b, vec_b, bevp->vec); + mul_qt_v3(bevp->quat, vec_a); + mul_qt_v3(bevp->quat, vec_b); + add_v3_v3v3(vec_a, vec_a, bevp->vec); + add_v3_v3v3(vec_b, vec_b, bevp->vec); VECSUBFAC(vec_a, vec_a, bevp->dir, fac); VECSUBFAC(vec_b, vec_b, bevp->dir, fac); @@ -4711,8 +4711,8 @@ static void drawspiral(float *cent, float rad, float tmat[][4], int start) VECCOPY(vx, tmat[0]); VECCOPY(vy, tmat[1]); - VecMulf(vx, rad); - VecMulf(vy, rad); + mul_v3_fl(vx, rad); + mul_v3_fl(vy, rad); VECCOPY(vec, cent); @@ -4776,7 +4776,7 @@ static void drawtube(float *vec, float radius, float height, float tmat[][4]) float cur[3]; drawcircball(GL_LINE_LOOP, vec, radius, tmat); - VecCopyf(cur,vec); + copy_v3_v3(cur,vec); cur[2]+=height; drawcircball(GL_LINE_LOOP, cur, radius, tmat); @@ -4797,7 +4797,7 @@ static void drawcone(float *vec, float radius, float height, float tmat[][4]) { float cur[3]; - VecCopyf(cur,vec); + copy_v3_v3(cur,vec); cur[2]+=height; drawcircball(GL_LINE_LOOP, cur, radius, tmat); @@ -4845,9 +4845,9 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, else UI_ThemeColor(TH_WIRE); wmGetMatrix(tmat); - Mat4Invert(imat, tmat); - Normalize(imat[0]); - Normalize(imat[1]); + invert_m4_m4(imat, tmat); + normalize_v3(imat[0]); + normalize_v3(imat[1]); while(ml) { @@ -4904,14 +4904,14 @@ static void draw_forcefield(Scene *scene, Object *ob) /* calculus here, is reused in PFIELD_FORCE */ wmGetMatrix(tmat); - Mat4Invert(imat, tmat); -// Normalize(imat[0]); // we don't do this because field doesnt scale either... apart from wind! -// Normalize(imat[1]); + invert_m4_m4(imat, tmat); +// normalize_v3(imat[0]); // we don't do this because field doesnt scale either... apart from wind! +// normalize_v3(imat[1]); if (pd->forcefield == PFIELD_WIND) { float force_val; - Mat4One(tmat); + unit_m4(tmat); UI_ThemeColorBlend(curcol, TH_BACK, 0.5); //if (has_ipo_code(ob->ipo, OB_PD_FSTR)) @@ -4947,7 +4947,7 @@ static void draw_forcefield(Scene *scene, Object *ob) else if (pd->forcefield == PFIELD_VORTEX) { float ffall_val, force_val; - Mat4One(tmat); + unit_m4(tmat); //if (has_ipo_code(ob->ipo, OB_PD_FFALL)) // ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra); //else @@ -5008,7 +5008,7 @@ static void draw_forcefield(Scene *scene, Object *ob) else if(pd->falloff==PFIELD_FALL_TUBE){ float radius,distance; - Mat4One(tmat); + unit_m4(tmat); vec[0]=vec[1]=0.0f; radius=(pd->flag&PFIELD_USEMAXR)?pd->maxrad:1.0f; @@ -5030,7 +5030,7 @@ static void draw_forcefield(Scene *scene, Object *ob) else if(pd->falloff==PFIELD_FALL_CONE){ float radius,distance; - Mat4One(tmat); + unit_m4(tmat); radius=(pd->flag&PFIELD_USEMAXR)?pd->maxrad:1.0f; radius*=(float)M_PI/180.0f; @@ -5278,7 +5278,7 @@ static void draw_hooks(Object *ob) if (md->type==eModifierType_Hook) { HookModifierData *hmd = (HookModifierData*) md; - VecMat4MulVecfl(vec, ob->obmat, hmd->cent); + mul_v3_m4v3(vec, ob->obmat, hmd->cent); if(hmd->object) { setlinestyle(3); @@ -5310,7 +5310,7 @@ void drawRBpivot(bRigidBodyJointConstraint *data) if(G.f & G_RENDER_SHADOW) return; - EulToMat4(eu,mat); + eul_to_mat4(mat,eu); glLineWidth (4.0f); setlinestyle(2); for (axis=0; axis<3; axis++) { @@ -5319,7 +5319,7 @@ void drawRBpivot(bRigidBodyJointConstraint *data) dir[axis] = 1.f; glBegin(GL_LINES); - Mat4MulVecfl(mat,dir); + mul_m4_v3(mat,dir); v[0] += dir[0]; v[1] += dir[1]; v[2] += dir[2]; @@ -5895,7 +5895,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) vec[0]= vec[1]= vec[2]= 0.0; wmGetMatrix(tmat); - Mat4Invert(imat, tmat); + invert_m4_m4(imat, tmat); setlinestyle(2); drawcircball(GL_LINE_LOOP, vec, ob->inertia, imat); @@ -5982,7 +5982,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if (cti->get_target_matrix) cti->get_target_matrix(curcon, cob, ct, bsystem_time(scene, ob, (float)(scene->r.cfra), give_timeoffset(ob))); else - Mat4One(ct->matrix); + unit_m4(ct->matrix); setlinestyle(3); glBegin(GL_LINES); diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 3c80441b9e6..168e1f8592d 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -66,7 +66,7 @@ #include "DNA_world_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_edgehash.h" #include "BLI_rand.h" @@ -191,7 +191,7 @@ static int convex(float *p0, float *up, float *a, float *b) float va[3], vb[3], tmp[3]; VECSUB(va, a, p0); VECSUB(vb, b, p0); - Crossf(tmp, va, vb); + cross_v3_v3v3(tmp, va, vb); return INPR(up, tmp) >= 0; } @@ -363,7 +363,7 @@ void draw_volume(Scene *scene, ARegion *ar, View3D *v3d, Base *base, GPUTexture // get view vector VECCOPY(viewnormal, rv3d->viewinv[2]); - Normalize(viewnormal); + normalize_v3(viewnormal); // find cube vertex that is closest to the viewer for (i=0; i<8; i++) { @@ -433,7 +433,7 @@ void draw_volume(Scene *scene, ARegion *ar, View3D *v3d, Base *base, GPUTexture break; VECCOPY(tmp_point, viewnormal); - VecMulf(tmp_point, -dd*((ds/dd)-(float)n)); + mul_v3_fl(tmp_point, -dd*((ds/dd)-(float)n)); VECADD(tmp_point2, cv[good_index], tmp_point); d = INPR(tmp_point2, viewnormal); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 453f16239fe..d470774f76a 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -40,7 +40,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_action.h" diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 608a22ea529..d3a922af67e 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -52,7 +52,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" @@ -176,7 +176,7 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d if(eve->f & SELECT) { evedef= eve; tot++; - VecAddf(median, median, eve->co); + add_v3_v3v3(median, median, eve->co); } eve= eve->next; } @@ -232,18 +232,18 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d a= nu->pntsu; while(a--) { if(bezt->f2 & SELECT) { - VecAddf(median, median, bezt->vec[1]); + add_v3_v3v3(median, median, bezt->vec[1]); tot++; median[4]+= bezt->weight; totweight++; } else { if(bezt->f1 & SELECT) { - VecAddf(median, median, bezt->vec[0]); + add_v3_v3v3(median, median, bezt->vec[0]); tot++; } if(bezt->f3 & SELECT) { - VecAddf(median, median, bezt->vec[2]); + add_v3_v3v3(median, median, bezt->vec[2]); tot++; } } @@ -255,7 +255,7 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d a= nu->pntsu*nu->pntsv; while(a--) { if(bp->f1 & SELECT) { - VecAddf(median, median, bp->vec); + add_v3_v3v3(median, median, bp->vec); median[3]+= bp->vec[3]; totw++; tot++; @@ -277,7 +277,7 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d bp= lt->editlatt->def; while(a--) { if(bp->f1 & SELECT) { - VecAddf(median, median, bp->vec); + add_v3_v3v3(median, median, bp->vec); tot++; median[4]+= bp->weight; totweight++; @@ -296,7 +296,7 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d if(totweight) median[4] /= (float)totweight; if(v3d->flag & V3D_GLOBAL_STATS) - Mat4MulVecfl(ob->obmat, median); + mul_m4_v3(ob->obmat, median); if(block) { // buttons int but_y; @@ -371,11 +371,11 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d memcpy(ve_median, tfp->ve_median, sizeof(tfp->ve_median)); if(v3d->flag & V3D_GLOBAL_STATS) { - Mat4Invert(ob->imat, ob->obmat); - Mat4MulVecfl(ob->imat, median); - Mat4MulVecfl(ob->imat, ve_median); + invert_m4_m4(ob->imat, ob->obmat); + mul_m4_v3(ob->imat, median); + mul_m4_v3(ob->imat, ve_median); } - VecSubf(median, ve_median, median); + sub_v3_v3v3(median, ve_median, median); median[3]= ve_median[3]-median[3]; median[4]= ve_median[4]-median[4]; @@ -388,7 +388,7 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d eve= em->verts.first; while(eve) { if(eve->f & SELECT) { - VecAddf(eve->co, eve->co, median); + add_v3_v3v3(eve->co, eve->co, median); } eve= eve->next; } @@ -423,17 +423,17 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d a= nu->pntsu; while(a--) { if(bezt->f2 & SELECT) { - VecAddf(bezt->vec[0], bezt->vec[0], median); - VecAddf(bezt->vec[1], bezt->vec[1], median); - VecAddf(bezt->vec[2], bezt->vec[2], median); + add_v3_v3v3(bezt->vec[0], bezt->vec[0], median); + add_v3_v3v3(bezt->vec[1], bezt->vec[1], median); + add_v3_v3v3(bezt->vec[2], bezt->vec[2], median); bezt->weight+= median[4]; } else { if(bezt->f1 & SELECT) { - VecAddf(bezt->vec[0], bezt->vec[0], median); + add_v3_v3v3(bezt->vec[0], bezt->vec[0], median); } if(bezt->f3 & SELECT) { - VecAddf(bezt->vec[2], bezt->vec[2], median); + add_v3_v3v3(bezt->vec[2], bezt->vec[2], median); } } bezt++; @@ -444,7 +444,7 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d a= nu->pntsu*nu->pntsv; while(a--) { if(bp->f1 & SELECT) { - VecAddf(bp->vec, bp->vec, median); + add_v3_v3v3(bp->vec, bp->vec, median); bp->vec[3]+= median[3]; bp->weight+= median[4]; } @@ -466,7 +466,7 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d bp= lt->editlatt->def; while(a--) { if(bp->f1 & SELECT) { - VecAddf(bp->vec, bp->vec, median); + add_v3_v3v3(bp->vec, bp->vec, median); bp->weight+= median[4]; } bp++; @@ -606,13 +606,13 @@ static void v3d_posearmature_buts(uiLayout *layout, View3D *v3d, Object *ob, flo if (pchan->rotmode == ROT_MODE_AXISANGLE) { float quat[4]; /* convert to euler, passing through quats... */ - AxisAngleToQuat(quat, pchan->rotAxis, pchan->rotAngle); - QuatToEul(quat, tfp->ob_eul); + axis_angle_to_quat(quat, pchan->rotAxis, pchan->rotAngle); + quat_to_eul( tfp->ob_eul,quat); } else if (pchan->rotmode == ROT_MODE_QUAT) - QuatToEul(pchan->quat, tfp->ob_eul); + quat_to_eul( tfp->ob_eul,pchan->quat); else - VecCopyf(tfp->ob_eul, pchan->eul); + copy_v3_v3(tfp->ob_eul, pchan->eul); tfp->ob_eul[0]*= 180.0/M_PI; tfp->ob_eul[1]*= 180.0/M_PI; tfp->ob_eul[2]*= 180.0/M_PI; @@ -823,13 +823,13 @@ static void do_view3d_region_buttons(bContext *C, void *arg, int event) if (pchan->rotmode == ROT_MODE_AXISANGLE) { float quat[4]; /* convert to axis-angle, passing through quats */ - EulToQuat(eul, quat); - QuatToAxisAngle(quat, pchan->rotAxis, &pchan->rotAngle); + eul_to_quat( quat,eul); + quat_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,quat); } else if (pchan->rotmode == ROT_MODE_QUAT) - EulToQuat(eul, pchan->quat); + eul_to_quat( pchan->quat,eul); else - VecCopyf(pchan->eul, eul); + copy_v3_v3(pchan->eul, eul); } /* no break, pass on */ case B_ARMATUREPANEL2: diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 2879dc3ed22..ee0830e85da 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -48,7 +48,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_anim.h" @@ -251,7 +251,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u vec4[0]=vec4[1]=vec4[2]=0.0; vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmat, vec4); + mul_m4_v4(rv3d->persmat, vec4); fx= vec4[0]; fy= vec4[1]; fw= vec4[3]; @@ -266,7 +266,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u vec4[2]= 0.0; vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmat, vec4); + mul_m4_v4(rv3d->persmat, vec4); fx= vec4[0]; fy= vec4[1]; fw= vec4[3]; @@ -596,7 +596,7 @@ static void draw_view_axis(RegionView3D *rv3d) /* X */ vec[0] = vec[3] = 1; vec[1] = vec[2] = 0; - QuatMulVecf(rv3d->viewquat, vec); + mul_qt_v3(rv3d->viewquat, vec); UI_make_axis_color((char *)gridcol, (char *)col, 'x'); rgb_to_hsv(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, &h, &s, &v); @@ -616,7 +616,7 @@ static void draw_view_axis(RegionView3D *rv3d) /* Y */ vec[1] = vec[3] = 1; vec[0] = vec[2] = 0; - QuatMulVecf(rv3d->viewquat, vec); + mul_qt_v3(rv3d->viewquat, vec); UI_make_axis_color((char *)gridcol, (char *)col, 'y'); rgb_to_hsv(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, &h, &s, &v); @@ -636,7 +636,7 @@ static void draw_view_axis(RegionView3D *rv3d) /* Z */ vec[2] = vec[3] = 1; vec[1] = vec[0] = 0; - QuatMulVecf(rv3d->viewquat, vec); + mul_qt_v3(rv3d->viewquat, vec); UI_make_axis_color((char *)gridcol, (char *)col, 'z'); rgb_to_hsv(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, &h, &s, &v); @@ -1558,7 +1558,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas /* need this for next part of code */ bb= object_get_boundbox(dob->ob); - Mat4One(dob->ob->obmat); /* obmat gets restored */ + unit_m4(dob->ob->obmat); /* obmat gets restored */ displist= glGenLists(1); glNewList(displist, GL_COMPILE); @@ -1576,7 +1576,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas wmLoadMatrix(rv3d->viewmat); } else { - Mat4CpyMat4(dob->ob->obmat, dob->mat); + copy_m4_m4(dob->ob->obmat, dob->mat); draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR); } @@ -1689,9 +1689,9 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ - Mat4MulMat4(rv3d->persmat, rv3d->viewmat, rv3d->winmat); - Mat4Invert(rv3d->persinv, rv3d->persmat); - Mat4Invert(rv3d->viewinv, rv3d->viewmat); + mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat); + invert_m4_m4(rv3d->persinv, rv3d->persmat); + invert_m4_m4(rv3d->viewinv, rv3d->viewmat); glClear(GL_DEPTH_BUFFER_BIT); @@ -1899,29 +1899,29 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, /* setup window matrices */ if(winmat) - Mat4CpyMat4(rv3d->winmat, winmat); + copy_m4_m4(rv3d->winmat, winmat); else setwinmatrixview3d(ar, v3d, NULL); /* NULL= no pickrect */ /* setup view matrix */ if(viewmat) - Mat4CpyMat4(rv3d->viewmat, viewmat); + copy_m4_m4(rv3d->viewmat, viewmat); else setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ /* update utilitity matrices */ - Mat4MulMat4(rv3d->persmat, rv3d->viewmat, rv3d->winmat); - Mat4Invert(rv3d->persinv, rv3d->persmat); - Mat4Invert(rv3d->viewinv, rv3d->viewmat); + mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat); + invert_m4_m4(rv3d->persinv, rv3d->persmat); + invert_m4_m4(rv3d->viewinv, rv3d->viewmat); /* calculate pixelsize factor once, is used for lamps and obcenters */ { float len1, len2, vec[3]; VECCOPY(vec, rv3d->persinv[0]); - len1= Normalize(vec); + len1= normalize_v3(vec); VECCOPY(vec, rv3d->persinv[1]); - len2= Normalize(vec); + len2= normalize_v3(vec); rv3d->pixsize= 2.0f*(len1>len2?len1:len2); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 49f2ece0bc4..6ef08a1c217 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -46,7 +46,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BKE_action.h" @@ -141,12 +141,12 @@ static void view3d_boxview_clip(ScrArea *sa) } /* normals for plane equations */ - CalcNormFloat(bb->vec[0], bb->vec[1], bb->vec[4], clip[0]); - CalcNormFloat(bb->vec[1], bb->vec[2], bb->vec[5], clip[1]); - CalcNormFloat(bb->vec[2], bb->vec[3], bb->vec[6], clip[2]); - CalcNormFloat(bb->vec[3], bb->vec[0], bb->vec[7], clip[3]); - CalcNormFloat(bb->vec[4], bb->vec[5], bb->vec[6], clip[4]); - CalcNormFloat(bb->vec[0], bb->vec[2], bb->vec[1], clip[5]); + normal_tri_v3( clip[0],bb->vec[0], bb->vec[1], bb->vec[4]); + normal_tri_v3( clip[1],bb->vec[1], bb->vec[2], bb->vec[5]); + normal_tri_v3( clip[2],bb->vec[2], bb->vec[3], bb->vec[6]); + normal_tri_v3( clip[3],bb->vec[3], bb->vec[0], bb->vec[7]); + normal_tri_v3( clip[4],bb->vec[4], bb->vec[5], bb->vec[6]); + normal_tri_v3( clip[5],bb->vec[0], bb->vec[2], bb->vec[1]); /* then plane equations */ for(val=0; val<5; val++) { @@ -299,7 +299,7 @@ static void viewops_data(bContext *C, wmOperator *op, wmEvent *event) /* If there's no selection, lastofs is unmodified and last value since static */ calculateTransformCenter(C, event, V3D_CENTROID, lastofs); VECCOPY(vod->obofs, lastofs); - VecMulf(vod->obofs, -1.0f); + mul_v3_fl(vod->obofs, -1.0f); } /* lookup, we dont pass on v3d to prevent confusement */ @@ -422,13 +422,13 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) calctrackballvec(&vod->ar->winrct, x, y, newvec); - VecSubf(dvec, newvec, vod->trackvec); + sub_v3_v3v3(dvec, newvec, vod->trackvec); si= sqrt(dvec[0]*dvec[0]+ dvec[1]*dvec[1]+ dvec[2]*dvec[2]); si/= (2.0*TRACKBALLSIZE); - Crossf(q1+1, vod->trackvec, newvec); - Normalize(q1+1); + cross_v3_v3v3(q1+1, vod->trackvec, newvec); + normalize_v3(q1+1); /* Allow for rotation beyond the interval * [-pi, pi] */ @@ -447,19 +447,19 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) q1[1]*= si; q1[2]*= si; q1[3]*= si; - QuatMul(rv3d->viewquat, q1, vod->oldquat); + mul_qt_qtqt(rv3d->viewquat, q1, vod->oldquat); if (use_sel) { /* compute the post multiplication quat, to rotate the offset correctly */ QUATCOPY(q1, vod->oldquat); - QuatConj(q1); - QuatMul(q1, q1, rv3d->viewquat); + conjugate_qt(q1); + mul_qt_qtqt(q1, q1, rv3d->viewquat); - QuatConj(q1); /* conj == inv for unit quat */ + conjugate_qt(q1); /* conj == inv for unit quat */ VECCOPY(rv3d->ofs, vod->ofs); - VecSubf(rv3d->ofs, rv3d->ofs, vod->obofs); - QuatMulVecf(q1, rv3d->ofs); - VecAddf(rv3d->ofs, rv3d->ofs, vod->obofs); + sub_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs); + mul_qt_v3(q1, rv3d->ofs); + add_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs); } } else { @@ -475,12 +475,12 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) const float sensitivity = 0.0035; /* Get the 3x3 matrix and its inverse from the quaternion */ - QuatToMat3(rv3d->viewquat, m); - Mat3Inv(m_inv,m); + quat_to_mat3( m,rv3d->viewquat); + invert_m3_m3(m_inv,m); /* Determine the direction of the x vector (for rotating up and down) */ /* This can likely be compuated directly from the quaternion. */ - Mat3MulVecfl(m_inv,xvec); + mul_m3_v3(m_inv,xvec); /* Perform the up/down rotation */ phi = sensitivity * -(y - vod->oldy); @@ -489,13 +489,13 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) q1[1] = si * xvec[0]; q1[2] = si * xvec[1]; q1[3] = si * xvec[2]; - QuatMul(rv3d->viewquat, rv3d->viewquat, q1); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1); if (use_sel) { - QuatConj(q1); /* conj == inv for unit quat */ - VecSubf(rv3d->ofs, rv3d->ofs, vod->obofs); - QuatMulVecf(q1, rv3d->ofs); - VecAddf(rv3d->ofs, rv3d->ofs, vod->obofs); + conjugate_qt(q1); /* conj == inv for unit quat */ + sub_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs); + mul_qt_v3(q1, rv3d->ofs); + add_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs); } /* Perform the orbital rotation */ @@ -503,13 +503,13 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) q1[0] = cos(phi); q1[1] = q1[2] = 0.0; q1[3] = sin(phi); - QuatMul(rv3d->viewquat, rv3d->viewquat, q1); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1); if (use_sel) { - QuatConj(q1); - VecSubf(rv3d->ofs, rv3d->ofs, vod->obofs); - QuatMulVecf(q1, rv3d->ofs); - VecAddf(rv3d->ofs, rv3d->ofs, vod->obofs); + conjugate_qt(q1); + sub_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs); + mul_qt_v3(q1, rv3d->ofs); + add_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs); } } @@ -519,17 +519,17 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) float viewmat[3][3]; - QuatToMat3(rv3d->viewquat, viewmat); + quat_to_mat3( viewmat,rv3d->viewquat); for (i = 0 ; i < 39; i++){ float snapmat[3][3]; float view = (int)snapquats[i][4]; - QuatToMat3(snapquats[i], snapmat); + quat_to_mat3( snapmat,snapquats[i]); - if ((Inpf(snapmat[0], viewmat[0]) > thres) && - (Inpf(snapmat[1], viewmat[1]) > thres) && - (Inpf(snapmat[2], viewmat[2]) > thres)){ + if ((dot_v3v3(snapmat[0], viewmat[0]) > thres) && + (dot_v3v3(snapmat[1], viewmat[1]) > thres) && + (dot_v3v3(snapmat[2], viewmat[2]) > thres)){ QUATCOPY(rv3d->viewquat, snapquats[i]); @@ -678,7 +678,7 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) float dvec[3]; window_to_3d_delta(vod->ar, dvec, x-vod->oldx, y-vod->oldy); - VecAddf(vod->rv3d->ofs, vod->rv3d->ofs, dvec); + add_v3_v3v3(vod->rv3d->ofs, vod->rv3d->ofs, dvec); if(vod->rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_sync(vod->sa, vod->ar); @@ -868,9 +868,9 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y) upvec[0] = upvec[1] = 0.0f; upvec[2] = (vod->dist0 - vod->rv3d->dist) * vod->grid; vod->rv3d->dist = vod->dist0; - Mat3CpyMat4(mat, vod->rv3d->viewinv); - Mat3MulVecfl(mat, upvec); - VecAddf(vod->rv3d->ofs, vod->rv3d->ofs, upvec); + copy_m3_m4(mat, vod->rv3d->viewinv); + mul_m3_v3(mat, upvec); + add_v3_v3v3(vod->rv3d->ofs, vod->rv3d->ofs, upvec); } else { /* these limits were in old code too */ if(vod->rv3d->dist<0.001*vod->grid) vod->rv3d->dist= 0.001*vod->grid; @@ -1142,10 +1142,10 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with if(pchan->bone->layer & arm->layer) { ok= 1; VECCOPY(vec, pchan->pose_head); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); DO_MINMAX(vec, min, max); VECCOPY(vec, pchan->pose_tail); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); DO_MINMAX(vec, min, max); } } @@ -1401,7 +1401,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) dvec[1] = p[1]-p_corner[1]; dvec[2] = p[2]-p_corner[2]; - new_dist = VecLength(dvec); + new_dist = len_v3(dvec); if(new_dist <= v3d->near*1.5) new_dist= v3d->near*1.5; new_ofs[0] = -p[0]; @@ -1430,7 +1430,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) window_to_3d_delta(ar, dvec, (rect.xmin+rect.xmax-vb[0])/2, (rect.ymin+rect.ymax-vb[1])/2); /* center the view to the center of the rectangle */ - VecSubf(new_ofs, new_ofs, dvec); + sub_v3_v3v3(new_ofs, new_ofs, dvec); } /* work out the ratios, so that everything selected fits when we zoom */ @@ -1524,9 +1524,9 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s /* same as transform manipulator when normal is set */ ED_getTransformOrientationMatrix(C, twmat, TRUE); - Mat3ToQuat(twmat, obact_quat); - QuatInv(obact_quat); - QuatMul(new_quat, new_quat, obact_quat); + mat3_to_quat( obact_quat,twmat); + invert_qt(obact_quat); + mul_qt_qtqt(new_quat, new_quat, obact_quat); rv3d->view= view= 0; } @@ -1704,14 +1704,14 @@ static int vieworbit_exec(bContext *C, wmOperator *op) q1[0]= (float)cos(phi); q1[1]= q1[2]= 0.0; q1[3]= si; - QuatMul(rv3d->viewquat, rv3d->viewquat, q1); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1); rv3d->view= 0; } if(orbitdir == V3D_VIEW_STEPDOWN || orbitdir == V3D_VIEW_STEPUP) { /* horizontal axis */ VECCOPY(q1+1, rv3d->viewinv[0]); - Normalize(q1+1); + normalize_v3(q1+1); phi= (float)(M_PI/360.0)*U.pad_rot_angle; if(orbitdir == V3D_VIEW_STEPDOWN) phi= -phi; si= (float)sin(phi); @@ -1719,7 +1719,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) q1[1]*= si; q1[2]*= si; q1[3]*= si; - QuatMul(rv3d->viewquat, rv3d->viewquat, q1); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1); rv3d->view= 0; } ED_region_tag_redraw(ar); @@ -1881,7 +1881,7 @@ static int view3d_clipping_exec(bContext *C, wmOperator *op) /* then plane equations */ for(val=0; val<4; val++) { - CalcNormFloat(rv3d->clipbb->vec[val], rv3d->clipbb->vec[val==3?0:val+1], rv3d->clipbb->vec[val+4], rv3d->clip[val]); + normal_tri_v3( rv3d->clip[val],rv3d->clipbb->vec[val], rv3d->clipbb->vec[val==3?0:val+1], rv3d->clipbb->vec[val+4]); rv3d->clip[val][3]= - rv3d->clip[val][0]*rv3d->clipbb->vec[val][0] - rv3d->clip[val][1]*rv3d->clipbb->vec[val][1] @@ -1960,7 +1960,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *op, wmEvent *event) if(mval[0]!=IS_CLIPPED) { window_to_3d_delta(ar, dvec, mval[0]-mx, mval[1]-my); - VecSubf(fp, fp, dvec); + sub_v3_v3v3(fp, fp, dvec); } else { @@ -2247,9 +2247,9 @@ void viewmoveNDOFfly(ARegion *ar, View3D *v3d, int mode) m_dist = rv3d->dist; upvec[0] = upvec[1] = 0; upvec[2] = rv3d->dist; - Mat3CpyMat4(mat, rv3d->viewinv); - Mat3MulVecfl(mat, upvec); - VecSubf(rv3d->ofs, rv3d->ofs, upvec); + copy_m3_m4(mat, rv3d->viewinv); + mul_m3_v3(mat, upvec); + sub_v3_v3v3(rv3d->ofs, rv3d->ofs, upvec); rv3d->dist = 0.0; } @@ -2263,16 +2263,16 @@ void viewmoveNDOFfly(ARegion *ar, View3D *v3d, int mode) // rotate device x and y by view z - Mat3CpyMat4(mat, rv3d->viewinv); + copy_m3_m4(mat, rv3d->viewinv); mat[2][2] = 0.0f; - Mat3MulVecfl(mat, rvec); + mul_m3_v3(mat, rvec); // rotate the view - phi = Normalize(rvec); + phi = normalize_v3(rvec); if(phi != 0) { - VecRotToQuat(rvec,phi,q1); - QuatMul(rv3d->viewquat, rv3d->viewquat, q1); + axis_angle_to_quat(q1,rvec,phi); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1); } @@ -2285,13 +2285,13 @@ void viewmoveNDOFfly(ARegion *ar, View3D *v3d, int mode) // the next three lines rotate the x and y translation coordinates // by the current z axis angle - Mat3CpyMat4(mat, rv3d->viewinv); + copy_m3_m4(mat, rv3d->viewinv); mat[2][2] = 0.0f; - Mat3MulVecfl(mat, tvec); + mul_m3_v3(mat, tvec); // translate the view - VecSubf(rv3d->ofs, rv3d->ofs, tvec); + sub_v3_v3v3(rv3d->ofs, rv3d->ofs, tvec); /*---------------------------------------------------- @@ -2350,9 +2350,9 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) rv3d->dist = m_dist; upvec[0] = upvec[1] = 0; upvec[2] = rv3d->dist; - Mat3CpyMat4(mat, rv3d->viewinv); - Mat3MulVecfl(mat, upvec); - VecAddf(rv3d->ofs, rv3d->ofs, upvec); + copy_m3_m4(mat, rv3d->viewinv); + mul_m3_v3(mat, upvec); + add_v3_v3v3(rv3d->ofs, rv3d->ofs, upvec); } /*---------------------------------------------------- @@ -2414,8 +2414,8 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) d = 1.0f; /* if (ob) { - VecSubf(diff, obofs, rv3d->ofs); - d = VecLength(diff); + sub_v3_v3v3(diff, obofs, rv3d->ofs); + d = len_v3(diff); } */ @@ -2430,7 +2430,7 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) dvec[0] = curareaX * rv3d->persinv[0][0] + curareaY * rv3d->persinv[1][0]; dvec[1] = curareaX * rv3d->persinv[0][1] + curareaY * rv3d->persinv[1][1]; dvec[2] = curareaX * rv3d->persinv[0][2] + curareaY * rv3d->persinv[1][2]; - VecAddf(rv3d->ofs, rv3d->ofs, dvec); + add_v3_v3v3(rv3d->ofs, rv3d->ofs, dvec); /*---------------------------------------------------- * ndof device dolly @@ -2455,14 +2455,14 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) */ /* Get the 3x3 matrix and its inverse from the quaternion */ - QuatToMat3(rv3d->viewquat, m); - Mat3Inv(m_inv,m); + quat_to_mat3( m,rv3d->viewquat); + invert_m3_m3(m_inv,m); /* Determine the direction of the x vector (for rotating up and down) */ /* This can likely be compuated directly from the quaternion. */ - Mat3MulVecfl(m_inv,xvec); - Mat3MulVecfl(m_inv,yvec); - Mat3MulVecfl(m_inv,zvec); + mul_m3_v3(m_inv,xvec); + mul_m3_v3(m_inv,yvec); + mul_m3_v3(m_inv,zvec); /* Perform the up/down rotation */ phi = sbadjust * rsens * /*0.5f * */ fval[3]; /* spin vertically half as fast as horizontally */ @@ -2471,13 +2471,13 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) q1[1] = si * xvec[0]; q1[2] = si * xvec[1]; q1[3] = si * xvec[2]; - QuatMul(rv3d->viewquat, rv3d->viewquat, q1); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1); if (use_sel) { - QuatConj(q1); /* conj == inv for unit quat */ - VecSubf(rv3d->ofs, rv3d->ofs, obofs); - QuatMulVecf(q1, rv3d->ofs); - VecAddf(rv3d->ofs, rv3d->ofs, obofs); + conjugate_qt(q1); /* conj == inv for unit quat */ + sub_v3_v3v3(rv3d->ofs, rv3d->ofs, obofs); + mul_qt_v3(q1, rv3d->ofs); + add_v3_v3v3(rv3d->ofs, rv3d->ofs, obofs); } /* Perform the orbital rotation */ @@ -2496,13 +2496,13 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) q1[0] = cos(phi); q1[1] = q1[2] = 0.0; q1[3] = sin(phi); - QuatMul(rv3d->viewquat, rv3d->viewquat, q1); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1); if (use_sel) { - QuatConj(q1); - VecSubf(rv3d->ofs, rv3d->ofs, obofs); - QuatMulVecf(q1, rv3d->ofs); - VecAddf(rv3d->ofs, rv3d->ofs, obofs); + conjugate_qt(q1); + sub_v3_v3v3(rv3d->ofs, rv3d->ofs, obofs); + mul_qt_v3(q1, rv3d->ofs); + add_v3_v3v3(rv3d->ofs, rv3d->ofs, obofs); } /*---------------------------------------------------- diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index d37c81904cf..7e2f41b369b 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -85,7 +85,7 @@ #include "BIF_gl.h" #include "BIF_glutil.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" @@ -635,7 +635,7 @@ void do_view3d_transform_moveaxismenu(bContext *C, void *arg, int event) #if 0 float mat[3][3]; - Mat3One(mat); + unit_m3(mat); switch(event) { @@ -702,7 +702,7 @@ void do_view3d_transform_rotateaxismenu(bContext *C, void *arg, int event) #if 0 float mat[3][3]; - Mat3One(mat); + unit_m3(mat); switch(event) { @@ -769,7 +769,7 @@ void do_view3d_transform_scaleaxismenu(bContext *C, void *arg, int event) #if 0 float mat[3][3]; - Mat3One(mat); + unit_m3(mat); switch(event) { diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index adda08202c0..b8945c849ae 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -39,7 +39,7 @@ #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 2505110d766..4b35cd186e6 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -49,7 +49,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" @@ -120,7 +120,7 @@ void view3d_get_view_aligned_coordinate(ViewContext *vc, float *fp, short mval[2 if(mval[0]!=IS_CLIPPED) { window_to_3d_delta(vc->ar, dvec, mval[0]-mx, mval[1]-my); - VecSubf(fp, fp, dvec); + sub_v3_v3v3(fp, fp, dvec); } } @@ -129,7 +129,7 @@ void view3d_get_transformation(ViewContext *vc, Object *ob, bglMats *mats) float cpy[4][4]; int i, j; - Mat4MulMat4(cpy, ob->obmat, vc->rv3d->viewmat); + mul_m4_m4m4(cpy, ob->obmat, vc->rv3d->viewmat); for(i = 0; i < 4; ++i) { for(j = 0; j < 4; ++j) { @@ -326,9 +326,9 @@ int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, in /* no points in lasso, so we have to intersect with lasso edge */ - if( IsectLL2Ds(mcords[0], mcords[moves-1], v1, v2) > 0) return 1; + if( isect_line_line_v2_short(mcords[0], mcords[moves-1], v1, v2) > 0) return 1; for(a=0; a 0) return 1; + if( isect_line_line_v2_short(mcords[a], mcords[a+1], v1, v2) > 0) return 1; } return 0; @@ -349,10 +349,10 @@ static void do_lasso_select_pose(ViewContext *vc, short mcords[][2], short moves for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { VECCOPY(vec, pchan->pose_head); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); project_short(vc->ar, vec, sco1); VECCOPY(vec, pchan->pose_tail); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); project_short(vc->ar, vec, sco2); if(lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { @@ -625,10 +625,10 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { VECCOPY(vec, ebone->head); - Mat4MulVecfl(vc->obedit->obmat, vec); + mul_m4_v3(vc->obedit->obmat, vec); project_short(vc->ar, vec, sco1); VECCOPY(vec, ebone->tail); - Mat4MulVecfl(vc->obedit->obmat, vec); + mul_m4_v3(vc->obedit->obmat, vec); project_short(vc->ar, vec, sco2); didpoint= 0; @@ -1227,7 +1227,7 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, v2[0]= x2; v2[1]= y2; - if( PdistVL2Dfl(v3, v1, v2) < (float)rad ) return 1; + if( dist_to_line_segment_v2(v3, v1, v2) < (float)rad ) return 1; return 0; } @@ -1859,12 +1859,12 @@ static void armature_circle_select(ViewContext *vc, int selecting, short *mval, /* project head location to screenspace */ VECCOPY(vec, ebone->head); - Mat4MulVecfl(vc->obedit->obmat, vec); + mul_m4_v3(vc->obedit->obmat, vec); project_short(vc->ar, vec, sco1); /* project tail location to screenspace */ VECCOPY(vec, ebone->tail); - Mat4MulVecfl(vc->obedit->obmat, vec); + mul_m4_v3(vc->obedit->obmat, vec); project_short(vc->ar, vec, sco2); /* check if the head and/or tail is in the circle diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 205d3e6df8c..933b12ae679 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -48,7 +48,7 @@ #include "DNA_view3d_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_linklist.h" @@ -135,8 +135,8 @@ static void special_transvert_update(Scene *scene, Object *obedit) if (tv) { float diffvec[3]; - VecSubf(diffvec, tv->loc, tv->oldloc); - VecAddf(ebo->tail, ebo->tail, diffvec); + sub_v3_v3v3(diffvec, tv->loc, tv->oldloc); + add_v3_v3v3(ebo->tail, ebo->tail, diffvec); a++; if (aobmat); - Mat3Inv(imat, bmat); + copy_m3_m4(bmat, obedit->obmat); + invert_m3_m3(imat, bmat); tv= transvmain; for(a=0; aloc); - Mat3MulVecfl(bmat, vec); - VecAddf(vec, vec, obedit->obmat[3]); + mul_m3_v3(bmat, vec); + add_v3_v3v3(vec, vec, obedit->obmat[3]); vec[0]= v3d->gridview*floor(.5+ vec[0]/gridf); vec[1]= v3d->gridview*floor(.5+ vec[1]/gridf); vec[2]= v3d->gridview*floor(.5+ vec[2]/gridf); - VecSubf(vec, vec, obedit->obmat[3]); + sub_v3_v3v3(vec, vec, obedit->obmat[3]); - Mat3MulVecfl(imat, vec); + mul_m3_v3(imat, vec); VECCOPY(tv->loc, vec); } @@ -525,8 +525,8 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op) if(ob->parent) { where_is_object(scene, ob); - Mat3Inv(imat, originmat); - Mat3MulVecfl(imat, vec); + invert_m3_m3(imat, originmat); + mul_m3_v3(imat, vec); ob->loc[0]+= vec[0]; ob->loc[1]+= vec[1]; ob->loc[2]+= vec[2]; @@ -586,8 +586,8 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op) make_trans_verts(obedit, bmat[0], bmat[1], 0); if(tottrans==0) return OPERATOR_CANCELLED; - Mat3CpyMat4(bmat, obedit->obmat); - Mat3Inv(imat, bmat); + copy_m3_m4(bmat, obedit->obmat); + invert_m3_m3(imat, bmat); tv= transvmain; for(a=0; aobmat[3][1]; vec[2]= curs[2]-obedit->obmat[3][2]; - Mat3MulVecfl(imat, vec); + mul_m3_v3(imat, vec); VECCOPY(tv->loc, vec); } @@ -612,9 +612,9 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op) bArmature *arm= ob->data; float cursp[3]; - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); VECCOPY(cursp, curs); - Mat4MulVecfl(ob->imat, cursp); + mul_m4_v3(ob->imat, cursp); for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { if(pchan->bone->flag & BONE_SELECTED) { @@ -650,8 +650,8 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op) if(ob->parent) { where_is_object(scene, ob); - Mat3Inv(imat, originmat); - Mat3MulVecfl(imat, vec); + invert_m3_m3(imat, originmat); + mul_m3_v3(imat, vec); ob->loc[0]+= vec[0]; ob->loc[1]+= vec[1]; ob->loc[2]+= vec[2]; @@ -749,19 +749,19 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op) make_trans_verts(obedit, bmat[0], bmat[1], 2); if(tottrans==0) return OPERATOR_CANCELLED; - Mat3CpyMat4(bmat, obedit->obmat); + copy_m3_m4(bmat, obedit->obmat); tv= transvmain; for(a=0; aloc); - Mat3MulVecfl(bmat, vec); - VecAddf(vec, vec, obedit->obmat[3]); - VecAddf(centroid, centroid, vec); + mul_m3_v3(bmat, vec); + add_v3_v3v3(vec, vec, obedit->obmat[3]); + add_v3_v3v3(centroid, centroid, vec); DO_MINMAX(vec, min, max); } if(v3d->around==V3D_CENTROID) { - VecMulf(centroid, 1.0/(float)tottrans); + mul_v3_fl(centroid, 1.0/(float)tottrans); VECCOPY(curs, centroid); } else { @@ -782,8 +782,8 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op) if(arm->layer & pchan->bone->layer) { if(pchan->bone->flag & BONE_SELECTED) { VECCOPY(vec, pchan->pose_head); - Mat4MulVecfl(ob->obmat, vec); - VecAddf(centroid, centroid, vec); + mul_m4_v3(ob->obmat, vec); + add_v3_v3v3(centroid, centroid, vec); DO_MINMAX(vec, min, max); count++; } @@ -793,7 +793,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op) else { CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { VECCOPY(vec, ob->obmat[3]); - VecAddf(centroid, centroid, vec); + add_v3_v3v3(centroid, centroid, vec); DO_MINMAX(vec, min, max); count++; } @@ -801,7 +801,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op) } if(count) { if(v3d->around==V3D_CENTROID) { - VecMulf(centroid, 1.0/(float)count); + mul_v3_fl(centroid, 1.0/(float)count); VECCOPY(curs, centroid); } else { @@ -854,7 +854,7 @@ static int snap_curs_to_active(bContext *C, wmOperator *op) EM_editselection_center(curs, &ese); } - Mat4MulVecfl(obedit->obmat, curs); + mul_m4_v3(obedit->obmat, curs); } } else { @@ -908,20 +908,20 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) make_trans_verts(obedit, bmat[0], bmat[1], 0); if(tottrans==0) return OPERATOR_CANCELLED; - Mat3CpyMat4(bmat, obedit->obmat); - Mat3Inv(imat, bmat); + copy_m3_m4(bmat, obedit->obmat); + invert_m3_m3(imat, bmat); tv= transvmain; for(a=0; aloc); - Mat3MulVecfl(bmat, vec); - VecAddf(vec, vec, obedit->obmat[3]); - VecAddf(centroid, centroid, vec); + mul_m3_v3(bmat, vec); + add_v3_v3v3(vec, vec, obedit->obmat[3]); + add_v3_v3v3(centroid, centroid, vec); DO_MINMAX(vec, min, max); } if(v3d->around==V3D_CENTROID) { - VecMulf(centroid, 1.0/(float)tottrans); + mul_v3_fl(centroid, 1.0/(float)tottrans); VECCOPY(snaploc, centroid); } else { @@ -944,7 +944,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) if(pchan->bone->flag & BONE_SELECTED) { if(pchan->bone->layer & arm->layer) { VECCOPY(vec, pchan->pose_mat[3]); - VecAddf(centroid, centroid, vec); + add_v3_v3v3(centroid, centroid, vec); DO_MINMAX(vec, min, max); count++; } @@ -954,7 +954,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) else { /* not armature bones (i.e. objects) */ VECCOPY(vec, ob->obmat[3]); - VecAddf(centroid, centroid, vec); + add_v3_v3v3(centroid, centroid, vec); DO_MINMAX(vec, min, max); count++; } @@ -963,7 +963,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) if(count) { if(v3d->around==V3D_CENTROID) { - VecMulf(centroid, 1.0/(float)count); + mul_v3_fl(centroid, 1.0/(float)count); VECCOPY(snaploc, centroid); } else { @@ -982,8 +982,8 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) make_trans_verts(obedit, bmat[0], bmat[1], 0); if(tottrans==0) return OPERATOR_CANCELLED; - Mat3CpyMat4(bmat, obedit->obmat); - Mat3Inv(imat, bmat); + copy_m3_m4(bmat, obedit->obmat); + invert_m3_m3(imat, bmat); tv= transvmain; for(a=0; aobmat[3][1]; vec[2]= snaploc[2]-obedit->obmat[3][2]; - Mat3MulVecfl(imat, vec); + mul_m3_v3(imat, vec); VECCOPY(tv->loc, vec); } @@ -1040,8 +1040,8 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) if(ob->parent) { where_is_object(scene, ob); - Mat3Inv(imat, originmat); - Mat3MulVecfl(imat, vec); + invert_m3_m3(imat, originmat); + mul_m3_v3(imat, vec); ob->loc[0]+= vec[0]; ob->loc[1]+= vec[1]; ob->loc[2]+= vec[2]; @@ -1093,14 +1093,14 @@ int minmax_verts(Object *obedit, float *min, float *max) if(tottrans==0) return 0; - Mat3CpyMat4(bmat, obedit->obmat); + copy_m3_m4(bmat, obedit->obmat); tv= transvmain; for(a=0; aloc); - Mat3MulVecfl(bmat, vec); - VecAddf(vec, vec, obedit->obmat[3]); - VecAddf(centroid, centroid, vec); + mul_m3_v3(bmat, vec); + add_v3_v3v3(vec, vec, obedit->obmat[3]); + add_v3_v3v3(centroid, centroid, vec); DO_MINMAX(vec, min, max); } diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index e1c6f70bde0..3249f26aff6 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -51,7 +51,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 9fbc916c02d..96a16e733d0 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -45,7 +45,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" @@ -161,26 +161,26 @@ static void view_settings_from_ob(Object *ob, float *ofs, float *quat, float *di /* Offset */ if (ofs) { VECCOPY(ofs, ob->obmat[3]); - VecMulf(ofs, -1.0f); /*flip the vector*/ + mul_v3_fl(ofs, -1.0f); /*flip the vector*/ } /* Quat */ if (quat) { - Mat4CpyMat4(bmat, ob->obmat); - Mat4Ortho(bmat); - Mat4Invert(imat, bmat); - Mat3CpyMat4(tmat, imat); - Mat3ToQuat(tmat, quat); + copy_m4_m4(bmat, ob->obmat); + normalize_m4(bmat); + invert_m4_m4(imat, bmat); + copy_m3_m4(tmat, imat); + mat3_to_quat( quat,tmat); } if (dist) { float vec[3]; - Mat3CpyMat4(tmat, ob->obmat); + copy_m3_m4(tmat, ob->obmat); vec[0]= vec[1] = 0.0; vec[2]= -(*dist); - Mat3MulVecfl(tmat, vec); - VecSubf(ofs, ofs, vec); + mul_m3_v3(tmat, vec); + sub_v3_v3v3(ofs, ofs, vec); } /* Lens */ @@ -263,10 +263,10 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo VECCOPY(vec1, sms.new_quat); VECCOPY(vec2, sms.orig_quat); - Normalize(vec1); - Normalize(vec2); + normalize_v3(vec1); + normalize_v3(vec2); /* scale the time allowed by the rotation */ - sms.time_allowed *= NormalizedVecAngle2(vec1, vec2)/(M_PI/2); + sms.time_allowed *= angle_normalized_v3v3(vec1, vec2)/(M_PI/2); } /* original values */ @@ -361,7 +361,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *op, wmEvent *event) for (i=0; i<3; i++) rv3d->ofs[i] = sms->new_ofs[i]*step + sms->orig_ofs[i]*step_inv; - QuatInterpol(rv3d->viewquat, sms->orig_quat, sms->new_quat, step); + interp_qt_qtqt(rv3d->viewquat, sms->orig_quat, sms->new_quat, step); rv3d->dist = sms->new_dist*step + sms->orig_dist*step_inv; v3d->lens = sms->new_lens*step + sms->orig_lens*step_inv; @@ -395,10 +395,10 @@ static void setcameratoview3d(View3D *v3d, RegionView3D *rv3d, Object *ob) dvec[2]= rv3d->dist*rv3d->viewinv[2][2]; VECCOPY(ob->loc, dvec); - VecSubf(ob->loc, ob->loc, rv3d->ofs); + sub_v3_v3v3(ob->loc, ob->loc, rv3d->ofs); rv3d->viewquat[0]= -rv3d->viewquat[0]; - QuatToEul(rv3d->viewquat, ob->rot); + quat_to_eul( ob->rot,rv3d->viewquat); rv3d->viewquat[0]= -rv3d->viewquat[0]; ob->recalc= OB_RECALC_OB; @@ -493,12 +493,12 @@ void viewline(ARegion *ar, View3D *v3d, float mval[2], float ray_start[3], float vec[2]= -1.0f; vec[3]= 1.0f; - Mat4MulVec4fl(rv3d->persinv, vec); - VecMulf(vec, 1.0f / vec[3]); + mul_m4_v4(rv3d->persinv, vec); + mul_v3_fl(vec, 1.0f / vec[3]); VECCOPY(ray_start, rv3d->viewinv[3]); VECSUB(vec, vec, ray_start); - Normalize(vec); + normalize_v3(vec); VECADDFAC(ray_start, rv3d->viewinv[3], vec, v3d->near); VECADDFAC(ray_end, rv3d->viewinv[3], vec, v3d->far); @@ -509,7 +509,7 @@ void viewline(ARegion *ar, View3D *v3d, float mval[2], float ray_start[3], float vec[2] = 0.0f; vec[3] = 1.0f; - Mat4MulVec4fl(rv3d->persinv, vec); + mul_m4_v4(rv3d->persinv, vec); VECADDFAC(ray_start, vec, rv3d->viewinv[2], 1000.0f); VECADDFAC(ray_end, vec, rv3d->viewinv[2], -1000.0f); @@ -522,8 +522,8 @@ void viewray(ARegion *ar, View3D *v3d, float mval[2], float ray_start[3], float float ray_end[3]; viewline(ar, v3d, mval, ray_start, ray_end); - VecSubf(ray_normal, ray_end, ray_start); - Normalize(ray_normal); + sub_v3_v3v3(ray_normal, ray_end, ray_start); + normalize_v3(ray_normal); } @@ -601,8 +601,8 @@ void view3d_get_object_project_mat(RegionView3D *rv3d, Object *ob, float pmat[4] { float vmat[4][4]; - Mat4MulMat4(vmat, ob->obmat, rv3d->viewmat); - Mat4MulMat4(pmat, vmat, rv3d->winmat); + mul_m4_m4m4(vmat, ob->obmat, rv3d->viewmat); + mul_m4_m4m4(pmat, vmat, rv3d->winmat); } /* Uses window coordinates (x,y) and depth component z to find a point in @@ -627,7 +627,7 @@ void view3d_project_float(ARegion *ar, float *vec, float *adr, float mat[4][4]) VECCOPY(vec4, vec); vec4[3]= 1.0; - Mat4MulVec4fl(mat, vec4); + mul_m4_v4(mat, vec4); if( vec4[3]>FLT_EPSILON ) { adr[0] = (float)(ar->winx/2.0f)+(ar->winx/2.0f)*vec4[0]/vec4[3]; @@ -648,12 +648,12 @@ int boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb) if(bb==NULL) return 1; if(bb->flag & OB_BB_DISABLED) return 1; - Mat4MulMat4(mat, obmat, rv3d->persmat); + mul_m4_m4m4(mat, obmat, rv3d->persmat); for(a=0; a<8; a++) { VECCOPY(vec, bb->vec[a]); vec[3]= 1.0; - Mat4MulVec4fl(mat, vec); + mul_m4_v4(mat, vec); max= vec[3]; min= -vec[3]; @@ -686,7 +686,7 @@ void project_short(ARegion *ar, float *vec, short *adr) /* clips */ VECCOPY(vec4, vec); vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmat, vec4); + mul_m4_v4(rv3d->persmat, vec4); if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); @@ -712,7 +712,7 @@ void project_int(ARegion *ar, float *vec, int *adr) VECCOPY(vec4, vec); vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmat, vec4); + mul_m4_v4(rv3d->persmat, vec4); if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); @@ -736,7 +736,7 @@ void project_int_noclip(ARegion *ar, float *vec, int *adr) VECCOPY(vec4, vec); vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmat, vec4); + mul_m4_v4(rv3d->persmat, vec4); if( fabs(vec4[3]) > BL_NEAR_CLIP ) { fx = (ar->winx/2)*(1 + vec4[0]/vec4[3]); @@ -761,7 +761,7 @@ void project_short_noclip(ARegion *ar, float *vec, short *adr) VECCOPY(vec4, vec); vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmat, vec4); + mul_m4_v4(rv3d->persmat, vec4); if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); @@ -787,7 +787,7 @@ void project_float(ARegion *ar, float *vec, float *adr) VECCOPY(vec4, vec); vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmat, vec4); + mul_m4_v4(rv3d->persmat, vec4); if( vec4[3]>BL_NEAR_CLIP ) { adr[0] = (float)(ar->winx/2.0)+(ar->winx/2.0)*vec4[0]/vec4[3]; @@ -803,7 +803,7 @@ void project_float_noclip(ARegion *ar, float *vec, float *adr) VECCOPY(vec4, vec); vec4[3]= 1.0; - Mat4MulVec4fl(rv3d->persmat, vec4); + mul_m4_v4(rv3d->persmat, vec4); if( fabs(vec4[3]) > BL_NEAR_CLIP ) { adr[0] = (float)(ar->winx/2.0)+(ar->winx/2.0)*vec4[0]/vec4[3]; @@ -1001,12 +1001,12 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->view= 0; /* dont show the grid */ - Mat4CpyMat4(bmat, ob->obmat); - Mat4Ortho(bmat); - Mat4Invert(rv3d->viewmat, bmat); + copy_m4_m4(bmat, ob->obmat); + normalize_m4(bmat); + invert_m4_m4(rv3d->viewmat, bmat); /* view quat calculation, needed for add object */ - Mat3CpyMat4(tmat, rv3d->viewmat); + copy_m3_m4(tmat, rv3d->viewmat); if (smooth) { float new_quat[4]; if (rv3d->persp==RV3D_CAMOB && v3d->camera) { @@ -1018,7 +1018,7 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short VECCOPY(orig_ofs, rv3d->ofs); /* Switch from camera view */ - Mat3ToQuat(tmat, new_quat); + mat3_to_quat( new_quat,tmat); rv3d->persp=RV3D_PERSP; rv3d->dist= 0.0; @@ -1029,11 +1029,11 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->persp=RV3D_CAMOB; /* just to be polite, not needed */ } else { - Mat3ToQuat(tmat, new_quat); + mat3_to_quat( new_quat,tmat); smooth_view(NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX } } else { - Mat3ToQuat(tmat, rv3d->viewquat); + mat3_to_quat( rv3d->viewquat,tmat); } } @@ -1077,7 +1077,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) obmat_to_viewmat(v3d, rv3d, v3d->camera, 0); } else { - QuatToMat4(rv3d->viewquat, rv3d->viewmat); + quat_to_mat4( rv3d->viewmat,rv3d->viewquat); rv3d->viewmat[3][2]-= rv3d->dist; } } @@ -1086,7 +1086,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) if(rv3d->viewlock) view3d_viewlock(rv3d); - QuatToMat4(rv3d->viewquat, rv3d->viewmat); + quat_to_mat4( rv3d->viewmat,rv3d->viewquat); if(rv3d->persp==RV3D_PERSP) rv3d->viewmat[3][2]-= rv3d->dist; if(v3d->ob_centre) { Object *ob= v3d->ob_centre; @@ -1097,12 +1097,12 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) bPoseChannel *pchan= get_pose_channel(ob->pose, v3d->ob_centre_bone); if(pchan) { VECCOPY(vec, pchan->pose_mat[3]); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); } } - i_translate(-vec[0], -vec[1], -vec[2], rv3d->viewmat); + translate_m4( rv3d->viewmat,-vec[0], -vec[1], -vec[2]); } - else i_translate(rv3d->ofs[0], rv3d->ofs[1], rv3d->ofs[2], rv3d->viewmat); + else translate_m4( rv3d->viewmat,rv3d->ofs[0], rv3d->ofs[1], rv3d->ofs[2]); } } @@ -1136,7 +1136,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b } setwinmatrixview3d(ar, v3d, &rect); - Mat4MulMat4(vc->rv3d->persmat, vc->rv3d->viewmat, vc->rv3d->winmat); + mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->viewmat, vc->rv3d->winmat); if(v3d->drawtype > OB_WIRE) { v3d->zbuf= TRUE; @@ -1186,11 +1186,11 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b for(dob= lb->first; dob; dob= dob->next) { tbase.object= dob->ob; - Mat4CpyMat4(dob->ob->obmat, dob->mat); + copy_m4_m4(dob->ob->obmat, dob->mat); draw_object(scene, ar, v3d, &tbase, DRAW_PICKING|DRAW_CONSTCOLOR); - Mat4CpyMat4(dob->ob->obmat, dob->omat); + copy_m4_m4(dob->ob->obmat, dob->omat); } free_object_duplilist(lb); } @@ -1206,7 +1206,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b G.f &= ~G_PICKSEL; setwinmatrixview3d(ar, v3d, NULL); - Mat4MulMat4(vc->rv3d->persmat, vc->rv3d->viewmat, vc->rv3d->winmat); + mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->viewmat, vc->rv3d->winmat); if(v3d->drawtype > OB_WIRE) { v3d->zbuf= 0; @@ -1851,8 +1851,8 @@ int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event) /* detect weather to start with Z locking */ upvec[0]=1.0f; upvec[1]=0.0f; upvec[2]=0.0f; - Mat3CpyMat4(mat, fly->rv3d->viewinv); - Mat3MulVecfl(mat, upvec); + copy_m3_m4(mat, fly->rv3d->viewinv); + mul_m3_v3(mat, upvec); if (fabs(upvec[2]) < 0.1) fly->zlock = 1; upvec[0]=0; upvec[1]=0; upvec[2]=0; @@ -1866,7 +1866,7 @@ int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event) where_is_object(fly->scene, fly->v3d->camera); VECCOPY(fly->rv3d->ofs, fly->v3d->camera->obmat[3]); - VecMulf(fly->rv3d->ofs, -1.0f); /*flip the vector*/ + mul_v3_fl(fly->rv3d->ofs, -1.0f); /*flip the vector*/ fly->rv3d->dist=0.0; fly->rv3d->viewbut=0; @@ -1884,8 +1884,8 @@ int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event) fly->rv3d->dist= 0.0; upvec[2]= fly->dist_backup; /*x and y are 0*/ - Mat3MulVecfl(mat, upvec); - VecSubf(fly->rv3d->ofs, fly->rv3d->ofs, upvec); + mul_m3_v3(mat, upvec); + sub_v3_v3v3(fly->rv3d->ofs, fly->rv3d->ofs, upvec); /*Done with correcting for the dist*/ } @@ -1922,8 +1922,8 @@ static int flyEnd(bContext *C, FlyInfo *fly) } else if (fly->persp_backup==RV3D_CAMOB) { /* camera */ float mat3[3][3]; - Mat3CpyMat4(mat3, v3d->camera->obmat); - Mat3ToCompatibleEul(mat3, v3d->camera->rot, fly->rot_backup); + copy_m3_m4(mat3, v3d->camera->obmat); + mat3_to_compatible_eul( v3d->camera->rot, fly->rot_backup,mat3); DAG_id_flush_update(&v3d->camera->id, OB_RECALC_OB); #if 0 //XXX2.5 @@ -1941,9 +1941,9 @@ static int flyEnd(bContext *C, FlyInfo *fly) float mat[3][3]; upvec[0]= upvec[1]= 0; upvec[2]= fly->dist_backup; /*x and y are 0*/ - Mat3CpyMat4(mat, rv3d->viewinv); - Mat3MulVecfl(mat, upvec); - VecAddf(rv3d->ofs, rv3d->ofs, upvec); + copy_m3_m4(mat, rv3d->viewinv); + mul_m3_v3(mat, upvec); + add_v3_v3v3(rv3d->ofs, rv3d->ofs, upvec); /*Done with correcting for the dist */ } @@ -2176,7 +2176,7 @@ int flyApply(FlyInfo *fly) if (fly->use_precision) fly->speed= fly->speed * (1.0f-time_redraw_clamped); - Mat3CpyMat4(mat, rv3d->viewinv); + copy_m3_m4(mat, rv3d->viewinv); if (fly->pan_view==TRUE) { /* pan only */ @@ -2189,8 +2189,8 @@ int flyApply(FlyInfo *fly) dvec_tmp[1] *= 0.1; } - Mat3MulVecfl(mat, dvec_tmp); - VecMulf(dvec_tmp, time_redraw*200.0 * fly->grid); + mul_m3_v3(mat, dvec_tmp); + mul_v3_fl(dvec_tmp, time_redraw*200.0 * fly->grid); } else { float roll; /* similar to the angle between the camera's up and the Z-up, but its very rough so just roll*/ @@ -2200,9 +2200,9 @@ int flyApply(FlyInfo *fly) upvec[0]=1; upvec[1]=0; upvec[2]=0; - Mat3MulVecfl(mat, upvec); - VecRotToQuat( upvec, (float)moffset[1]*-time_redraw*20, tmp_quat); /* Rotate about the relative up vec */ - QuatMul(rv3d->viewquat, rv3d->viewquat, tmp_quat); + mul_m3_v3(mat, upvec); + axis_angle_to_quat( tmp_quat, upvec, (float)moffset[1]*-time_redraw*20); /* Rotate about the relative up vec */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); if (fly->xlock) fly->xlock = 2; /*check for rotation*/ if (fly->zlock) fly->zlock = 2; @@ -2216,7 +2216,7 @@ int flyApply(FlyInfo *fly) upvec[0]=0; upvec[1]=1; upvec[2]=0; - Mat3MulVecfl(mat, upvec); + mul_m3_v3(mat, upvec); if(upvec[2] < 0.0f) moffset[0]= -moffset[0]; @@ -2230,11 +2230,11 @@ int flyApply(FlyInfo *fly) upvec[0]=0; upvec[1]=1; upvec[2]=0; - Mat3MulVecfl(mat, upvec); + mul_m3_v3(mat, upvec); } - VecRotToQuat( upvec, (float)moffset[0]*time_redraw*20, tmp_quat); /* Rotate about the relative up vec */ - QuatMul(rv3d->viewquat, rv3d->viewquat, tmp_quat); + axis_angle_to_quat( tmp_quat, upvec, (float)moffset[0]*time_redraw*20); /* Rotate about the relative up vec */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); if (fly->xlock) fly->xlock = 2;/*check for rotation*/ if (fly->zlock) fly->zlock = 2; @@ -2244,7 +2244,7 @@ int flyApply(FlyInfo *fly) upvec[0]=1; upvec[1]=0; upvec[2]=0; - Mat3MulVecfl(mat, upvec); + mul_m3_v3(mat, upvec); /*make sure we have some z rolling*/ if (fabs(upvec[2]) > 0.00001f) { @@ -2253,9 +2253,9 @@ int flyApply(FlyInfo *fly) upvec[1]=0; upvec[2]=1; - Mat3MulVecfl(mat, upvec); - VecRotToQuat( upvec, roll*time_redraw_clamped*fly->zlock_momentum*0.1, tmp_quat); /* Rotate about the relative up vec */ - QuatMul(rv3d->viewquat, rv3d->viewquat, tmp_quat); + mul_m3_v3(mat, upvec); + axis_angle_to_quat( tmp_quat, upvec, roll*time_redraw_clamped*fly->zlock_momentum*0.1); /* Rotate about the relative up vec */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); fly->zlock_momentum += 0.05f; } else { @@ -2268,7 +2268,7 @@ int flyApply(FlyInfo *fly) upvec[0]=0; upvec[1]=0; upvec[2]=1; - Mat3MulVecfl(mat, upvec); + mul_m3_v3(mat, upvec); /*make sure we have some z rolling*/ if (fabs(upvec[2]) > 0.00001) { roll= upvec[2] * -5; @@ -2277,10 +2277,10 @@ int flyApply(FlyInfo *fly) upvec[1]= 0.0f; upvec[2]= 0.0f; - Mat3MulVecfl(mat, upvec); + mul_m3_v3(mat, upvec); - VecRotToQuat( upvec, roll*time_redraw_clamped*fly->xlock_momentum*0.1f, tmp_quat); /* Rotate about the relative up vec */ - QuatMul(rv3d->viewquat, rv3d->viewquat, tmp_quat); + axis_angle_to_quat( tmp_quat, upvec, roll*time_redraw_clamped*fly->xlock_momentum*0.1f); /* Rotate about the relative up vec */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); fly->xlock_momentum += 0.05f; } else { @@ -2297,14 +2297,14 @@ int flyApply(FlyInfo *fly) /* move along the current axis */ dvec_tmp[fly->axis]= 1.0f; - Mat3MulVecfl(mat, dvec_tmp); + mul_m3_v3(mat, dvec_tmp); - VecMulf(dvec_tmp, fly->speed * time_redraw * 0.25f); + mul_v3_fl(dvec_tmp, fly->speed * time_redraw * 0.25f); } } /* impose a directional lag */ - VecLerpf(dvec, dvec_tmp, fly->dvec_prev, (1.0f/(1.0f+(time_redraw*5.0f)))); + interp_v3_v3v3(dvec, dvec_tmp, fly->dvec_prev, (1.0f/(1.0f+(time_redraw*5.0f)))); if (rv3d->persp==RV3D_CAMOB) { if (v3d->camera->protectflag & OB_LOCK_LOCX) @@ -2315,7 +2315,7 @@ int flyApply(FlyInfo *fly) dvec[2] = 0.0; } - VecAddf(rv3d->ofs, rv3d->ofs, dvec); + add_v3_v3v3(rv3d->ofs, rv3d->ofs, dvec); #if 0 //XXX2.5 if (fly->zlock && fly->xlock) headerprint("FlyKeys Speed:(+/- | Wheel), Upright Axis:X on/Z on, Slow:Shift, Direction:WASDRF, Ok:LMB, Pan:MMB, Cancel:RMB"); @@ -2338,7 +2338,7 @@ int flyApply(FlyInfo *fly) { //XXX - some reason setcameratoview3d doesnt copy, shouldnt not be needed! VECCOPY(v3d->camera->loc, rv3d->ofs); - VecNegf(v3d->camera->loc); + negate_v3(v3d->camera->loc); } rv3d->persp= RV3D_CAMOB; @@ -2466,11 +2466,11 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f else alignaxis[-axisidx-1]= -1.0; VECCOPY(norm, vec); - Normalize(norm); + normalize_v3(norm); - angle= (float)acos(Inpf(alignaxis, norm)); - Crossf(axis, alignaxis, norm); - VecRotToQuat(axis, -angle, new_quat); + angle= (float)acos(dot_v3v3(alignaxis, norm)); + cross_v3_v3v3(axis, alignaxis, norm); + axis_angle_to_quat( new_quat,axis, -angle); rv3d->view= 0; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 7467f7880af..c8c2a000450 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -106,7 +106,7 @@ #include "WM_types.h" #include "WM_api.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_ghash.h" @@ -129,17 +129,17 @@ void setTransformViewMatrices(TransInfo *t) if(t->spacetype==SPACE_VIEW3D && t->ar->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = t->ar->regiondata; - Mat4CpyMat4(t->viewmat, rv3d->viewmat); - Mat4CpyMat4(t->viewinv, rv3d->viewinv); - Mat4CpyMat4(t->persmat, rv3d->persmat); - Mat4CpyMat4(t->persinv, rv3d->persinv); + copy_m4_m4(t->viewmat, rv3d->viewmat); + copy_m4_m4(t->viewinv, rv3d->viewinv); + copy_m4_m4(t->persmat, rv3d->persmat); + copy_m4_m4(t->persinv, rv3d->persinv); t->persp = rv3d->persp; } else { - Mat4One(t->viewmat); - Mat4One(t->viewinv); - Mat4One(t->persmat); - Mat4One(t->persinv); + unit_m4(t->viewmat); + unit_m4(t->viewinv); + unit_m4(t->persmat); + unit_m4(t->persinv); t->persp = RV3D_ORTHO; } @@ -661,7 +661,7 @@ void transformEvent(TransInfo *t, wmEvent *event) getmouseco_sc(mval); BIF_selectOrientation(); calc_manipulator_stats(curarea); - Mat3CpyMat4(t->spacemtx, G.vd->twmat); + copy_m3_m4(t->spacemtx, G.vd->twmat); warp_pointer(mval[0], mval[1]); #endif } @@ -1112,11 +1112,11 @@ void drawHelpline(const struct bContext *C, TransInfo *t) VECCOPY(vecrot, t->center); if(t->flag & T_EDIT) { Object *ob= t->obedit; - if(ob) Mat4MulVecfl(ob->obmat, vecrot); + if(ob) mul_m4_v3(ob->obmat, vecrot); } else if(t->flag & T_POSE) { Object *ob=t->poseobj; - if(ob) Mat4MulVecfl(ob->obmat, vecrot); + if(ob) mul_m4_v3(ob->obmat, vecrot); } projectFloatView(t, vecrot, cent); // no overflow in extreme cases @@ -1368,12 +1368,12 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); } else if(t->spacetype == SPACE_IMAGE) { - Mat3One(t->spacemtx); + unit_m3(t->spacemtx); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); } else - Mat3One(t->spacemtx); + unit_m3(t->spacemtx); createTransData(C, t); // make TransData structs from selection @@ -1652,8 +1652,8 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl /* axis-angle get limited with euler... */ float eul[3], oldeul[3]; - AxisAngleToEulO(axis, *angle, eul, EULER_ORDER_DEFAULT); - AxisAngleToEulO(oldAxis, oldAngle, oldeul, EULER_ORDER_DEFAULT); + axis_angle_to_eulO( eul, EULER_ORDER_DEFAULT,axis, *angle); + axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,oldAxis, oldAngle); if (protectflag & OB_LOCK_ROTX) eul[0]= oldeul[0]; @@ -1662,7 +1662,7 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl if (protectflag & OB_LOCK_ROTZ) eul[2]= oldeul[2]; - EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, axis, angle); + eulO_to_axis_angle( axis, angle,eul, EULER_ORDER_DEFAULT); /* when converting to axis-angle, we need a special exception for the case when there is no axis */ if (IS_EQ(axis[0], axis[1]) && IS_EQ(axis[1], axis[2])) { @@ -1695,8 +1695,8 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu float eul[3], oldeul[3], quat1[4]; QUATCOPY(quat1, quat); - QuatToEul(quat, eul); - QuatToEul(oldquat, oldeul); + quat_to_eul( eul,quat); + quat_to_eul( oldeul,oldquat); if (protectflag & OB_LOCK_ROTX) eul[0]= oldeul[0]; @@ -1705,11 +1705,11 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu if (protectflag & OB_LOCK_ROTZ) eul[2]= oldeul[2]; - EulToQuat(eul, quat); + eul_to_quat( quat,eul); /* quaternions flip w sign to accumulate rotations correctly */ if ( (quat1[0]<0.0f && quat[0]>0.0f) || (quat1[0]>0.0f && quat[0]<0.0f) ) { - QuatMulf(quat, -1.0f); + mul_qt_fl(quat, -1.0f); } } } @@ -1728,7 +1728,7 @@ static void constraintTransLim(TransInfo *t, TransData *td) * - current space should be local */ memset(&cob, 0, sizeof(bConstraintOb)); - Mat4One(cob.matrix); + unit_m4(cob.matrix); VECCOPY(cob.matrix[3], td->loc); /* Evaluate valid constraints */ @@ -1749,8 +1749,8 @@ static void constraintTransLim(TransInfo *t, TransData *td) /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - Mat4CpyMat4(tmat, cob.matrix); - Mat4MulMat34(cob.matrix, td->mtx, tmat); + copy_m4_m4(tmat, cob.matrix); + mul_m4_m3m4(cob.matrix, td->mtx, tmat); } else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) { /* skip... incompatable spacetype */ @@ -1763,8 +1763,8 @@ static void constraintTransLim(TransInfo *t, TransData *td) /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - Mat4CpyMat4(tmat, cob.matrix); - Mat4MulMat34(cob.matrix, td->smtx, tmat); + copy_m4_m4(tmat, cob.matrix); + mul_m4_m3m4(cob.matrix, td->smtx, tmat); } } } @@ -1789,21 +1789,21 @@ static void constraintRotLim(TransInfo *t, TransData *td) if (td->rotOrder == ROT_MODE_QUAT) { /* quats */ if (td->ext) - QuatToMat4(td->ext->quat, cob.matrix); + quat_to_mat4( cob.matrix,td->ext->quat); else return; } else if (td->rotOrder == ROT_MODE_AXISANGLE) { /* axis angle */ if (td->ext) - AxisAngleToMat4(&td->ext->quat[1], td->ext->quat[0], cob.matrix); + axis_angle_to_mat4( cob.matrix,&td->ext->quat[1], td->ext->quat[0]); else return; } else { /* eulers */ if (td->ext) - EulOToMat4(td->ext->rot, td->rotOrder, cob.matrix); + eulO_to_mat4( cob.matrix,td->ext->rot, td->rotOrder); else return; } @@ -1826,8 +1826,8 @@ static void constraintRotLim(TransInfo *t, TransData *td) /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - Mat4CpyMat4(tmat, cob.matrix); - Mat4MulMat34(cob.matrix, td->mtx, tmat); + copy_m4_m4(tmat, cob.matrix); + mul_m4_m3m4(cob.matrix, td->mtx, tmat); } else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) { /* skip... incompatable spacetype */ @@ -1840,8 +1840,8 @@ static void constraintRotLim(TransInfo *t, TransData *td) /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - Mat4CpyMat4(tmat, cob.matrix); - Mat4MulMat34(cob.matrix, td->smtx, tmat); + copy_m4_m4(tmat, cob.matrix); + mul_m4_m3m4(cob.matrix, td->smtx, tmat); } } } @@ -1849,15 +1849,15 @@ static void constraintRotLim(TransInfo *t, TransData *td) /* copy results from cob->matrix */ if (td->rotOrder == ROT_MODE_QUAT) { /* quats */ - Mat4ToQuat(cob.matrix, td->ext->quat); + mat4_to_quat( td->ext->quat,cob.matrix); } else if (td->rotOrder == ROT_MODE_AXISANGLE) { /* axis angle */ - Mat4ToAxisAngle(cob.matrix, &td->ext->quat[1], &td->ext->quat[0]); + mat4_to_axis_angle( &td->ext->quat[1], &td->ext->quat[0],cob.matrix); } else { /* eulers */ - Mat4ToEulO(cob.matrix, td->ext->rot, td->rotOrder); + mat4_to_eulO( td->ext->rot, td->rotOrder,cob.matrix); } } } @@ -1883,7 +1883,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td) if (td->flag & TD_SINGLESIZE) return; - SizeToMat4(td->ext->size, cob.matrix); + size_to_mat4( cob.matrix,td->ext->size); } /* Evaluate valid constraints */ @@ -1904,8 +1904,8 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - Mat4CpyMat4(tmat, cob.matrix); - Mat4MulMat34(cob.matrix, td->mtx, tmat); + copy_m4_m4(tmat, cob.matrix); + mul_m4_m3m4(cob.matrix, td->mtx, tmat); } else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) { /* skip... incompatable spacetype */ @@ -1918,8 +1918,8 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - Mat4CpyMat4(tmat, cob.matrix); - Mat4MulMat34(cob.matrix, td->smtx, tmat); + copy_m4_m4(tmat, cob.matrix); + mul_m4_m3m4(cob.matrix, td->smtx, tmat); } } } @@ -1934,7 +1934,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td) if (td->flag & TD_SINGLESIZE) return; - Mat4ToSize(cob.matrix, td->ext->size); + mat4_to_size( td->ext->size,cob.matrix); } } } @@ -1964,11 +1964,11 @@ void initWarp(TransInfo *t) for(i = 0; i < t->total; i++) { float center[3]; VECCOPY(center, t->data[i].center); - Mat3MulVecfl(t->data[i].mtx, center); - Mat4MulVecfl(t->viewmat, center); - VecSubf(center, center, t->viewmat[3]); + mul_m3_v3(t->data[i].mtx, center); + mul_m4_v3(t->viewmat, center); + sub_v3_v3v3(center, center, t->viewmat[3]); if (i) - MinMax3(min, max, center); + minmax_v3_v3v3(min, max, center); else { VECCOPY(max, center); VECCOPY(min, center); @@ -2022,12 +2022,12 @@ int Warp(TransInfo *t, short mval[2]) VECCOPY(cursor, curs); VECCOPY(gcursor, cursor); if (t->flag & T_EDIT) { - VecSubf(cursor, cursor, t->obedit->obmat[3]); - VecSubf(gcursor, gcursor, t->obedit->obmat[3]); - Mat3MulVecfl(t->data->smtx, gcursor); + sub_v3_v3v3(cursor, cursor, t->obedit->obmat[3]); + sub_v3_v3v3(gcursor, gcursor, t->obedit->obmat[3]); + mul_m3_v3(t->data->smtx, gcursor); } - Mat4MulVecfl(t->viewmat, cursor); - VecSubf(cursor, cursor, t->viewmat[3]); + mul_m4_v3(t->viewmat, cursor); + sub_v3_v3v3(cursor, cursor, t->viewmat[3]); /* amount of degrees for warp */ circumfac = 360.0f * t->values[0]; @@ -2065,9 +2065,9 @@ int Warp(TransInfo *t, short mval[2]) /* translate point to center, rotate in such a way that outline==distance */ VECCOPY(vec, td->iloc); - Mat3MulVecfl(td->mtx, vec); - Mat4MulVecfl(t->viewmat, vec); - VecSubf(vec, vec, t->viewmat[3]); + mul_m3_v3(td->mtx, vec); + mul_m4_v3(t->viewmat, vec); + sub_v3_v3v3(vec, vec, t->viewmat[3]); dist= vec[0]-cursor[0]; @@ -2082,13 +2082,13 @@ int Warp(TransInfo *t, short mval[2]) loc[1]= co*vec[1]+cursor[1]; loc[2]= vec[2]; - Mat4MulVecfl(t->viewinv, loc); - VecSubf(loc, loc, t->viewinv[3]); - Mat3MulVecfl(td->smtx, loc); + mul_m4_v3(t->viewinv, loc); + sub_v3_v3v3(loc, loc, t->viewinv[3]); + mul_m3_v3(td->smtx, loc); - VecSubf(loc, loc, td->iloc); - VecMulf(loc, td->factor); - VecAddf(td->loc, td->iloc, loc); + sub_v3_v3v3(loc, loc, td->iloc); + mul_v3_fl(loc, td->factor); + add_v3_v3v3(td->loc, td->iloc, loc); } recalcData(t); @@ -2151,8 +2151,8 @@ int Shear(TransInfo *t, short mval[2]) int i; char str[50]; - Mat3CpyMat4(persmat, t->viewmat); - Mat3Inv(persinv, persmat); + copy_m3_m4(persmat, t->viewmat); + invert_m3_m3(persinv, persmat); value = 0.05f * t->values[0]; @@ -2173,7 +2173,7 @@ int Shear(TransInfo *t, short mval[2]) sprintf(str, "Shear: %.3f %s", value, t->proptext); } - Mat3One(smat); + unit_m3(smat); // Custom data signals shear direction if (t->customData == 0) @@ -2181,8 +2181,8 @@ int Shear(TransInfo *t, short mval[2]) else smat[0][1] = value; - Mat3MulMat3(tmat, smat, persmat); - Mat3MulMat3(totmat, persinv, tmat); + mul_m3_m3m3(tmat, smat, persmat); + mul_m3_m3m3(totmat, persinv, tmat); for(i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) @@ -2193,22 +2193,22 @@ int Shear(TransInfo *t, short mval[2]) if (t->obedit) { float mat3[3][3]; - Mat3MulMat3(mat3, totmat, td->mtx); - Mat3MulMat3(tmat, td->smtx, mat3); + mul_m3_m3m3(mat3, totmat, td->mtx); + mul_m3_m3m3(tmat, td->smtx, mat3); } else { - Mat3CpyMat3(tmat, totmat); + copy_m3_m3(tmat, totmat); } - VecSubf(vec, td->center, t->center); + sub_v3_v3v3(vec, td->center, t->center); - Mat3MulVecfl(tmat, vec); + mul_m3_v3(tmat, vec); - VecAddf(vec, vec, t->center); - VecSubf(vec, vec, td->center); + add_v3_v3v3(vec, vec, t->center); + sub_v3_v3v3(vec, vec, td->center); - VecMulf(vec, td->factor); + mul_v3_fl(vec, td->factor); - VecAddf(td->loc, td->iloc, vec); + add_v3_v3v3(td->loc, td->iloc, vec); } recalcData(t); @@ -2281,12 +2281,12 @@ static void TransMat3ToSize( float mat[][3], float smat[][3], float *size) { float vec[3]; - VecCopyf(vec, mat[0]); - size[0]= Normalize(vec); - VecCopyf(vec, mat[1]); - size[1]= Normalize(vec); - VecCopyf(vec, mat[2]); - size[2]= Normalize(vec); + copy_v3_v3(vec, mat[0]); + size[0]= normalize_v3(vec); + copy_v3_v3(vec, mat[1]); + size[1]= normalize_v3(vec); + copy_v3_v3(vec, mat[2]); + size[2]= normalize_v3(vec); /* first tried with dotproduct... but the sign flip is crucial */ if( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0]; @@ -2300,11 +2300,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { float vec[3]; if (t->flag & T_EDIT) { - Mat3MulMat3(smat, mat, td->mtx); - Mat3MulMat3(tmat, td->smtx, smat); + mul_m3_m3m3(smat, mat, td->mtx); + mul_m3_m3m3(tmat, td->smtx, smat); } else { - Mat3CpyMat3(tmat, mat); + copy_m3_m3(tmat, mat); } if (t->con.applySize) { @@ -2339,13 +2339,13 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { if (t->flag & (T_OBJECT|T_TEXTURE|T_POSE)) { float obsizemat[3][3]; // Reorient the size mat to fit the oriented object. - Mat3MulMat3(obsizemat, tmat, td->axismtx); - //printmatrix3("obsizemat", obsizemat); + mul_m3_m3m3(obsizemat, tmat, td->axismtx); + //print_m3("obsizemat", obsizemat); TransMat3ToSize(obsizemat, td->axismtx, fsize); - //printvecf("fsize", fsize); + //print_v3("fsize", fsize); } else { - Mat3ToSize(tmat, fsize); + mat3_to_size( fsize,tmat); } protectedSizeBits(td->protectflag, fsize); @@ -2375,26 +2375,26 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { /* For individual element center, Editmode need to use iloc */ if (t->flag & T_POINTS) - VecSubf(vec, td->iloc, center); + sub_v3_v3v3(vec, td->iloc, center); else - VecSubf(vec, td->center, center); + sub_v3_v3v3(vec, td->center, center); - Mat3MulVecfl(tmat, vec); + mul_m3_v3(tmat, vec); - VecAddf(vec, vec, center); + add_v3_v3v3(vec, vec, center); if (t->flag & T_POINTS) - VecSubf(vec, vec, td->iloc); + sub_v3_v3v3(vec, vec, td->iloc); else - VecSubf(vec, vec, td->center); + sub_v3_v3v3(vec, vec, td->center); - VecMulf(vec, td->factor); + mul_v3_fl(vec, td->factor); if (t->flag & (T_OBJECT|T_POSE)) { - Mat3MulVecfl(td->smtx, vec); + mul_m3_v3(td->smtx, vec); } protectedTransBits(td->protectflag, vec); - VecAddf(td->loc, td->iloc, vec); + add_v3_v3v3(td->loc, td->iloc, vec); constraintTransLim(t, td); } @@ -2435,13 +2435,13 @@ int Resize(TransInfo *t, short mval[2]) VECCOPY(t->values, size); - SizeToMat3(size, mat); + size_to_mat3( mat,size); if (t->con.applySize) { t->con.applySize(t, NULL, mat); } - Mat3CpyMat3(t->mat, mat); // used in manipulator + copy_m3_m3(t->mat, mat); // used in manipulator headerResize(t, size, str); @@ -2457,7 +2457,7 @@ int Resize(TransInfo *t, short mval[2]) /* evil hack - redo resize if cliping needed */ if (t->flag & T_CLIP_UV && clipUVTransform(t, size, 1)) { - SizeToMat3(size, mat); + size_to_mat3( mat,size); if (t->con.applySize) t->con.applySize(t, NULL, mat); @@ -2496,7 +2496,7 @@ void initToSphere(TransInfo *t) // Calculate average radius for(i = 0 ; i < t->total; i++, td++) { - t->val += VecLenf(t->center, td->iloc); + t->val += len_v3v3(t->center, td->iloc); } t->val /= (float)t->total; @@ -2543,15 +2543,15 @@ int ToSphere(TransInfo *t, short mval[2]) if (td->flag & TD_SKIP) continue; - VecSubf(vec, td->iloc, t->center); + sub_v3_v3v3(vec, td->iloc, t->center); - radius = Normalize(vec); + radius = normalize_v3(vec); tratio = ratio * td->factor; - VecMulf(vec, radius * (1.0f - tratio) + t->val * tratio); + mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio); - VecAddf(td->loc, t->center, vec); + add_v3_v3v3(td->loc, t->center, vec); } @@ -2604,25 +2604,25 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short } if (t->flag & T_POINTS) { - Mat3MulMat3(totmat, mat, td->mtx); - Mat3MulMat3(smat, td->smtx, totmat); + mul_m3_m3m3(totmat, mat, td->mtx); + mul_m3_m3m3(smat, td->smtx, totmat); - VecSubf(vec, td->iloc, center); - Mat3MulVecfl(smat, vec); + sub_v3_v3v3(vec, td->iloc, center); + mul_m3_v3(smat, vec); - VecAddf(td->loc, vec, center); + add_v3_v3v3(td->loc, vec, center); - VecSubf(vec,td->loc,td->iloc); + sub_v3_v3v3(vec,td->loc,td->iloc); protectedTransBits(td->protectflag, vec); - VecAddf(td->loc, td->iloc, vec); + add_v3_v3v3(td->loc, td->iloc, vec); if(td->flag & TD_USEQUAT) { - Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); - Mat3ToQuat(fmat, quat); // Actual transform + mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); + mat3_to_quat( quat,fmat); // Actual transform if(td->ext->quat){ - QuatMul(td->ext->quat, quat, td->ext->iquat); + mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); /* is there a reason not to have this here? -jahka */ protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); @@ -2645,28 +2645,28 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short float pmtx[3][3], imtx[3][3]; // Extract and invert armature object matrix - Mat3CpyMat4(pmtx, t->poseobj->obmat); - Mat3Inv(imtx, pmtx); + copy_m3_m4(pmtx, t->poseobj->obmat); + invert_m3_m3(imtx, pmtx); if ((td->flag & TD_NO_LOC) == 0) { - VecSubf(vec, td->center, center); + sub_v3_v3v3(vec, td->center, center); - Mat3MulVecfl(pmtx, vec); // To Global space - Mat3MulVecfl(mat, vec); // Applying rotation - Mat3MulVecfl(imtx, vec); // To Local space + mul_m3_v3(pmtx, vec); // To Global space + mul_m3_v3(mat, vec); // Applying rotation + mul_m3_v3(imtx, vec); // To Local space - VecAddf(vec, vec, center); + add_v3_v3v3(vec, vec, center); /* vec now is the location where the object has to be */ - VecSubf(vec, vec, td->center); // Translation needed from the initial location + sub_v3_v3v3(vec, vec, td->center); // Translation needed from the initial location - Mat3MulVecfl(pmtx, vec); // To Global space - Mat3MulVecfl(td->smtx, vec);// To Pose space + mul_m3_v3(pmtx, vec); // To Global space + mul_m3_v3(td->smtx, vec);// To Pose space protectedTransBits(td->protectflag, vec); - VecAddf(td->loc, td->iloc, vec); + add_v3_v3v3(td->loc, td->iloc, vec); constraintTransLim(t, td); } @@ -2675,11 +2675,11 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself /* euler or quaternion/axis-angle? */ if (td->rotOrder == ROT_MODE_QUAT) { - Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); + mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); - Mat3ToQuat(fmat, quat); // Actual transform + mat3_to_quat( quat,fmat); // Actual transform - QuatMul(td->ext->quat, quat, td->ext->iquat); + mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); /* this function works on end result */ protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); @@ -2688,13 +2688,13 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short /* calculate effect based on quats */ float iquat[4], tquat[4]; - AxisAngleToQuat(iquat, td->ext->irotAxis, td->ext->irotAngle); + axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle); - Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); - Mat3ToQuat(fmat, quat); // Actual transform - QuatMul(tquat, quat, iquat); + mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); + mat3_to_quat( quat,fmat); // Actual transform + mul_qt_qtqt(tquat, quat, iquat); - QuatToAxisAngle(tquat, td->ext->rotAxis, td->ext->rotAngle); + quat_to_axis_angle( td->ext->rotAxis, td->ext->rotAngle,tquat); /* this function works on end result */ protectedAxisAngleBits(td->protectflag, td->ext->rotAxis, td->ext->rotAngle, td->ext->irotAxis, td->ext->irotAngle); @@ -2702,17 +2702,17 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short else { float eulmat[3][3]; - Mat3MulMat3(totmat, mat, td->mtx); - Mat3MulMat3(smat, td->smtx, totmat); + mul_m3_m3m3(totmat, mat, td->mtx); + mul_m3_m3m3(smat, td->smtx, totmat); /* calculate the total rotatation in eulers */ VECCOPY(eul, td->ext->irot); - EulOToMat3(eul, td->rotOrder, eulmat); + eulO_to_mat3( eulmat,eul, td->rotOrder); /* mat = transform, obmat = bone rotation */ - Mat3MulMat3(fmat, smat, eulmat); + mul_m3_m3m3(fmat, smat, eulmat); - Mat3ToCompatibleEulO(fmat, eul, td->ext->rot, td->rotOrder); + mat3_to_compatible_eulO( eul, td->ext->rot, td->rotOrder,fmat); /* and apply (to end result only) */ protectedRotateBits(td->protectflag, eul, td->ext->irot); @@ -2726,16 +2726,16 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short if ((td->flag & TD_NO_LOC) == 0) { /* translation */ - VecSubf(vec, td->center, center); - Mat3MulVecfl(mat, vec); - VecAddf(vec, vec, center); + sub_v3_v3v3(vec, td->center, center); + mul_m3_v3(mat, vec); + add_v3_v3v3(vec, vec, center); /* vec now is the location where the object has to be */ - VecSubf(vec, vec, td->center); - Mat3MulVecfl(td->smtx, vec); + sub_v3_v3v3(vec, vec, td->center); + mul_m3_v3(td->smtx, vec); protectedTransBits(td->protectflag, vec); - VecAddf(td->loc, td->iloc, vec); + add_v3_v3v3(td->loc, td->iloc, vec); } @@ -2745,10 +2745,10 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself /* euler or quaternion? */ if ((td->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) { - Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); - Mat3ToQuat(fmat, quat); // Actual transform + mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); + mat3_to_quat( quat,fmat); // Actual transform - QuatMul(td->ext->quat, quat, td->ext->iquat); + mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); /* this function works on end result */ protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); } @@ -2756,13 +2756,13 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short /* calculate effect based on quats */ float iquat[4], tquat[4]; - AxisAngleToQuat(iquat, td->ext->irotAxis, td->ext->irotAngle); + axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle); - Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); - Mat3ToQuat(fmat, quat); // Actual transform - QuatMul(tquat, quat, iquat); + mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); + mat3_to_quat( quat,fmat); // Actual transform + mul_qt_qtqt(tquat, quat, iquat); - QuatToAxisAngle(quat, td->ext->rotAxis, td->ext->rotAngle); + quat_to_axis_angle( td->ext->rotAxis, td->ext->rotAngle,quat); /* this function works on end result */ protectedAxisAngleBits(td->protectflag, td->ext->rotAxis, td->ext->rotAngle, td->ext->irotAxis, td->ext->irotAngle); @@ -2770,19 +2770,19 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short else { float obmat[3][3]; - Mat3MulMat3(totmat, mat, td->mtx); - Mat3MulMat3(smat, td->smtx, totmat); + mul_m3_m3m3(totmat, mat, td->mtx); + mul_m3_m3m3(smat, td->smtx, totmat); /* calculate the total rotatation in eulers */ - VecAddf(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */ - EulOToMat3(eul, td->rotOrder, obmat); + add_v3_v3v3(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */ + eulO_to_mat3( obmat,eul, td->rotOrder); /* mat = transform, obmat = object rotation */ - Mat3MulMat3(fmat, smat, obmat); + mul_m3_m3m3(fmat, smat, obmat); - Mat3ToCompatibleEulO(fmat, eul, td->ext->rot, td->rotOrder); + mat3_to_compatible_eulO( eul, td->ext->rot, td->rotOrder,fmat); /* correct back for delta rot */ - VecSubf(eul, eul, td->ext->drot); + sub_v3_v3v3(eul, eul, td->ext->drot); /* and apply */ protectedRotateBits(td->protectflag, eul, td->ext->irot); @@ -2800,7 +2800,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) float mat[3][3]; int i; - VecRotToMat3(axis, angle, mat); + vec_rot_to_mat3( mat,axis, angle); for(i = 0 ; i < t->total; i++, td++) { @@ -2812,10 +2812,10 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) if (t->con.applyRot) { t->con.applyRot(t, td, axis, NULL); - VecRotToMat3(axis, angle * td->factor, mat); + vec_rot_to_mat3( mat,axis, angle * td->factor); } else if (t->flag & T_PROP_EDIT) { - VecRotToMat3(axis, angle * td->factor, mat); + vec_rot_to_mat3( mat,axis, angle * td->factor); } ElementRotation(t, td, mat, t->around); @@ -2832,8 +2832,8 @@ int Rotation(TransInfo *t, short mval[2]) float mat[3][3]; VECCOPY(axis, t->viewinv[2]); - VecMulf(axis, -1.0f); - Normalize(axis); + mul_v3_fl(axis, -1.0f); + normalize_v3(axis); final = t->values[0]; @@ -2869,11 +2869,11 @@ int Rotation(TransInfo *t, short mval[2]) sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext); } - VecRotToMat3(axis, final, mat); + vec_rot_to_mat3( mat,axis, final); // TRANSFORM_FIX_ME // t->values[0] = final; // used in manipulator -// Mat3CpyMat3(t->mat, mat); // used in manipulator +// copy_m3_m3(t->mat, mat); // used in manipulator applyRotation(t, final, axis); @@ -2914,10 +2914,10 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a float mat[3][3], smat[3][3], totmat[3][3]; int i; - VecRotToMat3(axis1, angles[0], smat); - VecRotToMat3(axis2, angles[1], totmat); + vec_rot_to_mat3( smat,axis1, angles[0]); + vec_rot_to_mat3( totmat,axis2, angles[1]); - Mat3MulMat3(mat, smat, totmat); + mul_m3_m3m3(mat, smat, totmat); for(i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) @@ -2927,10 +2927,10 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a continue; if (t->flag & T_PROP_EDIT) { - VecRotToMat3(axis1, td->factor * angles[0], smat); - VecRotToMat3(axis2, td->factor * angles[1], totmat); + vec_rot_to_mat3( smat,axis1, td->factor * angles[0]); + vec_rot_to_mat3( totmat,axis2, td->factor * angles[1]); - Mat3MulMat3(mat, smat, totmat); + mul_m3_m3m3(mat, smat, totmat); } ElementRotation(t, td, mat, t->around); @@ -2946,8 +2946,8 @@ int Trackball(TransInfo *t, short mval[2]) VECCOPY(axis1, t->persinv[0]); VECCOPY(axis2, t->persinv[1]); - Normalize(axis1); - Normalize(axis2); + normalize_v3(axis1); + normalize_v3(axis2); phi[0] = t->values[0]; phi[1] = t->values[1]; @@ -2972,13 +2972,13 @@ int Trackball(TransInfo *t, short mval[2]) sprintf(str, "Trackball: %.2f %.2f %s", 180.0*phi[0]/M_PI, 180.0*phi[1]/M_PI, t->proptext); } - VecRotToMat3(axis1, phi[0], smat); - VecRotToMat3(axis2, phi[1], totmat); + vec_rot_to_mat3( smat,axis1, phi[0]); + vec_rot_to_mat3( totmat,axis2, phi[1]); - Mat3MulMat3(mat, smat, totmat); + mul_m3_m3m3(mat, smat, totmat); // TRANSFORM_FIX_ME - //Mat3CpyMat3(t->mat, mat); // used in manipulator + //copy_m3_m3(t->mat, mat); // used in manipulator applyTrackball(t, axis1, axis2, phi); @@ -3030,7 +3030,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { if (hasNumInput(&t->num)) { outputNumInput(&(t->num), tvec); - dist = VecLength(t->num.val); + dist = len_v3(t->num.val); } else { float dvec[3]; @@ -3038,7 +3038,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { VECCOPY(dvec, vec); applyAspectRatio(t, dvec); - dist = VecLength(vec); + dist = len_v3(vec); if(t->scene->unit.system) { int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0; @@ -3113,12 +3113,12 @@ static void applyTranslation(TransInfo *t, float vec[3]) { float mat[3][3]; float angle; - Crossf(axis, original_normal, t->tsnap.snapNormal); - angle = saacos(Inpf(original_normal, t->tsnap.snapNormal)); + cross_v3_v3v3(axis, original_normal, t->tsnap.snapNormal); + angle = saacos(dot_v3v3(original_normal, t->tsnap.snapNormal)); - AxisAngleToQuat(quat, axis, angle); + axis_angle_to_quat(quat, axis, angle); - QuatToMat3(quat, mat); + quat_to_mat3( mat,quat); ElementRotation(t, td, mat, V3D_LOCAL); } @@ -3126,7 +3126,7 @@ static void applyTranslation(TransInfo *t, float vec[3]) { { float mat[3][3]; - Mat3One(mat); + unit_m3(mat); ElementRotation(t, td, mat, V3D_LOCAL); } @@ -3140,12 +3140,12 @@ static void applyTranslation(TransInfo *t, float vec[3]) { VECCOPY(tvec, vec); } - Mat3MulVecfl(td->smtx, tvec); - VecMulf(tvec, td->factor); + mul_m3_v3(td->smtx, tvec); + mul_v3_fl(tvec, td->factor); protectedTransBits(td->protectflag, tvec); - VecAddf(td->loc, td->iloc, tvec); + add_v3_v3v3(td->loc, td->iloc, tvec); constraintTransLim(t, td); } @@ -3252,10 +3252,10 @@ int ShrinkFatten(TransInfo *t, short mval[2]) continue; VECCOPY(vec, td->axismtx[2]); - VecMulf(vec, distance); - VecMulf(vec, td->factor); + mul_v3_fl(vec, distance); + mul_v3_fl(vec, td->factor); - VecAddf(td->loc, td->iloc, vec); + add_v3_v3v3(td->loc, td->iloc, vec); } recalcData(t); @@ -3462,23 +3462,23 @@ int PushPull(TransInfo *t, short mval[2]) if (td->flag & TD_SKIP) continue; - VecSubf(vec, t->center, td->center); + sub_v3_v3v3(vec, t->center, td->center); if (t->con.applyRot && t->con.mode & CON_APPLY) { t->con.applyRot(t, td, axis, NULL); if (isLockConstraint(t)) { float dvec[3]; - Projf(dvec, vec, axis); - VecSubf(vec, vec, dvec); + project_v3_v3v3(dvec, vec, axis); + sub_v3_v3v3(vec, vec, dvec); } else { - Projf(vec, vec, axis); + project_v3_v3v3(vec, vec, axis); } } - Normalize(vec); - VecMulf(vec, distance); - VecMulf(vec, td->factor); + normalize_v3(vec); + mul_v3_fl(vec, distance); + mul_v3_fl(vec, td->factor); - VecAddf(td->loc, td->iloc, vec); + add_v3_v3v3(td->loc, td->iloc, vec); } recalcData(t); @@ -3791,8 +3791,8 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3]) float tmat[3][3], smat[3][3], oldy; float sizemat[3][3]; - Mat3MulMat3(smat, mat, td->mtx); - Mat3MulMat3(tmat, td->smtx, smat); + mul_m3_m3m3(smat, mat, td->mtx); + mul_m3_m3m3(tmat, td->smtx, smat); if (t->con.applySize) { t->con.applySize(t, td, tmat); @@ -3800,9 +3800,9 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3]) /* we've tucked the scale in loc */ oldy= td->iloc[1]; - SizeToMat3(td->iloc, sizemat); - Mat3MulMat3(tmat, tmat, sizemat); - Mat3ToSize(tmat, td->loc); + size_to_mat3( sizemat,td->iloc); + mul_m3_m3m3(tmat, tmat, sizemat); + mat3_to_size( td->loc,tmat); td->loc[1]= oldy; } @@ -3834,13 +3834,13 @@ int BoneSize(TransInfo *t, short mval[2]) constraintNumInput(t, size); } - SizeToMat3(size, mat); + size_to_mat3( mat,size); if (t->con.applySize) { t->con.applySize(t, NULL, mat); } - Mat3CpyMat3(t->mat, mat); // used in manipulator + copy_m3_m3(t->mat, mat); // used in manipulator headerBoneSize(t, size, str); @@ -3955,7 +3955,7 @@ static int createSlideVerts(TransInfo *t) if (!v3d) { /*ok, let's try to survive this*/ - Mat4One(projectMat); + unit_m4(projectMat); } else { view3d_get_object_project_mat(v3d, t->obedit, projectMat); } @@ -4248,12 +4248,12 @@ static int createSlideVerts(TransInfo *t) } if (ev == tempsv->up->v1) { - VecSubf(vec, co, co2); + sub_v3_v3v3(vec, co, co2); } else { - VecSubf(vec, co2, co); + sub_v3_v3v3(vec, co2, co); } - VecAddf(start, start, vec); + add_v3_v3v3(start, start, vec); if (v3d) { view3d_project_float(t->ar, tempsv->down->v1->co, co, projectMat); @@ -4261,12 +4261,12 @@ static int createSlideVerts(TransInfo *t) } if (ev == tempsv->down->v1) { - VecSubf(vec, co2, co); + sub_v3_v3v3(vec, co2, co); } else { - VecSubf(vec, co, co2); + sub_v3_v3v3(vec, co, co2); } - VecAddf(end, end, vec); + add_v3_v3v3(end, end, vec); totvec += 1.0f; nearest = (EditVert*)look->link; @@ -4278,12 +4278,12 @@ static int createSlideVerts(TransInfo *t) look = look->next; } - VecAddf(start, start, end); - VecMulf(start, 0.5*(1.0/totvec)); + add_v3_v3v3(start, start, end); + mul_v3_fl(start, 0.5*(1.0/totvec)); VECCOPY(vec, start); start[0] = t->mval[0]; start[1] = t->mval[1]; - VecAddf(end, start, vec); + add_v3_v3v3(end, start, vec); sld->start[0] = (short) start[0]; sld->start[1] = (short) start[1]; @@ -4484,7 +4484,7 @@ int doEdgeSlide(TransInfo *t, float perc) upVert = editedge_getOtherVert(tempsv->up, centerVert); downVert = editedge_getOtherVert(tempsv->down, centerVert); - len = MIN2(perc, VecLenf(upVert->co,downVert->co)); + len = MIN2(perc, len_v3v3(upVert->co,downVert->co)); len = MAX2(len, 0); //Adjust Edgeloop @@ -4496,13 +4496,13 @@ int doEdgeSlide(TransInfo *t, float perc) tempsv = BLI_ghash_lookup(vertgh,ev); tempev = editedge_getOtherVert((perc>=0)?tempsv->up:tempsv->down, ev); - VecLerpf(ev->co, tempsv->origvert.co, tempev->co, fabs(perc)); + interp_v3_v3v3(ev->co, tempsv->origvert.co, tempev->co, fabs(perc)); if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) { for (uvlay_idx=0; uvlay_idxfuv_list && suv->uv_up && suv->uv_down) { - Vec2Lerpf(uv_tmp, suv->origuv, (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc)); + interp_v2_v2v2(uv_tmp, suv->origuv, (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc)); fuv_link = suv->fuv_list; while (fuv_link) { VECCOPY2D(((float *)fuv_link->link), uv_tmp); @@ -4522,17 +4522,17 @@ int doEdgeSlide(TransInfo *t, float perc) float newlen; ev = look->link; tempsv = BLI_ghash_lookup(vertgh,ev); - newlen = (len / VecLenf(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co)); + newlen = (len / len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co)); if(newlen > 1.0) {newlen = 1.0;} if(newlen < 0.0) {newlen = 0.0;} if(flip == 0) { - VecLerpf(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen)); + interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen)); if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) { /* dont do anything if no UVs */ for (uvlay_idx=0; uvlay_idxfuv_list && suv->uv_up && suv->uv_down) { - Vec2Lerpf(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen)); + interp_v2_v2v2(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen)); fuv_link = suv->fuv_list; while (fuv_link) { VECCOPY2D(((float *)fuv_link->link), uv_tmp); @@ -4542,14 +4542,14 @@ int doEdgeSlide(TransInfo *t, float perc) } } } else{ - VecLerpf(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen)); + interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen)); if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) { /* dont do anything if no UVs */ for (uvlay_idx=0; uvlay_idxfuv_list && suv->uv_up && suv->uv_down) { - Vec2Lerpf(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen)); + interp_v2_v2v2(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen)); fuv_link = suv->fuv_list; while (fuv_link) { VECCOPY2D(((float *)fuv_link->link), uv_tmp); @@ -4775,7 +4775,7 @@ int Mirror(TransInfo *t, short mval[2]) if (t->con.mode & CON_APPLY) { size[0] = size[1] = size[2] = -1; - SizeToMat3(size, mat); + size_to_mat3( mat,size); if (t->con.applySize) { t->con.applySize(t, NULL, mat); @@ -4801,7 +4801,7 @@ int Mirror(TransInfo *t, short mval[2]) { size[0] = size[1] = size[2] = 1; - SizeToMat3(size, mat); + size_to_mat3( mat,size); for(i = 0, td=t->data; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) @@ -4864,9 +4864,9 @@ int Align(TransInfo *t, short mval[2]) } } - Mat3Inv(invmat, td->axismtx); + invert_m3_m3(invmat, td->axismtx); - Mat3MulMat3(mat, t->spacemtx, invmat); + mul_m3_m3m3(mat, t->spacemtx, invmat); ElementRotation(t, td, mat, t->around); } diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 7a6244b72b8..da8f0c4d0e9 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -73,7 +73,7 @@ #include "ED_image.h" #include "ED_view3d.h" -#include "BLI_arithb.h" +#include "BLI_math.h" //#include "blendef.h" // @@ -157,7 +157,7 @@ void constraintNumInput(TransInfo *t, float vec[3]) static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) { int i = 0; - Mat3MulVecfl(t->con.imtx, vec); + mul_m3_v3(t->con.imtx, vec); snapGrid(t, vec); @@ -194,7 +194,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) { pvec[i++] = vec[2]; } - Mat3MulVecfl(t->con.mtx, vec); + mul_m3_v3(t->con.mtx, vec); } static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3]) { @@ -206,16 +206,16 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 /* For when view is parallel to constraint... will cause NaNs otherwise So we take vertical motion in 3D space and apply it to the constraint axis. Nice for camera grab + MMB */ - if(1.0f - fabs(Inpf(axis, t->viewinv[2])) < 0.000001f) { - Projf(vec, in, t->viewinv[1]); - factor = Inpf(t->viewinv[1], vec) * 2.0f; + if(1.0f - fabs(dot_v3v3(axis, t->viewinv[2])) < 0.000001f) { + project_v3_v3v3(vec, in, t->viewinv[1]); + factor = dot_v3v3(t->viewinv[1], vec) * 2.0f; /* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */ if(factor<0.0f) factor*= -factor; else factor*= factor; VECCOPY(out, axis); - Normalize(out); - VecMulf(out, -factor); /* -factor makes move down going backwards */ + normalize_v3(out); + mul_v3_fl(out, -factor); /* -factor makes move down going backwards */ } else { float v[3], i1[3], i2[3]; @@ -224,32 +224,32 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 float plane[3]; getViewVector(t, t->con.center, norm_center); - Crossf(plane, norm_center, axis); + cross_v3_v3v3(plane, norm_center, axis); - Projf(vec, in, plane); - VecSubf(vec, in, vec); + project_v3_v3v3(vec, in, plane); + sub_v3_v3v3(vec, in, vec); - VecAddf(v, vec, t->con.center); + add_v3_v3v3(v, vec, t->con.center); getViewVector(t, v, norm); /* give arbitrary large value if projection is impossible */ - factor = Inpf(axis, norm); + factor = dot_v3v3(axis, norm); if (1 - fabs(factor) < 0.0002f) { VECCOPY(out, axis); if (factor > 0) { - VecMulf(out, 1000000000); + mul_v3_fl(out, 1000000000); } else { - VecMulf(out, -1000000000); + mul_v3_fl(out, -1000000000); } } else { - VecAddf(v2, t->con.center, axis); - VecAddf(v4, v, norm); + add_v3_v3v3(v2, t->con.center, axis); + add_v3_v3v3(v4, v, norm); - LineIntersectLine(t->con.center, v2, v, v4, i1, i2); + isect_line_line_v3(t->con.center, v2, v, v4, i1, i2); - VecSubf(v, i2, v); + sub_v3_v3v3(v, i2, v); - VecSubf(out, i1, t->con.center); + sub_v3_v3v3(out, i1, t->con.center); } } } @@ -257,21 +257,21 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 static void planeProjection(TransInfo *t, float in[3], float out[3]) { float vec[3], factor, norm[3]; - VecAddf(vec, in, t->con.center); + add_v3_v3v3(vec, in, t->con.center); getViewVector(t, vec, norm); - VecSubf(vec, out, in); + sub_v3_v3v3(vec, out, in); - factor = Inpf(vec, norm); + factor = dot_v3v3(vec, norm); if (fabs(factor) <= 0.001) { return; /* prevent divide by zero */ } - factor = Inpf(vec, vec) / factor; + factor = dot_v3v3(vec, vec) / factor; VECCOPY(vec, norm); - VecMulf(vec, factor); + mul_v3_fl(vec, factor); - VecAddf(out, in, vec); + add_v3_v3v3(out, in, vec); } /* @@ -287,7 +287,7 @@ static void applyAxisConstraintVec(TransInfo *t, TransData *td, float in[3], flo { VECCOPY(out, in); if (!td && t->con.mode & CON_APPLY) { - Mat3MulVecfl(t->con.pmtx, out); + mul_m3_v3(t->con.pmtx, out); // With snap, a projection is alright, no need to correct for view alignment if ((t->tsnap.status & SNAP_ON) == 0) { @@ -331,7 +331,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], f VECCOPY(out, in); if (t->con.mode & CON_APPLY) { if (!td) { - Mat3MulVecfl(t->con.pmtx, out); + mul_m3_v3(t->con.pmtx, out); if (getConstraintSpaceDimension(t) == 2) { if (out[0] != 0.0f || out[1] != 0.0f || out[2] != 0.0f) { planeProjection(t, in, out); @@ -367,7 +367,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], f if (t->con.mode & CON_AXIS2) { out[2] = in[i++]; } - Mat3MulVecfl(td->axismtx, out); + mul_m3_v3(td->axismtx, out); } } } @@ -393,8 +393,8 @@ static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3 smat[2][2] = 1.0f; } - Mat3MulMat3(tmat, smat, t->con.imtx); - Mat3MulMat3(smat, t->con.mtx, tmat); + mul_m3_m3m3(tmat, smat, t->con.imtx); + mul_m3_m3m3(smat, t->con.mtx, tmat); } } @@ -410,7 +410,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3] float tmat[3][3]; float imat[3][3]; - Mat3Inv(imat, td->axismtx); + invert_m3_m3(imat, td->axismtx); if (!(t->con.mode & CON_AXIS0)) { smat[0][0] = 1.0f; @@ -422,8 +422,8 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3] smat[2][2] = 1.0f; } - Mat3MulMat3(tmat, smat, imat); - Mat3MulMat3(smat, td->axismtx, tmat); + mul_m3_m3m3(tmat, smat, imat); + mul_m3_m3m3(smat, td->axismtx, tmat); } } @@ -462,7 +462,7 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl } /* don't flip axis if asked to or if num input */ if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) { - if (Inpf(vec, t->viewinv[2]) > 0.0f) { + if (dot_v3v3(vec, t->viewinv[2]) > 0.0f) { *angle = -(*angle); } } @@ -508,7 +508,7 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], break; } if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) { - if (Inpf(vec, t->viewinv[2]) > 0.0f) { + if (dot_v3v3(vec, t->viewinv[2]) > 0.0f) { *angle = -(*angle); } } @@ -519,7 +519,7 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) { strncpy(t->con.text + 1, text, 48); - Mat3CpyMat3(t->con.mtx, space); + copy_m3_m3(t->con.mtx, space); t->con.mode = mode; getConstraintMatrix(t); @@ -535,7 +535,7 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) void setLocalConstraint(TransInfo *t, int mode, const char text[]) { if (t->flag & T_EDIT) { float obmat[3][3]; - Mat3CpyMat4(obmat, t->scene->obedit->obmat); + copy_m3_m4(obmat, t->scene->obedit->obmat); setConstraint(t, obmat, mode, text); } else { @@ -544,7 +544,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) { } else { strncpy(t->con.text + 1, text, 48); - Mat3CpyMat3(t->con.mtx, t->data->axismtx); + copy_m3_m3(t->con.mtx, t->data->axismtx); t->con.mode = mode; getConstraintMatrix(t); @@ -573,7 +573,7 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte { float mtx[3][3]; sprintf(text, ftext, "global"); - Mat3One(mtx); + unit_m3(mtx); setConstraint(t, mtx, mode, text); } break; @@ -630,7 +630,7 @@ void drawConstraint(const struct bContext *C, TransInfo *t) float vec[3]; char col2[3] = {255,255,255}; convertViewVec(t, vec, (short)(t->mval[0] - t->con.imval[0]), (short)(t->mval[1] - t->con.imval[1])); - VecAddf(vec, vec, tc->center); + add_v3_v3v3(vec, vec, tc->center); drawLine(t, tc->center, tc->mtx[0], 'x', 0); drawLine(t, tc->center, tc->mtx[1], 'y', 0); @@ -673,13 +673,13 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) if(t->spacetype == SPACE_VIEW3D && rv3d != NULL) { - Mat4CpyMat4(tmat, rv3d->viewmat); - Mat4Invert(imat, tmat); + copy_m4_m4(tmat, rv3d->viewmat); + invert_m4_m4(imat, tmat); } else { - Mat4One(tmat); - Mat4One(imat); + unit_m4(tmat); + unit_m4(imat); } glPushMatrix(); @@ -756,8 +756,8 @@ void stopConstraint(TransInfo *t) { void getConstraintMatrix(TransInfo *t) { float mat[3][3]; - Mat3Inv(t->con.imtx, t->con.mtx); - Mat3One(t->con.pmtx); + invert_m3_m3(t->con.imtx, t->con.mtx); + unit_m3(t->con.pmtx); if (!(t->con.mode & CON_AXIS0)) { t->con.pmtx[0][0] = @@ -777,15 +777,15 @@ void getConstraintMatrix(TransInfo *t) t->con.pmtx[2][2] = 0.0f; } - Mat3MulMat3(mat, t->con.pmtx, t->con.imtx); - Mat3MulMat3(t->con.pmtx, t->con.mtx, mat); + mul_m3_m3m3(mat, t->con.pmtx, t->con.imtx); + mul_m3_m3m3(t->con.pmtx, t->con.mtx, mat); } /*------------------------- MMB Select -------------------------------*/ void initSelectConstraint(TransInfo *t, float mtx[3][3]) { - Mat3CpyMat3(t->con.mtx, mtx); + copy_m3_m3(t->con.mtx, mtx); t->con.mode |= CON_APPLY; t->con.mode |= CON_SELECT; @@ -852,24 +852,24 @@ static void setNearestAxis3d(TransInfo *t) projecting them with window_to_3d_delta and then get the length of that vector. */ zfac= t->persmat[0][3]*t->center[0]+ t->persmat[1][3]*t->center[1]+ t->persmat[2][3]*t->center[2]+ t->persmat[3][3]; - zfac = VecLength(t->persinv[0]) * 2.0f/t->ar->winx * zfac * 30.0f; + zfac = len_v3(t->persinv[0]) * 2.0f/t->ar->winx * zfac * 30.0f; for (i = 0; i<3; i++) { VECCOPY(axis, t->con.mtx[i]); - VecMulf(axis, zfac); + mul_v3_fl(axis, zfac); /* now we can project to get window coordinate */ - VecAddf(axis, axis, t->con.center); + add_v3_v3v3(axis, axis, t->con.center); projectIntView(t, axis, icoord); axis[0] = (float)(icoord[0] - t->center2d[0]); axis[1] = (float)(icoord[1] - t->center2d[1]); axis[2] = 0.0f; - if (Normalize(axis) != 0.0f) { - Projf(proj, mvec, axis); - VecSubf(axis, mvec, proj); - len[i] = Normalize(axis); + if (normalize_v3(axis) != 0.0f) { + project_v3_v3v3(proj, mvec, axis); + sub_v3_v3v3(axis, mvec, proj); + len[i] = normalize_v3(axis); } else { len[i] = 10000000000.0f; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 85ebf725467..808b3ffa4ff 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -135,7 +135,7 @@ //#include "BDR_editobject.h" // reset_slowparents() //#include "BDR_gpencil.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" @@ -263,9 +263,9 @@ static void set_prop_dist(TransInfo *t, short with_dist) for (i = 0, td= t->data; i < t->total; i++, td++) { if(td->flag & TD_SELECTED) { - VecSubf(vec, tob->center, td->center); - Mat3MulVecfl(tob->mtx, vec); - dist = Normalize(vec); + sub_v3_v3v3(vec, tob->center, td->center); + mul_m3_v3(tob->mtx, vec); + dist = normalize_v3(vec); if (tob->rdist == -1.0f) { tob->rdist = dist; } @@ -315,10 +315,10 @@ static void createTransTexspace(bContext *C, TransInfo *t) VECCOPY(td->center, ob->obmat[3]); td->ob = ob; - Mat3CpyMat4(td->mtx, ob->obmat); - Mat3CpyMat4(td->axismtx, ob->obmat); - Mat3Ortho(td->axismtx); - Mat3Inv(td->smtx, td->mtx); + copy_m3_m4(td->mtx, ob->obmat); + copy_m3_m4(td->axismtx, ob->obmat); + normalize_m3(td->axismtx); + invert_m3_m3(td->smtx, td->mtx); if (give_obdata_texspace(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) { *texflag &= ~AUTOSPACE; @@ -358,14 +358,14 @@ static void createTransEdge(bContext *C, TransInfo *t) { td= t->data= MEM_callocN(t->total * sizeof(TransData), "TransCrease"); - Mat3CpyMat4(mtx, t->obedit->obmat); - Mat3Inv(smtx, mtx); + copy_m3_m4(mtx, t->obedit->obmat); + invert_m3_m3(smtx, mtx); for(eed= em->edges.first; eed; eed= eed->next) { if(eed->h==0 && (eed->f & SELECT || propmode)) { /* need to set center for center calculations */ - VecAddf(td->center, eed->v1->co, eed->v2->co); - VecMulf(td->center, 0.5f); + add_v3_v3v3(td->center, eed->v1->co, eed->v2->co); + mul_v3_fl(td->center, 0.5f); td->loc= NULL; if (eed->f & SELECT) @@ -374,8 +374,8 @@ static void createTransEdge(bContext *C, TransInfo *t) { td->flag= 0; - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); td->ext = NULL; if (t->mode == TFM_BWEIGHT) { @@ -460,7 +460,7 @@ static short apply_targetless_ik(Object *ob) float offs_bone[4][4]; /* offs_bone = yoffs(b-1) + root(b) + bonemat(b) */ - Mat4CpyMat3(offs_bone, bone->bone_mat); + copy_m4_m3(offs_bone, bone->bone_mat); /* The bone's root offset (is in the parent's coordinate system) */ VECCOPY(offs_bone[3], bone->head); @@ -471,60 +471,60 @@ static short apply_targetless_ik(Object *ob) /* pose_mat(b-1) * offs_bone */ if(parchan->bone->flag & BONE_HINGE) { /* the rotation of the parent restposition */ - Mat4CpyMat4(rmat, parbone->arm_mat); /* rmat used as temp */ + copy_m4_m4(rmat, parbone->arm_mat); /* rmat used as temp */ /* the location of actual parent transform */ VECCOPY(rmat[3], offs_bone[3]); offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; - Mat4MulVecfl(parchan->parent->pose_mat, rmat[3]); + mul_m4_v3(parchan->parent->pose_mat, rmat[3]); - Mat4MulMat4(tmat, offs_bone, rmat); + mul_m4_m4m4(tmat, offs_bone, rmat); } else if(parchan->bone->flag & BONE_NO_SCALE) { - Mat4MulMat4(tmat, offs_bone, parchan->parent->pose_mat); - Mat4Ortho(tmat); + mul_m4_m4m4(tmat, offs_bone, parchan->parent->pose_mat); + normalize_m4(tmat); } else - Mat4MulMat4(tmat, offs_bone, parchan->parent->pose_mat); + mul_m4_m4m4(tmat, offs_bone, parchan->parent->pose_mat); - Mat4Invert(imat, tmat); + invert_m4_m4(imat, tmat); } else { - Mat4CpyMat3(tmat, bone->bone_mat); + copy_m4_m3(tmat, bone->bone_mat); VECCOPY(tmat[3], bone->head); - Mat4Invert(imat, tmat); + invert_m4_m4(imat, tmat); } /* result matrix */ - Mat4MulMat4(rmat, parchan->pose_mat, imat); + mul_m4_m4m4(rmat, parchan->pose_mat, imat); /* apply and decompose, doesn't work for constraints or non-uniform scale well */ { float rmat3[3][3], qrmat[3][3], imat[3][3], smat[3][3]; - Mat3CpyMat4(rmat3, rmat); + copy_m3_m4(rmat3, rmat); /* rotation */ if (parchan->rotmode > 0) - Mat3ToEulO(rmat3, parchan->eul, parchan->rotmode); + mat3_to_eulO( parchan->eul, parchan->rotmode,rmat3); else if (parchan->rotmode == ROT_MODE_AXISANGLE) - Mat3ToAxisAngle(rmat3, parchan->rotAxis, &pchan->rotAngle); + mat3_to_axis_angle( parchan->rotAxis, &pchan->rotAngle,rmat3); else - Mat3ToQuat(rmat3, parchan->quat); + mat3_to_quat( parchan->quat,rmat3); /* for size, remove rotation */ /* causes problems with some constraints (so apply only if needed) */ if (data->flag & CONSTRAINT_IK_STRETCH) { if (parchan->rotmode > 0) - EulOToMat3(parchan->eul, parchan->rotmode, qrmat); + eulO_to_mat3( qrmat,parchan->eul, parchan->rotmode); else if (parchan->rotmode == ROT_MODE_AXISANGLE) - AxisAngleToMat3(parchan->rotAxis, parchan->rotAngle, qrmat); + axis_angle_to_mat3( qrmat,parchan->rotAxis, parchan->rotAngle); else - QuatToMat3(parchan->quat, qrmat); + quat_to_mat3( qrmat,parchan->quat); - Mat3Inv(imat, qrmat); - Mat3MulMat3(smat, rmat3, imat); - Mat3ToSize(smat, parchan->size); + invert_m3_m3(imat, qrmat); + mul_m3_m3m3(smat, rmat3, imat); + mat3_to_size( parchan->size,smat); } /* causes problems with some constraints (e.g. childof), so disable this */ @@ -602,38 +602,38 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr /* proper way to get parent transform + own transform + constraints transform */ - Mat3CpyMat4(omat, ob->obmat); + copy_m3_m4(omat, ob->obmat); if (pchan->parent) { if(pchan->bone->flag & BONE_HINGE) - Mat3CpyMat4(pmat, pchan->parent->bone->arm_mat); + copy_m3_m4(pmat, pchan->parent->bone->arm_mat); else - Mat3CpyMat4(pmat, pchan->parent->pose_mat); + copy_m3_m4(pmat, pchan->parent->pose_mat); if (constraints_list_needinv(t, &pchan->constraints)) { - Mat3CpyMat4(tmat, pchan->constinv); - Mat3Inv(cmat, tmat); - Mat3MulSerie(td->mtx, pchan->bone->bone_mat, pmat, omat, cmat, 0,0,0,0); // dang mulserie swaps args + copy_m3_m4(tmat, pchan->constinv); + invert_m3_m3(cmat, tmat); + mul_serie_m3(td->mtx, pchan->bone->bone_mat, pmat, omat, cmat, 0,0,0,0); // dang mulserie swaps args } else - Mat3MulSerie(td->mtx, pchan->bone->bone_mat, pmat, omat, 0,0,0,0,0); // dang mulserie swaps args + mul_serie_m3(td->mtx, pchan->bone->bone_mat, pmat, omat, 0,0,0,0,0); // dang mulserie swaps args } else { if (constraints_list_needinv(t, &pchan->constraints)) { - Mat3CpyMat4(tmat, pchan->constinv); - Mat3Inv(cmat, tmat); - Mat3MulSerie(td->mtx, pchan->bone->bone_mat, omat, cmat, 0,0,0,0,0); // dang mulserie swaps args + copy_m3_m4(tmat, pchan->constinv); + invert_m3_m3(cmat, tmat); + mul_serie_m3(td->mtx, pchan->bone->bone_mat, omat, cmat, 0,0,0,0,0); // dang mulserie swaps args } else - Mat3MulMat3(td->mtx, omat, pchan->bone->bone_mat); // Mat3MulMat3 has swapped args! + mul_m3_m3m3(td->mtx, omat, pchan->bone->bone_mat); // Mat3MulMat3 has swapped args! } - Mat3Inv(td->smtx, td->mtx); + invert_m3_m3(td->smtx, td->mtx); /* for axismat we use bone's own transform */ - Mat3CpyMat4(pmat, pchan->pose_mat); - Mat3MulMat3(td->axismtx, omat, pmat); - Mat3Ortho(td->axismtx); + copy_m3_m4(pmat, pchan->pose_mat); + mul_m3_m3m3(td->axismtx, omat, pmat); + normalize_m3(td->axismtx); if (t->mode==TFM_BONESIZE) { bArmature *arm= t->poseobj->data; @@ -666,8 +666,8 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr data->flag |= CONSTRAINT_IK_AUTO; /* only object matrix correction */ - Mat3CpyMat3 (td->mtx, omat); - Mat3Inv (td->smtx, td->mtx); + copy_m3_m3(td->mtx, omat); + invert_m3_m3(td->smtx, td->mtx); } } @@ -1080,8 +1080,8 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t) if (!t->total) return; - Mat3CpyMat4(mtx, t->obedit->obmat); - Mat3Inv(smtx, mtx); + copy_m3_m4(mtx, t->obedit->obmat); + invert_m3_m3(smtx, mtx); td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransEditBone"); @@ -1100,8 +1100,8 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t) VECCOPY (td->center, ebo->head); td->flag= TD_SELECTED; - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); td->loc = NULL; td->ext = NULL; @@ -1115,8 +1115,8 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t) VECCOPY (td->center, ebo->tail); td->flag= TD_SELECTED; - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); td->loc = NULL; td->ext = NULL; @@ -1145,13 +1145,13 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t) td->flag= TD_SELECTED; /* use local bone matrix */ - VecSubf(delta, ebo->tail, ebo->head); + sub_v3_v3v3(delta, ebo->tail, ebo->head); vec_roll_to_mat3(delta, ebo->roll, bonemat); - Mat3MulMat3(td->mtx, mtx, bonemat); - Mat3Inv(td->smtx, td->mtx); + mul_m3_m3m3(td->mtx, mtx, bonemat); + invert_m3_m3(td->smtx, td->mtx); - Mat3CpyMat3(td->axismtx, td->mtx); - Mat3Ortho(td->axismtx); + copy_m3_m3(td->axismtx, td->mtx); + normalize_m3(td->axismtx); td->ext = NULL; @@ -1185,10 +1185,10 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t) if (ebo->flag & BONE_EDITMODE_LOCKED) td->protectflag = OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE; - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); - VecSubf(delta, ebo->tail, ebo->head); + sub_v3_v3v3(delta, ebo->tail, ebo->head); vec_roll_to_mat3(delta, ebo->roll, td->axismtx); if ((ebo->flag & BONE_ROOTSEL) == 0) @@ -1210,10 +1210,10 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t) if (ebo->flag & BONE_EDITMODE_LOCKED) td->protectflag = OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE; - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); - VecSubf(delta, ebo->tail, ebo->head); + sub_v3_v3v3(delta, ebo->tail, ebo->head); vec_roll_to_mat3(delta, ebo->roll, td->axismtx); td->extra = ebo; /* to fix roll */ @@ -1255,8 +1255,8 @@ static void createTransMBallVerts(bContext *C, TransInfo *t) td = t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(MBall EditMode)"); tx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "MetaElement_TransExtension"); - Mat3CpyMat4(mtx, t->obedit->obmat); - Mat3Inv(smtx, mtx); + copy_m3_m4(mtx, t->obedit->obmat); + invert_m3_m3(smtx, mtx); for(ml= mb->editelems->first; ml; ml= ml->next) { if(propmode || (ml->flag & SELECT)) { @@ -1267,8 +1267,8 @@ static void createTransMBallVerts(bContext *C, TransInfo *t) if(ml->flag & SELECT) td->flag= TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE; else td->flag= TD_USEQUAT; - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); td->ext = tx; @@ -1311,7 +1311,7 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail) { } else if(td_near) { float dist; - dist = VecLenf(td_near->center, td->center); + dist = len_v3v3(td_near->center, td->center); if (dist < (td-1)->dist) { td->dist = (td-1)->dist; } @@ -1332,7 +1332,7 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail) { } else if(td_near) { float dist; - dist = VecLenf(td_near->center, td->center); + dist = len_v3v3(td_near->center, td->center); if (td->flag & TD_NOTCONNECTED || dist < td->dist || (td+1)->dist < td->dist) { td->flag &= ~TD_NOTCONNECTED; if (dist < (td+1)->dist) { @@ -1408,8 +1408,8 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) else t->total = countsel; t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Curve EditMode)"); - Mat3CpyMat4(mtx, t->obedit->obmat); - Mat3Inv(smtx, mtx); + copy_m3_m4(mtx, t->obedit->obmat); + invert_m3_m3(smtx, mtx); td = t->data; for(nu= cu->editnurb->first; nu; nu= nu->next) { @@ -1439,8 +1439,8 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) hdata = initTransDataCurveHandles(td, bezt); - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); td++; count++; @@ -1466,8 +1466,8 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) td->val = NULL; } - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0) /* If the middle is selected but the sides arnt, this is needed */ @@ -1500,8 +1500,8 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) hdata = initTransDataCurveHandles(td, bezt); } - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); td++; count++; @@ -1542,8 +1542,8 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) td->ival = bp->alfa; } - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); td++; count++; @@ -1590,8 +1590,8 @@ static void createTransLatticeVerts(bContext *C, TransInfo *t) else t->total = countsel; t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Lattice EditMode)"); - Mat3CpyMat4(mtx, t->obedit->obmat); - Mat3Inv(smtx, mtx); + copy_m3_m4(mtx, t->obedit->obmat); + invert_m3_m3(smtx, mtx); td = t->data; bp = latt->def; @@ -1604,8 +1604,8 @@ static void createTransLatticeVerts(bContext *C, TransInfo *t) VECCOPY(td->center, td->loc); if(bp->f1 & SELECT) td->flag= TD_SELECTED; else td->flag= 0; - Mat3CpyMat3(td->smtx, smtx); - Mat3CpyMat3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); td->ext = NULL; td->val = NULL; @@ -1679,9 +1679,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) else tx = t->ext = NULL; - Mat4One(mat); + unit_m4(mat); - Mat4Invert(ob->imat,ob->obmat); + invert_m4_m4(ob->imat,ob->obmat); for(i=0, point=edit->points; itotpoint; i++, point++) { TransData *head, *tail; @@ -1695,7 +1695,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) for(k=0, key=point->keys; ktotkey; k++, key++) { if(key->flag & PEK_USE_WCO) { VECCOPY(key->world_co, key->co); - Mat4MulVecfl(mat, key->world_co); + mul_m4_v3(mat, key->world_co); td->loc = key->world_co; } else @@ -1709,8 +1709,8 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) else if(!propmode) td->flag |= TD_SKIP; - Mat3One(td->mtx); - Mat3One(td->smtx); + unit_m3(td->mtx); + unit_m3(td->smtx); /* don't allow moving roots */ if(k==0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR))) @@ -1764,15 +1764,15 @@ void flushTransParticles(TransInfo *t) if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat); - Mat4Invert(imat,mat); + invert_m4_m4(imat,mat); for(k=0, key=point->keys; ktotkey; k++, key++) { VECCOPY(co, key->world_co); - Mat4MulVecfl(imat, co); + mul_m4_v3(imat, co); /* optimization for proportional edit */ - if(!propmode || !FloatCompare(key->co, co, 0.0001f)) { + if(!propmode || !compare_v3v3(key->co, co, 0.0001f)) { VECCOPY(key->co, co); point->flag |= PEP_EDIT_RECALC; } @@ -1838,13 +1838,13 @@ static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *v if (v1->f2) { if (v2->f2) { float nvec[3]; - float len1 = VecLength(vec1); - float len2 = VecLength(vec2); + float len1 = len_v3(vec1); + float len2 = len_v3(vec2); float lenn; /* for v2 if not selected */ if (v2->f2 != 2) { - VecSubf(nvec, v2->co, E_NEAR(v1)->co); - lenn = VecLength(nvec); + sub_v3_v3v3(nvec, v2->co, E_NEAR(v1)->co); + lenn = len_v3(nvec); /* 1 < n < 2 */ if (lenn - len1 > THRESHOLD && len2 - lenn > THRESHOLD) { VECCOPY(vec2, nvec); @@ -1860,8 +1860,8 @@ static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *v } /* for v1 if not selected */ if (v1->f2 != 2) { - VecSubf(nvec, v1->co, E_NEAR(v2)->co); - lenn = VecLength(nvec); + sub_v3_v3v3(nvec, v1->co, E_NEAR(v2)->co); + lenn = len_v3(nvec); /* 2 < n < 1 */ if (lenn - len2 > THRESHOLD && len1 - lenn > THRESHOLD) { VECCOPY(vec1, nvec); @@ -1878,9 +1878,9 @@ static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *v } else { v2->f2 = 1; - VecSubf(vec2, v2->co, E_NEAR(v1)->co); + sub_v3_v3v3(vec2, v2->co, E_NEAR(v1)->co); /* 2 < 1 */ - if (VecLength(vec1) - VecLength(vec2) > THRESHOLD) { + if (len_v3(vec1) - len_v3(vec2) > THRESHOLD) { VECCOPY(vec2, vec1); } E_NEAR(v2) = E_NEAR(v1); @@ -1889,9 +1889,9 @@ static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *v } else if (v2->f2) { v1->f2 = 1; - VecSubf(vec1, v1->co, E_NEAR(v2)->co); + sub_v3_v3v3(vec1, v1->co, E_NEAR(v2)->co); /* 2 < 1 */ - if (VecLength(vec2) - VecLength(vec1) > THRESHOLD) { + if (len_v3(vec2) - len_v3(vec1) > THRESHOLD) { VECCOPY(vec1, vec2); } E_NEAR(v1) = E_NEAR(v2); @@ -2009,13 +2009,13 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3, TAN_MAKE_VEC(vecu, v1, v2); TAN_MAKE_VEC(vecv, v1, v3); - triatoquat(v1, vecu, vecv, q1); + tri_to_quat( q1,v1, vecu, vecv); TAN_MAKE_VEC(vecu, def1, def2); TAN_MAKE_VEC(vecv, def1, def3); - triatoquat(def1, vecu, vecv, q2); + tri_to_quat( q2,def1, vecu, vecv); - QuatSub(quat, q2, q1); + sub_qt_qtqt(quat, q2, q1); } #undef TAN_MAKE_VEC @@ -2192,8 +2192,8 @@ static void createTransEditVerts(bContext *C, TransInfo *t) else t->total = countsel; tob= t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Mesh EditMode)"); - Mat3CpyMat4(mtx, t->obedit->obmat); - Mat3Inv(smtx, mtx); + copy_m3_m4(mtx, t->obedit->obmat); + invert_m3_m3(smtx, mtx); if(propmode) editmesh_set_connectivity_distance(em, t->total, vectors, nears); @@ -2251,8 +2251,8 @@ static void createTransEditVerts(bContext *C, TransInfo *t) if (eve->f2) { float vec[3]; VECCOPY(vec, E_VEC(eve)); - Mat3MulVecfl(mtx, vec); - tob->dist= VecLength(vec); + mul_m3_v3(mtx, vec); + tob->dist= len_v3(vec); } else { tob->flag |= TD_NOTCONNECTED; @@ -2266,25 +2266,25 @@ static void createTransEditVerts(bContext *C, TransInfo *t) /* use both or either quat and defmat correction */ if(quats && eve->tmp.f) { - QuatToMat3(eve->tmp.p, qmat); + quat_to_mat3( qmat,eve->tmp.p); if(defmats) - Mat3MulSerie(mat, mtx, qmat, defmats[a], + mul_serie_m3(mat, mtx, qmat, defmats[a], NULL, NULL, NULL, NULL, NULL); else - Mat3MulMat3(mat, mtx, qmat); + mul_m3_m3m3(mat, mtx, qmat); } else - Mat3MulMat3(mat, mtx, defmats[a]); + mul_m3_m3m3(mat, mtx, defmats[a]); - Mat3Inv(imat, mat); + invert_m3_m3(imat, mat); - Mat3CpyMat3(tob->smtx, imat); - Mat3CpyMat3(tob->mtx, mat); + copy_m3_m3(tob->smtx, imat); + copy_m3_m3(tob->mtx, mat); } else { - Mat3CpyMat3(tob->smtx, smtx); - Mat3CpyMat3(tob->mtx, mtx); + copy_m3_m3(tob->smtx, smtx); + copy_m3_m3(tob->mtx, mtx); } /* Mirror? */ @@ -2459,8 +2459,8 @@ static void UVsToTransData(SpaceImage *sima, TransData *td, TransData2D *td2d, f else { td->dist= MAXFLOAT; } - Mat3One(td->mtx); - Mat3One(td->smtx); + unit_m3(td->mtx); + unit_m3(td->smtx); } static void createTransUVs(bContext *C, TransInfo *t) @@ -2755,8 +2755,8 @@ static void createTransNlaData(bContext *C, TransInfo *t) td->flag |= TD_SELECTED; td->dist= 0.0f; - Mat3One(td->mtx); - Mat3One(td->smtx); + unit_m3(td->mtx); + unit_m3(td->smtx); } else { td->val= &tdn->h1[0]; @@ -2786,8 +2786,8 @@ static void createTransNlaData(bContext *C, TransInfo *t) td->flag |= TD_SELECTED; td->dist= 0.0f; - Mat3One(td->mtx); - Mat3One(td->smtx); + unit_m3(td->mtx); + unit_m3(td->smtx); } else { td->val= &tdn->h2[0]; @@ -3351,8 +3351,8 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, if (intvals) td->flag |= TD_INTVALUES; - Mat3One(td->mtx); - Mat3One(td->smtx); + unit_m3(td->mtx); + unit_m3(td->smtx); } static void createTransGraphEditData(bContext *C, TransInfo *t) @@ -3986,8 +3986,8 @@ static TransData *SeqToTransData(TransInfo *t, TransData *td, TransData2D *td2d, td->flag |= TD_SELECTED; td->dist= 0.0; - Mat3One(td->mtx); - Mat3One(td->smtx); + unit_m3(td->mtx); + unit_m3(td->smtx); /* Time Transform (extend) */ td->val= td2d->loc; @@ -4200,8 +4200,8 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object * short skip_invert = 0; /* axismtx has the real orientation */ - Mat3CpyMat4(td->axismtx, ob->obmat); - Mat3Ortho(td->axismtx); + copy_m3_m4(td->axismtx, ob->obmat); + normalize_m3(td->axismtx); td->con= ob->constraints.first; @@ -4280,7 +4280,7 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object * VECCOPY(td->center, ob->obmat[3]); - Mat4CpyMat4(td->ext->obmat, ob->obmat); + copy_m4_m4(td->ext->obmat, ob->obmat); /* is there a need to set the global<->data space conversion matrices? */ if (ob->parent || constinv) { @@ -4291,15 +4291,15 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object * * done, as it doesn't work well. */ object_to_mat3(ob, obmtx); - Mat3CpyMat4(totmat, ob->obmat); - Mat3Inv(obinv, totmat); - Mat3MulMat3(td->smtx, obmtx, obinv); - Mat3Inv(td->mtx, td->smtx); + copy_m3_m4(totmat, ob->obmat); + invert_m3_m3(obinv, totmat); + mul_m3_m3m3(td->smtx, obmtx, obinv); + invert_m3_m3(td->mtx, td->smtx); } else { /* no conversion to/from dataspace */ - Mat3One(td->smtx); - Mat3One(td->mtx); + unit_m3(td->smtx); + unit_m3(td->mtx); } /* set active flag */ @@ -5152,8 +5152,8 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) td->flag |= TD_SELECTED; td->dist= 0.0; - Mat3One(td->mtx); - Mat3One(td->smtx); + unit_m3(td->mtx); + unit_m3(td->smtx); } void createTransNodeData(bContext *C, TransInfo *t) diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 2e7cfd63836..d3c0e91e57c 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -100,7 +100,7 @@ //#include "BDR_unwrapper.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" @@ -131,20 +131,20 @@ void getViewVector(TransInfo *t, float coord[3], float vec[3]) p1[3] = 1.0f; VECCOPY(p2, p1); p2[3] = 1.0f; - Mat4MulVec4fl(t->viewmat, p2); + mul_m4_v4(t->viewmat, p2); p2[0] = 2.0f * p2[0]; p2[1] = 2.0f * p2[1]; p2[2] = 2.0f * p2[2]; - Mat4MulVec4fl(t->viewinv, p2); + mul_m4_v4(t->viewinv, p2); - VecSubf(vec, p1, p2); + sub_v3_v3v3(vec, p1, p2); } else { VECCOPY(vec, t->viewinv[2]); } - Normalize(vec); + normalize_v3(vec); } /* ************************** GENERICS **************************** */ @@ -181,9 +181,9 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) if (mmd->mirror_ob) { float obinv[4][4]; - Mat4Invert(obinv, mmd->mirror_ob->obmat); - Mat4MulMat4(mtx, ob->obmat, obinv); - Mat4Invert(imtx, mtx); + invert_m4_m4(obinv, mmd->mirror_ob->obmat); + mul_m4_m4m4(mtx, ob->obmat, obinv); + invert_m4_m4(imtx, mtx); } for(i = 0 ; i < t->total; i++, td++) { @@ -198,12 +198,12 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) if (td->flag & TD_SKIP) continue; - VecCopyf(loc, td->loc); - VecCopyf(iloc, td->iloc); + copy_v3_v3(loc, td->loc); + copy_v3_v3(iloc, td->iloc); if (mmd->mirror_ob) { - VecMat4MulVecfl(loc, mtx, loc); - VecMat4MulVecfl(iloc, mtx, iloc); + mul_v3_m4v3(loc, mtx, loc); + mul_v3_m4v3(iloc, mtx, iloc); } clip = 0; @@ -231,9 +231,9 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) } if (clip) { if (mmd->mirror_ob) { - VecMat4MulVecfl(loc, imtx, loc); + mul_v3_m4v3(loc, imtx, loc); } - VecCopyf(td->loc, loc); + copy_v3_v3(td->loc, loc); } } } @@ -692,7 +692,7 @@ void recalcData(TransInfo *t) } /* on extrude bones, oldlength==0.0f, so we scale radius of points */ - ebo->length= VecLenf(ebo->head, ebo->tail); + ebo->length= len_v3v3(ebo->head, ebo->tail); if(ebo->oldlength==0.0f) { ebo->rad_head= 0.25f*ebo->length; ebo->rad_tail= 0.10f*ebo->length; @@ -727,14 +727,14 @@ void recalcData(TransInfo *t) if (t->mode != TFM_ROTATION) { - VecSubf(vec, ebo->tail, ebo->head); - Normalize(vec); - RotationBetweenVectorsToQuat(qrot, td->axismtx[1], vec); - QuatMulVecf(qrot, up_axis); + sub_v3_v3v3(vec, ebo->tail, ebo->head); + normalize_v3(vec); + rotation_between_vecs_to_quat(qrot, td->axismtx[1], vec); + mul_qt_v3(qrot, up_axis); } else { - Mat3MulVecfl(t->mat, up_axis); + mul_m3_v3(t->mat, up_axis); } ebo->roll = ED_rollBoneToVector(ebo, up_axis); @@ -835,11 +835,11 @@ void drawLine(TransInfo *t, float *center, float *dir, char axis, short options) //if(t->obedit) glLoadMatrixf(t->obedit->obmat); // sets opengl viewing - VecCopyf(v3, dir); - VecMulf(v3, v3d->far); + copy_v3_v3(v3, dir); + mul_v3_fl(v3, v3d->far); - VecSubf(v2, center, v3); - VecAddf(v1, center, v3); + sub_v3_v3v3(v2, center, v3); + add_v3_v3v3(v1, center, v3); if (options & DRAWLIGHT) { col[0] = col[1] = col[2] = 220; @@ -928,7 +928,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) t->center[1] = t->center[2] = 0.0f; - Mat3One(t->mat); + unit_m3(t->mat); t->spacetype = sa->spacetype; if(t->spacetype == SPACE_VIEW3D) @@ -1155,7 +1155,7 @@ void restoreTransObjects(TransInfo *t) restoreElement(td); } - Mat3One(t->mat); + unit_m3(t->mat); recalcData(t); } @@ -1167,7 +1167,7 @@ void calculateCenter2D(TransInfo *t) float vec[3]; VECCOPY(vec, t->center); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); projectIntView(t, vec, t->center2d); } else { @@ -1187,10 +1187,10 @@ void calculateCenterCursor(TransInfo *t) Object *ob = t->obedit?t->obedit:t->poseobj; float mat[3][3], imat[3][3]; - VecSubf(t->center, t->center, ob->obmat[3]); - Mat3CpyMat4(mat, ob->obmat); - Mat3Inv(imat, mat); - Mat3MulVecfl(imat, t->center); + sub_v3_v3v3(t->center, t->center, ob->obmat[3]); + copy_m3_m4(mat, ob->obmat); + invert_m3_m3(imat, mat); + mul_m3_v3(imat, t->center); } calculateCenter2D(t); @@ -1234,7 +1234,7 @@ void calculateCenterMedian(TransInfo *t) if (t->data[i].flag & TD_SELECTED) { if (!(t->data[i].flag & TD_NOCENTER)) { - VecAddf(partial, partial, t->data[i].center); + add_v3_v3v3(partial, partial, t->data[i].center); total++; } } @@ -1247,7 +1247,7 @@ void calculateCenterMedian(TransInfo *t) } } if(i) - VecMulf(partial, 1.0f / total); + mul_v3_fl(partial, 1.0f / total); VECCOPY(t->center, partial); calculateCenter2D(t); @@ -1262,7 +1262,7 @@ void calculateCenterBound(TransInfo *t) if (i) { if (t->data[i].flag & TD_SELECTED) { if (!(t->data[i].flag & TD_NOCENTER)) - MinMax3(min, max, t->data[i].center); + minmax_v3_v3v3(min, max, t->data[i].center); } else { /* @@ -1277,8 +1277,8 @@ void calculateCenterBound(TransInfo *t) VECCOPY(min, t->data[i].center); } } - VecAddf(t->center, min, max); - VecMulf(t->center, 0.5); + add_v3_v3v3(t->center, min, max); + mul_v3_fl(t->center, 0.5); calculateCenter2D(t); } @@ -1341,7 +1341,7 @@ void calculateCenter(TransInfo *t) if(t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; - Mat4MulVecfl(ob->obmat, t->con.center); + mul_m4_v3(ob->obmat, t->con.center); } /* for panning from cameraview */ @@ -1358,7 +1358,7 @@ void calculateCenter(TransInfo *t) float axis[3]; /* persinv is nasty, use viewinv instead, always right */ VECCOPY(axis, t->viewinv[2]); - Normalize(axis); + normalize_v3(axis); /* 6.0 = 6 grid units */ axis[0]= t->center[0]- 6.0f*axis[0]; @@ -1385,7 +1385,7 @@ void calculateCenter(TransInfo *t) float vec[3]; VECCOPY(vec, t->center); - Mat4MulVecfl(ob->obmat, vec); + mul_m4_v3(ob->obmat, vec); initgrabz(t->ar->regiondata, vec[0], vec[1], vec[2]); } else { @@ -1509,9 +1509,9 @@ float get_drawsize(ARegion *ar, float *co) size= rv3d->persmat[0][3]*co[0]+ rv3d->persmat[1][3]*co[1]+ rv3d->persmat[2][3]*co[2]+ rv3d->persmat[3][3]; VECCOPY(vec, rv3d->persinv[0]); - len1= Normalize(vec); + len1= normalize_v3(vec); VECCOPY(vec, rv3d->persinv[1]); - len2= Normalize(vec); + len2= normalize_v3(vec); size*= 0.01f*(len1>len2?len1:len2); diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 83d4a314057..bccbfbc65f7 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -28,7 +28,7 @@ #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "WM_types.h" @@ -45,9 +45,9 @@ void InputVector(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) { /* calculate the main translation and the precise one separate */ convertViewVec(t, dvec, (short)(mval[0] - mi->precision_mval[0]), (short)(mval[1] - mi->precision_mval[1])); - VecMulf(dvec, 0.1f); + mul_v3_fl(dvec, 0.1f); convertViewVec(t, vec, (short)(mi->precision_mval[0] - t->imval[0]), (short)(mi->precision_mval[1] - t->imval[1])); - VecAddf(output, vec, dvec); + add_v3_v3v3(output, vec, dvec); } else { @@ -133,9 +133,9 @@ void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, short mval[2], float float vec[3]; InputVector(t, mi, mval, vec); - Projf(vec, vec, t->viewinv[0]); + project_v3_v3v3(vec, vec, t->viewinv[0]); - output[0] = Inpf(t->viewinv[0], vec) * 2.0f; + output[0] = dot_v3v3(t->viewinv[0], vec) * 2.0f; } void InputVerticalRatio(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) { @@ -158,9 +158,9 @@ void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, short mval[2], float ou float vec[3]; InputVector(t, mi, mval, vec); - Projf(vec, vec, t->viewinv[1]); + project_v3_v3v3(vec, vec, t->viewinv[1]); - output[0] = Inpf(t->viewinv[1], vec) * 2.0f; + output[0] = dot_v3v3(t->viewinv[1], vec) * 2.0f; } void setCustomPoints(TransInfo *t, MouseInput *mi, short start[2], short end[2]) diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 86e83715da4..a4e093644c3 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -66,7 +66,7 @@ #include "BKE_pointcache.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BIF_gl.h" @@ -116,8 +116,8 @@ static int is_mat4_flipped(float mat[][4]) { float vec[3]; - Crossf(vec, mat[0], mat[1]); - if( Inpf(vec, mat[2]) < 0.0 ) return 1; + cross_v3_v3v3(vec, mat[0], mat[1]); + if( dot_v3v3(vec, mat[2]) < 0.0 ) return 1; return 0; } @@ -129,7 +129,7 @@ static void calc_tw_center(Scene *scene, float *co) float *max= scene->twmax; DO_MINMAX(co, min, max); - VecAddf(twcent, twcent, co); + add_v3_v3v3(twcent, twcent, co); } static void protectflag_to_drawflags(short protectflag, short *drawflags) @@ -191,30 +191,30 @@ void gimbal_axis(Object *ob, float gmat[][3]) if(pchan && test_rotmode_euler(pchan->rotmode)) { float mat[3][3], tmat[3][3], obmat[3][3]; - EulToGimbalAxis(mat, pchan->eul, pchan->rotmode); + eulO_to_gimbal_axis(mat, pchan->eul, pchan->rotmode); /* apply bone transformation */ - Mat3MulMat3(tmat, pchan->bone->bone_mat, mat); + mul_m3_m3m3(tmat, pchan->bone->bone_mat, mat); if (pchan->parent) { float parent_mat[3][3]; - Mat3CpyMat4(parent_mat, pchan->parent->pose_mat); - Mat3MulMat3(mat, parent_mat, tmat); + copy_m3_m4(parent_mat, pchan->parent->pose_mat); + mul_m3_m3m3(mat, parent_mat, tmat); /* needed if object transformation isn't identity */ - Mat3CpyMat4(obmat, ob->obmat); - Mat3MulMat3(gmat, obmat, mat); + copy_m3_m4(obmat, ob->obmat); + mul_m3_m3m3(gmat, obmat, mat); } else { /* needed if object transformation isn't identity */ - Mat3CpyMat4(obmat, ob->obmat); - Mat3MulMat3(gmat, obmat, tmat); + copy_m3_m4(obmat, ob->obmat); + mul_m3_m3m3(gmat, obmat, tmat); } - Mat3Ortho(gmat); + normalize_m3(gmat); } } else { @@ -225,14 +225,14 @@ void gimbal_axis(Object *ob, float gmat[][3]) { float parent_mat[3][3], amat[3][3]; - EulToGimbalAxis(amat, ob->rot, ob->rotmode); - Mat3CpyMat4(parent_mat, ob->parent->obmat); - Mat3Ortho(parent_mat); - Mat3MulMat3(gmat, parent_mat, amat); + eulO_to_gimbal_axis(amat, ob->rot, ob->rotmode); + copy_m3_m4(parent_mat, ob->parent->obmat); + normalize_m3(parent_mat); + mul_m3_m3m3(gmat, parent_mat, amat); } else { - EulToGimbalAxis(gmat, ob->rot, ob->rotmode); + eulO_to_gimbal_axis(gmat, ob->rot, ob->rotmode); } } } @@ -254,7 +254,7 @@ int calc_manipulator_stats(const bContext *C) int a, totsel= 0; /* transform widget matrix */ - Mat4One(rv3d->twmat); + unit_m4(rv3d->twmat); v3d->twdrawflag= 0xFFFF; @@ -395,10 +395,10 @@ int calc_manipulator_stats(const bContext *C) /* selection center */ if(totsel) { - VecMulf(scene->twcent, 1.0f/(float)totsel); // centroid! - Mat4MulVecfl(obedit->obmat, scene->twcent); - Mat4MulVecfl(obedit->obmat, scene->twmin); - Mat4MulVecfl(obedit->obmat, scene->twmax); + mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! + mul_m4_v3(obedit->obmat, scene->twcent); + mul_m4_v3(obedit->obmat, scene->twmin); + mul_m4_v3(obedit->obmat, scene->twmax); } } else if(ob && (ob->mode & OB_MODE_POSE)) { @@ -415,10 +415,10 @@ int calc_manipulator_stats(const bContext *C) stats_pose(scene, v3d, pchan); } - VecMulf(scene->twcent, 1.0f/(float)totsel); // centroid! - Mat4MulVecfl(ob->obmat, scene->twcent); - Mat4MulVecfl(ob->obmat, scene->twmin); - Mat4MulVecfl(ob->obmat, scene->twmax); + mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! + mul_m4_v3(ob->obmat, scene->twcent); + mul_m4_v3(ob->obmat, scene->twmin); + mul_m4_v3(ob->obmat, scene->twmax); } } else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { @@ -445,7 +445,7 @@ int calc_manipulator_stats(const bContext *C) /* selection center */ if(totsel) - VecMulf(scene->twcent, 1.0f/(float)totsel); // centroid! + mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! } } else { @@ -466,7 +466,7 @@ int calc_manipulator_stats(const bContext *C) /* selection center */ if(totsel) { - VecMulf(scene->twcent, 1.0f/(float)totsel); // centroid! + mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! } } @@ -481,37 +481,37 @@ int calc_manipulator_stats(const bContext *C) case V3D_MANIP_GIMBAL: { float mat[3][3]; - Mat3One(mat); + unit_m3(mat); gimbal_axis(ob, mat); - Mat4CpyMat3(rv3d->twmat, mat); + copy_m4_m3(rv3d->twmat, mat); break; } case V3D_MANIP_NORMAL: if(obedit || ob->mode & OB_MODE_POSE) { float mat[3][3]; ED_getTransformOrientationMatrix(C, mat, (v3d->around == V3D_ACTIVE)); - Mat4CpyMat3(rv3d->twmat, mat); + copy_m4_m3(rv3d->twmat, mat); break; } /* no break we define 'normal' as 'local' in Object mode */ case V3D_MANIP_LOCAL: - Mat4CpyMat4(rv3d->twmat, ob->obmat); - Mat4Ortho(rv3d->twmat); + copy_m4_m4(rv3d->twmat, ob->obmat); + normalize_m4(rv3d->twmat); break; case V3D_MANIP_VIEW: { float mat[3][3]; - Mat3CpyMat4(mat, rv3d->viewinv); - Mat3Ortho(mat); - Mat4CpyMat3(rv3d->twmat, mat); + copy_m3_m4(mat, rv3d->viewinv); + normalize_m3(mat); + copy_m4_m3(rv3d->twmat, mat); } break; default: /* V3D_MANIP_CUSTOM */ { float mat[3][3]; applyTransformOrientation(C, mat, NULL); - Mat4CpyMat3(rv3d->twmat, mat); + copy_m4_m3(rv3d->twmat, mat); break; } } @@ -528,7 +528,7 @@ static float screen_aligned(RegionView3D *rv3d, float mat[][4]) float vec[3], size; VECCOPY(vec, mat[0]); - size= Normalize(vec); + size= normalize_v3(vec); glTranslatef(mat[3][0], mat[3][1], mat[3][2]); @@ -709,8 +709,8 @@ static void preOrtho(int ortho, float twmat[][4], int axis) { if (ortho == 0) { float omat[4][4]; - Mat4CpyMat4(omat, twmat); - Mat4Orthogonal(omat, axis); + copy_m4_m4(omat, twmat); + orthogonalize_m4(omat, axis); glPushMatrix(); wmMultMatrix(omat); } @@ -720,8 +720,8 @@ static void preOrthoFront(int ortho, float twmat[][4], int axis) { if (ortho == 0) { float omat[4][4]; - Mat4CpyMat4(omat, twmat); - Mat4Orthogonal(omat, axis); + copy_m4_m4(omat, twmat); + orthogonalize_m4(omat, axis); glPushMatrix(); wmMultMatrix(omat); glFrontFace( is_mat4_flipped(omat)?GL_CW:GL_CCW); @@ -753,8 +753,8 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d glEnable(GL_BLEND); /* we need both [4][4] transforms, t->mat seems to be premul, not post for mat[][4] */ - Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3] -// XXX Mat4MulMat34(matt, t->mat, rv3d->twmat); + copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] +// XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); /* Screen aligned view rot circle */ if(drawflags & MAN_ROT_V) { @@ -766,7 +766,7 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d vec[0]= 0; // XXX (float)(t->con.imval[0] - t->center2d[0]); vec[1]= 0; // XXX (float)(t->con.imval[1] - t->center2d[1]); vec[2]= 0.0f; - Normalize(vec); + normalize_v3(vec); startphi= saacos( vec[1] ); if(vec[0]<0.0) startphi= -startphi; @@ -788,16 +788,16 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d svec[2]= 0.0f; /* screen aligned vec transform back to manipulator space */ - Mat3CpyMat4(ivmat, rv3d->viewinv); - Mat3CpyMat4(tmat, rv3d->twmat); - Mat3Inv(imat, tmat); - Mat3MulMat3(tmat, imat, ivmat); + copy_m3_m4(ivmat, rv3d->viewinv); + copy_m3_m4(tmat, rv3d->twmat); + invert_m3_m3(imat, tmat); + mul_m3_m3m3(tmat, imat, ivmat); - Mat3MulVecfl(tmat, svec); // tmat is used further on - Normalize(svec); + mul_m3_v3(tmat, svec); // tmat is used further on + normalize_v3(svec); } - ortho = IsMat4Orthogonal(rv3d->twmat); + ortho = is_orthogonal_m4(rv3d->twmat); if (ortho) { wmMultMatrix(rv3d->twmat); // aligns with original widget @@ -812,19 +812,19 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d /* correct for squeezed arc */ svec[0]+= tmat[2][0]; svec[1]+= tmat[2][1]; - Normalize(svec); + normalize_v3(svec); startphi= (float)atan2(svec[0], svec[1]); } else startphi= 0.5f*(float)M_PI; VECCOPY(vec, rv3d->twmat[0]); // use x axis to detect rotation - Normalize(vec); - Normalize(matt[0]); - phi= saacos( Inpf(vec, matt[0]) ); + normalize_v3(vec); + normalize_v3(matt[0]); + phi= saacos( dot_v3v3(vec, matt[0]) ); if(phi!=0.0) { - Crossf(cross, vec, matt[0]); // results in z vector - if(Inpf(cross, rv3d->twmat[2]) > 0.0) phi= -phi; + cross_v3_v3v3(cross, vec, matt[0]); // results in z vector + if(dot_v3v3(cross, rv3d->twmat[2]) > 0.0) phi= -phi; gluPartialDisk(qobj, 0.0, 1.0, 32, 1, 180.0*startphi/M_PI, 180.0*(phi)/M_PI); } @@ -838,19 +838,19 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d /* correct for squeezed arc */ svec[1]+= tmat[2][1]; svec[2]+= tmat[2][2]; - Normalize(svec); + normalize_v3(svec); startphi= (float)(M_PI + atan2(svec[2], -svec[1])); } else startphi= 0.0f; VECCOPY(vec, rv3d->twmat[1]); // use y axis to detect rotation - Normalize(vec); - Normalize(matt[1]); - phi= saacos( Inpf(vec, matt[1]) ); + normalize_v3(vec); + normalize_v3(matt[1]); + phi= saacos( dot_v3v3(vec, matt[1]) ); if(phi!=0.0) { - Crossf(cross, vec, matt[1]); // results in x vector - if(Inpf(cross, rv3d->twmat[0]) > 0.0) phi= -phi; + cross_v3_v3v3(cross, vec, matt[1]); // results in x vector + if(dot_v3v3(cross, rv3d->twmat[0]) > 0.0) phi= -phi; glRotatef(90.0, 0.0, 1.0, 0.0); gluPartialDisk(qobj, 0.0, 1.0, 32, 1, 180.0*startphi/M_PI, 180.0*phi/M_PI); glRotatef(-90.0, 0.0, 1.0, 0.0); @@ -866,19 +866,19 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d /* correct for squeezed arc */ svec[0]+= tmat[2][0]; svec[2]+= tmat[2][2]; - Normalize(svec); + normalize_v3(svec); startphi= (float)(M_PI + atan2(-svec[0], svec[2])); } else startphi= (float)M_PI; VECCOPY(vec, rv3d->twmat[2]); // use z axis to detect rotation - Normalize(vec); - Normalize(matt[2]); - phi= saacos( Inpf(vec, matt[2]) ); + normalize_v3(vec); + normalize_v3(matt[2]); + phi= saacos( dot_v3v3(vec, matt[2]) ); if(phi!=0.0) { - Crossf(cross, vec, matt[2]); // results in y vector - if(Inpf(cross, rv3d->twmat[1]) > 0.0) phi= -phi; + cross_v3_v3v3(cross, vec, matt[2]); // results in y vector + if(dot_v3v3(cross, rv3d->twmat[1]) > 0.0) phi= -phi; glRotatef(-90.0, 1.0, 0.0, 0.0); gluPartialDisk(qobj, 0.0, 1.0, 32, 1, 180.0*startphi/M_PI, 180.0*phi/M_PI); glRotatef(90.0, 1.0, 0.0, 0.0); @@ -911,14 +911,14 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, /* Init stuff */ glDisable(GL_DEPTH_TEST); - Mat4One(unitmat); + unit_m4(unitmat); qobj= gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); /* prepare for screen aligned draw */ VECCOPY(vec, rv3d->twmat[0]); - size= Normalize(vec); + size= normalize_v3(vec); glPushMatrix(); glTranslatef(rv3d->twmat[3][0], rv3d->twmat[3][1], rv3d->twmat[3][2]); @@ -958,8 +958,8 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]); vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]); vec[2]= 0.0f; - Normalize(vec); - VecMulf(vec, 1.2f*size); + normalize_v3(vec); + mul_v3_fl(vec, 1.2f*size); glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3fv(vec); @@ -969,12 +969,12 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glPopMatrix(); - ortho = IsMat4Orthogonal(rv3d->twmat); + ortho = is_orthogonal_m4(rv3d->twmat); /* apply the transform delta */ if(moving) { - Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3] - // XXX Mat4MulMat34(matt, t->mat, rv3d->twmat); + copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] + // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); if (ortho) { wmMultMatrix(matt); glFrontFace( is_mat4_flipped(matt)?GL_CW:GL_CCW); @@ -1229,7 +1229,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, manipulator_setcolor(v3d, 'c', colcode); glPushMatrix(); size= screen_aligned(rv3d, rv3d->twmat); - Mat4One(unitmat); + unit_m4(unitmat); drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f*size, unitmat); glPopMatrix(); @@ -1240,8 +1240,8 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, if(moving) { float matt[4][4]; - Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3] - // XXX Mat4MulMat34(matt, t->mat, rv3d->twmat); + copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] + // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); wmMultMatrix(matt); glFrontFace( is_mat4_flipped(matt)?GL_CW:GL_CCW); } @@ -1347,7 +1347,7 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int movi manipulator_setcolor(v3d, 'c', colcode); glPushMatrix(); size= screen_aligned(rv3d, rv3d->twmat); - Mat4One(unitmat); + unit_m4(unitmat); drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f*size, unitmat); glPopMatrix(); @@ -1420,7 +1420,7 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov /* Screen aligned view rot circle */ if(drawflags & MAN_ROT_V) { float unitmat[4][4]; - Mat4One(unitmat); + unit_m4(unitmat); if(G.f & G_PICKSEL) glLoadName(MAN_ROT_V); UI_ThemeColor(TH_TRANSFORM); @@ -1431,8 +1431,8 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]); vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]); vec[2]= 0.0f; - Normalize(vec); - VecMulf(vec, 1.2f*size); + normalize_v3(vec); + mul_v3_fl(vec, 1.2f*size); glBegin(GL_LINES); glVertex3f(0.0, 0.0, 0.0); glVertex3fv(vec); @@ -1444,9 +1444,9 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov /* apply the transform delta */ if(moving) { float matt[4][4]; - Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3] + copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] // XXX if (t->flag & T_USES_MANIPULATOR) { - // XXX Mat4MulMat34(matt, t->mat, rv3d->twmat); + // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); // XXX } wmMultMatrix(matt); } @@ -1563,7 +1563,7 @@ void BIF_draw_manipulator(const bContext *C) break; } - Mat4MulFloat3((float *)rv3d->twmat, get_manipulator_drawsize(ar)); + mul_mat3_m4_fl((float *)rv3d->twmat, get_manipulator_drawsize(ar)); } if(v3d->twflag & V3D_DRAW_MANIPULATOR) { @@ -1622,7 +1622,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, short *mval, float ho rect.ymax= mval[1]+hotspot; setwinmatrixview3d(ar, v3d, &rect); - Mat4MulMat4(rv3d->persmat, rv3d->viewmat, rv3d->winmat); + mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat); glSelectBuffer( 64, buffer); glRenderMode(GL_SELECT); @@ -1644,7 +1644,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, short *mval, float ho G.f &= ~G_PICKSEL; setwinmatrixview3d(ar, v3d, NULL); - Mat4MulMat4(rv3d->persmat, rv3d->viewmat, rv3d->winmat); + mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat); if(hits==1) return buffer[3]; else if(hits>1) { diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 207cf4b9aee..3cb6700d679 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -32,7 +32,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" #include "BKE_context.h" diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 0cb2515828d..463af961682 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -46,7 +46,7 @@ #include "BKE_context.h" #include "BKE_report.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" @@ -160,8 +160,8 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *reports, char * ob = base->object; - Mat3CpyMat4(mat, ob->obmat); - Mat3Ortho(mat); + copy_m3_m4(mat, ob->obmat); + normalize_m3(mat); /* use object name if no name is given */ if (name[0] == 0) @@ -246,20 +246,20 @@ int createSpaceNormal(float mat[3][3], float normal[3]) float tangent[3] = {0.0f, 0.0f, 1.0f}; VECCOPY(mat[2], normal); - if (Normalize(mat[2]) == 0.0f) { + if (normalize_v3(mat[2]) == 0.0f) { return 0; /* error return */ } - Crossf(mat[0], mat[2], tangent); - if (Inpf(mat[0], mat[0]) == 0.0f) { + cross_v3_v3v3(mat[0], mat[2], tangent); + if (dot_v3v3(mat[0], mat[0]) == 0.0f) { tangent[0] = 1.0f; tangent[1] = tangent[2] = 0.0f; - Crossf(mat[0], tangent, mat[2]); + cross_v3_v3v3(mat[0], tangent, mat[2]); } - Crossf(mat[1], mat[2], mat[0]); + cross_v3_v3v3(mat[1], mat[2], mat[0]); - Mat3Ortho(mat); + normalize_m3(mat); return 1; } @@ -267,7 +267,7 @@ int createSpaceNormal(float mat[3][3], float normal[3]) int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3]) { VECCOPY(mat[2], normal); - if (Normalize(mat[2]) == 0.0f) { + if (normalize_v3(mat[2]) == 0.0f) { return 0; /* error return */ } @@ -277,14 +277,14 @@ int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3]) tangent[2] = 1; } - Crossf(mat[0], mat[2], tangent); - if (Normalize(mat[0]) == 0.0f) { + cross_v3_v3v3(mat[0], mat[2], tangent); + if (normalize_v3(mat[0]) == 0.0f) { return 0; /* error return */ } - Crossf(mat[1], mat[2], mat[0]); + cross_v3_v3v3(mat[1], mat[2], mat[0]); - Mat3Ortho(mat); + normalize_m3(mat); return 1; } @@ -311,7 +311,7 @@ TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[], } /* copy matrix into transform space */ - Mat3CpyMat3(ts->mat, mat); + copy_m3_m3(ts->mat, mat); return ts; } @@ -479,7 +479,7 @@ void applyTransformOrientation(const bContext *C, float mat[3][3], char *name) { if (name) strcpy(name, ts->name); - Mat3CpyMat3(mat, ts->mat); + copy_m3_m3(mat, ts->mat); break; } } @@ -522,7 +522,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) break; case V3D_MANIP_GIMBAL: - Mat3One(t->spacemtx); + unit_m3(t->spacemtx); if(ob) gimbal_axis(ob, t->spacemtx); break; @@ -537,10 +537,10 @@ void initTransformOrientation(bContext *C, TransInfo *t) strcpy(t->spacename, "local"); if(ob) { - Mat3CpyMat4(t->spacemtx, ob->obmat); - Mat3Ortho(t->spacemtx); + copy_m3_m4(t->spacemtx, ob->obmat); + normalize_m3(t->spacemtx); } else { - Mat3One(t->spacemtx); + unit_m3(t->spacemtx); } break; @@ -552,13 +552,13 @@ void initTransformOrientation(bContext *C, TransInfo *t) float mat[3][3]; strcpy(t->spacename, "view"); - Mat3CpyMat4(mat, rv3d->viewinv); - Mat3Ortho(mat); - Mat3CpyMat3(t->spacemtx, mat); + copy_m3_m4(mat, rv3d->viewinv); + normalize_m3(mat); + copy_m3_m3(t->spacemtx, mat); } else { - Mat3One(t->spacemtx); + unit_m3(t->spacemtx); } break; default: /* V3D_MANIP_CUSTOM */ @@ -584,10 +584,10 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], float imat[3][3], mat[3][3]; /* we need the transpose of the inverse for a normal... */ - Mat3CpyMat4(imat, ob->obmat); + copy_m3_m4(imat, ob->obmat); - Mat3Inv(mat, imat); - Mat3Transp(mat); + invert_m3_m3(mat, imat); + transpose_m3(mat); ob= obedit; @@ -629,7 +629,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], if(efa->f & SELECT) { VECADD(normal, normal, efa->n); - VecSubf(vec, efa->v2->co, efa->v1->co); + sub_v3_v3v3(vec, efa->v2->co, efa->v1->co); VECADD(plane, plane, vec); } } @@ -653,9 +653,9 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], else { v3 = eve; - VecSubf(plane, v2->co, v1->co); - VecSubf(cotangent, v3->co, v2->co); - Crossf(normal, cotangent, plane); + sub_v3_v3v3(plane, v2->co, v1->co); + sub_v3_v3v3(cotangent, v3->co, v2->co); + cross_v3_v3v3(normal, cotangent, plane); break; } } @@ -668,7 +668,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], for(eed= em->edges.first; eed; eed= eed->next) { if(eed->f & SELECT) { - VecSubf(plane, eed->v2->co, eed->v1->co); + sub_v3_v3v3(plane, eed->v2->co, eed->v1->co); break; } } @@ -685,7 +685,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], /* use average vert normals as plane and edge vector as normal */ VECCOPY(plane, eed->v1->no); VECADD(plane, plane, eed->v2->no); - VecSubf(normal, eed->v2->co, eed->v1->co); + sub_v3_v3v3(normal, eed->v2->co, eed->v1->co); break; } } @@ -706,7 +706,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], VECCOPY(plane, v1->no); VECADD(plane, plane, v2->no); - VecSubf(normal, v2->co, v1->co); + sub_v3_v3v3(normal, v2->co, v1->co); break; } } @@ -731,10 +731,10 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], for (eve = em->verts.first; eve; eve = eve->next) { if ( eve->f & SELECT ) { - VecAddf(normal, normal, eve->no); + add_v3_v3v3(normal, normal, eve->no); } } - Normalize(normal); + normalize_v3(normal); result = ORIENTATION_VERT; } } @@ -758,21 +758,21 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], /* exception */ if ( (bezt->f1 & SELECT) + (bezt->f2 & SELECT) + (bezt->f3 & SELECT) > SELECT ) { - VecSubf(normal, bezt->vec[0], bezt->vec[2]); + sub_v3_v3v3(normal, bezt->vec[0], bezt->vec[2]); } else { if(bezt->f1) { - VecSubf(normal, bezt->vec[0], bezt->vec[1]); + sub_v3_v3v3(normal, bezt->vec[0], bezt->vec[1]); } if(bezt->f2) { - VecSubf(normal, bezt->vec[0], bezt->vec[2]); + sub_v3_v3v3(normal, bezt->vec[0], bezt->vec[2]); } if(bezt->f3) { - VecSubf(normal, bezt->vec[1], bezt->vec[2]); + sub_v3_v3v3(normal, bezt->vec[1], bezt->vec[2]); } } bezt++; @@ -813,12 +813,12 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], float mat[4][4]; /* Rotation of MetaElem is stored in quat */ - QuatToMat4(ml_sel->quat, mat); + quat_to_mat4( mat,ml_sel->quat); VECCOPY(normal, mat[2]); VECCOPY(plane, mat[1]); - VecMulf(plane, -1.0); + mul_v3_fl(plane, -1.0); result = ORIENTATION_NORMAL; } @@ -837,18 +837,18 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], { float mat[3][3]; float vec[3]; - VecSubf(vec, ebone->tail, ebone->head); - Normalize(vec); - VecAddf(normal, normal, vec); + sub_v3_v3v3(vec, ebone->tail, ebone->head); + normalize_v3(vec); + add_v3_v3v3(normal, normal, vec); vec_roll_to_mat3(vec, ebone->roll, mat); - VecAddf(plane, plane, mat[2]); + add_v3_v3v3(plane, plane, mat[2]); } } } - Normalize(normal); - Normalize(plane); + normalize_v3(normal); + normalize_v3(plane); if (plane[0] != 0 || plane[1] != 0 || plane[2] != 0) { @@ -860,13 +860,13 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], /* Vectors from edges don't need the special transpose inverse multiplication */ if (result == ORIENTATION_EDGE) { - Mat4Mul3Vecfl(ob->obmat, normal); - Mat4Mul3Vecfl(ob->obmat, plane); + mul_mat3_m4_v3(ob->obmat, normal); + mul_mat3_m4_v3(ob->obmat, plane); } else { - Mat3MulVecfl(mat, normal); - Mat3MulVecfl(mat, plane); + mul_m3_v3(mat, normal); + mul_m3_v3(mat, plane); } } else if(ob && (ob->mode & OB_MODE_POSE)) @@ -882,19 +882,19 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], /* use channels to get stats */ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) { - VecAddf(normal, normal, pchan->pose_mat[2]); - VecAddf(plane, plane, pchan->pose_mat[1]); + add_v3_v3v3(normal, normal, pchan->pose_mat[2]); + add_v3_v3v3(plane, plane, pchan->pose_mat[1]); } } - VecMulf(plane, -1.0); + mul_v3_fl(plane, -1.0); /* we need the transpose of the inverse for a normal... */ - Mat3CpyMat4(imat, ob->obmat); + copy_m3_m4(imat, ob->obmat); - Mat3Inv(mat, imat); - Mat3Transp(mat); - Mat3MulVecfl(mat, normal); - Mat3MulVecfl(mat, plane); + invert_m3_m3(mat, imat); + transpose_m3(mat); + mul_m3_v3(mat, normal); + mul_m3_v3(mat, plane); result = ORIENTATION_EDGE; } @@ -963,6 +963,6 @@ void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[] if (type == ORIENTATION_NONE) { - Mat3One(orientation_mat); + unit_m3(orientation_mat); } } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 1d26649fea2..1cbfcc55911 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -47,7 +47,7 @@ #include "RNA_access.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_blenlib.h" @@ -145,8 +145,8 @@ void drawSnapping(const struct bContext *C, TransInfo *t) size *= 0.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); - Mat4CpyMat4(tmat, rv3d->viewmat); - Mat4Invert(imat, tmat); + copy_m4_m4(tmat, rv3d->viewmat); + invert_m4_m4(imat, tmat); drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, size, imat); @@ -229,7 +229,7 @@ void applyProject(TransInfo *t) if(t->flag & (T_EDIT|T_POSE)) { Object *ob = t->obedit?t->obedit:t->poseobj; - Mat4Invert(imat, ob->obmat); + invert_m4_m4(imat, ob->obmat); } for(i = 0 ; i < t->total; i++, td++) { @@ -247,7 +247,7 @@ void applyProject(TransInfo *t) if (t->flag & (T_EDIT|T_POSE)) { Object *ob = t->obedit?t->obedit:t->poseobj; - Mat4MulVecfl(ob->obmat, iloc); + mul_m4_v3(ob->obmat, iloc); } else if (t->flag & T_OBJECT) { @@ -259,14 +259,14 @@ void applyProject(TransInfo *t) if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.mode)) { // if(t->flag & (T_EDIT|T_POSE)) { -// Mat4MulVecfl(imat, loc); +// mul_m4_v3(imat, loc); // } // - VecSubf(tvec, loc, iloc); + sub_v3_v3v3(tvec, loc, iloc); - Mat3MulVecfl(td->smtx, tvec); + mul_m3_v3(td->smtx, tvec); - VecAddf(td->loc, td->loc, tvec); + add_v3_v3v3(td->loc, td->loc, tvec); } //XXX constraintTransLim(t, td); @@ -331,7 +331,7 @@ int validSnappingNormal(TransInfo *t) { if ((t->tsnap.status & (POINT_INIT|TARGET_INIT)) == (POINT_INIT|TARGET_INIT)) { - if (Inpf(t->tsnap.snapNormal, t->tsnap.snapNormal) > 0) + if (dot_v3v3(t->tsnap.snapNormal, t->tsnap.snapNormal) > 0) { return 1; } @@ -365,7 +365,7 @@ void initSnapping(TransInfo *t, wmOperator *op) { t->tsnap.align = RNA_boolean_get(op->ptr, "snap_align"); RNA_float_get_array(op->ptr, "snap_normal", t->tsnap.snapNormal); - Normalize(t->tsnap.snapNormal); + normalize_v3(t->tsnap.snapNormal); } if (RNA_struct_find_property(op->ptr, "snap_project")) @@ -500,7 +500,7 @@ void setSnappingCallback(TransInfo *t, short snap_target) void ApplySnapTranslation(TransInfo *t, float vec[3]) { - VecSubf(vec, t->tsnap.snapPoint, t->tsnap.snapTarget); + sub_v3_v3v3(vec, t->tsnap.snapPoint, t->tsnap.snapTarget); } void ApplySnapRotation(TransInfo *t, float *vec) @@ -527,7 +527,7 @@ void ApplySnapResize(TransInfo *t, float vec[3]) float TranslationBetween(TransInfo *t, float p1[3], float p2[3]) { - return VecLenf(p1, p2); + return len_v3v3(p1, p2); } float RotationBetween(TransInfo *t, float p1[3], float p2[3]) @@ -537,11 +537,11 @@ float RotationBetween(TransInfo *t, float p1[3], float p2[3]) VECCOPY(center, t->center); if(t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; - Mat4MulVecfl(ob->obmat, center); + mul_m4_v3(ob->obmat, center); } - VecSubf(start, p1, center); - VecSubf(end, p2, center); + sub_v3_v3v3(start, p1, center); + sub_v3_v3v3(end, p2, center); // Angle around a constraint axis (error prone, will need debug) if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) { @@ -549,29 +549,29 @@ float RotationBetween(TransInfo *t, float p1[3], float p2[3]) t->con.applyRot(t, NULL, axis, NULL); - Projf(tmp, end, axis); - VecSubf(end, end, tmp); + project_v3_v3v3(tmp, end, axis); + sub_v3_v3v3(end, end, tmp); - Projf(tmp, start, axis); - VecSubf(start, start, tmp); + project_v3_v3v3(tmp, start, axis); + sub_v3_v3v3(start, start, tmp); - Normalize(end); - Normalize(start); + normalize_v3(end); + normalize_v3(start); - Crossf(tmp, start, end); + cross_v3_v3v3(tmp, start, end); - if (Inpf(tmp, axis) < 0.0) - angle = -acos(Inpf(start, end)); + if (dot_v3v3(tmp, axis) < 0.0) + angle = -acos(dot_v3v3(start, end)); else - angle = acos(Inpf(start, end)); + angle = acos(dot_v3v3(start, end)); } else { float mtx[3][3]; - Mat3CpyMat4(mtx, t->viewmat); + copy_m3_m4(mtx, t->viewmat); - Mat3MulVecfl(mtx, end); - Mat3MulVecfl(mtx, start); + mul_m3_v3(mtx, end); + mul_m3_v3(mtx, start); angle = atan2(start[1],start[0]) - atan2(end[1],end[0]); } @@ -593,18 +593,18 @@ float ResizeBetween(TransInfo *t, float p1[3], float p2[3]) VECCOPY(center, t->center); if(t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; - Mat4MulVecfl(ob->obmat, center); + mul_m4_v3(ob->obmat, center); } - VecSubf(d1, p1, center); - VecSubf(d2, p2, center); + sub_v3_v3v3(d1, p1, center); + sub_v3_v3v3(d2, p2, center); if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) { - Mat3MulVecfl(t->con.pmtx, d1); - Mat3MulVecfl(t->con.pmtx, d2); + mul_m3_v3(t->con.pmtx, d1); + mul_m3_v3(t->con.pmtx, d2); } - return VecLength(d2) / VecLength(d1); + return len_v3(d2) / len_v3(d1); } /********************** CALC **************************/ @@ -685,8 +685,8 @@ void CalcSnapGeometry(TransInfo *t, float *vec) { p2->flag = 1; - VecAddf(vec, p1->p, p2->p); - VecMulf(vec, 0.5f); + add_v3_v3v3(vec, p1->p, p2->p); + mul_v3_fl(vec, 0.5f); } else { @@ -700,7 +700,7 @@ void CalcSnapGeometry(TransInfo *t, float *vec) break; } - new_dist = VecLenf(last_p, vec); + new_dist = len_v3v3(last_p, vec); if (new_dist < dist) { @@ -727,10 +727,10 @@ void CalcSnapGeometry(TransInfo *t, float *vec) { float tangent[3]; - VecSubf(tangent, loc, t->tsnap.snapPoint); + sub_v3_v3v3(tangent, loc, t->tsnap.snapPoint); tangent[2] = 0; - if (Inpf(tangent, tangent) > 0) + if (dot_v3v3(tangent, tangent) > 0) { VECCOPY(t->tsnap.snapTangent, tangent); } @@ -759,7 +759,7 @@ void CalcSnapGeometry(TransInfo *t, float *vec) t->tsnap.snapPoint[0] *= aspx; t->tsnap.snapPoint[1] *= aspy; - Mat4MulVecfl(t->obedit->obmat, t->tsnap.snapPoint); + mul_m4_v3(t->obedit->obmat, t->tsnap.snapPoint); t->tsnap.status |= POINT_INIT; } @@ -780,7 +780,7 @@ void TargetSnapCenter(TransInfo *t) VECCOPY(t->tsnap.snapTarget, t->center); if(t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; - Mat4MulVecfl(ob->obmat, t->tsnap.snapTarget); + mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } t->tsnap.status |= TARGET_INIT; @@ -811,7 +811,7 @@ void TargetSnapActive(TransInfo *t) if(t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; - Mat4MulVecfl(ob->obmat, t->tsnap.snapTarget); + mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } t->tsnap.status |= TARGET_INIT; @@ -840,14 +840,14 @@ void TargetSnapMedian(TransInfo *t) for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { - VecAddf(t->tsnap.snapTarget, t->tsnap.snapTarget, td->center); + add_v3_v3v3(t->tsnap.snapTarget, t->tsnap.snapTarget, td->center); } - VecMulf(t->tsnap.snapTarget, 1.0 / i); + mul_v3_fl(t->tsnap.snapTarget, 1.0 / i); if(t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; - Mat4MulVecfl(ob->obmat, t->tsnap.snapTarget); + mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } t->tsnap.status |= TARGET_INIT; @@ -879,7 +879,7 @@ void TargetSnapClosest(TransInfo *t) float dist; VECCOPY(loc, bb->vec[j]); - Mat4MulVecfl(td->ext->obmat, loc); + mul_m4_v3(td->ext->obmat, loc); dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint); @@ -922,7 +922,7 @@ void TargetSnapClosest(TransInfo *t) if(t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; - Mat4MulVecfl(ob->obmat, loc); + mul_m4_v3(ob->obmat, loc); } dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint); @@ -947,7 +947,7 @@ int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], float *v4 int result; int retval = 0; - result = RayIntersectsTriangleThreshold(ray_start_local, ray_normal_local, v1co, v2co, v3co, &lambda, NULL, 0.001); + result = isect_ray_tri_threshold_v3(ray_start_local, ray_normal_local, v1co, v2co, v3co, &lambda, NULL, 0.001); if (result) { float location[3], normal[3]; @@ -957,19 +957,19 @@ int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], float *v4 int new_dist; VECCOPY(intersect, ray_normal_local); - VecMulf(intersect, lambda); - VecAddf(intersect, intersect, ray_start_local); + mul_v3_fl(intersect, lambda); + add_v3_v3v3(intersect, intersect, ray_start_local); VECCOPY(location, intersect); if (v4co) - CalcNormFloat4(v1co, v2co, v3co, v4co, normal); + normal_quad_v3( normal,v1co, v2co, v3co, v4co); else - CalcNormFloat(v1co, v2co, v3co, normal); + normal_tri_v3( normal,v1co, v2co, v3co); - Mat4MulVecfl(obmat, location); + mul_m4_v3(obmat, location); - new_depth = VecLenf(location, ray_start); + new_depth = len_v3v3(location, ray_start); project_int(ar, location, screen_loc); new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); @@ -982,8 +982,8 @@ int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], float *v4 VECCOPY(loc, location); VECCOPY(no, normal); - Mat3MulVecfl(timat, no); - Normalize(no); + mul_m3_v3(timat, no); + normalize_v3(no); *dist = new_dist; } @@ -999,10 +999,10 @@ int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2n int retval = 0; VECCOPY(ray_end, ray_normal_local); - VecMulf(ray_end, 2000); - VecAddf(ray_end, ray_start_local, ray_end); + mul_v3_fl(ray_end, 2000); + add_v3_v3v3(ray_end, ray_start_local, ray_end); - result = LineIntersectLine(v1co, v2co, ray_start_local, ray_end, intersect, dvec); /* dvec used but we don't care about result */ + result = isect_line_line_v3(v1co, v2co, ray_start_local, ray_end, intersect, dvec); /* dvec used but we don't care about result */ if (result) { @@ -1010,12 +1010,12 @@ int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2n float mul; /* check for behind ray_start */ - VecSubf(dvec, intersect, ray_start_local); + sub_v3_v3v3(dvec, intersect, ray_start_local); - VecSubf(edge_loc, v1co, v2co); - VecSubf(vec, intersect, v2co); + sub_v3_v3v3(edge_loc, v1co, v2co); + sub_v3_v3v3(vec, intersect, v2co); - mul = Inpf(vec, edge_loc) / Inpf(edge_loc, edge_loc); + mul = dot_v3v3(vec, edge_loc) / dot_v3v3(edge_loc, edge_loc); if (mul > 1) { mul = 1; @@ -1026,7 +1026,7 @@ int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2n VECCOPY(intersect, v2co); } - if (Inpf(ray_normal_local, dvec) > 0) + if (dot_v3v3(ray_normal_local, dvec) > 0) { float location[3]; float new_depth; @@ -1035,9 +1035,9 @@ int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2n VECCOPY(location, intersect); - Mat4MulVecfl(obmat, location); + mul_m4_v3(obmat, location); - new_depth = VecLenf(location, ray_start); + new_depth = len_v3v3(location, ray_start); project_int(ar, location, screen_loc); new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); @@ -1053,18 +1053,18 @@ int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2n *depth = new_depth; retval = 1; - VecSubf(edge_loc, v1co, v2co); - VecSubf(vec, intersect, v2co); + sub_v3_v3v3(edge_loc, v1co, v2co); + sub_v3_v3v3(vec, intersect, v2co); - mul = Inpf(vec, edge_loc) / Inpf(edge_loc, edge_loc); + mul = dot_v3v3(vec, edge_loc) / dot_v3v3(edge_loc, edge_loc); if (no) { - NormalShortToFloat(n1, v1no); - NormalShortToFloat(n2, v2no); - VecLerpf(no, n2, n1, mul); - Mat3MulVecfl(timat, no); - Normalize(no); + normal_short_to_float_v3(n1, v1no); + normal_short_to_float_v3(n2, v2no); + interp_v3_v3v3(no, n2, n1, mul); + mul_m3_v3(timat, no); + normalize_v3(no); } VECCOPY(loc, location); @@ -1082,9 +1082,9 @@ int snapVertex(ARegion *ar, float vco[3], short vno[3], float mval[2], float ray int retval = 0; float dvec[3]; - VecSubf(dvec, vco, ray_start_local); + sub_v3_v3v3(dvec, vco, ray_start_local); - if (Inpf(ray_normal_local, dvec) > 0) + if (dot_v3v3(ray_normal_local, dvec) > 0) { float location[3]; float new_depth; @@ -1093,9 +1093,9 @@ int snapVertex(ARegion *ar, float vco[3], short vno[3], float mval[2], float ray VECCOPY(location, vco); - Mat4MulVecfl(obmat, location); + mul_m4_v3(obmat, location); - new_depth = VecLenf(location, ray_start); + new_depth = len_v3v3(location, ray_start); project_int(ar, location, screen_loc); new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); @@ -1109,9 +1109,9 @@ int snapVertex(ARegion *ar, float vco[3], short vno[3], float mval[2], float ray if (no) { - NormalShortToFloat(no, vno); - Mat3MulVecfl(timat, no); - Normalize(no); + normal_short_to_float_v3(no, vno); + mul_m3_v3(timat, no); + normalize_v3(no); } *dist = new_dist; @@ -1127,13 +1127,13 @@ int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float float ray_start_local[3], ray_normal_local[3]; int retval = 0; - Mat4Invert(imat, obmat); + invert_m4_m4(imat, obmat); VECCOPY(ray_start_local, ray_start); VECCOPY(ray_normal_local, ray_normal); - Mat4MulVecfl(imat, ray_start_local); - Mat4Mul3Vecfl(imat, ray_normal_local); + mul_m4_v3(imat, ray_start_local); + mul_mat3_m4_v3(imat, ray_normal_local); if(arm->edbo) { @@ -1198,16 +1198,16 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E float ray_start_local[3], ray_normal_local[3]; int test = 1; - Mat4Invert(imat, obmat); + invert_m4_m4(imat, obmat); - Mat3CpyMat4(timat, imat); - Mat3Transp(timat); + copy_m3_m4(timat, imat); + transpose_m3(timat); VECCOPY(ray_start_local, ray_start); VECCOPY(ray_normal_local, ray_normal); - Mat4MulVecfl(imat, ray_start_local); - Mat4Mul3Vecfl(imat, ray_normal_local); + mul_m4_v3(imat, ray_start_local); + mul_mat3_m4_v3(imat, ray_normal_local); /* If number of vert is more than an arbitrary limit, @@ -1587,16 +1587,16 @@ int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta float ray_start_local[3], ray_normal_local[3]; int test = 1; - Mat4Invert(imat, obmat); + invert_m4_m4(imat, obmat); - Mat3CpyMat4(timat, imat); - Mat3Transp(timat); + copy_m3_m4(timat, imat); + transpose_m3(timat); VECCOPY(ray_start_local, ray_start); VECCOPY(ray_normal_local, ray_normal); - Mat4MulVecfl(imat, ray_start_local); - Mat4Mul3Vecfl(imat, ray_normal_local); + mul_m4_v3(imat, ray_start_local); + mul_mat3_m4_v3(imat, ray_normal_local); /* If number of vert is more than an arbitrary limit, @@ -1618,7 +1618,7 @@ int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta int result; - result = RayIntersectsTriangleThreshold(ray_start_local, ray_normal_local, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, &lambda, NULL, 0.001); + result = isect_ray_tri_threshold_v3(ray_start_local, ray_normal_local, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, &lambda, NULL, 0.001); if (result) { float location[3], normal[3]; @@ -1626,29 +1626,29 @@ int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta float new_depth; VECCOPY(intersect, ray_normal_local); - VecMulf(intersect, lambda); - VecAddf(intersect, intersect, ray_start_local); + mul_v3_fl(intersect, lambda); + add_v3_v3v3(intersect, intersect, ray_start_local); VECCOPY(location, intersect); if (f->v4) - CalcNormFloat4(verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, verts[f->v4].co, normal); + normal_quad_v3( normal,verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, verts[f->v4].co); else - CalcNormFloat(verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, normal); + normal_tri_v3( normal,verts[f->v1].co, verts[f->v2].co, verts[f->v3].co); - Mat4MulVecfl(obmat, location); + mul_m4_v3(obmat, location); - new_depth = VecLenf(location, ray_start); + new_depth = len_v3v3(location, ray_start); - Mat3MulVecfl(timat, normal); - Normalize(normal); + mul_m3_v3(timat, normal); + normalize_v3(normal); addDepthPeel(depth_peels, new_depth, location, normal, ob); } if (f->v4 && result == 0) { - result = RayIntersectsTriangleThreshold(ray_start_local, ray_normal_local, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, &lambda, NULL, 0.001); + result = isect_ray_tri_threshold_v3(ray_start_local, ray_normal_local, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, &lambda, NULL, 0.001); if (result) { float location[3], normal[3]; @@ -1656,22 +1656,22 @@ int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta float new_depth; VECCOPY(intersect, ray_normal_local); - VecMulf(intersect, lambda); - VecAddf(intersect, intersect, ray_start_local); + mul_v3_fl(intersect, lambda); + add_v3_v3v3(intersect, intersect, ray_start_local); VECCOPY(location, intersect); if (f->v4) - CalcNormFloat4(verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, verts[f->v4].co, normal); + normal_quad_v3( normal,verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, verts[f->v4].co); else - CalcNormFloat(verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, normal); + normal_tri_v3( normal,verts[f->v1].co, verts[f->v2].co, verts[f->v3].co); - Mat4MulVecfl(obmat, location); + mul_m4_v3(obmat, location); - new_depth = VecLenf(location, ray_start); + new_depth = len_v3v3(location, ray_start); - Mat3MulVecfl(timat, normal); - Normalize(normal); + mul_m3_v3(timat, normal); + normalize_v3(normal); addDepthPeel(depth_peels, new_depth, location, normal, ob); } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index fbd12007c16..c5dccc14b03 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -42,7 +42,7 @@ #include "BKE_object.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_editVert.h" #include "BIF_gl.h" @@ -251,44 +251,44 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac if(efa->v4) { #if 0 /* Simple but slow, better reuse normalized vectors */ - uvang1 = RAD2DEG(Vec2Angle3(tf_uv[3], tf_uv[0], tf_uv[1])); - ang1 = RAD2DEG(VecAngle3(efa->v4->co, efa->v1->co, efa->v2->co)); + uvang1 = RAD2DEG(angle_v2v2v2(tf_uv[3], tf_uv[0], tf_uv[1])); + ang1 = RAD2DEG(angle_v3v3v3(efa->v4->co, efa->v1->co, efa->v2->co)); - uvang2 = RAD2DEG(Vec2Angle3(tf_uv[0], tf_uv[1], tf_uv[2])); - ang2 = RAD2DEG(VecAngle3(efa->v1->co, efa->v2->co, efa->v3->co)); + uvang2 = RAD2DEG(angle_v2v2v2(tf_uv[0], tf_uv[1], tf_uv[2])); + ang2 = RAD2DEG(angle_v3v3v3(efa->v1->co, efa->v2->co, efa->v3->co)); - uvang3 = RAD2DEG(Vec2Angle3(tf_uv[1], tf_uv[2], tf_uv[3])); - ang3 = RAD2DEG(VecAngle3(efa->v2->co, efa->v3->co, efa->v4->co)); + uvang3 = RAD2DEG(angle_v2v2v2(tf_uv[1], tf_uv[2], tf_uv[3])); + ang3 = RAD2DEG(angle_v3v3v3(efa->v2->co, efa->v3->co, efa->v4->co)); - uvang4 = RAD2DEG(Vec2Angle3(tf_uv[2], tf_uv[3], tf_uv[0])); - ang4 = RAD2DEG(VecAngle3(efa->v3->co, efa->v4->co, efa->v1->co)); + uvang4 = RAD2DEG(angle_v2v2v2(tf_uv[2], tf_uv[3], tf_uv[0])); + ang4 = RAD2DEG(angle_v3v3v3(efa->v3->co, efa->v4->co, efa->v1->co)); #endif /* uv angles */ - VECSUB2D(av1, tf_uv[3], tf_uv[0]); Normalize2(av1); - VECSUB2D(av2, tf_uv[0], tf_uv[1]); Normalize2(av2); - VECSUB2D(av3, tf_uv[1], tf_uv[2]); Normalize2(av3); - VECSUB2D(av4, tf_uv[2], tf_uv[3]); Normalize2(av4); + VECSUB2D(av1, tf_uv[3], tf_uv[0]); normalize_v2(av1); + VECSUB2D(av2, tf_uv[0], tf_uv[1]); normalize_v2(av2); + VECSUB2D(av3, tf_uv[1], tf_uv[2]); normalize_v2(av3); + VECSUB2D(av4, tf_uv[2], tf_uv[3]); normalize_v2(av4); /* This is the correct angle however we are only comparing angles - * uvang1 = 90-((NormalizedVecAngle2_2D(av1, av2) * 180.0/M_PI)-90);*/ - uvang1 = NormalizedVecAngle2_2D(av1, av2)*180.0/M_PI; - uvang2 = NormalizedVecAngle2_2D(av2, av3)*180.0/M_PI; - uvang3 = NormalizedVecAngle2_2D(av3, av4)*180.0/M_PI; - uvang4 = NormalizedVecAngle2_2D(av4, av1)*180.0/M_PI; + * uvang1 = 90-((angle_normalized_v2v2(av1, av2) * 180.0/M_PI)-90);*/ + uvang1 = angle_normalized_v2v2(av1, av2)*180.0/M_PI; + uvang2 = angle_normalized_v2v2(av2, av3)*180.0/M_PI; + uvang3 = angle_normalized_v2v2(av3, av4)*180.0/M_PI; + uvang4 = angle_normalized_v2v2(av4, av1)*180.0/M_PI; /* 3d angles */ - VECSUB(av1, efa->v4->co, efa->v1->co); Normalize(av1); - VECSUB(av2, efa->v1->co, efa->v2->co); Normalize(av2); - VECSUB(av3, efa->v2->co, efa->v3->co); Normalize(av3); - VECSUB(av4, efa->v3->co, efa->v4->co); Normalize(av4); + VECSUB(av1, efa->v4->co, efa->v1->co); normalize_v3(av1); + VECSUB(av2, efa->v1->co, efa->v2->co); normalize_v3(av2); + VECSUB(av3, efa->v2->co, efa->v3->co); normalize_v3(av3); + VECSUB(av4, efa->v3->co, efa->v4->co); normalize_v3(av4); /* This is the correct angle however we are only comparing angles - * ang1 = 90-((NormalizedVecAngle2(av1, av2) * 180.0/M_PI)-90);*/ - ang1 = NormalizedVecAngle2(av1, av2)*180.0/M_PI; - ang2 = NormalizedVecAngle2(av2, av3)*180.0/M_PI; - ang3 = NormalizedVecAngle2(av3, av4)*180.0/M_PI; - ang4 = NormalizedVecAngle2(av4, av1)*180.0/M_PI; + * ang1 = 90-((angle_normalized_v3v3(av1, av2) * 180.0/M_PI)-90);*/ + ang1 = angle_normalized_v3v3(av1, av2)*180.0/M_PI; + ang2 = angle_normalized_v3v3(av2, av3)*180.0/M_PI; + ang3 = angle_normalized_v3v3(av3, av4)*180.0/M_PI; + ang4 = angle_normalized_v3v3(av4, av1)*180.0/M_PI; glBegin(GL_QUADS); @@ -315,36 +315,36 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac } else { #if 0 /* Simple but slow, better reuse normalized vectors */ - uvang1 = RAD2DEG(Vec2Angle3(tf_uv[2], tf_uv[0], tf_uv[1])); - ang1 = RAD2DEG(VecAngle3(efa->v3->co, efa->v1->co, efa->v2->co)); + uvang1 = RAD2DEG(angle_v2v2v2(tf_uv[2], tf_uv[0], tf_uv[1])); + ang1 = RAD2DEG(angle_v3v3v3(efa->v3->co, efa->v1->co, efa->v2->co)); - uvang2 = RAD2DEG(Vec2Angle3(tf_uv[0], tf_uv[1], tf_uv[2])); - ang2 = RAD2DEG(VecAngle3(efa->v1->co, efa->v2->co, efa->v3->co)); + uvang2 = RAD2DEG(angle_v2v2v2(tf_uv[0], tf_uv[1], tf_uv[2])); + ang2 = RAD2DEG(angle_v3v3v3(efa->v1->co, efa->v2->co, efa->v3->co)); uvang3 = M_PI-(uvang1+uvang2); ang3 = M_PI-(ang1+ang2); #endif /* uv angles */ - VECSUB2D(av1, tf_uv[2], tf_uv[0]); Normalize2(av1); - VECSUB2D(av2, tf_uv[0], tf_uv[1]); Normalize2(av2); - VECSUB2D(av3, tf_uv[1], tf_uv[2]); Normalize2(av3); + VECSUB2D(av1, tf_uv[2], tf_uv[0]); normalize_v2(av1); + VECSUB2D(av2, tf_uv[0], tf_uv[1]); normalize_v2(av2); + VECSUB2D(av3, tf_uv[1], tf_uv[2]); normalize_v2(av3); /* This is the correct angle however we are only comparing angles - * uvang1 = 90-((NormalizedVecAngle2_2D(av1, av2) * 180.0/M_PI)-90); */ - uvang1 = NormalizedVecAngle2_2D(av1, av2)*180.0/M_PI; - uvang2 = NormalizedVecAngle2_2D(av2, av3)*180.0/M_PI; - uvang3 = NormalizedVecAngle2_2D(av3, av1)*180.0/M_PI; + * uvang1 = 90-((angle_normalized_v2v2(av1, av2) * 180.0/M_PI)-90); */ + uvang1 = angle_normalized_v2v2(av1, av2)*180.0/M_PI; + uvang2 = angle_normalized_v2v2(av2, av3)*180.0/M_PI; + uvang3 = angle_normalized_v2v2(av3, av1)*180.0/M_PI; /* 3d angles */ - VECSUB(av1, efa->v3->co, efa->v1->co); Normalize(av1); - VECSUB(av2, efa->v1->co, efa->v2->co); Normalize(av2); - VECSUB(av3, efa->v2->co, efa->v3->co); Normalize(av3); + VECSUB(av1, efa->v3->co, efa->v1->co); normalize_v3(av1); + VECSUB(av2, efa->v1->co, efa->v2->co); normalize_v3(av2); + VECSUB(av3, efa->v2->co, efa->v3->co); normalize_v3(av3); /* This is the correct angle however we are only comparing angles - * ang1 = 90-((NormalizedVecAngle2(av1, av2) * 180.0/M_PI)-90); */ - ang1 = NormalizedVecAngle2(av1, av2)*180.0/M_PI; - ang2 = NormalizedVecAngle2(av2, av3)*180.0/M_PI; - ang3 = NormalizedVecAngle2(av3, av1)*180.0/M_PI; + * ang1 = 90-((angle_normalized_v3v3(av1, av2) * 180.0/M_PI)-90); */ + ang1 = angle_normalized_v3v3(av1, av2)*180.0/M_PI; + ang2 = angle_normalized_v3v3(av2, av3)*180.0/M_PI; + ang3 = angle_normalized_v3v3(av3, av1)*180.0/M_PI; /* This simple makes the angles display worse then they really are ;) * 1.0-pow((1.0-a), 2) */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index f9a849798be..0e5e283d109 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -41,7 +41,7 @@ #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" @@ -359,9 +359,9 @@ void uv_center(float uv[][2], float cent[2], int quad) float uv_area(float uv[][2], int quad) { if(quad) - return AreaF2Dfl(uv[0], uv[1], uv[2]) + AreaF2Dfl(uv[0], uv[2], uv[3]); + return area_tri_v2(uv[0], uv[1], uv[2]) + area_tri_v2(uv[0], uv[2], uv[3]); else - return AreaF2Dfl(uv[0], uv[1], uv[2]); + return area_tri_v2(uv[0], uv[1], uv[2]); } void uv_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy) @@ -473,7 +473,7 @@ static void find_nearest_uv_edge(Scene *scene, Image *ima, EditMesh *em, float c nverts= efa->v4? 4: 3; for(i=0; iuv[i], tf->uv[(i+1)%nverts]); + dist= dist_to_line_segment_v2(co, tf->uv[i], tf->uv[(i+1)%nverts]); if(dist < mindist) { hit->tf= tf; @@ -534,8 +534,8 @@ static int nearest_uv_between(MTFace *tf, int nverts, int id, float co[2], float m[0]= co[0]-uv[0]; m[1]= co[1]-uv[1]; - Vec2Subf(v1, tf->uv[id1], tf->uv[id]); - Vec2Subf(v2, tf->uv[id2], tf->uv[id]); + sub_v2_v2v2(v1, tf->uv[id1], tf->uv[id]); + sub_v2_v2v2(v2, tf->uv[id2], tf->uv[id]); /* m and v2 on same side of v-v1? */ c1= v1[0]*m[1] - v1[1]*m[0]; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 20f74085e52..85ccef5cd7d 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -2,7 +2,7 @@ #include "MEM_guardedalloc.h" #include "BLI_memarena.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BLI_heap.h" #include "BLI_boxpack2d.h" @@ -333,8 +333,8 @@ static float p_vec_angle_cos(float *v1, float *v2, float *v3) d2[1] = v3[1] - v2[1]; d2[2] = v3[2] - v2[2]; - Normalize(d1); - Normalize(d2); + normalize_v3(d1); + normalize_v3(d2); return d1[0]*d2[0] + d1[1]*d2[1] + d1[2]*d2[2]; } @@ -382,7 +382,7 @@ static float p_face_area(PFace *f) PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next; PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert; - return AreaT3Dfl(v1->co, v2->co, v3->co); + return area_tri_v3(v1->co, v2->co, v3->co); } static float p_area_signed(float *v1, float *v2, float *v3) @@ -1099,7 +1099,7 @@ static PFace *p_face_add_fill(PChart *chart, PVert *v1, PVert *v2, PVert *v3) static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys) { - float fac= VecLenf(co[0], co[2]) - VecLenf(co[1], co[3]); + float fac= len_v3v3(co[0], co[2]) - len_v3v3(co[1], co[3]); PBool dir = (fac <= 0.0f); /* the face exists check is there because of a special case: when @@ -1414,16 +1414,16 @@ static float p_vert_cotan(float *v1, float *v2, float *v3) { float a[3], b[3], c[3], clen; - VecSubf(a, v2, v1); - VecSubf(b, v3, v1); - Crossf(c, a, b); + sub_v3_v3v3(a, v2, v1); + sub_v3_v3v3(b, v3, v1); + cross_v3_v3v3(c, a, b); - clen = VecLength(c); + clen = len_v3(c); if (clen == 0.0f) return 0.0f; - return Inpf(a, b)/clen; + return dot_v3v3(a, b)/clen; } static PBool p_vert_flipped_wheel_triangle(PVert *v) @@ -1752,15 +1752,15 @@ static PBool p_collapse_normal_flipped(float *v1, float *v2, float *vold, float { float nold[3], nnew[3], sub1[3], sub2[3]; - VecSubf(sub1, vold, v1); - VecSubf(sub2, vold, v2); - Crossf(nold, sub1, sub2); + sub_v3_v3v3(sub1, vold, v1); + sub_v3_v3v3(sub2, vold, v2); + cross_v3_v3v3(nold, sub1, sub2); - VecSubf(sub1, vnew, v1); - VecSubf(sub2, vnew, v2); - Crossf(nnew, sub1, sub2); + sub_v3_v3v3(sub1, vnew, v1); + sub_v3_v3v3(sub2, vnew, v2); + cross_v3_v3v3(nnew, sub1, sub2); - return (Inpf(nold, nnew) <= 0.0f); + return (dot_v3v3(nold, nnew) <= 0.0f); } static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair) @@ -1866,7 +1866,7 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair) oldf1 = (edge)? edge->face: NULL; oldf2 = (pair)? pair->face: NULL; - VecSubf(edgevec, keepv->co, oldv->co); + sub_v3_v3v3(edgevec, keepv->co, oldv->co); e = oldv->edge; do { @@ -1878,16 +1878,16 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair) float tetrav2[3], tetrav3[3], c[3]; /* tetrahedron volume = (1/3!)*|a.(b x c)| */ - VecSubf(tetrav2, co1, oldv->co); - VecSubf(tetrav3, co2, oldv->co); - Crossf(c, tetrav2, tetrav3); + sub_v3_v3v3(tetrav2, co1, oldv->co); + sub_v3_v3v3(tetrav3, co2, oldv->co); + cross_v3_v3v3(c, tetrav2, tetrav3); - volumecost += fabs(Inpf(edgevec, c)/6.0f); + volumecost += fabs(dot_v3v3(edgevec, c)/6.0f); #if 0 - shapecost += Inpf(co1, keepv->co); + shapecost += dot_v3v3(co1, keepv->co); if (p_wheel_edge_next(e) == NULL) - shapecost += Inpf(co2, keepv->co); + shapecost += dot_v3v3(co2, keepv->co); #endif p_triangle_angles(oldv->co, co1, co2, &a1, &a2, &a3); @@ -1915,10 +1915,10 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair) PVert *v1 = p_boundary_edge_prev(oldv->edge)->vert; PVert *v2 = p_boundary_edge_next(oldv->edge)->vert; - areacost = AreaT3Dfl(oldv->co, v1->co, v2->co); + areacost = area_tri_v3(oldv->co, v1->co, v2->co); } - elen = VecLength(edgevec); + elen = len_v3(edgevec); weight = 1.0f; /* 0.2f */ cost = weight*volumecost*volumecost + elen*elen*areacost*areacost; #if 0 @@ -2750,7 +2750,7 @@ static void p_chart_pin_positions(PChart *chart, PVert **pin1, PVert **pin2) int diru, dirv, dirx, diry; float sub[3]; - VecSubf(sub, (*pin1)->co, (*pin2)->co); + sub_v3_v3v3(sub, (*pin1)->co, (*pin2)->co); sub[0] = fabs(sub[0]); sub[1] = fabs(sub[1]); sub[2] = fabs(sub[2]); @@ -3185,35 +3185,35 @@ static float p_face_stretch(PFace *f) w= 1.0f/(2.0f*area); /* compute derivatives */ - VecCopyf(Ps, v1->co); - VecMulf(Ps, (v2->uv[1] - v3->uv[1])); + copy_v3_v3(Ps, v1->co); + mul_v3_fl(Ps, (v2->uv[1] - v3->uv[1])); - VecCopyf(tmp, v2->co); - VecMulf(tmp, (v3->uv[1] - v1->uv[1])); - VecAddf(Ps, Ps, tmp); + copy_v3_v3(tmp, v2->co); + mul_v3_fl(tmp, (v3->uv[1] - v1->uv[1])); + add_v3_v3v3(Ps, Ps, tmp); - VecCopyf(tmp, v3->co); - VecMulf(tmp, (v1->uv[1] - v2->uv[1])); - VecAddf(Ps, Ps, tmp); + copy_v3_v3(tmp, v3->co); + mul_v3_fl(tmp, (v1->uv[1] - v2->uv[1])); + add_v3_v3v3(Ps, Ps, tmp); - VecMulf(Ps, w); + mul_v3_fl(Ps, w); - VecCopyf(Pt, v1->co); - VecMulf(Pt, (v3->uv[0] - v2->uv[0])); + copy_v3_v3(Pt, v1->co); + mul_v3_fl(Pt, (v3->uv[0] - v2->uv[0])); - VecCopyf(tmp, v2->co); - VecMulf(tmp, (v1->uv[0] - v3->uv[0])); - VecAddf(Pt, Pt, tmp); + copy_v3_v3(tmp, v2->co); + mul_v3_fl(tmp, (v1->uv[0] - v3->uv[0])); + add_v3_v3v3(Pt, Pt, tmp); - VecCopyf(tmp, v3->co); - VecMulf(tmp, (v2->uv[0] - v1->uv[0])); - VecAddf(Pt, Pt, tmp); + copy_v3_v3(tmp, v3->co); + mul_v3_fl(tmp, (v2->uv[0] - v1->uv[0])); + add_v3_v3v3(Pt, Pt, tmp); - VecMulf(Pt, w); + mul_v3_fl(Pt, w); /* Sander Tensor */ - a= Inpf(Ps, Ps); - c= Inpf(Pt, Pt); + a= dot_v3v3(Ps, Ps); + c= dot_v3v3(Pt, Pt); T = sqrt(0.5f*(a + c)); if (f->flag & PFACE_FILLED) @@ -3273,7 +3273,7 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng) low = 0; stretch_low = orig_stretch; - Vec2Addf(v->uv, orig_uv, dir); + add_v2_v2v2(v->uv, orig_uv, dir); high = 1; stretch = stretch_high = p_stretch_compute_vertex(v); @@ -3296,7 +3296,7 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng) /* no luck, stretch has increased, reset to old values */ if(stretch >= orig_stretch) - Vec2Copyf(v->uv, orig_uv); + copy_v2_v2(v->uv, orig_uv); } } @@ -3404,7 +3404,7 @@ static float p_rectangle_area(float *p1, float *dir, float *p2, float *p3, float if (!p_intersect_line_2d_dir(p3, dir, p4, orthodir, corner3)) return 1e10; - return Vec2Lenf(corner1, corner2)*Vec2Lenf(corner2, corner3); + return len_v2v2(corner1, corner2)*len_v2v2(corner2, corner3); } static float p_chart_minimum_area_angle(PChart *chart) @@ -3499,7 +3499,7 @@ static float p_chart_minimum_area_angle(PChart *chart) p3 = points[idx[(mini+2)%4]]; p4 = points[idx[(mini+3)%4]]; - len = Vec2Lenf(p1->uv, p1n->uv); + len = len_v2v2(p1->uv, p1n->uv); if (len > 0.0f) { len = 1.0/len; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 29d9bb4864e..792026a798d 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -48,7 +48,7 @@ #include "BKE_mesh.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" @@ -563,7 +563,7 @@ static void uv_map_transform_center(Scene *scene, View3D *v3d, float *result, Ob if(efa->v4) DO_MINMAX(efa->v4->co, min, max); } } - VecMidf(result, min, max); + mid_v3_v3v3(result, min, max); break; case V3D_CURSOR: /*cursor center*/ @@ -590,23 +590,23 @@ static void uv_map_rotation_matrix(float result[][4], RegionView3D *rv3d, Object /* get rotation of the current view matrix */ if(rv3d) - Mat4CpyMat4(viewmatrix, rv3d->viewmat); + copy_m4_m4(viewmatrix, rv3d->viewmat); else - Mat4One(viewmatrix); + unit_m4(viewmatrix); /* but shifting */ for(k=0; k<4; k++) viewmatrix[3][k] =0.0f; /* get rotation of the current object matrix */ - Mat4CpyMat4(rotobj,ob->obmat); + copy_m4_m4(rotobj,ob->obmat); /* but shifting */ for(k=0; k<4; k++) rotobj[3][k] =0.0f; - Mat4Clr(*rotup); - Mat4Clr(*rotside); + zero_m4(*rotup); + zero_m4(*rotside); /* compensate front/side.. against opengl x,y,z world definition */ /* this is "kanonen gegen spatzen", a few plus minus 1 will do here */ @@ -626,7 +626,7 @@ static void uv_map_rotation_matrix(float result[][4], RegionView3D *rv3d, Object rotup[0][0]= (float)1.0f/radius; /* calculate transforms*/ - Mat4MulSerie(result, rotup, rotside, viewmatrix, rotobj, NULL, NULL, NULL, NULL); + mul_serie_m4(result, rotup, rotside, viewmatrix, rotobj, NULL, NULL, NULL, NULL); } static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float rotmat[4][4]) @@ -657,7 +657,7 @@ static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float /* be compatible to the "old" sphere/cylinder mode */ if(direction == ALIGN_TO_OBJECT) - Mat4One(rotmat); + unit_m4(rotmat); else uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius); @@ -873,7 +873,7 @@ static void uv_from_view_bounds(float target[2], float source[3], float rotmat[4 { float pv[3]; - Mat4MulVecfl(rotmat, pv); + mul_m4_v3(rotmat, pv); /* ortho projection */ target[0] = -pv[0]; @@ -885,19 +885,19 @@ static void uv_from_view(ARegion *ar, float target[2], float source[3], float ro RegionView3D *rv3d= ar->regiondata; float pv[3], pv4[4], dx, dy, x= 0.0, y= 0.0; - Mat4MulVecfl(rotmat, pv); + mul_m4_v3(rotmat, pv); dx= ar->winx; dy= ar->winy; - VecCopyf(pv4, source); + copy_v3_v3(pv4, source); pv4[3]= 1.0; /* rotmat is the object matrix in this case */ - Mat4MulVec4fl(rotmat, pv4); + mul_m4_v4(rotmat, pv4); /* almost project_short */ - Mat4MulVec4fl(rv3d->persmat, pv4); + mul_m4_v4(rv3d->persmat, pv4); if(fabs(pv4[3]) > 0.00001) { /* avoid division by zero */ target[0] = dx/2.0 + (dx/2.0)*pv4[0]/pv4[3]; target[1] = dy/2.0 + (dy/2.0)*pv4[1]/pv4[3]; @@ -954,7 +954,7 @@ static int from_view_exec(bContext *C, wmOperator *op) } } else { - Mat4CpyMat4(rotmat, obedit->obmat); + copy_m4_m4(rotmat, obedit->obmat); for(efa= em->faces.first; efa; efa= efa->next) { if(efa->f & SELECT) { @@ -1063,10 +1063,10 @@ static void uv_sphere_project(float target[2], float source[3], float center[3], { float pv[3]; - VecSubf(pv, source, center); - Mat4MulVecfl(rotmat, pv); + sub_v3_v3v3(pv, source, center); + mul_m4_v3(rotmat, pv); - spheremap(pv[0], pv[1], pv[2], &target[0], &target[1]); + map_to_sphere( &target[0], &target[1],pv[0], pv[1], pv[2]); /* split line is always zero */ if(target[0] >= 1.0f) @@ -1155,10 +1155,10 @@ static void uv_cylinder_project(float target[2], float source[3], float center[3 { float pv[3]; - VecSubf(pv, source, center); - Mat4MulVecfl(rotmat, pv); + sub_v3_v3v3(pv, source, center); + mul_m4_v3(rotmat, pv); - tubemap(pv[0], pv[1], pv[2], &target[0], &target[1]); + map_to_tube( &target[0], &target[1],pv[0], pv[1], pv[2]); /* split line is always zero */ if(target[0] >= 1.0f) @@ -1248,7 +1248,7 @@ static int cube_project_exec(bContext *C, wmOperator *op) for(efa= em->faces.first; efa; efa= efa->next) { if(efa->f & SELECT) { tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, no); + normal_tri_v3( no,efa->v1->co, efa->v2->co, efa->v3->co); no[0]= fabs(no[0]); no[1]= fabs(no[1]); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 9e164f46e4c..a59c263055d 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -36,7 +36,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_meshdata_types.h" @@ -545,9 +545,9 @@ void GPU_buffer_copy_normal( DerivedMesh *dm, float *varray, int *index, int *re VECCOPY(&varray[start+6],&nors[i*3]); } if( mface[i].v4 ) - CalcNormFloat4(mvert[mface[i].v1].co, mvert[mface[i].v2].co, mvert[mface[i].v3].co, mvert[mface[i].v4].co, norm); + normal_quad_v3( norm,mvert[mface[i].v1].co, mvert[mface[i].v2].co, mvert[mface[i].v3].co, mvert[mface[i].v4].co); else - CalcNormFloat(mvert[mface[i].v1].co, mvert[mface[i].v2].co, mvert[mface[i].v3].co, norm); + normal_tri_v3( norm,mvert[mface[i].v1].co, mvert[mface[i].v2].co, mvert[mface[i].v3].co); VECCOPY(&varray[start],norm); VECCOPY(&varray[start+3],norm); VECCOPY(&varray[start+6],norm); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 0650a0bfa19..3da83d557a3 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -54,7 +54,7 @@ #include "BKE_texture.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "GPU_extensions.h" @@ -290,7 +290,7 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float v GPU_shader_uniform_vector(shader, material->obmatloc, 16, 1, (float*)obmat); } if(material->builtins & GPU_INVERSE_OBJECT_MATRIX) { - Mat4Invert(invmat, obmat); + invert_m4_m4(invmat, obmat); GPU_shader_uniform_vector(shader, material->invobmatloc, 16, 1, (float*)invmat); } if(material->builtins & GPU_OBCOLOR) { @@ -305,20 +305,20 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float v if(material->dynproperty & DYN_LAMP_VEC) { VECCOPY(lamp->dynvec, lamp->vec); - Normalize(lamp->dynvec); - VecNegf(lamp->dynvec); - Mat4Mul3Vecfl(viewmat, lamp->dynvec); + normalize_v3(lamp->dynvec); + negate_v3(lamp->dynvec); + mul_mat3_m4_v3(viewmat, lamp->dynvec); } if(material->dynproperty & DYN_LAMP_CO) { VECCOPY(lamp->dynco, lamp->co); - Mat4MulVecfl(viewmat, lamp->dynco); + mul_m4_v3(viewmat, lamp->dynco); } if(material->dynproperty & DYN_LAMP_IMAT) - Mat4MulMat4(lamp->dynimat, viewinv, lamp->imat); + mul_m4_m4m4(lamp->dynimat, viewinv, lamp->imat); if(material->dynproperty & DYN_LAMP_PERSMAT) - Mat4MulMat4(lamp->dynpersmat, viewinv, lamp->persmat); + mul_m4_m4m4(lamp->dynpersmat, viewinv, lamp->persmat); } GPU_pass_update_uniforms(material->pass); @@ -782,7 +782,7 @@ static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr) Object *ob = dob->ob; if(ob->type==OB_LAMP) { - Mat4CpyMat4(ob->obmat, dob->mat); + copy_m4_m4(ob->obmat, dob->mat); lamp = GPU_lamp_from_blender(shi->gpumat->scene, ob, base->object); if(lamp) @@ -1318,13 +1318,13 @@ void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4]) lamp->lay = lay; - Mat4CpyMat4(mat, obmat); - Mat4Ortho(mat); + copy_m4_m4(mat, obmat); + normalize_m4(mat); VECCOPY(lamp->vec, mat[2]); VECCOPY(lamp->co, mat[3]); - Mat4CpyMat4(lamp->obmat, mat); - Mat4Invert(lamp->imat, mat); + copy_m4_m4(lamp->obmat, mat); + invert_m4_m4(lamp->imat, mat); } void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy) @@ -1388,7 +1388,7 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l pixsize= (lamp->d)/temp; wsize= pixsize*0.5f*lamp->size; - i_window(-wsize, wsize, -wsize, wsize, lamp->d, lamp->clipend, lamp->winmat); + perspective_m4( lamp->winmat,-wsize, wsize, -wsize, wsize, lamp->d, lamp->clipend); } static void gpu_lamp_shadow_free(GPULamp *lamp) @@ -1489,16 +1489,16 @@ void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize float rangemat[4][4], persmat[4][4]; /* initshadowbuf */ - Mat4Invert(lamp->viewmat, lamp->obmat); - Normalize(lamp->viewmat[0]); - Normalize(lamp->viewmat[1]); - Normalize(lamp->viewmat[2]); + invert_m4_m4(lamp->viewmat, lamp->obmat); + normalize_v3(lamp->viewmat[0]); + normalize_v3(lamp->viewmat[1]); + normalize_v3(lamp->viewmat[2]); /* makeshadowbuf */ - Mat4MulMat4(persmat, lamp->viewmat, lamp->winmat); + mul_m4_m4m4(persmat, lamp->viewmat, lamp->winmat); /* opengl depth buffer is range 0.0..1.0 instead of -1.0..1.0 in blender */ - Mat4One(rangemat); + unit_m4(rangemat); rangemat[0][0] = 0.5f; rangemat[1][1] = 0.5f; rangemat[2][2] = 0.5f; @@ -1506,15 +1506,15 @@ void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize rangemat[3][1] = 0.5f; rangemat[3][2] = 0.5f; - Mat4MulMat4(lamp->persmat, persmat, rangemat); + mul_m4_m4m4(lamp->persmat, persmat, rangemat); /* opengl */ glDisable(GL_SCISSOR_TEST); GPU_framebuffer_texture_bind(lamp->fb, lamp->tex); /* set matrices */ - Mat4CpyMat4(viewmat, lamp->viewmat); - Mat4CpyMat4(winmat, lamp->winmat); + copy_m4_m4(viewmat, lamp->viewmat); + copy_m4_m4(winmat, lamp->winmat); *winsize = lamp->size; } diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c index f106302dbaf..c6ff6377f00 100644 --- a/source/blender/ikplugin/intern/ikplugin_api.c +++ b/source/blender/ikplugin/intern/ikplugin_api.c @@ -31,7 +31,7 @@ #include "BIK_api.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_armature.h" #include "BKE_utildefines.h" diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index 6eb1ef56094..e9378a7e12b 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -31,7 +31,7 @@ #include "BIK_api.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_armature.h" #include "BKE_constraint.h" @@ -179,10 +179,10 @@ static void make_dmats(bPoseChannel *pchan) { if (pchan->parent) { float iR_parmat[4][4]; - Mat4Invert(iR_parmat, pchan->parent->pose_mat); - Mat4MulMat4(pchan->chan_mat, pchan->pose_mat, iR_parmat); // delta mat + invert_m4_m4(iR_parmat, pchan->parent->pose_mat); + mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, iR_parmat); // delta mat } - else Mat4CpyMat4(pchan->chan_mat, pchan->pose_mat); + else copy_m4_m4(pchan->chan_mat, pchan->pose_mat); } /* applies IK matrix to pchan, IK is done separated */ @@ -192,19 +192,19 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[][3]) // nr = t { float vec[3], ikmat[4][4]; - Mat4CpyMat3(ikmat, ik_mat); + copy_m4_m3(ikmat, ik_mat); if (pchan->parent) - Mat4MulSerie(pchan->pose_mat, pchan->parent->pose_mat, pchan->chan_mat, ikmat, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(pchan->pose_mat, pchan->parent->pose_mat, pchan->chan_mat, ikmat, NULL, NULL, NULL, NULL, NULL); else - Mat4MulMat4(pchan->pose_mat, ikmat, pchan->chan_mat); + mul_m4_m4m4(pchan->pose_mat, ikmat, pchan->chan_mat); /* calculate head */ VECCOPY(pchan->pose_head, pchan->pose_mat[3]); /* calculate tail */ VECCOPY(vec, pchan->pose_mat[1]); - VecMulf(vec, pchan->bone->length); - VecAddf(pchan->pose_tail, pchan->pose_head, vec); + mul_v3_fl(vec, pchan->bone->length); + add_v3_v3v3(pchan->pose_tail, pchan->pose_head, vec); pchan->flag |= POSE_DONE; } @@ -266,41 +266,41 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) IK_SetParent(seg, parent); /* get the matrix that transforms from prevbone into this bone */ - Mat3CpyMat4(R_bonemat, pchan->pose_mat); + copy_m3_m4(R_bonemat, pchan->pose_mat); /* gather transformations for this IK segment */ if (pchan->parent) - Mat3CpyMat4(R_parmat, pchan->parent->pose_mat); + copy_m3_m4(R_parmat, pchan->parent->pose_mat); else - Mat3One(R_parmat); + unit_m3(R_parmat); /* bone offset */ if (pchan->parent && (a > 0)) - VecSubf(start, pchan->pose_head, pchan->parent->pose_tail); + sub_v3_v3v3(start, pchan->pose_head, pchan->parent->pose_tail); else /* only root bone (a = 0) has no parent */ start[0]= start[1]= start[2]= 0.0f; /* change length based on bone size */ - length= bone->length*VecLength(R_bonemat[1]); + length= bone->length*len_v3(R_bonemat[1]); /* compute rest basis and its inverse */ - Mat3CpyMat3(rest_basis, bone->bone_mat); - Mat3CpyMat3(irest_basis, bone->bone_mat); - Mat3Transp(irest_basis); + copy_m3_m3(rest_basis, bone->bone_mat); + copy_m3_m3(irest_basis, bone->bone_mat); + transpose_m3(irest_basis); /* compute basis with rest_basis removed */ - Mat3Inv(iR_parmat, R_parmat); - Mat3MulMat3(full_basis, iR_parmat, R_bonemat); - Mat3MulMat3(basis, irest_basis, full_basis); + invert_m3_m3(iR_parmat, R_parmat); + mul_m3_m3m3(full_basis, iR_parmat, R_bonemat); + mul_m3_m3m3(basis, irest_basis, full_basis); /* basis must be pure rotation */ - Mat3Ortho(basis); + normalize_m3(basis); /* transform offset into local bone space */ - Mat3Ortho(iR_parmat); - Mat3MulVecfl(iR_parmat, start); + normalize_m3(iR_parmat); + mul_m3_v3(iR_parmat, start); IK_SetTransform(seg, start, rest_basis, basis, length); @@ -332,13 +332,13 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) /* transform goal by parent mat, so this rotation is not part of the segment's basis. otherwise rotation limits do not work on the local transform of the segment itself. */ - Mat4CpyMat4(rootmat, pchan->parent->pose_mat); + copy_m4_m4(rootmat, pchan->parent->pose_mat); else - Mat4One(rootmat); + unit_m4(rootmat); VECCOPY(rootmat[3], pchan->pose_head); - Mat4MulMat4 (imat, rootmat, ob->obmat); - Mat4Invert (goalinv, imat); + mul_m4_m4m4(imat, rootmat, ob->obmat); + invert_m4_m4(goalinv, imat); for (target=tree->targets.first; target; target=target->next) { float polepos[3]; @@ -352,10 +352,10 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0); /* and set and transform goal */ - Mat4MulMat4(goal, rootmat, goalinv); + mul_m4_m4m4(goal, rootmat, goalinv); VECCOPY(goalpos, goal[3]); - Mat3CpyMat4(goalrot, goal); + copy_m3_m4(goalrot, goal); /* same for pole vector target */ if(data->poletar) { @@ -366,7 +366,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) break; } else { - Mat4MulMat4(goal, rootmat, goalinv); + mul_m4_m4m4(goal, rootmat, goalinv); VECCOPY(polepos, goal[3]); poleconstrain= 1; @@ -392,9 +392,9 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) pchan= tree->pchan[target->tip]; /* end effector in world space */ - Mat4CpyMat4(end_pose, pchan->pose_mat); + copy_m4_m4(end_pose, pchan->pose_mat); VECCOPY(end_pose[3], pchan->pose_tail); - Mat4MulSerie(world_pose, goalinv, ob->obmat, end_pose, 0, 0, 0, 0, 0); + mul_serie_m4(world_pose, goalinv, ob->obmat, end_pose, 0, 0, 0, 0, 0); /* blend position */ goalpos[0]= fac*goalpos[0] + mfac*world_pose[3][0]; @@ -402,10 +402,10 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) goalpos[2]= fac*goalpos[2] + mfac*world_pose[3][2]; /* blend rotation */ - Mat3ToQuat(goalrot, q1); - Mat4ToQuat(world_pose, q2); - QuatInterpol(q, q1, q2, mfac); - QuatToMat3(q, goalrot); + mat3_to_quat( q1,goalrot); + mat4_to_quat( q2,world_pose); + interp_qt_qtqt(q, q1, q2, mfac); + quat_to_mat3( goalrot,q); } iktarget= iktree[target->tip]; @@ -449,7 +449,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) float trans[3], length; IK_GetTranslationChange(iktree[a], trans); - length= pchan->bone->length*VecLength(pchan->pose_mat[1]); + length= pchan->bone->length*len_v3(pchan->pose_mat[1]); ikstretch[a]= (length == 0.0)? 1.0: (trans[1]+length)/length; } @@ -458,14 +458,14 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) stretch= (parentstretch == 0.0)? 1.0: ikstretch[a]/parentstretch; - VecMulf(tree->basis_change[a][0], stretch); - VecMulf(tree->basis_change[a][1], stretch); - VecMulf(tree->basis_change[a][2], stretch); + mul_v3_fl(tree->basis_change[a][0], stretch); + mul_v3_fl(tree->basis_change[a][1], stretch); + mul_v3_fl(tree->basis_change[a][2], stretch); } if(resultblend && resultinf!=1.0f) { - Mat3One(identity); - Mat3BlendMat3(tree->basis_change[a], identity, + unit_m3(identity); + blend_m3_m3m3(tree->basis_change[a], identity, tree->basis_change[a], resultinf); } diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 3dcb9e462b9..05de0a0775b 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -46,7 +46,7 @@ extern "C" { #include "BIK_api.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_global.h" #include "BKE_armature.h" @@ -550,15 +550,15 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram if (pchan->parent) { pchan = pchan->parent; float chanmat[4][4]; - Mat4CpyMat4(chanmat, pchan->pose_mat); + copy_m4_m4(chanmat, pchan->pose_mat); VECCOPY(chanmat[3], pchan->pose_tail); - Mat4MulSerie(restmat, target->owner->obmat, chanmat, target->eeRest, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(restmat, target->owner->obmat, chanmat, target->eeRest, NULL, NULL, NULL, NULL, NULL); } else { - Mat4MulMat4(restmat, target->eeRest, target->owner->obmat); + mul_m4_m4m4(restmat, target->eeRest, target->owner->obmat); } // blend the target - Mat4BlendMat4(tarmat, restmat, tarmat, constraint->enforce); + blend_m4_m4m4(tarmat, restmat, tarmat, constraint->enforce); } next.setValue(&tarmat[0][0]); return true; @@ -577,15 +577,15 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& if (pchan->parent) { pchan = pchan->parent; float chanmat[4][4]; - Mat4CpyMat4(chanmat, pchan->pose_mat); + copy_m4_m4(chanmat, pchan->pose_mat); VECCOPY(chanmat[3], pchan->pose_tail); // save the base as a frame too so that we can compute deformation // after simulation ikscene->baseFrame.setValue(&chanmat[0][0]); - Mat4MulMat4(rootmat, chanmat, ikscene->blArmature->obmat); + mul_m4_m4m4(rootmat, chanmat, ikscene->blArmature->obmat); } else { - Mat4CpyMat4(rootmat, ikscene->blArmature->obmat); + copy_m4_m4(rootmat, ikscene->blArmature->obmat); ikscene->baseFrame = iTaSC::F_identity; } next.setValue(&rootmat[0][0]); @@ -598,7 +598,7 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& float mat[4][4]; // temp matrix bKinematicConstraint* poledata = (bKinematicConstraint*)ikscene->polarConstraint->data; - Mat4Invert(imat, rootmat); + invert_m4_m4(imat, rootmat); // polar constraint imply only one target IK_Target *iktarget = ikscene->targets[0]; // root channel from which we take the bone initial orientation @@ -607,11 +607,11 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& // get polar target matrix in world space get_constraint_target_matrix(ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0); // convert to armature space - Mat4MulMat4(polemat, mat, imat); + mul_m4_m4m4(polemat, mat, imat); // get the target in world space (was computed before as target object are defined before base object) iktarget->target->getPose().getValue(mat[0]); // convert to armature space - Mat4MulMat4(goalmat, mat, imat); + mul_m4_m4m4(goalmat, mat, imat); // take position of target, polar target, end effector, in armature space KDL::Vector goalpos(goalmat[3]); KDL::Vector polepos(polemat[3]); @@ -787,16 +787,16 @@ static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintV if (chan->rotmode > 0) { /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */ - EulOToMat3(chan->eul, chan->rotmode, rmat); + eulO_to_mat3( rmat,chan->eul, chan->rotmode); } else if (chan->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - stored in quaternion data, but not really that great for 3D-changing orientations */ - AxisAngleToMat3(&chan->quat[1], chan->quat[0], rmat); + axis_angle_to_mat3( rmat,&chan->quat[1], chan->quat[0]); } else { /* quats are normalised before use to eliminate scaling issues */ - NormalQuat(chan->quat); - QuatToMat3(chan->quat, rmat); + normalize_qt(chan->quat); + quat_to_mat3( rmat,chan->quat); } KDL::Rotation jointRot( rmat[0][0], rmat[1][0], rmat[2][0], @@ -977,26 +977,26 @@ static void convert_pose(IK_Scene *ikscene) int a, joint; // assume uniform scaling and take Y scale as general scale for the armature - scale = VecLength(ikscene->blArmature->obmat[1]); + scale = len_v3(ikscene->blArmature->obmat[1]); rot = &ikscene->jointArray(0); for(joint=a=0, ikchan = ikscene->channels; anumchan && jointnumjoint; ++a, ++ikchan) { pchan= ikchan->pchan; bone= pchan->bone; if (pchan->parent) { - Mat4One(bmat); - Mat4MulMat43(bmat, pchan->parent->pose_mat, bone->bone_mat); + unit_m4(bmat); + mul_m4_m4m3(bmat, pchan->parent->pose_mat, bone->bone_mat); } else { - Mat4CpyMat4(bmat, bone->arm_mat); + copy_m4_m4(bmat, bone->arm_mat); } - Mat4Invert(rmat, bmat); - Mat4MulMat4(bmat, pchan->pose_mat, rmat); - Mat4Ortho(bmat); + invert_m4_m4(rmat, bmat); + mul_m4_m4m4(bmat, pchan->pose_mat, rmat); + normalize_m4(bmat); boneRot.setValue(bmat[0]); GetJointRotation(boneRot, ikchan->jointType, rot); if (ikchan->jointType & IK_TRANSY) { // compute actual length - rot[ikchan->ndof-1] = VecLenf(pchan->pose_tail, pchan->pose_head) * scale; + rot[ikchan->ndof-1] = len_v3v3(pchan->pose_tail, pchan->pose_head) * scale; } rot += ikchan->ndof; joint += ikchan->ndof; @@ -1014,7 +1014,7 @@ static void rest_pose(IK_Scene *ikscene) int a, joint; // assume uniform scaling and take Y scale as general scale for the armature - scale = VecLength(ikscene->blArmature->obmat[1]); + scale = len_v3(ikscene->blArmature->obmat[1]); // rest pose is 0 KDL::SetToZero(ikscene->jointArray); // except for transY joints @@ -1103,7 +1103,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) std::vector weights; double weight[3]; // assume uniform scaling and take Y scale as general scale for the armature - float scale = VecLength(ob->obmat[1]); + float scale = len_v3(ob->obmat[1]); // build the array of joints corresponding to the IK chain convert_channels(ikscene, tree); if (ingame) { @@ -1379,12 +1379,12 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) // it has a parent, get the pose matrix from it float baseFrame[4][4]; pchan = pchan->parent; - Mat4CpyMat4(baseFrame, pchan->bone->arm_mat); + copy_m4_m4(baseFrame, pchan->bone->arm_mat); // move to the tail and scale to get rest pose of armature base - VecCopyf(baseFrame[3], pchan->bone->arm_tail); - Mat4Invert(invBaseFrame, baseFrame); + copy_v3_v3(baseFrame[3], pchan->bone->arm_tail); + invert_m4_m4(invBaseFrame, baseFrame); } else { - Mat4One(invBaseFrame); + unit_m4(invBaseFrame); } // finally add the constraint for (t=0; ttargets.size(); t++) { @@ -1403,10 +1403,10 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) bonelen /= bonecnt; // store the rest pose of the end effector to compute enforce target - Mat4CpyMat4(mat, pchan->bone->arm_mat); - VecCopyf(mat[3], pchan->bone->arm_tail); + copy_m4_m4(mat, pchan->bone->arm_mat); + copy_v3_v3(mat[3], pchan->bone->arm_tail); // get the rest pose relative to the armature base - Mat4MulMat4(iktarget->eeRest, mat, invBaseFrame); + mul_m4_m4m4(iktarget->eeRest, mat, invBaseFrame); iktarget->eeBlend = (!ikscene->polarConstraint && condata->type==CONSTRAINT_IK_COPYPOSE) ? true : false; // use target_callback to make sure the initPose includes enforce coefficient target_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, iktarget); @@ -1660,13 +1660,13 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl VECCOPY(pchan->pose_tail, pchan->pose_mat[3]); // shift to head VECCOPY(yaxis, pchan->pose_mat[1]); - VecMulf(yaxis, length); - VecSubf(pchan->pose_mat[3], pchan->pose_mat[3], yaxis); + mul_v3_fl(yaxis, length); + sub_v3_v3v3(pchan->pose_mat[3], pchan->pose_mat[3], yaxis); VECCOPY(pchan->pose_head, pchan->pose_mat[3]); // add scale - VecMulf(pchan->pose_mat[0], scale); - VecMulf(pchan->pose_mat[1], scale); - VecMulf(pchan->pose_mat[2], scale); + mul_v3_fl(pchan->pose_mat[0], scale); + mul_v3_fl(pchan->pose_mat[1], scale); + mul_v3_fl(pchan->pose_mat[2], scale); } if (inumchan) { // big problem diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 7067c967da3..aed0d4e80a7 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -220,7 +220,7 @@ typedef enum ePchan_IkFlag { typedef enum eRotationModes { /* quaternion rotations (default, and for older Blender versions) */ ROT_MODE_QUAT = 0, - /* euler rotations - keep in sync with enum in BLI_arithb.h */ + /* euler rotations - keep in sync with enum in BLI_math.h */ ROT_MODE_EUL = 1, /* Blender 'default' (classic) - must be as 1 to sync with arithb defines */ ROT_MODE_XYZ = 1, /* Blender 'default' (classic) - must be as 1 to sync with arithb defines */ ROT_MODE_XZY, diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index 2b24b673185..8235d92d6f7 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -90,7 +90,7 @@ typedef struct bConstraintTarget { short space; /* space that target should be evaluated in (overrides bConstraint->tarspace) */ short flag; /* runtime settings (for editor, etc.) */ short type; /* type of target (B_CONSTRAINT_OB_TYPE) */ - short rotOrder; /* rotation order for target (as defined in BLI_arithb.h) */ + short rotOrder; /* rotation order for target (as defined in BLI_math.h) */ } bConstraintTarget; /* bConstraintTarget -> flag */ diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 7d88745779d..e79d8091917 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -38,7 +38,7 @@ #ifdef RNA_RUNTIME -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_depsgraph.h" diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index b02b6d8bba3..9217a7a7b98 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -39,7 +39,7 @@ #include "DNA_scene_types.h" #include "BLI_editVert.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_customdata.h" #include "BKE_depsgraph.h" @@ -123,9 +123,9 @@ static void rna_MeshFace_normal_get(PointerRNA *ptr, float *values) MFace *mface= (MFace*)ptr->data; if(mface->v4) - CalcNormFloat4(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co, me->mvert[mface->v4].co, values); + normal_quad_v3( values,me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co, me->mvert[mface->v4].co); else - CalcNormFloat(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co, values); + normal_tri_v3( values,me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co); } static float rna_MeshFace_area_get(PointerRNA *ptr) @@ -134,9 +134,9 @@ static float rna_MeshFace_area_get(PointerRNA *ptr) MFace *mface= (MFace*)ptr->data; if(mface->v4) - return AreaQ3Dfl(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co, me->mvert[mface->v4].co); + return area_quad_v3(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co, me->mvert[mface->v4].co); else - return AreaT3Dfl(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co); + return area_tri_v3(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co); } /* notice red and blue are swapped */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index a5ec30bd624..a02dcb7d9a2 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -83,7 +83,7 @@ EnumPropertyItem object_type_items[] = { #ifdef RNA_RUNTIME -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_key_types.h" @@ -508,7 +508,7 @@ static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value) /* for now, assume that rotation mode is axis-angle */ value[0]= ob->rotAngle; - VecCopyf(&value[1], ob->rotAxis); + copy_v3_v3(&value[1], ob->rotAxis); } /* rotation - axis-angle */ @@ -518,7 +518,7 @@ static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *val /* for now, assume that rotation mode is axis-angle */ ob->rotAngle= value[0]; - VecCopyf(ob->rotAxis, (float *)&value[1]); + copy_v3_v3(ob->rotAxis, (float *)&value[1]); // TODO: validate axis? } @@ -543,7 +543,7 @@ static void rna_Object_dimensions_get(PointerRNA *ptr, float *value) if (bb) { float scale[3]; - Mat4ToSize(ob->obmat, scale); + mat4_to_size( scale,ob->obmat); value[0] = fabs(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); value[1] = fabs(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); @@ -562,7 +562,7 @@ static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value) if (bb) { float scale[3], len[3]; - Mat4ToSize(ob->obmat, scale); + mat4_to_size( scale,ob->obmat); len[0] = bb->vec[4][0] - bb->vec[0][0]; len[1] = bb->vec[2][1] - bb->vec[0][1]; diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 098604c1eab..8fcc4e49986 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -57,7 +57,7 @@ #include "BKE_font.h" #include "BKE_mball.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_mesh_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index ad73f279b45..f458ee86091 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -105,7 +105,7 @@ EnumPropertyItem part_hair_ren_as_items[] = { #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_listbase.h" /* property update functions */ diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 584c971951a..5d2c281fb62 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -43,7 +43,7 @@ #include "BIK_api.h" #include "BKE_action.h" #include "BKE_armature.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_userdef_types.h" @@ -163,7 +163,7 @@ static void rna_PoseChannel_rotation_axis_angle_get(PointerRNA *ptr, float *valu /* for now, assume that rotation mode is axis-angle */ value[0]= pchan->rotAngle; - VecCopyf(&value[1], pchan->rotAxis); + copy_v3_v3(&value[1], pchan->rotAxis); } /* rotation - axis-angle */ @@ -173,7 +173,7 @@ static void rna_PoseChannel_rotation_axis_angle_set(PointerRNA *ptr, const float /* for now, assume that rotation mode is axis-angle */ pchan->rotAngle= value[0]; - VecCopyf(pchan->rotAxis, (float *)&value[1]); + copy_v3_v3(pchan->rotAxis, (float *)&value[1]); // TODO: validate axis? } diff --git a/source/blender/nodes/intern/CMP_util.h b/source/blender/nodes/intern/CMP_util.h index bb08a448bf4..6f37a876169 100644 --- a/source/blender/nodes/intern/CMP_util.h +++ b/source/blender/nodes/intern/CMP_util.h @@ -60,7 +60,7 @@ #include "../CMP_node.h" #include "node_util.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_camera.c b/source/blender/nodes/intern/SHD_nodes/SHD_camera.c index 20136d75540..91dc1c7ceb5 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_camera.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_camera.c @@ -45,7 +45,7 @@ static void node_shader_exec_camera(void *data, bNode *node, bNodeStack **in, bN VECCOPY(out[0]->vec, shi->co); /* get view vector */ out[1]->vec[0]= fabs(shi->co[2]); /* get view z-depth */ - out[2]->vec[0]= Normalize(out[0]->vec); /* get view distance */ + out[2]->vec[0]= normalize_v3(out[0]->vec); /* get view distance */ } } diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_curves.c b/source/blender/nodes/intern/SHD_nodes/SHD_curves.c index 511a6a6566d..c4f1dba57d3 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_curves.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_curves.c @@ -106,7 +106,7 @@ static void node_shader_exec_curve_rgb(void *data, bNode *node, bNodeStack **in, nodestack_get_vec(vec, SOCK_VECTOR, in[1]); curvemapping_evaluateRGBF(node->storage, out[0]->vec, vec); if(in[0]->vec[0] != 1.0f) { - VecLerpf(out[0]->vec, vec, out[0]->vec, *in[0]->vec); + interp_v3_v3v3(out[0]->vec, vec, out[0]->vec, *in[0]->vec); } } diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c b/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c index c081929a2fc..987525f52b6 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c @@ -49,7 +49,7 @@ static void node_shader_exec_mapping(void *data, bNode *node, bNodeStack **in, b /* stack order input: vector */ /* stack order output: vector */ nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - Mat4MulVecfl(texmap->mat, vec); + mul_m4_v3(texmap->mat, vec); if(texmap->flag & TEXMAP_CLIP_MIN) { if(vec[0]min[0]) vec[0]= texmap->min[0]; diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_material.c b/source/blender/nodes/intern/SHD_nodes/SHD_material.c index 69c2c0a345c..551958d190d 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_material.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_material.c @@ -101,7 +101,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, /* retrieve normal */ if(in[MAT_IN_NORMAL]->hasinput) { nodestack_get_vec(shi->vn, SOCK_VECTOR, in[MAT_IN_NORMAL]); - Normalize(shi->vn); + normalize_v3(shi->vn); } else VECCOPY(shi->vn, shi->vno); @@ -138,7 +138,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, if(node->custom1 & SH_NODE_MAT_DIFF) { VECCOPY(col, shrnode.combined); if(!(node->custom1 & SH_NODE_MAT_SPEC)) { - VecSubf(col, col, shrnode.spec); + sub_v3_v3v3(col, col, shrnode.spec); } } else if(node->custom1 & SH_NODE_MAT_SPEC) { diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_vectMath.c b/source/blender/nodes/intern/SHD_nodes/SHD_vectMath.c index 8a73a318f70..b377dbd2e03 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_vectMath.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_vectMath.c @@ -70,7 +70,7 @@ static void node_shader_exec_vect_math(void *data, bNode *node, bNodeStack **in, out[0]->vec[1]= vec1[1] + vec2[1]; out[0]->vec[2]= vec1[2] + vec2[2]; - out[1]->vec[0] = Normalize( out[0]->vec ); + out[1]->vec[0] = normalize_v3( out[0]->vec ); } else if(node->custom1 == 3) { /* Dot product */ out[1]->vec[0]= (vec1[0] * vec2[0]) + (vec1[1] * vec2[1]) + (vec1[2] * vec2[2]); @@ -80,7 +80,7 @@ static void node_shader_exec_vect_math(void *data, bNode *node, bNodeStack **in, out[0]->vec[1]= (vec1[2] * vec2[0]) - (vec1[0] * vec2[2]); out[0]->vec[2]= (vec1[0] * vec2[1]) - (vec1[1] * vec2[0]); - out[1]->vec[0] = Normalize( out[0]->vec ); + out[1]->vec[0] = normalize_v3( out[0]->vec ); } else if(node->custom1 == 5) { /* Normalize */ if(in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ @@ -94,7 +94,7 @@ static void node_shader_exec_vect_math(void *data, bNode *node, bNodeStack **in, out[0]->vec[2]= vec2[2]; } - out[1]->vec[0] = Normalize( out[0]->vec ); + out[1]->vec[0] = normalize_v3( out[0]->vec ); } } diff --git a/source/blender/nodes/intern/SHD_util.h b/source/blender/nodes/intern/SHD_util.h index a6fe5f4e9cc..76d5eb79490 100644 --- a/source/blender/nodes/intern/SHD_util.h +++ b/source/blender/nodes/intern/SHD_util.h @@ -58,7 +58,7 @@ #include "../SHD_node.h" #include "node_util.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c index 297fc02939d..5355b3f0fff 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c @@ -27,7 +27,7 @@ */ #include -#include "BLI_arithb.h" +#include "BLI_math.h" #include "../TEX_util.h" static bNodeSocketType inputs[]= { @@ -48,7 +48,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor tex_input_vec(coord1, in[0], p, thread); tex_input_vec(coord2, in[1], p, thread); - *out = VecLenf(coord2, coord1); + *out = len_v3v3(coord2, coord1); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c index 2184d32fcf2..1f550e32135 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c @@ -65,19 +65,19 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor if(magsq == 0) magsq = 1; - ndx = Inpf(coord, ax); + ndx = dot_v3v3(coord, ax); para[0] = ax[0] * ndx * (1 - cos_a); para[1] = ax[1] * ndx * (1 - cos_a); para[2] = ax[2] * ndx * (1 - cos_a); - VecSubf(perp, coord, para); + sub_v3_v3v3(perp, coord, para); perp[0] = coord[0] * cos_a; perp[1] = coord[1] * cos_a; perp[2] = coord[2] * cos_a; - Crossf(cp, ax, coord); + cross_v3_v3v3(cp, ax, coord); cp[0] = cp[0] * sin_a; cp[1] = cp[1] * sin_a; diff --git a/source/blender/nodes/intern/TEX_util.h b/source/blender/nodes/intern/TEX_util.h index 14e2773414a..e0bb907b0db 100644 --- a/source/blender/nodes/intern/TEX_util.h +++ b/source/blender/nodes/intern/TEX_util.h @@ -57,7 +57,7 @@ #include "../SHD_node.h" #include "node_util.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" diff --git a/source/blender/python/generic/Geometry.c b/source/blender/python/generic/Geometry.c index f7b7ee866f0..a49b93adabd 100644 --- a/source/blender/python/generic/Geometry.c +++ b/source/blender/python/generic/Geometry.c @@ -30,7 +30,7 @@ #include "Geometry.h" /* - Not needed for now though other geometry functions will probably need them -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" */ @@ -42,7 +42,7 @@ #include "BKE_utildefines.h" #include "BKE_curve.h" #include "BLI_boxpack2d.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #define SWAP_FLOAT(a,b,tmp) tmp=a; a=b; b=tmp #define eul 0.000001 @@ -346,7 +346,7 @@ static PyObject *M_Geometry_ClosestPointOnLine( PyObject * self, PyObject * args else { l2[2]=0.0; VECCOPY2D(l2, line_2->vec) } /* do the calculation */ - lambda = lambda_cp_line_ex(pt_in, l1, l2, pt_out); + lambda = closest_to_line_v3( pt_out,pt_in, l1, l2); ret = PyTuple_New(2); PyTuple_SET_ITEM( ret, 0, newVectorObject(pt_out, 3, Py_NEW, NULL) ); @@ -371,7 +371,7 @@ static PyObject *M_Geometry_PointInTriangle2D( PyObject * self, PyObject * args if(!BaseMath_ReadCallback(pt_vec) || !BaseMath_ReadCallback(tri_p1) || !BaseMath_ReadCallback(tri_p2) || !BaseMath_ReadCallback(tri_p3)) return NULL; - return PyLong_FromLong(IsectPT2Df(pt_vec->vec, tri_p1->vec, tri_p2->vec, tri_p3->vec)); + return PyLong_FromLong(isect_point_tri_v2(pt_vec->vec, tri_p1->vec, tri_p2->vec, tri_p3->vec)); } static PyObject *M_Geometry_PointInQuad2D( PyObject * self, PyObject * args ) @@ -392,7 +392,7 @@ static PyObject *M_Geometry_PointInQuad2D( PyObject * self, PyObject * args ) if(!BaseMath_ReadCallback(pt_vec) || !BaseMath_ReadCallback(quad_p1) || !BaseMath_ReadCallback(quad_p2) || !BaseMath_ReadCallback(quad_p3) || !BaseMath_ReadCallback(quad_p4)) return NULL; - return PyLong_FromLong(IsectPQ2Df(pt_vec->vec, quad_p1->vec, quad_p2->vec, quad_p3->vec, quad_p4->vec)); + return PyLong_FromLong(isect_point_quad_v2(pt_vec->vec, quad_p1->vec, quad_p2->vec, quad_p3->vec, quad_p4->vec)); } static int boxPack_FromPyObject(PyObject * value, boxPack **boxarray ) diff --git a/source/blender/python/generic/Mathutils.c b/source/blender/python/generic/Mathutils.c index 431f1987383..b44d6450145 100644 --- a/source/blender/python/generic/Mathutils.c +++ b/source/blender/python/generic/Mathutils.c @@ -29,7 +29,7 @@ #include "Mathutils.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "PIL_time.h" #include "BLI_rand.h" #include "BKE_utildefines.h" @@ -437,7 +437,7 @@ static PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args) mat[8] = 1.0f; } else if((strcmp(axis, "r") == 0) || (strcmp(axis, "R") == 0)) { //arbitrary rotation - AxisAngleToMat3(vec->vec, angle, (float (*)[3])mat); + axis_angle_to_mat3( (float (*)[3])mat,vec->vec, angle); } else { PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): unrecognizable axis of rotation type - expected x,y,z or r\n"); @@ -477,7 +477,7 @@ static PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * v return NULL; //create a identity matrix and add translation - Mat4One((float(*)[4]) mat); + unit_m4((float(*)[4]) mat); mat[12] = vec->vec[0]; mat[13] = vec->vec[1]; mat[14] = vec->vec[2]; @@ -762,7 +762,7 @@ static PyObject *M_Mathutils_DifferenceQuats(PyObject * self, PyObject * args) for(x = 0; x < 4; x++) { tempQuat[x] /= (float)(dot * dot); } - QuatMul(quat, tempQuat, quatV->quat); + mul_qt_qtqt(quat, tempQuat, quatV->quat); return newQuaternionObject(quat, Py_NEW, NULL); } //----------------------------------Mathutils.Slerp() ------------------ @@ -853,19 +853,19 @@ static PyObject *M_Mathutils_Intersect( PyObject * self, PyObject * args ) VECCOPY(v3, vec3->vec); VECCOPY(dir, ray->vec); - Normalize(dir); + normalize_v3(dir); VECCOPY(orig, ray_off->vec); /* find vectors for two edges sharing v1 */ - VecSubf(e1, v2, v1); - VecSubf(e2, v3, v1); + sub_v3_v3v3(e1, v2, v1); + sub_v3_v3v3(e2, v3, v1); /* begin calculating determinant - also used to calculated U parameter */ - Crossf(pvec, dir, e2); + cross_v3_v3v3(pvec, dir, e2); /* if determinant is near zero, ray lies in plane of triangle */ - det = Inpf(e1, pvec); + det = dot_v3v3(e1, pvec); if (det > -0.000001 && det < 0.000001) { Py_RETURN_NONE; @@ -874,29 +874,29 @@ static PyObject *M_Mathutils_Intersect( PyObject * self, PyObject * args ) inv_det = 1.0f / det; /* calculate distance from v1 to ray origin */ - VecSubf(tvec, orig, v1); + sub_v3_v3v3(tvec, orig, v1); /* calculate U parameter and test bounds */ - u = Inpf(tvec, pvec) * inv_det; + u = dot_v3v3(tvec, pvec) * inv_det; if (clip && (u < 0.0f || u > 1.0f)) { Py_RETURN_NONE; } /* prepare to test the V parameter */ - Crossf(qvec, tvec, e1); + cross_v3_v3v3(qvec, tvec, e1); /* calculate V parameter and test bounds */ - v = Inpf(dir, qvec) * inv_det; + v = dot_v3v3(dir, qvec) * inv_det; if (clip && (v < 0.0f || u + v > 1.0f)) { Py_RETURN_NONE; } /* calculate t, ray intersects triangle */ - t = Inpf(e2, qvec) * inv_det; + t = dot_v3v3(e2, qvec) * inv_det; - VecMulf(dir, t); - VecAddf(pvec, orig, dir); + mul_v3_fl(dir, t); + add_v3_v3v3(pvec, orig, dir); return newVectorObject(pvec, 3, Py_NEW, NULL); } @@ -947,7 +947,7 @@ static PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args ) v4[2] = 0.0f; } - result = LineIntersectLine(v1, v2, v3, v4, i1, i2); + result = isect_line_line_v3(v1, v2, v3, v4, i1, i2); if (result == 0) { /* colinear */ @@ -1000,22 +1000,22 @@ static PyObject *M_Mathutils_QuadNormal( PyObject * self, PyObject * args ) VECCOPY(v4, vec4->vec); /* find vectors for two edges sharing v2 */ - VecSubf(e1, v1, v2); - VecSubf(e2, v3, v2); + sub_v3_v3v3(e1, v1, v2); + sub_v3_v3v3(e2, v3, v2); - Crossf(n1, e2, e1); - Normalize(n1); + cross_v3_v3v3(n1, e2, e1); + normalize_v3(n1); /* find vectors for two edges sharing v4 */ - VecSubf(e1, v3, v4); - VecSubf(e2, v1, v4); + sub_v3_v3v3(e1, v3, v4); + sub_v3_v3v3(e2, v1, v4); - Crossf(n2, e2, e1); - Normalize(n2); + cross_v3_v3v3(n2, e2, e1); + normalize_v3(n2); /* adding and averaging the normals of both triangles */ - VecAddf(n1, n2, n1); - Normalize(n1); + add_v3_v3v3(n1, n2, n1); + normalize_v3(n1); return newVectorObject(n1, 3, Py_NEW, NULL); } @@ -1047,11 +1047,11 @@ static PyObject *M_Mathutils_TriangleNormal( PyObject * self, PyObject * args ) VECCOPY(v3, vec3->vec); /* find vectors for two edges sharing v2 */ - VecSubf(e1, v1, v2); - VecSubf(e2, v3, v2); + sub_v3_v3v3(e1, v1, v2); + sub_v3_v3v3(e2, v3, v2); - Crossf(n, e2, e1); - Normalize(n); + cross_v3_v3v3(n, e2, e1); + normalize_v3(n); return newVectorObject(n, 3, Py_NEW, NULL); } @@ -1082,7 +1082,7 @@ static PyObject *M_Mathutils_TriangleArea( PyObject * self, PyObject * args ) VECCOPY(v2, vec2->vec); VECCOPY(v3, vec3->vec); - return PyFloat_FromDouble( AreaT3Dfl(v1, v2, v3) ); + return PyFloat_FromDouble( area_tri_v3(v1, v2, v3) ); } else if (vec1->size == 2) { v1[0] = vec1->vec[0]; @@ -1094,7 +1094,7 @@ static PyObject *M_Mathutils_TriangleArea( PyObject * self, PyObject * args ) v3[0] = vec3->vec[0]; v3[1] = vec3->vec[1]; - return PyFloat_FromDouble( AreaF2Dfl(v1, v2, v3) ); + return PyFloat_FromDouble( area_tri_v2(v1, v2, v3) ); } else { PyErr_SetString( PyExc_TypeError, "only 2D,3D vectors are supported\n" ); diff --git a/source/blender/python/generic/euler.c b/source/blender/python/generic/euler.c index 73fcaeb457b..f6f2e337211 100644 --- a/source/blender/python/generic/euler.c +++ b/source/blender/python/generic/euler.c @@ -28,7 +28,7 @@ #include "Mathutils.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" #include "BLI_blenlib.h" @@ -123,9 +123,9 @@ static PyObject *Euler_ToQuat(EulerObject * self) for(x = 0; x < 3; x++) { eul[x] = self->eul[x] * ((float)Py_PI / 180); } - EulToQuat(eul, quat); + eul_to_quat( quat,eul); #else - EulToQuat(self->eul, quat); + eul_to_quat( quat,self->eul); #endif return newQuaternionObject(quat, Py_NEW, NULL); @@ -147,10 +147,10 @@ static PyObject *Euler_ToMatrix(EulerObject * self) for(x = 0; x < 3; x++) { eul[x] = self->eul[x] * ((float)Py_PI / 180); } - EulToMat3(eul, (float (*)[3]) mat); + eul_to_mat3( (float (*)[3]) mat,eul); } #else - EulToMat3(self->eul, (float (*)[3]) mat); + eul_to_mat3( (float (*)[3]) mat,self->eul); #endif return newMatrixObject(mat, 3, 3 , Py_NEW, NULL); } @@ -261,7 +261,7 @@ static PyObject *Euler_Rotate(EulerObject * self, PyObject *args) } } #endif - euler_rot(self->eul, angle, *axis); + rotate_eul(self->eul, *axis, angle); #ifdef USE_MATHUTILS_DEG { diff --git a/source/blender/python/generic/matrix.c b/source/blender/python/generic/matrix.c index 16ae3501b93..a1ef4b53615 100644 --- a/source/blender/python/generic/matrix.c +++ b/source/blender/python/generic/matrix.c @@ -28,7 +28,7 @@ #include "Mathutils.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" static PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject* vec); /* utility func */ @@ -229,9 +229,9 @@ static PyObject *Matrix_toQuat(MatrixObject * self) return NULL; } if(self->colSize == 3){ - Mat3ToQuat((float (*)[3])*self->matrix, quat); + mat3_to_quat( quat,(float (*)[3])*self->matrix); }else{ - Mat4ToQuat((float (*)[4])*self->matrix, quat); + mat4_to_quat( quat,(float (*)[4])*self->matrix); } return newQuaternionObject(quat, Py_NEW, NULL); @@ -266,14 +266,14 @@ PyObject *Matrix_toEuler(MatrixObject * self, PyObject *args) /*must be 3-4 cols, 3-4 rows, square matrix*/ if(self->colSize ==3 && self->rowSize ==3) { - if(eul_compat) Mat3ToCompatibleEul((float (*)[3])*self->matrix, eul, eul_compatf); - else Mat3ToEul((float (*)[3])*self->matrix, eul); + if(eul_compat) mat3_to_compatible_eul( eul, eul_compatf,(float (*)[3])*self->matrix); + else mat3_to_eul( eul,(float (*)[3])*self->matrix); }else if (self->colSize ==4 && self->rowSize ==4) { float tempmat3[3][3]; - Mat3CpyMat4(tempmat3, (float (*)[4])*self->matrix); - Mat3ToEul(tempmat3, eul); - if(eul_compat) Mat3ToCompatibleEul(tempmat3, eul, eul_compatf); - else Mat3ToEul(tempmat3, eul); + copy_m3_m4(tempmat3, (float (*)[4])*self->matrix); + mat3_to_eul( eul,tempmat3); + if(eul_compat) mat3_to_compatible_eul( eul, eul_compatf,tempmat3); + else mat3_to_eul( eul,tempmat3); }else { PyErr_SetString(PyExc_AttributeError, "Matrix.toEuler(): inappropriate matrix size - expects 3x3 or 4x4 matrix\n"); @@ -400,18 +400,18 @@ PyObject *Matrix_scalePart(MatrixObject * self) /*must be 3-4 cols, 3-4 rows, square matrix*/ if(self->colSize == 4 && self->rowSize == 4) - Mat3CpyMat4(mat, (float (*)[4])*self->matrix); + copy_m3_m4(mat, (float (*)[4])*self->matrix); else if(self->colSize == 3 && self->rowSize == 3) - Mat3CpyMat3(mat, (float (*)[3])*self->matrix); + copy_m3_m3(mat, (float (*)[3])*self->matrix); else { PyErr_SetString(PyExc_AttributeError, "Matrix.scalePart(): inappropriate matrix size - expects 3x3 or 4x4 matrix\n"); return NULL; } /* functionality copied from editobject.c apply_obmat */ - Mat3ToEul(mat, rot); - EulToMat3(rot, tmat); - Mat3Inv(imat, tmat); - Mat3MulMat3(tmat, imat, mat); + mat3_to_eul( rot,mat); + eul_to_mat3( tmat,rot); + invert_m3_m3(imat, tmat); + mul_m3_m3m3(tmat, imat, mat); scale[0]= tmat[0][0]; scale[1]= tmat[1][1]; @@ -449,9 +449,9 @@ PyObject *Matrix_Invert(MatrixObject * self) mat[2] = -self->matrix[1][0]; mat[3] = self->matrix[0][0]; } else if(self->rowSize == 3) { - Mat3Adj((float (*)[3]) mat,(float (*)[3]) *self->matrix); + adjoint_m3_m3((float (*)[3]) mat,(float (*)[3]) *self->matrix); } else if(self->rowSize == 4) { - Mat4Adj((float (*)[4]) mat, (float (*)[4]) *self->matrix); + adjoint_m4_m4((float (*)[4]) mat, (float (*)[4]) *self->matrix); } /*divide by determinate*/ for(x = 0; x < (self->rowSize * self->colSize); x++) { @@ -491,16 +491,16 @@ PyObject *Matrix_Determinant(MatrixObject * self) } if(self->rowSize == 2) { - det = Det2x2(self->matrix[0][0], self->matrix[0][1], + det = determinant_m2(self->matrix[0][0], self->matrix[0][1], self->matrix[1][0], self->matrix[1][1]); } else if(self->rowSize == 3) { - det = Det3x3(self->matrix[0][0], self->matrix[0][1], + det = determinant_m3(self->matrix[0][0], self->matrix[0][1], self->matrix[0][2], self->matrix[1][0], self->matrix[1][1], self->matrix[1][2], self->matrix[2][0], self->matrix[2][1], self->matrix[2][2]); } else { - det = Det4x4((float (*)[4]) *self->matrix); + det = determinant_m4((float (*)[4]) *self->matrix); } return PyFloat_FromDouble( (double) det ); @@ -523,9 +523,9 @@ PyObject *Matrix_Transpose(MatrixObject * self) self->matrix[1][0] = self->matrix[0][1]; self->matrix[0][1] = t; } else if(self->rowSize == 3) { - Mat3Transp((float (*)[3])*self->matrix); + transpose_m3((float (*)[3])*self->matrix); } else { - Mat4Transp((float (*)[4])*self->matrix); + transpose_m4((float (*)[4])*self->matrix); } BaseMath_WriteCallback(self); @@ -568,9 +568,9 @@ PyObject *Matrix_Identity(MatrixObject * self) self->matrix[1][0] = 0.0f; self->matrix[1][1] = 1.0f; } else if(self->rowSize == 3) { - Mat3One((float (*)[3]) *self->matrix); + unit_m3((float (*)[3]) *self->matrix); } else { - Mat4One((float (*)[4]) *self->matrix); + unit_m4((float (*)[4]) *self->matrix); } if(!BaseMath_WriteCallback(self)) diff --git a/source/blender/python/generic/quat.c b/source/blender/python/generic/quat.c index 7e12fe7925a..2ee78235224 100644 --- a/source/blender/python/generic/quat.c +++ b/source/blender/python/generic/quat.c @@ -28,7 +28,7 @@ #include "Mathutils.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" #include "BLI_blenlib.h" @@ -152,9 +152,9 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw if(size == 3) //calculate the quat based on axis/angle #ifdef USE_MATHUTILS_DEG - AxisAngleToQuat(quat, quat, angle * (Py_PI / 180)); + axis_angle_to_quat(quat, quat, angle * (Py_PI / 180)); #else - AxisAngleToQuat(quat, quat, angle); + axis_angle_to_quat(quat, quat, angle); #endif return newQuaternionObject(quat, Py_NEW, NULL); @@ -180,7 +180,7 @@ static PyObject *Quaternion_ToEuler(QuaternionObject * self, PyObject *args) if(!BaseMath_ReadCallback(eul_compat)) return NULL; - QuatToMat3(self->quat, mat); + quat_to_mat3( mat,self->quat); #ifdef USE_MATHUTILS_DEG { @@ -190,14 +190,14 @@ static PyObject *Quaternion_ToEuler(QuaternionObject * self, PyObject *args) for(x = 0; x < 3; x++) { eul_compatf[x] = eul_compat->eul[x] * ((float)Py_PI / 180); } - Mat3ToCompatibleEul(mat, eul, eul_compatf); + mat3_to_compatible_eul( eul, eul_compatf,mat); } #else - Mat3ToCompatibleEul(mat, eul, eul_compat->eul); + mat3_to_compatible_eul( eul, eul_compat->eul,mat); #endif } else { - QuatToEul(self->quat, eul); + quat_to_eul( eul,self->quat); } #ifdef USE_MATHUTILS_DEG @@ -220,7 +220,7 @@ static PyObject *Quaternion_ToMatrix(QuaternionObject * self) if(!BaseMath_ReadCallback(self)) return NULL; - QuatToMat3(self->quat, (float (*)[3]) mat); + quat_to_mat3( (float (*)[3]) mat,self->quat); return newMatrixObject(mat, 3, 3, Py_NEW, NULL); } @@ -238,7 +238,7 @@ static PyObject *Quaternion_Cross(QuaternionObject * self, QuaternionObject * va if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value)) return NULL; - QuatMul(quat, self->quat, value->quat); + mul_qt_qtqt(quat, self->quat, value->quat); return newQuaternionObject(quat, Py_NEW, NULL); } @@ -254,7 +254,7 @@ static PyObject *Quaternion_Dot(QuaternionObject * self, QuaternionObject * valu if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value)) return NULL; - return PyFloat_FromDouble(QuatDot(self->quat, value->quat)); + return PyFloat_FromDouble(dot_qtqt(self->quat, value->quat)); } //----------------------------Quaternion.normalize()---------------- @@ -264,7 +264,7 @@ static PyObject *Quaternion_Normalize(QuaternionObject * self) if(!BaseMath_ReadCallback(self)) return NULL; - NormalQuat(self->quat); + normalize_qt(self->quat); BaseMath_WriteCallback(self); Py_INCREF(self); @@ -277,7 +277,7 @@ static PyObject *Quaternion_Inverse(QuaternionObject * self) if(!BaseMath_ReadCallback(self)) return NULL; - QuatInv(self->quat); + invert_qt(self->quat); BaseMath_WriteCallback(self); Py_INCREF(self); @@ -290,7 +290,7 @@ static PyObject *Quaternion_Identity(QuaternionObject * self) if(!BaseMath_ReadCallback(self)) return NULL; - QuatOne(self->quat); + unit_qt(self->quat); BaseMath_WriteCallback(self); Py_INCREF(self); @@ -303,7 +303,7 @@ static PyObject *Quaternion_Negate(QuaternionObject * self) if(!BaseMath_ReadCallback(self)) return NULL; - QuatMulf(self->quat, -1.0f); + mul_qt_fl(self->quat, -1.0f); BaseMath_WriteCallback(self); Py_INCREF(self); @@ -316,7 +316,7 @@ static PyObject *Quaternion_Conjugate(QuaternionObject * self) if(!BaseMath_ReadCallback(self)) return NULL; - QuatConj(self->quat); + conjugate_qt(self->quat); BaseMath_WriteCallback(self); Py_INCREF(self); @@ -525,7 +525,7 @@ static PyObject *Quaternion_add(PyObject * q1, PyObject * q2) if(!BaseMath_ReadCallback(quat1) || !BaseMath_ReadCallback(quat2)) return NULL; - QuatAdd(quat, quat1->quat, quat2->quat, 1.0f); + add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f); return newQuaternionObject(quat, Py_NEW, NULL); } //------------------------obj - obj------------------------------ @@ -573,7 +573,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) } if(quat1 && quat2) { /* QUAT*QUAT (dot product) */ - return PyFloat_FromDouble(QuatDot(quat1->quat, quat2->quat)); + return PyFloat_FromDouble(dot_qtqt(quat1->quat, quat2->quat)); } /* the only case this can happen (for a supported type is "FLOAT*QUAT" ) */ @@ -581,7 +581,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) scalar= PyFloat_AsDouble(q1); if ((scalar == -1.0 && PyErr_Occurred())==0) { /* FLOAT*QUAT */ QUATCOPY(quat, quat2->quat); - QuatMulf(quat, scalar); + mul_qt_fl(quat, scalar); return newQuaternionObject(quat, Py_NEW, NULL); } PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: val * quat, val is not an acceptable type"); @@ -600,7 +600,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) scalar= PyFloat_AsDouble(q2); if ((scalar == -1.0 && PyErr_Occurred())==0) { /* QUAT*FLOAT */ QUATCOPY(quat, quat1->quat); - QuatMulf(quat, scalar); + mul_qt_fl(quat, scalar); return newQuaternionObject(quat, Py_NEW, NULL); } } @@ -669,7 +669,7 @@ static int Quaternion_setAxis( QuaternionObject * self, PyObject * value, void * static PyObject *Quaternion_getMagnitude( QuaternionObject * self, void *type ) { - return PyFloat_FromDouble(sqrt(QuatDot(self->quat, self->quat))); + return PyFloat_FromDouble(sqrt(dot_qtqt(self->quat, self->quat))); } static PyObject *Quaternion_getAngle( QuaternionObject * self, void *type ) @@ -692,7 +692,7 @@ static PyObject *Quaternion_getAxisVec( QuaternionObject * self, void *type ) for(i = 0; i < 3; i++) vec[i] = (float)(self->quat[i + 1] / mag); - Normalize(vec); + normalize_v3(vec); //If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations if( EXPP_FloatsAreEqual(vec[0], 0.0f, 10) && EXPP_FloatsAreEqual(vec[1], 0.0f, 10) && @@ -820,7 +820,7 @@ PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type) }else if (type == Py_NEW){ self->quat = PyMem_Malloc(4 * sizeof(float)); if(!quat) { //new empty - QuatOne(self->quat); + unit_qt(self->quat); }else{ QUATCOPY(self->quat, quat); } diff --git a/source/blender/python/generic/vector.c b/source/blender/python/generic/vector.c index 0ce7b83e653..8d1356f62f4 100644 --- a/source/blender/python/generic/vector.c +++ b/source/blender/python/generic/vector.c @@ -29,7 +29,7 @@ #include "BLI_blenlib.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #define MAX_DIMENSIONS 4 /* Swizzle axes get packed into a single value that is used as a closure. Each @@ -347,7 +347,7 @@ static PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args ) vec[1] = -self->vec[1]; vec[2] = -self->vec[2]; - vectoquat(vec, track, up, quat); + vec_to_quat( quat,vec, track, up); return newQuaternionObject(quat, Py_NEW, NULL); } @@ -379,7 +379,7 @@ static PyObject *Vector_Reflect( VectorObject * self, VectorObject * value ) if (self->size > 2) vec[2] = self->vec[2]; else vec[2] = 0.0; - VecReflect(reflect, vec, mirror); + reflect_v3_v3v3(reflect, vec, mirror); return newVectorObject(reflect, self->size, Py_NEW, NULL); } @@ -402,7 +402,7 @@ static PyObject *Vector_Cross( VectorObject * self, VectorObject * value ) return NULL; vecCross = (VectorObject *)newVectorObject(NULL, 3, Py_NEW, NULL); - Crossf(vecCross->vec, self->vec, value->vec); + cross_v3_v3v3(vecCross->vec, self->vec, value->vec); return (PyObject *)vecCross; } diff --git a/source/blender/render/intern/raytrace/rayobject.cpp b/source/blender/render/intern/raytrace/rayobject.cpp index 8aff7a38317..869405e0fbc 100644 --- a/source/blender/render/intern/raytrace/rayobject.cpp +++ b/source/blender/render/intern/raytrace/rayobject.cpp @@ -29,7 +29,7 @@ #include #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "DNA_material_types.h" #include "RE_raytrace.h" @@ -170,8 +170,8 @@ static inline int rayface_check_cullface(RayFace *face, Isect *is) float nor[3]; /* don't intersect if the ray faces along the face normal */ - if(face->quad) CalcNormFloat4(face->v1, face->v2, face->v3, face->v4, nor); - else CalcNormFloat(face->v1, face->v2, face->v3, nor); + if(face->quad) normal_quad_v3( nor,face->v1, face->v2, face->v3, face->v4); + else normal_tri_v3( nor,face->v1, face->v2, face->v3); return (INPR(nor, is->vec) < 0); } @@ -376,7 +376,7 @@ int RE_rayobject_raycast(RayObject *r, Isect *isec) RE_RC_COUNT(isec->raycounter->raycast.test); /* Setup vars used on raycast */ - isec->dist = VecLength(isec->vec); + isec->dist = len_v3(isec->vec); for(i=0; i<3; i++) { @@ -435,11 +435,11 @@ int RE_rayobject_intersect(RayObject *r, Isect *i) if(face->ob->transform_primitives) { - Mat4MulVecfl(face->ob->mat, nface.v1); - Mat4MulVecfl(face->ob->mat, nface.v2); - Mat4MulVecfl(face->ob->mat, nface.v3); + mul_m4_v3(face->ob->mat, nface.v1); + mul_m4_v3(face->ob->mat, nface.v2); + mul_m4_v3(face->ob->mat, nface.v3); if(RE_rayface_isQuad(&nface)) - Mat4MulVecfl(face->ob->mat, nface.v4); + mul_m4_v3(face->ob->mat, nface.v4); } return intersect_rayface(r, &nface, i); diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp index a16499d4f91..09026929829 100644 --- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp +++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp @@ -33,7 +33,7 @@ #include "rayobject_rtbuild.h" #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_utildefines.h" static bool selected_node(RTBuilder::Object *node) diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp index 11f04c04141..4a2a56fa8ef 100644 --- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp @@ -38,7 +38,7 @@ int tot_hints = 0; #include "BLI_memarena.h" #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "reorganize.h" #include "bvh.h" diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 072083e58a7..cbb15558a3d 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -35,7 +35,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_memarena.h" @@ -191,8 +191,8 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), if (re) re->flag |= R_HALO; else stargrid *= 1.0; /* then it draws fewer */ - if(re) Mat4Invert(mat, re->viewmat); - else Mat4One(mat); + if(re) invert_m4_m4(mat, re->viewmat); + else unit_m4(mat); /* BOUNDING BOX CALCULATION * bbox goes from z = loc_near_var | loc_far_var, @@ -240,7 +240,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), done++; } else { - Mat4MulVecfl(re->viewmat, vec); + mul_m4_v3(re->viewmat, vec); /* in vec are global coordinates * calculate distance to camera @@ -372,7 +372,7 @@ static int check_vnormal(float *n, float *veno) static void calc_edge_stress_add(float *accum, VertRen *v1, VertRen *v2) { - float len= VecLenf(v1->co, v2->co)/VecLenf(v1->orco, v2->orco); + float len= len_v3v3(v1->co, v2->co)/len_v3v3(v1->orco, v2->orco); float *acc; acc= accum + 2*v1->index; @@ -459,11 +459,11 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr } else if(v1->orco) { uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; - spheremap(v1->orco[0], v1->orco[1], v1->orco[2], &uv[0][0], &uv[0][1]); - spheremap(v2->orco[0], v2->orco[1], v2->orco[2], &uv[1][0], &uv[1][1]); - spheremap(v3->orco[0], v3->orco[1], v3->orco[2], &uv[2][0], &uv[2][1]); + map_to_sphere( &uv[0][0], &uv[0][1],v1->orco[0], v1->orco[1], v1->orco[2]); + map_to_sphere( &uv[1][0], &uv[1][1],v2->orco[0], v2->orco[1], v2->orco[2]); + map_to_sphere( &uv[2][0], &uv[2][1],v3->orco[0], v3->orco[1], v3->orco[2]); if(v4) - spheremap(v4->orco[0], v4->orco[1], v4->orco[2], &uv[3][0], &uv[3][1]); + map_to_sphere( &uv[3][0], &uv[3][1],v4->orco[0], v4->orco[1], v4->orco[2]); } else return; @@ -539,23 +539,23 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d if(re->flag & R_GLOB_NOPUNOFLIP) vlr->flag |= R_NOPUNOFLIP; - VecSubf(n1, v2->co, v1->co); - Normalize(n1); - VecSubf(n2, v3->co, v2->co); - Normalize(n2); + sub_v3_v3v3(n1, v2->co, v1->co); + normalize_v3(n1); + sub_v3_v3v3(n2, v3->co, v2->co); + normalize_v3(n2); if(v4==NULL) { - VecSubf(n3, v1->co, v3->co); - Normalize(n3); + sub_v3_v3v3(n3, v1->co, v3->co); + normalize_v3(n3); fac1= saacos(-n1[0]*n3[0]-n1[1]*n3[1]-n1[2]*n3[2]); fac2= saacos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2]); fac3= saacos(-n2[0]*n3[0]-n2[1]*n3[1]-n2[2]*n3[2]); } else { - VecSubf(n3, v4->co, v3->co); - Normalize(n3); - VecSubf(n4, v1->co, v4->co); - Normalize(n4); + sub_v3_v3v3(n3, v4->co, v3->co); + normalize_v3(n3); + sub_v3_v3v3(n4, v1->co, v4->co); + normalize_v3(n4); fac1= saacos(-n4[0]*n1[0]-n4[1]*n1[1]-n4[2]*n1[2]); fac2= saacos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2]); @@ -622,17 +622,17 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d vtang= find_vertex_tangent(vtangents[v1->index], tface->uv[0]); VECCOPY(ftang, vtang); - Normalize(ftang); + normalize_v3(ftang); vtang= find_vertex_tangent(vtangents[v2->index], tface->uv[1]); VECCOPY(ftang+3, vtang); - Normalize(ftang+3); + normalize_v3(ftang+3); vtang= find_vertex_tangent(vtangents[v3->index], tface->uv[2]); VECCOPY(ftang+6, vtang); - Normalize(ftang+6); + normalize_v3(ftang+6); if(v4) { vtang= find_vertex_tangent(vtangents[v4->index], tface->uv[3]); VECCOPY(ftang+9, vtang); - Normalize(ftang+9); + normalize_v3(ftang+9); } } } @@ -641,7 +641,7 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d /* normalize vertex normals */ for(a=0; atotvert; a++) { VertRen *ver= RE_findOrAddVert(obr, a); - Normalize(ver->n); + normalize_v3(ver->n); if(do_tangent) { float *tav= RE_vertren_get_tangent(obr, ver, 0); if (tav) { @@ -650,7 +650,7 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d tav[0] -= ver->n[0]*tdn; tav[1] -= ver->n[1]*tdn; tav[2] -= ver->n[2]*tdn; - Normalize(tav); + normalize_v3(tav); } } } @@ -829,7 +829,7 @@ static void autosmooth(Render *re, ObjectRen *obr, float mat[][4], int degr) /* rotate vertices and calculate normal of faces */ for(a=0; atotvert; a++) { ver= RE_findOrAddVert(obr, a); - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); } for(a=0; atotvlak; a++) { vlr= RE_findOrAddVlak(obr, a); @@ -837,9 +837,9 @@ static void autosmooth(Render *re, ObjectRen *obr, float mat[][4], int degr) /* skip wire faces */ if(vlr->v2 != vlr->v3) { if(vlr->v4) - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); else - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); } } } @@ -982,9 +982,9 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par int flag, i; static int second=0; - VecSubf(nor, vec, vec1); - Normalize(nor); // nor needed as tangent - Crossf(cross, vec, nor); + sub_v3_v3v3(nor, vec, vec1); + normalize_v3(nor); // nor needed as tangent + cross_v3_v3v3(cross, vec, nor); /* turn cross in pixelsize */ w= vec[2]*re->winmat[2][3] + re->winmat[3][3]; @@ -1006,19 +1006,19 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par /* use actual Blender units for strand width and fall back to minimum width */ if(ma->mode & MA_STR_B_UNITS){ - crosslen= VecLength(cross); + crosslen= len_v3(cross); w= 2.0f*crosslen*ma->strand_min/w; if(width < w) width= w; /*cross is the radius of the strand so we want it to be half of full width */ - VecMulf(cross,0.5/crosslen); + mul_v3_fl(cross,0.5/crosslen); } else width/=w; - VecMulf(cross, width); + mul_v3_fl(cross, width); } else width= 1.0f; @@ -1041,30 +1041,30 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->v4= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(vlr->v1->co, vec); - VecAddf(vlr->v1->co, vlr->v1->co, cross); + add_v3_v3v3(vlr->v1->co, vlr->v1->co, cross); VECCOPY(vlr->v1->n, nor); vlr->v1->orco= sd->orco; vlr->v1->accum= -1.0f; // accum abuse for strand texco VECCOPY(vlr->v2->co, vec); - VecSubf(vlr->v2->co, vlr->v2->co, cross); + sub_v3_v3v3(vlr->v2->co, vlr->v2->co, cross); VECCOPY(vlr->v2->n, nor); vlr->v2->orco= sd->orco; vlr->v2->accum= vlr->v1->accum; VECCOPY(vlr->v4->co, vec1); - VecAddf(vlr->v4->co, vlr->v4->co, cross); + add_v3_v3v3(vlr->v4->co, vlr->v4->co, cross); VECCOPY(vlr->v4->n, nor); vlr->v4->orco= sd->orco; vlr->v4->accum= 1.0f; // accum abuse for strand texco VECCOPY(vlr->v3->co, vec1); - VecSubf(vlr->v3->co, vlr->v3->co, cross); + sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); VECCOPY(vlr->v3->n, nor); vlr->v3->orco= sd->orco; vlr->v3->accum= vlr->v4->accum; - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); vlr->mat= ma; vlr->ec= ME_V2V3; @@ -1115,13 +1115,13 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par v2= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(v1->co, vec); - VecAddf(v1->co, v1->co, cross); + add_v3_v3v3(v1->co, v1->co, cross); VECCOPY(v1->n, nor); v1->orco= sd->orco; v1->accum= -1.0f; // accum abuse for strand texco VECCOPY(v2->co, vec); - VecSubf(v2->co, v2->co, cross); + sub_v3_v3v3(v2->co, v2->co, cross); VECCOPY(v2->n, nor); v2->orco= sd->orco; v2->accum= v1->accum; @@ -1149,15 +1149,15 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par } else if(sd->adapt){ float dvec[3],pvec[3]; - VecSubf(dvec,avec,vec); - Projf(pvec,dvec,vec); - VecSubf(dvec,dvec,pvec); + sub_v3_v3v3(dvec,avec,vec); + project_v3_v3v3(pvec,dvec,vec); + sub_v3_v3v3(dvec,dvec,pvec); w= vec[2]*re->winmat[2][3] + re->winmat[3][3]; dx= re->winx*dvec[0]*re->winmat[0][0]/w; dy= re->winy*dvec[1]*re->winmat[1][1]/w; w= sqrt(dx*dx + dy*dy); - if(Inpf(anor,nor)adapt_angle && w>sd->adapt_pix){ + if(dot_v3v3(anor,nor)adapt_angle && w>sd->adapt_pix){ vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->flag= flag; vlr->v1= v1; @@ -1177,18 +1177,18 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par } VECCOPY(vlr->v4->co, vec); - VecAddf(vlr->v4->co, vlr->v4->co, cross); + add_v3_v3v3(vlr->v4->co, vlr->v4->co, cross); VECCOPY(vlr->v4->n, nor); vlr->v4->orco= sd->orco; vlr->v4->accum= -1.0f + 2.0f*sd->time; // accum abuse for strand texco VECCOPY(vlr->v3->co, vec); - VecSubf(vlr->v3->co, vlr->v3->co, cross); + sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); VECCOPY(vlr->v3->n, nor); vlr->v3->orco= sd->orco; vlr->v3->accum= vlr->v4->accum; - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); vlr->mat= ma; vlr->ec= ME_V2V3; @@ -1244,8 +1244,8 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float VECCOPY(vlr->v1->co, vec); VECCOPY(vlr->v2->co, vec1); - VecSubf(vlr->n, vec, vec1); - Normalize(vlr->n); + sub_v3_v3v3(vlr->n, vec, vec1); + normalize_v3(vlr->n); VECCOPY(vlr->v1->n, vlr->n); VECCOPY(vlr->v2->n, vlr->n); @@ -1267,8 +1267,8 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float v1= vlr->v2; // cycle VECCOPY(v1->co, vec); - VecSubf(vlr->n, vec, vec1); - Normalize(vlr->n); + sub_v3_v3v3(vlr->n, vec, vec1); + normalize_v3(vlr->n); VECCOPY(v1->n, vlr->n); vlr->mat= ma; @@ -1307,21 +1307,21 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl VECADD(vlr->v1->co, bb_center, xvec); VECADD(vlr->v1->co, vlr->v1->co, yvec); - Mat4MulVecfl(re->viewmat, vlr->v1->co); + mul_m4_v3(re->viewmat, vlr->v1->co); VECSUB(vlr->v2->co, bb_center, xvec); VECADD(vlr->v2->co, vlr->v2->co, yvec); - Mat4MulVecfl(re->viewmat, vlr->v2->co); + mul_m4_v3(re->viewmat, vlr->v2->co); VECSUB(vlr->v3->co, bb_center, xvec); VECSUB(vlr->v3->co, vlr->v3->co, yvec); - Mat4MulVecfl(re->viewmat, vlr->v3->co); + mul_m4_v3(re->viewmat, vlr->v3->co); VECADD(vlr->v4->co, bb_center, xvec); VECSUB(vlr->v4->co, vlr->v4->co, yvec); - Mat4MulVecfl(re->viewmat, vlr->v4->co); + mul_m4_v3(re->viewmat, vlr->v4->co); - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); VECCOPY(vlr->v1->n,vlr->n); VECCOPY(vlr->v2->n,vlr->n); VECCOPY(vlr->v3->n,vlr->n); @@ -1352,10 +1352,10 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl axis2[(bb->align + 2) % 3] = 1.0f; if(bb->lock == 0) { zvec[bb->align] = 0.0f; - Normalize(zvec); + normalize_v3(zvec); } - time = saacos(Inpf(zvec, axis1)) / (float)M_PI; - if(Inpf(zvec, axis2) < 0.0f) + time = saacos(dot_v3v3(zvec, axis1)) / (float)M_PI; + if(dot_v3v3(zvec, axis2) < 0.0f) time = 1.0f - time / 2.0f; else time = time / 2.0f; @@ -1419,7 +1419,7 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re VECCOPY(loc, state->co); if(ren_as != PART_DRAW_BB) - Mat4MulVecfl(re->viewmat, loc); + mul_m4_v3(re->viewmat, loc); switch(ren_as) { case PART_DRAW_LINE: @@ -1428,11 +1428,11 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re sd->size = hasize; VECCOPY(vel, state->vel); - Mat4Mul3Vecfl(re->viewmat, vel); - Normalize(vel); + mul_mat3_m4_v3(re->viewmat, vel); + normalize_v3(vel); if(part->draw & PART_DRAW_VEL_LENGTH) - VecMulf(vel, VecLength(state->vel)); + mul_v3_fl(vel, len_v3(state->vel)); VECADDFAC(loc0, loc, vel, -part->draw_line[0]); VECADDFAC(loc1, loc, vel, part->draw_line[1]); @@ -1651,10 +1651,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem // } /* 2.5 setup matrices */ - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); /* need to be that way, for imat texture */ - Mat3CpyMat4(nmat, ob->imat); - Mat3Transp(nmat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); /* need to be that way, for imat texture */ + copy_m3_m4(nmat, ob->imat); + transpose_m3(nmat); /* 2.6 setup strand rendering */ if(part->ren_as == PART_DRAW_PATH && psys->pathcache){ @@ -1677,7 +1677,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem strandbuf= RE_addStrandBuffer(obr, (totpart+totchild)*(path_nbr+1)); strandbuf->ma= ma; strandbuf->lay= ob->lay; - Mat4CpyMat4(strandbuf->winmat, re->winmat); + copy_m4_m4(strandbuf->winmat, re->winmat); strandbuf->winx= re->winx; strandbuf->winy= re->winy; strandbuf->maxdepth= 2; @@ -1861,7 +1861,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* surface normal shading setup */ if(ma->mode_l & MA_STR_SURFDIFF) { - Mat3MulVecfl(nmat, nor); + mul_m3_v3(nmat, nor); sd.surfnor= nor; } else @@ -1916,7 +1916,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem curlen= 0.0f; for(k=1; k<=path_nbr; k++) if(k<=max_k) - strandlen += VecLenf((cache+k-1)->co, (cache+k)->co); + strandlen += len_v3v3((cache+k-1)->co, (cache+k)->co); } if(path_nbr) { @@ -1930,11 +1930,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem continue; if(k > 0) - curlen += VecLenf((cache+k-1)->co, (cache+k)->co); + curlen += len_v3v3((cache+k-1)->co, (cache+k)->co); time= curlen/strandlen; VECCOPY(loc,state.co); - Mat4MulVecfl(re->viewmat,loc); + mul_m4_v3(re->viewmat,loc); if(strandbuf) { VECCOPY(svert->co, loc); @@ -1985,7 +1985,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem psys_get_particle_on_path(&sim,a,&state,1); if(psys->parent) - Mat4MulVecfl(psys->parent->obmat, state.co); + mul_m4_v3(psys->parent->obmat, state.co); if(part->ren_as == PART_DRAW_BB) { bb.random = random; @@ -2005,7 +2005,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem continue; if(psys->parent) - Mat4MulVecfl(psys->parent->obmat, state.co); + mul_m4_v3(psys->parent->obmat, state.co); if(part->ren_as == PART_DRAW_BB) { bb.random = random; @@ -2076,8 +2076,8 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *me, int totvert, float vec[3], hasize, mat[4][4], imat[3][3]; int a, ok, seed= ma->seed1; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat3CpyMat4(imat, ob->imat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + copy_m3_m4(imat, ob->imat); re->flag |= R_HALO; @@ -2088,7 +2088,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *me, int totvert, hasize= ma->hasize; VECCOPY(vec, mvert->co); - Mat4MulVecfl(mat, vec); + mul_m4_v3(mat, vec); if(ma->mode & MA_HALOPUNO) { xn= mvert->no[0]; @@ -2099,10 +2099,10 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *me, int totvert, nor[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; nor[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; nor[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - Normalize(nor); + normalize_v3(nor); VECCOPY(view, vec); - Normalize(view); + normalize_v3(view); zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2]; if(zn>=0.0) hasize= 0.0; @@ -2183,7 +2183,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve VECCOPY(shi->vn, vr->n); if(mat) - Mat4MulVecfl(mat, shi->co); + mul_m4_v3(mat, shi->co); if(imat) { shi->vn[0]= imat[0][0]*vr->n[0]+imat[0][1]*vr->n[1]+imat[0][2]*vr->n[2]; @@ -2221,7 +2221,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve } if (texco & TEXCO_GLOB) { VECCOPY(shi->gl, shi->co); - Mat4MulVecfl(re->viewinv, shi->gl); + mul_m4_v3(re->viewinv, shi->gl); } if (texco & TEXCO_NORM) { VECCOPY(shi->orn, shi->vn); @@ -2242,7 +2242,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve displace[2]= shi->displace[2] * scale[2]; if(mat) - Mat3MulVecfl(imat, displace); + mul_m3_v3(imat, displace); /* 0.5 could become button once? */ vr->co[0] += displace[0]; @@ -2306,10 +2306,10 @@ static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float /* Recalculate the face normal - if flipped before, flip now */ if(vlr->v4) { - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); } else { - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); } } @@ -2325,7 +2325,7 @@ static void do_displacement(Render *re, ObjectRen *obr, float mat[][4], float im /* Object Size with parenting */ obt=obr->ob; while(obt){ - VecAddf(temp, obt->size, obt->dsize); + add_v3_v3v3(temp, obt->size, obt->dsize); scale[0]*=temp[0]; scale[1]*=temp[1]; scale[2]*=temp[2]; obt=obt->parent; } @@ -2362,9 +2362,9 @@ static void init_render_mball(Render *re, ObjectRen *obr) if (ob!=find_basis_mball(re->scene, ob)) return; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); - Mat3CpyMat4(imat, ob->imat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); + copy_m3_m4(imat, ob->imat); ma= give_render_material(re, ob, 1); @@ -2385,7 +2385,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, data); - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); /* render normals are inverted */ xn= -nors[0]; @@ -2396,8 +2396,8 @@ static void init_render_mball(Render *re, ObjectRen *obr) ver->n[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; ver->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; ver->n[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - Normalize(ver->n); - //if(ob->transflag & OB_NEG_SCALE) VecMulf(ver->n. -1.0); + normalize_v3(ver->n); + //if(ob->transflag & OB_NEG_SCALE) mul_v3_fl(ver->n. -1.0); if(need_orco) ver->orco= orco; } @@ -2412,9 +2412,9 @@ static void init_render_mball(Render *re, ObjectRen *obr) vlr->v4= 0; if(ob->transflag & OB_NEG_SCALE) - CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v1->co, vlr->v2->co, vlr->v3->co); else - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); vlr->mat= ma; vlr->flag= ME_SMOOTH+R_NOPUNOFLIP; @@ -2429,9 +2429,9 @@ static void init_render_mball(Render *re, ObjectRen *obr) vlr1->v2= vlr1->v3; vlr1->v3= RE_findOrAddVert(obr, index[3]); if(ob->transflag & OB_NEG_SCALE) - CalcNormFloat(vlr1->v1->co, vlr1->v2->co, vlr1->v3->co, vlr1->n); + normal_tri_v3( vlr1->n,vlr1->v1->co, vlr1->v2->co, vlr1->v3->co); else - CalcNormFloat(vlr1->v3->co, vlr1->v2->co, vlr1->v1->co, vlr1->n); + normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co); } } @@ -2469,7 +2469,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, if(orco) { v1->orco= orco; orco+= 3; orcoret++; } - Mat4MulVecfl(mat, v1->co); + mul_m4_v3(mat, v1->co); for (v = 1; v < sizev; v++) { ver= RE_findOrAddVert(obr, obr->totvert++); @@ -2477,7 +2477,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, if(orco) { ver->orco= orco; orco+= 3; orcoret++; } - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); } /* if V-cyclic, add extra vertices at end of the row */ if (dl->flag & DL_CYCL_U) { @@ -2525,7 +2525,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->v1= v1; vlr->v2= v2; vlr->v3= v3; vlr->v4= v4; - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, n1); + normal_quad_v3( n1,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); VECCOPY(vlr->n, n1); @@ -2536,10 +2536,10 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, vlr->flag |= R_NOPUNOFLIP; } - VecAddf(v1->n, v1->n, n1); - VecAddf(v2->n, v2->n, n1); - VecAddf(v3->n, v3->n, n1); - VecAddf(v4->n, v4->n, n1); + add_v3_v3v3(v1->n, v1->n, n1); + add_v3_v3v3(v2->n, v2->n, n1); + add_v3_v3v3(v3->n, v3->n, n1); + add_v3_v3v3(v4->n, v4->n, n1); p1++; p2++; p3++; p4++; } @@ -2553,10 +2553,10 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, /* optimize! :*/ vlr= RE_findOrAddVlak(obr, UVTOINDEX(sizeu - 1, v)); vlr1= RE_findOrAddVlak(obr, UVTOINDEX(0, v)); - VecAddf(vlr1->v1->n, vlr1->v1->n, vlr->n); - VecAddf(vlr1->v2->n, vlr1->v2->n, vlr->n); - VecAddf(vlr->v3->n, vlr->v3->n, vlr1->n); - VecAddf(vlr->v4->n, vlr->v4->n, vlr1->n); + add_v3_v3v3(vlr1->v1->n, vlr1->v1->n, vlr->n); + add_v3_v3v3(vlr1->v2->n, vlr1->v2->n, vlr->n); + add_v3_v3v3(vlr->v3->n, vlr->v3->n, vlr1->n); + add_v3_v3v3(vlr->v4->n, vlr->v4->n, vlr1->n); } } if (dl->flag & DL_CYCL_U) { @@ -2566,10 +2566,10 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, /* optimize! :*/ vlr= RE_findOrAddVlak(obr, UVTOINDEX(u, 0)); vlr1= RE_findOrAddVlak(obr, UVTOINDEX(u, sizev-1)); - VecAddf(vlr1->v2->n, vlr1->v2->n, vlr->n); - VecAddf(vlr1->v3->n, vlr1->v3->n, vlr->n); - VecAddf(vlr->v1->n, vlr->v1->n, vlr1->n); - VecAddf(vlr->v4->n, vlr->v4->n, vlr1->n); + add_v3_v3v3(vlr1->v2->n, vlr1->v2->n, vlr->n); + add_v3_v3v3(vlr1->v3->n, vlr1->v3->n, vlr->n); + add_v3_v3v3(vlr->v1->n, vlr->v1->n, vlr1->n); + add_v3_v3v3(vlr->v4->n, vlr->v4->n, vlr1->n); } } /* last vertex is an extra case: @@ -2593,11 +2593,11 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, { vlr= RE_findOrAddVlak(obr, UVTOINDEX(sizeu - 1, sizev - 1)); /* (m,n) */ vlr1= RE_findOrAddVlak(obr, UVTOINDEX(0,0)); /* (0,0) */ - VecAddf(n1, vlr->n, vlr1->n); + add_v3_v3v3(n1, vlr->n, vlr1->n); vlr2= RE_findOrAddVlak(obr, UVTOINDEX(0, sizev-1)); /* (0,n) */ - VecAddf(n1, n1, vlr2->n); + add_v3_v3v3(n1, n1, vlr2->n); vlr3= RE_findOrAddVlak(obr, UVTOINDEX(sizeu-1, 0)); /* (m,0) */ - VecAddf(n1, n1, vlr3->n); + add_v3_v3v3(n1, n1, vlr3->n); VECCOPY(vlr->v3->n, n1); VECCOPY(vlr1->v1->n, n1); VECCOPY(vlr2->v2->n, n1); @@ -2605,7 +2605,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, } for(a = startvert; a < obr->totvert; a++) { ver= RE_findOrAddVert(obr, a); - Normalize(ver->n); + normalize_v3(ver->n); } @@ -2627,8 +2627,8 @@ static void init_render_surf(Render *re, ObjectRen *obr) nu= cu->nurb.first; if(nu==0) return; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); /* material array */ totmat= ob->totcol+1; @@ -2688,8 +2688,8 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) dl= cu->disp.first; if(cu->disp.first==NULL) return; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); /* material array */ totmat= ob->totcol+1; @@ -2715,7 +2715,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) n[0]= ob->imat[0][2]; n[1]= ob->imat[1][2]; n[2]= ob->imat[2][2]; - Normalize(n); + normalize_v3(n); for(a=0; anr; a++, data+=3) { ver= RE_findOrAddVert(obr, obr->totvert++); @@ -2731,7 +2731,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) ver->flag = 0; } - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); if (orco) { ver->orco = orco; @@ -2783,7 +2783,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, fp); - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); fp+= 3; if (orco) { @@ -2824,9 +2824,9 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) */ if(frontside) - CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v2->co, vlr->v3->co, vlr->v4->co); else - CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n); + normal_tri_v3( vlr->n,vlr->v1->co, vlr->v2->co, vlr->v3->co); vlr->mat= matar[ dl->col ]; @@ -2847,14 +2847,14 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) for(a= startvlak; atotvlak; a++) { vlr= RE_findOrAddVlak(obr, a); - VecAddf(vlr->v1->n, vlr->v1->n, vlr->n); - VecAddf(vlr->v3->n, vlr->v3->n, vlr->n); - VecAddf(vlr->v2->n, vlr->v2->n, vlr->n); - VecAddf(vlr->v4->n, vlr->v4->n, vlr->n); + add_v3_v3v3(vlr->v1->n, vlr->v1->n, vlr->n); + add_v3_v3v3(vlr->v3->n, vlr->v3->n, vlr->n); + add_v3_v3v3(vlr->v2->n, vlr->v2->n, vlr->n); + add_v3_v3v3(vlr->v4->n, vlr->v4->n, vlr->n); } for(a=startvert; atotvert; a++) { ver= RE_findOrAddVert(obr, a); - len= Normalize(ver->n); + len= normalize_v3(ver->n); if(len==0.0) ver->flag= 1; /* flag abuse, its only used in zbuf now */ else ver->flag= 0; } @@ -3080,9 +3080,9 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) me= ob->data; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); - Mat3CpyMat4(imat, ob->imat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); + copy_m3_m4(imat, ob->imat); if(me->totvert==0) return; @@ -3163,7 +3163,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, mvert->co); if(do_autosmooth==0) /* autosmooth on original unrotated data to prevent differences between frames */ - Mat4MulVecfl(mat, ver->co); + mul_m4_v3(mat, ver->co); if(orco) { ver->orco= orco; @@ -3236,15 +3236,15 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) MVert *mv= me->mvert; if(vlr->v4) - len= CalcNormFloat4( mv[mf->v4].co, mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co, vlr->n); + len= normal_quad_v3( vlr->n, mv[mf->v4].co, mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co); else - len= CalcNormFloat(mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co, vlr->n); + len= normal_tri_v3( vlr->n,mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co); } else { if(vlr->v4) - len= CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + len= normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); else - len= CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + len= normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); } vlr->mat= ma; @@ -3318,7 +3318,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) vlr->n[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; vlr->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; vlr->n[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - Normalize(vlr->n); + normalize_v3(vlr->n); vlr->mat= ma; vlr->flag= 0; @@ -3384,13 +3384,13 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4]) shb->soft= lar->soft; shb->shadhalostep= lar->shadhalostep; - Mat4Ortho(mat); - Mat4Invert(shb->winmat, mat); /* winmat is temp */ + normalize_m4(mat); + invert_m4_m4(shb->winmat, mat); /* winmat is temp */ /* matrix: combination of inverse view and lampmat */ /* calculate again: the ortho-render has no correct viewinv */ - Mat4Invert(viewinv, re->viewmat); - Mat4MulMat4(shb->viewmat, viewinv, shb->winmat); + invert_m4_m4(viewinv, re->viewmat); + mul_m4_m4m4(shb->viewmat, viewinv, shb->winmat); /* projection */ shb->d= lar->clipsta; @@ -3469,11 +3469,11 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) BLI_addtail(&re->lampren, lar); go->lampren= lar; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); - Mat3CpyMat4(lar->mat, mat); - Mat3CpyMat4(lar->imat, ob->imat); + copy_m3_m4(lar->mat, mat); + copy_m3_m4(lar->imat, ob->imat); lar->bufsize = la->bufsize; lar->samp = la->samp; @@ -3498,7 +3498,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->vec[0]= -mat[2][0]; lar->vec[1]= -mat[2][1]; lar->vec[2]= -mat[2][2]; - Normalize(lar->vec); + normalize_v3(lar->vec); lar->co[0]= mat[3][0]; lar->co[1]= mat[3][1]; lar->co[2]= mat[3][2]; @@ -3577,7 +3577,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->sunsky->effect_type = la->sun_effect_type; VECCOPY(vec,ob->obmat[2]); - Normalize(vec); + normalize_v3(vec); InitSunSky(lar->sunsky, la->atm_turbidity, vec, la->horizon_brightness, la->spread, la->sun_brightness, la->sun_size, la->backscattered_light, @@ -3607,9 +3607,9 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) if(lar->type==LA_SPOT) { - Normalize(lar->imat[0]); - Normalize(lar->imat[1]); - Normalize(lar->imat[2]); + normalize_v3(lar->imat[0]); + normalize_v3(lar->imat[1]); + normalize_v3(lar->imat[2]); xn= saacos(lar->spotsi); xn= sin(xn)/cos(xn); @@ -3630,7 +3630,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->sh_invcampos[0]= -lar->co[0]; lar->sh_invcampos[1]= -lar->co[1]; lar->sh_invcampos[2]= -lar->co[2]; - Mat3MulVecfl(lar->imat, lar->sh_invcampos); + mul_m3_v3(lar->imat, lar->sh_invcampos); /* z factor, for a normalized volume */ angle= saacos(lar->spotsi); @@ -3677,7 +3677,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) else if (la->type==LA_SPOT && (lar->mode & LA_SHAD_BUF) ) { /* Per lamp, one shadow buffer is made. */ lar->bufflag= la->bufflag; - Mat4CpyMat4(mat, ob->obmat); + copy_m4_m4(mat, ob->obmat); initshadowbuf(re, lar, mat); // mat is altered } @@ -3792,8 +3792,8 @@ void init_render_world(Render *re) cp[3]= 1; VECCOPY(re->grvec, re->viewmat[2]); - Normalize(re->grvec); - Mat3CpyMat4(re->imat, re->viewinv); + normalize_v3(re->grvec); + copy_m3_m4(re->imat, re->viewinv); for(a=0; awrld.mtex[a] && re->wrld.mtex[a]->tex) re->wrld.skytype |= WO_SKYTEX; @@ -3946,8 +3946,8 @@ static void split_quads(ObjectRen *obr, int dir) vlr->v4 = vlr1->v4 = NULL; /* new normals */ - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); - CalcNormFloat(vlr1->v3->co, vlr1->v2->co, vlr1->v1->co, vlr1->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); + normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co); } /* clear the flag when not divided */ else vlr->flag &= ~R_DIVIDE_24; @@ -4011,8 +4011,8 @@ static void check_non_flat_quads(ObjectRen *obr) /* 1---2 1---2 0 = orig face, 1 = new face */ /* render normals are inverted in render! we calculate normal of single tria here */ - flen= CalcNormFloat(vlr->v4->co, vlr->v3->co, vlr->v1->co, nor); - if(flen==0.0) CalcNormFloat(vlr->v4->co, vlr->v2->co, vlr->v1->co, nor); + flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co); + if(flen==0.0) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co); xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2]; @@ -4024,10 +4024,10 @@ static void check_non_flat_quads(ObjectRen *obr) vlr1->flag |= R_FACE_SPLIT; /* split direction based on vnorms */ - CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, nor); + normal_tri_v3( nor,vlr->v1->co, vlr->v2->co, vlr->v3->co); d1= nor[0]*vlr->v1->n[0] + nor[1]*vlr->v1->n[1] + nor[2]*vlr->v1->n[2]; - CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, nor); + normal_tri_v3( nor,vlr->v2->co, vlr->v3->co, vlr->v4->co); d2= nor[0]*vlr->v2->n[0] + nor[1]*vlr->v2->n[1] + nor[2]*vlr->v2->n[2]; if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24; @@ -4053,8 +4053,8 @@ static void check_non_flat_quads(ObjectRen *obr) vlr->v4 = vlr1->v4 = NULL; /* new normals */ - CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); - CalcNormFloat(vlr1->v3->co, vlr1->v2->co, vlr1->v1->co, vlr1->n); + normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); + normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co); } /* clear the flag when not divided */ else vlr->flag &= ~R_DIVIDE_24; @@ -4143,8 +4143,8 @@ static void find_dupli_instances(Render *re, ObjectRen *obr) float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3]; int first = 1; - Mat4MulMat4(obmat, obr->obmat, re->viewmat); - Mat4Invert(imat, obmat); + mul_m4_m4m4(obmat, obr->obmat, re->viewmat); + invert_m4_m4(imat, obmat); /* for objects instanced by dupliverts/faces/particles, we go over the * list of instances to find ones that instance obr, and setup their @@ -4155,12 +4155,12 @@ static void find_dupli_instances(Render *re, ObjectRen *obr) /* compute difference between object matrix and * object matrix with dupli transform, in viewspace */ - Mat4CpyMat4(obimat, obi->mat); - Mat4MulMat4(obi->mat, imat, obimat); + copy_m4_m4(obimat, obi->mat); + mul_m4_m4m4(obi->mat, imat, obimat); - Mat3CpyMat4(nmat, obi->mat); - Mat3Inv(obi->nmat, nmat); - Mat3Transp(obi->nmat); + copy_m3_m4(nmat, obi->mat); + invert_m3_m3(obi->nmat, nmat); + transpose_m3(obi->nmat); if(!first) { re->totvert += obr->totvert; @@ -4178,19 +4178,19 @@ static void assign_dupligroup_dupli(Render *re, ObjectInstanceRen *obi, ObjectRe { float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3]; - Mat4MulMat4(obmat, obr->obmat, re->viewmat); - Mat4Invert(imat, obmat); + mul_m4_m4m4(obmat, obr->obmat, re->viewmat); + invert_m4_m4(imat, obmat); obi->obr= obr; /* compute difference between object matrix and * object matrix with dupli transform, in viewspace */ - Mat4CpyMat4(obimat, obi->mat); - Mat4MulMat4(obi->mat, imat, obimat); + copy_m4_m4(obimat, obi->mat); + mul_m4_m4m4(obi->mat, imat, obimat); - Mat3CpyMat4(nmat, obi->mat); - Mat3Inv(obi->nmat, nmat); - Mat3Transp(obi->nmat); + copy_m3_m4(nmat, obi->mat); + invert_m3_m3(obi->nmat, nmat); + transpose_m3(obi->nmat); re->totvert += obr->totvert; re->totvlak += obr->totvlak; @@ -4253,8 +4253,8 @@ static void set_dupli_tex_mat(Render *re, ObjectInstanceRen *obi, DupliObject *d float imat[4][4]; obi->duplitexmat= BLI_memarena_alloc(re->memArena, sizeof(float)*4*4); - Mat4Invert(imat, dob->mat); - Mat4MulSerie(obi->duplitexmat, re->viewmat, dob->omat, imat, re->viewinv, 0, 0, 0, 0); + invert_m4_m4(imat, dob->mat); + mul_serie_m4(obi->duplitexmat, re->viewmat, dob->omat, imat, re->viewinv, 0, 0, 0, 0); } } @@ -4325,7 +4325,7 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject * obr= RE_addRenderObject(re, ob, par, index, 0, ob->lay); if((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) { obr->flag |= R_INSTANCEABLE; - Mat4CpyMat4(obr->obmat, ob->obmat); + copy_m4_m4(obr->obmat, ob->obmat); } if(obr->lay & vectorlay) obr->flag |= R_NEED_VECTORS; @@ -4353,7 +4353,7 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject * obr= RE_addRenderObject(re, ob, par, index, psysindex, ob->lay); if((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) { obr->flag |= R_INSTANCEABLE; - Mat4CpyMat4(obr->obmat, ob->obmat); + copy_m4_m4(obr->obmat, ob->obmat); } if(obr->lay & vectorlay) obr->flag |= R_NEED_VECTORS; @@ -4384,8 +4384,8 @@ static void init_render_object(Render *re, Object *ob, Object *par, DupliObject else if(render_object_type(ob->type)) add_render_object(re, ob, par, dob, timeoffset, vectorlay); else { - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); } time= PIL_check_seconds_timer(); @@ -4635,8 +4635,8 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp for(SETLOOPER(re->scene, base)) { ob= base->object; /* imat objects has to be done here, since displace can have texture using Object map-input */ - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); /* each object should only be rendered once */ ob->flag &= ~OB_DONE; ob->transflag &= ~OB_RENDER_DUPLI; @@ -4681,7 +4681,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp for(dob= lb->first; dob; dob= dob->next) { Object *obd= dob->ob; - Mat4CpyMat4(obd->obmat, dob->mat); + copy_m4_m4(obd->obmat, dob->mat); /* group duplis need to set ob matrices correct, for deform. so no_draw is part handled */ if(!(obd->transflag & OB_RENDER_DUPLI) && dob->no_draw) @@ -4706,7 +4706,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp * this is a duplivert/face/particle, or it is a non-animated object in * a dupligroup that has already been created before */ if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) { - Mat4MulMat4(mat, dob->mat, re->viewmat); + mul_m4_m4m4(mat, dob->mat, re->viewmat); obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat, obd->lay); /* fill in instance variables for texturing */ @@ -4782,8 +4782,8 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp if(redoimat) { for(SETLOOPER(re->scene, base)) { ob= base->object; - Mat4MulMat4(mat, ob->obmat, re->viewmat); - Mat4Invert(ob->imat, mat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); + invert_m4_m4(ob->imat, mat); } } @@ -4827,8 +4827,8 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view) /* if no camera, viewmat should have been set! */ if(use_camera_view && re->scene->camera) { - Mat4Ortho(re->scene->camera->obmat); - Mat4Invert(mat, re->scene->camera->obmat); + normalize_m4(re->scene->camera->obmat); + invert_m4_m4(mat, re->scene->camera->obmat); RE_SetView(re, mat); re->scene->camera->recalc= OB_RECALC_OB; /* force correct matrix for scaled cameras */ } @@ -4948,7 +4948,7 @@ void RE_DataBase_ApplyWindow(Render *re) void RE_DataBase_GetView(Render *re, float mat[][4]) { - Mat4CpyMat4(mat, re->viewmat); + copy_m4_m4(mat, re->viewmat); } /* ------------------------------------------------------------------------- */ @@ -4982,8 +4982,8 @@ static void database_fromscene_vectors(Render *re, Scene *scene, int timeoffset) /* if no camera, viewmat should have been set! */ if(re->scene->camera) { - Mat4Ortho(re->scene->camera->obmat); - Mat4Invert(mat, re->scene->camera->obmat); + normalize_m4(re->scene->camera->obmat); + invert_m4_m4(mat, re->scene->camera->obmat); RE_SetView(re, mat); } @@ -5091,9 +5091,9 @@ static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen if(mesh->co && mesh->prevco && mesh->nextco) { if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, re->winmat); + mul_m4_m4m4(winmat, obi->mat, re->winmat); else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); winspeed= MEM_callocN(sizeof(float)*4*mesh->totvert, "StrandSurfWin"); @@ -5128,9 +5128,9 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve int a, *face, *index; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, re->winmat); + mul_m4_m4m4(winmat, obi->mat, re->winmat); else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); if(obr->vertnodes) { for(a=0; atotvert; a++, vectors+=2) { @@ -5168,7 +5168,7 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve co3= mesh->co[face[2]]; co4= (face[3])? mesh->co[face[3]]: NULL; - InterpWeightsQ3Dfl(co1, co2, co3, co4, strand->vert->co, w); + interp_weights_face_v3( w,co1, co2, co3, co4, strand->vert->co); speed[0]= speed[1]= speed[2]= speed[3]= 0.0f; QUATADDFAC(speed, speed, winspeed[face[0]], w[0]); @@ -5208,8 +5208,8 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * else return 0; - Mat4CpyMat4(mat, re->viewmat); - Mat4Invert(imat, mat); + copy_m4_m4(mat, re->viewmat); + invert_m4_m4(imat, mat); /* set first vertex OK */ if(!fss->meshSurfNormals) return 0; @@ -5222,9 +5222,9 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * velarray = (float *)fss->meshSurfNormals; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, re->winmat); + mul_m4_m4m4(winmat, obi->mat, re->winmat); else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); /* (bad) HACK calculate average velocity */ /* better solution would be fixing getVelocityAt() in intern/elbeem/intern/solver_util.cpp @@ -5312,9 +5312,9 @@ static void copy_dbase_object_vectors(Render *re, ListBase *lb) vec= obilb->vectors= MEM_mallocN(2*sizeof(float)*totvector, "vector array"); if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, re->winmat); + mul_m4_m4m4(winmat, obi->mat, re->winmat); else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); for(a=0; atotvert; a++, vec+=2) { if((a & 255)==0) ver= obr->vertnodes[a>>8].vert; @@ -5513,12 +5513,12 @@ void RE_Database_Baking(Render *re, Scene *scene, int type, Object *actob) /* if no camera, set unit */ if(re->scene->camera) { - Mat4Ortho(re->scene->camera->obmat); - Mat4Invert(mat, re->scene->camera->obmat); + normalize_m4(re->scene->camera->obmat); + invert_m4_m4(mat, re->scene->camera->obmat); RE_SetView(re, mat); } else { - Mat4One(mat); + unit_m4(mat); RE_SetView(re, mat); } @@ -5601,8 +5601,8 @@ void RE_make_sticky(Scene *scene, View3D *v3d) RE_SetCamera(re, scene->camera); /* and set view matrix */ - Mat4Ortho(scene->camera->obmat); - Mat4Invert(mat, scene->camera->obmat); + normalize_m4(scene->camera->obmat); + invert_m4_m4(mat, scene->camera->obmat); RE_SetView(re, mat); for(base= FIRSTBASE; base; base= base->next) { @@ -5618,12 +5618,12 @@ void RE_make_sticky(Scene *scene, View3D *v3d) CD_CALLOC, NULL, me->totvert); where_is_object(scene, ob); - Mat4MulMat4(mat, ob->obmat, re->viewmat); + mul_m4_m4m4(mat, ob->obmat, re->viewmat); ms= me->msticky; for(a=0; atotvert; a++, ms++, mvert++) { VECCOPY(ho, mvert->co); - Mat4MulVecfl(mat, ho); + mul_m4_v3(mat, ho); projectverto(ho, re->winmat, ho); ms->co[0]= ho[0]/ho[3]; ms->co[1]= ho[1]/ho[3]; diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index b5774d11799..323eb6a9500 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -31,7 +31,7 @@ /* external modules: */ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" @@ -211,9 +211,9 @@ static void envmap_transmatrix(float mat[][4], int part) eul[2]= -M_PI/2.0; } - Mat4CpyMat4(tmat, mat); - EulToMat4(eul, rotmat); - Mat4MulSerie(mat, tmat, rotmat, + copy_m4_m4(tmat, mat); + eul_to_mat4( rotmat,eul); + mul_serie_m4(mat, tmat, rotmat, 0, 0, 0, 0, 0, 0); } @@ -231,28 +231,28 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) int a; if(mode==0) { - Mat4Invert(tmat, mat); - Mat3CpyMat4(imat, tmat); + invert_m4_m4(tmat, mat); + copy_m3_m4(imat, tmat); } else { - Mat4CpyMat4(tmat, mat); - Mat3CpyMat4(imat, mat); + copy_m4_m4(tmat, mat); + copy_m3_m4(imat, mat); } for(obi=re->instancetable.first; obi; obi=obi->next) { /* append or set matrix depending on dupli */ if(obi->flag & R_DUPLI_TRANSFORMED) { - Mat4CpyMat4(tmpmat, obi->mat); - Mat4MulMat4(obi->mat, tmpmat, tmat); + copy_m4_m4(tmpmat, obi->mat); + mul_m4_m4m4(obi->mat, tmpmat, tmat); } else if(mode==1) - Mat4CpyMat4(obi->mat, tmat); + copy_m4_m4(obi->mat, tmat); else - Mat4One(obi->mat); + unit_m4(obi->mat); - Mat3CpyMat4(cmat, obi->mat); - Mat3Inv(obi->nmat, cmat); - Mat3Transp(obi->nmat); + copy_m3_m4(cmat, obi->mat); + invert_m3_m3(obi->nmat, cmat); + transpose_m3(obi->nmat); /* indicate the renderer has to use transform matrices */ if(mode==0) @@ -267,7 +267,7 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) if((a & 255)==0) har= obr->bloha[a>>8]; else har++; - Mat4MulVecfl(tmat, har->co); + mul_m4_v3(tmat, har->co); } } @@ -277,25 +277,25 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) /* removed here some horrible code of someone in NaN who tried to fix prototypes... just solved by introducing a correct cmat[3][3] instead of using smat. this works, check square spots in reflections (ton) */ - Mat3CpyMat3(cmat, lar->imat); - Mat3MulMat3(lar->imat, cmat, imat); + copy_m3_m3(cmat, lar->imat); + mul_m3_m3m3(lar->imat, cmat, imat); - Mat3MulVecfl(imat, lar->vec); - Mat4MulVecfl(tmat, lar->co); + mul_m3_v3(imat, lar->vec); + mul_m4_v3(tmat, lar->co); lar->sh_invcampos[0]= -lar->co[0]; lar->sh_invcampos[1]= -lar->co[1]; lar->sh_invcampos[2]= -lar->co[2]; - Mat3MulVecfl(lar->imat, lar->sh_invcampos); + mul_m3_v3(lar->imat, lar->sh_invcampos); lar->sh_invcampos[2]*= lar->sh_zfac; if(lar->shb) { if(mode==1) { - Mat4Invert(pmat, mat); - Mat4MulMat4(smat, pmat, lar->shb->viewmat); - Mat4MulMat4(lar->shb->persmat, smat, lar->shb->winmat); + invert_m4_m4(pmat, mat); + mul_m4_m4m4(smat, pmat, lar->shb->viewmat); + mul_m4_m4m4(lar->shb->persmat, smat, lar->shb->winmat); } - else Mat4MulMat4(lar->shb->persmat, lar->shb->viewmat, lar->shb->winmat); + else mul_m4_m4m4(lar->shb->persmat, lar->shb->viewmat, lar->shb->winmat); } } @@ -373,8 +373,8 @@ static void env_set_imats(Render *re) base= re->scene->base.first; while(base) { - Mat4MulMat4(mat, base->object->obmat, re->viewmat); - Mat4Invert(base->object->imat, mat); + mul_m4_m4m4(mat, base->object->obmat, re->viewmat); + invert_m4_m4(base->object->imat, mat); base= base->next; } @@ -393,18 +393,18 @@ static void render_envmap(Render *re, EnvMap *env) short part; /* need a recalc: ortho-render has no correct viewinv */ - Mat4Invert(oldviewinv, re->viewmat); + invert_m4_m4(oldviewinv, re->viewmat); envre= envmap_render_copy(re, env); /* precalc orthmat for object */ - Mat4CpyMat4(orthmat, env->object->obmat); - Mat4Ortho(orthmat); + copy_m4_m4(orthmat, env->object->obmat); + normalize_m4(orthmat); /* need imat later for texture imat */ - Mat4MulMat4(mat, orthmat, re->viewmat); - Mat4Invert(tmat, mat); - Mat3CpyMat4(env->obimat, tmat); + mul_m4_m4m4(mat, orthmat, re->viewmat); + invert_m4_m4(tmat, mat); + copy_m3_m4(env->obimat, tmat); for(part=0; part<6; part++) { if(env->type==ENV_PLANE && part!=1) @@ -412,17 +412,17 @@ static void render_envmap(Render *re, EnvMap *env) re->display_clear(re->dch, envre->result); - Mat4CpyMat4(tmat, orthmat); + copy_m4_m4(tmat, orthmat); envmap_transmatrix(tmat, part); - Mat4Invert(mat, tmat); + invert_m4_m4(mat, tmat); /* mat now is the camera 'viewmat' */ - Mat4CpyMat4(envre->viewmat, mat); - Mat4CpyMat4(envre->viewinv, tmat); + copy_m4_m4(envre->viewmat, mat); + copy_m4_m4(envre->viewinv, tmat); /* we have to correct for the already rotated vertexcoords */ - Mat4MulMat4(tmat, oldviewinv, envre->viewmat); - Mat4Invert(env->imat, tmat); + mul_m4_m4m4(tmat, oldviewinv, envre->viewmat); + invert_m4_m4(env->imat, tmat); env_rotate_scene(envre, tmat, 1); init_render_world(envre); @@ -503,13 +503,13 @@ void make_envmaps(Render *re) float orthmat[4][4], mat[4][4], tmat[4][4]; /* precalc orthmat for object */ - Mat4CpyMat4(orthmat, env->object->obmat); - Mat4Ortho(orthmat); + copy_m4_m4(orthmat, env->object->obmat); + normalize_m4(orthmat); /* need imat later for texture imat */ - Mat4MulMat4(mat, orthmat, re->viewmat); - Mat4Invert(tmat, mat); - Mat3CpyMat4(env->obimat, tmat); + mul_m4_m4m4(mat, orthmat, re->viewmat); + invert_m4_m4(tmat, mat); + copy_m3_m4(env->obimat, tmat); } else { @@ -678,20 +678,20 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe /* rotate to envmap space, if object is set */ VECCOPY(vec, texvec); - if(env->object) Mat3MulVecfl(env->obimat, vec); - else Mat4Mul3Vecfl(R.viewinv, vec); + if(env->object) mul_m3_v3(env->obimat, vec); + else mul_mat3_m4_v3(R.viewinv, vec); face= envcube_isect(env, vec, sco); ibuf= env->cube[face]; if(osatex) { if(env->object) { - Mat3MulVecfl(env->obimat, dxt); - Mat3MulVecfl(env->obimat, dyt); + mul_m3_v3(env->obimat, dxt); + mul_m3_v3(env->obimat, dyt); } else { - Mat4Mul3Vecfl(R.viewinv, dxt); - Mat4Mul3Vecfl(R.viewinv, dyt); + mul_mat3_m4_v3(R.viewinv, dxt); + mul_mat3_m4_v3(R.viewinv, dyt); } set_dxtdyt(dxts, dyts, dxt, dyt, face); imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, texres); @@ -703,9 +703,9 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe texr1.nor= texr2.nor= NULL; - VecAddf(vec, vec, dxt); + add_v3_v3v3(vec, vec, dxt); face1= envcube_isect(env, vec, sco); - VecSubf(vec, vec, dxt); + sub_v3_v3v3(vec, vec, dxt); if(face!=face1) { ibuf= env->cube[face1]; @@ -716,9 +716,9 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe /* here was the nasty bug! results were not zero-ed. FPE! */ - VecAddf(vec, vec, dyt); + add_v3_v3v3(vec, vec, dyt); face1= envcube_isect(env, vec, sco); - VecSubf(vec, vec, dyt); + sub_v3_v3v3(vec, vec, dyt); if(face!=face1) { ibuf= env->cube[face1]; diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 01131f09b96..3d46fdfaaee 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -48,7 +48,7 @@ #include "DNA_scene_types.h" #include "DNA_texture_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index d388e81a745..abff8bf2655 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -37,7 +37,7 @@ #include "PIL_time.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" @@ -562,7 +562,7 @@ void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, flo { re->r.cfra= frame; RE_SetCamera(re, camera); - Mat4CpyMat4(mat, re->winmat); + copy_m4_m4(mat, re->winmat); } /* ~~~~~~~~~~~~~~~~ part (tile) calculus ~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index a15377a8c6d..f62668b84c0 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -36,7 +36,7 @@ #include "DNA_material_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_memarena.h" #include "BLI_threads.h" @@ -165,7 +165,7 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, /* set up view vector */ VECCOPY(shi->view, shi->co); - Normalize(shi->view); + normalize_v3(shi->view); /* cache for shadow */ shi->samplenr++; @@ -181,8 +181,8 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, /* not a pretty solution, but fixes common cases */ if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { - VecNegf(shi->vn); - VecNegf(shi->vno); + negate_v3(shi->vn); + negate_v3(shi->vno); } /* init material vars */ @@ -311,12 +311,12 @@ static void occ_face(const OccFace *face, float *co, float *normal, float *area) if(co) { if(vlr->v4) - VecLerpf(co, vlr->v1->co, vlr->v3->co, 0.5f); + interp_v3_v3v3(co, vlr->v1->co, vlr->v3->co, 0.5f); else - CalcCent3f(co, vlr->v1->co, vlr->v2->co, vlr->v3->co); + cent_tri_v3(co, vlr->v1->co, vlr->v2->co, vlr->v3->co); if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, co); + mul_m4_v3(obi->mat, co); } if(normal) { @@ -325,7 +325,7 @@ static void occ_face(const OccFace *face, float *co, float *normal, float *area) normal[2]= -vlr->n[2]; if(obi->flag & R_TRANSFORMED) - Mat3MulVecfl(obi->nmat, normal); + mul_m3_v3(obi->nmat, normal); } if(area) { @@ -335,17 +335,17 @@ static void occ_face(const OccFace *face, float *co, float *normal, float *area) if(vlr->v4) VECCOPY(v4, vlr->v4->co); if(obi->flag & R_TRANSFORMED) { - Mat4MulVecfl(obi->mat, v1); - Mat4MulVecfl(obi->mat, v2); - Mat4MulVecfl(obi->mat, v3); - if(vlr->v4) Mat4MulVecfl(obi->mat, v4); + mul_m4_v3(obi->mat, v1); + mul_m4_v3(obi->mat, v2); + mul_m4_v3(obi->mat, v3); + if(vlr->v4) mul_m4_v3(obi->mat, v4); } /* todo: correct area for instances */ if(vlr->v4) - *area= AreaQ3Dfl(v1, v2, v3, v4); + *area= area_quad_v3(v1, v2, v3, v4); else - *area= AreaT3Dfl(v1, v2, v3); + *area= area_tri_v3(v1, v2, v3); } } @@ -591,7 +591,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i } if(node->area != 0.0f) - VecMulf(node->co, 1.0f/node->area); + mul_v3_fl(node->co, 1.0f/node->area); /* compute maximum distance from center */ node->dco= 0.0f; @@ -1116,10 +1116,10 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa normalizef(r2); normalizef(r3); - Crossf(g0, r1, r0); normalizef(g0); - Crossf(g1, r2, r1); normalizef(g1); - Crossf(g2, r3, r2); normalizef(g2); - Crossf(g3, r0, r3); normalizef(g3); + cross_v3_v3v3(g0, r1, r0); normalizef(g0); + cross_v3_v3v3(g1, r2, r1); normalizef(g1); + cross_v3_v3v3(g2, r3, r2); normalizef(g2); + cross_v3_v3v3(g3, r0, r3); normalizef(g3); a1= saacosf(INPR(r0, r1)); a2= saacosf(INPR(r1, r2)); @@ -1151,9 +1151,9 @@ static float occ_form_factor(OccFace *face, float *p, float *n) VECCOPY(v3, vlr->v3->co); if(obi->flag & R_TRANSFORMED) { - Mat4MulVecfl(obi->mat, v1); - Mat4MulVecfl(obi->mat, v2); - Mat4MulVecfl(obi->mat, v3); + mul_m4_v3(obi->mat, v1); + mul_m4_v3(obi->mat, v2); + mul_m4_v3(obi->mat, v3); } if(occ_visible_quad(p, n, v1, v2, v3, q0, q1, q2, q3)) @@ -1162,7 +1162,7 @@ static float occ_form_factor(OccFace *face, float *p, float *n) if(vlr->v4) { VECCOPY(v4, vlr->v4->co); if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, v4); + mul_m4_v3(obi->mat, v4); if(occ_visible_quad(p, n, v1, v3, v4, q0, q1, q2, q3)) contrib += occ_quad_form_factor(p, n, q0, q1, q2, q3); @@ -1269,7 +1269,7 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float } if(occ) *occ= resultocc; - if(bentn) Normalize(bentn); + if(bentn) normalize_v3(bentn); } static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) @@ -1282,7 +1282,7 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) for(pass=0; passtotface; i++) { occ_face(&tree->face[i], co, n, NULL); - VecNegf(n); + negate_v3(n); VECADDFAC(co, co, n, 1e-8f); occ_lookup(tree, 0, &tree->face[i], co, n, &occ[i], NULL); @@ -1315,7 +1315,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f aocolor= WO_AOPLAIN; VECCOPY(nn, n); - VecNegf(nn); + negate_v3(nn); occ_lookup(tree, thread, exclude, co, nn, &occ, (aocolor)? bn: NULL); @@ -1347,7 +1347,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f } #endif - VecMulf(skycol, occlusion); + mul_v3_fl(skycol, occlusion); } else { skycol[0]= occlusion; @@ -1477,7 +1477,7 @@ static void sample_occ_surface(ShadeInput *shi) co3= mesh->co[face[2]]; co4= (face[3])? mesh->co[face[3]]: NULL; - InterpWeightsQ3Dfl(co1, co2, co3, co4, strand->vert->co, w); + interp_weights_face_v3( w,co1, co2, co3, co4, strand->vert->co); shi->ao[0]= shi->ao[1]= shi->ao[2]= 0.0f; VECADDFAC(shi->ao, shi->ao, mesh->col[face[0]], w[0]); @@ -1512,14 +1512,14 @@ static void *exec_strandsurface_sample(void *data) if(face[3]) { co4= mesh->co[face[3]]; - VecLerpf(co, co1, co3, 0.5f); - CalcNormFloat4(co1, co2, co3, co4, n); + interp_v3_v3v3(co, co1, co3, 0.5f); + normal_quad_v3( n,co1, co2, co3, co4); } else { - CalcCent3f(co, co1, co2, co3); - CalcNormFloat(co1, co2, co3, n); + cent_tri_v3(co, co1, co2, co3); + normal_tri_v3( n,co1, co2, co3); } - VecNegf(n); + negate_v3(n); sample_occ_tree(re, re->occlusiontree, NULL, co, n, othread->thread, 0, col); VECCOPY(othread->facecol[a], col); @@ -1597,7 +1597,7 @@ void make_occ_tree(Render *re) for(a=0; atotvert; a++) if(count[a]) - VecMulf(mesh->col[a], 1.0f/count[a]); + mul_v3_fl(mesh->col[a], 1.0f/count[a]); MEM_freeN(count); MEM_freeN(facecol); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 86bbdb8534e..9c4c83a82f9 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -53,7 +53,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" @@ -1264,7 +1264,7 @@ void RE_SetWindow(Render *re, rctf *viewplane, float clipsta, float clipend) re->clipend= clipend; re->r.mode &= ~R_ORTHO; - i_window(re->viewplane.xmin, re->viewplane.xmax, re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend, re->winmat); + perspective_m4( re->winmat,re->viewplane.xmin, re->viewplane.xmax, re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend); } @@ -1277,14 +1277,14 @@ void RE_SetOrtho(Render *re, rctf *viewplane, float clipsta, float clipend) re->clipend= clipend; re->r.mode |= R_ORTHO; - i_ortho(re->viewplane.xmin, re->viewplane.xmax, re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend, re->winmat); + orthographic_m4( re->winmat,re->viewplane.xmin, re->viewplane.xmax, re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend); } void RE_SetView(Render *re, float mat[][4]) { /* re->ok flag? */ - Mat4CpyMat4(re->viewmat, mat); - Mat4Invert(re->viewinv, re->viewmat); + copy_m4_m4(re->viewmat, mat); + invert_m4_m4(re->viewinv, re->viewmat); } /* image and movie output has to move to either imbuf or kernel */ @@ -1511,7 +1511,7 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane) R.viewplane.xmin = viewplane->xmin + R.panodxv; R.viewplane.xmax = viewplane->xmax + R.panodxv; RE_SetWindow(re, &R.viewplane, R.clipsta, R.clipend); - Mat4CpyMat4(R.winmat, re->winmat); + copy_m4_m4(R.winmat, re->winmat); /* rotate database according to part coordinates */ project_renderdata(re, projectverto, 1, -R.panodxp*phi, 1); diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c index 0e453d461ab..da9a698291c 100644 --- a/source/blender/render/intern/source/pixelblending.c +++ b/source/blender/render/intern/source/pixelblending.c @@ -34,7 +34,7 @@ #include /* global includes */ -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" /* own includes */ diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index de3a50acddf..d4b7c403f50 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -27,7 +27,7 @@ #include #include #include -#include "BLI_arithb.h" +#include "BLI_math.h" /* External modules: */ #include "IMB_imbuf_types.h" @@ -155,7 +155,7 @@ static void render_lighting_halo(HaloRen *har, float *colf) /* rotate view to lampspace */ VECCOPY(lvrot, lv); - Mat3MulVecfl(lar->imat, lvrot); + mul_m3_v3(lar->imat, lvrot); x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2])); /* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */ @@ -553,7 +553,7 @@ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short th VECCOPY(lo, view); if(R.wrld.skytype & WO_SKYREAL) { - Mat3MulVecfl(R.imat, lo); + mul_m3_v3(R.imat, lo); SWAP(float, lo[1], lo[2]); @@ -594,11 +594,11 @@ void shadeSunView(float *colf, float *view) if(do_init) { VECCOPY(sview, view); - Normalize(sview); - Mat3MulVecfl(R.imat, sview); + normalize_v3(sview); + mul_m3_v3(R.imat, sview); if (sview[2] < 0.0) sview[2] = 0.0; - Normalize(sview); + normalize_v3(sview); do_init= 0; } @@ -654,7 +654,7 @@ void shadeSkyPixel(float *collector, float fx, float fy, short thread) } else { calc_view_vector(view, fx, fy); - fac= Normalize(view); + fac= normalize_v3(view); if(R.wrld.skytype & WO_SKYTEX) { dxyview[0]= -R.viewdx/fac; @@ -677,8 +677,8 @@ void shadeAtmPixel(struct SunSky *sunsky, float *collector, float fx, float fy, float view[3]; calc_view_vector(view, fx, fy); - Normalize(view); - /*Mat3MulVecfl(R.imat, view);*/ + normalize_v3(view); + /*mul_m3_v3(R.imat, view);*/ AtmospherePixleShader(sunsky, view, distance, collector); } diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 2b3e6047af4..e808d70da33 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -29,7 +29,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdopbvh.h" @@ -106,7 +106,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa /* init everything */ if (!psys || !ob || !pd) return; - Mat4MulMat4(obview, re->viewinv, ob->obmat); + mul_m4_m4m4(obview, re->viewinv, ob->obmat); /* Just to create a valid rendering context for particles */ psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, 0); @@ -119,7 +119,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa } /* in case ob->imat isn't up-to-date */ - Mat4Invert(ob->imat, ob->obmat); + invert_m4_m4(ob->imat, ob->obmat); total_particles = psys->totpart+psys->totchild; psys->lattice=psys_get_lattice(&sim); @@ -140,11 +140,11 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa VECCOPY(partco, state.co); if (pd->psys_cache_space == TEX_PD_OBJECTSPACE) - Mat4MulVecfl(ob->imat, partco); + mul_m4_v3(ob->imat, partco); else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) { float obloc[3]; VECCOPY(obloc, ob->loc); - VecSubf(partco, partco, obloc); + sub_v3_v3v3(partco, partco, obloc); } else { /* TEX_PD_WORLDSPACE */ } @@ -209,12 +209,12 @@ static void pointdensity_cache_object(Render *re, PointDensity *pd, Object *ob) case TEX_PD_OBJECTSPACE: break; case TEX_PD_OBJECTLOC: - Mat4MulVecfl(ob->obmat, co); - VecSubf(co, co, ob->loc); + mul_m4_v3(ob->obmat, co); + sub_v3_v3v3(co, co, ob->loc); break; case TEX_PD_WORLDSPACE: default: - Mat4MulVecfl(ob->obmat, co); + mul_m4_v3(ob->obmat, co); break; } @@ -391,7 +391,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) num = BLI_bvhtree_range_query(pd->point_tree, co, pd->radius, accum_density, &pdr); if (num > 0) { age /= num; - VecMulf(vec, 1.0f/num); + mul_v3_fl(vec, 1.0f/num); } /* reset */ @@ -424,7 +424,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) num = BLI_bvhtree_range_query(pd->point_tree, co, pd->radius, accum_density, &pdr); if (num > 0) { age /= num; - VecMulf(vec, 1.0f/num); + mul_v3_fl(vec, 1.0f/num); } texres->tin = density; @@ -448,7 +448,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) break; case TEX_PD_COLOR_PARTSPEED: { - float speed = VecLength(vec) * pd->speed_scale; + float speed = len_v3(vec) * pd->speed_scale; if (pd->coba) { if (do_colorband(pd->coba, speed, col)) { @@ -462,7 +462,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) } case TEX_PD_COLOR_PARTVEL: texres->talpha= 1; - VecMulf(vec, pd->speed_scale); + mul_v3_fl(vec, pd->speed_scale); VECCOPY(&texres->tr, vec); texres->ta = texres->tin; break; diff --git a/source/blender/render/intern/source/rayobject_blibvh.c b/source/blender/render/intern/source/rayobject_blibvh.c index 3fd71862f54..3579eb9007f 100644 --- a/source/blender/render/intern/source/rayobject_blibvh.c +++ b/source/blender/render/intern/source/rayobject_blibvh.c @@ -31,7 +31,7 @@ #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" #include "BLI_kdopbvh.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "RE_raytrace.h" #include "render_types.h" #include "rayobject.h" @@ -120,7 +120,7 @@ static int RE_rayobject_blibvh_intersect(RayObject *o, Isect *isec) data.leafs = obj->leafs; VECCOPY(dir, isec->vec); - Normalize(dir); + normalize_v3(dir); hit.index = 0; hit.dist = isec->labda*isec->dist; diff --git a/source/blender/render/intern/source/rayobject_instance.c b/source/blender/render/intern/source/rayobject_instance.c index e2f4dc5a9dd..9ed184e532c 100644 --- a/source/blender/render/intern/source/rayobject_instance.c +++ b/source/blender/render/intern/source/rayobject_instance.c @@ -30,7 +30,7 @@ #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "RE_raytrace.h" #include "rayobject.h" @@ -79,8 +79,8 @@ RayObject *RE_rayobject_instance_create(RayObject *target, float transform[][4], obj->ob = ob; obj->target_ob = target_ob; - Mat4CpyMat4(obj->target2global, transform); - Mat4Invert(obj->global2target, obj->target2global); + copy_m4_m4(obj->target2global, transform); + invert_m4_m4(obj->global2target, obj->target2global); return RE_rayobject_unalignRayAPI((RayObject*) obj); } @@ -111,10 +111,10 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) //Transform to target coordinates system VECADD( isec->vec, isec->vec, isec->start ); - Mat4MulVecfl(obj->global2target, isec->start); - Mat4MulVecfl(obj->global2target, isec->vec ); + mul_m4_v3(obj->global2target, isec->start); + mul_m4_v3(obj->global2target, isec->vec ); - isec->dist = VecLenf( isec->start, isec->vec ); + isec->dist = len_v3v3( isec->start, isec->vec ); VECSUB( isec->vec, isec->vec, isec->start ); isec->labda *= isec->dist / dist; @@ -194,7 +194,7 @@ static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max) for(i=0; i<8; i++) { for(j=0; j<3; j++) t[j] = i&(1<target2global, t); + mul_m4_v3(obj->target2global, t); DO_MINMAX(t, min, max); } } diff --git a/source/blender/render/intern/source/rayobject_octree.c b/source/blender/render/intern/source/rayobject_octree.c index 2f0a1a3f53b..7c29db6a4bb 100644 --- a/source/blender/render/intern/source/rayobject_octree.c +++ b/source/blender/render/intern/source/rayobject_octree.c @@ -40,7 +40,7 @@ #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "rayobject.h" @@ -226,7 +226,7 @@ static int face_in_node(RayFace *face, short x, short y, short z, float rtf[][3] // init static vars if(face) { - CalcNormFloat(rtf[0], rtf[1], rtf[2], nor); + normal_tri_v3( nor,rtf[0], rtf[1], rtf[2]); d= -nor[0]*rtf[0][0] - nor[1]*rtf[0][1] - nor[2]*rtf[0][2]; return 0; } diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 7043837166a..85442480a9c 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -41,7 +41,7 @@ #include "BKE_node.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_rand.h" @@ -397,11 +397,11 @@ static void makeraytree_single(Render *re) RE_rayface_from_vlak(face, obi, vlr); if((obi->flag & R_TRANSFORMED)) { - Mat4MulVecfl(obi->mat, face->v1); - Mat4MulVecfl(obi->mat, face->v2); - Mat4MulVecfl(obi->mat, face->v3); + mul_m4_v3(obi->mat, face->v1); + mul_m4_v3(obi->mat, face->v2); + mul_m4_v3(obi->mat, face->v3); if(RE_rayface_isQuad(face)) - Mat4MulVecfl(obi->mat, face->v4); + mul_m4_v3(obi->mat, face->v4); } RE_rayobject_add( raytree, RE_rayobject_unalignRayFace(face) ); @@ -481,7 +481,7 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) shi->co[1]= is->start[1]+is->labda*(shi->view[1]); shi->co[2]= is->start[2]+is->labda*(shi->view[2]); - Normalize(shi->view); + normalize_v3(shi->view); shi->obi= obi; shi->obr= obi->obr; @@ -674,7 +674,7 @@ static void ray_fadeout_endcolor(float *col, ShadeInput *origshi, ShadeInput *sh VECCOPY(col, shr->combined); } else if (origshi->mat->fadeto_mir == MA_RAYMIR_FADETOSKY) { VECCOPY(shi->view, vec); - Normalize(shi->view); + normalize_v3(shi->view); shadeSkyView(col, isec->start, shi->view, NULL, shi->thread); shadeSunView(col, shi->view); @@ -686,7 +686,7 @@ static void ray_fadeout(Isect *is, ShadeInput *shi, float *col, float *blendcol, /* if fading out, linear blend against fade color */ float blendfac; - blendfac = 1.0 - VecLenf(shi->co, is->start)/dist_mir; + blendfac = 1.0 - len_v3v3(shi->co, is->start)/dist_mir; col[0] = col[0]*blendfac + (1.0 - blendfac)*blendcol[0]; col[1] = col[1]*blendfac + (1.0 - blendfac)*blendcol[1]; @@ -1297,15 +1297,15 @@ static void trace_refract(float *col, ShadeInput *shi, ShadeResult *shr) /* get a quasi-random vector from a phong-weighted disc */ QMC_samplePhong(samp3d, qsa, shi->thread, samples, blur); - VecOrthoBasisf(v_refract, orthx, orthy); - VecMulf(orthx, samp3d[0]); - VecMulf(orthy, samp3d[1]); + ortho_basis_v3v3_v3( orthx, orthy,v_refract); + mul_v3_fl(orthx, samp3d[0]); + mul_v3_fl(orthy, samp3d[1]); /* and perturb the refraction vector in it */ - VecAddf(v_refract_new, v_refract, orthx); - VecAddf(v_refract_new, v_refract_new, orthy); + add_v3_v3v3(v_refract_new, v_refract, orthx); + add_v3_v3v3(v_refract_new, v_refract_new, orthy); - Normalize(v_refract_new); + normalize_v3(v_refract_new); } else { /* no blurriness, use the original normal */ VECCOPY(v_refract_new, v_refract); @@ -1384,20 +1384,20 @@ static void trace_reflect(float *col, ShadeInput *shi, ShadeResult *shr, float f /* find the normal's perpendicular plane, blurring along tangents * if tangent shading enabled */ if (shi->mat->mode & (MA_TANGENT_V)) { - Crossf(orthx, shi->vn, shi->tang); // bitangent + cross_v3_v3v3(orthx, shi->vn, shi->tang); // bitangent VECCOPY(orthy, shi->tang); - VecMulf(orthx, samp3d[0]); - VecMulf(orthy, samp3d[1]*aniso); + mul_v3_fl(orthx, samp3d[0]); + mul_v3_fl(orthy, samp3d[1]*aniso); } else { - VecOrthoBasisf(shi->vn, orthx, orthy); - VecMulf(orthx, samp3d[0]); - VecMulf(orthy, samp3d[1]); + ortho_basis_v3v3_v3( orthx, orthy,shi->vn); + mul_v3_fl(orthx, samp3d[0]); + mul_v3_fl(orthy, samp3d[1]); } /* and perturb the normal in it */ - VecAddf(v_nor_new, shi->vn, orthx); - VecAddf(v_nor_new, v_nor_new, orthy); - Normalize(v_nor_new); + add_v3_v3v3(v_nor_new, shi->vn, orthx); + add_v3_v3v3(v_nor_new, v_nor_new, orthy); + normalize_v3(v_nor_new); } else { /* no blurriness, use the original normal */ VECCOPY(v_nor_new, shi->vn); @@ -1706,7 +1706,7 @@ static void DS_energy(float *sphere, int tot, float *vec) res[0]= res[1]= res[2]= 0.0f; for(a=0, fp=sphere; afacenor); } - VecOrthoBasisf(nrm, up, side); + ortho_basis_v3v3_v3( up, side,nrm); /* sampling init */ if (R.wrld.ao_samp_method==WO_AOSAMP_HALTON) { @@ -1908,7 +1908,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *shadfac) dir[1] = (samp3d[0]*up[1] + samp3d[1]*side[1] + samp3d[2]*nrm[1]); dir[2] = (samp3d[0]*up[2] + samp3d[1]*side[2] + samp3d[2]*nrm[2]); - Normalize(dir); + normalize_v3(dir); isec.vec[0] = -dir[0]; isec.vec[1] = -dir[1]; @@ -1928,7 +1928,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *shadfac) view[0]= -dir[0]; view[1]= -dir[1]; view[2]= -dir[2]; - Normalize(view); + normalize_v3(view); if(aocolor==WO_AOSKYCOL) { skyfac= 0.5*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); @@ -2064,7 +2064,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *shadfac) view[0]= -vec[0]; view[1]= -vec[1]; view[2]= -vec[2]; - Normalize(view); + normalize_v3(view); if(aocolor==WO_AOSKYCOL) { fac= 0.5*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); @@ -2230,8 +2230,8 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * v[0] = co[0] - lampco[0]; v[1] = co[1] - lampco[1]; v[2] = co[2] - lampco[2]; - Normalize(v); - VecOrthoBasisf(v, ru, rv); + normalize_v3(v); + ortho_basis_v3v3_v3( ru, rv,v); /* sampling, returns quasi-random vector in area_size disc */ QMC_sampleDisc(samp3d, qsa, shi->thread, samples,lar->area_size); @@ -2248,7 +2248,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * QMC_sampleRect(samp3d, qsa, shi->thread, samples, lar->area_size, lar->area_sizey); /* align samples to lamp vector */ - Mat3MulVecfl(lar->mat, samp3d); + mul_m3_v3(lar->mat, samp3d); } end[0] = vec[0]+samp3d[0]; end[1] = vec[1]+samp3d[1]; @@ -2259,11 +2259,11 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * if(shi->strand) { /* bias away somewhat to avoid self intersection */ - float jitbias= 0.5f*(VecLength(shi->dxco) + VecLength(shi->dyco)); + float jitbias= 0.5f*(len_v3(shi->dxco) + len_v3(shi->dyco)); float v[3]; VECSUB(v, co, end); - Normalize(v); + normalize_v3(v); co[0] -= jitbias*v[0]; co[1] -= jitbias*v[1]; @@ -2274,7 +2274,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * isec->vec[0] = end[0]-isec->start[0]; isec->vec[1] = end[1]-isec->start[1]; isec->vec[2] = end[2]-isec->start[2]; - isec->labda = 1.0f; // * Normalize(isec->vec); + isec->labda = 1.0f; // * normalize_v3(isec->vec); /* trace the ray */ if(isec->mode==RE_RAY_SHADOW_TRA) { @@ -2370,7 +2370,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, float *lampco, floa vec[0]= jitlamp[0]; vec[1]= jitlamp[1]; vec[2]= 0.0f; - Mat3MulVecfl(lar->mat, vec); + mul_m3_v3(lar->mat, vec); /* set start and vec */ isec->vec[0] = vec[0]+lampco[0]-isec->start[0]; @@ -2537,7 +2537,7 @@ static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float co[1]= isec.start[1]+isec.labda*(isec.vec[1]); co[2]= isec.start[2]+isec.labda*(isec.vec[2]); - *distfac= VecLength(isec.vec); + *distfac= len_v3(isec.vec); } else *distfac= 0.0f; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 6c18592b8d2..cae6c640f8b 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -36,7 +36,7 @@ /* External modules: */ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_rand.h" @@ -1498,13 +1498,13 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe VECCOPY(nor, shi->facenor); calc_view_vector(shi->facenor, sx, sy); - Normalize(shi->facenor); + normalize_v3(shi->facenor); shade_input_set_viewco(shi, x, y, sx, sy, z); - orthoarea= VecLength(shi->dxco)*VecLength(shi->dyco); + orthoarea= len_v3(shi->dxco)*len_v3(shi->dyco); VECCOPY(shi->facenor, nor); shade_input_set_viewco(shi, x, y, sx, sy, z); - *area= VecLength(shi->dxco)*VecLength(shi->dyco); + *area= len_v3(shi->dxco)*len_v3(shi->dyco); *area= MIN2(*area, 2.0f*orthoarea); shade_input_set_uv(shi); @@ -1516,8 +1516,8 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe /* not a pretty solution, but fixes common cases */ if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { - VecNegf(shi->vn); - VecNegf(shi->vno); + negate_v3(shi->vn); + negate_v3(shi->vno); } /* if nodetree, use the material that we are currently preprocessing @@ -2148,24 +2148,24 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int /* bitangent */ if(tvn && ttang) { VECCOPY(mat[0], ttang); - Crossf(mat[1], tvn, ttang); + cross_v3_v3v3(mat[1], tvn, ttang); VECCOPY(mat[2], tvn); } else { VECCOPY(mat[0], shi->nmaptang); - Crossf(mat[1], shi->vn, shi->nmaptang); + cross_v3_v3v3(mat[1], shi->vn, shi->nmaptang); VECCOPY(mat[2], shi->vn); } - Mat3Inv(imat, mat); - Mat3MulVecfl(imat, nor); + invert_m3_m3(imat, mat); + mul_m3_v3(imat, nor); } else if(R.r.bake_normal_space == R_BAKE_SPACE_OBJECT) - Mat4Mul3Vecfl(ob->imat, nor); /* ob->imat includes viewinv! */ + mul_mat3_m4_v3(ob->imat, nor); /* ob->imat includes viewinv! */ else if(R.r.bake_normal_space == R_BAKE_SPACE_WORLD) - Mat4Mul3Vecfl(R.viewinv, nor); + mul_mat3_m4_v3(R.viewinv, nor); - Normalize(nor); /* in case object has scaling */ + normalize_v3(nor); /* in case object has scaling */ shr.combined[0]= nor[0]/2.0f + 0.5f; shr.combined[1]= 0.5f - nor[1]/2.0f; @@ -2278,7 +2278,7 @@ static int bake_intersect_tree(RayObject* raytree, Isect* isect, float *start, f hitco[1] = isect->start[1] + isect->labda*isect->vec[1]; hitco[2] = isect->start[2] + isect->labda*isect->vec[2]; - *dist= VecLenf(start, hitco); + *dist= len_v3v3(start, hitco); } return hit; @@ -2330,8 +2330,8 @@ static void bake_set_vlr_dxyco(BakeShade *bs, float *uv1, float *uv2, float *uv3 } if(bs->obi->flag & R_TRANSFORMED) { - Mat3MulVecfl(bs->obi->nmat, bs->dxco); - Mat3MulVecfl(bs->obi->nmat, bs->dyco); + mul_m3_v3(bs->obi->nmat, bs->dxco); + mul_m3_v3(bs->obi->nmat, bs->dyco); } } @@ -2370,7 +2370,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) shi->co[2]= l*v3[2]+u*v1[2]+v*v2[2]; if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, shi->co); + mul_m4_v3(obi->mat, shi->co); VECCOPY(shi->dxco, bs->dxco); VECCOPY(shi->dyco, bs->dyco); @@ -2406,7 +2406,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) isec.userdata= bs; if(bake_intersect_tree(R.raytree, &isec, shi->co, shi->vn, sign, co, &dist)) { - if(!hit || VecLenf(shi->co, co) < VecLenf(shi->co, minco)) { + if(!hit || len_v3v3(shi->co, co) < len_v3v3(shi->co, minco)) { minisec= isec; mindist= dist; VECCOPY(minco, co); diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 54863ef3295..75e58648cd5 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -60,7 +60,7 @@ #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_memarena.h" @@ -448,8 +448,8 @@ int RE_vlakren_get_normal(Render *re, ObjectInstanceRen *obi, VlakRen *vlr, floa if(obi->flag & R_TRANSFORMED) { VECCOPY(nor, vlr->n); - Mat3MulVecfl(nmat, nor); - Normalize(nor); + mul_m3_v3(nmat, nor); + normalize_v3(nor); } else VECCOPY(nor, vlr->n); @@ -462,7 +462,7 @@ int RE_vlakren_get_normal(Render *re, ObjectInstanceRen *obi, VlakRen *vlr, floa else { VECCOPY(v1, vlr->v1->co); if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, v1); + mul_m4_v3(obi->mat, v1); if(INPR(v1, nor) < 0.0f) { flipped= 1; } @@ -995,12 +995,12 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f har->sin= sin(zn); har->cos= cos(zn); - zn= VecLenf(vec1, vec); + zn= len_v3v3(vec1, vec); har->hasize= vectsize*zn + (1.0-vectsize)*hasize; - VecSubf(har->no, vec, vec1); - Normalize(har->no); + sub_v3_v3v3(har->no, vec, vec1); + normalize_v3(har->no); } if(ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA; @@ -1035,7 +1035,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f /* texvec[0]+= imatbase->ivec[0]; */ /* texvec[1]+= imatbase->ivec[1]; */ /* texvec[2]+= imatbase->ivec[2]; */ - /* Mat3MulVecfl(imatbase->imat, texvec); */ + /* mul_m3_v3(imatbase->imat, texvec); */ } else { if(orco) { @@ -1108,12 +1108,12 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater har->sin= sin(zn); har->cos= cos(zn); - zn= VecLenf(vec1, vec)*0.5; + zn= len_v3v3(vec1, vec)*0.5; har->hasize= vectsize*zn + (1.0-vectsize)*hasize; - VecSubf(har->no, vec, vec1); - Normalize(har->no); + sub_v3_v3v3(har->no, vec, vec1); + normalize_v3(har->no); } if(ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA; @@ -1149,13 +1149,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater if(mtex->object){ float imat[4][4]; /* imat should really be cached somewhere before this */ - Mat4Invert(imat,mtex->object->obmat); - Mat4MulVecfl(imat,texvec); + invert_m4_m4(imat,mtex->object->obmat); + mul_m4_v3(imat,texvec); } /* texvec[0]+= imatbase->ivec[0]; */ /* texvec[1]+= imatbase->ivec[1]; */ /* texvec[2]+= imatbase->ivec[2]; */ - /* Mat3MulVecfl(imatbase->imat, texvec); */ + /* mul_m3_v3(imatbase->imat, texvec); */ } else if(mtex->texco & TEXCO_GLOB){ VECCOPY(texvec,vec); @@ -1349,10 +1349,10 @@ ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob, obi->lay= lay; if(mat) { - Mat4CpyMat4(obi->mat, mat); - Mat3CpyMat4(mat3, mat); - Mat3Inv(obi->nmat, mat3); - Mat3Transp(obi->nmat); + copy_m4_m4(obi->mat, mat); + copy_m3_m4(mat3, mat); + invert_m3_m3(obi->nmat, mat3); + transpose_m3(obi->nmat); obi->flag |= R_DUPLI_TRANSFORMED; } @@ -1395,14 +1395,14 @@ int clip_render_object(float boundbox[][3], float *bounds, float winmat[][4]) float mat[4][4], vec[4]; int a, fl, flag= -1; - Mat4CpyMat4(mat, winmat); + copy_m4_m4(mat, winmat); for(a=0; a<8; a++) { vec[0]= (a & 1)? boundbox[0][0]: boundbox[1][0]; vec[1]= (a & 2)? boundbox[0][1]: boundbox[1][1]; vec[2]= (a & 4)? boundbox[0][2]: boundbox[1][2]; vec[3]= 1.0; - Mat4MulVec4fl(mat, vec); + mul_m4_v4(mat, vec); fl= 0; if(bounds) { diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 50e0321a6eb..f8428680135 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -37,7 +37,7 @@ #include "BKE_scene.h" #include "BKE_utildefines.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_memarena.h" @@ -613,7 +613,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) char *clipflag; minz= 1.0e30f; maxz= -1.0e30f; - Mat4CpyMat4(viewmat, lar->shb->viewmat); + copy_m4_m4(viewmat, lar->shb->viewmat); if(lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay; @@ -628,9 +628,9 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) obr= obi->obr; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obviewmat, obi->mat, viewmat); + mul_m4_m4m4(obviewmat, obi->mat, viewmat); else - Mat4CpyMat4(obviewmat, viewmat); + copy_m4_m4(obviewmat, viewmat); memset(clipflag, 0, sizeof(char)*obr->totvert); @@ -661,7 +661,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) if(clipflag[a]) { VECCOPY(vec, ver->co); - Mat4MulVecfl(obviewmat, vec); + mul_m4_v3(obviewmat, vec); /* Z on visible side of lamp space */ if(vec[2] < 0.0f) { float inpr, z= -vec[2]; @@ -669,7 +669,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) /* since vec is rotated in lampspace, this is how to get the cosine of angle */ /* precision is set 20% larger */ vec[2]*= 1.2f; - Normalize(vec); + normalize_v3(vec); inpr= - vec[2]; if(inpr>=lar->spotsi) { @@ -764,8 +764,8 @@ void makeshadowbuf(Render *re, LampRen *lar) shb->pixsize= (shb->d)/temp; wsize= shb->pixsize*(shb->size/2.0); - i_window(-wsize, wsize, -wsize, wsize, shb->d, shb->clipend, shb->winmat); - Mat4MulMat4(shb->persmat, shb->viewmat, shb->winmat); + perspective_m4( shb->winmat,-wsize, wsize, -wsize, wsize, shb->d, shb->clipend); + mul_m4_m4m4(shb->persmat, shb->viewmat, shb->winmat); if(ELEM3(lar->buftype, LA_SHADBUF_REGULAR, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) { shb->totbuf= lar->buffers; @@ -1107,7 +1107,7 @@ float testshadowbuf(Render *re, ShadBuf *shb, float *rco, float *dxco, float *dy VECCOPY(co, rco); co[3]= 1.0f; - Mat4MulVec4fl(shb->persmat, co); /* rational hom co */ + mul_m4_v4(shb->persmat, co); /* rational hom co */ xs1= siz*(1.0f+co[0]/co[3]); ys1= siz*(1.0f+co[1]/co[3]); @@ -1148,7 +1148,7 @@ float testshadowbuf(Render *re, ShadBuf *shb, float *rco, float *dxco, float *dy co[1]= rco[1]+dxco[1]; co[2]= rco[2]+dxco[2]; co[3]= 1.0; - Mat4MulVec4fl(shb->persmat,co); /* rational hom co */ + mul_m4_v4(shb->persmat,co); /* rational hom co */ dx[0]= xs1- siz*(1.0+co[0]/co[3]); dx[1]= ys1- siz*(1.0+co[1]/co[3]); @@ -1156,7 +1156,7 @@ float testshadowbuf(Render *re, ShadBuf *shb, float *rco, float *dxco, float *dy co[1]= rco[1]+dyco[1]; co[2]= rco[2]+dyco[2]; co[3]= 1.0; - Mat4MulVec4fl(shb->persmat,co); /* rational hom co */ + mul_m4_v4(shb->persmat,co); /* rational hom co */ dy[0]= xs1- siz*(1.0+co[0]/co[3]); dy[1]= ys1- siz*(1.0+co[1]/co[3]); @@ -1292,7 +1292,7 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) co[1]= p1[1]; co[2]= p1[2]/lar->sh_zfac; co[3]= 1.0; - Mat4MulVec4fl(shb->winmat, co); /* rational hom co */ + mul_m4_v4(shb->winmat, co); /* rational hom co */ xf1= siz*(1.0+co[0]/co[3]); yf1= siz*(1.0+co[1]/co[3]); zf1= (co[2]/co[3]); @@ -1302,7 +1302,7 @@ float shadow_halo(LampRen *lar, float *p1, float *p2) co[1]= p2[1]; co[2]= p2[2]/lar->sh_zfac; co[3]= 1.0; - Mat4MulVec4fl(shb->winmat, co); /* rational hom co */ + mul_m4_v4(shb->winmat, co); /* rational hom co */ xf2= siz*(1.0+co[0]/co[3]); yf2= siz*(1.0+co[1]/co[3]); zf2= (co[2]/co[3]); @@ -1635,9 +1635,9 @@ static void bspface_init_strand(BSPFace *face) face->radline= 0.5f*VecLen2f(face->v1, face->v2); - VecMidf(face->vec1, face->v1, face->v2); + mid_v3_v3v3(face->vec1, face->v1, face->v2); if(face->v4) - VecMidf(face->vec2, face->v3, face->v4); + mid_v3_v3v3(face->vec2, face->v3, face->v4); else VECCOPY(face->vec2, face->v3); @@ -1659,7 +1659,7 @@ static int point_behind_strand(float *p, BSPFace *face) /* v1 - v2 is radius, v1 - v3 length */ float dist, rc[2], pt[2]; - /* using code from PdistVL2Dfl(), distance vec to line-piece */ + /* using code from dist_to_line_segment_v2(), distance vec to line-piece */ if(face->len==0.0f) { rc[0]= p[0]-face->vec1[0]; @@ -1977,9 +1977,9 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root) obr= obi->obr; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(winmat, obi->mat, shb->persmat); + mul_m4_m4m4(winmat, obi->mat, shb->persmat); else - Mat4CpyMat4(winmat, shb->persmat); + copy_m4_m4(winmat, shb->persmat); for(a=0; atotvlak; a++) { @@ -2055,7 +2055,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v RE_vlakren_get_normal(&R, obi, vlr, nor); VECCOPY(v1, vlr->v1->co); if(obi->flag & R_TRANSFORMED) - Mat4MulVecfl(obi->mat, v1); + mul_m4_v3(obi->mat, v1); /* from shadepixel() */ dface= v1[0]*nor[0] + v1[1]*nor[1] + v1[2]*nor[2]; @@ -2093,7 +2093,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v } /* move 3d vector to lampbuf */ - Mat4MulVec4fl(shb->persmat, hoco); /* rational hom co */ + mul_m4_v4(shb->persmat, hoco); /* rational hom co */ /* clip We can test for -1.0/1.0 because of the properties of the * coordinate transformations. */ diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 79ee6c89460..396c713cfb7 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -30,7 +30,7 @@ #include -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "DNA_curve_types.h" @@ -212,7 +212,7 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) if(R.r.mode & R_ORTHO) shr->mist= mistfactor(-shi->co[2], shi->co); else - shr->mist= mistfactor(VecLength(shi->co), shi->co); + shr->mist= mistfactor(len_v3(shi->co), shi->co); } else shr->mist= 0.0f; @@ -227,7 +227,7 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) shr->combined[3]= fac; if (shi->mat->material_type!= MA_TYPE_VOLUME) - VecMulf(shr->combined, fac); + mul_v3_fl(shr->combined, fac); } else shr->combined[3]= 1.0f; @@ -314,9 +314,9 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen VECCOPY(shi->n3, shi->v3->n); if(obi->flag & R_TRANSFORMED) { - Mat3MulVecfl(obi->nmat, shi->n1); - Mat3MulVecfl(obi->nmat, shi->n2); - Mat3MulVecfl(obi->nmat, shi->n3); + mul_m3_v3(obi->nmat, shi->n1); + mul_m3_v3(obi->nmat, shi->n2); + mul_m3_v3(obi->nmat, shi->n3); } if(!(vlr->flag & (R_NOPUNOFLIP|R_TANGENT))) { @@ -384,7 +384,7 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo /* shade_input_set_viewco equivalent */ VECCOPY(shi->co, spoint->co); VECCOPY(shi->view, shi->co); - Normalize(shi->view); + normalize_v3(shi->view); shi->xs= (int)spoint->x; shi->ys= (int)spoint->y; @@ -407,12 +407,12 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo else { float cross[3]; - Crossf(cross, spoint->co, spoint->tan); - Crossf(shi->vn, cross, spoint->tan); - Normalize(shi->vn); + cross_v3_v3v3(cross, spoint->co, spoint->tan); + cross_v3_v3v3(shi->vn, cross, spoint->tan); + normalize_v3(shi->vn); if(INPR(shi->vn, shi->view) < 0.0f) - VecNegf(shi->vn); + negate_v3(shi->vn); } VECCOPY(shi->vno, shi->vn); @@ -450,8 +450,8 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert if(shi->mat->strand_surfnor > 0.0f) { shi->surfdist= 0.0f; for(sv=strand->vert; sv!=svert; sv++) - shi->surfdist+=VecLenf(sv->co, (sv+1)->co); - shi->surfdist += spoint->t*VecLenf(sv->co, (sv+1)->co); + shi->surfdist+=len_v3v3(sv->co, (sv+1)->co); + shi->surfdist += spoint->t*len_v3v3(sv->co, (sv+1)->co); } } @@ -474,13 +474,13 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert if(texco & TEXCO_GLOB) { VECCOPY(shi->gl, shi->co); - Mat4MulVecfl(R.viewinv, shi->gl); + mul_m4_v3(R.viewinv, shi->gl); if(shi->osatex) { VECCOPY(shi->dxgl, shi->dxco); - Mat3MulVecfl(R.imat, shi->dxco); + mul_m3_v3(R.imat, shi->dxco); VECCOPY(shi->dygl, shi->dyco); - Mat3MulVecfl(R.imat, shi->dyco); + mul_m3_v3(R.imat, shi->dyco); } } @@ -652,7 +652,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float * VECCOPY(v1, shi->v1->co); if(shi->obi->flag & R_TRANSFORMED) - Mat4MulVecfl(shi->obi->mat, v1); + mul_m4_v3(shi->obi->mat, v1); dface= v1[0]*shi->facenor[0]+v1[1]*shi->facenor[1]+v1[2]*shi->facenor[2]; @@ -731,7 +731,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float * shi->camera_co[0] = shi->camera_co[1] = shi->camera_co[2] = 0.0f; /* cannot normalize earlier, code above needs it at viewplane level */ - Normalize(view); + normalize_v3(view); } /* from scanline pixel coordinates to 3d coordinates, requires set_triangle */ @@ -773,17 +773,17 @@ void shade_input_set_uv(ShadeInput *shi) VECCOPY(v3, shi->v3->co); if(shi->obi->flag & R_TRANSFORMED) { - Mat4MulVecfl(shi->obi->mat, v1); - Mat4MulVecfl(shi->obi->mat, v2); - Mat4MulVecfl(shi->obi->mat, v3); + mul_m4_v3(shi->obi->mat, v1); + mul_m4_v3(shi->obi->mat, v2); + mul_m4_v3(shi->obi->mat, v3); } /* exception case for wire render of edge */ if(vlr->v2==vlr->v3) { float lend, lenc; - lend= VecLenf(v2, v1); - lenc= VecLenf(shi->co, v1); + lend= len_v3v3(v2, v1); + lenc= len_v3v3(shi->co, v1); if(lend==0.0f) { shi->u=shi->v= 0.0f; @@ -851,7 +851,7 @@ void shade_input_set_normals(ShadeInput *shi) shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; - Normalize(shi->vn); + normalize_v3(shi->vn); } else VECCOPY(shi->vn, shi->facenor); @@ -939,9 +939,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->tang[2]= (tl*s3[2] - tu*s1[2] - tv*s2[2]); if(obi->flag & R_TRANSFORMED) - Mat3MulVecfl(obi->nmat, shi->tang); + mul_m3_v3(obi->nmat, shi->tang); - Normalize(shi->tang); + normalize_v3(shi->tang); VECCOPY(shi->nmaptang, shi->tang); } } @@ -963,9 +963,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->nmaptang[2]= (tl*s3[2] - tu*s1[2] - tv*s2[2]); if(obi->flag & R_TRANSFORMED) - Mat3MulVecfl(obi->nmat, shi->nmaptang); + mul_m3_v3(obi->nmat, shi->nmaptang); - Normalize(shi->nmaptang); + normalize_v3(shi->nmaptang); } } } @@ -976,7 +976,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) if(surfnor) { VECCOPY(shi->surfnor, surfnor) if(obi->flag & R_TRANSFORMED) - Mat3MulVecfl(obi->nmat, shi->surfnor); + mul_m3_v3(obi->nmat, shi->surfnor); } else VECCOPY(shi->surfnor, shi->vn) @@ -1037,15 +1037,15 @@ void shade_input_set_shade_texco(ShadeInput *shi) if(texco & TEXCO_GLOB) { VECCOPY(shi->gl, shi->co); - Mat4MulVecfl(R.viewinv, shi->gl); + mul_m4_v3(R.viewinv, shi->gl); if(shi->osatex) { VECCOPY(shi->dxgl, shi->dxco); // TXF: bug was here, but probably should be in convertblender.c, R.imat only valid if there is a world - //Mat3MulVecfl(R.imat, shi->dxco); - Mat4Mul3Vecfl(R.viewinv, shi->dxco); + //mul_m3_v3(R.imat, shi->dxco); + mul_mat3_m4_v3(R.viewinv, shi->dxco); VECCOPY(shi->dygl, shi->dyco); - //Mat3MulVecfl(R.imat, shi->dyco); - Mat4Mul3Vecfl(R.viewinv, shi->dyco); + //mul_m3_v3(R.imat, shi->dyco); + mul_mat3_m4_v3(R.viewinv, shi->dyco); } } @@ -1242,9 +1242,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) zbuf_make_winmat(&R, winmat); if(shi->obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); zbuf_render_project(obwinmat, v1->co, ho1); zbuf_render_project(obwinmat, v2->co, ho2); diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index aa0bbd575a7..f167122f497 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -31,7 +31,7 @@ #include -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_colortools.h" #include "BKE_material.h" @@ -168,7 +168,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) p1[0]= shi->co[0]-lar->co[0]; p1[1]= shi->co[1]-lar->co[1]; p1[2]= -lar->co[2]; - Mat3MulVecfl(lar->imat, p1); + mul_m3_v3(lar->imat, p1); VECCOPY(npos, p1); // npos is double! /* pre-scale */ @@ -180,7 +180,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) /* rotate view */ VECCOPY(nray, shi->view); - Mat3MulVecd(lar->imat, nray); + mul_m3_v3_double(lar->imat, nray); if(R.wrld.mode & WO_MIST) { /* patchy... */ @@ -311,7 +311,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) a= sqrt(p1[0]*p1[0]+p1[1]*p1[1]+p1[2]*p1[2]); b= sqrt(p2[0]*p2[0]+p2[1]*p2[1]+p2[2]*p2[2]); - c= VecLenf(p1, p2); + c= len_v3v3(p1, p2); a/= ladist; a= sqrt(a); @@ -489,7 +489,7 @@ static float area_lamp_energy_multisample(LampRen *lar, float *co, float *vn) vec[0]= jitlamp[0]; vec[1]= jitlamp[1]; vec[2]= 0.0f; - Mat3MulVecfl(lar->mat, vec); + mul_m3_v3(lar->mat, vec); VECADD(area[0], lar->area[0], vec); VECADD(area[1], lar->area[1], vec); @@ -553,7 +553,7 @@ static float Phong_Spec( float *n, float *l, float *v, int hard, int tangent ) h[0] = l[0] + v[0]; h[1] = l[1] + v[1]; h[2] = l[2] + v[2]; - Normalize(h); + normalize_v3(h); rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2]; if(tangent) rslt= sasqrt(1.0f - rslt*rslt); @@ -573,7 +573,7 @@ static float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent) h[0]= v[0]+l[0]; h[1]= v[1]+l[1]; h[2]= v[2]+l[2]; - Normalize(h); + normalize_v3(h); nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; if(tangent) nh= sasqrt(1.0f - nh*nh); @@ -606,7 +606,7 @@ static float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_p h[0]= v[0]+l[0]; h[1]= v[1]+l[1]; h[2]= v[2]+l[2]; - Normalize(h); + normalize_v3(h); nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ if(tangent) nh= sasqrt(1.0f - nh*nh); @@ -653,7 +653,7 @@ static float Toon_Spec( float *n, float *l, float *v, float size, float smooth, h[0] = l[0] + v[0]; h[1] = l[1] + v[1]; h[2] = l[2] + v[2]; - Normalize(h); + normalize_v3(h); rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2]; if(tangent) rslt = sasqrt(1.0f - rslt*rslt); @@ -677,7 +677,7 @@ static float WardIso_Spec( float *n, float *l, float *v, float rms, int tangent) h[0] = l[0] + v[0]; h[1] = l[1] + v[1]; h[2] = l[2] + v[2]; - Normalize(h); + normalize_v3(h); nh = n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ if(tangent) nh = sasqrt(1.0f - nh*nh); @@ -728,7 +728,7 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough h[0]= v[0]+l[0]; h[1]= v[1]+l[1]; h[2]= v[2]+l[2]; - Normalize(h); + normalize_v3(h); nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ if(nh<0.0f) nh = 0.0f; @@ -749,12 +749,12 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough Lit_B[0] = l[0] - (realnl * n[0]); Lit_B[1] = l[1] - (realnl * n[1]); Lit_B[2] = l[2] - (realnl * n[2]); - Normalize( Lit_B ); + normalize_v3( Lit_B ); View_B[0] = v[0] - (nv * n[0]); View_B[1] = v[1] - (nv * n[1]); View_B[2] = v[2] - (nv * n[2]); - Normalize( View_B ); + normalize_v3( View_B ); t = Lit_B[0]*View_B[0] + Lit_B[1]*View_B[1] + Lit_B[2]*View_B[2]; if( t < 0 ) t = 0; @@ -1143,7 +1143,7 @@ float lamp_get_visibility(LampRen *lar, float *co, float *lv, float *dist) /* rotate view to lampspace */ VECCOPY(lvrot, lv); - Mat3MulVecfl(lar->imat, lvrot); + mul_m3_v3(lar->imat, lvrot); x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2])); /* 1.0f/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */ @@ -1235,27 +1235,27 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int float cross[3], nstrand[3], blend; if(ma->mode & MA_STR_SURFDIFF) { - Crossf(cross, shi->surfnor, vn); - Crossf(nstrand, vn, cross); + cross_v3_v3v3(cross, shi->surfnor, vn); + cross_v3_v3v3(nstrand, vn, cross); blend= INPR(nstrand, shi->surfnor); blend= 1.0f - blend; CLAMP(blend, 0.0f, 1.0f); - VecLerpf(vnor, nstrand, shi->surfnor, blend); - Normalize(vnor); + interp_v3_v3v3(vnor, nstrand, shi->surfnor, blend); + normalize_v3(vnor); } else { - Crossf(cross, lv, vn); - Crossf(vnor, cross, vn); - Normalize(vnor); + cross_v3_v3v3(cross, lv, vn); + cross_v3_v3v3(vnor, cross, vn); + normalize_v3(vnor); } if(ma->strand_surfnor > 0.0f) { if(ma->strand_surfnor > shi->surfdist) { blend= (ma->strand_surfnor - shi->surfdist)/ma->strand_surfnor; - VecLerpf(vnor, vnor, shi->surfnor, blend); - Normalize(vnor); + interp_v3_v3v3(vnor, vnor, shi->surfnor, blend); + normalize_v3(vnor); } } @@ -1264,9 +1264,9 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int } else if (ma->mode & MA_TANGENT_V) { float cross[3]; - Crossf(cross, lv, shi->tang); - Crossf(vnor, cross, shi->tang); - Normalize(vnor); + cross_v3_v3v3(cross, lv, shi->tang); + cross_v3_v3v3(vnor, cross, shi->tang); + normalize_v3(vnor); vnor[0]= -vnor[0];vnor[1]= -vnor[1];vnor[2]= -vnor[2]; vn= vnor; } @@ -1404,7 +1404,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int lv[1]+= view[1]; lv[2]+= view[2]; - Normalize(lv); + normalize_v3(lv); t= vn[0]*lv[0]+vn[1]*lv[1]+vn[2]*lv[2]; @@ -1662,15 +1662,15 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if(texfac==0.0f) { VECCOPY(col, shr->col); - VecMulf(col, invalpha); + mul_v3_fl(col, invalpha); } else if(texfac==1.0f) { col[0]= col[1]= col[2]= 1.0f; - VecMulf(col, invalpha); + mul_v3_fl(col, invalpha); } else { VECCOPY(col, shr->col); - VecMulf(col, invalpha); + mul_v3_fl(col, invalpha); col[0]= pow(col[0], 1.0f-texfac); col[1]= pow(col[1], 1.0f-texfac); col[2]= pow(col[2], 1.0f-texfac); diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index a416c2d2764..25cfc0f1253 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -47,7 +47,7 @@ /* external modules: */ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_memarena.h" @@ -443,8 +443,8 @@ static void compute_radiance(ScatterTree *tree, float *co, float *rad) of the mesh not visible from the camera. this can not only make it darker, but also lead to ugly color shifts */ - VecMulf(result.rad, tree->ss[0]->frontweight); - VecMulf(result.backrad, tree->ss[0]->backweight); + mul_v3_fl(result.rad, tree->ss[0]->frontweight); + mul_v3_fl(result.backrad, tree->ss[0]->backweight); VECCOPY(rad, result.rad); VECADD(backrad, result.rad, result.backrad); @@ -760,7 +760,7 @@ ScatterTree *scatter_tree_new(ScatterSettings *ss[3], float scale, float error, points[i].area= fabs(area[i])/(tree->scale*tree->scale); points[i].back= (area[i] < 0.0f); - VecMulf(points[i].co, 1.0f/tree->scale); + mul_v3_fl(points[i].co, 1.0f/tree->scale); DO_MINMAX(points[i].co, tree->min, tree->max); refpoints[i]= points + i; @@ -813,7 +813,7 @@ void scatter_tree_sample(ScatterTree *tree, float *co, float *color) float sco[3]; VECCOPY(sco, co); - VecMulf(sco, 1.0f/tree->scale); + mul_v3_fl(sco, 1.0f/tree->scale); compute_radiance(tree, sco, color); } diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index 61080c7d807..47a7c052b18 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -37,7 +37,7 @@ #include "DNA_material_types.h" #include "DNA_meshdata_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_memarena.h" @@ -99,10 +99,10 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) VECCOPY(p[3], sseg->v[3]->co); if(sseg->obi->flag & R_TRANSFORMED) { - Mat4MulVecfl(sseg->obi->mat, p[0]); - Mat4MulVecfl(sseg->obi->mat, p[1]); - Mat4MulVecfl(sseg->obi->mat, p[2]); - Mat4MulVecfl(sseg->obi->mat, p[3]); + mul_m4_v3(sseg->obi->mat, p[0]); + mul_m4_v3(sseg->obi->mat, p[1]); + mul_m4_v3(sseg->obi->mat, p[2]); + mul_m4_v3(sseg->obi->mat, p[3]); } if(t == 0.0f) { @@ -135,11 +135,11 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) spoint->dtco[2]= data[0]*p[0][2] + data[1]*p[1][2] + data[2]*p[2][2] + data[3]*p[3][2]; VECCOPY(spoint->tan, spoint->dtco); - Normalize(spoint->tan); + normalize_v3(spoint->tan); VECCOPY(spoint->nor, spoint->co); VECMUL(spoint->nor, -1.0f); - Normalize(spoint->nor); + normalize_v3(spoint->nor); spoint->width= strand_eval_width(ma, spoint->strandco); @@ -148,7 +148,7 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) spoint->alpha= (simplify)? simplify[1]: 1.0f; /* outer points */ - Crossf(cross, spoint->co, spoint->tan); + cross_v3_v3v3(cross, spoint->co, spoint->tan); w= spoint->co[2]*strandbuf->winmat[2][3] + strandbuf->winmat[3][3]; dx= strandbuf->winx*cross[0]*strandbuf->winmat[0][0]/w; @@ -157,7 +157,7 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) if(w > 0.0f) { if(strandbuf->flag & R_STRAND_B_UNITS) { - crosslen= VecLength(cross); + crosslen= len_v3(cross); w= 2.0f*crosslen*strandbuf->minwidth/w; if(spoint->width < w) { @@ -169,14 +169,14 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) /* squared because we only change width, not length */ spoint->width *= simplify[0]*simplify[0]; - VecMulf(cross, spoint->width*0.5f/crosslen); + mul_v3_fl(cross, spoint->width*0.5f/crosslen); } else - VecMulf(cross, spoint->width/w); + mul_v3_fl(cross, spoint->width/w); } - VecSubf(spoint->co1, spoint->co, cross); - VecAddf(spoint->co2, spoint->co, cross); + sub_v3_v3v3(spoint->co1, spoint->co, cross); + add_v3_v3v3(spoint->co2, spoint->co, cross); VECCOPY(spoint->dsco, cross); } @@ -220,7 +220,7 @@ void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float t, Sha interpolate_vec4(shr1->col, shr2->col, t, negt, shr->col); if(addpassflag & SCE_PASS_NORMAL) { interpolate_vec3(shr1->nor, shr2->nor, t, negt, shr->nor); - Normalize(shr->nor); + normalize_v3(shr->nor); } if(addpassflag & SCE_PASS_DIFFUSE) interpolate_vec3(shr1->diff, shr2->diff, t, negt, shr->diff); @@ -825,9 +825,9 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa /* compute matrix and try clipping whole object */ if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, bounds, winmat)) continue; @@ -903,9 +903,9 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa obr= obi->obr; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); sseg.obi= obi; sseg.strand= RE_findOrAddStrand(obr, sortseg->strand); @@ -975,7 +975,7 @@ StrandSurface *cache_strand_surface(Render *re, ObjectRen *obr, DerivedMesh *dm, mvert= dm->getVertArray(dm); for(a=0; atotvert; a++, mvert++) { VECCOPY(co[a], mvert->co); - Mat4MulVecfl(mat, co[a]); + mul_m4_v3(mat, co[a]); } mface= dm->getFaceArray(dm); diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index 2b490e71142..54032833196 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -21,7 +21,7 @@ #include "sunsky.h" #include "math.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_global.h" /** @@ -289,12 +289,12 @@ void GetSkyXYZRadiancef(struct SunSky* sunsky, const float varg[3], float color_ float theta, phi; float v[3]; - VecCopyf(v, (float*)varg); - Normalize(v); + copy_v3_v3(v, (float*)varg); + normalize_v3(v); if (v[2] < 0.001){ v[2] = 0.001; - Normalize(v); + normalize_v3(v); } DirectionToThetaPhi(v, &theta, &phi); @@ -448,7 +448,7 @@ void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float sunDirection[1] = sunSky->toSun[1]; sunDirection[2] = sunSky->toSun[2]; - costheta = Inpf(view, sunDirection); // cos(theta) + costheta = dot_v3v3(view, sunDirection); // cos(theta) Phase_1 = 1 + (costheta * costheta); // Phase_1 vec3opf(sunSky->atm_BetaRay, sunSky->atm_BetaRay, *, sunSky->atm_BetaRayMultiplier); @@ -461,7 +461,7 @@ void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float E1[1] = exp(E1[1]); E1[2] = exp(E1[2]); - VecCopyf(E, E1); + copy_v3_v3(E, E1); //Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2) fTemp = 1 + sunSky->atm_HGg - 2 * sunSky->atm_HGg * costheta; diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index a74bd3e8041..d2e36a7a286 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -33,7 +33,7 @@ #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "DNA_texture_types.h" @@ -832,7 +832,7 @@ static int cubemap_glob(float *n, float x, float y, float z, float *adr1, float else { VECCOPY(nor, n); } - Mat4Mul3Vecfl(R.viewinv, nor); + mul_mat3_m4_v3(R.viewinv, nor); x1= fabs(nor[0]); y1= fabs(nor[1]); @@ -871,7 +871,7 @@ static int cubemap(MTex *mtex, VlakRen *vlr, float *n, float x, float y, float z /* test for v1, vlr can be faked for baking */ if(vlr->v1 && vlr->v1->orco) { float nor[3]; - CalcNormFloat(vlr->v1->orco, vlr->v2->orco, vlr->v3->orco, nor); + normal_tri_v3( nor,vlr->v1->orco, vlr->v2->orco, vlr->v3->orco); if( fabs(nor[0])puno |= ME_PROJXY; else if( fabs(nor[0])puno |= ME_PROJXZ; @@ -925,7 +925,7 @@ static int cubemap_ob(Object *ob, float *n, float x, float y, float z, float *ad if(n==NULL) return 0; VECCOPY(nor, n); - if(ob) Mat4Mul3Vecfl(ob->imat, nor); + if(ob) mul_mat3_m4_v3(ob->imat, nor); x1= fabs(nor[0]); y1= fabs(nor[1]); @@ -970,8 +970,8 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d fx = (t[0] + 1.0) / 2.0; fy = (t[1] + 1.0) / 2.0; } - else if(wrap==MTEX_TUBE) tubemap(t[0], t[1], t[2], &fx, &fy); - else if(wrap==MTEX_SPHERE) spheremap(t[0], t[1], t[2], &fx, &fy); + else if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); + else if(wrap==MTEX_SPHERE) map_to_sphere( &fx, &fy,t[0], t[1], t[2]); else { if(texco==TEXCO_OBJECT) cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy); else if(texco==TEXCO_GLOB) cubemap_glob(n, t[0], t[1], t[2], &fx, &fy); @@ -1042,20 +1042,20 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d } if(ok) { if(wrap==MTEX_TUBE) { - tubemap(t[0], t[1], t[2], area, area+1); - tubemap(t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2], area+2, area+3); - tubemap(t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2], area+4, area+5); + map_to_tube( area, area+1,t[0], t[1], t[2]); + map_to_tube( area+2, area+3,t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2]); + map_to_tube( area+4, area+5,t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2]); } else { - spheremap(t[0], t[1], t[2],area,area+1); - spheremap(t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2], area+2, area+3); - spheremap(t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2], area+4, area+5); + map_to_sphere(area,area+1,t[0], t[1], t[2]); + map_to_sphere( area+2, area+3,t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2]); + map_to_sphere( area+4, area+5,t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2]); } areaflag= 1; } else { - if(wrap==MTEX_TUBE) tubemap(t[0], t[1], t[2], &fx, &fy); - else spheremap(t[0], t[1], t[2], &fx, &fy); + if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); + else map_to_sphere( &fx, &fy,t[0], t[1], t[2]); dxt[0]/= 2.0; dxt[1]/= 2.0; dyt[0]/= 2.0; @@ -1230,7 +1230,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, * artificer: added the use of tmpvec to avoid scaling texvec */ VECCOPY(tmpvec, texvec); - VecMulf(tmpvec, 1.0/tex->noisesize); + mul_v3_fl(tmpvec, 1.0/tex->noisesize); switch(tex->stype) { case TEX_MFRACTAL: @@ -1252,7 +1252,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, * artificer: added the use of tmpvec to avoid scaling texvec */ VECCOPY(tmpvec, texvec); - VecMulf(tmpvec, 1.0/tex->noisesize); + mul_v3_fl(tmpvec, 1.0/tex->noisesize); retval= voronoiTex(tex, tmpvec, texres); break; @@ -1261,7 +1261,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, * artificer: added the use of tmpvec to avoid scaling texvec */ VECCOPY(tmpvec, texvec); - VecMulf(tmpvec, 1.0/tex->noisesize); + mul_v3_fl(tmpvec, 1.0/tex->noisesize); retval= mg_distNoiseTex(tex, tmpvec, texres); break; @@ -1675,13 +1675,13 @@ void do_material_tex(ShadeInput *shi) VECCOPY(tempvec, shi->co); if(mtex->texflag & MTEX_OB_DUPLI_ORIG) if(shi->obi && shi->obi->duplitexmat) - Mat4MulVecfl(shi->obi->duplitexmat, tempvec); - Mat4MulVecfl(ob->imat, tempvec); + mul_m4_v3(shi->obi->duplitexmat, tempvec); + mul_m4_v3(ob->imat, tempvec); if(shi->osatex) { VECCOPY(dxt, shi->dxco); VECCOPY(dyt, shi->dyco); - Mat4Mul3Vecfl(ob->imat, dxt); - Mat4Mul3Vecfl(ob->imat, dyt); + mul_mat3_m4_v3(ob->imat, dxt); + mul_mat3_m4_v3(ob->imat, dyt); } } else { @@ -1742,7 +1742,7 @@ void do_material_tex(ShadeInput *shi) nn[0] = -shi->vn[0]; nn[1] = -shi->vn[1]; nn[2] = -shi->vn[2]; - VecOrthoBasisf(nn, nu, nv); + ortho_basis_v3v3_v3( nu, nv,nn); nunvdone= 1; } @@ -1819,7 +1819,7 @@ void do_material_tex(ShadeInput *shi) nn[0] = -shi->vn[0]; nn[1] = -shi->vn[1]; nn[2] = -shi->vn[2]; - VecOrthoBasisf(nn, nu, nv); + ortho_basis_v3v3_v3( nu, nv,nn); nunvdone= 1; } @@ -1897,20 +1897,20 @@ void do_material_tex(ShadeInput *shi) idv = (dv < 1e-6f) ? bf : (bf/dv); if ((mtex->texco == TEXCO_ORCO) && shi->obr && shi->obr->ob) { - Mat4Mul3Vecfl(shi->obr->ob->imat, tu); - Mat4Mul3Vecfl(shi->obr->ob->imat, tv); - Normalize(tu); - Normalize(tv); + mul_mat3_m4_v3(shi->obr->ob->imat, tu); + mul_mat3_m4_v3(shi->obr->ob->imat, tv); + normalize_v3(tu); + normalize_v3(tv); } else if (mtex->texco == TEXCO_GLOB) { - Mat4Mul3Vecfl(R.viewinv, tu); - Mat4Mul3Vecfl(R.viewinv, tv); + mul_mat3_m4_v3(R.viewinv, tu); + mul_mat3_m4_v3(R.viewinv, tv); } else if (mtex->texco == TEXCO_OBJECT && mtex->object) { - Mat4Mul3Vecfl(mtex->object->imat, tu); - Mat4Mul3Vecfl(mtex->object->imat, tv); - Normalize(tu); - Normalize(tv); + mul_mat3_m4_v3(mtex->object->imat, tu); + mul_mat3_m4_v3(mtex->object->imat, tv); + normalize_v3(tu); + normalize_v3(tv); } // +u val @@ -1937,7 +1937,7 @@ void do_material_tex(ShadeInput *shi) nv[0] += vd*nn[0]; nv[1] += vd*nn[1]; nv[2] += vd*nn[2]; - Crossf(nvec, nu, nv); + cross_v3_v3v3(nvec, nu, nv); nvec[0] = -nvec[0]; nvec[1] = -nvec[1]; @@ -2020,12 +2020,12 @@ void do_material_tex(ShadeInput *shi) // rotate to global coords if(mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { if(shi->vlr && shi->obr && shi->obr->ob) { - float len= Normalize(texres.nor); + float len= normalize_v3(texres.nor); // can be optimized... (ton) - Mat4Mul3Vecfl(shi->obr->ob->obmat, texres.nor); - Mat4Mul3Vecfl(R.viewmat, texres.nor); - Normalize(texres.nor); - VecMulf(texres.nor, len); + mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor); + mul_mat3_m4_v3(R.viewmat, texres.nor); + normalize_v3(texres.nor); + mul_v3_fl(texres.nor, len); } } } @@ -2100,7 +2100,7 @@ void do_material_tex(ShadeInput *shi) if(mtex->normapspace == MTEX_NSPACE_TANGENT) { /* qdn: tangent space */ float B[3], tv[3]; - Crossf(B, shi->vn, shi->nmaptang); /* bitangent */ + cross_v3_v3v3(B, shi->vn, shi->nmaptang); /* bitangent */ /* transform norvec from tangent space to object surface in camera space */ tv[0] = texres.nor[0]*shi->nmaptang[0] + texres.nor[1]*B[0] + texres.nor[2]*shi->vn[0]; tv[1] = texres.nor[0]*shi->nmaptang[1] + texres.nor[1]*B[1] + texres.nor[2]*shi->vn[1]; @@ -2116,15 +2116,15 @@ void do_material_tex(ShadeInput *shi) if(mtex->normapspace == MTEX_NSPACE_CAMERA); else if(mtex->normapspace == MTEX_NSPACE_WORLD) { - Mat4Mul3Vecfl(R.viewmat, nor); + mul_mat3_m4_v3(R.viewmat, nor); } else if(mtex->normapspace == MTEX_NSPACE_OBJECT) { if(shi->obr && shi->obr->ob) - Mat4Mul3Vecfl(shi->obr->ob->obmat, nor); - Mat4Mul3Vecfl(R.viewmat, nor); + mul_mat3_m4_v3(shi->obr->ob->obmat, nor); + mul_mat3_m4_v3(R.viewmat, nor); } - Normalize(nor); + normalize_v3(nor); /* qdn: worldspace */ shi->vn[0]= facm*shi->vn[0] + fact*nor[0]; @@ -2159,7 +2159,7 @@ void do_material_tex(ShadeInput *shi) shi->vn[2]+= dot*nor[2]; } } - Normalize(shi->vn); + normalize_v3(shi->vn); /* this makes sure the bump is passed on to the next texture */ shi->orn[0]= -shi->vn[0]; @@ -2316,9 +2316,9 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa VECCOPY(co, xyz); if(mtex->texflag & MTEX_OB_DUPLI_ORIG) { if(shi->obi && shi->obi->duplitexmat) - Mat4MulVecfl(shi->obi->duplitexmat, co); + mul_m4_v3(shi->obi->duplitexmat, co); } - Mat4MulVecfl(ob->imat, co); + mul_m4_v3(ob->imat, co); } } /* not really orco, but 'local' */ @@ -2330,12 +2330,12 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa else { Object *ob= shi->obi->ob; VECCOPY(co, xyz); - Mat4MulVecfl(ob->imat, co); + mul_m4_v3(ob->imat, co); } } else if(mtex->texco==TEXCO_GLOB) { VECCOPY(co, xyz); - Mat4MulVecfl(R.viewinv, co); + mul_m4_v3(R.viewinv, co); } else continue; // can happen when texco defines disappear and it renders old files @@ -2648,8 +2648,8 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f case TEXCO_H_SPHEREMAP: case TEXCO_H_TUBEMAP: if(skyflag & WO_ZENUP) { - if(mtex->texco==TEXCO_H_TUBEMAP) tubemap(lo[0], lo[2], lo[1], tempvec, tempvec+1); - else spheremap(lo[0], lo[2], lo[1], tempvec, tempvec+1); + if(mtex->texco==TEXCO_H_TUBEMAP) map_to_tube( tempvec, tempvec+1,lo[0], lo[2], lo[1]); + else map_to_sphere( tempvec, tempvec+1,lo[0], lo[2], lo[1]); /* tube/spheremap maps for outside view, not inside */ tempvec[0]= 1.0-tempvec[0]; /* only top half */ @@ -2668,7 +2668,7 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f case TEXCO_OBJECT: if(mtex->object) { VECCOPY(tempvec, lo); - Mat4MulVecfl(mtex->object->imat, tempvec); + mul_m4_v3(mtex->object->imat, tempvec); co= tempvec; } break; @@ -2676,16 +2676,16 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f case TEXCO_GLOB: if(rco) { VECCOPY(tempvec, rco); - Mat4MulVecfl(R.viewinv, tempvec); + mul_m4_v3(R.viewinv, tempvec); co= tempvec; } else co= lo; // VECCOPY(shi->dxgl, shi->dxco); -// Mat3MulVecfl(R.imat, shi->dxco); +// mul_m3_v3(R.imat, shi->dxco); // VECCOPY(shi->dygl, shi->dyco); -// Mat3MulVecfl(R.imat, shi->dyco); +// mul_m3_v3(R.imat, shi->dyco); break; } @@ -2812,12 +2812,12 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef dx= dxt; dy= dyt; VECCOPY(tempvec, shi->co); - Mat4MulVecfl(ob->imat, tempvec); + mul_m4_v3(ob->imat, tempvec); if(shi->osatex) { VECCOPY(dxt, shi->dxco); VECCOPY(dyt, shi->dyco); - Mat4Mul3Vecfl(ob->imat, dxt); - Mat4Mul3Vecfl(ob->imat, dyt); + mul_mat3_m4_v3(ob->imat, dxt); + mul_mat3_m4_v3(ob->imat, dyt); } } else { @@ -2828,12 +2828,12 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef else if(mtex->texco==TEXCO_GLOB) { co= shi->gl; dx= shi->dxco; dy= shi->dyco; VECCOPY(shi->gl, shi->co); - Mat4MulVecfl(R.viewinv, shi->gl); + mul_m4_v3(R.viewinv, shi->gl); } else if(mtex->texco==TEXCO_VIEW) { VECCOPY(tempvec, lavec); - Mat3MulVecfl(la->imat, tempvec); + mul_m3_v3(la->imat, tempvec); if(la->type==LA_SPOT) { tempvec[0]*= la->spottexfac; @@ -2846,11 +2846,11 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef VECCOPY(dxt, shi->dxlv); VECCOPY(dyt, shi->dylv); /* need some matrix conversion here? la->imat is a [3][3] matrix!!! **/ - Mat3MulVecfl(la->imat, dxt); - Mat3MulVecfl(la->imat, dyt); + mul_m3_v3(la->imat, dxt); + mul_m3_v3(la->imat, dyt); - VecMulf(dxt, la->spottexfac); - VecMulf(dyt, la->spottexfac); + mul_v3_fl(dxt, la->spottexfac); + mul_v3_fl(dyt, la->spottexfac); } } diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index cfaf333d656..4ec30721274 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_threads.h" #include "BLI_voxel.h" @@ -444,8 +444,8 @@ static void *vol_precache_part(void *data) continue; } - VecCopyf(shi->view, co); - Normalize(shi->view); + copy_v3_v3(shi->view, co); + normalize_v3(shi->view); vol_get_scattering(shi, scatter_col, co); obi->volume_precache->data_r[ V_I(x, y, z, res) ] = scatter_col[0]; @@ -495,7 +495,7 @@ static void precache_init_parts(Render *re, RayObject *tree, ShadeInput *shi, Ob parts[0] = parts[1] = parts[2] = totthread; res = vp->res; - VecSubf(voxel, bbmax, bbmin); + sub_v3_v3v3(voxel, bbmax, bbmin); voxel[0] /= res[0]; voxel[1] /= res[1]; @@ -564,7 +564,7 @@ static int precache_resolution(VolumePrecache *vp, float *bbmin, float *bbmax, i { float dim[3], div; - VecSubf(dim, bbmax, bbmin); + sub_v3_v3v3(dim, bbmax, bbmin); div = MAX3(dim[0], dim[1], dim[2]); dim[0] /= div; diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index cf4b6b4002f..32ab2980316 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "BLI_voxel.h" @@ -85,7 +85,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, float *co) /* trace shadow manually, no good lamp api atm */ Isect is; - VecCopyf(is.start, co); + copy_v3_v3(is.start, co); if(lar->type==LA_SUN || lar->type==LA_HEMI) { is.vec[0] = -lar->vec[0]; is.vec[1] = -lar->vec[1]; @@ -93,7 +93,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, float *co) is.labda = R.maxdist; } else { VECSUB( is.vec, lar->co, is.start ); - is.labda = VecLength( is.vec ); + is.labda = len_v3( is.vec ); } is.mode = RE_RAY_MIRROR; @@ -122,9 +122,9 @@ static int vol_get_bounds(ShadeInput *shi, float *co, float *vec, float *hitco, /* XXX TODO - get raytrace max distance from object instance's bounding box */ /* need to account for scaling only, but keep coords in camera space... * below code is WIP and doesn't work! - VecSubf(bb_dim, shi->obi->obr->boundbox[1], shi->obi->obr->boundbox[2]); - Mat3MulVecfl(shi->obi->nmat, bb_dim); - maxsize = VecLength(bb_dim); + sub_v3_v3v3(bb_dim, shi->obi->obr->boundbox[1], shi->obi->obr->boundbox[2]); + mul_m3_v3(shi->obi->nmat, bb_dim); + maxsize = len_v3(bb_dim); */ VECCOPY(isect->start, co); @@ -184,7 +184,7 @@ static void shade_intersection(ShadeInput *shi, float *col, Isect *is) shade_ray(is, &shi_new, &shr_new); } - VecCopyf(col, shr_new.combined); + copy_v3_v3(col, shr_new.combined); col[3] = shr_new.alpha; } @@ -225,7 +225,7 @@ static void vol_get_precached_scattering(ShadeInput *shi, float *scatter_col, fl /* convert input coords to 0.0, 1.0 */ VECCOPY(bbmin, shi->obi->obr->boundbox[0]); VECCOPY(bbmax, shi->obi->obr->boundbox[1]); - VecSubf(dim, bbmax, bbmin); + sub_v3_v3v3(dim, bbmax, bbmin); sample_co[0] = ((co[0] - bbmin[0]) / dim[0]); sample_co[1] = ((co[1] - bbmin[1]) / dim[1]); @@ -246,18 +246,18 @@ static float metadensity(Object* ob, float* co) /* transform co to meta-element */ float tco[3] = {co[0], co[1], co[2]}; - Mat4MulMat4(mat, ob->obmat, R.viewmat); - Mat4Invert(imat, mat); - Mat4MulVecfl(imat, tco); + mul_m4_m4m4(mat, ob->obmat, R.viewmat); + invert_m4_m4(imat, mat); + mul_m4_v3(imat, tco); for (ml = mb->elems.first; ml; ml=ml->next) { float bmat[3][3], dist2; /* element rotation transform */ float tp[3] = {ml->x - tco[0], ml->y - tco[1], ml->z - tco[2]}; - QuatToMat3(ml->quat, bmat); - Mat3Transp(bmat); // rot.only, so inverse == transpose - Mat3MulVecfl(bmat, tp); + quat_to_mat3( bmat,ml->quat); + transpose_m3(bmat); // rot.only, so inverse == transpose + mul_m3_v3(bmat, tp); /* MB_BALL default */ switch (ml->type) { @@ -379,7 +379,7 @@ float vol_get_phasefunc(ShadeInput *shi, float g, float *w, float *wp) return normalize * 1.f; } else { /* schlick */ const float k = 1.55f * g - .55f * g * g * g; - const float kcostheta = k * Inpf(w, wp); + const float kcostheta = k * dot_v3v3(w, wp); return normalize * (1.f - k*k) / ((1.f - kcostheta) * (1.f - kcostheta)); } @@ -435,14 +435,14 @@ static void vol_get_transmittance(ShadeInput *shi, float *tr, float *co, float * float tau[3] = {0.f, 0.f, 0.f}; float t0 = 0.f; - float t1 = Normalize(step_vec); + float t1 = normalize_v3(step_vec); float pt0 = t0; t0 += shi->mat->vol.stepsize * ((shi->mat->vol.stepsize_type == MA_VOL_STEP_CONSTANT) ? 0.5f : BLI_thread_frand(shi->thread)); p[0] += t0 * step_vec[0]; p[1] += t0 * step_vec[1]; p[2] += t0 * step_vec[2]; - VecMulf(step_vec, shi->mat->vol.stepsize); + mul_v3_fl(step_vec, shi->mat->vol.stepsize); for (; t0 < t1; pt0 = t0, t0 += shi->mat->vol.stepsize) { const float d = vol_get_density(shi, p); @@ -455,7 +455,7 @@ static void vol_get_transmittance(ShadeInput *shi, float *tr, float *co, float * tau[1] += stepd * sigma_t[1]; tau[2] += stepd * sigma_t[2]; - VecAddf(p, p, step_vec); + add_v3_v3v3(p, p, step_vec); } /* return transmittance */ @@ -477,34 +477,34 @@ void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar, float * if ((visifac= lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return; - VecCopyf(lacol, &lar->r); + copy_v3_v3(lacol, &lar->r); if(lar->mode & LA_TEXTURE) { shi->osatex= 0; do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE); } - VecMulf(lacol, visifac); + mul_v3_fl(lacol, visifac); if (ELEM(lar->type, LA_SUN, LA_HEMI)) VECCOPY(lv, lar->vec); - VecMulf(lv, -1.0f); + mul_v3_fl(lv, -1.0f); if (shi->mat->vol.shade_type == MA_VOL_SHADE_SHADOWED) { - VecMulf(lacol, vol_get_shadow(shi, lar, co)); + mul_v3_fl(lacol, vol_get_shadow(shi, lar, co)); } else if (shi->mat->vol.shade_type == MA_VOL_SHADE_SHADED) { Isect is; if (shi->mat->vol.shadeflag & MA_VOL_RECV_EXT_SHADOW) { - VecMulf(lacol, vol_get_shadow(shi, lar, co)); + mul_v3_fl(lacol, vol_get_shadow(shi, lar, co)); if (luminance(lacol) < 0.001f) return; } /* find minimum of volume bounds, or lamp coord */ if (vol_get_bounds(shi, co, lv, hitco, &is, VOL_BOUNDS_SS)) { - float dist = VecLenf(co, hitco); + float dist = len_v3v3(co, hitco); VlakRen *vlr = (VlakRen *)is.hit.face; /* simple internal shadowing */ @@ -523,7 +523,7 @@ void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar, float * vol_get_transmittance(shi, tr, co, atten_co); - VecMulVecf(lacol, lacol, tr); + mul_v3_v3v3(lacol, lacol, tr); } else { /* Point is on the outside edge of the volume, @@ -561,7 +561,7 @@ void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co) if (lar) { vol_shade_one_lamp(shi, co, lar, lacol); - VecAddf(scatter_col, scatter_col, lacol); + add_v3_v3v3(scatter_col, scatter_col, lacol); } } } @@ -594,13 +594,13 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float float t0 = 0.f; float pt0 = t0; - float t1 = Normalize(step_vec); /* returns vector length */ + float t1 = normalize_v3(step_vec); /* returns vector length */ t0 += stepsize * ((shi->mat->vol.stepsize_type == MA_VOL_STEP_CONSTANT) ? 0.5f : BLI_thread_frand(shi->thread)); p[0] += t0 * step_vec[0]; p[1] += t0 * step_vec[1]; p[2] += t0 * step_vec[2]; - VecMulf(step_vec, stepsize); + mul_v3_fl(step_vec, stepsize); for (; t0 < t1; pt0 = t0, t0 += stepsize) { const float density = vol_get_density(shi, p); @@ -631,12 +631,12 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float radiance[1] += stepd * tr[1] * (emit_col[1] + scatter_col[1]); radiance[2] += stepd * tr[2] * (emit_col[2] + scatter_col[2]); } - VecAddf(p, p, step_vec); + add_v3_v3v3(p, p, step_vec); } /* multiply original color (from behind volume) with transmittance over entire distance */ - VecMulVecf(col, tr, col); - VecAddf(col, col, radiance); + mul_v3_v3v3(col, tr, col); + add_v3_v3v3(col, col, radiance); /* alpha <-- transmission luminance */ col[3] = 1.0f - luminance(tr); @@ -729,7 +729,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in else col[3] = 1.f; - VecCopyf(shr->combined, col); + copy_v3_v3(shr->combined, col); shr->alpha = col[3]; VECCOPY(shr->diff, shr->combined); @@ -768,7 +768,7 @@ void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct density = vol_get_density(shi, startco); vol_get_transmittance(shi, tr, startco, endco); - VecCopyf(shr->combined, tr); + copy_v3_v3(shr->combined, tr); shr->combined[3] = 1.0f - luminance(tr); } diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 479f33c9ff2..8e71fec4db9 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -32,7 +32,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_voxel.h" @@ -277,9 +277,9 @@ int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres) /* scale lookup from 0.0-1.0 (original location) to -1.0, 1.0, consistent with image texture tex coords */ /* in implementation this works backwards, bringing sample locations from -1.0, 1.0 * to the range 0.0, 1.0, before looking up in the voxel structure. */ - VecCopyf(co, texvec); - VecMulf(co, 0.5f); - VecAddf(co, co, offset); + copy_v3_v3(co, texvec); + mul_v3_fl(co, 0.5f); + add_v3_v3v3(co, co, offset); /* co is now in the range 0.0, 1.0 */ switch (tex->extend) { diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 6c1055ec9e0..a3a714553d2 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -37,7 +37,7 @@ #include #include -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_threads.h" @@ -1808,16 +1808,16 @@ void zbuf_make_winmat(Render *re, float winmat[][4]) float panomat[4][4]; if(re->r.mode & R_PANORAMA) { - Mat4One(panomat); + unit_m4(panomat); panomat[0][0]= re->panoco; panomat[0][2]= re->panosi; panomat[2][0]= -re->panosi; panomat[2][2]= re->panoco; - Mat4MulMat4(winmat, panomat, re->winmat); + mul_m4_m4m4(winmat, panomat, re->winmat); } else - Mat4CpyMat4(winmat, re->winmat); + copy_m4_m4(winmat, re->winmat); } /* do zbuffering and clip, f1 f2 f3 are hocos, c1 c2 c3 are clipping flags */ @@ -2133,9 +2133,9 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, continue; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; @@ -2312,9 +2312,9 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int continue; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, NULL, obwinmat)) continue; @@ -2551,9 +2551,9 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo continue; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; @@ -3297,9 +3297,9 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * continue; if(obi->flag & R_TRANSFORMED) - Mat4MulMat4(obwinmat, obi->mat, winmat); + mul_m4_m4m4(obwinmat, obi->mat, winmat); else - Mat4CpyMat4(obwinmat, winmat); + copy_m4_m4(obwinmat, winmat); if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 081125bf7f6..00af9eb0bb9 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -38,7 +38,7 @@ #include "DNA_screen_types.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_global.h" @@ -133,7 +133,7 @@ void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4]) wmSubWindow *swin= swin_from_swinid(win, swinid); if(swin) - Mat4MulMat4(mat, swin->viewmat, swin->winmat); + mul_m4_m4m4(mat, swin->viewmat, swin->winmat); } /* always sets pixel-precise 2D window/view matrices */ @@ -155,8 +155,8 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct) swin->swinid= freewinid; swin->winrct= *winrct; - Mat4One(swin->viewmat); - Mat4One(swin->winmat); + unit_m4(swin->viewmat); + unit_m4(swin->winmat); /* and we appy it all right away */ wmSubWindowSet(win, swin->swinid); @@ -279,9 +279,9 @@ void wmLoadMatrix(float mat[][4]) glLoadMatrixf(mat); if (glaGetOneInteger(GL_MATRIX_MODE)==GL_MODELVIEW) - Mat4CpyMat4(_curswin->viewmat, mat); + copy_m4_m4(_curswin->viewmat, mat); else - Mat4CpyMat4(_curswin->winmat, mat); + copy_m4_m4(_curswin->winmat, mat); } void wmGetMatrix(float mat[][4]) @@ -289,9 +289,9 @@ void wmGetMatrix(float mat[][4]) if(_curswin==NULL) return; if (glaGetOneInteger(GL_MATRIX_MODE)==GL_MODELVIEW) { - Mat4CpyMat4(mat, _curswin->viewmat); + copy_m4_m4(mat, _curswin->viewmat); } else { - Mat4CpyMat4(mat, _curswin->winmat); + copy_m4_m4(mat, _curswin->winmat); } } @@ -317,8 +317,8 @@ void wmPushMatrix(void) printf("wmPushMatrix error already pushed\n"); debugpush= 1; - Mat4CpyMat4(_curswin->viewmat1, _curswin->viewmat); - Mat4CpyMat4(_curswin->winmat1, _curswin->winmat); + copy_m4_m4(_curswin->viewmat1, _curswin->viewmat); + copy_m4_m4(_curswin->winmat1, _curswin->winmat); } void wmPopMatrix(void) @@ -329,8 +329,8 @@ void wmPopMatrix(void) printf("wmPopMatrix error nothing popped\n"); debugpush= 0; - Mat4CpyMat4(_curswin->viewmat, _curswin->viewmat1); - Mat4CpyMat4(_curswin->winmat, _curswin->winmat1); + copy_m4_m4(_curswin->viewmat, _curswin->viewmat1); + copy_m4_m4(_curswin->winmat, _curswin->winmat1); glMatrixMode(GL_PROJECTION); glLoadMatrixf(&_curswin->winmat[0][0]); @@ -342,7 +342,7 @@ void wmPopMatrix(void) void wmGetSingleMatrix(float mat[][4]) { if(_curswin) - Mat4MulMat4(mat, _curswin->viewmat, _curswin->winmat); + mul_m4_m4m4(mat, _curswin->viewmat, _curswin->winmat); } void wmScale(float x, float y, float z) @@ -363,9 +363,9 @@ void wmLoadIdentity(void) if(_curswin==NULL) return; if (glaGetOneInteger(GL_MATRIX_MODE)==GL_MODELVIEW) - Mat4One(_curswin->viewmat); + unit_m4(_curswin->viewmat); else - Mat4One(_curswin->winmat); + unit_m4(_curswin->winmat); glLoadIdentity(); } diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 6f3036d8e09..1325c80a6d4 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -46,7 +46,7 @@ #include "DNA_scene_types.h" #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" #include "FloatValue.h" @@ -539,8 +539,8 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, if(pchan) { VECCOPY (pchan->loc, matrix[3]); - Mat4ToSize(matrix, pchan->size); - Mat4ToQuat(matrix, pchan->quat); + mat4_to_size( pchan->size,matrix); + mat4_to_quat( pchan->quat,matrix); } } else { diff --git a/source/gameengine/Converter/BL_ArmatureActuator.cpp b/source/gameengine/Converter/BL_ArmatureActuator.cpp index b70a0aa79e7..603dfc370b4 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.cpp +++ b/source/gameengine/Converter/BL_ArmatureActuator.cpp @@ -33,7 +33,7 @@ #include "BKE_constraint.h" #include "BL_ArmatureActuator.h" #include "BL_ArmatureObject.h" -#include "BLI_arithb.h" +#include "BLI_math.h" /** * This class is the conversion of the Pose channel constraint. diff --git a/source/gameengine/Converter/BL_ArmatureChannel.cpp b/source/gameengine/Converter/BL_ArmatureChannel.cpp index 71e91735b24..2444390c9f3 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.cpp +++ b/source/gameengine/Converter/BL_ArmatureChannel.cpp @@ -34,7 +34,7 @@ #include "BL_ArmatureChannel.h" #include "BL_ArmatureObject.h" #include "BL_ArmatureConstraint.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_string.h" #ifndef DISABLE_PYTHON @@ -211,19 +211,19 @@ PyObject* BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const str float norm; double sa, ca; // get rotation in armature space - Mat3CpyMat4(pose_mat, pchan->pose_mat); - Mat3Ortho(pose_mat); + copy_m3_m4(pose_mat, pchan->pose_mat); + normalize_m3(pose_mat); if (pchan->parent) { // bone has a parent, compute the rest pose of the bone taking actual pose of parent - Mat3IsMat3MulMat4(rest_mat, pchan->bone->bone_mat, pchan->parent->pose_mat); - Mat3Ortho(rest_mat); + mul_m3_m3m4(rest_mat, pchan->bone->bone_mat, pchan->parent->pose_mat); + normalize_m3(rest_mat); } else { // otherwise, the bone matrix in armature space is the rest pose - Mat3CpyMat4(rest_mat, pchan->bone->arm_mat); + copy_m3_m4(rest_mat, pchan->bone->arm_mat); } // remove the rest pose to get the joint movement - Mat3Transp(rest_mat); - Mat3MulMat3(joint_mat, rest_mat, pose_mat); + transpose_m3(rest_mat); + mul_m3_m3m3(joint_mat, rest_mat, pose_mat); joints[0] = joints[1] = joints[2] = 0.f; // returns a 3 element list that gives corresponding joint int flag = 0; @@ -237,35 +237,35 @@ PyObject* BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const str case 0: // fixed joint break; case 1: // X only - Mat3ToEulO(joint_mat, joints, EULER_ORDER_XYZ); + mat3_to_eulO( joints, EULER_ORDER_XYZ,joint_mat); joints[1] = joints[2] = 0.f; break; case 2: // Y only - Mat3ToEulO(joint_mat, joints, EULER_ORDER_XYZ); + mat3_to_eulO( joints, EULER_ORDER_XYZ,joint_mat); joints[0] = joints[2] = 0.f; break; case 3: // X+Y - Mat3ToEulO(joint_mat, joints, EULER_ORDER_ZYX); + mat3_to_eulO( joints, EULER_ORDER_ZYX,joint_mat); joints[2] = 0.f; break; case 4: // Z only - Mat3ToEulO(joint_mat, joints, EULER_ORDER_XYZ); + mat3_to_eulO( joints, EULER_ORDER_XYZ,joint_mat); joints[0] = joints[1] = 0.f; break; case 5: // X+Z // decompose this as an equivalent rotation vector in X/Z plane joints[0] = joint_mat[1][2]; joints[2] = -joint_mat[1][0]; - norm = Normalize(joints); + norm = normalize_v3(joints); if (norm < FLT_EPSILON) { norm = (joint_mat[1][1] < 0.f) ? M_PI : 0.f; } else { norm = acos(joint_mat[1][1]); } - VecMulf(joints, norm); + mul_v3_fl(joints, norm); break; case 6: // Y+Z - Mat3ToEulO(joint_mat, joints, EULER_ORDER_XYZ); + mat3_to_eulO( joints, EULER_ORDER_XYZ,joint_mat); joints[0] = 0.f; break; case 7: // X+Y+Z @@ -273,14 +273,14 @@ PyObject* BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const str joints[0] = (joint_mat[1][2]-joint_mat[2][1])*0.5f; joints[1] = (joint_mat[2][0]-joint_mat[0][2])*0.5f; joints[2] = (joint_mat[0][1]-joint_mat[1][0])*0.5f; - sa = VecLength(joints); + sa = len_v3(joints); ca = (joint_mat[0][0]+joint_mat[1][1]+joint_mat[1][1]-1.0f)*0.5f; if (sa > FLT_EPSILON) { norm = atan2(sa,ca)/sa; } else { if (ca < 0.0) { norm = M_PI; - VecMulf(joints,0.f); + mul_v3_fl(joints,0.f); if (joint_mat[0][0] > 0.f) { joints[0] = 1.0f; } else if (joint_mat[1][1] > 0.f) { @@ -292,7 +292,7 @@ PyObject* BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const str norm = 0.0; } } - VecMulf(joints,norm); + mul_v3_fl(joints,norm); break; } return newVectorObject(joints, 3, Py_NEW, NULL); @@ -327,45 +327,45 @@ int BL_ArmatureChannel::py_attr_set_joint_rotation(void *self_v, const struct KX flag |= 2; if (!(pchan->ikflag & BONE_IK_NO_ZDOF)) flag |= 4; - QuatOne(quat); + unit_qt(quat); switch (flag) { case 0: // fixed joint break; case 1: // X only joints[1] = joints[2] = 0.f; - EulOToQuat(joints, EULER_ORDER_XYZ, quat); + eulO_to_quat( quat,joints, EULER_ORDER_XYZ); break; case 2: // Y only joints[0] = joints[2] = 0.f; - EulOToQuat(joints, EULER_ORDER_XYZ, quat); + eulO_to_quat( quat,joints, EULER_ORDER_XYZ); break; case 3: // X+Y joints[2] = 0.f; - EulOToQuat(joints, EULER_ORDER_ZYX, quat); + eulO_to_quat( quat,joints, EULER_ORDER_ZYX); break; case 4: // Z only joints[0] = joints[1] = 0.f; - EulOToQuat(joints, EULER_ORDER_XYZ, quat); + eulO_to_quat( quat,joints, EULER_ORDER_XYZ); break; case 5: // X+Z // X and Z are components of an equivalent rotation axis joints[1] = 0; - VecRotToQuat(joints, VecLength(joints), quat); + axis_angle_to_quat( quat,joints, len_v3(joints)); break; case 6: // Y+Z joints[0] = 0.f; - EulOToQuat(joints, EULER_ORDER_XYZ, quat); + eulO_to_quat( quat,joints, EULER_ORDER_XYZ); break; case 7: // X+Y+Z // equivalent axis - VecRotToQuat(joints, VecLength(joints), quat); + axis_angle_to_quat( quat,joints, len_v3(joints)); break; } if (pchan->rotmode > 0) { - QuatToEulO(quat, joints, pchan->rotmode); - VecCopyf(pchan->eul, joints); + quat_to_eulO( joints, pchan->rotmode,quat); + copy_v3_v3(pchan->eul, joints); } else - QuatCopy(pchan->quat, quat); + copy_qt_qt(pchan->quat, quat); return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.cpp b/source/gameengine/Converter/BL_ArmatureConstraint.cpp index 42581b63ec4..c37f963b82f 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.cpp +++ b/source/gameengine/Converter/BL_ArmatureConstraint.cpp @@ -34,7 +34,7 @@ #include "DNA_action_types.h" #include "BL_ArmatureConstraint.h" #include "BL_ArmatureObject.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BLI_string.h" #ifndef DISABLE_PYTHON @@ -82,12 +82,12 @@ BL_ArmatureConstraint::BL_ArmatureConstraint( m_blendsubtarget = (subtarget) ? subtarget->GetBlenderObject() : NULL; m_pose = m_subpose = NULL; if (m_blendtarget) { - Mat4CpyMat4(m_blendmat, m_blendtarget->obmat); + copy_m4_m4(m_blendmat, m_blendtarget->obmat); if (m_blendtarget->type == OB_ARMATURE) m_pose = m_blendtarget->pose; } if (m_blendsubtarget) { - Mat4CpyMat4(m_blendsubmat, m_blendsubtarget->obmat); + copy_m4_m4(m_blendsubmat, m_blendsubtarget->obmat); if (m_blendsubtarget->type == OB_ARMATURE) m_subpose = m_blendsubtarget->pose; } @@ -198,12 +198,12 @@ void BL_ArmatureConstraint::RestoreTarget() { if (m_constraint && !(m_constraint->flag&CONSTRAINT_OFF) && (!m_blendtarget || m_target)) { if (m_blendtarget) { - Mat4CpyMat4(m_blendtarget->obmat, m_blendmat); + copy_m4_m4(m_blendtarget->obmat, m_blendmat); if (m_pose) m_blendtarget->pose = m_pose; } if (m_blendsubtarget && m_subtarget) { - Mat4CpyMat4(m_blendsubtarget->obmat, m_blendsubmat); + copy_m4_m4(m_blendsubtarget->obmat, m_blendsubmat); if (m_subpose) m_blendsubtarget->pose = m_subpose; } diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index a6066adc03e..f62a6b84fca 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -32,7 +32,7 @@ #include "KX_BlenderSceneConverter.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "BIK_api.h" #include "BKE_action.h" #include "BKE_armature.h" @@ -158,13 +158,13 @@ void game_blend_poses(bPose *dst, bPose *src, float srcweight/*, short mode*/) QUATCOPY(dquat, dchan->quat); QUATCOPY(squat, schan->quat); if (mode==ACTSTRIPMODE_BLEND) - QuatInterpol(dchan->quat, dquat, squat, srcweight); + interp_qt_qtqt(dchan->quat, dquat, squat, srcweight); else { - QuatMulFac(squat, srcweight); - QuatMul(dchan->quat, dquat, squat); + mul_fac_qt_fl(squat, srcweight); + mul_qt_qtqt(dchan->quat, dquat, squat); } - NormalQuat(dchan->quat); + normalize_qt(dchan->quat); } for (i=0; i<3; i++) { diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 881f4cc2517..6e26182a23f 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -135,7 +135,7 @@ #include "BKE_mesh.h" #include "MT_Point3.h" -#include "BLI_arithb.h" +#include "BLI_math.h" extern "C" { #include "BKE_customdata.h" @@ -805,15 +805,15 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, if(mface->flag & ME_SMOOTH) { float n0[3], n1[3], n2[3], n3[3]; - NormalShortToFloat(n0, mvert[mface->v1].no); - NormalShortToFloat(n1, mvert[mface->v2].no); - NormalShortToFloat(n2, mvert[mface->v3].no); + normal_short_to_float_v3(n0, mvert[mface->v1].no); + normal_short_to_float_v3(n1, mvert[mface->v2].no); + normal_short_to_float_v3(n2, mvert[mface->v3].no); no0 = n0; no1 = n1; no2 = n2; if(mface->v4) { - NormalShortToFloat(n3, mvert[mface->v4].no); + normal_short_to_float_v3(n3, mvert[mface->v4].no); no3 = n3; } } @@ -821,9 +821,9 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, float fno[3]; if(mface->v4) - CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co, fno); + normal_quad_v3( fno,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co); else - CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, fno); + normal_tri_v3( fno,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co); no0 = no1 = no2 = no3 = MT_Vector3(fno); } diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index d7012abe316..0abc344a844 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -47,7 +47,7 @@ #include "GEN_Map.h" #include "STR_HashedString.h" -#include "BLI_arithb.h" +#include "BLI_math.h" bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*) { @@ -176,7 +176,7 @@ void BL_MeshDeformer::RecalcNormals() fnor[0]= n1[1]*n2[2] - n1[2]*n2[1]; fnor[1]= n1[2]*n2[0] - n1[0]*n2[2]; fnor[2]= n1[0]*n2[1] - n1[1]*n2[0]; - Normalize(fnor); + normalize_v3(fnor); /* add to vertices for smooth normals */ float *vn1 = m_transnors[v1.getOrigIndex()]; diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index 80165548ff2..0cdca74fea5 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -64,7 +64,7 @@ extern "C"{ #include "BKE_utildefines.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 0af6556f285..4171bfcc58e 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -46,7 +46,7 @@ #include "DNA_armature_types.h" #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" #include "FloatValue.h" diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 125e91e0e0a..9b6d3f61705 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -58,7 +58,7 @@ extern "C"{ #include "BKE_utildefines.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index f166a7252ad..ecc45b2da1a 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -52,7 +52,7 @@ extern "C"{ #include "BKE_utildefines.h" #include "BLI_blenlib.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS @@ -70,7 +70,7 @@ BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj, m_poseApplied(false), m_recalcNormal(true) { - Mat4CpyMat4(m_obmat, bmeshobj->obmat); + copy_m4_m4(m_obmat, bmeshobj->obmat); }; BL_SkinDeformer::BL_SkinDeformer( @@ -93,7 +93,7 @@ BL_SkinDeformer::BL_SkinDeformer( // that takes an object as parameter and not a mesh. The object matrice is used // in the calculation, so we must use the matrix of the original object to // simulate a pure replacement of the mesh. - Mat4CpyMat4(m_obmat, bmeshobj_new->obmat); + copy_m4_m4(m_obmat, bmeshobj_new->obmat); } BL_SkinDeformer::~BL_SkinDeformer() @@ -194,14 +194,14 @@ bool BL_SkinDeformer::UpdateInternal(bool shape_applied) m_armobj->ApplyPose(); // save matrix first - Mat4CpyMat4(obmat, m_objMesh->obmat); + copy_m4_m4(obmat, m_objMesh->obmat); // set reference matrix - Mat4CpyMat4(m_objMesh->obmat, m_obmat); + copy_m4_m4(m_objMesh->obmat, m_obmat); armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, ARM_DEF_VGROUP, NULL, NULL ); // restore matrix - Mat4CpyMat4(m_objMesh->obmat, obmat); + copy_m4_m4(m_objMesh->obmat, obmat); #ifdef __NLA_DEFNORMALS if (m_recalcNormal) diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 26b4514061c..8e7560cdcbd 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -66,7 +66,7 @@ #include "DNA_world_types.h" #include "BKE_main.h" -#include "BLI_arithb.h" +#include "BLI_math.h" extern "C" { @@ -617,8 +617,8 @@ extern "C" //XXX void testhandles_ipocurve(struct IpoCurve *icu); void insert_vert_icu(struct IpoCurve *, float, float, short); float eval_icu(struct IpoCurve *icu, float ipotime); - //void Mat3ToEul(float tmat[][3], float *eul); - void Mat3ToCompatibleEul(float mat[][3], float *eul, float *oldrot); + //void mat3_to_eul( float *eul,float tmat[][3]); + void mat3_to_compatible_eul( float *eul, float *oldrot,float mat[][3]); } IpoCurve* findIpoCurve(IpoCurve* first, const char* searchName) @@ -742,7 +742,7 @@ void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo(){ if (blenderobject->type==OB_ARMATURE) continue; float eu[3]; - Mat4ToEul(blenderobject->obmat,eu); + mat4_to_eul(eu,blenderobject->obmat); MT_Point3 pos = MT_Point3( blenderobject->obmat[3][0], blenderobject->obmat[3][1], @@ -847,8 +847,8 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) for (int c=0;c<3;c++) tmat[r][c] = orn[c][r]; - // Mat3ToEul(tmat, eulerAngles); // better to use Mat3ToCompatibleEul - Mat3ToCompatibleEul(tmat, eulerAngles, eulerAnglesOld); + // mat3_to_eul( eulerAngles,tmat); // better to use Mat3ToCompatibleEul + mat3_to_compatible_eul( eulerAngles, eulerAnglesOld,tmat); //eval_icu for(int x = 0; x < 3; x++) diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index c0d7b639077..b62593b7911 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -33,7 +33,7 @@ Developed as part of a Research and Development project for SAT - La Soci�t� #include "DNA_scene_types.h" #include "RAS_CameraData.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "GL/glew.h" diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index d516d3e03ff..d18e11d3ca5 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -79,7 +79,7 @@ typedef unsigned long uint_ptr; #include "KX_SG_NodeRelationships.h" -#include "BLI_arithb.h" +#include "BLI_math.h" static MT_Point3 dummy_point= MT_Point3(0.0, 0.0, 0.0); static MT_Vector3 dummy_scaling = MT_Vector3(1.0, 1.0, 1.0); @@ -474,9 +474,9 @@ void KX_GameObject::UpdateBlenderObjectMatrix(Object* blendobj) const MT_Vector3& pos = NodeGetWorldPosition(); rot.getValue(blendobj->obmat[0]); pos.getValue(blendobj->obmat[3]); - VecMulf(blendobj->obmat[0], scale[0]); - VecMulf(blendobj->obmat[1], scale[1]); - VecMulf(blendobj->obmat[2], scale[2]); + mul_v3_fl(blendobj->obmat[0], scale[0]); + mul_v3_fl(blendobj->obmat[1], scale[1]); + mul_v3_fl(blendobj->obmat[2], scale[2]); } } diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index bd7e09d1dda..edd3a82b6b0 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -49,7 +49,7 @@ typedef unsigned long uint_ptr; #include "KX_GameObject.h" #include "KX_IPhysicsController.h" #include "DNA_ipo_types.h" -#include "BLI_arithb.h" +#include "BLI_math.h" // All objects should start on frame 1! Will we ever need an object to // start on another frame, the 1.0 should change. diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 6e70bfb14a0..62594f9552c 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -34,7 +34,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "DNA_scene_types.h" #include "RAS_CameraData.h" #include "RAS_MeshObject.h" -#include "BLI_arithb.h" +#include "BLI_math.h" #include "ImageRender.h" #include "ImageBase.h" @@ -589,15 +589,15 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj { v4 = polygon->GetVertex(3); mirrorVerts.push_back(v4); - area = CalcNormFloat4((float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ(), (float*)v4->getXYZ(), normal); + area = normal_quad_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ(), (float*)v4->getXYZ()); } else { - area = CalcNormFloat((float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ(), normal); + area = normal_tri_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ()); } area = fabs(area); mirrorArea += area; - VecMulf(normal, area); - VecAddf(mirrorNormal, mirrorNormal, normal); + mul_v3_fl(normal, area); + add_v3_v3v3(mirrorNormal, mirrorNormal, normal); } } } @@ -607,8 +607,8 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj THRWEXCP(MirrorSizeInvalid, S_OK); } // compute average normal of mirror faces - VecMulf(mirrorNormal, 1.0f/mirrorArea); - if (Normalize(mirrorNormal) == 0.f) + mul_v3_fl(mirrorNormal, 1.0f/mirrorArea); + if (normalize_v3(mirrorNormal) == 0.f) { // no normal THRWEXCP(MirrorNormalInvalid, S_OK); @@ -622,26 +622,26 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj fabs(mirrorNormal[2]) > fabs(mirrorNormal[0])) { // the mirror is more horizontal than vertical - VecCopyf(axis, yaxis); + copy_v3_v3(axis, yaxis); } else { // the mirror is more vertical than horizontal - VecCopyf(axis, zaxis); + copy_v3_v3(axis, zaxis); } - dist = Inpf(mirrorNormal, axis); + dist = dot_v3v3(mirrorNormal, axis); if (fabs(dist) < FLT_EPSILON) { // the mirror is already fully aligned with up axis - VecCopyf(mirrorUp, axis); + copy_v3_v3(mirrorUp, axis); } else { // projection of axis to mirror plane through normal - VecCopyf(vec, mirrorNormal); - VecMulf(vec, dist); - VecSubf(mirrorUp, axis, vec); - if (Normalize(mirrorUp) == 0.f) + copy_v3_v3(vec, mirrorNormal); + mul_v3_fl(vec, dist); + sub_v3_v3v3(mirrorUp, axis, vec); + if (normalize_v3(mirrorUp) == 0.f) { // should not happen THRWEXCP(MirrorHorizontal, S_OK); @@ -650,12 +650,12 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj } // compute rotation matrix between local coord and mirror coord // to match camera orientation, we select mirror z = -normal, y = up, x = y x z - VecCopyf(mirrorMat[2], mirrorNormal); - VecMulf(mirrorMat[2], -1.0f); - VecCopyf(mirrorMat[1], mirrorUp); - Crossf(mirrorMat[0], mirrorMat[1], mirrorMat[2]); + copy_v3_v3(mirrorMat[2], mirrorNormal); + mul_v3_fl(mirrorMat[2], -1.0f); + copy_v3_v3(mirrorMat[1], mirrorUp); + cross_v3_v3v3(mirrorMat[0], mirrorMat[1], mirrorMat[2]); // transpose to make it a orientation matrix from local space to mirror space - Mat3Transp(mirrorMat); + transpose_m3(mirrorMat); // transform all vertex to plane coordinates and determine mirror position left = FLT_MAX; right = -FLT_MAX; @@ -664,8 +664,8 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj back = -FLT_MAX; // most backward vertex (=highest Z coord in mirror space) for (it = mirrorVerts.begin(); it != mirrorVerts.end(); it++) { - VecCopyf(vec, (float*)(*it)->getXYZ()); - Mat3MulVecfl(mirrorMat, vec); + copy_v3_v3(vec, (float*)(*it)->getXYZ()); + mul_m3_v3(mirrorMat, vec); if (vec[0] < left) left = vec[0]; if (vec[0] > right) @@ -690,8 +690,8 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj vec[1] = (top+bottom)*0.5f; vec[2] = back; // convert it in local space: transpose again the matrix to get back to mirror to local transform - Mat3Transp(mirrorMat); - Mat3MulVecfl(mirrorMat, vec); + transpose_m3(mirrorMat); + mul_m3_v3(mirrorMat, vec); // mirror position in local space m_mirrorPos.setValue(vec[0], vec[1], vec[2]); // mirror normal vector (pointed towards the back of the mirror) in local space