Skip to content
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

Precision must be double for JSON #528

Merged
merged 1 commit into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions brayns/Brayns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,10 +910,10 @@ struct Brayns::Impl : public PluginAPI
if (!renderer.hasProperty("aoWeight"))
return;

auto aoStrength = renderer.getProperty<float>("aoWeight");
aoStrength += 0.1f;
if (aoStrength > 1.f)
aoStrength = 1.f;
auto aoStrength = renderer.getProperty<double>("aoWeight");
aoStrength += 0.1;
if (aoStrength > 1.)
aoStrength = 1.;
renderer.updateProperty("aoWeight", aoStrength);
}

Expand All @@ -923,10 +923,10 @@ struct Brayns::Impl : public PluginAPI
if (!renderer.hasProperty("aoWeight"))
return;

auto aoStrength = renderer.getProperty<float>("aoWeight");
aoStrength -= 0.1f;
if (aoStrength < 0.f)
aoStrength = 0.f;
auto aoStrength = renderer.getProperty<double>("aoWeight");
aoStrength -= 0.1;
if (aoStrength < 0.)
aoStrength = 0.;
renderer.updateProperty("aoWeight", aoStrength);
}

Expand All @@ -942,10 +942,8 @@ struct Brayns::Impl : public PluginAPI
if (!renderer.hasProperty("shadows"))
return;

renderer.updateProperty("shadows",
renderer.getProperty<float>("shadows") == 0.f
? 1.f
: 0.f);
renderer.updateProperty(
"shadows", renderer.getProperty<double>("shadows") == 0. ? 1. : 0.);
}

void _toggleSoftShadows()
Expand All @@ -954,10 +952,10 @@ struct Brayns::Impl : public PluginAPI
if (!renderer.hasProperty("softShadows"))
return;

renderer.updateProperty("softShadows", renderer.getProperty<float>(
"softShadows") == 0.f
? 1.f
: 0.f);
renderer.updateProperty("softShadows", renderer.getProperty<double>(
"softShadows") == 0.
? 1.
: 0.);
}

void _increaseSamplesPerRay()
Expand Down Expand Up @@ -1074,8 +1072,8 @@ struct Brayns::Impl : public PluginAPI
KeyboardHandler _keyboardHandler;
AbstractManipulatorPtr _cameraManipulator;

float _fieldOfView{45.f};
float _eyeSeparation{0.0635f};
double _fieldOfView{45.};
double _eyeSeparation{0.0635};

std::future<void> _dataLoadingFuture;

Expand Down
15 changes: 11 additions & 4 deletions brayns/common/PropertyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include <boost/any.hpp>
#include <boost/static_assert.hpp>
#include <functional>
#include <memory>
#include <string>
Expand Down Expand Up @@ -254,7 +255,7 @@ class PropertyMap
};

template <>
inline PropertyMap::Property::Type PropertyMap::Property::_getType<float>()
inline PropertyMap::Property::Type PropertyMap::Property::_getType<double>()
{
return PropertyMap::Property::Type::Float;
}
Expand Down Expand Up @@ -282,7 +283,7 @@ inline PropertyMap::Property::Type PropertyMap::Property::_getType<bool>()
}
template <>
inline PropertyMap::Property::Type
PropertyMap::Property::_getType<std::array<float, 2>>()
PropertyMap::Property::_getType<std::array<double, 2>>()
{
return PropertyMap::Property::Type::Vec2f;
}
Expand All @@ -294,7 +295,7 @@ inline PropertyMap::Property::Type
}
template <>
inline PropertyMap::Property::Type
PropertyMap::Property::_getType<std::array<float, 3>>()
PropertyMap::Property::_getType<std::array<double, 3>>()
{
return PropertyMap::Property::Type::Vec3f;
}
Expand All @@ -306,8 +307,14 @@ inline PropertyMap::Property::Type
}
template <>
inline PropertyMap::Property::Type
PropertyMap::Property::_getType<std::array<float, 4>>()
PropertyMap::Property::_getType<std::array<double, 4>>()
{
return PropertyMap::Property::Type::Vec4f;
}
template <typename T>
inline PropertyMap::Property::Type PropertyMap::Property::_getType()
{
BOOST_STATIC_ASSERT(!std::is_same<T, float>());
return PropertyMap::Property::Type::Float;
}
}
42 changes: 20 additions & 22 deletions brayns/common/Transformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef TRANSFORMATION_H
#define TRANSFORMATION_H
#pragma once

#include <brayns/common/BaseObject.h>
#include <brayns/common/types.h>
Expand All @@ -37,29 +36,29 @@ class Transformation : public BaseObject
public:
Transformation() = default;

Transformation(const Vector3f& translation, const Vector3f& scale,
const Quaternionf& rotation, const Vector3f& rotationCenter)
Transformation(const Vector3d& translation, const Vector3d& scale,
const Quaterniond& rotation, const Vector3d& rotationCenter)
: _translation(translation)
, _scale(scale)
, _rotation(rotation)
, _rotationCenter(rotationCenter)
{
}

const Vector3f& getTranslation() const { return _translation; }
void setTranslation(const Vector3f& value)
const Vector3d& getTranslation() const { return _translation; }
void setTranslation(const Vector3d& value)
{
_updateValue(_translation, value);
}
const Vector3f& getScale() const { return _scale; }
void setScale(const Vector3f& value) { _updateValue(_scale, value); }
const Quaternionf& getRotation() const { return _rotation; }
void setRotation(const Quaternionf& value)
const Vector3d& getScale() const { return _scale; }
void setScale(const Vector3d& value) { _updateValue(_scale, value); }
const Quaterniond& getRotation() const { return _rotation; }
void setRotation(const Quaterniond& value)
{
_updateValue(_rotation, value);
}
const Vector3f& getRotationCenter() const { return _rotationCenter; }
void setRotationCenter(const Vector3f& value)
const Vector3d& getRotationCenter() const { return _rotationCenter; }
void setRotationCenter(const Vector3d& value)
{
_updateValue(_rotationCenter, value);
}
Expand All @@ -71,17 +70,17 @@ class Transformation : public BaseObject
}
bool operator!=(const Transformation& rhs) const { return !(*this == rhs); }
// only applies rotation and translation, use scaling separately if needed
Matrix4f toMatrix() const
Matrix4d toMatrix() const
{
Matrix4f matrix(getRotation(), getTranslation());
Matrix4d matrix(getRotation(), getTranslation());
return matrix;
}

private:
Vector3f _translation{0.f, 0.f, 0.f};
Vector3f _scale{1.f, 1.f, 1.f};
Quaternionf _rotation;
Vector3f _rotationCenter{0.f, 0.f, 0.f};
Vector3d _translation{0., 0., 0.};
Vector3d _scale{1., 1., 1.};
Quaterniond _rotation;
Vector3d _rotationCenter{0., 0., 0.};

SERIALIZATION_FRIEND(Transformation)
};
Expand All @@ -93,10 +92,9 @@ inline Transformation operator*(const Transformation& a,
a.getRotationCenter()};
}

inline Boxf transformBox(const Boxf& box, const Transformation& trafo)
inline Boxd transformBox(const Boxd& box, const Transformation& transformation)
{
return {trafo.toMatrix() * box.getMin(), trafo.toMatrix() * box.getMax()};
return {transformation.toMatrix() * box.getMin(),
transformation.toMatrix() * box.getMax()};
}
}

#endif // TRANSFORMATION_H
2 changes: 1 addition & 1 deletion brayns/common/camera/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void Camera::setInitialState(const Vector3f& position, const Vector3f& target,
set(position, target, upVector);
}

BRAYNS_API void Camera::setInitialState(const Boxf& boundingBox)
BRAYNS_API void Camera::setInitialState(const Boxd& boundingBox)
{
const Vector3f& target = boundingBox.getCenter();
const Vector3f& diag = boundingBox.getSize();
Expand Down
27 changes: 13 additions & 14 deletions brayns/common/camera/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ class Camera : public PropertyObject
BRAYNS_API void setInitialState(const Vector3f& position,
const Vector3f& target, const Vector3f& up);

BRAYNS_API void setInitialState(const Boxf& boundingBox);
BRAYNS_API void setInitialState(const Boxd& boundingBox);

/**
Sets camera position
@param position The x, y, z coordinates of the camera position
*/
void setPosition(const Vector3f& position)
void setPosition(const Vector3d& position)
{
_updateValue(_position, position);
}
Expand All @@ -73,29 +73,29 @@ class Camera : public PropertyObject
Gets camera position
@return The x, y, z coordinates of the camera position
*/
const Vector3f& getPosition() const { return _position; }
const Vector3d& getPosition() const { return _position; }
/**
Sets camera target
@param target The x, y, z coordinates of the camera target: the point the
camera is "looking at" or focused on
*/
void setTarget(const Vector3f& target) { _updateValue(_target, target); }
void setTarget(const Vector3d& target) { _updateValue(_target, target); }
/**
Gets camera target
@return The x, y, z coordinates of the camera target: the point the
camera is "looking at" or focused on
*/
const Vector3f& getTarget() const { return _target; }
const Vector3d& getTarget() const { return _target; }
/**
Sets camera up vector
@param up the x, y, z coordinates of the up vector's end point
*/
void setUp(const Vector3f& up) { _updateValue(_up, up); }
void setUp(const Vector3d& up) { _updateValue(_up, up); }
/**
Gets camera up vector
@return the x, y, z coordinates of the up vector's end point
*/
const Vector3f& getUp() const { return _up; }
const Vector3d& getUp() const { return _up; }
/**
Gets the camera rotation matrix
@return the rotation matrix from the original *target* and *up* vectors
Expand All @@ -115,15 +115,14 @@ class Camera : public PropertyObject
const bool environmentMap BRAYNS_UNUSED){};

virtual bool isSideBySideStereo() const { return false; }

private:
Vector3f _position;
Vector3f _target;
Vector3f _up;
Vector3d _position;
Vector3d _target;
Vector3d _up;

Vector3f _initialPosition;
Vector3f _initialTarget;
Vector3f _initialUp;
Vector3d _initialPosition;
Vector3d _initialTarget;
Vector3d _initialUp;

/*! rotation matrice along x and y axis */
Matrix4f _matrix;
Expand Down
6 changes: 3 additions & 3 deletions brayns/common/engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ void Engine::reshape(const Vector2ui& frameSize)
const auto size = getSupportedFrameSize(frameSize);

_frameBuffer->resize(size);
_camera->updateProperty("aspect", static_cast<float>(size.x()) /
static_cast<float>(size.y()));
_camera->updateProperty("aspect", static_cast<double>(size.x()) /
static_cast<double>(size.y()));
}

void Engine::commit()
Expand Down Expand Up @@ -90,7 +90,7 @@ void Engine::_writeFrameToFile()

void Engine::setDefaultCamera()
{
const auto frameSize = Vector2f(_frameBuffer->getSize());
const auto frameSize = Vector2d(_frameBuffer->getSize());
_camera->setInitialState(_scene->getBounds());
_camera->updateProperty("aspect", frameSize.x() / frameSize.y());
}
Expand Down
4 changes: 2 additions & 2 deletions brayns/common/geometry/SDFGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ inline SDFGeometry createSDFConePillSigmoid(
return geom;
}

inline Boxf getSDFBoundingBox(const SDFGeometry& geom)
inline Boxd getSDFBoundingBox(const SDFGeometry& geom)
{
Boxf bounds;
Boxd bounds;
switch (geom.type)
{
case brayns::SDFType::Sphere:
Expand Down
Loading