-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaced lookat, target, position by quaternion, position in the camera #591
Conversation
tests/shadows.cpp
Outdated
camera.setUp(brayns::Vector3f(0.f, 1.f, 0.f)); | ||
camera.setPosition(brayns::Vector3f(0.f, 2 * height, -1.5f)); | ||
//camera.setTarget(brayns::Vector3f(0.f, 0.f, 0.f)); | ||
//camera.setUp(brayns::Vector3f(0.f, 1.f, 0.f)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
apps/BraynsBenchmark/main.cpp
Outdated
const brayns::Vector3f up = {0.f, 1.f, 0.f}; | ||
engine.getCamera().set(origin, target, up); | ||
|
||
const brayns::Vector3d center = bounds.getCenter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto&
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to use "const brayns::Vector3d&". It's easier to understand and more consistent with the following lines.
apps/BraynsBenchmark/main.cpp
Outdated
engine.getCamera().set(origin, target, up); | ||
|
||
const brayns::Vector3d center = bounds.getCenter(); | ||
const brayns::Quaterniond quat(frame * M_PI / 180.0f, brayns::Vector3d(0.0,1.0,0.0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mix of float and double
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -31,7 +31,15 @@ namespace brayns | |||
class AbstractManipulator | |||
{ | |||
public: | |||
AbstractManipulator(Camera& camera, KeyboardHandler& keyboardHandler); | |||
|
|||
enum AxisMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum class, lower-case names for values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do mean ? AxisMode -> axisMode ? or GLOBAL_Y -> globalY ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is AxisMode a value?
enum class AxisMode
{
globalY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum AxisMode | |
enum class AxisMode | |
{ | |
local_y, | |
global_y | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were using camelCase in other projects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
apps/BraynsBenchmark/main.cpp
Outdated
const brayns::Quaterniond quat(frame * M_PI / 180.0f, brayns::Vector3d(0.0,1.0,0.0)); | ||
const brayns::Vector3d dir = quat.rotate(brayns::Vector3d(0.0, 0.0, -1.0)); | ||
engine.getCamera().setPosition(center + radius * -dir); | ||
engine.getCamera().setQuaternion(quat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not keep using the set()
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call the method camera.setOrientation. The quaternion is the parameter type, not the attribute you're modifying. Otherwise it would be setVector instead of setPosition
brayns/common/camera/Camera.h
Outdated
const Vector3d& getUp() const { return _up; } | ||
void setQuaternion(const Quaterniond& quat) | ||
{ | ||
Quaterniond normalized = quat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could just take a copy arg in the function then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
brayns/common/camera/Camera.h
Outdated
@@ -52,13 +52,9 @@ class Camera : public PropertyObject | |||
camera is "looking at" or focused on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that comment is wrong now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also the one for the class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just make sure to run clang format on all the changed files.
if (updateTarget) | ||
_camera.setTarget(_camera.getPosition() - newPivotToCam); | ||
Vector3d axisY; | ||
if(axisMode == LOCAL_Y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like no clang format has been run on this code
|
||
if (updateTarget) | ||
_camera.setTarget(_camera.getPosition() - newPivotToCam); | ||
Vector3d axisY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can write this as const auto axisY = axisMode == LOCAL_Y ? _camera.getQuaternion().rotate(Vector3d(0.0, 1.0, 0.0)) : Vector3d(0.0, 1.0, 0.0);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/webAPI.cpp
Outdated
@@ -37,10 +37,10 @@ BOOST_AUTO_TEST_CASE(change_fov) | |||
|
|||
BOOST_AUTO_TEST_CASE(reset_camera) | |||
{ | |||
const auto target = getCamera().getTarget(); | |||
getCamera().setTarget({1, 2, 3}); | |||
const auto quat = getCamera().getQuaternion(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto (&) quat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
namespace brayns | ||
{ | ||
namespace | ||
{ | ||
const float DEFAULT_MOTION_SPEED = 0.001f; | ||
const float DEFAULT_ROTATION_SPEED = 0.005f; | ||
const float DEFAULT_MOTION_SPEED = 0.03f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const float DEFAULT_MOTION_SPEED = 0.03f; | |
constexpr float DEFAULT_MOTION_SPEED = 0.03f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Furthermore, the docker build is failing currently with:
[261/405] Building CXX object brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o
FAILED: brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o
/usr/bin/c++ -DBOOST_ALL_NO_LIB -DBRAYNSCOMMON_DSO_NAME=\"libbraynsCommon.so.0.8.0\" -DBRAYNSCOMMON_SHARED -DBRAYNS_LITTLEENDIAN=1 -DBRAYNS_USE_ASSIMP=1 -DBRAYNS_USE_BOOST=1 -DBRAYNS_USE_BRION=1 -DBRAYNS_USE_CXX11=1 -DBRAYNS_USE_FREEIMAGE=1 -DBRAYNS_USE_HDF5=1 -DBRAYNS_USE_LIBARCHIVE=1 -DBRAYNS_USE_LIBJPEGTURBO=1 -DBRAYNS_USE_LIBUV=1 -DBRAYNS_USE_NETWORKING=1 -DBRAYNS_USE_OPENMP=1 -DBRAYNS_USE_OSPRAY=1 -DBRAYNS_USE_ROCKETS=1 -DBRAYNS_USE_SERVUS=1 -DBRAYNS_USE_VMMLIB=1 -DBoost_NO_BOOST_CMAKE -DLIBASYNC_STATIC -DLinux=1 -DOSPRAY_TASKING_TBB -DWARN_DEPRECATED -DbraynsCommon_EXPORTS -I../ -Iinclude -I. -I../vmmlib -Ivmmlib/include -Ivmmlib -I../async++/include -isystem /usr/lib/include -isystem /app/dist/include -isystem /app/dist/include/ospray/SDK -isystem /app/dist/include/ospray -isystem /usr/include/hdf5/serial -isystem ../uvw/src -fopenmp -O3 -DNDEBUG -fPIC -Wuninitialized -Wnon-virtual-dtor -Wsign-promo -Wvla -fno-strict-aliasing -Wall -Wextra -Winvalid-pch -Winit-self -Wno-unknown-pragmas -Wshadow -Werror -fmax-errors=5 -pthread -std=gnu++14 -MD -MT brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o -MF brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o.d -o brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o -c ../brayns/common/camera/AbstractManipulator.cpp
../brayns/common/camera/AbstractManipulator.cpp: In member function 'void brayns::AbstractManipulator::translate(const Vector3f&)':
../brayns/common/camera/AbstractManipulator.cpp:81:35: error: 'class vmml::Quaternion<double>' has no member named 'rotate'
const auto translation = quat.rotate(vector);
^~~~~~
../brayns/common/camera/AbstractManipulator.cpp: In member function 'void brayns::AbstractManipulator::rotate(const Vector3f&, float, float, brayns::AbstractManipulator::AxisMode)':
../brayns/common/camera/AbstractManipulator.cpp:89:52: error: 'const Quaterniond' {aka 'const class vmml::Quaternion<double>'} has no member named 'rotate'
const Vector3d axisX = _camera.getQuaternion().rotate(Vector3d(1.0, 0.0, 0.0));
^~~~~~
../brayns/common/camera/AbstractManipulator.cpp:93:41: error: 'const Quaterniond' {aka 'const class vmml::Quaternion<double>'} has no member named 'rotate'
axisY = _camera.getQuaternion().rotate(Vector3d(0.0, 1.0, 0.0));
^~~~~~
../brayns/common/camera/AbstractManipulator.cpp:101:32: error: 'const Quaterniond' {aka 'const class vmml::Quaternion<double>'} has no member named 'rotate'
const Vector3d dir = final.rotate(Vector3d(0.0, 0.0, -1.0));
^~~~~~
apps/ui/BaseWindow.cpp
Outdated
renderInput.target = camera.getTarget(); | ||
renderInput.up = camera.getUp(); | ||
|
||
renderInput.quat = camera.getQuaternion(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderInput.quat = camera.getQuaternion(); | |
renderInput.quaternion = camera.getQuaternion(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in other comment, this should be called orientation, not quaternion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -217,12 +217,11 @@ inline void init(brayns::Renderer::PickResult* p, ObjectHandler* h) | |||
|
|||
inline void init(brayns::Camera* c, ObjectHandler* h) | |||
{ | |||
h->add_property("look_at", Vector3dArray(c->_target), Flags::Optional); | |||
h->add_property("quat", Vector4dArray(c->_quat), Flags::Optional); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h->add_property("quat", Vector4dArray(c->_quat), Flags::Optional); | |
h->add_property("quaternion", Vector4dArray(c->_quaternion), Flags::Optional); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be also 'orientation' as all the other instances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
CI is not passing either, it looks like the revision for vmmlib in .gitsubprojects and the nix recipe has not been updated to account for the function added there. |
apps/BraynsBenchmark/main.cpp
Outdated
const brayns::Quaterniond quat(frame * M_PI / 180.0f, brayns::Vector3d(0.0,1.0,0.0)); | ||
const brayns::Vector3d dir = quat.rotate(brayns::Vector3d(0.0, 0.0, -1.0)); | ||
engine.getCamera().setPosition(center + radius * -dir); | ||
engine.getCamera().setQuaternion(quat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call the method camera.setOrientation. The quaternion is the parameter type, not the attribute you're modifying. Otherwise it would be setVector instead of setPosition
@@ -217,12 +217,11 @@ inline void init(brayns::Renderer::PickResult* p, ObjectHandler* h) | |||
|
|||
inline void init(brayns::Camera* c, ObjectHandler* h) | |||
{ | |||
h->add_property("look_at", Vector3dArray(c->_target), Flags::Optional); | |||
h->add_property("quat", Vector4dArray(c->_quat), Flags::Optional); | |||
h->add_property("origin", Vector3dArray(c->_position), Flags::Optional); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to 'position'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
retest this please |
…the camera (BlueBrain#591)" This reverts commit 28e43de.
No description provided.