mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-14 16:44:37 +00:00
Filters refined
This commit is contained in:
parent
ac01f61e61
commit
0db2a1ee90
@ -32,8 +32,8 @@ void ODEFacade::initialize(){
|
||||
|
||||
void ODEFacade::clear(MeshDocument& md){
|
||||
for(MeshContainer::iterator i = m_registeredMeshes.begin(); i != m_registeredMeshes.end(); i++){
|
||||
if(md.meshList.contains(i->first))
|
||||
tri::Allocator<CMeshO>::DeletePerMeshAttribute(i->first->cm, "physicsID");
|
||||
/*if(tri::HasPerMeshAttribute(i->first->cm, "physicsID"))
|
||||
tri::Allocator<CMeshO>::DeletePerMeshAttribute(i->first->cm, "physicsID");*/
|
||||
|
||||
dGeomDestroy(i->second->geom);
|
||||
if(i->second->body)
|
||||
@ -50,7 +50,7 @@ void ODEFacade::setGlobalForce(float force[3]){
|
||||
|
||||
void ODEFacade::registerTriMesh(MeshModel& mesh, bool scenery){
|
||||
if(tri::HasPerMeshAttribute(mesh.cm, "physicsID"))
|
||||
return;
|
||||
tri::Allocator<CMeshO>::DeletePerMeshAttribute(mesh.cm, "physicsID");
|
||||
|
||||
if(mesh.cm.Tr != vcg::Matrix44f::Identity()){
|
||||
vcg::tri::UpdatePosition<CMeshO>::Matrix(mesh.cm, mesh.cm.Tr);
|
||||
|
||||
@ -46,10 +46,15 @@ bool RandomFillFilter::applyFilter(QAction* filter, MeshDocument &md, RichParame
|
||||
|
||||
srand((unsigned)time(0));
|
||||
|
||||
vcg::tri::UpdatePosition<CMeshO>::Matrix(filler->cm, filler->cm.Tr);
|
||||
filler->cm.Tr.SetIdentity();
|
||||
|
||||
tri::Inertia<CMeshO> inertiaContainer, inertiaFiller;
|
||||
inertiaContainer.Compute(par.getMesh("container")->cm);
|
||||
inertiaFiller.Compute(par.getMesh("filler")->cm);
|
||||
|
||||
int objects = abs(inertiaContainer.Mass()/inertiaFiller.Mass())*par.getFloat("factor");
|
||||
filler->cm.Tr.SetColumn(3, - inertiaFiller.CenterOfMass());
|
||||
|
||||
if(par.getBool("useRandomVertices")){
|
||||
for(int i = 0; i < objects; i++){
|
||||
@ -74,6 +79,7 @@ bool RandomFillFilter::applyFilter(QAction* filter, MeshDocument &md, RichParame
|
||||
}
|
||||
|
||||
m_engine.updateTransform();
|
||||
filler->cm.Tr.SetIdentity();
|
||||
|
||||
if(cb != 0) (*cb)(0, "Physics renderization of the scene completed...");
|
||||
return true;
|
||||
@ -91,5 +97,5 @@ void RandomFillFilter::addRandomObject(MeshDocument& md, MeshModel* filler, cons
|
||||
MeshModel* meshCopy = md.addNewMesh(meshName.str().c_str());
|
||||
vcg::tri::Append<CMeshO,CMeshO>::Mesh(meshCopy->cm, filler->cm, false, true);
|
||||
meshCopy->cm.Tr = filler->cm.Tr;
|
||||
meshCopy->cm.Tr.SetColumn(3, origin);
|
||||
meshCopy->cm.Tr.SetColumn(3, meshCopy->cm.Tr.GetColumn3(3) + origin);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user