forked from bartvdbraak/blender
- rather then passing the python namespace dictionary to the controller function get the namespace from the converter.
- renamed SetPythonDictionary() to SetPyNamespace() - remove IsLight(), GetGameObjectType() existed before this but wasnt used for lights.
This commit is contained in:
parent
71b3088596
commit
8b6f5c171d
@ -375,7 +375,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw
|
||||
#ifndef DISABLE_PYTHON
|
||||
// some python things
|
||||
PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata);
|
||||
ketsjiengine->SetPythonDictionary(dictionaryobject);
|
||||
ketsjiengine->SetPyNamespace(dictionaryobject);
|
||||
initRasterizer(rasterizer, canvas);
|
||||
PyObject *gameLogic = initGameLogic(ketsjiengine, startscene);
|
||||
PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
|
||||
@ -406,9 +406,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw
|
||||
// convert and add scene
|
||||
sceneconverter->ConvertScene(
|
||||
startscene,
|
||||
#ifndef DISABLE_PYTHON
|
||||
dictionaryobject,
|
||||
#endif
|
||||
rendertools,
|
||||
canvas);
|
||||
ketsjiengine->AddScene(startscene);
|
||||
@ -702,7 +699,7 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win,
|
||||
#ifndef DISABLE_PYTHON
|
||||
// some python things
|
||||
PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata);
|
||||
ketsjiengine->SetPythonDictionary(dictionaryobject);
|
||||
ketsjiengine->SetPyNamespace(dictionaryobject);
|
||||
initRasterizer(rasterizer, canvas);
|
||||
PyObject *gameLogic = initGameLogic(ketsjiengine, startscene);
|
||||
PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module
|
||||
@ -721,9 +718,6 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win,
|
||||
// convert and add scene
|
||||
sceneconverter->ConvertScene(
|
||||
startscene,
|
||||
#ifndef DISABLE_PYTHON
|
||||
dictionaryobject,
|
||||
#endif
|
||||
rendertools,
|
||||
canvas);
|
||||
ketsjiengine->AddScene(startscene);
|
||||
|
@ -1897,9 +1897,6 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
KX_Scene* kxscene,
|
||||
KX_KetsjiEngine* ketsjiEngine,
|
||||
e_PhysicsEngine physics_engine,
|
||||
#ifndef DISABLE_PYTHON
|
||||
PyObject* pythondictionary,
|
||||
#endif
|
||||
RAS_IRenderTools* rendertools,
|
||||
RAS_ICanvas* canvas,
|
||||
KX_BlenderSceneConverter* converter,
|
||||
@ -2655,11 +2652,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
struct Object* blenderobj = gameobj->GetBlenderObject();
|
||||
int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
|
||||
bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
|
||||
BL_ConvertControllers(blenderobj,gameobj,logicmgr,
|
||||
#ifndef DISABLE_PYTHON
|
||||
pythondictionary,
|
||||
#endif
|
||||
layerMask,isInActiveLayer,converter);
|
||||
BL_ConvertControllers(blenderobj,gameobj,logicmgr, layerMask,isInActiveLayer,converter);
|
||||
}
|
||||
for ( i=0;i<logicbrick_conversionlist->GetCount();i++)
|
||||
{
|
||||
|
@ -40,9 +40,6 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
class KX_Scene* kxscene,
|
||||
class KX_KetsjiEngine* ketsjiEngine,
|
||||
e_PhysicsEngine physics_engine,
|
||||
#ifndef DISABLE_PYTHON
|
||||
PyObject* pythondictionary,
|
||||
#endif
|
||||
class RAS_IRenderTools* rendertools,
|
||||
class RAS_ICanvas* canvas,
|
||||
class KX_BlenderSceneConverter* sceneconverter,
|
||||
|
@ -243,9 +243,6 @@ struct BlenderDebugDraw : public btIDebugDraw
|
||||
#endif
|
||||
|
||||
void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
|
||||
#ifndef DISABLE_PYTHON
|
||||
PyObject* dictobj,
|
||||
#endif
|
||||
class RAS_IRenderTools* rendertools,
|
||||
class RAS_ICanvas* canvas)
|
||||
{
|
||||
@ -330,9 +327,6 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
|
||||
destinationscene,
|
||||
m_ketsjiEngine,
|
||||
physics_engine,
|
||||
#ifndef DISABLE_PYTHON
|
||||
dictobj,
|
||||
#endif
|
||||
rendertools,
|
||||
canvas,
|
||||
this,
|
||||
@ -924,3 +918,10 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
|
||||
|
||||
|
||||
}
|
||||
|
||||
#ifndef DISABLE_PYTHON
|
||||
PyObject *KX_BlenderSceneConverter::GetPyNamespace()
|
||||
{
|
||||
return m_ketsjiEngine->GetPyNamespace();
|
||||
}
|
||||
#endif
|
||||
|
@ -89,9 +89,6 @@ public:
|
||||
*/
|
||||
virtual void ConvertScene(
|
||||
class KX_Scene* destinationscene,
|
||||
#ifndef DISABLE_PYTHON
|
||||
PyObject* dictobj,
|
||||
#endif
|
||||
class RAS_IRenderTools* rendertools,
|
||||
class RAS_ICanvas* canvas
|
||||
);
|
||||
@ -145,6 +142,9 @@ public:
|
||||
|
||||
struct Main* GetMain() { return m_maggie; };
|
||||
|
||||
#ifndef DISABLE_PYTHON
|
||||
PyObject *GetPyNamespace();
|
||||
#endif
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
public:
|
||||
|
@ -92,9 +92,6 @@ void BL_ConvertControllers(
|
||||
struct Object* blenderobject,
|
||||
class KX_GameObject* gameobj,
|
||||
SCA_LogicManager* logicmgr,
|
||||
#ifndef DISABLE_PYTHON
|
||||
PyObject* pythondictionary,
|
||||
#endif
|
||||
int activeLayerBitInfo,
|
||||
bool isInActiveLayer,
|
||||
KX_BlenderSceneConverter* converter
|
||||
@ -160,10 +157,9 @@ void BL_ConvertControllers(
|
||||
bPythonCont* pycont = (bPythonCont*) bcontr->data;
|
||||
SCA_PythonController* pyctrl = new SCA_PythonController(gameobj, pycont->mode);
|
||||
gamecontroller = pyctrl;
|
||||
|
||||
#ifndef DISABLE_PYTHON
|
||||
|
||||
pyctrl->SetDictionary(pythondictionary);
|
||||
pyctrl->SetNamespace(converter->GetPyNamespace());
|
||||
|
||||
if(pycont->mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) {
|
||||
if (pycont->text)
|
||||
|
@ -35,9 +35,6 @@ void BL_ConvertControllers(
|
||||
struct Object* blenderobject,
|
||||
class KX_GameObject* gameobj,
|
||||
class SCA_LogicManager* logicmgr,
|
||||
#ifndef DISABLE_PYTHON
|
||||
PyObject* pythondictionary,
|
||||
#endif
|
||||
int activeLayerBitInfo,
|
||||
bool isInActiveLayer,
|
||||
class KX_BlenderSceneConverter* converter
|
||||
|
@ -219,6 +219,7 @@ public:
|
||||
typedef enum ObjectTypes {
|
||||
OBJ_ARMATURE=0,
|
||||
OBJ_CAMERA=1,
|
||||
OBJ_LIGHT=2,
|
||||
}ObjectTypes;
|
||||
|
||||
};
|
||||
|
@ -151,7 +151,7 @@ void SCA_PythonController::SetScriptName(const STR_String& name)
|
||||
|
||||
|
||||
#ifndef DISABLE_PYTHON
|
||||
void SCA_PythonController::SetDictionary(PyObject* pythondictionary)
|
||||
void SCA_PythonController::SetNamespace(PyObject* pythondictionary)
|
||||
{
|
||||
if (m_pythondictionary)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ class SCA_PythonController : public SCA_IController
|
||||
void SetScriptText(const STR_String& text);
|
||||
void SetScriptName(const STR_String& name);
|
||||
#ifndef DISABLE_PYTHON
|
||||
void SetDictionary(PyObject* pythondictionary);
|
||||
void SetNamespace(PyObject* pythondictionary);
|
||||
#endif
|
||||
void SetDebug(bool debug) { m_debug = debug; }
|
||||
void AddTriggeredSensor(class SCA_ISensor* sensor)
|
||||
|
@ -679,7 +679,7 @@ bool GPG_Application::startEngine(void)
|
||||
|
||||
// some python things
|
||||
PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest, m_maggie, m_argc, m_argv);
|
||||
m_ketsjiengine->SetPythonDictionary(dictionaryobject);
|
||||
m_ketsjiengine->SetPyNamespace(dictionaryobject);
|
||||
initRasterizer(m_rasterizer, m_canvas);
|
||||
PyObject *gameLogic = initGameLogic(m_ketsjiengine, startscene);
|
||||
PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module
|
||||
@ -702,7 +702,6 @@ bool GPG_Application::startEngine(void)
|
||||
|
||||
m_sceneconverter->ConvertScene(
|
||||
startscene,
|
||||
dictionaryobject,
|
||||
m_rendertools,
|
||||
m_canvas);
|
||||
m_ketsjiengine->AddScene(startscene);
|
||||
|
@ -748,14 +748,6 @@ public:
|
||||
void
|
||||
) { return m_bIsNegativeScaling; }
|
||||
|
||||
/**
|
||||
* Is this a light?
|
||||
*/
|
||||
virtual bool
|
||||
IsLight(
|
||||
void
|
||||
) { return false; }
|
||||
|
||||
/**
|
||||
* @section Logic bubbling methods.
|
||||
*/
|
||||
|
@ -53,9 +53,6 @@ public:
|
||||
*/
|
||||
virtual void ConvertScene(
|
||||
class KX_Scene* destinationscene,
|
||||
#ifndef DISABLE_PYTHON
|
||||
PyObject* dictobj,
|
||||
#endif
|
||||
class RAS_IRenderTools* rendertools,
|
||||
class RAS_ICanvas* canvas)=0;
|
||||
|
||||
|
@ -238,7 +238,7 @@ void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer)
|
||||
* At the moment the GameLogic module is imported into 'pythondictionary' after this function is called.
|
||||
* if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand.
|
||||
*/
|
||||
void KX_KetsjiEngine::SetPythonDictionary(PyObject* pythondictionary)
|
||||
void KX_KetsjiEngine::SetPyNamespace(PyObject* pythondictionary)
|
||||
{
|
||||
MT_assert(pythondictionary);
|
||||
m_pythondictionary = pythondictionary;
|
||||
@ -1618,9 +1618,6 @@ KX_Scene* KX_KetsjiEngine::CreateScene(const STR_String& scenename)
|
||||
scene);
|
||||
|
||||
m_sceneconverter->ConvertScene(tmpscene,
|
||||
#ifndef DISABLE_PYTHON
|
||||
m_pythondictionary,
|
||||
#endif
|
||||
m_rendertools,
|
||||
m_canvas);
|
||||
|
||||
|
@ -204,7 +204,8 @@ public:
|
||||
void SetRenderTools(RAS_IRenderTools* rendertools);
|
||||
void SetRasterizer(RAS_IRasterizer* rasterizer);
|
||||
#ifndef DISABLE_PYTHON
|
||||
void SetPythonDictionary(PyObject* pythondictionary);
|
||||
void SetPyNamespace(PyObject* pythondictionary);
|
||||
PyObject* GetPyNamespace(){return m_pythondictionary;};
|
||||
#endif
|
||||
void SetSceneConverter(KX_ISceneConverter* sceneconverter);
|
||||
void SetGame2IpoMode(bool game2ipo,int startFrame);
|
||||
|
@ -65,6 +65,8 @@ public:
|
||||
void UnbindShadowBuffer(class RAS_IRasterizer *ras);
|
||||
void Update();
|
||||
|
||||
virtual int GetGameObjectType() { return OBJ_LIGHT; }
|
||||
|
||||
#ifndef DISABLE_PYTHON
|
||||
/* attributes */
|
||||
static PyObject* pyattr_get_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
@ -73,8 +75,6 @@ public:
|
||||
static PyObject* pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static int pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value);
|
||||
#endif
|
||||
|
||||
virtual bool IsLight(void) { return true; }
|
||||
};
|
||||
|
||||
#endif //__KX_LIGHT
|
||||
|
@ -477,7 +477,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
|
||||
|
||||
// this is the list of object that are send to the graphics pipeline
|
||||
m_objectlist->Add(newobj->AddRef());
|
||||
if (newobj->IsLight())
|
||||
if (newobj->GetGameObjectType()==SCA_IObject::OBJ_LIGHT)
|
||||
m_lightlist->Add(newobj->AddRef());
|
||||
newobj->AddMeshUser();
|
||||
|
||||
@ -753,7 +753,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
|
||||
// add the object in the layer of the parent
|
||||
(*git)->SetLayer(groupobj->GetLayer());
|
||||
// If the object was a light, we need to update it's RAS_LightObject as well
|
||||
if ((*git)->IsLight())
|
||||
if ((*git)->GetGameObjectType()==SCA_IObject::OBJ_LIGHT)
|
||||
{
|
||||
KX_LightObject* lightobj = static_cast<KX_LightObject*>(*git);
|
||||
lightobj->GetLightData()->m_layer = groupobj->GetLayer();
|
||||
@ -861,7 +861,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
|
||||
// add the object in the layer of the parent
|
||||
(*git)->SetLayer(parentobj->GetLayer());
|
||||
// If the object was a light, we need to update it's RAS_LightObject as well
|
||||
if ((*git)->IsLight())
|
||||
if ((*git)->GetGameObjectType()==SCA_IObject::OBJ_LIGHT)
|
||||
{
|
||||
KX_LightObject* lightobj = static_cast<KX_LightObject*>(*git);
|
||||
lightobj->GetLightData()->m_layer = parentobj->GetLayer();
|
||||
@ -982,7 +982,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
|
||||
|
||||
newobj->RemoveMeshes();
|
||||
ret = 1;
|
||||
if (newobj->IsLight() && m_lightlist->RemoveValue(newobj))
|
||||
if (newobj->GetGameObjectType()==SCA_IObject::OBJ_LIGHT && m_lightlist->RemoveValue(newobj))
|
||||
ret = newobj->Release();
|
||||
if (m_objectlist->RemoveValue(newobj))
|
||||
ret = newobj->Release();
|
||||
|
Loading…
Reference in New Issue
Block a user