diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2016-04-12 00:04:58 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2016-04-12 00:04:58 +0300 |
commit | 4a507a7653ad74686e677ffc569dbe3bd7e91060 (patch) | |
tree | 2b4ec318631fa95d6e42728a2a6d1ec742a34c37 /source/gameengine | |
parent | 12bb5bdabf51eca1cc8fd236df2c4606b5e963aa (diff) | |
parent | 7d033717ad52bf92235e65224b6b3940de7ec473 (diff) |
Merge remote-tracking branch 'origin/master' into decklink
Diffstat (limited to 'source/gameengine')
37 files changed, 142 insertions, 103 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index d9865c1f4fb..d28cdb84275 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -584,7 +584,7 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF if (val != "") { - action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val); + action= (bAction*)self->GetLogicManager()->GetActionByName(val); if (!action) { PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!"); diff --git a/source/gameengine/Converter/BL_ArmatureActuator.cpp b/source/gameengine/Converter/BL_ArmatureActuator.cpp index e38cb6eadaf..67cc7d2c291 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.cpp +++ b/source/gameengine/Converter/BL_ArmatureActuator.cpp @@ -243,7 +243,7 @@ int BL_ArmatureActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBU KX_GameObject* &target = (!strcmp(attrdef->m_name, "target")) ? actuator->m_gametarget : actuator->m_gamesubtarget; KX_GameObject *gameobj; - if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: BL_ArmatureActuator")) + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: BL_ArmatureActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (target != NULL) diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.cpp b/source/gameengine/Converter/BL_ArmatureConstraint.cpp index 88d82e21d61..d0c7e061fb7 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.cpp +++ b/source/gameengine/Converter/BL_ArmatureConstraint.cpp @@ -36,6 +36,7 @@ #include "BL_ArmatureObject.h" #include "BLI_math.h" #include "BLI_string.h" +#include "KX_PythonInit.h" #ifdef WITH_PYTHON @@ -360,6 +361,7 @@ int BL_ArmatureConstraint::py_attr_setattr(void *self_v, const struct KX_PYATTRI int ival; double dval; // char* sval; + SCA_LogicManager *logicmgr = KX_GetActiveScene()->GetLogicManager(); KX_GameObject *oval; if (!constraint) { @@ -387,13 +389,13 @@ int BL_ArmatureConstraint::py_attr_setattr(void *self_v, const struct KX_PYATTRI return PY_SET_ATTR_SUCCESS; case BCA_TARGET: - if (!ConvertPythonToGameObject(value, &oval, true, "constraint.target = value: BL_ArmatureConstraint")) + if (!ConvertPythonToGameObject(logicmgr, value, &oval, true, "constraint.target = value: BL_ArmatureConstraint")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error self->SetTarget(oval); return PY_SET_ATTR_SUCCESS; case BCA_SUBTARGET: - if (!ConvertPythonToGameObject(value, &oval, true, "constraint.subtarget = value: BL_ArmatureConstraint")) + if (!ConvertPythonToGameObject(logicmgr, value, &oval, true, "constraint.subtarget = value: BL_ArmatureConstraint")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error self->SetSubtarget(oval); return PY_SET_ATTR_SUCCESS; diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 0f55438ecf6..c2cfd8808a9 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -228,17 +228,7 @@ static std::map<int, SCA_IInputDevice::KX_EnumInputs> create_translate_table() m[EKEY ] = SCA_IInputDevice::KX_EKEY; m[FKEY ] = SCA_IInputDevice::KX_FKEY; m[GKEY ] = SCA_IInputDevice::KX_GKEY; - -//XXX clean up -#ifdef WIN32 -#define HKEY 'h' -#endif m[HKEY ] = SCA_IInputDevice::KX_HKEY; -//XXX clean up -#ifdef WIN32 -#undef HKEY -#endif - m[IKEY ] = SCA_IInputDevice::KX_IKEY; m[JKEY ] = SCA_IInputDevice::KX_JKEY; m[KKEY ] = SCA_IInputDevice::KX_KKEY; @@ -1427,6 +1417,9 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l lightobj->m_att1 = la->att1; lightobj->m_att2 = (la->mode & LA_QUAD) ? la->att2 : 0.0f; + lightobj->m_coeff_const = la->coeff_const; + lightobj->m_coeff_lin = la->coeff_lin; + lightobj->m_coeff_quad = la->coeff_quad; lightobj->m_color[0] = la->r; lightobj->m_color[1] = la->g; lightobj->m_color[2] = la->b; diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index e8f451213f5..f21db419ebc 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -547,7 +547,7 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE if (val != "") { - action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val); + action= (bAction*)self->GetLogicManager()->GetActionByName(val); if (action==NULL) { PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, action not found!"); diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 950c1dcad11..68da99f9fa5 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -153,7 +153,10 @@ void BL_SkinDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map) bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) { // We do everything in UpdateInternal() now so we can thread it. - return false; + // All that is left is telling the rasterizer if we've changed the mesh + bool retval = !m_poseApplied; + m_poseApplied = true; + return retval; } RAS_Deformer *BL_SkinDeformer::GetReplica() @@ -359,6 +362,8 @@ bool BL_SkinDeformer::UpdateInternal(bool shape_applied) UpdateTransverts(); + m_poseApplied = false; + /* indicate that the m_transverts and normals are up to date */ return true; } diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 96328da60bd..b97d0b2a85d 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -630,8 +630,8 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) mat3_to_compatible_eul(blenderObject->rot, blenderObject->rot, tmat); - insert_keyframe(NULL, &blenderObject->id, NULL, NULL, "location", -1, (float)frameNumber, INSERTKEY_FAST); - insert_keyframe(NULL, &blenderObject->id, NULL, NULL, "rotation_euler", -1, (float)frameNumber, INSERTKEY_FAST); + insert_keyframe(NULL, &blenderObject->id, NULL, NULL, "location", -1, (float)frameNumber, BEZT_KEYTYPE_JITTER, INSERTKEY_FAST); + insert_keyframe(NULL, &blenderObject->id, NULL, NULL, "rotation_euler", -1, (float)frameNumber, BEZT_KEYTYPE_JITTER, INSERTKEY_FAST); #if 0 const MT_Point3& position = gameObj->NodeGetWorldPosition(); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 021111b4fe5..455fef0aceb 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -1127,6 +1127,7 @@ void BL_ConvertActuators(const char* maggiename, uniquename += uniqueval->GetText(); uniqueval->Release(); baseact->SetName(bact->name); + baseact->SetLogicManager(logicmgr); //gameobj->SetProperty(uniquename,baseact); gameobj->AddActuator(baseact); diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index e3697087ea9..f55d81adb80 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -214,6 +214,7 @@ void BL_ConvertControllers( //at some point it should either be implemented globally (and saved as a separate var) or removed. //gamecontroller->SetName(uniquename); gamecontroller->SetName(bcontr->name); + gamecontroller->SetLogicManager(logicmgr); gameobj->AddController(gamecontroller); converter->RegisterGameController(gamecontroller, bcontr); diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 79fd9cb9254..5e897bb4a62 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -608,6 +608,7 @@ void BL_ConvertSensors(struct Object* blenderobject, gamesensor->SetLevel(level); gamesensor->SetTap(tap); gamesensor->SetName(sens->name); + gamesensor->SetLogicManager(logicmgr); gameobj->AddSensor(gamesensor); diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index b03570e3c28..1a66b2aee52 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -29,10 +29,6 @@ * \ingroup gamelogic */ -#ifdef WITH_SDL -# include <SDL.h> -#endif - #include <stdio.h> #include <stdlib.h> diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index dd9fbefa545..c9221753d45 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -34,7 +34,18 @@ #include "SCA_JoystickDefines.h" #ifdef WITH_SDL +/* SDL force defines __SSE__ and __SSE2__ flags, which generates warnings + * because we pass those defines via command line as well. For until there's + * proper ifndef added to SDL headers we ignore the redefinition warning. + */ +# ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4005) +# endif # include "SDL.h" +# ifdef _MSC_VER +# pragma warning(pop) +# endif #endif /** diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp index 0033c137eb6..fd3d713b3d2 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp @@ -29,10 +29,6 @@ * \ingroup gamelogic */ -#ifdef WITH_SDL -# include <SDL.h> -#endif - #include "SCA_Joystick.h" #include "SCA_JoystickPrivate.h" diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index 72a0b392447..d0a6e4540c9 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -35,12 +35,11 @@ #include "SCA_ILogicBrick.h" #include "EXP_PyObjectPlus.h" -SCA_LogicManager* SCA_ILogicBrick::m_sCurrentLogicManager = NULL; - SCA_ILogicBrick::SCA_ILogicBrick(SCA_IObject* gameobj) : CValue(), m_gameobj(gameobj), + m_logicManager(NULL), m_Execute_Priority(0), m_Execute_Ueber_Priority(0), m_bActive(false), @@ -143,6 +142,16 @@ bool SCA_ILogicBrick::LessComparedTo(SCA_ILogicBrick* other) (this->m_Execute_Priority < other->m_Execute_Priority)); } +void SCA_ILogicBrick::SetLogicManager(SCA_LogicManager *logicmgr) +{ + m_logicManager = logicmgr; +} + +SCA_LogicManager *SCA_ILogicBrick::GetLogicManager() +{ + return m_logicManager; +} + void SCA_ILogicBrick::RegisterEvent(CValue* eventval) { if (m_eventval) diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index a3725789227..f9ef18cc348 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -40,12 +40,14 @@ class NG_NetworkScene; class SCA_IScene; +class SCA_LogicManager; class SCA_ILogicBrick : public CValue { Py_Header protected: SCA_IObject* m_gameobj; + SCA_LogicManager *m_logicManager; int m_Execute_Priority; int m_Execute_Ueber_Priority; @@ -127,9 +129,8 @@ public: virtual bool LessComparedTo(SCA_ILogicBrick* other); - /* runtime variable, set when Triggering the python controller */ - static class SCA_LogicManager* m_sCurrentLogicManager; - + virtual void SetLogicManager(SCA_LogicManager *logicmgr); + SCA_LogicManager *GetLogicManager(); /* for moving logic bricks between scenes */ virtual void Replace_IScene(SCA_IScene *val) {} diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index fa30e3a5caf..25936b34fde 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -386,8 +386,7 @@ bool SCA_PythonController::Import() void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) { m_sCurrentController = this; - m_sCurrentLogicManager = logicmgr; - + PyObject *excdict= NULL; PyObject *resultobj= NULL; @@ -478,7 +477,7 @@ PyObject *SCA_PythonController::PyActivate(PyObject *value) if (actu==NULL) return NULL; - m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, true); + m_logicManager->AddActiveActuator((SCA_IActuator*)actu, true); Py_RETURN_NONE; } @@ -493,7 +492,7 @@ PyObject *SCA_PythonController::PyDeActivate(PyObject *value) if (actu==NULL) return NULL; - m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, false); + m_logicManager->AddActiveActuator((SCA_IActuator*)actu, false); Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 361cd65d50a..89aea80bb67 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -1035,7 +1035,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition, { PyErr_Clear(); - if (ConvertPythonToGameObject(value, &obj, true, "")) + if (ConvertPythonToGameObject(GetScene()->GetLogicManager(), value, &obj, true, "")) { PyErr_Clear(); vect = MT_Vector3(obj->NodeGetWorldPosition()); diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index f065e3f0001..e488bf3c30a 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -411,7 +411,7 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF KX_CameraActuator* self = static_cast<KX_CameraActuator*>(self_v); KX_GameObject *gameobj; - if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_CameraActuator")) + if (!ConvertPythonToGameObject(self->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_CameraActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (self->m_ob) diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index ad6447778e5..69c1af35bd9 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1187,6 +1187,7 @@ const MT_Vector4& KX_GameObject::GetObjectColor() void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) { + const MT_Scalar eps = 3.0f * MT_EPSILON; MT_Matrix3x3 orimat; MT_Vector3 vect,ori,z,x,y; MT_Scalar len; @@ -1212,10 +1213,12 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) orimat = GetSGNode()->GetWorldOrientation(); switch (axis) { - case 0: //x axis - ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis - if (MT_abs(vect.dot(ori)) > 1.0f-3.0f*MT_EPSILON) //is the vector parallel to the pivot? - ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot! + case 0: // align x axis of new coord system to vect + ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); // pivot axis + if (1.0f - MT_abs(vect.dot(ori)) < eps) { // vect parallel to pivot? + ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); // change the pivot! + } + if (fac == 1.0f) { x = vect; } else { @@ -1227,10 +1230,12 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) y = ori.cross(x); z = x.cross(y); break; - case 1: //y axis + case 1: // y axis ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]); - if (MT_abs(vect.dot(ori)) > 1.0f-3.0f*MT_EPSILON) + if (1.0f - MT_abs(vect.dot(ori)) < eps) { ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); + } + if (fac == 1.0f) { y = vect; } else { @@ -1242,10 +1247,12 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) z = ori.cross(y); x = y.cross(z); break; - case 2: //z axis + case 2: // z axis ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); - if (MT_abs(vect.dot(ori)) > 1.0f-3.0f*MT_EPSILON) + if (1.0f - MT_abs(vect.dot(ori)) < eps) { ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]); + } + if (fac == 1.0f) { z = vect; } else { @@ -1257,25 +1264,27 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) x = ori.cross(z); y = z.cross(x); break; - default: //wrong input? - cout << "alignAxisToVect(): Wrong axis '" << axis <<"'\n"; + default: // invalid axis specified + cout << "alignAxisToVect(): Invalid axis '" << axis <<"'\n"; return; } - x.normalize(); //normalize the vectors + x.normalize(); // normalize the new base vectors y.normalize(); z.normalize(); - orimat.setValue( x[0],y[0],z[0], - x[1],y[1],z[1], - x[2],y[2],z[2]); + orimat.setValue(x[0], y[0], z[0], + x[1], y[1], z[1], + x[2], y[2], z[2]); + if (GetSGNode()->GetSGParent() != NULL) { // the object is a child, adapt its local orientation so that - // the global orientation is aligned as we want. + // the global orientation is aligned as we want (cancelling out the parent orientation) MT_Matrix3x3 invori = GetSGNode()->GetSGParent()->GetWorldOrientation().inverse(); NodeSetLocalOrientation(invori*orimat); } - else + else { NodeSetLocalOrientation(orimat); + } } MT_Scalar KX_GameObject::GetMass() @@ -1588,14 +1597,6 @@ void KX_GameObject::RunCollisionCallbacks(KX_GameObject *collider, const MT_Vect if (!m_collisionCallbacks || PyList_GET_SIZE(m_collisionCallbacks) == 0) return; - /** Current logic controller is set by each python logic bricks before run, - * but if no python logic brick ran the logic manager can be wrong - * (if the user use muti scenes) and it will cause problems with function - * ConvertPythonToGameObject which use the current logic manager for object's name. - * Note: the scene is already set in logic frame loop. - */ - SCA_ILogicBrick::m_sCurrentLogicManager = GetScene()->GetLogicManager(); - PyObject *args[] = {collider->GetProxy(), PyObjectFrom(point), PyObjectFrom(normal)}; RunPythonCallBackList(m_collisionCallbacks, args, 1, ARRAY_SIZE(args)); @@ -2034,7 +2035,8 @@ PyAttributeDef KX_GameObject::Attributes[] = { PyObject *KX_GameObject::PyReplaceMesh(PyObject *args) { KX_Scene *scene = KX_GetActiveScene(); - + SCA_LogicManager *logicmgr = GetScene()->GetLogicManager(); + PyObject *value; int use_gfx= 1, use_phys= 0; RAS_MeshObject *new_mesh; @@ -2042,7 +2044,7 @@ PyObject *KX_GameObject::PyReplaceMesh(PyObject *args) if (!PyArg_ParseTuple(args,"O|ii:replaceMesh", &value, &use_gfx, &use_phys)) return NULL; - if (!ConvertPythonToMesh(value, &new_mesh, false, "gameOb.replaceMesh(value): KX_GameObject")) + if (!ConvertPythonToMesh(logicmgr, value, &new_mesh, false, "gameOb.replaceMesh(value): KX_GameObject")) return NULL; scene->ReplaceMesh(this, new_mesh, (bool)use_gfx, (bool)use_phys); @@ -2063,13 +2065,14 @@ PyObject *KX_GameObject::PyReinstancePhysicsMesh(PyObject *args) { KX_GameObject *gameobj= NULL; RAS_MeshObject *mesh= NULL; + SCA_LogicManager *logicmgr = GetScene()->GetLogicManager(); PyObject *gameobj_py= NULL; PyObject *mesh_py= NULL; if ( !PyArg_ParseTuple(args,"|OO:reinstancePhysicsMesh",&gameobj_py, &mesh_py) || - (gameobj_py && !ConvertPythonToGameObject(gameobj_py, &gameobj, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject")) || - (mesh_py && !ConvertPythonToMesh(mesh_py, &mesh, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject")) + (gameobj_py && !ConvertPythonToGameObject(logicmgr, gameobj_py, &gameobj, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject")) || + (mesh_py && !ConvertPythonToMesh(logicmgr, mesh_py, &mesh, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject")) ) { return NULL; } @@ -3414,6 +3417,7 @@ PyObject *KX_GameObject::PyDisableRigidBody() PyObject *KX_GameObject::PySetParent(PyObject *args) { KX_Scene *scene = KX_GetActiveScene(); + SCA_LogicManager *logicmgr = GetScene()->GetLogicManager(); PyObject *pyobj; KX_GameObject *obj; int addToCompound=1, ghost=1; @@ -3421,7 +3425,7 @@ PyObject *KX_GameObject::PySetParent(PyObject *args) if (!PyArg_ParseTuple(args,"O|ii:setParent", &pyobj, &addToCompound, &ghost)) { return NULL; // Python sets a simple error } - if (!ConvertPythonToGameObject(pyobj, &obj, true, "gameOb.setParent(obj): KX_GameObject")) + if (!ConvertPythonToGameObject(logicmgr, pyobj, &obj, true, "gameOb.setParent(obj): KX_GameObject")) return NULL; if (obj) this->SetParent(scene, obj, addToCompound, ghost); @@ -3577,9 +3581,10 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getDistanceTo, return PyFloat_FromDouble(NodeGetWorldPosition().distance(b)); } PyErr_Clear(); - + + SCA_LogicManager *logicmgr = GetScene()->GetLogicManager(); KX_GameObject *other; - if (ConvertPythonToGameObject(value, &other, false, "gameOb.getDistanceTo(value): KX_GameObject")) + if (ConvertPythonToGameObject(logicmgr, value, &other, false, "gameOb.getDistanceTo(value): KX_GameObject")) { return PyFloat_FromDouble(NodeGetWorldPosition().distance(other->NodeGetWorldPosition())); } @@ -3595,6 +3600,7 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo, MT_Vector3 toDir, locToDir; MT_Scalar distance; + SCA_LogicManager *logicmgr = GetScene()->GetLogicManager(); PyObject *returnValue; if (!PyVecTo(value, toPoint)) @@ -3602,7 +3608,7 @@ KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo, PyErr_Clear(); KX_GameObject *other; - if (ConvertPythonToGameObject(value, &other, false, "")) /* error will be overwritten */ + if (ConvertPythonToGameObject(logicmgr, value, &other, false, "")) /* error will be overwritten */ { toPoint = other->NodeGetWorldPosition(); } else @@ -3704,6 +3710,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, PyObject *pyarg; float dist = 0.0f; char *propName = NULL; + SCA_LogicManager *logicmgr = GetScene()->GetLogicManager(); if (!PyArg_ParseTuple(args,"O|fs:rayCastTo", &pyarg, &dist, &propName)) { return NULL; // python sets simple error @@ -3714,7 +3721,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, KX_GameObject *other; PyErr_Clear(); - if (ConvertPythonToGameObject(pyarg, &other, false, "")) /* error will be overwritten */ + if (ConvertPythonToGameObject(logicmgr, pyarg, &other, false, "")) /* error will be overwritten */ { toPoint = other->NodeGetWorldPosition(); } else @@ -3734,7 +3741,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, if (!spc && parent) spc = parent->GetPhysicsController(); - RayCastData rayData(propName, false, (1 << OB_MAX_COL_MASKS) - 1); + RayCastData rayData(propName, false, (1u << OB_MAX_COL_MASKS) - 1); KX_RayCast::Callback<KX_GameObject, RayCastData> callback(this, spc, &rayData); if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) { return rayData.m_hitObject->GetProxy(); @@ -3820,6 +3827,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, KX_GameObject *other; int face=0, xray=0, poly=0; int mask = (1 << OB_MAX_COL_MASKS) - 1; + SCA_LogicManager *logicmgr = GetScene()->GetLogicManager(); if (!PyArg_ParseTuple(args,"O|Ofsiiii:rayCast", &pyto, &pyfrom, &dist, &propName, &face, &xray, &poly, &mask)) { return NULL; // Python sets a simple error @@ -3829,7 +3837,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, { PyErr_Clear(); - if (ConvertPythonToGameObject(pyto, &other, false, "")) /* error will be overwritten */ + if (ConvertPythonToGameObject(logicmgr, pyto, &other, false, "")) /* error will be overwritten */ { toPoint = other->NodeGetWorldPosition(); } else @@ -3846,7 +3854,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, { PyErr_Clear(); - if (ConvertPythonToGameObject(pyfrom, &other, false, "")) /* error will be overwritten */ + if (ConvertPythonToGameObject(logicmgr, pyfrom, &other, false, "")) /* error will be overwritten */ { fromPoint = other->NodeGetWorldPosition(); } else @@ -4135,7 +4143,7 @@ PyObject *KX_GameObject::Pyget(PyObject *args) return def; } -bool ConvertPythonToGameObject(PyObject *value, KX_GameObject **object, bool py_none_ok, const char *error_prefix) +bool ConvertPythonToGameObject(SCA_LogicManager *manager, PyObject *value, KX_GameObject **object, bool py_none_ok, const char *error_prefix) { if (value==NULL) { PyErr_Format(PyExc_TypeError, "%s, python pointer NULL, should never happen", error_prefix); @@ -4155,7 +4163,7 @@ bool ConvertPythonToGameObject(PyObject *value, KX_GameObject **object, bool py_ } if (PyUnicode_Check(value)) { - *object = (KX_GameObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String( _PyUnicode_AsString(value) )); + *object = (KX_GameObject*)manager->GetGameObjectByName(STR_String( _PyUnicode_AsString(value) )); if (*object) { return true; diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index a25f999026c..9c582d3e27a 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -67,7 +67,7 @@ struct bAction; #ifdef WITH_PYTHON /* utility conversion function */ -bool ConvertPythonToGameObject(PyObject *value, KX_GameObject **object, bool py_none_ok, const char *error_prefix); +bool ConvertPythonToGameObject(SCA_LogicManager *logicmgr, PyObject *value, KX_GameObject **object, bool py_none_ok, const char *error_prefix); #endif #ifdef USE_MATHUTILS diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index d96459dda7c..16d648b27b4 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1100,7 +1100,9 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene) raslight->Update(); - if (m_rasterizer->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED && raslight->HasShadowBuffer()) { + if (light->GetVisible() && m_rasterizer->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED && + raslight->HasShadowBuffer()) + { /* make temporary camera */ RAS_CameraData camdata = RAS_CameraData(); KX_Camera *cam = new KX_Camera(scene, scene->m_callbacks, camdata, true, true); diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index c98766c9c81..8da3542b4d6 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -43,6 +43,8 @@ #include "KX_PyMath.h" +#include "SCA_LogicManager.h" + #include "EXP_PyObjectPlus.h" PyTypeObject KX_MeshProxy::Type = { @@ -405,7 +407,7 @@ PyObject *KX_MeshProxy::pyattr_get_numPolygons(void *self_v, const KX_PYATTRIBUT } /* a close copy of ConvertPythonToGameObject but for meshes */ -bool ConvertPythonToMesh(PyObject *value, RAS_MeshObject **object, bool py_none_ok, const char *error_prefix) +bool ConvertPythonToMesh(SCA_LogicManager *logicmgr, PyObject *value, RAS_MeshObject **object, bool py_none_ok, const char *error_prefix) { if (value==NULL) { PyErr_Format(PyExc_TypeError, "%s, python pointer NULL, should never happen", error_prefix); @@ -425,7 +427,7 @@ bool ConvertPythonToMesh(PyObject *value, RAS_MeshObject **object, bool py_none_ } if (PyUnicode_Check(value)) { - *object = (RAS_MeshObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String( _PyUnicode_AsString(value) )); + *object = (RAS_MeshObject*)logicmgr->GetMeshByName(STR_String( _PyUnicode_AsString(value) )); if (*object) { return true; diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h index 4a4358bff3a..dbd7987f785 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.h +++ b/source/gameengine/Ketsji/KX_MeshProxy.h @@ -36,8 +36,9 @@ #include "SCA_IObject.h" +class SCA_LogicManager; /* utility conversion function */ -bool ConvertPythonToMesh(PyObject *value, class RAS_MeshObject **object, bool py_none_ok, const char *error_prefix); +bool ConvertPythonToMesh(SCA_LogicManager *logicmgr, PyObject *value, class RAS_MeshObject **object, bool py_none_ok, const char *error_prefix); class KX_MeshProxy : public CValue { diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 45436693281..8c1dee7940f 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -687,7 +687,7 @@ int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIB KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self); KX_GameObject *refOb; - if (!ConvertPythonToGameObject(value, &refOb, true, "actu.reference = value: KX_ObjectActuator")) + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &refOb, true, "actu.reference = value: KX_ObjectActuator")) return PY_SET_ATTR_FAIL; if (actuator->m_reference) diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 6ffa2593792..0b133400920 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -186,7 +186,7 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE KX_ParentActuator* actuator = static_cast<KX_ParentActuator*>(self); KX_GameObject *gameobj; - if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_ParentActuator")) + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_ParentActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (actuator->m_ob != NULL) diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index a0084662490..81fe3be1fcf 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -40,6 +40,7 @@ #include "MT_Matrix3x3.h" #include "KX_GameObject.h" // ConvertPythonToGameObject() +#include "KX_PythonInit.h" #include "EXP_PyObjectPlus.h" @@ -472,7 +473,7 @@ static PyObject* gPyGetCharacter(PyObject* self, if (!PyArg_ParseTuple(args,"O", &pyob)) return NULL; - if (!ConvertPythonToGameObject(pyob, &ob, false, "bge.constraints.getCharacter(value)")) + if (!ConvertPythonToGameObject(KX_GetActiveScene()->GetLogicManager(), pyob, &ob, false, "bge.constraints.getCharacter(value)")) return NULL; if (PHY_GetActiveEnvironment()) diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index fdcfd22270b..bb38d8269b7 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -216,7 +216,7 @@ int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYAT KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self); KX_GameObject *gameobj; - if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_SCA_AddObjectActuator")) + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_SCA_AddObjectActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (actuator->m_OriginalObject != NULL) diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 6b6b090c1c4..1bf76de0b40 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -101,7 +101,7 @@ int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYAT KX_SCA_ReplaceMeshActuator* actuator = static_cast<KX_SCA_ReplaceMeshActuator*>(self); RAS_MeshObject* new_mesh; - if (!ConvertPythonToMesh(value, &new_mesh, true, "actuator.mesh = value: KX_SCA_ReplaceMeshActuator")) + if (!ConvertPythonToMesh(actuator->GetLogicManager(), value, &new_mesh, true, "actuator.mesh = value: KX_SCA_ReplaceMeshActuator")) return PY_SET_ATTR_FAIL; actuator->m_mesh = new_mesh; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 149f0fb0168..47ba2c4343f 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1926,6 +1926,7 @@ static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *from, KX_Sce brick->Replace_IScene(to); brick->Replace_NetworkScene(to->GetNetworkScene()); + brick->SetLogicManager(to->GetLogicManager()); // If we end up replacing a KX_TouchEventManager, we need to make sure // physics controllers are properly in place. In other words, do this @@ -2542,8 +2543,8 @@ KX_PYMETHODDEF_DOC(KX_Scene, addObject, if (!PyArg_ParseTuple(args, "O|Oi:addObject", &pyob, &pyreference, &time)) return NULL; - if (!ConvertPythonToGameObject(pyob, &ob, false, "scene.addObject(object, reference, time): KX_Scene (first argument)") || - !ConvertPythonToGameObject(pyreference, &reference, true, "scene.addObject(object, reference, time): KX_Scene (second argument)")) + if (!ConvertPythonToGameObject(m_logicmgr, pyob, &ob, false, "scene.addObject(object, reference, time): KX_Scene (first argument)") || + !ConvertPythonToGameObject(m_logicmgr, pyreference, &reference, true, "scene.addObject(object, reference, time): KX_Scene (second argument)")) return NULL; if (!m_inactivelist->SearchValue(ob)) { diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.cpp b/source/gameengine/Ketsji/KX_SteeringActuator.cpp index af2a2b30b84..d3a7b665e61 100644 --- a/source/gameengine/Ketsji/KX_SteeringActuator.cpp +++ b/source/gameengine/Ketsji/KX_SteeringActuator.cpp @@ -579,7 +579,7 @@ int KX_SteeringActuator::pyattr_set_target(void *self, const struct KX_PYATTRIBU KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self); KX_GameObject *gameobj; - if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_SteeringActuator")) + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_SteeringActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (actuator->m_target != NULL) @@ -607,7 +607,7 @@ int KX_SteeringActuator::pyattr_set_navmesh(void *self, const struct KX_PYATTRIB KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self); KX_GameObject *gameobj; - if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_SteeringActuator")) + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_SteeringActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (dynamic_cast<KX_NavMeshObject *>(gameobj) == NULL) { diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 74902ab20ee..beccdfaad93 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -411,7 +411,7 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT KX_TrackToActuator* actuator = static_cast<KX_TrackToActuator*>(self); KX_GameObject *gameobj; - if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_TrackToActuator")) + if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_TrackToActuator")) return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error if (actuator->m_object != NULL) diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index ee791a44782..c1af6de127e 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -30,6 +30,7 @@ #include "KX_PyMath.h" #include "KX_GameObject.h" #include "KX_MotionState.h" +#include "KX_PythonInit.h" KX_VehicleWrapper::KX_VehicleWrapper( PHY_IVehicle* vehicle, @@ -82,7 +83,7 @@ PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args) if (PyArg_ParseTuple(args,"OOOOffi:addWheel",&wheelGameObject,&pylistPos,&pylistDir,&pylistAxleDir,&suspensionRestLength,&wheelRadius,&hasSteering)) { KX_GameObject *gameOb; - if (!ConvertPythonToGameObject(wheelGameObject, &gameOb, false, "vehicle.addWheel(...): KX_VehicleWrapper (first argument)")) + if (!ConvertPythonToGameObject(KX_GetActiveScene()->GetLogicManager(), wheelGameObject, &gameOb, false, "vehicle.addWheel(...): KX_VehicleWrapper (first argument)")) return NULL; if (gameOb->GetSGNode()) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 89806d80ea9..c79e1c23ef6 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -1895,10 +1895,10 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh *dm, for (int p2 = 0; p2 < numpolys; p2++) { MFace *mf = &mface[p2]; const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2; - RAS_Polygon *poly = meshobj->GetPolygon(origi); + RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL; // only add polygons that have the collision flag set - if (poly->IsCollider()) { + if (poly && poly->IsCollider()) { if (!vert_tag_array[mf->v1]) { vert_tag_array[mf->v1] = true; tot_bt_verts++; @@ -1930,7 +1930,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh *dm, for (int p2 = 0; p2 < numpolys; p2++) { MFace *mf = &mface[p2]; const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2; - RAS_Polygon *poly = meshobj->GetPolygon(origi); + RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL; // only add polygons that have the collisionflag set if (poly->IsCollider()) { @@ -1973,10 +1973,10 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh *dm, for (int p2 = 0; p2 < numpolys; p2++) { MFace *mf = &mface[p2]; const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2; - RAS_Polygon *poly = meshobj->GetPolygon(origi); + RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL; // only add polygons that have the collision flag set - if (poly->IsCollider()) { + if (poly && poly->IsCollider()) { if (!vert_tag_array[mf->v1]) { vert_tag_array[mf->v1] = true; vert_remap_array[mf->v1] = tot_bt_verts; @@ -2025,10 +2025,10 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh *dm, MFace *mf = &mface[p2]; MTFace *tf = (tface) ? &tface[p2] : NULL; const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2; - RAS_Polygon *poly = meshobj->GetPolygon(origi); + RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL; // only add polygons that have the collisionflag set - if (poly->IsCollider()) { + if (poly && poly->IsCollider()) { MVert *v1 = &mvert[mf->v1]; MVert *v2 = &mvert[mf->v2]; MVert *v3 = &mvert[mf->v3]; diff --git a/source/gameengine/Rasterizer/RAS_ILightObject.h b/source/gameengine/Rasterizer/RAS_ILightObject.h index 59475200a73..a3d55c925d6 100644 --- a/source/gameengine/Rasterizer/RAS_ILightObject.h +++ b/source/gameengine/Rasterizer/RAS_ILightObject.h @@ -69,6 +69,7 @@ public: float m_att1; float m_att2; + float m_coeff_const, m_coeff_lin, m_coeff_quad; float m_spotsize; float m_spotblend; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp index ff62225b496..fff988a07c5 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp @@ -59,7 +59,7 @@ RAS_OpenGLLight::~RAS_OpenGLLight() if ((lamp = GetGPULamp())) { float obmat[4][4] = {{0}}; GPU_lamp_update(lamp, 0, 0, obmat); - GPU_lamp_update_distance(lamp, la->dist, la->att1, la->att2); + GPU_lamp_update_distance(lamp, la->dist, la->att1, la->att2, la->coeff_const, la->coeff_lin, la->coeff_quad); GPU_lamp_update_spot(lamp, la->spotsize, la->spotblend); } } @@ -287,11 +287,11 @@ void RAS_OpenGLLight::Update() for (int i=0; i<4; i++) for (int j=0; j<4; j++, dobmat++) obmat[i][j] = (float)*dobmat; - - GPU_lamp_update(lamp, m_layer, 0, obmat); + int hide = kxlight->GetVisible() ? 0 : 1; + GPU_lamp_update(lamp, m_layer, hide, obmat); GPU_lamp_update_colors(lamp, m_color[0], m_color[1], m_color[2], m_energy); - GPU_lamp_update_distance(lamp, m_distance, m_att1, m_att2); + GPU_lamp_update_distance(lamp, m_distance, m_att1, m_att2, m_coeff_const, m_coeff_lin, m_coeff_quad); GPU_lamp_update_spot(lamp, m_spotsize, m_spotblend); } } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp index 08d27cbc3fc..cad5b5a508e 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp @@ -193,6 +193,11 @@ bool RAS_StorageVBO::Init() void RAS_StorageVBO::Exit() { + VBOMap::iterator it = m_vbo_lookup.begin(); + while (it != m_vbo_lookup.end()) { + delete it->second; + ++it; + } m_vbo_lookup.clear(); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h index f78faa97b16..9cb3449bed5 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h @@ -62,6 +62,8 @@ private: void* uv_offset; }; +typedef std::map<RAS_DisplayArray*, VBO*> VBOMap; + class RAS_StorageVBO : public RAS_IStorage { @@ -86,7 +88,7 @@ protected: RAS_IRasterizer::TexCoGen* m_attrib; int* m_attrib_layer; - std::map<RAS_DisplayArray*, class VBO*> m_vbo_lookup; + VBOMap m_vbo_lookup; #ifdef WITH_CXX_GUARDEDALLOC public: |