Hello. Can someone please help? I’m using a C++ CRhinoDisplayConduit in a Grasshopper component, and I’m getting this weird behavior with the clipping planes. This code is directly copied and pasted from another CPP file that works exactly as intended in a different component. I’m lost with how to fix it.
class RelativeElevationConduit : public CRhinoDisplayConduit {
std::vector<const RelativeElevationData*> m_data;
RenderMaterial m_material = RenderMaterial(L"Relative Elevation Material", RGB(0, 0, 0), 0);
public:
RelativeElevationConduit() : CRhinoDisplayConduit(CSupportChannels::SC_CALCBOUNDINGBOX | CSupportChannels::SC_PREDRAWOBJECTS | CSupportChannels::SC_POSTDRAWOBJECTS) {
Enable();
}
bool ExecConduit(CRhinoDisplayPipeline& dp, UINT nActiveChannel, bool& bTerminate) override {
m_pDisplayAttrs->m_bShowMeshEdges = true;
if (nActiveChannel == CSupportChannels::SC_CALCBOUNDINGBOX) {
m_pChannelAttrs->m_BoundingBox = ON_BoundingBox::EmptyBoundingBox;
for (const RelativeElevationData* d : m_data) {
if (d->GetDisplayMode() != 0)
m_pChannelAttrs->m_BoundingBox.Union(d->Mesh().BoundingBox());
}
}
else if (nActiveChannel == CSupportChannels::SC_PREDRAWOBJECTS) {
for (const RelativeElevationData* d : m_data) {
if (d->GetDisplayMode() != 0)
dp.DrawShadedMesh(d->Mesh(), &m_material);
}
}
return true;
}
void AddData(const RelativeElevationData* data) {
for (const RelativeElevationData* d : m_data) {
if (d == data)
return;
}
m_data.push_back(data);
}
void RemoveData(const RelativeElevationData* data) {
for (int i = (int)m_data.size() - 1; i >= 0; i--) {
if (m_data[i] == data)
m_data.erase(m_data.begin() + i);
}
}
};
RelativeElevationData::RelativeElevationData(const ON_Mesh* mesh, const MeshGrid* grid) {
RConduit.AddData(this);
m_mesh = *mesh;
m_grid = grid;
MeshUtil::MeshPoints(mesh, m_points);
m_mesh.m_C.SetArray(new ON_Color[m_mesh.m_V.Count()], m_mesh.m_V.Count(), m_mesh.m_V.Count());
Differences.SetArray(new double[m_mesh.FaceCount()], m_mesh.FaceCount(), m_mesh.FaceCount());
Averages.SetArray(new double[m_mesh.FaceCount()], m_mesh.FaceCount(), m_mesh.FaceCount());
Minimums.SetArray(new double[m_mesh.FaceCount()], m_mesh.FaceCount(), m_mesh.FaceCount());
Maximums.SetArray(new double[m_mesh.FaceCount()], m_mesh.FaceCount(), m_mesh.FaceCount());
m_shader.SetState(m_grid->FaceCount);
}
RelativeElevationData::~RelativeElevationData() {
RConduit.RemoveData(this);
}
void RelativeElevationData::SetDisplayMode(int mode) {
m_displayMode = mode;
setColors();
}