flexbody_replay.patch
| source/main/Beam.cpp (working copy) | ||
|---|---|---|
| 6420 | 6420 |
beams[i].broken = bbuff[i].broken; |
| 6421 | 6421 |
beams[i].disabled = bbuff[i].disabled; |
| 6422 | 6422 |
} |
| 6423 | ||
| 6424 |
// restore blendmap of flexbodies |
|
| 6425 |
if(free_flexbody>0) |
|
| 6426 |
{
|
|
| 6427 |
ARGB *bbuff = (ARGB *)replay->getReadBuffer(replaypos, 2, time); |
|
| 6428 |
ARGB *ptr = bbuff; |
|
| 6429 |
for(int i=0;i<free_flexbody;i++) |
|
| 6430 |
{
|
|
| 6431 |
size_t size = flexbodies[i]->getBlendMapSize(); |
|
| 6432 |
ARGB *dst = flexbodies[i]->getBlendMap(); |
|
| 6433 |
memcpy(dst, bbuff, size * sizeof(ARGB)); |
|
| 6434 |
flexbodies[i]->writeBlend(); |
|
| 6435 |
ptr += size; |
|
| 6436 |
} |
|
| 6437 |
} |
|
| 6438 | ||
| 6423 | 6439 |
//LogManager::getSingleton().logMessage("replay: " + StringConverter::toString(time));
|
| 6424 | 6440 |
oldreplaypos = replaypos; |
| 6425 | 6441 |
} |
| ... | ... | |
| 9150 | 9166 |
bbuff[i].disabled = beams[i].disabled; |
| 9151 | 9167 |
} |
| 9152 | 9168 | |
| 9169 |
// store blendmap of flexbodies |
|
| 9170 |
if(free_flexbody>0) |
|
| 9171 |
{
|
|
| 9172 |
ARGB *bbuff = (ARGB *)replay->getWriteBuffer(2); |
|
| 9173 |
ARGB *ptr = bbuff; |
|
| 9174 |
for(int i=0;i<free_flexbody;i++) |
|
| 9175 |
{
|
|
| 9176 |
size_t size = flexbodies[i]->getBlendMapSize(); |
|
| 9177 |
ARGB *src = flexbodies[i]->getBlendMap(); |
|
| 9178 |
memcpy(bbuff, src, size * sizeof(ARGB)); |
|
| 9179 |
ptr += size; |
|
| 9180 |
} |
|
| 9181 |
} |
|
| 9182 | ||
| 9153 | 9183 |
replay->writeDone(); |
| 9154 | 9184 |
replayTimer = 0.0f; |
| 9155 | 9185 |
} |
| ... | ... | |
| 10108 | 10138 |
//updateDebugOverlay(); |
| 10109 | 10139 |
} |
| 10110 | 10140 |
//Flex body |
| 10111 |
for (i=0; i<free_flexbody; i++) flexbodies[i]->flexit(); |
|
| 10141 |
for (i=0; i<free_flexbody; i++) flexbodies[i]->flexit(!replaymode);
|
|
| 10112 | 10142 | |
| 10113 | 10143 |
if (netLabelNode && netMT && netMT->isVisible()) |
| 10114 | 10144 |
{
|
| source/main/FlexBody.cpp (working copy) | ||
|---|---|---|
| 256 | 256 |
dstpos=(Vector3*)ror_malloc(sizeof(Vector3)*vertex_count); |
| 257 | 257 |
srcnormals=(Vector3*)ror_malloc(sizeof(Vector3)*vertex_count); |
| 258 | 258 |
dstnormals=(Vector3*)ror_malloc(sizeof(Vector3)*vertex_count); |
| 259 |
srccolors=0; |
|
| 259 | 260 |
if (haveblend) |
| 260 | 261 |
{
|
| 261 | 262 |
srccolors=(ARGB*)ror_malloc(sizeof(ARGB)*vertex_count); |
| ... | ... | |
| 578 | 579 |
return false; |
| 579 | 580 |
} |
| 580 | 581 | |
| 581 |
Vector3 FlexBody::flexit() |
|
| 582 |
Vector3 FlexBody::flexit(bool updateBlendMap)
|
|
| 582 | 583 |
{
|
| 583 |
if (haveblend) updateBlend(); |
|
| 584 |
if (haveblend && updateBlendMap) updateBlend();
|
|
| 584 | 585 |
//compute the local center |
| 585 | 586 | |
| 586 | 587 |
Vector3 normal; |
| source/main/FlexBody.h (working copy) | ||
|---|---|---|
| 105 | 105 |
bool isinset(int n); |
| 106 | 106 |
void printMeshInfo(Mesh* mesh); |
| 107 | 107 |
void setVisible(bool visible); |
| 108 |
Vector3 flexit(); |
|
| 108 |
Vector3 flexit(bool updateBlendMap=true);
|
|
| 109 | 109 |
void reset(); |
| 110 | 110 |
void updateBlend(); |
| 111 | 111 |
void writeBlend(); |
| 112 | 112 |
SceneNode *getSceneNode() { return snode; };
|
| 113 |
|
|
| 114 |
|
|
| 115 |
ARGB *getBlendMap() { return srccolors; };
|
|
| 116 |
size_t getBlendMapSize() { return vertex_count; };
|
|
| 113 | 117 |
}; |
| 114 | 118 | |
| 115 | 119 | |
| source/main/Replay.cpp (working copy) | ||
|---|---|---|
| 25 | 25 |
#endif // MYGUI |
| 26 | 26 |
#include "rormemory.h" |
| 27 | 27 |
#include "language.h" |
| 28 |
#include "FlexBody.h" |
|
| 28 | 29 | |
| 29 | 30 |
using namespace Ogre; |
| 30 | 31 | |
| ... | ... | |
| 32 | 33 |
{
|
| 33 | 34 |
numNodes = b->getNodeCount(); |
| 34 | 35 |
numBeams = b->getBeamCount(); |
| 36 |
|
|
| 37 |
blendMapSize = 0; |
|
| 38 |
if(b->free_flexbody>0) |
|
| 39 |
{
|
|
| 40 |
for(int i=0;i<b->free_flexbody;i++) |
|
| 41 |
blendMapSize += b->flexbodies[i]->getBlendMapSize(); |
|
| 42 |
} |
|
| 35 | 43 |
numFrames = _numFrames; |
| 36 | 44 | |
| 37 | 45 |
replayTimer = new Timer(); |
| ... | ... | |
| 39 | 47 |
// DO NOT get memory here, get memory when we use it first time! |
| 40 | 48 |
nodes = 0; |
| 41 | 49 |
beams = 0; |
| 50 |
blendmap = 0; |
|
| 42 | 51 |
times = 0; |
| 43 | 52 | |
| 44 | 53 |
unsigned long bsize = (numNodes * numFrames * sizeof(node_simple_t) + numBeams * numFrames * sizeof(beam_simple_t) + numFrames * sizeof(unsigned long)) / 1024.0f; |
| ... | ... | |
| 76 | 85 |
{
|
| 77 | 86 |
ror_free(nodes); nodes=0; |
| 78 | 87 |
ror_free(beams); beams=0; |
| 88 |
ror_free(blendmap); blendmap=0; |
|
| 79 | 89 |
ror_free(times); times=0; |
| 80 | 90 |
} |
| 81 | 91 |
delete replayTimer; |
| ... | ... | |
| 87 | 97 |
{
|
| 88 | 98 |
// get memory |
| 89 | 99 |
nodes = (node_simple_t*)ror_calloc(numNodes * numFrames, sizeof(node_simple_t)); |
| 90 |
beams = (beam_simple_t*)ror_calloc(numBeams * numFrames, sizeof(beam_simple_t)); |
|
| 100 |
beams = (beam_simple_t*)ror_calloc(numBeams * numFrames, sizeof(beam_simple_t)); |
|
| 101 |
blendmap = (ARGB*)ror_calloc(blendMapSize * numFrames, sizeof(ARGB)); |
|
| 91 | 102 |
times = (unsigned long*)ror_calloc(numFrames, sizeof(unsigned long)); |
| 92 | 103 |
} |
| 93 | 104 |
void *ptr = 0; |
| ... | ... | |
| 100 | 111 |
{
|
| 101 | 112 |
// beams |
| 102 | 113 |
ptr = (void *)(beams + (writeIndex * numBeams)); |
| 114 |
}else if(type == 2) |
|
| 115 |
{
|
|
| 116 |
// blendmap |
|
| 117 |
ptr = (void *)(blendmap + (writeIndex * blendMapSize)); |
|
| 103 | 118 |
} |
| 104 | 119 |
return ptr; |
| 105 | 120 |
} |
| ... | ... | |
| 140 | 155 |
return (void *)(nodes + delta * numNodes); |
| 141 | 156 |
else if(type == 1) |
| 142 | 157 |
return (void *)(beams + delta * numBeams); |
| 158 |
else if(type == 2) |
|
| 159 |
return (void *)(blendmap + delta * blendMapSize); |
|
| 143 | 160 |
return 0; |
| 144 | 161 |
} |
| 145 | 162 | |
| source/main/Replay.h (working copy) | ||
|---|---|---|
| 58 | 58 |
Ogre::Timer *replayTimer; |
| 59 | 59 |
int numNodes; |
| 60 | 60 |
int numBeams; |
| 61 |
size_t blendMapSize; |
|
| 61 | 62 |
int numFrames; |
| 62 | 63 | |
| 63 | 64 | |
| ... | ... | |
| 69 | 70 |
// malloc'ed |
| 70 | 71 |
node_simple_t *nodes; |
| 71 | 72 |
beam_simple_t *beams; |
| 73 |
ARGB *blendmap; |
|
| 72 | 74 |
unsigned long *times; |
| 73 | 75 | |
| 74 | 76 |
#ifdef USE_MYGUI |