[Scummvm-cvs-logs] CVS: residual actor.cpp,1.47,1.48 actor.h,1.22,1.23 lua.cpp,1.113,1.114 vector3d.h,1.9,1.10 walkplane.cpp,1.13,1.14 walkplane.h,1.12,1.13
Daniel Schepler
dschepler at users.sourceforge.net
Sun Mar 27 17:58:22 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: residual driver.h,1.6,1.7 driver_gl.h,1.19,1.20 driver_gl.cpp,1.42,1.43 driver_tinygl.h,1.6,1.7 driver_tinygl.cpp,1.12,1.13 engine.cpp,1.68,1.69 main.cpp,1.47,1.48
- Next message: [Scummvm-cvs-logs] CVS: residual actor.cpp,1.48,1.49
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19579
Modified Files:
actor.cpp actor.h lua.cpp vector3d.h walkplane.cpp walkplane.h
Log Message:
Preliminary version of wall handling. Manny still gets stuck at walls,
but he now turns until he can move forward again.
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- actor.cpp 20 Mar 2005 16:48:26 -0000 1.47
+++ actor.cpp 28 Mar 2005 01:56:40 -0000 1.48
@@ -34,6 +34,7 @@
Actor::Actor(const char *name) :
_name(name), _talkColor(255, 255, 255), _pos(0, 0, 0),
_pitch(0), _yaw(0), _roll(0), _walkRate(0), _turnRate(0),
+ _reflectionAngle(80),
_visible(true), _lipSynch(NULL), _turning(false), _walking(false),
_restCostume(NULL), _restChore(-1),
_walkCostume(NULL), _walkChore(-1), _walkedLast(false), _walkedCur(false),
@@ -98,16 +99,65 @@
std::sin(pitch_rad));
Vector3d destPos = _pos + forwardVec * dist;
- if (!_constrain) {
- _pos = destPos;
+ if (! _constrain) {
+ _pos += forwardVec * dist;
_walkedCur = true;
- } else {
- Sector *sector = g_engine->currScene()->findPointSector(destPos, 0x1000);
- if (sector != NULL) {
- _pos = sector->projectToPlane(destPos);
+ return;
+ }
+
+ if (dist < 0) {
+ dist = -dist;
+ forwardVec = -forwardVec;
+ }
+
+ Sector *currSector = NULL, *prevSector = NULL;
+ Sector::ExitInfo ei;
+
+ g_engine->currScene()->findClosestSector(_pos, &currSector, &_pos);
+ if (currSector == NULL) { // Shouldn't happen...
+ _pos += forwardVec * dist;
+ _walkedCur = true;
+ return;
+ }
+
+ while (currSector != NULL) {
+ prevSector = currSector;
+ Vector3d puckVector = currSector->projectToPuckVector(forwardVec);
+ puckVector /= puckVector.magnitude();
+ currSector->getExitInfo(_pos, puckVector, &ei);
+ float exitDist = (ei.exitPoint - _pos).magnitude();
+ if (dist < exitDist) {
+ _pos += puckVector * dist;
_walkedCur = true;
+ return;
}
+ _pos = ei.exitPoint;
+ dist -= exitDist;
+ if (exitDist > 0.0001)
+ _walkedCur = true;
+
+ // Check for an adjacent sector which can continue
+ // the path
+ currSector = g_engine->currScene()->findPointSector(ei.exitPoint + 0.0001 * puckVector, 0x1000);
+ if (currSector == prevSector)
+ break;
}
+
+ ei.angleWithEdge *= (180.0 / M_PI);
+ int turnDir = 1;
+ if (ei.angleWithEdge > 90) {
+ ei.angleWithEdge = 180 - ei.angleWithEdge;
+ ei.edgeDir = -ei.edgeDir;
+ turnDir = -1;
+ }
+ if (ei.angleWithEdge > _reflectionAngle)
+ return;
+
+ ei.angleWithEdge += 0.1;
+ float turnAmt = g_engine->perSecond(_turnRate);
+ if (turnAmt > ei.angleWithEdge)
+ turnAmt = ei.angleWithEdge;
+ _yaw += turnAmt * turnDir;
}
Vector3d Actor::puckVector() const {
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- actor.h 20 Mar 2005 16:48:26 -0000 1.22
+++ actor.h 28 Mar 2005 01:56:40 -0000 1.23
@@ -66,6 +66,7 @@
return _setName == name;
}
void walkForward();
+ void setReflection(float angle) { _reflectionAngle = angle; }
Vector3d puckVector() const;
void turn(int dir);
@@ -125,6 +126,7 @@
float _walkRate, _turnRate;
bool _constrain; // Constrain to walkboxes
+ float _reflectionAngle; // Maximum angle to turn by at walls
bool _visible;
bool _lookingMode;
std::string _talkSoundName;
Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- lua.cpp 20 Mar 2005 16:48:26 -0000 1.113
+++ lua.cpp 28 Mar 2005 01:56:40 -0000 1.114
@@ -457,6 +457,12 @@
act->walkForward();
}
+static void SetActorReflection() {
+ Actor *act = check_actor(1);
+ float angle = luaL_check_number(2);
+ act->setReflection(angle);
+}
+
static void GetActorPuckVector() {
Actor *act = check_actor(1);
Vector3d result = act->puckVector();
@@ -1584,7 +1590,6 @@
STUB_FUNC(GetCameraActor)
STUB_FUNC(DriveActorTo)
STUB_FUNC(WalkActorVector)
-STUB_FUNC(SetActorReflection)
STUB_FUNC(GetActorRect)
STUB_FUNC(GetActorNodeLocation)
STUB_FUNC(SetActorTimeScale)
@@ -1924,6 +1929,8 @@
{ "PutActorInSet", PutActorInSet },
{ "WalkActorVector", WalkActorVector },
{ "WalkActorForward", WalkActorForward },
+ { "SetActorReflection", SetActorReflection },
+ { "GetActorPuckVector", GetActorPuckVector },
{ "DriveActorTo", DriveActorTo },
{ "WalkActorTo", WalkActorTo },
{ "WalkActorToAvoiding", WalkActorToAvoiding },
Index: vector3d.h
===================================================================
RCS file: /cvsroot/scummvm/residual/vector3d.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- vector3d.h 1 Jan 2005 10:23:16 -0000 1.9
+++ vector3d.h 28 Mar 2005 01:56:40 -0000 1.10
@@ -125,6 +125,10 @@
return result;
}
+inline Vector3d operator -(const Vector3d& v) {
+ return (-1.0f) * v;
+}
+
inline Vector3d operator *(const Vector3d& v, float s) {
return s * v;
}
Index: walkplane.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/walkplane.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- walkplane.cpp 12 Jan 2005 23:28:47 -0000 1.13
+++ walkplane.cpp 28 Mar 2005 01:56:40 -0000 1.14
@@ -160,3 +160,38 @@
}
return _vertices[index];
}
+
+void Sector::getExitInfo(Vector3d start, Vector3d dir,
+ struct ExitInfo *result) {
+ start = projectToPlane(start);
+ dir = projectToPuckVector(dir);
+
+ // First find the edge the ray exits through: this is where
+ // the z-component of (v_i - start) x dir changes sign from
+ // positive to negative.
+
+ // First find a vertex such that the cross product has
+ // positive z-component.
+ int i;
+ for (i = 0; i < _numVertices; i++) {
+ Vector3d delta = _vertices[i] - start;
+ if (delta.x() * dir.y() > delta.y() * dir.x())
+ break;
+ }
+
+ // Now continue until the cross product has negative
+ // z-component.
+ while (i < _numVertices) {
+ i++;
+ Vector3d delta = _vertices[i] - start;
+ if (delta.x() * dir.y() <= delta.y() * dir.x())
+ break;
+ }
+
+ result->edgeDir = _vertices[i] - _vertices[i - 1];
+ result->angleWithEdge = angle(dir, result->edgeDir);
+
+ Vector3d edgeNormal(result->edgeDir.y(), -result->edgeDir.x(), 0);
+ result->exitPoint = start + (dot(_vertices[i] - start, edgeNormal) /
+ dot(dir, edgeNormal)) * dir;
+}
Index: walkplane.h
===================================================================
RCS file: /cvsroot/scummvm/residual/walkplane.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- walkplane.h 12 Jan 2005 18:06:43 -0000 1.12
+++ walkplane.h 28 Mar 2005 01:56:40 -0000 1.13
@@ -46,6 +46,15 @@
Vector3d closestPoint(Vector3d point) const;
+ // Interface to trace a ray to its exit from the polygon
+ struct ExitInfo {
+ Vector3d exitPoint;
+ float angleWithEdge;
+ Vector3d edgeDir;
+ };
+ void getExitInfo(Vector3d start, Vector3d dir,
+ struct ExitInfo *result);
+
private:
int _numVertices, _id;
- Previous message: [Scummvm-cvs-logs] CVS: residual driver.h,1.6,1.7 driver_gl.h,1.19,1.20 driver_gl.cpp,1.42,1.43 driver_tinygl.h,1.6,1.7 driver_tinygl.cpp,1.12,1.13 engine.cpp,1.68,1.69 main.cpp,1.47,1.48
- Next message: [Scummvm-cvs-logs] CVS: residual actor.cpp,1.48,1.49
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list