Jump to content

[SOLVED] Replay occasionally not saving/loading proper enabled/hidden state of meshes..


photo

Recommended Posts

Hello,

 

I have a kind of replay system working for our game using the physics scene save/load system. It works out well now, but I noticed that when the cannonball destroys the crates sometimes it does not replay correctly. It shows the cannonball knocking the crate away, but the crate does not disappear. The particle effect still plays at the correct location, however. Is there any way to guarantee the proper render state of objects when saving/loading physics scenes? Both saving and loading physics scenes are done in the flush function for my implementation.

 

-Chris

Link to comment

I will add the object enable flag into the physical scene state.

You can patch your engine by the following code:

source/engine/physics/bodies/Body.cpp

#include "Bits.h"
int Body::saveScene(const Stream &stream) const {
int flags = 0;
if(enabled) flags |= BIT_SET(0);
if(isFrozen()) flags |= BIT_SET(1);
if(isGravity()) flags |= BIT_SET(2);
if(object && object->isEnabled()) flags |= BIT_SET(3);
stream.writeUChar(flags);
return 1;
}

int Body::restoreScene(const Stream &stream) {
int flags = stream.readUChar();
setEnabled(BIT_GET(flags,0);
setFrozen(BIT_GET(flags,1));
setGravity(BIT_GET(flags,2));
if(object) object->setEnabled(BIT_GET(flags,3));
return 1;
}

Link to comment
×
×
  • Create New...