@@ -178,25 +178,41 @@ void Camera::moveRight(uint64_t dt) {
178178 implMove (KeyEvent::K_D,dt);
179179 }
180180
181- void Camera::setMode (Camera::Mode m) {
181+ void Camera::setMode (const Camera::Mode m) {
182182 if (camMod==m)
183183 return ;
184184
185- const bool reset = true ; // (m==Inventory || camMod==Inventory || camMod==Dialog || camMod==Dive || m==Fall || camMod==Fall);
185+ auto isRegular = [](const Camera::Mode m){
186+ return m==Normal || m==Inventory || m==Melee || m==Ranged || m==Magic;
187+ };
188+
189+ const auto prev = camMod;
186190 camMod = m;
187191
188- if (camMarvinMod==M_Freeze)
192+ // const bool reset = true; //(m==Inventory || camMod==Inventory || camMod==Dialog || camMod==Dive || m==Fall || camMod==Fall);
193+ const bool reset = !(isRegular (prev) && isRegular (m));
194+
195+ if (prev==Mode::Cutscene) {
196+ state.spin = angles;
197+ state.target = origin;
198+ inter.target = origin;
199+ }
200+
201+ if (camMarvinMod==M_Free || camMarvinMod==M_Freeze)
189202 return ;
190203
204+ const auto & def = cameraDef ();
205+
191206 if (reset) {
192- resetDst ();
207+ state.range = def.best_range ;
208+ state.spin = Vec3 (0 );
209+ // userRange = (def.best_range - def.min_range)/(def.max_range - def.min_range);
193210 }
194211
195212 if (auto pl = Gothic::inst ().player ()) {
196213 state.spin = Vec3 (0 , pl->rotation (), 0 );
197214 }
198215
199- const auto & def = cameraDef ();
200216 auto rotBest = Vec3 (def.best_elevation ,
201217 def.best_azimuth ,
202218 def.best_rot_z );
@@ -270,7 +286,6 @@ void Camera::setLookBack(bool lb) {
270286 if (lbEnable==lb)
271287 return ;
272288 lbEnable = lb;
273- resetDst ();
274289 }
275290
276291void Camera::toggleDebug () {
@@ -285,6 +300,18 @@ void Camera::setTarget(const Tempest::Vec3& pos) {
285300 state.target = pos;
286301 }
287302
303+ void Camera::setAngles (const Tempest::PointF& p) {
304+ angles = /* angleMod*/ (Vec3 (p.x ,p.y ,0 ));
305+ }
306+
307+ void Camera::setPosition (const Tempest::Vec3& pos) {
308+ origin = pos;
309+ }
310+
311+ void Camera::setDialogDistance (float d) {
312+ dlgDist = d;
313+ }
314+
288315void Camera::onRotateMouse (const PointF& dpos) {
289316 state.spin .x += dpos.x ;
290317 state.spin .y += dpos.y ;
@@ -565,14 +592,6 @@ void Camera::implMove(Tempest::Event::KeyType key, uint64_t dt) {
565592 state.spin .y -= dRot;
566593 }
567594
568- void Camera::setPosition (const Tempest::Vec3& pos) {
569- origin = pos;
570- }
571-
572- void Camera::setDialogDistance (float d) {
573- dlgDist = d;
574- }
575-
576595Vec3 Camera::followTarget (Vec3 pos, Vec3 dest, float dtF) {
577596 auto dp = (dest-pos);
578597 auto len = dp.length ();
@@ -663,6 +682,10 @@ void Camera::tick(uint64_t dt) {
663682 if (Gothic::inst ().isPause () || (camMarvinMod==M_Freeze && camMod!=Dialog))
664683 return ;
665684
685+ if (isCutscene ()) {
686+ return ; // handle pass thru water ?
687+ }
688+
666689 const float dtF = float (dt)/1000 .f ;
667690
668691 {
@@ -678,10 +701,7 @@ void Camera::tick(uint64_t dt) {
678701
679702 switch (camMarvinMod) {
680703 case M_Normal: {
681- if (isCutscene ()) {
682- // nop
683- }
684- else if (fpEnable && camMod!=Dialog) {
704+ if (fpEnable && camMod!=Dialog) {
685705 tickFirstPerson (dtF);
686706 }
687707 else {
@@ -901,17 +921,6 @@ Vec3 Camera::clampRotation(Tempest::Vec3 spin) {
901921 return (spin + plSpin);
902922 }
903923
904- void Camera::resetDst () {
905- if (isMarvin ())
906- return ;
907- const auto & def = cameraDef ();
908-
909- state.range = def.best_range ;
910- state.spin = Vec3 (0 );
911-
912- // userRange = (def.best_range - def.min_range)/(def.max_range - def.min_range);
913- }
914-
915924Matrix4x4 Camera::mkView (const Vec3& pos, const Vec3& spin) const {
916925 Matrix4x4 view;
917926 view.identity ();
0 commit comments