# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 1 post ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Optimizing world with double link listPosted: Tue May 01, 2012 6:17 pm

Joined: Sun Jan 29, 2012 10:01 pm
Posts: 49
I am trying to optimize the Bullet engine by keeping a non allocating double link list of each active rigid body so that the world don't have to ask each sleeping body if it is active.
The only thing missing is a way to know when a rigid body has changed it's activation state so that isActive() gives another result.
I noticed that all methods for setting the activation state in btCollisionObject are not virtual so that I can't get a call from it without having to recompile the library.

Code:

template <class el>

// This is stored where you want to access the list
// There can be multiple heads using the same relation as long as they are mutually exclusive
template <class el>
void ResetMemory(void) {
}
};

template <class el>
if (!(Element->Included)) { // If the element is not included
Element->Included = true; // The element is included
Element->Previous = NULL; // The first element has no previous element
Element->Content = Content;
}
}

template <class el>
if (Element->Included) { // If the element belongs to something
Element->Included = false; // The element is no longer a member
if (Head == Element) { // If the element is first in this collection
} else if (Element->Previous) { // If the element has a previous element
Element->Previous->Next = Element->Next; // The previous element inherits it's next element no matter if it is null
}
if (Element->Next) { // If the element has a next element
Element->Next->Previous = Element->Previous; // The next element inherits it's previous element no matter if it is null
}
Element->Next = NULL; // The element have no next element
Element->Previous = NULL; // The element have no previous element
}
}

// This is stored in each element
// It can at most declare membership to one list and can therefor not be used for many to many relations
template <class el>
el* Content;
bool Included;
void ResetMemory(void) {
Previous = NULL;
Next = NULL;
Content = NULL;
Included = false;
}
};

#endif

I put the head in my world class inheriting from btDiscreteDynamicsWorld
Code:

I put the body with the next and previous pointers and a pointer to the world's head in my rigid body class inheriting from btRigidBody.
Both the head and the body is named LL_ActiveRigidBodies to show that they belong to the same link list.
Code:

The ResetMemory methods are used as constructors but can be called wherever the list is stored without having to use placement new.

The rigid body use these methods for adding and removing itself from the list.
Code:
}

void ModifiedRigidBody::RemoveFromActiveList(void) {
}

This is how I get each element in the list.
Code:
while (Iterator) {
UseRigidBody(Iterator->Content);
Iterator = Iterator->Next;
}

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 1 post ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot] and 8 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities