[IPhyCollmap] Fix plane writing

This commit is contained in:
momo5502 2017-03-18 15:19:31 +01:00
parent 649605551d
commit 5b0b14a5f5
2 changed files with 28 additions and 32 deletions

View File

@ -13,22 +13,22 @@ namespace Assets
// Save_cbrushWrapper_t // Save_cbrushWrapper_t
{ {
AssertSize(Game::cbrushWrapper_t, 36); AssertSize(Game::cbrush_t, 36);
if (brush->brush.brushSide) if (brush->brush.sides)
{ {
AssertSize(Game::cbrushside_t, 8); AssertSize(Game::cbrushside_t, 8);
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
Game::cbrushside_t* destBrushSide = buffer->dest<Game::cbrushside_t>(); Game::cbrushside_t* destBrushSide = buffer->dest<Game::cbrushside_t>();
buffer->saveArray(brush->brush.brushSide, brush->brush.count); buffer->saveArray(brush->brush.sides, brush->brush.numsides);
// Save_cbrushside_tArray // Save_cbrushside_tArray
for (short i = 0; i < brush->brush.count; ++i) for (unsigned short i = 0; i < brush->brush.numsides; ++i)
{ {
Game::cbrushside_t* destSide = &destBrushSide[i]; Game::cbrushside_t* destSide = &destBrushSide[i];
Game::cbrushside_t* side = &brush->brush.brushSide[i]; Game::cbrushside_t* side = &brush->brush.sides[i];
if (side->plane) if (side->plane)
{ {
@ -47,13 +47,13 @@ namespace Assets
} }
} }
Utils::Stream::ClearPointer(&destBrush->brush.brushSide); Utils::Stream::ClearPointer(&destBrush->brush.sides);
} }
if (brush->brush.brushEdge) if (brush->brush.baseAdjacentSide)
{ {
buffer->save(brush->brush.brushEdge, brush->totalEdgeCount); buffer->save(brush->brush.baseAdjacentSide, brush->totalEdgeCount);
Utils::Stream::ClearPointer(&destBrush->brush.brushEdge); Utils::Stream::ClearPointer(&destBrush->brush.baseAdjacentSide);
} }
} }
@ -63,14 +63,19 @@ namespace Assets
if (builder->hasPointer(brush->planes)) if (builder->hasPointer(brush->planes))
{ {
Components::Logger::Print("Loading cplane pointer before the array has been written. Not sure if this is correct!\n");
destBrush->planes = builder->getPointer(brush->planes); destBrush->planes = builder->getPointer(brush->planes);
} }
else else
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
builder->storePointer(brush->planes);
buffer->save(brush->planes, sizeof(Game::cplane_t)); for (unsigned short j = 0; j < brush->brush.numsides; ++j)
{
builder->storePointer(&brush->planes[j]);
buffer->save(&brush->planes[j]);
}
Utils::Stream::ClearPointer(&destBrush->planes); Utils::Stream::ClearPointer(&destBrush->planes);
} }
} }

View File

@ -1350,8 +1350,8 @@ namespace Game
struct Bounds struct Bounds
{ {
vec3_t midPoint; vec3_t midPoint; // mins
vec3_t halfSize; vec3_t halfSize; // maxs
}; };
struct TriggerModel struct TriggerModel
@ -1700,20 +1700,22 @@ namespace Game
char edgeCount; char edgeCount;
}; };
struct cbrushWrapper_t struct cbrush_t
{ {
short count; unsigned __int16 numsides;
cbrushside_t* brushSide; unsigned __int16 glassPieceIndex;
char * brushEdge; cbrushside_t *sides;
char pad[24]; char *baseAdjacentSide;
__int16 axialMaterialNum[2][3];
char firstAdjacentSideOffsets[2][3];
char edgeCount[2][3];
}; };
#pragma pack(push, 4) #pragma pack(push, 4)
struct BrushWrapper struct BrushWrapper
{ {
float mins[3]; Bounds bounds;
float maxs[3]; cbrush_t brush;
cbrushWrapper_t brush;
int totalEdgeCount; int totalEdgeCount;
cplane_t *planes; cplane_t *planes;
}; };
@ -2465,17 +2467,6 @@ namespace Game
short children[2]; short children[2];
}; };
struct cbrush_t
{
unsigned __int16 numsides;
unsigned __int16 glassPieceIndex;
cbrushside_t *sides;
char *baseAdjacentSide;
__int16 axialMaterialNum[2][3];
char firstAdjacentSideOffsets[2][3];
char edgeCount[2][3];
};
struct cLeaf_t struct cLeaf_t
{ {
unsigned __int16 firstCollAabbIndex; unsigned __int16 firstCollAabbIndex;