mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-05 12:47:53 +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);
|
Location best = getLocationForAngle(targetAngleY, distH, distV);
|
||||||
|
|
||||||
if (trace(target, best))
|
if (trace(target, best, true))
|
||||||
return best;
|
return best;
|
||||||
|
|
||||||
if (clip && best.pos != target.pos)
|
if (clip && best.pos != target.pos)
|
||||||
@@ -168,7 +168,7 @@ struct Camera
|
|||||||
Location tmpDest = getLocationForAngle(i * ANGLE_90, distH, distV);
|
Location tmpDest = getLocationForAngle(i * ANGLE_90, distH, distV);
|
||||||
Location tmpView = view;
|
Location tmpView = view;
|
||||||
|
|
||||||
if (!trace(target, tmpDest) || !trace(tmpDest, tmpView))
|
if (!trace(target, tmpDest, true) || !trace(tmpDest, tmpView, false))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
distQ = X_SQR(view.pos.x - tmpDest.pos.x) + X_SQR(view.pos.z - tmpDest.pos.z);
|
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 flush();
|
||||||
|
|
||||||
void readLevel(const uint8 *data);
|
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);
|
Lara* getLara(const vec3i &pos);
|
||||||
|
|
||||||
|
@@ -3118,7 +3118,7 @@ struct Lara : Item
|
|||||||
} else {
|
} else {
|
||||||
to.pos += dir;
|
to.pos += dir;
|
||||||
|
|
||||||
trace(from, to);
|
trace(from, to, true);
|
||||||
fxRicochet(to.room, to.pos, true);
|
fxRicochet(to.room, to.pos, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3583,7 +3583,7 @@ struct Lara : Item
|
|||||||
angleAim.x -= angle.x;
|
angleAim.x -= angle.x;
|
||||||
angleAim.y -= angle.y;
|
angleAim.y -= angle.y;
|
||||||
|
|
||||||
if (trace(from, to))
|
if (trace(from, to, false))
|
||||||
{
|
{
|
||||||
if (abs(angleAim.x) <= params.aimX && abs(angleAim.y) <= params.aimY) {
|
if (abs(angleAim.x) <= params.aimX && abs(angleAim.y) <= params.aimY) {
|
||||||
extraL->armR.aim = extraL->armL.aim = true;
|
extraL->armR.aim = extraL->armL.aim = true;
|
||||||
@@ -3632,7 +3632,7 @@ struct Lara : Item
|
|||||||
Location to;
|
Location to;
|
||||||
weaponGetAimPoint(item, to);
|
weaponGetAimPoint(item, to);
|
||||||
|
|
||||||
if (!trace(from, to))
|
if (!trace(from, to, false))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vec3i dir = to.pos - from.pos;
|
vec3i dir = to.pos - from.pos;
|
||||||
|
@@ -124,15 +124,24 @@ void readLevel(const uint8* data)
|
|||||||
#define TRACE_CHECK(r, x, y, z) \
|
#define TRACE_CHECK(r, x, y, z) \
|
||||||
{ \
|
{ \
|
||||||
const Sector* sector = r->getSector(x, z); \
|
const Sector* sector = r->getSector(x, z); \
|
||||||
if (y > sector->getFloor(x, y, z) || y < sector->getCeiling(x, y, z)) \
|
if (accurate) { \
|
||||||
{ \
|
if (y > sector->getFloor(x, y, z) || y < sector->getCeiling(x, y, z)) \
|
||||||
to.pos = p; \
|
{ \
|
||||||
to.room = room; \
|
to.pos = p; \
|
||||||
return false; \
|
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;
|
vec3i d = to.pos - from.pos;
|
||||||
|
|
||||||
@@ -190,7 +199,7 @@ bool traceX(const Location &from, Location &to)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool traceZ(const Location &from, Location &to)
|
bool traceZ(const Location &from, Location &to, bool accurate)
|
||||||
{
|
{
|
||||||
vec3i d = to.pos - from.pos;
|
vec3i d = to.pos - from.pos;
|
||||||
|
|
||||||
@@ -250,7 +259,7 @@ bool traceZ(const Location &from, Location &to)
|
|||||||
|
|
||||||
#undef TRACE_CHECK
|
#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 dx = abs(to.pos.x - from.pos.x);
|
||||||
int32 dz = abs(to.pos.z - from.pos.z);
|
int32 dz = abs(to.pos.z - from.pos.z);
|
||||||
@@ -259,12 +268,12 @@ bool trace(const Location &from, Location &to)
|
|||||||
bool res;
|
bool res;
|
||||||
|
|
||||||
if (dz > dx) {
|
if (dz > dx) {
|
||||||
res = traceX(from, to);
|
res = traceX(from, to, accurate);
|
||||||
if (!traceZ(from, to))
|
if (!traceZ(from, to, accurate))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
res = traceZ(from, to);
|
res = traceZ(from, to, accurate);
|
||||||
if (!traceX(from, to))
|
if (!traceX(from, to, accurate))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user