mirror of
https://github.com/libretro/scummvm.git
synced 2025-05-13 17:46:22 +00:00
STARK: Change the Movement base class to only keep an ItemVisual pointer
This commit is contained in:
parent
8678e56301
commit
c733a5ab59
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
namespace Stark {
|
namespace Stark {
|
||||||
|
|
||||||
Movement::Movement(Resources::FloorPositionedItem *item) :
|
Movement::Movement(Resources::ItemVisual *item) :
|
||||||
_ended(false),
|
_ended(false),
|
||||||
_item(item) {
|
_item(item) {
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
namespace Stark {
|
namespace Stark {
|
||||||
|
|
||||||
namespace Resources {
|
namespace Resources {
|
||||||
class FloorPositionedItem;
|
class ItemVisual;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,7 +36,7 @@ class FloorPositionedItem;
|
|||||||
*/
|
*/
|
||||||
class Movement {
|
class Movement {
|
||||||
public:
|
public:
|
||||||
Movement(Resources::FloorPositionedItem *item);
|
Movement(Resources::ItemVisual *item);
|
||||||
virtual ~Movement();
|
virtual ~Movement();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +71,7 @@ protected:
|
|||||||
float computeAngleBetweenVectorsXYPlane(const Math::Vector3d &v1, const Math::Vector3d &v2) const;
|
float computeAngleBetweenVectorsXYPlane(const Math::Vector3d &v1, const Math::Vector3d &v2) const;
|
||||||
|
|
||||||
bool _ended;
|
bool _ended;
|
||||||
Resources::FloorPositionedItem *_item;
|
Resources::ItemVisual *_item;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Stark
|
} // End of namespace Stark
|
||||||
|
@ -31,6 +31,7 @@ namespace Stark {
|
|||||||
|
|
||||||
Turn::Turn(Resources::FloorPositionedItem *item) :
|
Turn::Turn(Resources::FloorPositionedItem *item) :
|
||||||
Movement(item),
|
Movement(item),
|
||||||
|
_item3D(item),
|
||||||
_turnSpeed(_defaultTurnAngleSpeed) {
|
_turnSpeed(_defaultTurnAngleSpeed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ void Turn::onGameLoop() {
|
|||||||
direction.normalize();
|
direction.normalize();
|
||||||
|
|
||||||
// Compute the angle with the current character direction
|
// Compute the angle with the current character direction
|
||||||
Math::Vector3d currentDirection = _item->getDirectionVector();
|
Math::Vector3d currentDirection = _item3D->getDirectionVector();
|
||||||
float directionDeltaAngle = computeAngleBetweenVectorsXYPlane(currentDirection, direction);
|
float directionDeltaAngle = computeAngleBetweenVectorsXYPlane(currentDirection, direction);
|
||||||
|
|
||||||
// If the angle between the current direction and the new one is too high,
|
// If the angle between the current direction and the new one is too high,
|
||||||
@ -68,7 +69,7 @@ void Turn::onGameLoop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the item's direction
|
// Update the item's direction
|
||||||
_item->setDirection(computeAngleBetweenVectorsXYPlane(direction, Math::Vector3d(1.0, 0.0, 0.0)));
|
_item3D->setDirection(computeAngleBetweenVectorsXYPlane(direction, Math::Vector3d(1.0, 0.0, 0.0)));
|
||||||
|
|
||||||
// Check if we are close enough to the destination to stop
|
// Check if we are close enough to the destination to stop
|
||||||
if (direction == _targetDirection) {
|
if (direction == _targetDirection) {
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
namespace Stark {
|
namespace Stark {
|
||||||
|
|
||||||
|
namespace Resources {
|
||||||
|
class FloorPositionedItem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make an item turn on itself towards a target direction
|
* Make an item turn on itself towards a target direction
|
||||||
*/
|
*/
|
||||||
@ -42,6 +46,7 @@ public:
|
|||||||
void setTargetDirection(const Math::Vector3d &direction);
|
void setTargetDirection(const Math::Vector3d &direction);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Resources::FloorPositionedItem *_item3D;
|
||||||
Math::Vector3d _targetDirection;
|
Math::Vector3d _targetDirection;
|
||||||
float _turnSpeed;
|
float _turnSpeed;
|
||||||
};
|
};
|
||||||
|
@ -38,6 +38,7 @@ namespace Stark {
|
|||||||
|
|
||||||
Walk::Walk(Resources::FloorPositionedItem *item) :
|
Walk::Walk(Resources::FloorPositionedItem *item) :
|
||||||
Movement(item),
|
Movement(item),
|
||||||
|
_item3D(item),
|
||||||
_running(false),
|
_running(false),
|
||||||
_turnDirection(kTurnNone) {
|
_turnDirection(kTurnNone) {
|
||||||
_path = new StringPullingPath();
|
_path = new StringPullingPath();
|
||||||
@ -60,8 +61,8 @@ void Walk::start() {
|
|||||||
void Walk::updatePath() const {
|
void Walk::updatePath() const {
|
||||||
Resources::Floor *floor = StarkGlobal->getCurrent()->getFloor();
|
Resources::Floor *floor = StarkGlobal->getCurrent()->getFloor();
|
||||||
|
|
||||||
Math::Vector3d startPosition = _item->getPosition3D();
|
Math::Vector3d startPosition = _item3D->getPosition3D();
|
||||||
int32 startFloorFaceIndex = _item->getFloorFaceIndex();
|
int32 startFloorFaceIndex = _item3D->getFloorFaceIndex();
|
||||||
Resources::FloorFace *startFloorFace = floor->getFace(startFloorFaceIndex);
|
Resources::FloorFace *startFloorFace = floor->getFace(startFloorFaceIndex);
|
||||||
Resources::FloorEdge *startFloorEdge = startFloorFace->findNearestEdge(startPosition);
|
Resources::FloorEdge *startFloorEdge = startFloorFace->findNearestEdge(startPosition);
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ void Walk::onGameLoop() {
|
|||||||
Resources::Floor *floor = StarkGlobal->getCurrent()->getFloor();
|
Resources::Floor *floor = StarkGlobal->getCurrent()->getFloor();
|
||||||
|
|
||||||
// Get the target to walk to
|
// Get the target to walk to
|
||||||
Math::Vector3d currentPosition = _item->getPosition3D();
|
Math::Vector3d currentPosition = _item3D->getPosition3D();
|
||||||
Math::Vector3d target = _path->computeWalkTarget(currentPosition);
|
Math::Vector3d target = _path->computeWalkTarget(currentPosition);
|
||||||
|
|
||||||
// Compute the direction to walk into
|
// Compute the direction to walk into
|
||||||
@ -95,7 +96,7 @@ void Walk::onGameLoop() {
|
|||||||
direction.normalize();
|
direction.normalize();
|
||||||
|
|
||||||
// Compute the angle with the current character direction
|
// Compute the angle with the current character direction
|
||||||
Math::Vector3d currentDirection = _item->getDirectionVector();
|
Math::Vector3d currentDirection = _item3D->getDirectionVector();
|
||||||
float directionDeltaAngle = computeAngleBetweenVectorsXYPlane(currentDirection, direction);
|
float directionDeltaAngle = computeAngleBetweenVectorsXYPlane(currentDirection, direction);
|
||||||
|
|
||||||
// If the angle between the current direction and the new one is too high,
|
// If the angle between the current direction and the new one is too high,
|
||||||
@ -140,11 +141,11 @@ void Walk::onGameLoop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the item's properties
|
// Update the item's properties
|
||||||
_item->setPosition3D(newPosition);
|
_item3D->setPosition3D(newPosition);
|
||||||
if (direction.getMagnitude() != 0.0) {
|
if (direction.getMagnitude() != 0.0) {
|
||||||
_item->setDirection(computeAngleBetweenVectorsXYPlane(direction, Math::Vector3d(1.0, 0.0, 0.0)));
|
_item3D->setDirection(computeAngleBetweenVectorsXYPlane(direction, Math::Vector3d(1.0, 0.0, 0.0)));
|
||||||
}
|
}
|
||||||
_item->setFloorFaceIndex(newFloorFaceIndex);
|
_item3D->setFloorFaceIndex(newFloorFaceIndex);
|
||||||
|
|
||||||
changeItemAnim();
|
changeItemAnim();
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,10 @@ namespace Stark {
|
|||||||
|
|
||||||
class StringPullingPath;
|
class StringPullingPath;
|
||||||
|
|
||||||
|
namespace Resources {
|
||||||
|
class FloorPositionedItem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make an item walk / run to its destination on the current
|
* Make an item walk / run to its destination on the current
|
||||||
* location's floor
|
* location's floor
|
||||||
@ -54,6 +58,7 @@ private:
|
|||||||
void changeItemAnim();
|
void changeItemAnim();
|
||||||
void updatePath() const;
|
void updatePath() const;
|
||||||
|
|
||||||
|
Resources::FloorPositionedItem *_item3D;
|
||||||
StringPullingPath *_path;
|
StringPullingPath *_path;
|
||||||
|
|
||||||
Math::Vector3d _destination;
|
Math::Vector3d _destination;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user