From 37e4a311b0ad9da7177e50620efc3561e2dd7045 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Nov 2009 20:43:45 +0000 Subject: 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/gameengine/Converter/BL_ActionActuator.cpp | 6 +-- .../gameengine/Converter/BL_ArmatureActuator.cpp | 2 +- source/gameengine/Converter/BL_ArmatureChannel.cpp | 58 +++++++++++----------- .../gameengine/Converter/BL_ArmatureConstraint.cpp | 10 ++-- source/gameengine/Converter/BL_ArmatureObject.cpp | 10 ++-- .../Converter/BL_BlenderDataConversion.cpp | 14 +++--- source/gameengine/Converter/BL_MeshDeformer.cpp | 4 +- .../gameengine/Converter/BL_ModifierDeformer.cpp | 2 +- .../Converter/BL_ShapeActionActuator.cpp | 2 +- source/gameengine/Converter/BL_ShapeDeformer.cpp | 2 +- source/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 +-- source/gameengine/Ketsji/KX_IPO_SGController.cpp | 2 +- source/gameengine/VideoTexture/ImageRender.cpp | 48 +++++++++--------- 16 files changed, 97 insertions(+), 97 deletions(-) (limited to 'source/gameengine') 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 -- cgit v1.2.3