BGE PhysicsConstraints.exportBulletFile improvement: also export the object names to .bullet files.
This commit is contained in:
@@ -524,4 +524,15 @@ bool KX_BulletPhysicsController::Update(double time)
|
|||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* KX_BulletPhysicsController::getName()
|
||||||
|
{
|
||||||
|
if (m_pObject)
|
||||||
|
{
|
||||||
|
KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject();
|
||||||
|
return gameobj->GetName();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // USE_BULLET
|
#endif // USE_BULLET
|
||||||
|
@@ -80,6 +80,8 @@ public:
|
|||||||
virtual bool Update(double time);
|
virtual bool Update(double time);
|
||||||
void* GetUserData() { return m_userdata;}
|
void* GetUserData() { return m_userdata;}
|
||||||
|
|
||||||
|
virtual const char* getName();
|
||||||
|
|
||||||
void
|
void
|
||||||
SetOption(
|
SetOption(
|
||||||
int option,
|
int option,
|
||||||
|
@@ -577,6 +577,10 @@ protected:
|
|||||||
return m_parentCtrl;
|
return m_parentCtrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual const char* getName()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WITH_CXX_GUARDEDALLOC
|
#ifdef WITH_CXX_GUARDEDALLOC
|
||||||
public:
|
public:
|
||||||
|
@@ -2797,8 +2797,26 @@ float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid)
|
|||||||
void CcdPhysicsEnvironment::exportFile(const char* filename)
|
void CcdPhysicsEnvironment::exportFile(const char* filename)
|
||||||
{
|
{
|
||||||
btDefaultSerializer* serializer = new btDefaultSerializer();
|
btDefaultSerializer* serializer = new btDefaultSerializer();
|
||||||
m_dynamicsWorld->serialize(serializer);
|
|
||||||
|
|
||||||
|
|
||||||
|
for (int i=0;i<m_dynamicsWorld->getNumCollisionObjects();i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
||||||
|
|
||||||
|
CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(colObj->getUserPointer());
|
||||||
|
if (controller)
|
||||||
|
{
|
||||||
|
const char* name = controller->getName();
|
||||||
|
if (name)
|
||||||
|
{
|
||||||
|
serializer->registerNameForPointer(colObj,name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_dynamicsWorld->serialize(serializer);
|
||||||
|
|
||||||
FILE* file = fopen(filename,"wb");
|
FILE* file = fopen(filename,"wb");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user