@@ -30,6 +30,7 @@ class Camera final {
3030 Dive,
3131 Fall,
3232 Cutscene,
33+ FirstPerson,
3334 };
3435
3536 enum MarvinMode {
@@ -49,7 +50,7 @@ class Camera final {
4950 void reset (const Npc* pl);
5051
5152 void save (Serialize &s);
52- void load (Serialize &s,Npc* pl);
53+ void load (Serialize &s, Npc* pl);
5354
5455 void changeZoom (int delta);
5556 void setViewport (uint32_t w, uint32_t h);
@@ -62,7 +63,7 @@ class Camera final {
6263 void moveLeft (uint64_t dt);
6364 void moveRight (uint64_t dt);
6465
65- void setMode (Mode m);
66+ void setMode (const Mode m);
6667 void setMarvinMode (MarvinMode m);
6768 bool isMarvin () const ;
6869 bool isFree () const ;
@@ -85,17 +86,15 @@ class Camera final {
8586 void tick (uint64_t dt);
8687 void debugDraw (DbgPainter& p);
8788
88- Tempest::PointF spin () const ;
89- Tempest::PointF destSpin () const ;
90-
91- Tempest::Vec3 destPosition () const ;
89+ Tempest::PointF spin () const ;
90+ Tempest::Vec3 destTarget () const ;
91+ float azimuth () const ;
9292
9393 void setSpin (const Tempest::PointF& p);
94- void setDestSpin (const Tempest::PointF& p );
94+ void setTarget (const Tempest::Vec3& pos );
9595
96+ void setAngles (const Tempest::PointF& pos);
9697 void setPosition (const Tempest::Vec3& pos);
97- void setDestPosition (const Tempest::Vec3& pos);
98-
9998 void setDialogDistance (float d);
10099
101100 void onRotateMouse (const Tempest::PointF& dpos);
@@ -119,29 +118,34 @@ class Camera final {
119118 float zFar () const ;
120119
121120 private:
121+ struct Pin {
122+ Tempest::Vec3 origin = {};
123+ Tempest::Vec3 spin = {};
124+ };
125+
122126 struct State {
123127 float range = 3 .f;
124128 Tempest::Vec3 spin = {};
125129 Tempest::Vec3 target = {};
126130 };
127131
128- struct Pin {
129- Tempest::Vec3 origin = {};
130- Tempest::Vec3 spin = {};
132+ struct Interpolated {
133+ Tempest::Vec3 target = {};
134+ Tempest::Vec3 rotOffset = {};
131135 };
132136
133- Tempest::Vec3 cameraPos = {};
134- Tempest::Vec3 origin = {};
135- Tempest::Vec3 rotOffset = {};
136- Tempest::Vec3 offsetAng = {};
137- State src, dst;
138-
137+ State state;
138+ Interpolated inter;
139139 Pin pin;
140140
141- float dlgDist = 0 ;
142- float userRange = 0 .13f ;
141+ Tempest::Vec3 origin = {};
142+ Tempest::Vec3 angles = {};
143+ Tempest::Vec3 veloTrans = {};
144+ float userRange = 0 ;
145+
143146 float targetVelo = 0 ;
144- float veloTrans = 0 ;
147+
148+ float dlgRange = 0 ;
145149
146150 Tempest::Matrix4x4 proj;
147151 uint32_t vpWidth=0 ;
@@ -159,29 +163,30 @@ class Camera final {
159163
160164 mutable int raysCasted = 0 ;
161165
162- static float maxDist;
163- static float baseSpeeed;
164- static float offsetAngleMul;
165166 static const float minLength;
166167
167- void calcControlPoints (float dtF);
168+ void tickFirstPerson (float dtF);
169+ void tickThirdPerson (float dtF);
168170
169- Tempest::Vec3 calcOffsetAngles (const Tempest::Vec3& srcOrigin, const Tempest::Vec3& target) const ;
170- Tempest::Vec3 calcOffsetAngles (Tempest::Vec3 srcOrigin, Tempest::Vec3 dstOrigin, Tempest::Vec3 target) const ;
171- Tempest::Vec3 calcCameraColision (const Tempest::Vec3& target, const Tempest::Vec3& origin, const Tempest::Vec3& rotSpin, float dist) const ;
171+ Tempest::Vec3 clampRotation (Tempest::Vec3 spin);
172+ float calcCameraColision (const Tempest::Vec3& target, const Tempest::Vec3& dir, const Tempest::Vec3& rotSpin, float dist) const ;
173+ Tempest::Vec3 calcCameraColision (const Tempest::Vec3& from, const Tempest::Vec3& dir) const ;
174+
175+ Tempest::Vec3 calcLookAtAngles (const Tempest::Vec3& origin, const Tempest::Vec3& target,
176+ const Tempest::Vec3& rotOffset, const Tempest::Vec3& defSpin) const ;
172177
173178 void implMove (Tempest::KeyEvent::KeyType t, uint64_t dt);
179+
174180 Tempest::Matrix4x4 mkView (const Tempest::Vec3& pos, const Tempest::Vec3& spin) const ;
175181 Tempest::Matrix4x4 mkRotation (const Tempest::Vec3& spin) const ;
176182 Tempest::Matrix4x4 mkViewShadow (const Tempest::Vec3& cameraPos, float rotation,
177183 const Tempest::Matrix4x4& viewProj, const Tempest::Vec3& lightDir, size_t layer) const ;
178184 Tempest::Matrix4x4 mkViewShadowVsm (const Tempest::Vec3& cameraPos, const Tempest::Vec3& ldir) const ;
179- void resetDst ();
180185
181- void clampRotation (Tempest::Vec3& spin);
186+ Tempest::Vec3 followTarget (Tempest::Vec3 pos, Tempest::Vec3 dest, float dtF);
187+ Tempest::Vec3 followTrans (Tempest::Vec3 pos, Tempest::Vec3 dest, float dtF, float velo);
188+ Tempest::Vec3 followRot (Tempest::Vec3 spin, Tempest::Vec3 dest, float dtF, float velo);
182189
183- void followCamera (Tempest::Vec3& pos, Tempest::Vec3 dest, float dtF);
184- void followPos (Tempest::Vec3& pos, Tempest::Vec3 dest, float dtF);
185190 void followAng (Tempest::Vec3& spin, Tempest::Vec3 dest, float dtF);
186191 static void followAng (float & ang, float dest, float speed, float dtF);
187192
0 commit comments