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

Attempt to fix OSPRay clip plane behavior #1260

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion plugins/mmadios/src/adiosWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool adiosWriter::create() {
if (MpiInitialized) {
adiosInst = adios2::ADIOS(this->mpi_comm_);
} else {
adiosInst = adios2::ADIOS(adios2::DebugON);
adiosInst = adios2::ADIOS();
}
#else
try {
Expand Down
4 changes: 3 additions & 1 deletion plugins/mmospray/include/mmospray/CallOSPRayStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "mmcore/factories/CallAutoDescription.h"
#include "mmospray/CallOSPRayMaterial.h"
#include "mmospray/CallOSPRayTransformation.h"
#include "rkcommon/math/vec.h"

#include <map>
#include <vector>

Expand Down Expand Up @@ -85,7 +87,7 @@ struct curveStructure {
};

struct ClippingPlane {
std::array<float, 4> coeff = {0, 0, 0, 0};
::rkcommon::math::vec4f coeff = {0, 0, 0, 0};
bool isValid = false;
};

Expand Down
8 changes: 2 additions & 6 deletions plugins/mmospray/src/AbstractOSPRayRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,17 +1162,13 @@ bool AbstractOSPRayRenderer::generateRepresentations() {
if (entry.second.clippingPlane.isValid) {
_baseStructures[entry.first].emplace_back(::ospray::cpp::Geometry("plane"), GEOMETRY);

::rkcommon::math::vec4f plane;
plane[0] = entry.second.clippingPlane.coeff[0];
plane[1] = entry.second.clippingPlane.coeff[1];
plane[2] = entry.second.clippingPlane.coeff[2];
plane[3] = entry.second.clippingPlane.coeff[3];
std::get<::ospray::cpp::Geometry>(_baseStructures[entry.first].structures.back())
.setParam("plane.coefficients", ::ospray::cpp::CopiedData(plane));
.setParam("plane.coefficients", ::ospray::cpp::SharedData(entry.second.clippingPlane.coeff));
std::get<::ospray::cpp::Geometry>(_baseStructures[entry.first].structures.back()).commit();

_clippingModels[entry.first].emplace_back(::ospray::cpp::GeometricModel(
std::get<::ospray::cpp::Geometry>(_baseStructures[entry.first].structures.back())));
_clippingModels[entry.first].back().setParam("invertNormals", true);
_clippingModels[entry.first].back().commit();

_groups[entry.first].setParam(
Expand Down
4 changes: 2 additions & 2 deletions plugins/mmospray/src/AbstractOSPRayStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ void AbstractOSPRayStructure::processClippingPlane() {
// ccp->GetPlane().Point().GetX(), ccp->GetPlane().Point().GetY(), ccp->GetPlane().Point().GetZ()};
//float d = glm::dot(point, normal);
ClippingPlane& cp = this->structureContainer.clippingPlane;
if (cp.coeff[0] != normal.x || cp.coeff[1] != normal.y || cp.coeff[2] != normal.z || cp.coeff[3] != d) {
if (cp.coeff[0] != normal.x || cp.coeff[1] != normal.y || cp.coeff[2] != normal.z || cp.coeff[3] != -d) {
this->structureContainer.clippingPlaneChanged = true;
cp.coeff[0] = normal.x;
cp.coeff[1] = normal.y;
cp.coeff[2] = normal.z;
cp.coeff[3] = d;
cp.coeff[3] = -d;
} else {
this->structureContainer.clippingPlaneChanged = false;
}
Expand Down
3 changes: 3 additions & 0 deletions plugins/mmstd/include/mmstd/renderer/ClipPlane.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ class ClipPlane : public Module {

/** The plane-origin distance */
param::ParamSlot distSlot;

/** A button to normalize the normal */
param::ParamSlot normalizeSlot;
};

} // namespace megamol::core::view
13 changes: 12 additions & 1 deletion plugins/mmstd/src/renderer/ClipPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "mmstd/renderer/ClipPlane.h"
#include "mmcore/param/BoolParam.h"
#include "mmcore/param/ButtonParam.h"
#include "mmcore/param/ColorParam.h"
#include "mmcore/param/FloatParam.h"
#include "mmcore/param/Vector3fParam.h"
Expand All @@ -29,7 +30,8 @@ view::ClipPlane::ClipPlane()
, colourSlot("colour", "Defines the colour of the clipping plane")
, normalSlot("normal", "Defines the normal of the clipping plane")
, pointSlot("point", "Defines a point in the clipping plane")
, distSlot("dist", "The plane-origin distance") {
, distSlot("dist", "The plane-origin distance")
, normalizeSlot("normalize", "normalizes the normal") {

this->plane.Set(vislib::math::Point<float, 3>(0.0, 0.0f, 0.0f), vislib::math::Vector<float, 3>(1.0f, 0.0f, 0.0f));
this->col[0] = this->col[1] = this->col[2] = 0.5f;
Expand All @@ -53,6 +55,9 @@ view::ClipPlane::ClipPlane()

this->distSlot << new param::FloatParam(-this->plane.Distance(vislib::math::Point<float, 3>(0.0f, 0.0f, 0.0f)));
this->MakeSlotAvailable(&this->distSlot);

this->normalizeSlot << new param::ButtonParam();
this->MakeSlotAvailable(&this->normalizeSlot);
}


Expand Down Expand Up @@ -94,6 +99,12 @@ bool view::ClipPlane::requestPlane(Call& call) {
return false;
}

if (this->normalizeSlot.IsDirty()) {
auto n = this->normalSlot.Param<param::Vector3fParam>()->Value();
n.Normalise();
this->normalSlot.Param<param::Vector3fParam>()->SetValue(n);
}

if (this->colourSlot.IsDirty()) {
this->colourSlot.ResetDirty();
this->colourSlot.Param<param::ColorParam>()->Value(this->col[0], this->col[1], this->col[2], this->col[3]);
Expand Down
Loading