Inspiration needed for a collision manager

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Inspiration needed for a collision manager

Postby jiandingzhe » Wed Nov 30, 2011 7:27 am

The reason why I need to build an collision manager, is:
1: NewtonCollision requires an unique ID when being constructed. A manager is a good place to put the ID seed.
2: Collisions can be reused in different bodies.

First of all, I already have an convex mesh manager, from which a convex mesh can be fetched from a name string.

An NewtonCollision is created from an convex mesh and a offset matrix. So a collision can be uniquely keyed by a name and a matrix. I can define a key class to organize collisions into a std::map.

So I can use something like this:
Code: Select all
class CollisionKey {
    string name;
    Vector3 position;
    Quaternion orientation;
}

class Manager {
public:
    NewtonCollision* getOrCreateCollision(string& name, Vector3& position, Quaternion& orientation);
protected:
    std::map<CollisionKey,int> collisionIDs;
    std::map<int,NewtonCollision*> collisions;
}



Then the problem comes: How can I cope with CompoundCollision?
User avatar
jiandingzhe
 
Posts: 48
Joined: Fri Jul 08, 2011 11:21 am
Location: Beijing

Re: Inspiration needed for a collision manager

Postby Julio Jerez » Wed Nov 30, 2011 8:12 am

compound collision can no be reused, because they have local dada.

compound collision overhead per sube collsion is very small anyway.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Inspiration needed for a collision manager

Postby JernejL » Fri Dec 02, 2011 6:50 pm

you can clone a compound collision tho - by using newtoncollisiongetinfo & get the object pieces back
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron