Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
acgl
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
Model registry
Operate
Environments
Monitor
Incidents
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
ACGL
acgl
Commits
b946f8ab
Commit
b946f8ab
authored
13 years ago
by
Robert Menzel
Browse files
Options
Downloads
Patches
Plain Diff
Improved MatrixStack performance
parent
ba4db533
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/ACGL/Scene/MatrixStack.hh
+20
-6
20 additions, 6 deletions
include/ACGL/Scene/MatrixStack.hh
with
20 additions
and
6 deletions
include/ACGL/Scene/MatrixStack.hh
+
20
−
6
View file @
b946f8ab
...
...
@@ -74,29 +74,42 @@ public:
// will replace the top matrix with the given matrix
void
loadMatrix
(
glm
::
mat4
matrixToLoad
)
{
popMatrix
();
if
(
!
mStack
.
empty
())
{
mStack
.
top
()
=
matrixToLoad
;
}
else
{
mStack
.
push
(
matrixToLoad
);
}
}
// the top matrix will be multiplied with the given one and
// will then replace the top matrix
void
multMatrix
(
const
glm
::
mat4
&
rhs
)
{
mStack
.
push
(
popAndGetMatrix
()
*
rhs
);
if
(
mStack
.
empty
())
mStack
.
push
(
glm
::
mat4
()
);
mStack
.
top
()
*=
rhs
;
}
// pushes the product of top and rhs
void
pushAndMultMatrix
(
const
glm
::
mat4
&
rhs
)
{
if
(
mStack
.
empty
())
mStack
.
push
(
glm
::
mat4
()
);
mStack
.
push
(
mStack
.
top
()
*
rhs
);
}
// like glRotate rotates the top matrix around a given axis a given degree phi
void
rotate
(
const
float
phi
,
const
float
x
,
const
float
y
,
const
float
z
)
{
rotate
(
phi
,
glm
::
vec3
(
x
,
y
,
z
));
}
void
rotate
(
const
float
phi
,
const
glm
::
vec3
&
axis
)
{
mStack
.
push
(
glm
::
rotate
(
popAndGetMatrix
(),
phi
,
axis
)
);
if
(
mStack
.
empty
())
mStack
.
push
(
glm
::
mat4
()
);
mStack
.
top
()
=
glm
::
rotate
(
mStack
.
top
(),
phi
,
axis
);
}
// like glTranslate
void
translate
(
float
x
,
float
y
,
float
z
)
{
translate
(
glm
::
vec3
(
x
,
y
,
z
)
);
}
void
translate
(
glm
::
vec3
vector
)
{
mStack
.
push
(
glm
::
translate
(
popAndGetMatrix
(),
vector
)
);
if
(
mStack
.
empty
())
mStack
.
push
(
glm
::
mat4
()
);
mStack
.
top
()
=
glm
::
translate
(
mStack
.
top
(),
vector
);
}
// like glScale
...
...
@@ -104,7 +117,8 @@ public:
void
scale
(
float
x
,
float
y
,
float
z
)
{
scale
(
glm
::
vec3
(
x
,
y
,
z
));
}
void
scale
(
const
glm
::
vec3
&
factor
)
{
mStack
.
push
(
glm
::
scale
(
popAndGetMatrix
(),
factor
)
);
if
(
mStack
.
empty
())
mStack
.
push
(
glm
::
mat4
()
);
mStack
.
top
()
=
glm
::
scale
(
mStack
.
top
(),
factor
);
}
private
:
...
...
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