Food For Thought

Hi everyone.

Lately I just solved something in my Application I thought I had solved already…but it came back and bit me in the “arse”, HARD!

This topic relates to the collision handler queue; or more specific, the Data Structure Pand3D uses.

I always thought collision entries were being appended to a list (list data structure), which would mean the last collision entry would be just that…in the last index of the list. This is not so.

I found out, if you want to retrieve the collision Entries in the order in which the collisions happened, you have to reverse the sequence yourself.

For instance, if you performed a loop that took every collision entry from the queue, going from index 0 to the last index of the queue, you would get a backward list using the Python Programming Language. Thus you would have to call the reverse method on the python list.

Not knowing this wasted an entire day of work for me…and caused me to pull some hair out.

Because of this I grew curious…

Can anyone tell me, what kind of data structure Panda3D is using to store the collision queue? or better yet, how that data structure works? It’s obvious data is being pushed down in a stack instead of being placed at the end of the stack.

I wish little details like this were included in the Manual where it teaches about collision queues. If the Manual would of mentioned that the data entering the collision queue was pushed down instead of placed at the end…that little info would of saved me a lot of time (and hair).

Just thought I’d mention this discovery (for me anyway) as “food for thought.” No big deal…so please don’t curse me out everyone. lol

I don’t understand why you’re asking this question. Why does it matter? Panda doesn’t guarantee the order things will appear in the list (use sortEntries() if you want them to be sorted front-to-back). The underlying data structure used is irrelevant and it wouldn’t be any different if a different data structure was used internally.

That makes me even more curious… Since Data Structures usually have some form of Structure…hence the name.

E.g. Python Dictionaries; structured in a key, value pair. A Python list will keep order based on how data is entered. Appending data puts it at the end. you can insert data for a specific position in the list. In addition, you have methods that will reverse, sort, etc a list.

Oh well… I guess RDB cleared up this Post, case closed. :slight_smile:

Thanks for the knowledge.

I think Python dictionaries use hash tables as data structure, internally.

Just for the record, the internal data storage used by CollisionHandlerQueue is a vector, which is a type of dynamic array.