Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Contributor 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
Vulkan2021
VkCV Framework
Commits
7ddce0ce
Commit
7ddce0ce
authored
3 years ago
by
Vanessa Karolek
Browse files
Options
Downloads
Patches
Plain Diff
[
#60
] avoid if branching for speed up
parent
93fc0e71
No related branches found
No related tags found
1 merge request
!65
Resolve "Kamera - Steuerung mittels Controller"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/camera/src/vkcv/camera/PilotCameraController.cpp
+9
-14
9 additions, 14 deletions
modules/camera/src/vkcv/camera/PilotCameraController.cpp
modules/camera/src/vkcv/camera/TrackballCameraController.cpp
+10
-20
10 additions, 20 deletions
modules/camera/src/vkcv/camera/TrackballCameraController.cpp
with
19 additions
and
34 deletions
modules/camera/src/vkcv/camera/PilotCameraController.cpp
+
9
−
14
View file @
7ddce0ce
...
@@ -39,24 +39,19 @@ namespace vkcv::camera {
...
@@ -39,24 +39,19 @@ namespace vkcv::camera {
}
}
void
PilotCameraController
::
panView
(
double
xOffset
,
double
yOffset
,
Camera
&
camera
)
{
void
PilotCameraController
::
panView
(
double
xOffset
,
double
yOffset
,
Camera
&
camera
)
{
// handle yaw rotation
// update only if there is (valid) input
float
yaw
=
camera
.
getYaw
()
+
xOffset
;
if
(
xOffset
==
0.0
&&
yOffset
==
0.0
)
{
if
(
yaw
<
-
180.0
f
)
{
return
;
yaw
+=
360.0
f
;
}
else
if
(
yaw
>
180.0
f
)
{
yaw
-=
360.0
f
;
}
}
// handle yaw rotation
float
yaw
=
camera
.
getYaw
()
+
static_cast
<
float
>
(
xOffset
);
yaw
+=
360.0
f
*
(
yaw
<
-
180.0
f
)
-
360.0
f
*
(
yaw
>
180.0
f
);
camera
.
setYaw
(
yaw
);
camera
.
setYaw
(
yaw
);
// handle pitch rotation
// handle pitch rotation
float
pitch
=
camera
.
getPitch
()
-
yOffset
;
float
pitch
=
camera
.
getPitch
()
-
static_cast
<
float
>
(
yOffset
);
if
(
pitch
>
89.0
f
)
{
pitch
=
glm
::
clamp
(
pitch
,
-
89.0
f
,
89.0
f
);
pitch
=
89.0
f
;
}
if
(
pitch
<
-
89.0
f
)
{
pitch
=
-
89.0
f
;
}
camera
.
setPitch
(
pitch
);
camera
.
setPitch
(
pitch
);
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/camera/src/vkcv/camera/TrackballCameraController.cpp
+
10
−
20
View file @
7ddce0ce
...
@@ -12,33 +12,23 @@ namespace vkcv::camera {
...
@@ -12,33 +12,23 @@ namespace vkcv::camera {
}
}
void
TrackballCameraController
::
setRadius
(
const
float
radius
)
{
void
TrackballCameraController
::
setRadius
(
const
float
radius
)
{
if
(
radius
<
0.1
f
)
{
m_radius
=
0.1
f
*
(
radius
<
0.1
f
)
+
radius
*
(
1
-
(
radius
<
0.1
f
));
m_radius
=
0.1
f
;
}
else
{
m_radius
=
radius
;
}
}
}
void
TrackballCameraController
::
panView
(
double
xOffset
,
double
yOffset
,
Camera
&
camera
)
{
void
TrackballCameraController
::
panView
(
double
xOffset
,
double
yOffset
,
Camera
&
camera
)
{
// handle yaw rotation
// update only if there is (valid) input
float
yaw
=
camera
.
getYaw
()
+
xOffset
*
m_cameraSpeed
;
if
(
xOffset
==
0.0
&&
yOffset
==
0.0
)
{
if
(
yaw
<
0.0
f
)
{
return
;
yaw
+=
360.0
f
;
}
else
if
(
yaw
>
360.0
f
)
{
yaw
-=
360.0
f
;
}
}
// handle yaw rotation
float
yaw
=
camera
.
getYaw
()
+
static_cast
<
float
>
(
xOffset
)
*
m_cameraSpeed
;
yaw
+=
360.0
f
*
(
yaw
<
0.0
f
)
-
360.0
f
*
(
yaw
>
360.0
f
);
camera
.
setYaw
(
yaw
);
camera
.
setYaw
(
yaw
);
// handle pitch rotation
// handle pitch rotation
float
pitch
=
camera
.
getPitch
()
+
yOffset
*
m_cameraSpeed
;
float
pitch
=
camera
.
getPitch
()
+
static_cast
<
float
>
(
yOffset
)
*
m_cameraSpeed
;
if
(
pitch
<
0.0
f
)
{
pitch
+=
360.0
f
*
(
pitch
<
0.0
f
)
-
360.0
f
*
(
pitch
>
360.0
f
);
pitch
+=
360.0
f
;
}
else
if
(
pitch
>
360.0
f
)
{
pitch
-=
360.0
f
;
}
camera
.
setPitch
(
pitch
);
camera
.
setPitch
(
pitch
);
}
}
...
...
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