mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 17:33:05 +00:00
EMI: use X-Z in Vector3d::intersectLine2d
This commit is contained in:
parent
ef8239f8cf
commit
c3237e129e
@ -335,16 +335,18 @@ Common::List<Math::Line3d> Sector::getBridgesTo(Sector *sector) const {
|
||||
bool b1_out = edge.x() * delta_b1.y() < edge.y() * delta_b1.x();
|
||||
bool b2_out = edge.x() * delta_b2.y() < edge.y() * delta_b2.x();
|
||||
|
||||
bool useXZ = (g_grim->getGameType() == GType_MONKEY4);
|
||||
|
||||
if (b1_out && b2_out) {
|
||||
// Both points are outside.
|
||||
it = bridges.erase(it);
|
||||
continue;
|
||||
} else if (b1_out) {
|
||||
if (bridge.intersectLine2d(line, &pos)) {
|
||||
if (bridge.intersectLine2d(line, &pos), useXZ) {
|
||||
bridge = Math::Line3d(pos, bridge.end());
|
||||
}
|
||||
} else if (b2_out) {
|
||||
if (bridge.intersectLine2d(line, &pos)) {
|
||||
if (bridge.intersectLine2d(line, &pos, useXZ)) {
|
||||
bridge = Math::Line3d(bridge.begin(), pos);
|
||||
}
|
||||
}
|
||||
|
@ -49,13 +49,22 @@ Math::Vector3d Line3d::middle() const {
|
||||
return (_begin + _end) / 2.f;
|
||||
}
|
||||
|
||||
bool Line3d::intersectLine2d(const Line3d &other, Math::Vector3d *pos) {
|
||||
bool Line3d::intersectLine2d(const Line3d &other, Math::Vector3d *pos, bool useXZ) {
|
||||
|
||||
float denom = ((other._end.y() - other._begin.y()) * (_end.x() - _begin.x())) -
|
||||
((other._end.x() - other._begin.x()) * (_end.y() - _begin.y()));
|
||||
float denom, nume_a;
|
||||
if (useXZ) {
|
||||
denom = ((other._end.z() - other._begin.z()) * (_end.x() - _begin.x())) -
|
||||
((other._end.x() - other._begin.x()) * (_end.z() - _begin.z()));
|
||||
|
||||
float nume_a = ((other._end.x() - other._begin.x()) * (_begin.y() - other._begin.y())) -
|
||||
((other._end.y() - other._begin.y()) * (_begin.x() - other._begin.x()));
|
||||
nume_a = ((other._end.x() - other._begin.x()) * (_begin.z() - other._begin.z())) -
|
||||
((other._end.z() - other._begin.z()) * (_begin.x() - other._begin.x()));
|
||||
} else {
|
||||
denom = ((other._end.y() - other._begin.y()) * (_end.x() - _begin.x())) -
|
||||
((other._end.x() - other._begin.x()) * (_end.y() - _begin.y()));
|
||||
|
||||
nume_a = ((other._end.x() - other._begin.x()) * (_begin.y() - other._begin.y())) -
|
||||
((other._end.y() - other._begin.y()) * (_begin.x() - other._begin.x()));
|
||||
}
|
||||
|
||||
if (denom == 0.0f) {
|
||||
return false;
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
Math::Vector3d end() const;
|
||||
Math::Vector3d middle() const;
|
||||
|
||||
bool intersectLine2d(const Line3d &other, Math::Vector3d *pos);
|
||||
bool intersectLine2d(const Line3d &other, Math::Vector3d *pos, bool useXZ = false);
|
||||
|
||||
void operator=(const Line3d &other);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user