🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Untitled

posted in DruinkJournal
Published August 03, 2006
Advertisement
Hnng. Damn std::set.

I found that I kept getting asserts all over the place when TEH MMORPG!!1 shut down, to do with objects not being found in my scene graph. Since I'm using an almost RAII technique for adding/removing objects in my scene, I didn't know where this problem was comming from.

Well, I found it on the way home yesterday. My scene graph is a std::set, but the sort func was only sorting objects by type and priority. Which meant that it wasn't being sorted properly. After fixing that, I spent about 2 hours tracking down another problem. Because the scene objects are pointers, I was changing the XYZ position (Where Z is priority) in my GUI code, which caused the scene graph to no longer be sorted, meaning std::set couldn't find the right objects and was erasing incorrect objects when I requested an object be removed from the scene.
So, I have to reinsert the object to the scene graph after I change it's position.

However, while I've been writing this, I just realised I'm sorting by X and Y position as well as Z, which is totally pointless. I'll change to to just sort by Z and pointer value. That also means I don't need to reinsert the objects when their XY position changes. Whoops. That'd explain the enormous drop in FPS when you start moving stuff...


In other news, I've started playing OpenTTD. I used to play Transport Tycoon Deluxe, but it won't work on XP. And OpenTTD has cool new stuff. The upshot of all this is that I don't get early nights because it's surprisingly addictive. "Oh, I'll just finish this one transport route". Followed by "Well, it's busier than I thought. I'll make the rail take 2 trains". Then "Oh, now I have more trains on it, I might as well visit a couple more stops", and it goes on like that.

Anyway. Work.
Previous Entry Untitled
Next Entry LOL. SPAM.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement