我正在调查PhysX,我一直坚持序列化。当我尝试序列化一个关节时,反序列化失败并出现错误:
code: 8
message: NpActorTemplate::resolvePointers: connector not found.
file: ..\..\PhysX\src\NpActor.cpp
line: 95
但是没有关节它可以正常工作并反序列化所有对象。是否需要正确序列化关节?代码的序列化部分是:
material1->collectForExport(*collection);
material->collectForExport(*collection);
mesh->collectForExport(*collection);
for (__int8 i = 0; i < 4; ++i)
{
actors[i]->collectForExport(*collection);
aggregate->addActor(*actors[i]);
}
aggregate->collectForExport(*collection);
joints[0] = PxD6JointCreate(*physics, actors[0], PxTransform(PxVec3(2, -.5f, 0)), actors[1], PxTransform(PxVec3(0)));
PxD6JointDrive drive(1000, 100, PX_MAX_F32, true);
joints[0]->setMotion(PxD6Axis::eX, PxD6Motion::eFREE);
joints[0]->setMotion(PxD6Axis::eY, PxD6Motion::eFREE);
joints[0]->setMotion(PxD6Axis::eZ, PxD6Motion::eFREE);
joints[0]->setDrive(PxD6Drive::eX, drive);
joints[0]->setDrive(PxD6Drive::eY, drive);
joints[0]->setDrive(PxD6Drive::eZ, drive);
joints[0]->setDrivePosition(PxTransform(PxVec3(2, -.5f, 0)));
joints[0]->setDriveVelocity(PxVec3(0), PxVec3(0));
for (__int8 i = 0; i < 1; ++i)
{
joints[i]->collectForExport(*collection);
}
反序列化:
_pxBuffer = _aligned_malloc(length, PX_SERIAL_FILE_ALIGN);
//filling the buffer here
_pxCollection = pxContext->GetPhysics()->createCollection();
_pxCollection->deserialize(_pxBuffer, 0, 0);