Skip to content

Commit

Permalink
Remove M_PI, documenation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cykoder committed Jul 18, 2024
1 parent 5deacb8 commit 9beb380
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
11 changes: 4 additions & 7 deletions apps/openmw/mwrender/animblendcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

#include <osgAnimation/Bone>

#define _USE_MATH_DEFINES

#include <cassert>
#include <cmath>
#include <string>
#include <vector>

Expand All @@ -25,17 +22,17 @@ namespace MWRender

float sineOut(float x)
{
return sin((x * M_PI) / 2);
return sin((x * osg::PIf) / 2);
}

float sineIn(float x)
{
return 1 - cos((x * M_PI) / 2);
return 1 - cos((x * osg::PIf) / 2);
}

float sineInOut(float x)
{
return -(cos(M_PI * x) - 1) / 2;
return -(cos(osg::PIf * x) - 1) / 2;
}

float cubicOut(float t)
Expand Down Expand Up @@ -90,7 +87,7 @@ namespace MWRender
{
// Higher lambda = lower swing amplitude. 1 = 150% swing amplitude.
// w is the frequency of oscillation in the easing func, controls the amount of overswing
constexpr float w = 1.5f * M_PI; // 4.71238
const float w = 1.5f * osg::PIf; // 4.71238
return 1 - expf(-lambda * x) * cos(w * x);
}

Expand Down
2 changes: 0 additions & 2 deletions components/sceneutil/animblendrules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace SceneUtil
}
return std::make_pair(group, key);
}

}

using BlendRule = AnimBlendRules::BlendRule;
Expand Down Expand Up @@ -168,5 +167,4 @@ namespace SceneUtil

return std::nullopt;
}

}
12 changes: 6 additions & 6 deletions docs/source/reference/modding/animation-blending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ In examples below ``.yaml`` config file will be used. You can provide ``.json``

Animation blending config file is a list of blending rules that look like this:

```
blending_rules:
::

blending_rules:
- from: "*"
to: "*"
easing: "sineOut"
Expand All @@ -30,9 +31,8 @@ blending_rules:
to: "idlesneak*"
easing: "springOutWeak"
duration: 0.4
```

See ``OpenMW\files\data\animations\animation-config.yaml`` for an example of such a file.
See `files/data/animations/animation-config.yaml <https://gitlab.com/OpenMW/openmw/-/tree/master/files/data/animations/animation-config.yaml>`__ for an example of such a file.

Every blending rule should include a set of following fields:

Expand Down Expand Up @@ -85,6 +85,6 @@ List of possible easings

Its hard to give an example of use cases for the latter 2 types of easing functions, they are there for developers to experiment.

The possible easings are largely ported from `here <https://easings.net/>`__ and have similar names. Except for the ``springOut`` family, those are similar to ``elasticOut`` from `easings.net <https://easings.net/>`__, with ``springOutWeak`` being almost identical to ``elasticOut``.
The possible easings are largely ported from `easings.net <https://easings.net/>`__ and have similar names. Except for the ``springOut`` family, those are similar to ``elasticOut``, with ``springOutWeak`` being almost identical to ``elasticOut``.

Don't be afraid to experiment with different timing and easing functions!
Don't be afraid to experiment with different timing and easing functions!
2 changes: 1 addition & 1 deletion docs/source/reference/modding/settings/game.rst
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ Enabling this option disables this swaying by having the player character move i
This setting can be controlled in the Settings tab of the launcher.

smooth animation transitions
---------------------------------
----------------------------

:Type: boolean
:Range: True/False
Expand Down
1 change: 0 additions & 1 deletion files/data/animations/animation-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This is the default OpenMW animation blending config file (global config) , will affect NPCs and creatures but not animated objects.
# If you want to provide an animation blending config for your modded animations - DO NOT override the global config in your mod.
# For details on how to edit and create your own blending rules, see https://openmw.readthedocs.io/en/latest/reference/modding/animation-blending.html
# Author: Maksim Eremenko (Max Yari)

blending_rules:
# General blending rule, any transition that will not be caught by the rules below - will use this rule
Expand Down

0 comments on commit 9beb380

Please sign in to comment.