Skip to content

Commit

Permalink
UPBGE: Remove usage of MT_CmMatrix4x4.
Browse files Browse the repository at this point in the history
MT_CmMatrix4x4 is easilly replacable by MT_Matrix4x4.
  • Loading branch information
panzergame committed Jun 22, 2017
1 parent 485afb0 commit e56dc43
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 49 deletions.
8 changes: 8 additions & 0 deletions intern/moto/include/MT_Matrix4x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ class MT_Matrix4x4 {

MT_Matrix4x4 inverse() const;
void invert();

MT_Transform toTransform() const
{
return MT_Transform(MT_Vector3(m_el[0][3], m_el[1][3], m_el[2][3]),
MT_Matrix3x3(m_el[0][0], m_el[0][1], m_el[0][2],
m_el[1][0], m_el[1][1], m_el[1][2],
m_el[2][0], m_el[2][1], m_el[2][2]));
}

protected:
/**
Expand Down
25 changes: 0 additions & 25 deletions source/gameengine/Ketsji/KX_GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "SCA_IObject.h"
#include "SG_Node.h"
#include "MT_Transform.h"
#include "MT_CmMatrix4x4.h"
#include "KX_Scene.h"
#include "KX_KetsjiEngine.h" /* for m_anim_framerate */
#include "DNA_constraint_types.h" /* for constraint replication */
Expand Down Expand Up @@ -116,8 +115,6 @@ class KX_GameObject : public SCA_IObject
KX_CullingNode m_cullingNode;
SG_Node* m_pSGNode;

MT_CmMatrix4x4 m_OpenGL_4x4Matrix;

CListValue<KX_PythonComponent> *m_components;

std::vector<bRigidBodyJointConstraint*> m_constraints;
Expand Down Expand Up @@ -169,28 +166,6 @@ class KX_GameObject : public SCA_IObject
std::map<SCA_IObject *, SCA_IObject *>& map
);

/**
* Compute an OpenGl compatible 4x4 matrix. Has the
* side effect of storing the result internally. The
* memory for the matrix remains the property of this class.
*/
float *
GetOpenGLMatrix(
);

/**
* Return a pointer to a MT_CmMatrix4x4 storing the
* opengl transformation for this object. This is updated
* by a call to GetOpenGLMatrix(). This class owns the
* memory for the returned matrix.
*/

MT_CmMatrix4x4 *
GetOpenGLMatrixPtr(
) {
return &m_OpenGL_4x4Matrix;
};

/**
* Update the blender object obmat field from the object world position
* if blendobj is nullptr, update the object pointed by m_pBlenderObject
Expand Down
9 changes: 4 additions & 5 deletions source/gameengine/Ketsji/KX_KetsjiEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ float KX_KetsjiEngine::GetCameraZoom(KX_Camera *camera) const
return overrideCamera ? m_overrideCamZoom : m_cameraZoom;
}

void KX_KetsjiEngine::EnableCameraOverride(const std::string& forscene, const MT_CmMatrix4x4& projmat,
const MT_CmMatrix4x4& viewmat, const RAS_CameraData& camdata)
void KX_KetsjiEngine::EnableCameraOverride(const std::string& forscene, const MT_Matrix4x4& projmat,
const MT_Matrix4x4& viewmat, const RAS_CameraData& camdata)
{
SetFlag(CAMERA_OVERRIDE, true);
m_overrideSceneName = forscene;
Expand Down Expand Up @@ -885,7 +885,7 @@ MT_Matrix4x4 KX_KetsjiEngine::GetCameraProjectionMatrix(KX_Scene *scene, KX_Came
MT_Matrix4x4 projmat;
if (override_camera && !m_overrideCamData.m_perspective) {
// needed to get frustum planes for culling
projmat.setValue(m_overrideCamProjMat.getPointer());
projmat = m_overrideCamProjMat;
}
else {
RAS_FrameFrustum frustum;
Expand Down Expand Up @@ -1101,8 +1101,7 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene *scene)

// set transformation
if (override_camera) {
const MT_CmMatrix4x4& cammatdata = m_overrideCamViewMat;
MT_Transform trans = MT_Transform(cammatdata.getPointer());
MT_Transform trans = m_overrideCamViewMat.toTransform();
MT_Transform camtrans;
camtrans.invert(trans);

Expand Down
7 changes: 3 additions & 4 deletions source/gameengine/Ketsji/KX_KetsjiEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#ifndef __KX_KETSJIENGINE_H__
#define __KX_KETSJIENGINE_H__

#include "MT_CmMatrix4x4.h"
#include "MT_Matrix4x4.h"
#include <string>
#include "KX_ISystem.h"
Expand Down Expand Up @@ -196,8 +195,8 @@ class KX_KetsjiEngine

std::string m_overrideSceneName;
RAS_CameraData m_overrideCamData;
MT_CmMatrix4x4 m_overrideCamProjMat;
MT_CmMatrix4x4 m_overrideCamViewMat;
MT_Matrix4x4 m_overrideCamProjMat;
MT_Matrix4x4 m_overrideCamViewMat;
/// Default camera zoom.
float m_overrideCamZoom;

Expand Down Expand Up @@ -360,7 +359,7 @@ class KX_KetsjiEngine
/// Get the camera zoom for the passed camera.
float GetCameraZoom(KX_Camera *camera) const;

void EnableCameraOverride(const std::string& forscene, const MT_CmMatrix4x4& projmat, const MT_CmMatrix4x4& viewmat, const RAS_CameraData& camdata);
void EnableCameraOverride(const std::string& forscene, const MT_Matrix4x4& projmat, const MT_Matrix4x4& viewmat, const RAS_CameraData& camdata);

// Update animations for object in this scene
void UpdateAnimations(KX_Scene *scene);
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Launcher/LA_BlenderLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void LA_BlenderLauncher::InitCamera()
camdata.m_clipend = m_view3d->far;
camdata.m_perspective = (rv3d->persp != RV3D_ORTHO);

m_ketsjiEngine->EnableCameraOverride(m_startSceneName, MT_CmMatrix4x4(rv3d->winmat), MT_CmMatrix4x4(rv3d->viewmat), camdata);
m_ketsjiEngine->EnableCameraOverride(m_startSceneName, MT_Matrix4x4(&rv3d->winmat[0][0]), MT_Matrix4x4(&rv3d->viewmat[0][0]), camdata);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#include "RAS_Rasterizer.h"
#include "RAS_ICanvas.h"

#include "MT_CmMatrix4x4.h"

#include "KX_Camera.h"
#include "KX_Light.h"
#include "KX_Scene.h"
Expand Down
9 changes: 0 additions & 9 deletions source/gameengine/Rasterizer/RAS_Rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,6 @@ void RAS_Rasterizer::IndexPrimitivesDerivedMesh(RAS_MeshSlot *ms)
m_impl->DrawDerivedMesh(ms, m_drawingmode);
}

void RAS_Rasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
{
SetMatrixMode(RAS_PROJECTION);
float *matrix = &mat(0, 0);
LoadMatrix(matrix);

m_camortho = (mat(3, 3) != 0.0f);
}

void RAS_Rasterizer::SetProjectionMatrix(const MT_Matrix4x4 & mat)
{
SetMatrixMode(RAS_PROJECTION);
Expand Down
3 changes: 0 additions & 3 deletions source/gameengine/Rasterizer/RAS_Rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
# pragma warning (disable:4786)
#endif

#include "MT_CmMatrix4x4.h"
#include "MT_Matrix4x4.h"

#include "RAS_DebugDraw.h"
Expand Down Expand Up @@ -561,8 +560,6 @@ class RAS_Rasterizer
/// Render text mesh slot using BLF functions.
void IndexPrimitivesText(RAS_MeshSlot *ms);

void SetProjectionMatrix(MT_CmMatrix4x4 &mat);

/* This one should become our final version, methinks. */
/**
* Set the projection matrix for the rasterizer. This projects
Expand Down

0 comments on commit e56dc43

Please sign in to comment.