yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #10457
[Branch ~yade-pkg/yade/git-trunk] Rev 3820: Add hideBody/showBody to selectively display bodies in the 3D view
------------------------------------------------------------
revno: 3820
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
timestamp: Sun 2014-02-16 17:42:06 +0100
message:
Add hideBody/showBody to selectively display bodies in the 3D view
modified:
pkg/common/OpenGLRenderer.cpp
pkg/common/OpenGLRenderer.hpp
--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/common/OpenGLRenderer.cpp'
--- pkg/common/OpenGLRenderer.cpp 2013-05-30 20:13:27 +0000
+++ pkg/common/OpenGLRenderer.cpp 2014-02-16 16:42:06 +0000
@@ -85,7 +85,9 @@
void OpenGLRenderer::setBodiesDispInfo(){
- if(scene->bodies->size()!=bodyDisp.size()) bodyDisp.resize(scene->bodies->size());
+ if(scene->bodies->size()!=bodyDisp.size()) {
+ bodyDisp.resize(scene->bodies->size());
+ for (Body::id_t k=0; k<scene->bodies->size(); k++) bodyDisp[k].hidden=0;}
bool scaleRotations=(rotScale!=1.0);
bool scaleDisplacements=(dispScale!=Vector3r::Ones());
FOREACH(const shared_ptr<Body>& b, *scene->bodies){
@@ -305,7 +307,7 @@
FOREACH(const shared_ptr<Body>& b, *scene->bodies){
if(!b || !b->bound) continue;
- if(!bodyDisp[b->getId()].isDisplayed) continue;
+ if(!bodyDisp[b->getId()].isDisplayed or bodyDisp[b->getId()].hidden) continue;
if(b->bound && ((b->getGroupMask()&mask) || b->getGroupMask()==0)){
glPushMatrix(); boundDispatcher(b->bound,scene.get()); glPopMatrix();
}
@@ -339,7 +341,7 @@
// but it is still better than crashes if the body gets deleted meanwile.
FOREACH(shared_ptr<Body> b, *scene->bodies){
if(!b || !b->shape) continue;
- if(!bodyDisp[b->getId()].isDisplayed) continue;
+ if(!(bodyDisp[b->getId()].isDisplayed and !bodyDisp[b->getId()].hidden)) continue;
Vector3r pos=bodyDisp[b->getId()].pos;
Quaternionr ori=bodyDisp[b->getId()].ori;
if(!b->shape || !((b->getGroupMask()&mask) || b->getGroupMask()==0)) continue;
=== modified file 'pkg/common/OpenGLRenderer.hpp'
--- pkg/common/OpenGLRenderer.hpp 2013-05-30 20:13:27 +0000
+++ pkg/common/OpenGLRenderer.hpp 2014-02-16 16:42:06 +0000
@@ -44,9 +44,12 @@
Vector3r pos;
Quaternionr ori;
bool isDisplayed;
+ bool hidden;
};
//! display data for individual bodies
vector<BodyDisp> bodyDisp;
+ void hide(Body::id_t id) {if ((unsigned int) id<bodyDisp.size()) bodyDisp[id].hidden=true; }
+ void show(Body::id_t id) {if ((unsigned int) id<bodyDisp.size()) bodyDisp[id].hidden=false; }
virtual ~OpenGLRenderer();
@@ -119,6 +122,8 @@
/*py*/
.def("setRefSe3",&OpenGLRenderer::setBodiesRefSe3,"Make current positions and orientation reference for scaleDisplacements and scaleRotations.")
.def("render",&OpenGLRenderer::pyRender,"Render the scene in the current OpenGL context.")
+ .def("hideBody",&OpenGLRenderer::hide,(python::arg("id")),"Hide body from id (see :yref:`OpenGLRenderer::showBody`)")
+ .def("showBody",&OpenGLRenderer::show,(python::arg("id")),"Make body visible (see :yref:`OpenGLRenderer::hideBody`)")
);
};
REGISTER_SERIALIZABLE(OpenGLRenderer);