I’ve started working on a new game, having lost interest in my last one, and in this game I have some actors that I need to keep on top of terrain in a similar fashion to what’s done in roaming ralph.
There’s one sticky bit, though. It’s a racing game and the terrain may have loops or spirals or some such that would put the actor technically below the terrain it needs to fall up onto, if you get what I was saying.
I figured this wouldn’t be a big problem and I cracked open roaming ralph to look at his groundray code and I saw something that surprised me.
entries =  for i in range(self.ralphGroundHandler.getNumEntries()): entry = self.ralphGroundHandler.getEntry(i) entries.append(entry) entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(), x.getSurfacePoint(render).getZ()))
That block of code sorts through the entries in the collision handler, I think by the Z of the point of collision. How does that compare to just calling sortEntries() on the collision handler? Why is this much more complicated sorting system in use?
I’d love to know, if anyone would be kind enough to supply an answer.