Finish CBallCamera

This commit is contained in:
Jack Andersen 2017-10-15 19:26:50 -10:00
parent 6d0769bba7
commit 4af2d975f4
18 changed files with 1445 additions and 955 deletions

View File

@ -10,7 +10,7 @@ struct ITweakBall : ITweak
virtual float GetMaxBallTranslationAcceleration(int s) const=0; virtual float GetMaxBallTranslationAcceleration(int s) const=0;
virtual float GetBallTranslationFriction(int s) const=0; virtual float GetBallTranslationFriction(int s) const=0;
virtual float GetBallTranslationMaxSpeed(int s) const=0; virtual float GetBallTranslationMaxSpeed(int s) const=0;
virtual float GetBallCameraElevation() const { return 2.736f; } virtual float GetBallCameraElevation() const=0;
virtual float GetBallCameraAnglePerSecond() const=0; virtual float GetBallCameraAnglePerSecond() const=0;
virtual const zeus::CVector3f& GetBallCameraOffset() const=0; virtual const zeus::CVector3f& GetBallCameraOffset() const=0;
virtual float GetBallCameraMinSpeedDistance() const=0; virtual float GetBallCameraMinSpeedDistance() const=0;
@ -32,6 +32,7 @@ struct ITweakBall : ITweak
virtual float GetBallGravity() const=0; virtual float GetBallGravity() const=0;
virtual float GetBallWaterGravity() const=0; virtual float GetBallWaterGravity() const=0;
virtual float GetBallSlipFactor(int s) const=0; virtual float GetBallSlipFactor(int s) const=0;
virtual float GetConservativeDoorCameraDistance() const=0;
virtual float GetBallCameraChaseElevation() const=0; virtual float GetBallCameraChaseElevation() const=0;
virtual float GetBallCameraChaseDampenAngle() const=0; virtual float GetBallCameraChaseDampenAngle() const=0;
virtual float GetBallCameraChaseDistance() const=0; virtual float GetBallCameraChaseDistance() const=0;

View File

@ -15,57 +15,57 @@ struct CameraHint : IScriptObject
String<-1> name; String<-1> name;
Value<atVec3f> location; Value<atVec3f> location;
Value<atVec3f> orientation; Value<atVec3f> orientation;
Value<bool> unknown1; Value<bool> active;
Value<atUint32> unknown2; Value<atUint32> priority;
Value<atUint32> unknown3; Value<atUint32> behaviour;
struct CameraHintParameters : BigYAML struct CameraHintParameters : BigYAML
{ {
DECL_YAML DECL_YAML
Value<atUint32> propertyCount; Value<atUint32> propertyCount;
Value<bool> unknown1; Value<bool> unknown1; // 0x1
Value<bool> unknown2; Value<bool> chaseAllowed; // 0x2
Value<bool> unknown3; Value<bool> boostAllowed; // 0x4
Value<bool> unknown4; Value<bool> obscureAvoidance; // 0x8
Value<bool> unknown5; Value<bool> volumeCollider; // 0x10
Value<bool> unknown6; Value<bool> applyImmediately; // 0x20
Value<bool> unknown7; Value<bool> lookAtBall; // 0x40
Value<bool> unknown8; Value<bool> hintDistanceSelection; // 0x80
Value<bool> unknown9; Value<bool> hintDistanceSelfPos; // 0x100
Value<bool> unknown10; Value<bool> controlInterpolation; // 0x200
Value<bool> unknown11; Value<bool> unknown11; // 0x400
Value<bool> unknown12; Value<bool> unknown12; // 0x800
Value<bool> unknown13; Value<bool> clampVelocity; // 0x1000
Value<bool> unknown14; Value<bool> skipCinematic; // 0x2000
Value<bool> unknown15; Value<bool> noElevationInterp; // 0x4000
Value<bool> unknown16; Value<bool> directElevation; // 0x8000
Value<bool> unknown17; Value<bool> overrideLookDir; // 0x10000
Value<bool> unknown18; Value<bool> noElevationVelClamp; // 0x20000
Value<bool> unknown19; Value<bool> calculateTransformFromPrevCam; // 0x40000
Value<bool> unknown20; Value<bool> noSpline; // 0x80000
Value<bool> unknown21; Value<bool> unknown21; // 0x100000
Value<bool> unknown22; Value<bool> unknown22; // 0x200000
} cameraHintParameters; } cameraHintParameters;
struct BoolFloat : BigYAML struct BoolFloat : BigYAML
{ {
DECL_YAML DECL_YAML
Value<bool> unknown1; Value<bool> active;
Value<float> unknown2; Value<float> value;
} boolFloat1[3]; } minDist, maxDist, backwardsDist; // 0x400000, 0x800000, 0x1000000
struct BoolVec3f : BigYAML struct BoolVec3f : BigYAML
{ {
DECL_YAML DECL_YAML
Value<bool> unknown1; Value<bool> active;
Value<atVec3f> unknown2; Value<atVec3f> value;
} boolVec3f[2]; } lookAtOffset, chaseLookAtOffset; // 0x2000000, 0x4000000
Value<atVec3f> unknown4; Value<atVec3f> ballToCam;
BoolFloat boolFloat2[4]; BoolFloat fov, attitudeRange, azimuthRange, anglePerSecond; // 0x8000000, 0x10000000, 0x20000000, 0x40000000
Value<float> unknown5; Value<float> clampVelRange;
Value<float> unknown6; Value<float> unknown6;
BoolFloat boolFloat3; BoolFloat elevation; // 0x80000000
Value<float> unknown7; Value<float> unknown7;
Value<float> unknown8; Value<float> clampVelTime;
Value<float> unknown9; Value<float> controlInterpDur;
}; };
} }
} }

View File

@ -151,8 +151,8 @@ void CTweakBall::read(athena::io::IStreamReader& __dna_reader)
x168_ = __dna_reader.readFloatBig(); x168_ = __dna_reader.readFloatBig();
/* x16c_ */ /* x16c_ */
x16c_ = __dna_reader.readFloatBig(); x16c_ = __dna_reader.readFloatBig();
/* x170_ */ /* x170_conservativeDoorCamDistance */
x170_ = __dna_reader.readFloatBig(); x170_conservativeDoorCamDistance = __dna_reader.readFloatBig();
/* x174_ */ /* x174_ */
x174_ = __dna_reader.readFloatBig(); x174_ = __dna_reader.readFloatBig();
/* x178_ballCameraChaseElevation */ /* x178_ballCameraChaseElevation */
@ -371,8 +371,8 @@ void CTweakBall::write(athena::io::IStreamWriter& __dna_writer) const
__dna_writer.writeFloatBig(x168_); __dna_writer.writeFloatBig(x168_);
/* x16c_ */ /* x16c_ */
__dna_writer.writeFloatBig(x16c_); __dna_writer.writeFloatBig(x16c_);
/* x170_ */ /* x170_conservativeDoorCamDistance */
__dna_writer.writeFloatBig(x170_); __dna_writer.writeFloatBig(x170_conservativeDoorCamDistance);
/* x174_ */ /* x174_ */
__dna_writer.writeFloatBig(x174_); __dna_writer.writeFloatBig(x174_);
/* x178_ballCameraChaseElevation */ /* x178_ballCameraChaseElevation */
@ -611,8 +611,8 @@ void CTweakBall::read(athena::io::YAMLDocReader& __dna_docin)
x168_ = __dna_docin.readFloat("x168_"); x168_ = __dna_docin.readFloat("x168_");
/* x16c_ */ /* x16c_ */
x16c_ = __dna_docin.readFloat("x16c_"); x16c_ = __dna_docin.readFloat("x16c_");
/* x170_ */ /* x170_conservativeDoorCamDistance */
x170_ = __dna_docin.readFloat("x170_"); x170_conservativeDoorCamDistance = __dna_docin.readFloat("x170_conservativeDoorCamDistance");
/* x174_ */ /* x174_ */
x174_ = __dna_docin.readFloat("x174_"); x174_ = __dna_docin.readFloat("x174_");
/* x178_ballCameraChaseElevation */ /* x178_ballCameraChaseElevation */
@ -847,8 +847,8 @@ void CTweakBall::write(athena::io::YAMLDocWriter& __dna_docout) const
__dna_docout.writeFloat("x168_", x168_); __dna_docout.writeFloat("x168_", x168_);
/* x16c_ */ /* x16c_ */
__dna_docout.writeFloat("x16c_", x16c_); __dna_docout.writeFloat("x16c_", x16c_);
/* x170_ */ /* x170_conservativeDoorCamDistance */
__dna_docout.writeFloat("x170_", x170_); __dna_docout.writeFloat("x170_conservativeDoorCamDistance", x170_conservativeDoorCamDistance);
/* x174_ */ /* x174_ */
__dna_docout.writeFloat("x174_", x174_); __dna_docout.writeFloat("x174_", x174_);
/* x178_ballCameraChaseElevation */ /* x178_ballCameraChaseElevation */

View File

@ -66,7 +66,7 @@ struct CTweakBall final : public ITweakBall
Value<float> x164_; Value<float> x164_;
Value<float> x168_; Value<float> x168_;
Value<float> x16c_; Value<float> x16c_;
Value<float> x170_; Value<float> x170_conservativeDoorCamDistance;
Value<float> x174_; Value<float> x174_;
Value<float> x178_ballCameraChaseElevation; Value<float> x178_ballCameraChaseElevation;
Value<float> x17c_ballCameraChaseDampenAngle; Value<float> x17c_ballCameraChaseDampenAngle;
@ -155,6 +155,7 @@ struct CTweakBall final : public ITweakBall
float GetBallGravity() const { return xe4_ballGravity; } float GetBallGravity() const { return xe4_ballGravity; }
float GetBallWaterGravity() const { return xe8_ballWaterGravity; } float GetBallWaterGravity() const { return xe8_ballWaterGravity; }
float GetBallSlipFactor(int s) const { return x12c_ballSlipFactor[s]; } float GetBallSlipFactor(int s) const { return x12c_ballSlipFactor[s]; }
float GetConservativeDoorCameraDistance() const { return x170_conservativeDoorCamDistance; }
float GetBallCameraChaseElevation() const { return x178_ballCameraChaseElevation; } float GetBallCameraChaseElevation() const { return x178_ballCameraChaseElevation; }
float GetBallCameraChaseDampenAngle() const { return x17c_ballCameraChaseDampenAngle; } float GetBallCameraChaseDampenAngle() const { return x17c_ballCameraChaseDampenAngle; }
float GetBallCameraChaseDistance() const { return x180_ballCameraChaseDistance; } float GetBallCameraChaseDistance() const { return x180_ballCameraChaseDistance; }

File diff suppressed because it is too large Load Diff

View File

@ -27,16 +27,17 @@ class CCameraCollider
{ {
friend class CBallCamera; friend class CBallCamera;
float x4_radius; float x4_radius;
zeus::CVector3f x8_; zeus::CVector3f x8_lastLocalPos;
zeus::CVector3f x14_; zeus::CVector3f x14_localPos;
zeus::CVector3f x20_; zeus::CVector3f x20_scaledWorldPos;
zeus::CVector3f x2c_; zeus::CVector3f x2c_lastWorldPos;
CCameraSpring x38_spring; CCameraSpring x38_spring;
u32 x4c_occlusionCount = 0; u32 x4c_occlusionCount = 0;
float x50_scale; float x50_scale;
public: public:
CCameraCollider(float radius, const zeus::CVector3f& vec, const CCameraSpring& spring, float scale) CCameraCollider(float radius, const zeus::CVector3f& vec, const CCameraSpring& spring, float scale)
: x4_radius(radius), x8_(vec), x14_(vec), x20_(vec), x2c_(vec), x38_spring(spring), x50_scale(scale) {} : x4_radius(radius), x8_lastLocalPos(vec), x14_localPos(vec), x20_scaledWorldPos(vec),
x2c_lastWorldPos(vec), x38_spring(spring), x50_scale(scale) {}
}; };
class CBallCamera : public CGameCamera class CBallCamera : public CGameCamera
@ -44,56 +45,62 @@ class CBallCamera : public CGameCamera
public: public:
enum class EBallCameraState enum class EBallCameraState
{ {
Zero, Default,
One, One,
Two, Chase,
Three, Boost,
Four, ToBall,
Five FromBall
}; };
enum class EBallCameraBehaviour enum class EBallCameraBehaviour
{ {
Zero, Default,
One, FreezeLookPosition, // Unused
Two, HintBallToCam,
Three, HintInitializePosition,
Four, HintFixedPosition,
Five, HintFixedTransform,
Six, PathCameraDesiredPos, // Unused
Seven, PathCamera,
Eight SpindleCamera
};
enum class ESplineState
{
Invalid,
Nav,
Arc
}; };
private: private:
struct SFailsafeState struct SFailsafeState
{ {
zeus::CTransform x0_; zeus::CTransform x0_playerXf;
zeus::CTransform x30_; zeus::CTransform x30_camXf;
zeus::CVector3f x60_; zeus::CVector3f x60_lookPos;
zeus::CVector3f x6c_; zeus::CVector3f x6c_behindPos;
zeus::CVector3f x78_; zeus::CVector3f x78_;
zeus::CVector3f x84_; zeus::CVector3f x84_playerPos;
std::vector<zeus::CVector3f> x90_bezPoints; std::vector<zeus::CVector3f> x90_splinePoints;
}; };
EBallCameraBehaviour x188_behaviour = EBallCameraBehaviour::Zero; EBallCameraBehaviour x188_behaviour = EBallCameraBehaviour::Default;
bool x18c_24_ : 1; bool x18c_24_ : 1;
bool x18c_25_ : 1; bool x18c_25_chaseAllowed : 1;
bool x18c_26_ : 1; bool x18c_26_boostAllowed : 1;
bool x18c_27_ : 1; bool x18c_27_obscureAvoidance : 1;
bool x18c_28_ : 1; bool x18c_28_volumeCollider : 1;
bool x18c_29_ : 1; bool x18c_29_clampAttitude : 1;
bool x18c_30_ : 1; bool x18c_30_clampAzimuth : 1;
bool x18c_31_ : 1; bool x18c_31_clearLOS : 1;
bool x18d_24_ : 1; bool x18d_24_prevClearLOS : 1;
bool x18d_25_ : 1; bool x18d_25_avoidGeometryFull : 1;
bool x18d_26_ : 1; bool x18d_26_lookAtBall : 1;
bool x18d_27_ : 1; bool x18d_27_forceProcessing : 1;
bool x18d_28_ : 1; bool x18d_28_obtuseDirection : 1;
bool x18d_29_ : 1; bool x18d_29_noElevationInterp : 1;
bool x18d_30_ : 1; bool x18d_30_directElevation : 1;
bool x18d_31_ : 1; bool x18d_31_overrideLookDir : 1;
bool x18e_24_ : 1; bool x18e_24_noElevationVelClamp : 1;
bool x18e_25_ : 1; bool x18e_25_noSpline : 1;
bool x18e_26_ : 1; bool x18e_26_ : 1;
bool x18e_27_nearbyDoorClosed : 1; bool x18e_27_nearbyDoorClosed : 1;
bool x18e_28_nearbyDoorClosing : 1; bool x18e_28_nearbyDoorClosing : 1;
@ -104,13 +111,13 @@ private:
float x1a0_elevation; float x1a0_elevation;
float x1a4_curAnglePerSecond; float x1a4_curAnglePerSecond;
float x1a8_targetAnglePerSecond; float x1a8_targetAnglePerSecond;
float x1ac_ = 1.5533431f; float x1ac_attitudeRange = zeus::degToRad(89.f);
float x1b0_ = 1.5533431f; float x1b0_azimuthRange = zeus::degToRad(89.f);
zeus::CVector3f x1b4_lookAtOffset; zeus::CVector3f x1b4_lookAtOffset;
zeus::CVector3f x1c0_; zeus::CVector3f x1c0_lookPosAhead;
zeus::CVector3f x1cc_; zeus::CVector3f x1cc_fixedLookPos;
zeus::CVector3f x1d8_; zeus::CVector3f x1d8_lookPos;
zeus::CTransform x1e4_; zeus::CTransform x1e4_nextLookXf;
CCameraSpring x214_ballCameraSpring; CCameraSpring x214_ballCameraSpring;
CCameraSpring x228_ballCameraCentroidSpring; CCameraSpring x228_ballCameraCentroidSpring;
CCameraSpring x23c_ballCameraLookAtSpring; CCameraSpring x23c_ballCameraLookAtSpring;
@ -118,53 +125,53 @@ private:
std::vector<CCameraCollider> x264_smallColliders; std::vector<CCameraCollider> x264_smallColliders;
std::vector<CCameraCollider> x274_mediumColliders; std::vector<CCameraCollider> x274_mediumColliders;
std::vector<CCameraCollider> x284_largeColliders; std::vector<CCameraCollider> x284_largeColliders;
zeus::CVector3f x294_; zeus::CVector3f x294_dampedPos;
zeus::CVector3f x2a0_ = zeus::CVector3f::skUp; zeus::CVector3f x2a0_smallCentroid = zeus::CVector3f::skUp;
zeus::CVector3f x2ac_ = zeus::CVector3f::skUp; zeus::CVector3f x2ac_mediumCentroid = zeus::CVector3f::skUp;
zeus::CVector3f x2b8_ = zeus::CVector3f::skUp; zeus::CVector3f x2b8_largeCentroid = zeus::CVector3f::skUp;
int x2c4_ = 0; int x2c4_smallCollidersObsCount = 0;
int x2c8_ = 0; int x2c8_mediumCollidersObsCount = 0;
int x2cc_ = 0; int x2cc_largeCollidersObsCount = 0;
int x2d0_ = 0; int x2d0_smallColliderIt = 0;
int x2d4_ = 0; int x2d4_mediumColliderIt = 0;
int x2d8_ = 0; int x2d8_largeColliderIt = 0;
zeus::CVector3f x2dc_; zeus::CVector3f x2dc_prevBallPos;
float x2e8_ = 0.f; float x2e8_ballVelFlat = 0.f;
float x2ec_ = 0.f; float x2ec_maxBallVel = 0.f;
zeus::CVector3f x2f0_; zeus::CVector3f x2f0_ballDelta;
zeus::CVector3f x2fc_; zeus::CVector3f x2fc_ballDeltaFlat;
float x308_ = 0.f; float x308_speedFactor = 0.f;
float x30c_ = 0.f; float x30c_speedingTime = 0.f;
zeus::CVector3f x310_; zeus::CVector3f x310_idealLookVec;
zeus::CVector3f x31c_; zeus::CVector3f x31c_predictedLookPos;
u32 x328_ = 0; u32 x328_avoidGeomCycle = 0;
float x32c_ = 1.f; float x32c_colliderMag = 1.f;
float x330_ = 0.2f; float x330_clearColliderThreshold = 0.2f;
zeus::CAABox x334_ = zeus::CAABox::skNullBox; zeus::CAABox x334_collidersAABB = zeus::CAABox::skNullBox;
float x34c_ = 0.f; float x34c_obscuredTime = 0.f;
CMaterialList x350_ = {EMaterialTypes::Unknown}; CMaterialList x350_obscuringMaterial = {EMaterialTypes::Unknown};
float x358_ = 0.f; float x358_unobscureMag = 0.f;
zeus::CVector3f x35c_; zeus::CVector3f x35c_splineIntermediatePos;
TUniqueId x368_ = kInvalidUniqueId; TUniqueId x368_obscuringObjectId = kInvalidUniqueId;
u32 x36c_ = 0; ESplineState x36c_splineState = ESplineState::Invalid;
bool x370_24_ : 1; bool x370_24_reevalSplineEnd : 1;
float x374_ = 0.f; float x374_splineCtrl = 0.f;
float x378_; float x378_splineCtrlRange;
CCameraSpline x37c_camSpline; CCameraSpline x37c_camSpline;
CMaterialList x3c8_ = {EMaterialTypes::Unknown}; CMaterialList x3c8_collisionExcludeList = {EMaterialTypes::Unknown};
bool x3d0_24_ : 1; bool x3d0_24_camBehindFloorOrWall : 1;
float x3d4_ = 0.f; float x3d4_elevInterpTimer = 0.f;
float x3d8_ = 0.f; float x3d8_elevInterpStart = 0.f;
TUniqueId x3dc_tooCloseActorId = kInvalidUniqueId; TUniqueId x3dc_tooCloseActorId = kInvalidUniqueId;
float x3e0_tooCloseActorDist = 10000.f; float x3e0_tooCloseActorDist = 10000.f;
bool x3e4_ = false; bool x3e4_pendingFailsafe = false;
float x3e8_ = 0.f; float x3e8_ = 0.f;
float x3ec_ = 0.f; float x3ec_ = 0.f;
float x3f0_ = 0.f; float x3f0_ = 0.f;
float x3f4_ = 2.f; float x3f4_ = 2.f;
float x3f8_ = 0.f; float x3f8_ = 0.f;
float x3fc_ = 0.f; float x3fc_ = 0.f;
EBallCameraState x400_state = EBallCameraState::Zero; EBallCameraState x400_state = EBallCameraState::Default;
float x404_chaseElevation; float x404_chaseElevation;
float x408_chaseDistance; float x408_chaseDistance;
float x40c_chaseAnglePerSecond; float x40c_chaseAnglePerSecond;
@ -175,19 +182,19 @@ private:
float x438_boostAnglePerSecond; float x438_boostAnglePerSecond;
zeus::CVector3f x43c_boostLookAtOffset; zeus::CVector3f x43c_boostLookAtOffset;
CCameraSpring x448_ballCameraBoostSpring; CCameraSpring x448_ballCameraBoostSpring;
zeus::CVector3f x45c_; zeus::CVector3f x45c_overrideBallToCam;
float x468_; float x468_conservativeDoorCamDistance;
TUniqueId x46c_collisionActorId = kInvalidUniqueId; TUniqueId x46c_collisionActorId = kInvalidUniqueId;
float x470_ = 0.f; float x470_clampVelTimer = 0.f;
float x474_ = 0.f; float x474_clampVelRange = 0.f;
u32 x478_ = 0; u32 x478_shortMoveCount = 0;
std::unique_ptr<SFailsafeState> x47c_failsafeState; std::unique_ptr<SFailsafeState> x47c_failsafeState;
std::unique_ptr<u32> x480_; std::unique_ptr<u32> x480_;
void SetupColliders(std::vector<CCameraCollider>& out, float xMag, float zMag, float radius, int count, void SetupColliders(std::vector<CCameraCollider>& out, float xMag, float zMag, float radius, int count,
float tardis, float max, float startAngle); float k, float max, float startAngle);
void ResetSpline(CStateManager& mgr); void BuildSplineNav(CStateManager& mgr);
void BuildSpline(CStateManager& mgr); void BuildSplineArc(CStateManager& mgr);
bool ShouldResetSpline(CStateManager& mgr) const; bool ShouldResetSpline(CStateManager& mgr) const;
void UpdatePlayerMovement(float dt, CStateManager& mgr); void UpdatePlayerMovement(float dt, CStateManager& mgr);
void UpdateTransform(const zeus::CVector3f& lookDir, const zeus::CVector3f& pos, float dt, CStateManager& mgr); void UpdateTransform(const zeus::CVector3f& lookDir, const zeus::CVector3f& pos, float dt, CStateManager& mgr);
@ -197,41 +204,42 @@ private:
void UpdateObjectTooCloseId(CStateManager& mgr); void UpdateObjectTooCloseId(CStateManager& mgr);
void UpdateAnglePerSecond(float dt); void UpdateAnglePerSecond(float dt);
void UpdateUsingPathCameras(float dt, CStateManager& mgr); void UpdateUsingPathCameras(float dt, CStateManager& mgr);
zeus::CVector3f GetFixedLookTarget(const zeus::CVector3f& pos, CStateManager& mgr) const; zeus::CVector3f GetFixedLookTarget(const zeus::CVector3f& hintToLookDir, CStateManager& mgr) const;
void UpdateUsingFixedCameras(float dt, CStateManager& mgr); void UpdateUsingFixedCameras(float dt, CStateManager& mgr);
zeus::CVector3f ComputeVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& posDelta) const; zeus::CVector3f ComputeVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& posDelta) const;
zeus::CVector3f TweenVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& newVel, float rate, float dt); zeus::CVector3f TweenVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& newVel, float rate, float dt);
zeus::CVector3f MoveCollisionActor(const zeus::CVector3f& pos, float dt, CStateManager& mgr); zeus::CVector3f MoveCollisionActor(const zeus::CVector3f& pos, float dt, CStateManager& mgr);
void UpdateUsingFreeLook(float dt, CStateManager& mgr); void UpdateUsingFreeLook(float dt, CStateManager& mgr);
zeus::CVector3f InterpolateCameraElevation(const zeus::CVector3f& camPos); zeus::CVector3f InterpolateCameraElevation(const zeus::CVector3f& camPos, float dt);
zeus::CVector3f CalculateCollidersCentroid(const std::vector<CCameraCollider>& colliderList, int w1) const; zeus::CVector3f CalculateCollidersCentroid(const std::vector<CCameraCollider>& colliderList, int numObscured) const;
zeus::CVector3f ApplyColliders(); zeus::CVector3f ApplyColliders();
void UpdateColliders(const zeus::CTransform& xf, std::vector<CCameraCollider>& colliderList, int& r6, int r7, void UpdateColliders(const zeus::CTransform& xf, std::vector<CCameraCollider>& colliderList, int& it, int count,
float f1, const rstl::reserved_vector<TUniqueId, 1024>& nearList, float dt, float tolerance, const rstl::reserved_vector<TUniqueId, 1024>& nearList, float dt,
CStateManager& mgr); CStateManager& mgr);
zeus::CVector3f AvoidGeometry(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, 1024>& nearList, zeus::CVector3f AvoidGeometry(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
float dt, CStateManager& mgr); float dt, CStateManager& mgr);
zeus::CVector3f AvoidGeometryFull(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, 1024>& nearList, zeus::CVector3f AvoidGeometryFull(const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
float dt, CStateManager& mgr); float dt, CStateManager& mgr);
zeus::CAABox CalculateCollidersBoundingBox(const std::vector<CCameraCollider>& colliderList, zeus::CAABox CalculateCollidersBoundingBox(const std::vector<CCameraCollider>& colliderList,
CStateManager& mgr) const; CStateManager& mgr) const;
int CountObscuredColliders(const std::vector<CCameraCollider>& colliderList) const; int CountObscuredColliders(const std::vector<CCameraCollider>& colliderList) const;
void UpdateCollidersDistances(std::vector<CCameraCollider>& colliderList, float f1, float f2, float f3); void UpdateCollidersDistances(std::vector<CCameraCollider>& colliderList, float xMag, float zMag, float angOffset);
void UpdateUsingColliders(float dt, CStateManager& mgr); void UpdateUsingColliders(float dt, CStateManager& mgr);
void UpdateUsingSpindleCameras(float dt, CStateManager& mgr); void UpdateUsingSpindleCameras(float dt, CStateManager& mgr);
zeus::CVector3f ClampElevationToWater(zeus::CVector3f& pos, CStateManager& mgr) const; zeus::CVector3f ClampElevationToWater(zeus::CVector3f& pos, CStateManager& mgr) const;
void UpdateTransitionFromBallCamera(CStateManager& mgr); void UpdateTransitionFromBallCamera(CStateManager& mgr);
void UpdateUsingTransitions(float dt, CStateManager& mgr); void UpdateUsingTransitions(float dt, CStateManager& mgr);
zeus::CTransform UpdateCameraPositions(float dt, const zeus::CTransform& oldXf, const zeus::CTransform& newXf); zeus::CTransform UpdateCameraPositions(float dt, const zeus::CTransform& oldXf, const zeus::CTransform& newXf);
static zeus::CVector3f GetFailsafeBezierPoint(const std::vector<zeus::CVector3f>& points, float t); static zeus::CVector3f GetFailsafeSplinePoint(const std::vector<zeus::CVector3f>& points, float t);
bool CheckFailsafeFromMorphBallState(CStateManager& mgr) const; bool CheckFailsafeFromMorphBallState(CStateManager& mgr) const;
bool SplineIntersectTest(CMaterialList& intersectMat, CStateManager& mgr) const; bool SplineIntersectTest(CMaterialList& intersectMat, CStateManager& mgr) const;
static bool IsBallNearDoor(const zeus::CVector3f& pos, CStateManager& mgr); static bool IsBallNearDoor(const zeus::CVector3f& pos, CStateManager& mgr);
void ActivateFailsafe(float dt, CStateManager& mgr); void ActivateFailsafe(float dt, CStateManager& mgr);
bool ConstrainElevationAndDistance(float& elevation, float& distance, float dt, CStateManager& mgr); bool ConstrainElevationAndDistance(float& elevation, float& distance, float dt, CStateManager& mgr);
zeus::CVector3f FindDesiredPosition(float distance, float elevation, const zeus::CVector3f& dir, zeus::CVector3f FindDesiredPosition(float distance, float elevation, const zeus::CVector3f& dir,
CStateManager& mgr, bool b); CStateManager& mgr, bool fullTest);
static bool DetectCollision(const zeus::CVector3f& from, const zeus::CVector3f& to, float margin, static bool DetectCollision(const zeus::CVector3f& from, const zeus::CVector3f& to, float radius,
float& d, CStateManager& mgr); float& d, CStateManager& mgr);
void TeleportColliders(std::vector<CCameraCollider>& colliderList, const zeus::CVector3f& pos); void TeleportColliders(std::vector<CCameraCollider>& colliderList, const zeus::CVector3f& pos);
static bool CheckTransitionLineOfSight(const zeus::CVector3f& eyePos, const zeus::CVector3f& behindPos, static bool CheckTransitionLineOfSight(const zeus::CVector3f& eyePos, const zeus::CVector3f& behindPos,
@ -254,12 +262,12 @@ public:
float GetTooCloseActorDistance() const { return x3e0_tooCloseActorDist; } float GetTooCloseActorDistance() const { return x3e0_tooCloseActorDist; }
void TeleportCamera(const zeus::CVector3f& pos, CStateManager& mgr); void TeleportCamera(const zeus::CVector3f& pos, CStateManager& mgr);
void TeleportCamera(const zeus::CTransform& xf, CStateManager& mgr); void TeleportCamera(const zeus::CTransform& xf, CStateManager& mgr);
const zeus::CVector3f& GetX1D8() const { return x1d8_; } const zeus::CVector3f& GetLookPos() const { return x1d8_lookPos; }
void ResetToTweaks(CStateManager& mgr); void ResetToTweaks(CStateManager& mgr);
void UpdateLookAtPosition(float dt, CStateManager& mgr); void UpdateLookAtPosition(float dt, CStateManager& mgr);
zeus::CTransform UpdateLookDirection(const zeus::CVector3f& dir, CStateManager& mgr); zeus::CTransform UpdateLookDirection(const zeus::CVector3f& dir, CStateManager& mgr);
void SetX470(float f) { x470_ = f; } void SetClampVelTimer(float f) { x470_clampVelTimer = f; }
void SetX474(float f) { x474_ = f; } void SetClampVelRange(float f) { x474_clampVelRange = f; }
void ApplyCameraHint(CStateManager& mgr); void ApplyCameraHint(CStateManager& mgr);
void ResetPosition(CStateManager& mgr); void ResetPosition(CStateManager& mgr);
void DoorClosed(TUniqueId doorId); void DoorClosed(TUniqueId doorId);

View File

@ -168,12 +168,12 @@ void CCameraManager::SetSpindleCamera(TUniqueId id, CStateManager& mgr)
} }
void CCameraManager::InterpolateToBallCamera(const zeus::CTransform& xf, TUniqueId camId, void CCameraManager::InterpolateToBallCamera(const zeus::CTransform& xf, TUniqueId camId,
const zeus::CVector3f& lookDir, float f1, float f2, float f3, const zeus::CVector3f& lookPos, float f1, float f2, float f3,
bool b1, CStateManager& mgr) bool b1, CStateManager& mgr)
{ {
if (!IsInFirstPersonCamera()) if (!IsInFirstPersonCamera())
{ {
x88_interpCamera->SetInterpolation(xf, lookDir, f1, f2, f3, camId, b1, mgr); x88_interpCamera->SetInterpolation(xf, lookPos, f1, f2, f3, camId, b1, mgr);
if (!ShouldBypassInterpolation()) if (!ShouldBypassInterpolation())
SetCurrentCameraId(x88_interpCamera->GetUniqueId(), mgr); SetCurrentCameraId(x88_interpCamera->GetUniqueId(), mgr);
} }
@ -197,18 +197,19 @@ void CCameraManager::RestoreHintlessCamera(CStateManager& mgr)
x80_ballCamera->ResetToTweaks(mgr); x80_ballCamera->ResetToTweaks(mgr);
x80_ballCamera->UpdateLookAtPosition(0.f, mgr); x80_ballCamera->UpdateLookAtPosition(0.f, mgr);
if (!mgr.GetPlayer().IsMorphBallTransitioning() && if (!mgr.GetPlayer().IsMorphBallTransitioning() &&
hint->GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Zero) hint->GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Default)
{ {
if ((hint->GetHint().GetOverrideFlags() & 0x1000) != 0) if ((hint->GetHint().GetOverrideFlags() & 0x1000) != 0)
{ {
x80_ballCamera->SetX474(hint->GetHint().GetX4C()); x80_ballCamera->SetClampVelRange(hint->GetHint().GetClampVelRange());
x80_ballCamera->SetX470(hint->GetHint().GetX5C()); x80_ballCamera->SetClampVelTimer(hint->GetHint().GetClampVelTime());
} }
else else
{ {
x80_ballCamera->TeleportCamera(x80_ballCamera->UpdateLookDirection(camToPlayerFlat, mgr), mgr); x80_ballCamera->TeleportCamera(x80_ballCamera->UpdateLookDirection(camToPlayerFlat, mgr), mgr);
InterpolateToBallCamera(ballCamXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetX1D8(), InterpolateToBallCamera(ballCamXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetLookPos(),
hint->GetHint().GetX5C(), hint->GetHint().GetX4C(), hint->GetHint().GetX50(), hint->GetHint().GetClampVelTime(), hint->GetHint().GetClampVelRange(),
hint->GetHint().GetX50(),
(hint->GetHint().GetOverrideFlags() & 0x800) != 0, mgr); (hint->GetHint().GetOverrideFlags() & 0x800) != 0, mgr);
} }
} }
@ -228,9 +229,9 @@ void CCameraManager::SkipBallCameraCinematic(CStateManager& mgr)
void CCameraManager::ApplyCameraHint(const CScriptCameraHint& hint, CStateManager& mgr) void CCameraManager::ApplyCameraHint(const CScriptCameraHint& hint, CStateManager& mgr)
{ {
if (x80_ballCamera->GetState() == CBallCamera::EBallCameraState::Four) if (x80_ballCamera->GetState() == CBallCamera::EBallCameraState::ToBall)
{ {
x80_ballCamera->SetState(CBallCamera::EBallCameraState::Zero, mgr); x80_ballCamera->SetState(CBallCamera::EBallCameraState::Default, mgr);
mgr.GetPlayer().SetCameraState(CPlayer::EPlayerCameraState::Ball, mgr); mgr.GetPlayer().SetCameraState(CPlayer::EPlayerCameraState::Ball, mgr);
} }
@ -246,11 +247,11 @@ void CCameraManager::ApplyCameraHint(const CScriptCameraHint& hint, CStateManage
switch (hint.GetHint().GetBehaviourType()) switch (hint.GetHint().GetBehaviourType())
{ {
case CBallCamera::EBallCameraBehaviour::Six: case CBallCamera::EBallCameraBehaviour::PathCameraDesiredPos:
case CBallCamera::EBallCameraBehaviour::Seven: case CBallCamera::EBallCameraBehaviour::PathCamera:
SetPathCamera(hint.GetDelegatedCamera(), mgr); SetPathCamera(hint.GetDelegatedCamera(), mgr);
break; break;
case CBallCamera::EBallCameraBehaviour::Eight: case CBallCamera::EBallCameraBehaviour::SpindleCamera:
SetSpindleCamera(hint.GetDelegatedCamera(), mgr); SetSpindleCamera(hint.GetDelegatedCamera(), mgr);
break; break;
default: default:
@ -265,11 +266,11 @@ void CCameraManager::ApplyCameraHint(const CScriptCameraHint& hint, CStateManage
x80_ballCamera->UpdateLookAtPosition(0.f, mgr); x80_ballCamera->UpdateLookAtPosition(0.f, mgr);
if ((hint.GetHint().GetOverrideFlags() & 0x20) == 0 && if ((hint.GetHint().GetOverrideFlags() & 0x20) == 0 &&
(hint.GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Zero || (hint.GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Default ||
(oldHint && oldHint->GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Zero))) (oldHint && oldHint->GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Default)))
{ {
InterpolateToBallCamera(camXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetX1D8(), InterpolateToBallCamera(camXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetLookPos(),
hint.GetHint().GetX58(), hint.GetHint().GetX4C(), hint.GetHint().GetX50(), hint.GetHint().GetX58(), hint.GetHint().GetClampVelRange(), hint.GetHint().GetX50(),
(hint.GetHint().GetOverrideFlags() & 0x400) != 0, mgr); (hint.GetHint().GetOverrideFlags() & 0x400) != 0, mgr);
} }
} }
@ -381,7 +382,7 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr)
if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(it->second)) if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(it->second))
{ {
if ((hint->GetHint().GetOverrideFlags() & 0x80) != 0 && hint->GetPriority() == if ((hint->GetHint().GetOverrideFlags() & 0x80) != 0 && hint->GetPriority() ==
bestHint->GetPriority() && bestHint->GetPriority() &&
hint->GetAreaIdAlways() == bestHint->GetAreaIdAlways()) hint->GetAreaIdAlways() == bestHint->GetAreaIdAlways())
{ {
zeus::CVector3f hintToBall = ballPos - bestHint->GetTranslation(); zeus::CVector3f hintToBall = ballPos - bestHint->GetTranslation();
@ -478,12 +479,12 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr)
} }
else if (xa6_camHintId != bestHint->GetUniqueId()) else if (xa6_camHintId != bestHint->GetUniqueId())
{ {
if (bestHint->GetHint().GetBehaviourType() == CBallCamera::EBallCameraBehaviour::Three) if (bestHint->GetHint().GetBehaviourType() == CBallCamera::EBallCameraBehaviour::HintInitializePosition)
{ {
if ((bestHint->GetHint().GetOverrideFlags() & 0x20) != 0) if ((bestHint->GetHint().GetOverrideFlags() & 0x20) != 0)
{ {
x80_ballCamera->TeleportCamera( x80_ballCamera->TeleportCamera(
zeus::lookAt(bestHint->GetTranslation(), x80_ballCamera->GetX1D8()), mgr); zeus::lookAt(bestHint->GetTranslation(), x80_ballCamera->GetLookPos()), mgr);
} }
DeleteCameraHint(bestHint->GetUniqueId(), mgr); DeleteCameraHint(bestHint->GetUniqueId(), mgr);
if ((bestHint->GetHint().GetOverrideFlags() & 0x2000) != 0) if ((bestHint->GetHint().GetOverrideFlags() & 0x2000) != 0)
@ -659,7 +660,7 @@ void CCameraManager::SetupBallCamera(CStateManager& mgr)
{ {
if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(xa6_camHintId)) if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(xa6_camHintId))
{ {
if (hint->GetHint().GetBehaviourType() == CBallCamera::EBallCameraBehaviour::Three) if (hint->GetHint().GetBehaviourType() == CBallCamera::EBallCameraBehaviour::HintInitializePosition)
{ {
if ((hint->GetHint().GetOverrideFlags() & 0x20) != 0) if ((hint->GetHint().GetOverrideFlags() & 0x20) != 0)
x80_ballCamera->TeleportCamera(hint->GetTransform(), mgr); x80_ballCamera->TeleportCamera(hint->GetTransform(), mgr);

View File

@ -76,7 +76,7 @@ class CCameraManager
void SetPathCamera(TUniqueId id, CStateManager& mgr); void SetPathCamera(TUniqueId id, CStateManager& mgr);
void SetSpindleCamera(TUniqueId id, CStateManager& mgr); void SetSpindleCamera(TUniqueId id, CStateManager& mgr);
void RestoreHintlessCamera(CStateManager& mgr); void RestoreHintlessCamera(CStateManager& mgr);
void InterpolateToBallCamera(const zeus::CTransform& xf, TUniqueId camId, const zeus::CVector3f& lookDir, void InterpolateToBallCamera(const zeus::CTransform& xf, TUniqueId camId, const zeus::CVector3f& lookPos,
float f1, float f2, float f3, bool b1, CStateManager& mgr); float f1, float f2, float f3, bool b1, CStateManager& mgr);
static constexpr bool ShouldBypassInterpolation() { return false; } static constexpr bool ShouldBypassInterpolation() { return false; }
void SkipBallCameraCinematic(CStateManager& mgr); void SkipBallCameraCinematic(CStateManager& mgr);

View File

@ -44,7 +44,7 @@ void CInterpolationCamera::Think(float, CStateManager& mgr)
} }
void CInterpolationCamera::SetInterpolation(const zeus::CTransform& xf, const zeus::CVector3f& lookDir, void CInterpolationCamera::SetInterpolation(const zeus::CTransform& xf, const zeus::CVector3f& lookPos,
float f1, float f2, float f3, TUniqueId camId, bool b1, CStateManager& mgr) float f1, float f2, float f3, TUniqueId camId, bool b1, CStateManager& mgr)
{ {

View File

@ -16,7 +16,7 @@ public:
void Render(const CStateManager&) const; void Render(const CStateManager&) const;
void Reset(const zeus::CTransform&, CStateManager& mgr); void Reset(const zeus::CTransform&, CStateManager& mgr);
void Think(float, CStateManager &); void Think(float, CStateManager &);
void SetInterpolation(const zeus::CTransform& xf, const zeus::CVector3f& lookDir, void SetInterpolation(const zeus::CTransform& xf, const zeus::CVector3f& lookPos,
float f1, float f2, float f3, TUniqueId camId, bool b1, CStateManager& mgr); float f1, float f2, float f3, TUniqueId camId, bool b1, CStateManager& mgr);
}; };

View File

@ -82,16 +82,16 @@ static const char* LightingShadowHLSL =
"{\n" "{\n"
" float4 ret = ambient;\n" " float4 ret = ambient;\n"
" \n" " \n"
" float3 delta = mvPosIn.xyz - lights[i].pos.xyz;\n" " float3 delta = mvPosIn.xyz - lights[0].pos.xyz;\n"
" float dist = length(delta);\n" " float dist = length(delta);\n"
" float angDot = saturate(dot(normalize(delta), lights[i].dir.xyz));\n" " float angDot = saturate(dot(normalize(delta), lights[0].dir.xyz));\n"
" float att = 1.0 / (lights[i].linAtt[2] * dist * dist +\n" " float att = 1.0 / (lights[0].linAtt[2] * dist * dist +\n"
" lights[i].linAtt[1] * dist +\n" " lights[0].linAtt[1] * dist +\n"
" lights[i].linAtt[0]);\n" " lights[0].linAtt[0]);\n"
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n" " float angAtt = lights[0].angAtt[2] * angDot * angDot +\n"
" lights[i].angAtt[1] * angDot +\n" " lights[0].angAtt[1] * angDot +\n"
" lights[i].angAtt[0];\n" " lights[0].angAtt[0];\n"
" ret += lights[i].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn.xyz)) *\n" " ret += lights[0].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn.xyz)) *\n"
" extTex0.Sample(clampSamp, vtf.extTcgs[0]).r;\n" " extTex0.Sample(clampSamp, vtf.extTcgs[0]).r;\n"
" \n" " \n"
" for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n" " for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"

View File

@ -83,16 +83,16 @@ static const char* LightingShadowMetal =
"{\n" "{\n"
" float4 ret = lu.ambient;\n" " float4 ret = lu.ambient;\n"
" \n" " \n"
" float3 delta = mvPosIn.xyz - lu.lights[i].pos.xyz;\n" " float3 delta = mvPosIn.xyz - lu.lights[0].pos.xyz;\n"
" float dist = length(delta);\n" " float dist = length(delta);\n"
" float angDot = saturate(dot(normalize(delta), lu.lights[i].dir.xyz));\n" " float angDot = saturate(dot(normalize(delta), lu.lights[0].dir.xyz));\n"
" float att = 1.0 / (lu.lights[i].linAtt[2] * dist * dist +\n" " float att = 1.0 / (lu.lights[0].linAtt[2] * dist * dist +\n"
" lu.lights[i].linAtt[1] * dist +\n" " lu.lights[0].linAtt[1] * dist +\n"
" lu.lights[i].linAtt[0]);\n" " lu.lights[0].linAtt[0]);\n"
" float angAtt = lu.lights[i].angAtt[2] * angDot * angDot +\n" " float angAtt = lu.lights[0].angAtt[2] * angDot * angDot +\n"
" lu.lights[i].angAtt[1] * angDot +\n" " lu.lights[0].angAtt[1] * angDot +\n"
" lu.lights[i].angAtt[0];\n" " lu.lights[0].angAtt[0];\n"
" ret += lu.lights[i].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn.xyz)) *\n" " ret += lu.lights[0].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn.xyz)) *\n"
" extTex0.sample(clampSamp, vtf.extTcgs0);\n" " extTex0.sample(clampSamp, vtf.extTcgs0);\n"
" \n" " \n"
" for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n" " for (int i=1 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"

View File

@ -189,11 +189,11 @@ void CPlayer::TransitionToMorphBallState(float dt, CStateManager& mgr)
if (!mgr.GetCameraManager()->HasBallCameraInitialPositionHint(mgr)) if (!mgr.GetCameraManager()->HasBallCameraInitialPositionHint(mgr))
{ {
mgr.GetCameraManager()->SetupBallCamera(mgr); mgr.GetCameraManager()->SetupBallCamera(mgr);
ballCam->SetState(CBallCamera::EBallCameraState::Four, mgr); ballCam->SetState(CBallCamera::EBallCameraState::ToBall, mgr);
} }
else else
{ {
ballCam->SetState(CBallCamera::EBallCameraState::Zero, mgr); ballCam->SetState(CBallCamera::EBallCameraState::Default, mgr);
SetCameraState(EPlayerCameraState::Ball, mgr); SetCameraState(EPlayerCameraState::Ball, mgr);
zeus::CTransform newXf = mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform(); zeus::CTransform newXf = mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform();
ballCam->SetTransform(newXf); ballCam->SetTransform(newXf);
@ -304,7 +304,7 @@ void CPlayer::TransitionFromMorphBallState(CStateManager& mgr)
ForceGunOrientation(x34_transform, mgr); ForceGunOrientation(x34_transform, mgr);
DrawGun(mgr); DrawGun(mgr);
ballCam->SetState(CBallCamera::EBallCameraState::Five, mgr); ballCam->SetState(CBallCamera::EBallCameraState::FromBall, mgr);
ClearForcesAndTorques(); ClearForcesAndTorques();
SetAngularVelocityWR(zeus::CAxisAngle::sIdentity); SetAngularVelocityWR(zeus::CAxisAngle::sIdentity);
AddMaterial(EMaterialTypes::GroundCollider, mgr); AddMaterial(EMaterialTypes::GroundCollider, mgr);
@ -6173,7 +6173,7 @@ void CPlayer::LeaveMorphBallState(CStateManager& mgr)
x3f0_vertFreeLookAngleVel = 0.f; x3f0_vertFreeLookAngleVel = 0.f;
x768_morphball->LeaveMorphBallState(mgr); x768_morphball->LeaveMorphBallState(mgr);
mgr.GetCameraManager()->SetPlayerCamera(mgr, mgr.GetCameraManager()->GetFirstPersonCamera()->GetUniqueId()); mgr.GetCameraManager()->SetPlayerCamera(mgr, mgr.GetCameraManager()->GetFirstPersonCamera()->GetUniqueId());
mgr.GetCameraManager()->GetBallCamera()->SetState(CBallCamera::EBallCameraState::Zero, mgr); mgr.GetCameraManager()->GetBallCamera()->SetState(CBallCamera::EBallCameraState::Default, mgr);
SetCameraState(EPlayerCameraState::FirstPerson, mgr); SetCameraState(EPlayerCameraState::FirstPerson, mgr);
mgr.GetCameraManager()->GetFirstPersonCamera()->DeferBallTransitionProcessing(); mgr.GetCameraManager()->GetFirstPersonCamera()->DeferBallTransitionProcessing();
mgr.GetCameraManager()->GetFirstPersonCamera()->Think(0.f, mgr); mgr.GetCameraManager()->GetFirstPersonCamera()->Think(0.f, mgr);
@ -6205,7 +6205,7 @@ void CPlayer::EnterMorphBallState(CStateManager& mgr)
void CPlayer::ActivateMorphBallCamera(CStateManager& mgr) void CPlayer::ActivateMorphBallCamera(CStateManager& mgr)
{ {
SetCameraState(EPlayerCameraState::Ball, mgr); SetCameraState(EPlayerCameraState::Ball, mgr);
mgr.GetCameraManager()->GetBallCamera()->SetState(CBallCamera::EBallCameraState::Zero, mgr); mgr.GetCameraManager()->GetBallCamera()->SetState(CBallCamera::EBallCameraState::Default, mgr);
} }
void CPlayer::UpdateCinematicState(CStateManager& mgr) void CPlayer::UpdateCinematicState(CStateManager& mgr)

View File

@ -8,13 +8,17 @@ namespace urde
CScriptCameraHint::CScriptCameraHint(TUniqueId uid, const std::string& name, const CEntityInfo& info, CScriptCameraHint::CScriptCameraHint(TUniqueId uid, const std::string& name, const CEntityInfo& info,
const zeus::CTransform& xf, bool active, s32 priority, const zeus::CTransform& xf, bool active, s32 priority,
CBallCamera::EBallCameraBehaviour behaviour, s32 overrideFlags, float f1, CBallCamera::EBallCameraBehaviour behaviour, u32 overrideFlags, float minDist,
float f2, float f3, const zeus::CVector3f& r6, const zeus::CVector3f& r7, float maxDist, float backwardsDist, const zeus::CVector3f& lookAtOffset,
const zeus::CVector3f& r8, float f4, float f5, float f6, float f7, const zeus::CVector3f& chaseLookAtOffset, const zeus::CVector3f& ballToCam,
float f8, float f9, float f10, float f11, float f12, float f13) float fov, float attitudeRange, float azimuthRange, float anglePerSecond,
float clampVelRange, float f9, float elevation, float f11,
float clampVelTime, float controlInterpDur)
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Unknown), : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Unknown),
CActorParameters::None(), kInvalidUniqueId), xe8_priority(priority), CActorParameters::None(), kInvalidUniqueId), xe8_priority(priority),
xec_hint(overrideFlags, behaviour, f1, f2, f3, r6, r7, r8, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13), xec_hint(overrideFlags, behaviour, minDist, maxDist, backwardsDist, lookAtOffset, chaseLookAtOffset, ballToCam,
fov, attitudeRange, azimuthRange, anglePerSecond, clampVelRange, f9, elevation, f11, clampVelTime,
controlInterpDur),
x168_origXf(xf) x168_origXf(xf)
{ {
} }

View File

@ -9,39 +9,55 @@ namespace urde
class CCameraHint class CCameraHint
{ {
s32 x4_overrideFlags; u32 x4_overrideFlags;
CBallCamera::EBallCameraBehaviour x8_behaviour; CBallCamera::EBallCameraBehaviour x8_behaviour;
float xc_f1; float xc_minDist;
float x10_f2; float x10_maxDist;
float x14_f3; float x14_backwardsDist;
zeus::CVector3f x18_r6; zeus::CVector3f x18_lookAtOffset;
zeus::CVector3f x24_r7; zeus::CVector3f x24_chaseLookAtOffset;
zeus::CVector3f x30_r8; zeus::CVector3f x30_ballToCam;
float x3c_f4; float x3c_fov;
float x40_f5; float x40_attitudeRange;
float x44_f6; float x44_azimuthRange;
float x48_f7; float x48_anglePerSecond;
float x4c_f8; float x4c_clampVelRange;
float x50_f9; float x50_f9;
float x54_f10; float x54_elevation;
float x58_f11; float x58_f11;
float x5c_f12; float x5c_clampVelTime;
float x60_f13; float x60_controlInterpDur;
public: public:
CCameraHint(s32 overrideFlags, CBallCamera::EBallCameraBehaviour behaviour, float f1, float f2, float f3, CCameraHint(u32 overrideFlags, CBallCamera::EBallCameraBehaviour behaviour, float minDist, float maxDist,
const zeus::CVector3f& r6, const zeus::CVector3f& r7, const zeus::CVector3f& r8, float f4, float backwardsDist, const zeus::CVector3f& lookAtOffset, const zeus::CVector3f& chaseLookAtOffset,
float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13) const zeus::CVector3f& ballToCam, float fov, float attitudeRange, float azimuthRange,
: x4_overrideFlags(overrideFlags), x8_behaviour(behaviour), xc_f1(f1), x10_f2(f2), x14_f3(f3), x18_r6(r6), float anglePerSecond, float clampVelRange, float f9, float elevation, float f11,
x24_r7(r7), x30_r8(r8), x3c_f4(f4), x40_f5(f5), x44_f6(f6), x48_f7(f7), x4c_f8(f8), x50_f9(f9), x54_f10(f10), float clampVelTime, float controlInterpDur)
x58_f11(f11), x5c_f12(f12), x60_f13(f13) {} : x4_overrideFlags(overrideFlags), x8_behaviour(behaviour), xc_minDist(minDist), x10_maxDist(maxDist),
x14_backwardsDist(backwardsDist), x18_lookAtOffset(lookAtOffset), x24_chaseLookAtOffset(chaseLookAtOffset),
x30_ballToCam(ballToCam), x3c_fov(fov), x40_attitudeRange(attitudeRange), x44_azimuthRange(azimuthRange),
x48_anglePerSecond(anglePerSecond), x4c_clampVelRange(clampVelRange), x50_f9(f9), x54_elevation(elevation),
x58_f11(f11), x5c_clampVelTime(clampVelTime), x60_controlInterpDur(controlInterpDur) {}
s32 GetOverrideFlags() const { return x4_overrideFlags; } u32 GetOverrideFlags() const { return x4_overrideFlags; }
CBallCamera::EBallCameraBehaviour GetBehaviourType() const { return x8_behaviour; } CBallCamera::EBallCameraBehaviour GetBehaviourType() const { return x8_behaviour; }
float GetX4C() const { return x4c_f8; } float GetMinDist() const { return xc_minDist; }
float GetMaxDist() const { return x10_maxDist; }
float GetBackwardsDist() const { return x14_backwardsDist; }
const zeus::CVector3f& GetLookAtOffset() const { return x18_lookAtOffset; }
const zeus::CVector3f& GetChaseLookAtOffset() const { return x24_chaseLookAtOffset; }
const zeus::CVector3f& GetBallToCam() const { return x30_ballToCam; }
float GetFov() const { return x3c_fov; }
float GetAttitudeRange() const { return x40_attitudeRange; }
float GetAzimuthRange() const { return x44_azimuthRange; }
float GetAnglePerSecond() const { return x48_anglePerSecond; }
float GetClampVelRange() const { return x4c_clampVelRange; }
float GetX50() const { return x50_f9; } float GetX50() const { return x50_f9; }
float GetElevation() const { return x54_elevation; }
float GetX58() const { return x58_f11; } float GetX58() const { return x58_f11; }
float GetX5C() const { return x5c_f12; } float GetClampVelTime() const { return x5c_clampVelTime; }
float GetControlInterpDur() const { return x60_controlInterpDur; }
}; };
class CScriptCameraHint : public CActor class CScriptCameraHint : public CActor
@ -57,10 +73,11 @@ class CScriptCameraHint : public CActor
void RemoveHelper(TUniqueId id); void RemoveHelper(TUniqueId id);
public: public:
CScriptCameraHint(TUniqueId, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CScriptCameraHint(TUniqueId, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf,
bool active, s32 priority, CBallCamera::EBallCameraBehaviour behaviour, s32 overrideFlags, bool active, s32 priority, CBallCamera::EBallCameraBehaviour behaviour, u32 overrideFlags,
float f1, float f2, float f3, const zeus::CVector3f& r6, const zeus::CVector3f& r7, float minDist, float maxDist, float backwardsDist, const zeus::CVector3f& lookAtOffset,
const zeus::CVector3f& r8, float f4, float f5, float f6, float f7, float f8, float f9, float f10, const zeus::CVector3f& chaseLookAtOffset, const zeus::CVector3f& ballToCam, float fov,
float f11, float f12, float f13); float attitudeRange, float azimuthRange, float anglePerSecond, float clampVelRange, float f9,
float elevation, float f11, float clampVelTime, float controlInterpDur);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr);

View File

@ -34,7 +34,7 @@ CScriptDoor::CScriptDoor(TUniqueId uid, const std::string& name, const CEntityIn
{ {
x2a8_29_ballDoor = ballDoor; x2a8_29_ballDoor = ballDoor;
x2a8_25_ = open; x2a8_25_ = open;
x2a8_26_ = open; x2a8_26_useConservativeCameraDistance = open;
x2a8_28_ = b2; x2a8_28_ = b2;
x2a8_27_ = true; x2a8_27_ = true;
x264_ = GetBoundingBox(); x264_ = GetBoundingBox();
@ -70,7 +70,7 @@ void CScriptDoor::Think(float dt, CStateManager& mgr)
if (!GetActive()) if (!GetActive())
return; return;
if (!x2a8_26_) if (!x2a8_26_useConservativeCameraDistance)
{ {
if (x25c_ < 0.5f) if (x25c_ < 0.5f)
x25c_ += dt; x25c_ += dt;
@ -86,9 +86,9 @@ void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, CStateManager
/* ORIGINAL 0-00 OFFSET: 8007E0BC */ /* ORIGINAL 0-00 OFFSET: 8007E0BC */
void CScriptDoor::ForceClosed(CStateManager & mgr) void CScriptDoor::ForceClosed(CStateManager & mgr)
{ {
if (x2a8_26_) if (x2a8_26_useConservativeCameraDistance)
{ {
x2a8_26_ = false; x2a8_26_useConservativeCameraDistance = false;
x2a8_25_ = false; x2a8_25_ = false;
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(x8_uid); mgr.GetCameraManager()->GetBallCamera()->DoorClosing(x8_uid);

View File

@ -42,7 +42,7 @@ public:
{ {
bool x2a8_24_ : 1; bool x2a8_24_ : 1;
bool x2a8_25_ : 1; bool x2a8_25_ : 1;
bool x2a8_26_ : 1; bool x2a8_26_useConservativeCameraDistance : 1;
bool x2a8_27_ : 1; bool x2a8_27_ : 1;
bool x2a8_28_ : 1; bool x2a8_28_ : 1;
bool x2a8_29_ballDoor : 1; bool x2a8_29_ballDoor : 1;

View File

@ -845,41 +845,43 @@ CEntity* ScriptLoader::LoadCameraHint(CStateManager& mgr, CInputStream& in, int
SActorHead head = LoadActorHead(in, mgr); SActorHead head = LoadActorHead(in, mgr);
bool active = in.readBool(); bool active = in.readBool();
u32 w1 = in.readUint32Big(); u32 prio = in.readUint32Big();
auto behaviour = CBallCamera::EBallCameraBehaviour(in.readUint32Big()); auto behaviour = CBallCamera::EBallCameraBehaviour(in.readUint32Big());
u32 pf = LoadParameterFlags(in); u32 overrideFlags = LoadParameterFlags(in);
pf |= in.readBool() << 6; overrideFlags |= in.readBool() << 22;
float f1 = in.readFloatBig(); float minDist = in.readFloatBig();
pf |= in.readBool() << 7; overrideFlags |= in.readBool() << 23;
float f2 = in.readFloatBig(); float maxDist = in.readFloatBig();
pf |= in.readBool() << 8; overrideFlags |= in.readBool() << 24;
float f3 = in.readFloatBig(); float backwardsDist = in.readFloatBig();
zeus::CVector3f vec1; overrideFlags |= in.readBool() << 25;
vec1.readBig(in); zeus::CVector3f lookAtOffset;
pf |= in.readBool() << 9; lookAtOffset.readBig(in);
zeus::CVector3f vec2; overrideFlags |= in.readBool() << 26;
vec2.readBig(in); zeus::CVector3f chaseLookAtOffset;
zeus::CVector3f vec3; chaseLookAtOffset.readBig(in);
vec3.readBig(in); zeus::CVector3f ballToCam;
pf |= in.readBool() << 10; ballToCam.readBig(in);
float f4 = in.readFloatBig(); overrideFlags |= in.readBool() << 27;
pf |= in.readBool() << 11; float fov = in.readFloatBig();
float f5 = in.readFloatBig(); overrideFlags |= in.readBool() << 28;
pf |= in.readBool() << 12; float attitudeRange = in.readFloatBig();
float f6 = in.readFloatBig(); overrideFlags |= in.readBool() << 29;
pf |= in.readBool() << 13; float azimuthRange = in.readFloatBig();
float f7 = in.readFloatBig(); overrideFlags |= in.readBool() << 30;
float f8 = in.readFloatBig(); float anglePerSecond = in.readFloatBig();
float clampVelRange = in.readFloatBig();
float f9 = in.readFloatBig(); float f9 = in.readFloatBig();
pf |= in.readBool() << 14; overrideFlags |= in.readBool() << 31;
float f10 = in.readFloatBig(); float elevation = in.readFloatBig();
float f11 = in.readFloatBig(); float f11 = in.readFloatBig();
float f12 = in.readFloatBig(); float clampVelTime = in.readFloatBig();
float f13 = in.readFloatBig(); float controlInterpDur = in.readFloatBig();
return new CScriptCameraHint(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, active, w1, return new CScriptCameraHint(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, active, prio,
behaviour, pf, f1, f2, f3, vec1, vec2, vec3, f4, f5, f6, f7, f8, f9, f10, behaviour, overrideFlags, minDist, maxDist, backwardsDist, lookAtOffset,
f11, f12, f13); chaseLookAtOffset, ballToCam, fov, attitudeRange, azimuthRange, anglePerSecond,
clampVelRange, f9, elevation, f11, clampVelTime, controlInterpDur);
} }
CEntity* ScriptLoader::LoadPickup(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadPickup(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)