mirror of
https://github.com/XProger/OpenLara.git
synced 2025-07-31 18:30:19 +02:00
#368 GBA use less accurate ray casting in some cases to boost perf
This commit is contained in:
@@ -150,7 +150,7 @@ struct Camera
|
||||
|
||||
Location best = getLocationForAngle(targetAngleY, distH, distV);
|
||||
|
||||
if (trace(target, best))
|
||||
if (trace(target, best, true))
|
||||
return best;
|
||||
|
||||
if (clip && best.pos != target.pos)
|
||||
@@ -168,7 +168,7 @@ struct Camera
|
||||
Location tmpDest = getLocationForAngle(i * ANGLE_90, distH, distV);
|
||||
Location tmpView = view;
|
||||
|
||||
if (!trace(target, tmpDest) || !trace(tmpDest, tmpView))
|
||||
if (!trace(target, tmpDest, true) || !trace(tmpDest, tmpView, false))
|
||||
continue;
|
||||
|
||||
distQ = X_SQR(view.pos.x - tmpDest.pos.x) + X_SQR(view.pos.z - tmpDest.pos.z);
|
||||
|
@@ -1838,7 +1838,7 @@ void faceAddMesh(const Quad* rFaces, const Quad* crFaces, const Triangle* tFaces
|
||||
void flush();
|
||||
|
||||
void readLevel(const uint8 *data);
|
||||
bool trace(const Location &from, Location &to);
|
||||
bool trace(const Location &from, Location &to, bool accurate);
|
||||
|
||||
Lara* getLara(const vec3i &pos);
|
||||
|
||||
|
@@ -3118,7 +3118,7 @@ struct Lara : Item
|
||||
} else {
|
||||
to.pos += dir;
|
||||
|
||||
trace(from, to);
|
||||
trace(from, to, true);
|
||||
fxRicochet(to.room, to.pos, true);
|
||||
}
|
||||
}
|
||||
@@ -3583,7 +3583,7 @@ struct Lara : Item
|
||||
angleAim.x -= angle.x;
|
||||
angleAim.y -= angle.y;
|
||||
|
||||
if (trace(from, to))
|
||||
if (trace(from, to, false))
|
||||
{
|
||||
if (abs(angleAim.x) <= params.aimX && abs(angleAim.y) <= params.aimY) {
|
||||
extraL->armR.aim = extraL->armL.aim = true;
|
||||
@@ -3632,7 +3632,7 @@ struct Lara : Item
|
||||
Location to;
|
||||
weaponGetAimPoint(item, to);
|
||||
|
||||
if (!trace(from, to))
|
||||
if (!trace(from, to, false))
|
||||
continue;
|
||||
|
||||
vec3i dir = to.pos - from.pos;
|
||||
|
@@ -124,15 +124,24 @@ void readLevel(const uint8* data)
|
||||
#define TRACE_CHECK(r, x, y, z) \
|
||||
{ \
|
||||
const Sector* sector = r->getSector(x, z); \
|
||||
if (y > sector->getFloor(x, y, z) || y < sector->getCeiling(x, y, z)) \
|
||||
{ \
|
||||
to.pos = p; \
|
||||
to.room = room; \
|
||||
return false; \
|
||||
if (accurate) { \
|
||||
if (y > sector->getFloor(x, y, z) || y < sector->getCeiling(x, y, z)) \
|
||||
{ \
|
||||
to.pos = p; \
|
||||
to.room = room; \
|
||||
return false; \
|
||||
} \
|
||||
} else { \
|
||||
if (y > (sector->floor << 8) || y < (sector->ceiling << 8)) \
|
||||
{ \
|
||||
to.pos = p; \
|
||||
to.room = room; \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
bool traceX(const Location &from, Location &to)
|
||||
bool traceX(const Location &from, Location &to, bool accurate)
|
||||
{
|
||||
vec3i d = to.pos - from.pos;
|
||||
|
||||
@@ -190,7 +199,7 @@ bool traceX(const Location &from, Location &to)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool traceZ(const Location &from, Location &to)
|
||||
bool traceZ(const Location &from, Location &to, bool accurate)
|
||||
{
|
||||
vec3i d = to.pos - from.pos;
|
||||
|
||||
@@ -250,7 +259,7 @@ bool traceZ(const Location &from, Location &to)
|
||||
|
||||
#undef TRACE_CHECK
|
||||
|
||||
bool trace(const Location &from, Location &to)
|
||||
bool trace(const Location &from, Location &to, bool accurate)
|
||||
{
|
||||
int32 dx = abs(to.pos.x - from.pos.x);
|
||||
int32 dz = abs(to.pos.z - from.pos.z);
|
||||
@@ -259,12 +268,12 @@ bool trace(const Location &from, Location &to)
|
||||
bool res;
|
||||
|
||||
if (dz > dx) {
|
||||
res = traceX(from, to);
|
||||
if (!traceZ(from, to))
|
||||
res = traceX(from, to, accurate);
|
||||
if (!traceZ(from, to, accurate))
|
||||
return false;
|
||||
} else {
|
||||
res = traceZ(from, to);
|
||||
if (!traceX(from, to))
|
||||
res = traceZ(from, to, accurate);
|
||||
if (!traceX(from, to, accurate))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user