Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
fc92da43
Commit
fc92da43
authored
13 years ago
by
Kahrl
Browse files
Options
Downloads
Patches
Plain Diff
View bobbing is slower in the water.
parent
524cf237
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/camera.cpp
+7
-6
7 additions, 6 deletions
src/camera.cpp
src/camera.h
+2
-0
2 additions, 0 deletions
src/camera.h
with
9 additions
and
6 deletions
src/camera.cpp
+
7
−
6
View file @
fc92da43
...
@@ -19,10 +19,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
...
@@ -19,10 +19,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include
"camera.h"
#include
"camera.h"
#include
"debug.h"
#include
"debug.h"
#include
"client.h"
#include
"main.h"
// for g_settings
#include
"main.h"
// for g_settings
#include
"map.h"
#include
"map.h"
#include
"player.h"
#include
"player.h"
#include
"utility.h"
#include
<cmath>
#include
<cmath>
const
s32
BOBFRAMES
=
0x1000000
;
// must be a power of two
const
s32
BOBFRAMES
=
0x1000000
;
// must be a power of two
...
@@ -51,7 +51,8 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
...
@@ -51,7 +51,8 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
m_time_per_range
(
30.
/
50
),
// a sane default of 30ms per 50 nodes of range
m_time_per_range
(
30.
/
50
),
// a sane default of 30ms per 50 nodes of range
m_view_bobbing_anim
(
0
),
m_view_bobbing_anim
(
0
),
m_view_bobbing_state
(
0
)
m_view_bobbing_state
(
0
),
m_view_bobbing_slow
(
false
)
{
{
//dstream<<__FUNCTION_NAME<<std::endl;
//dstream<<__FUNCTION_NAME<<std::endl;
...
@@ -72,7 +73,8 @@ void Camera::step(f32 dtime)
...
@@ -72,7 +73,8 @@ void Camera::step(f32 dtime)
{
{
if
(
m_view_bobbing_state
!=
0
)
if
(
m_view_bobbing_state
!=
0
)
{
{
s32
offset
=
MYMAX
(
dtime
*
BOBFRAMES
,
1
);
f32
bobspeed
=
(
m_view_bobbing_slow
?
(
BOBFRAMES
/
4
)
:
BOBFRAMES
);
s32
offset
=
MYMAX
(
dtime
*
bobspeed
,
1
);
if
(
m_view_bobbing_state
==
2
)
if
(
m_view_bobbing_state
==
2
)
{
{
// Animation is getting turned off
// Animation is getting turned off
...
@@ -93,7 +95,6 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
...
@@ -93,7 +95,6 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
// Set player node transformation
// Set player node transformation
m_playernode
->
setPosition
(
player
->
getPosition
());
m_playernode
->
setPosition
(
player
->
getPosition
());
//m_playernode->setRotation(v3f(player->getPitch(), -1 * player->getYaw(), 0));
m_playernode
->
setRotation
(
v3f
(
0
,
-
1
*
player
->
getYaw
(),
0
));
m_playernode
->
setRotation
(
v3f
(
0
,
-
1
*
player
->
getYaw
(),
0
));
m_playernode
->
updateAbsolutePosition
();
m_playernode
->
updateAbsolutePosition
();
...
@@ -144,9 +145,8 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
...
@@ -144,9 +145,8 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
// view bobbing is enabled and free_move is off,
// view bobbing is enabled and free_move is off,
// start (or continue) the view bobbing animation.
// start (or continue) the view bobbing animation.
v3f
speed
=
player
->
getSpeed
();
v3f
speed
=
player
->
getSpeed
();
//dstream<<"speed: ("<<speed.X<<","<<speed.Y<<","<<speed.Z<<")"<<std::endl;
if
((
hypot
(
speed
.
X
,
speed
.
Z
)
>
BS
)
&&
if
((
hypot
(
speed
.
X
,
speed
.
Z
)
>
BS
)
&&
(
fabs
(
speed
.
Y
)
<
BS
/
10
)
&&
(
player
->
touching_ground
)
&&
(
g_settings
.
getBool
(
"view_bobbing"
)
==
true
)
&&
(
g_settings
.
getBool
(
"view_bobbing"
)
==
true
)
&&
(
g_settings
.
getBool
(
"free_move"
)
==
false
))
(
g_settings
.
getBool
(
"free_move"
)
==
false
))
{
{
...
@@ -158,6 +158,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
...
@@ -158,6 +158,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
// Stop animation
// Stop animation
m_view_bobbing_state
=
2
;
m_view_bobbing_state
=
2
;
}
}
m_view_bobbing_slow
=
player
->
in_water_stable
;
}
}
void
Camera
::
updateViewingRange
(
f32
frametime_in
)
void
Camera
::
updateViewingRange
(
f32
frametime_in
)
...
...
This diff is collapsed.
Click to expand it.
src/camera.h
+
2
−
0
View file @
fc92da43
...
@@ -136,6 +136,8 @@ class Camera
...
@@ -136,6 +136,8 @@ class Camera
// If 1, view bobbing is on (player is walking).
// If 1, view bobbing is on (player is walking).
// If 2, view bobbing is getting switched off.
// If 2, view bobbing is getting switched off.
s32
m_view_bobbing_state
;
s32
m_view_bobbing_state
;
// If true, view bobbing is slown down (player is swimming)
bool
m_view_bobbing_slow
;
};
};
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment