mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-25 20:02:33 +01:00
- slight cell lookup changes
This commit is contained in:
parent
265a2b3a70
commit
5e975d1854
@ -286,9 +286,7 @@ int CameraCollisionCheck(void)
|
||||
|
||||
if (gCameraDistance > 0)
|
||||
{
|
||||
ppco = GetFirstPackedCop(cellx, cellz, &ci, 0, cellLevel);
|
||||
|
||||
while (ppco)
|
||||
for (ppco = GetFirstPackedCop(cellx, cellz, &ci, 0, cellLevel); ppco; ppco = GetNextPackedCop(&ci))
|
||||
{
|
||||
int type = (ppco->value >> 6) | ((ppco->pos.vy & 1) << 10);
|
||||
|
||||
@ -349,7 +347,6 @@ int CameraCollisionCheck(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
ppco = GetNextPackedCop(&ci);
|
||||
}
|
||||
}
|
||||
count++;
|
||||
|
@ -7,7 +7,7 @@
|
||||
int cell_object_index = 0;
|
||||
CELL_OBJECT cell_object_buffer[1024];
|
||||
|
||||
unsigned char cell_object_computed_values[2048];
|
||||
u_char cell_object_computed_values[2048];
|
||||
|
||||
extern u_char NumPlayers;
|
||||
|
||||
@ -69,11 +69,11 @@ PACKED_CELL_OBJECT * GetFirstPackedCop(int cellx, int cellz, CELL_ITERATOR *pci,
|
||||
8767,555,445,223 - objects of list 2
|
||||
0x8000 - end of cell objects
|
||||
*/
|
||||
|
||||
while (cell->num != (level | 0x4000)) // skip until we reach the needed list header
|
||||
|
||||
level |= 0x4000;
|
||||
while (cell->num != level) // skip until we reach the needed list header
|
||||
{
|
||||
cell++;
|
||||
|
||||
if (cell->num & 0x8000) // end of cell objects?
|
||||
return NULL;
|
||||
}
|
||||
@ -86,8 +86,8 @@ PACKED_CELL_OBJECT * GetFirstPackedCop(int cellx, int cellz, CELL_ITERATOR *pci,
|
||||
|
||||
pci->pcd = cell;
|
||||
|
||||
num = cell->num;
|
||||
ppco = &cell_objects[num & 0x3fff];
|
||||
num = cell->num & 16383;
|
||||
ppco = &cell_objects[num];
|
||||
|
||||
if (ppco->value == 0xffff && (ppco->pos.vy & 1))
|
||||
{
|
||||
@ -95,9 +95,9 @@ PACKED_CELL_OBJECT * GetFirstPackedCop(int cellx, int cellz, CELL_ITERATOR *pci,
|
||||
}
|
||||
else if (use_computed)
|
||||
{
|
||||
value = 1 << (num & 7) & 0xffff;
|
||||
value = 1 << (num & 7);
|
||||
|
||||
if (cell_object_computed_values[(num & 0x3fff) >> 3] & value) // get cached value
|
||||
if (cell_object_computed_values[num / 8] & value) // get cached value
|
||||
{
|
||||
ppco = GetNextPackedCop(pci);
|
||||
pci->ppco = ppco;
|
||||
@ -105,7 +105,7 @@ PACKED_CELL_OBJECT * GetFirstPackedCop(int cellx, int cellz, CELL_ITERATOR *pci,
|
||||
return ppco;
|
||||
}
|
||||
|
||||
cell_object_computed_values[(num & 0x3fff) >> 3] |= value;
|
||||
cell_object_computed_values[num / 8] |= value;
|
||||
}
|
||||
|
||||
pci->ppco = ppco;
|
||||
@ -135,20 +135,19 @@ PACKED_CELL_OBJECT* GetNextPackedCop(CELL_ITERATOR* pci)
|
||||
if (num & 0x4000) // end of list?
|
||||
return NULL;
|
||||
|
||||
ppco = &cell_objects[num & 0x3fff];
|
||||
num &= 16383;
|
||||
ppco = &cell_objects[num];
|
||||
} while (ppco->value == 0xffff && (ppco->pos.vy & 1));
|
||||
|
||||
if (!pci->use_computed)
|
||||
break;
|
||||
|
||||
value = 1 << (num & 7) & 0xffff;
|
||||
|
||||
if ((cell_object_computed_values[(num & 0x3fff) >> 3] & value) == 0)
|
||||
value = 1 << (num & 7);
|
||||
if ((cell_object_computed_values[num / 8] & value) == 0)
|
||||
{
|
||||
cell_object_computed_values[(num & 0x3fff) >> 3] |= value;
|
||||
cell_object_computed_values[num / 8] |= value;
|
||||
break;
|
||||
}
|
||||
|
||||
} while (true);
|
||||
|
||||
pci->pcd = celld;
|
||||
@ -157,34 +156,20 @@ PACKED_CELL_OBJECT* GetNextPackedCop(CELL_ITERATOR* pci)
|
||||
return ppco;
|
||||
}
|
||||
|
||||
|
||||
// [D] [T]
|
||||
CELL_OBJECT* UnpackCellObject(PACKED_CELL_OBJECT* ppco, XZPAIR* near)
|
||||
{
|
||||
int newIndex;
|
||||
CELL_OBJECT* pco;
|
||||
|
||||
if (ppco == NULL)
|
||||
return NULL;
|
||||
|
||||
pco = &cell_object_buffer[cell_object_index];
|
||||
cell_object_index = cell_object_index + 1 & 0x3ff;
|
||||
pco = &cell_object_buffer[newIndex = cell_object_index];
|
||||
cell_object_index = newIndex + 1 & 1023;
|
||||
|
||||
pco->pos.vx = near->x + (((ppco->pos.vx - near->x) << 0x10) >> 0x10);
|
||||
pco->pos.vz = near->z + (((ppco->pos.vz - near->z) << 0x10) >> 0x10);
|
||||
|
||||
pco->pos.vy = (ppco->pos.vy << 0x10) >> 0x11;
|
||||
pco->yang = ppco->value & 0x3f;
|
||||
pco->type = (ppco->value >> 6) | ((ppco->pos.vy & 1) << 10);
|
||||
QuickUnpackCellObject(ppco, near, pco);
|
||||
|
||||
return pco;
|
||||
}
|
||||
|
||||
// [D] [T]
|
||||
void QuickUnpackCellObject(PACKED_CELL_OBJECT* ppco, XZPAIR* near, CELL_OBJECT* pco)
|
||||
{
|
||||
pco->pos.vx = near->x + (((ppco->pos.vx - near->x) << 0x10) >> 0x10);
|
||||
pco->pos.vz = near->z + (((ppco->pos.vz - near->z) << 0x10) >> 0x10);
|
||||
|
||||
pco->pos.vy = (ppco->pos.vy << 0x10) >> 0x11;
|
||||
pco->yang = ppco->value & 0x3f;
|
||||
pco->type = (ppco->value >> 6) | ((ppco->pos.vy & 1) << 10);
|
||||
}
|
@ -9,6 +9,15 @@ extern PACKED_CELL_OBJECT * GetFirstPackedCop(int cellx, int cellz, CELL_ITERATO
|
||||
extern PACKED_CELL_OBJECT* GetNextPackedCop(CELL_ITERATOR* pci); // 0x0003F5F0
|
||||
extern CELL_OBJECT* UnpackCellObject(PACKED_CELL_OBJECT* ppco, XZPAIR* near); // 0x000418E8
|
||||
|
||||
extern void QuickUnpackCellObject(PACKED_CELL_OBJECT* ppco, XZPAIR* near, CELL_OBJECT* pco);
|
||||
inline void QuickUnpackCellObject(PACKED_CELL_OBJECT* ppco, XZPAIR* near, CELL_OBJECT* pco)
|
||||
{
|
||||
pco->pos.vx = near->x + (short)(ppco->pos.vx - near->x);
|
||||
pco->pos.vz = near->z + (short)(ppco->pos.vz - near->z);
|
||||
|
||||
pco->pos.vy = (short)ppco->pos.vy >> 1;
|
||||
|
||||
pco->yang = ppco->value & 63;
|
||||
pco->type = (ppco->value >> 6) | ((ppco->pos.vy & 1) << 10);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1396,10 +1396,8 @@ void DrawMapPSX(int* comp_val)
|
||||
cellz > -1 && cellz < cells_down &&
|
||||
PVS_ptr[vis_v * pvs_square + vis_h]) // check PVS table
|
||||
{
|
||||
ppco = GetFirstPackedCop(cellx, cellz, &ci, 1, drawData.cellLevel);
|
||||
|
||||
// walk each cell object in cell
|
||||
while (ppco != NULL)
|
||||
for (ppco = GetFirstPackedCop(cellx, cellz, &ci, 1, drawData.cellLevel); ppco; ppco = GetNextPackedCop(&ci))
|
||||
{
|
||||
model = modelpointers[(ppco->value >> 6) | ((ppco->pos).vy & 1) << 10];
|
||||
|
||||
@ -1493,8 +1491,6 @@ void DrawMapPSX(int* comp_val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ppco = GetNextPackedCop(&ci);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1522,9 +1522,7 @@ void UpdateRoadPosition(CAR_DATA* cp, VECTOR* basePos, int intention)
|
||||
if (RoadMapRegions[cbr] != cbrX + cbrZ * regions_across)
|
||||
continue;
|
||||
|
||||
ppco = GetFirstPackedCop(cell_x, cell_z, &ci, 1);
|
||||
|
||||
while (ppco)
|
||||
for (ppco = GetFirstPackedCop(cell_x, cell_z, &ci, 1); ppco; ppco = GetNextPackedCop(&ci))
|
||||
{
|
||||
int type = (ppco->value >> 6) | ((ppco->pos.vy & 1) << 10);
|
||||
model = modelpointers[type];
|
||||
@ -1666,7 +1664,6 @@ void UpdateRoadPosition(CAR_DATA* cp, VECTOR* basePos, int intention)
|
||||
collide++;
|
||||
}
|
||||
}
|
||||
ppco = GetNextPackedCop(&ci);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +41,7 @@ char CellEmpty(VECTOR *pPosition, int radius)
|
||||
cell_x = (pPosition->vx + units_across_halved) / MAP_CELL_SIZE;
|
||||
cell_z = (pPosition->vz + units_down_halved) / MAP_CELL_SIZE;
|
||||
|
||||
ppco = GetFirstPackedCop(cell_x, cell_z, &ci, 0);
|
||||
|
||||
while(ppco)
|
||||
for (ppco = GetFirstPackedCop(cell_x, cell_z, &ci, 0); ppco; ppco = GetNextPackedCop(&ci))
|
||||
{
|
||||
type = (ppco->value >> 6) | ((ppco->pos.vy & 1) << 10);
|
||||
pModel = modelpointers[type];
|
||||
@ -198,8 +196,6 @@ char CellEmpty(VECTOR *pPosition, int radius)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ppco = GetNextPackedCop(&ci);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -372,9 +368,7 @@ char lineClear(VECTOR *v1, VECTOR *v2)
|
||||
|
||||
if ((ocx != cell_x) || (ocz != cell_z))
|
||||
{
|
||||
ppco = GetFirstPackedCop(cell_x, cell_z, &ci, 0);
|
||||
|
||||
while (ppco)
|
||||
for (ppco = GetFirstPackedCop(cell_x, cell_z, &ci, 0); ppco; ppco = GetNextPackedCop(&ci))
|
||||
{
|
||||
QuickUnpackCellObject(ppco, &ci.nearCell, &tempCO);
|
||||
pModel = modelpointers[tempCO.type];
|
||||
@ -503,7 +497,6 @@ char lineClear(VECTOR *v1, VECTOR *v2)
|
||||
collide++;
|
||||
}
|
||||
}
|
||||
ppco = GetNextPackedCop(&ci);
|
||||
}
|
||||
}
|
||||
|
||||
@ -555,9 +548,7 @@ void CollisionCopList(XZPAIR* pos, int* count)
|
||||
// check if we have valid region
|
||||
if (cbr.x + cbr.z * regions_across == RoadMapRegions[(cbr.x & 1) + (cbr.z & 1) * 2])
|
||||
{
|
||||
ppco = GetFirstPackedCop(cell.x, cell.z, &ci, 1, cellLevel);
|
||||
|
||||
while (ppco)
|
||||
for (ppco = GetFirstPackedCop(cell.x, cell.z, &ci, 1, cellLevel); ppco; ppco = GetNextPackedCop(&ci))
|
||||
{
|
||||
type = (ppco->value >> 6) | ((ppco->pos.vy & 1) << 10);
|
||||
|
||||
@ -576,8 +567,6 @@ void CollisionCopList(XZPAIR* pos, int* count)
|
||||
pcoplist[cnt] = ppco;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
ppco = GetNextPackedCop(&ci);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user