-
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
Added scene management #379
Conversation
372d694
to
fc8907f
Compare
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.
Pretty good overall!
I would like to have a test of adding a second model in the uploadpath and/or -binary test.
Also, the change of CMake/common should be reverted too I think.
brayns/Brayns.cpp
Outdated
@@ -482,6 +468,12 @@ struct Brayns::Impl : public PluginAPI | |||
_engine->getStatistics().setSceneSizeInBytes( | |||
_engine->getScene().getSizeInBytes()); | |||
|
|||
// Set default camera position | |||
const auto frameSize = Vector2f(_engine->getFrameBuffer().getSize()); |
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.
_engine->setDefaultCamera(); ?
brayns/Brayns.cpp
Outdated
@@ -1226,17 +1183,20 @@ struct Brayns::Impl : public PluginAPI | |||
|
|||
void _gradientMaterials() | |||
{ | |||
_engine->initializeMaterials(MaterialsColorMap::gradient); | |||
_engine->getScene().setMaterialsColorMap(MaterialsColorMap::gradient); | |||
_engine->getFrameBuffer().clear(); | |||
} | |||
|
|||
void _pastelMaterials() |
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.
no longer used, remove?
brayns/Brayns.cpp
Outdated
@@ -1287,10 +1247,9 @@ struct Brayns::Impl : public PluginAPI | |||
|
|||
ParametersManager _parametersManager; | |||
EngineFactory _engineFactory; | |||
EnginePtr _engine; | |||
EnginePtr _engine{nullptr}; |
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.
not needed
brayns/Brayns.cpp
Outdated
KeyboardHandler _keyboardHandler; | ||
AbstractManipulatorPtr _cameraManipulator; | ||
MeshLoader _meshLoader; | ||
AbstractManipulatorPtr _cameraManipulator{nullptr}; |
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.
same
@@ -55,6 +55,6 @@ class BaseObject | |||
} | |||
|
|||
private: | |||
std::atomic_bool _modified{true}; | |||
bool _modified{true}; |
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.
can we revert this too? we can have a look offline if this is needed though be changed
plugins/RocketsPlugin/SnapshotTask.h
Outdated
@@ -77,7 +77,6 @@ class SnapshotFunctor : public TaskFunctor | |||
*_camera = *_params.camera; | |||
else | |||
*_camera = engine.getCamera(); | |||
_camera->setAspectRatio(float(_params.size.x()) / _params.size.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.
you sure? the snapshot has a different ratio. it's handled in the assignment now?
h->add_property("bounds", &s->getWorldBounds(), | ||
Flags::IgnoreRead | Flags::Optional); | ||
h->add_property("materials", &s->getMaterials()); | ||
auto bounds = s->getBounds(); |
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.
hmm, the bounds would ideally be cached by the scene, so they don't have to computed here. Let's discuss offline maybe.
#define OSPRAYMATERIAL_H | ||
|
||
#include <brayns/common/material/Material.h> | ||
#include <ospray_cpp/Data.h> |
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.
not used? in any case, don't use they're cpp API, it's terrible :)
#include <brayns/common/material/Material.h> | ||
namespace | ||
{ | ||
const size_t BOUNDINGBOX_MATERIAL_ID = 9999; |
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.
no more than 10000-2 materials? so sad 📦
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 regularly use more than that actually. Maybe set it to size_t (-1)?
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.
Actually, shouldn't these be in types.h class? Next to
const size_t NO_MATERIAL = std::numeric_limits<size_t>::max();
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 like that! Done.
tests/ClientServer.h
Outdated
@@ -45,8 +45,9 @@ const size_t SERVER_PROCESS_RETRIES = 10; /*ms*/ | |||
class ForeverLoader : public brayns::Loader | |||
{ | |||
public: | |||
void importFromBlob(brayns::Blob&&, brayns::Scene&, const brayns::Matrix4f&, | |||
const size_t) final | |||
void importFromBlob(brayns::Blob&&, brayns::Scene&, const size_t = 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.
those default values are not needed here. they're already in the base class
brayns/common/scene/Model.cpp
Outdated
if (_materials.find(materialId) == _materials.end()) | ||
throw std::runtime_error("Material " + std::to_string(materialId) + | ||
" is not registered in the model"); | ||
return _materials[materialId]; |
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.
Double lookup of materialId in map.
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.
Fixed!
brayns/common/scene/Model.cpp
Outdated
catch (const std::runtime_error&) | ||
{ | ||
createMaterial(materialId, std::to_string(materialId)); | ||
} |
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 would prefer to just do a _materials.find() instead of trying and catching exceptions.
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.
The really fishy thing is that getMaterial doesn't return anything. It should have a different name.
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.
Fixed. Thanks.
brayns/common/scene/Model.h
Outdated
{ | ||
ModelTransformation() = default; | ||
ModelTransformation(ModelTransformation&& rhs) = default; | ||
ModelTransformation& operator=(ModelTransformation&& rhs) = default; |
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.
All constructors/assignment are default, maybe remove all?
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 cannot because there is another constructor with a different signature below :(
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.
Okay, I missed that 👍
brayns/common/scene/Model.h
Outdated
private: | ||
Vector3f _translation{0.f, 0.f, 0.f}; | ||
Vector3f _scale{1.f, 1.f, 1.f}; | ||
Vector3f _rotation{0.f, 0.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.
I guess my opinion doesn't count very much here, but this looks like Euler angles, which are quite cumbersome to specify formally (is this xzx, xyz, xyx, intrinsic, extrinsic, ...?). The interpretation is not even documented here.
Why don't you use a quaternion or an angle, axis representation, which are unambiguous and self-explanatory?
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 agree, I guess we will match these with what the user uses in the UI.
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's a discussion that comes and go on a regular basis ;) I don't have a strong opinion there, I simply find the translation/scaling/rotation more human readable, and since this is what is exposed to the HTTP interface, I decided to use that representation. I guess the JS guy's opinion also is to consider. I'll ask input from @rolandjitsu
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.
This interface doesn't have to match what users see necessarily. This class could use a matrix to encode the transformations and the client could use whatever is preferable depending on the use case, converting it to a matrix at the last step. That would be my choice, in fact.
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 know this discussion is recurrent and I don't what to start it again here. My criticism is that the way the rotation is expressed in this API is unclear (If you give this to two different people, the chances of ending up with a different transformation are quite high). At the very least, it should be documented better. And since it's not so easy to document easily, I suggest to use something which is unambiguous instead.
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.
Any method for manipulating objects from the GUI in a natural way and relative to the camera position will have to do some transformations, no matter what this API is, and for that you need an algebraic representation (matrix or quaternion), which means that in the end you need to transform the user input to a matrix or quaternion.
If this API describes the rotation as something else, it means that you need to transform the algebraic representation to whatever this API requires. Any representation can be easily converted to a quaternion or a matrix, but I find the opposite more annoying.
For me these are good reasons to choose a quaternion.
Flags::IgnoreRead | Flags::Optional); | ||
h->add_property("materials", &s->getMaterials()); | ||
auto bounds = s->getBounds(); | ||
h->add_property("bounds", &bounds, Flags::IgnoreRead | 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.
Are you sending a pointer to a temporary variable 'bounds' here?
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.
Yes! :) Fixed ;)
brayns/io/ProteinLoader.cpp
Outdated
material->setDiffuseColor({colorMap[materialId].R / 255.f, | ||
colorMap[materialId].G / 255.f, | ||
colorMap[materialId].B / 255.f}); | ||
for (const auto& sphere : spheresPerMaterial.second) |
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 do you use colorMap[i] and colorMap[materialId] for the same material?
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.
Fixed!
I cannot comment too much on the design since I am not familiar enough with all the pieces but to me it looks fine :) |
799710f
to
3794847
Compare
Retest this please |
Introduced the notion of models.