Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Game Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Onuralp SEZER
Game Library
Commits
035a4566
Commit
035a4566
authored
2 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
more cleanup of the Tranform component
parent
a4d9b349
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/fggl/math/types.hpp
+18
-5
18 additions, 5 deletions
include/fggl/math/types.hpp
with
18 additions
and
5 deletions
include/fggl/math/types.hpp
+
18
−
5
View file @
035a4566
...
...
@@ -53,6 +53,10 @@ namespace fggl::math {
constexpr
static
const
math
::
mat4
IDENTITY_M4
{
1.0
F
};
constexpr
static
const
math
::
quat
IDENTITY_Q
{
1.0
F
,
0.0
,
0.0
,
0.0
};
constexpr
static
const
math
::
vec3
AXIS_X
{
1.0
F
,
0.0
F
,
0.0
F
};
constexpr
static
const
math
::
vec3
AXIS_Y
{
0.0
F
,
1.0
F
,
0.0
F
};
constexpr
static
const
math
::
vec3
AXIS_Z
{
0.0
F
,
0.0
F
,
1.0
F
};
// fastFloor from OpenSimplex2
inline
int
fastFloor
(
double
x
)
{
int
xi
=
(
int
)
x
;
...
...
@@ -160,10 +164,11 @@ namespace fggl::math {
return
m_euler
;
}
inline
mat4
model
()
const
{
const
glm
::
mat4
transformX
=
glm
::
rotate
(
math
::
IDENTITY_M4
,
glm
::
radians
(
m_euler
.
x
),
glm
::
vec3
(
1.0
f
,
0.0
f
,
0.0
f
)
);
const
glm
::
mat4
transformY
=
glm
::
rotate
(
math
::
IDENTITY_M4
,
glm
::
radians
(
m_euler
.
y
),
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
)
);
const
glm
::
mat4
transformZ
=
glm
::
rotate
(
math
::
IDENTITY_M4
,
glm
::
radians
(
m_euler
.
z
),
glm
::
vec3
(
0.0
f
,
0.0
f
,
1.0
f
)
);
[[
nodiscard
]]
inline
mat4
local
()
const
{
const
glm
::
mat4
transformX
=
glm
::
rotate
(
math
::
IDENTITY_M4
,
glm
::
radians
(
m_euler
.
x
),
AXIS_X
);
const
glm
::
mat4
transformY
=
glm
::
rotate
(
math
::
IDENTITY_M4
,
glm
::
radians
(
m_euler
.
y
),
AXIS_Y
);
const
glm
::
mat4
transformZ
=
glm
::
rotate
(
math
::
IDENTITY_M4
,
glm
::
radians
(
m_euler
.
z
),
AXIS_Z
);
const
auto
rotation
=
transformY
*
transformX
*
transformZ
;
return
glm
::
translate
(
math
::
IDENTITY_M4
,
m_origin
)
...
...
@@ -171,12 +176,20 @@ namespace fggl::math {
*
glm
::
scale
(
math
::
IDENTITY_M4
,
m_scale
);
}
[[
nodiscard
]]
inline
mat4
model
()
const
{
return
local
();
}
inline
void
update
(
const
math
::
mat4
&
parent
)
{
m_model
=
parent
*
local
();
}
private
:
mat4
m_model
;
// us -> world
vec3
m_origin
;
vec3
m_euler
;
vec3
m_scale
;
};
}
...
...
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