MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xPartitionWorld

Function xPartitionWorld

src/SB/Core/x/xPartition.cpp:81–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void xPartitionWorld(_tagPartition* part, xEnv* env, S32 x_spaces, S32 y_spaces, S32 z_spaces)
82{
83 memset(part, 0, sizeof(_tagPartition));
84 xBox* bb = (xBox*)xEnvGetBBox(env);
85 part->min = bb->lower;
86 part->max = bb->upper;
87
88 F32 dx = part->max.x - part->min.x;
89 F32 dy = part->max.y - part->min.y;
90 F32 dz = part->max.z - part->min.z;
91
92 part->total_x = x_spaces;
93 part->total_y = y_spaces;
94 part->total_z = z_spaces;
95
96 part->space_dim.x = dx / part->total_x;
97 part->space_dim.y = dy / part->total_y;
98 part->space_dim.z = dz / part->total_z;
99
100 part->space = (_tagPartSpace*)xMemAlloc(
101 gActiveHeap, sizeof(_tagPartSpace) * part->total_x * part->total_y * part->total_z, 0);
102
103 for (S32 z = 0; z < z_spaces; z++)
104 {
105 for (S32 y = 0; y < y_spaces; y++)
106 {
107 for (S32 x = 0; x < x_spaces; x++)
108 {
109 S32 idx = xPartitionGetTrueIdx(part, x, y, z);
110 PartitionSpaceReset(&part->space[idx]);
111 }
112 }
113 }
114
115 PartitionSpaceReset(&part->global);
116}
117
118S32 xPartitionInsert(_tagPartition* part, void* insert_data, xVec3* insert_pos)
119{

Callers 1

zLightResetAllFunction · 0.50

Calls 5

memsetFunction · 0.85
xEnvGetBBoxFunction · 0.85
xPartitionGetTrueIdxFunction · 0.85
PartitionSpaceResetFunction · 0.85
xMemAllocFunction · 0.70

Tested by

no test coverage detected