|
|
@ -264,22 +264,27 @@ static void world_sortModels(const world_t *world) |
|
|
for (u_short modelIdx = 1; modelIdx < world->numModels; ++modelIdx) |
|
|
for (u_short modelIdx = 1; modelIdx < world->numModels; ++modelIdx) |
|
|
{ |
|
|
{ |
|
|
ps1bsp_model_t* model = (ps1bsp_model_t*)&world->models[modelIdx]; |
|
|
ps1bsp_model_t* model = (ps1bsp_model_t*)&world->models[modelIdx]; |
|
|
|
|
|
ps1bsp_leaf_t* leaf = (ps1bsp_leaf_t*)model->currentLeaf; |
|
|
|
|
|
|
|
|
// TODO: refence leaf in model, update only when model moves |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the model's current leaf. This only needs to be done when the model moves. |
|
|
|
|
|
if (leaf == NULL) |
|
|
|
|
|
{ |
|
|
VECTOR pos; |
|
|
VECTOR pos; |
|
|
pos.vx = model->origin.vx + model->boundingSphere.vx; |
|
|
pos.vx = model->origin.vx + model->boundingSphere.vx; |
|
|
pos.vy = model->origin.vy + model->boundingSphere.vy; |
|
|
pos.vy = model->origin.vy + model->boundingSphere.vy; |
|
|
pos.vz = model->origin.vz + model->boundingSphere.vz; |
|
|
pos.vz = model->origin.vz + model->boundingSphere.vz; |
|
|
|
|
|
|
|
|
short leafIdx = world_leafAtPoint(world, &pos); |
|
|
short leafIdx = world_leafAtPoint(world, &pos); |
|
|
if (leafIdx >= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
ps1bsp_leaf_t *leaf = (ps1bsp_leaf_t*)&world->leaves[leafIdx]; |
|
|
|
|
|
|
|
|
if (leafIdx <= 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
leaf = (ps1bsp_leaf_t*)&world->leaves[leafIdx]; |
|
|
|
|
|
model->currentLeaf = leaf; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
model->nextModel = leaf->models; |
|
|
model->nextModel = leaf->models; |
|
|
leaf->models = model; |
|
|
leaf->models = model; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static ps1bsp_leaf_t *world_sortLeafs(const world_t *world, short startNode, u_char *pvs) |
|
|
static ps1bsp_leaf_t *world_sortLeafs(const world_t *world, short startNode, u_char *pvs) |
|
|
|