To Optimize cloth

Ask other users for help.

To Optimize cloth

Postby arvin.mittal » Wed Dec 28, 2011 9:25 am

Hi,
I have drawn the cloth ( soft body) and made it fall on ball. It falls very slowly due to calculations which make it slow, how can I optimize my code and make the cloth fall fast.
arvin.mittal
 
Posts: 6
Joined: Fri Nov 18, 2011 7:45 am
Location: Noida, India

Re: To Optimize cloth

Postby noone » Thu Dec 29, 2011 1:30 pm

Hi!

How large is your cloth? Do you use selfcollision?
User avatar
noone
Site Admin
 
Posts: 432
Joined: Wed Jul 28, 2010 2:02 pm

Re: To Optimize cloth

Postby arvin.mittal » Fri Dec 30, 2011 11:44 am

noone wrote:Hi!

How large is your cloth? Do you use selfcollision?




Hey thanks for your reply.....but i have solved that......I was doing it wrong earlier
Help me in optimizing this...

foreach (RigidBody body in world.RigidBodies)
{
if(body.Position.y< -10)
{
world.removebody(body);///////it crashes at this point.....i want to remove the body which is not in my view....plz tell
}
if (body.Shape is SphereShape)
{
if ((string)body.Tag == "mySphere" )
{
//SphereShape shape = body.Shape as SphereShape;
GLES1.glColor4f(0.0f, 1.0f, 1.0f, 1.0f);
dsDrawSphere(body.Position, body.Orientation, radius);
}
}
}
arvin.mittal
 
Posts: 6
Joined: Fri Nov 18, 2011 7:45 am
Location: Noida, India

Re: To Optimize cloth

Postby noone » Fri Dec 30, 2011 6:04 pm

//it crashes at this point.....i want to remove the body which is not in my view....plz tell


What's the error message you get?
User avatar
noone
Site Admin
 
Posts: 432
Joined: Wed Jul 28, 2010 2:02 pm

Re: To Optimize cloth

Postby arvin.mittal » Mon Jan 02, 2012 6:34 am

noone wrote:
//it crashes at this point.....i want to remove the body which is not in my view....plz tell


What's the error message you get?



error comes when sphere body falls below -10units.(ie. body.position.Y < -10)

foreach (RigidBody body in world.RigidBodies)

//invalid Operation exceptionwas handled
Collection was modified; enumeration operation may not execute.

please reply..
Thanks
arvin.mittal
 
Posts: 6
Joined: Fri Nov 18, 2011 7:45 am
Location: Noida, India

Re: To Optimize cloth

Postby wert1990 » Tue Mar 26, 2013 6:57 pm

That error comes from the foreach loop.
you often cant write in the variable you are iterating throught, only reading is allowed.
If you use a for or while loop it should work.
wert1990
 
Posts: 1
Joined: Tue Mar 26, 2013 1:38 pm


Return to Questions and Help

Who is online

Users browsing this forum: No registered users and 0 guests

cron