Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ACGL
acgl
Commits
b946f8ab
Commit
b946f8ab
authored
Dec 01, 2011
by
Robert Menzel
Browse files
Improved MatrixStack performance
parent
ba4db533
Changes
1
Show whitespace changes
Inline
Side-by-side
include/ACGL/Scene/MatrixStack.hh
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:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment