Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Sommersemester 2019
Cpp
PhaseShifter
Commits
396ec8c3
Commit
396ec8c3
authored
Sep 18, 2019
by
Florian Oetke
Browse files
Merge branch 'develop' into feature/9-highlevel-gameplay
parents
6bba32a4
6ad48533
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/gameplay/camera_system.cpp
View file @
396ec8c3
...
...
@@ -4,6 +4,8 @@
namespace
phase_shifter
::
gameplay
{
using
mirrage
::
ecs
::
components
::
Transform_comp
;
Camera_system
::
Camera_system
(
mirrage
::
ecs
::
Entity_manager
&
entity_manager
)
:
_entity_manager
(
entity_manager
)
{
...
...
@@ -13,8 +15,8 @@ namespace phase_shifter::gameplay {
void
Camera_system
::
update
(
mirrage
::
util
::
Time
dt
)
{
for
(
auto
&&
[
camera
,
viewtarget
,
spring
]
:
_entity_manager
.
list
<
mirrage
::
ecs
::
Entity_facet
,
Viewtarget_comp
,
Spring_comp
>
())
{
for
(
auto
&&
[
transform
,
viewtarget
,
spring
]
:
_entity_manager
.
list
<
Transform_comp
,
Viewtarget_comp
,
Spring_comp
>
())
{
auto
target_facet
=
_entity_manager
.
get
(
viewtarget
.
target
);
if
(
target_facet
.
is_some
())
{
...
...
@@ -30,13 +32,11 @@ namespace phase_shifter::gameplay {
float
damping_constant
=
2
*
sqrtf
(
spring
.
spring_constant
);
glm
::
vec3
damping_force
=
-
damping_constant
*
spring
.
velocity
;
camera
.
process
([
&
](
mirrage
::
ecs
::
components
::
Transform_comp
&
transform
)
{
glm
::
vec3
spring_force
=
spring
.
spring_constant
*
(
dest_pos
-
transform
.
position
);
glm
::
vec3
acceleration
=
(
spring_force
+
damping_force
)
/
spring
.
mass
;
spring
.
velocity
+=
dt
.
value
()
*
acceleration
;
transform
.
position
+=
dt
.
value
()
*
spring
.
velocity
;
transform
.
direction
(
-
offset
);
});
glm
::
vec3
spring_force
=
spring
.
spring_constant
*
(
dest_pos
-
transform
.
position
);
glm
::
vec3
acceleration
=
(
spring_force
+
damping_force
)
/
spring
.
mass
;
spring
.
velocity
+=
dt
.
value
()
*
acceleration
;
transform
.
position
+=
dt
.
value
()
*
spring
.
velocity
;
transform
.
direction
(
-
offset
);
}
}
}
...
...
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