Join #ludumdare on irc.afternet.org
Mini LD #5 :: November 7th-9th Weekend :: Theme :: Cover

Sign In | Write your Journal
Home | Planet Ludum | Rules Wiki | Mailing List
Ludum Dare 12 Final Results NOW AVAILABLE

Click HERE for the Ludum Dare 12 entries image grid
(to be included in the image grid, you must upload an image to the blog)


Banging My Head For What???

Posted by ArmchairArmada

I spent the past couple of hours trying to get a simple spacial partitioning system working so ray/triangle intersection tests between game objects and the world mesh would be reasonably quick … or so I hoped.  On my machine the frame rate drops horribly with even as few as 10 intersection tests per frame!  I guess Python’s not a good platform to write a 3D engine in.  :(

Tags:

5 Responses to “Banging My Head For What???”

  1. mikejedw Says:

    Have you tried using Soya? It’s a 3D engine for Python that has a lot of stuff you might need already pre-built.

  2. ArmchairArmada Says:

    It might have been a good idea for me to use an existing 3d engine … but I wanted to try to write a simple engine from scratch. I thought it would be fun!

  3. RB0 Says:

    I remember doing the same thing during a Pyweek once, rewrote the code almost a dozen times. Then abandoned the idea and moved on. Ended up being just a couple things I missed really.

    I would suggest looking at how other projects handle it before giving up, as I don’t think it is a limitation in Python - you just have to do it differently. C++ will generally only get you 5-10x (at least from what I have seen, it can be higher, but not usually IIRC)…

    Good luck with it though :) I look forward to what you come up with :)

  4. ArmchairArmada Says:

    I forgot to mention it earlier, but I figured out how to speed it up quite a bit. I was using a simple 3D grid of cells for a spacial partitioning system with each cell containing the triangles that intersect with it. A lot of the slowdown problem had to do with how Python works. I found that dictionaries are A LOT faster than arrays, so I decided to use dictionaries as arrays. They dictionary keys were simply [z * width * height + y * width + x]. It sounds a little stupid, but the speed increase was amazing. I went from only being able to comfortably do about 7 ray-triangle tests per frame to being able to do around 70 — which would have permitted me to have around 20-25 moving objects (with around 3 ray-triangle tests per object). Unfortunately, this realization came after MANY hours of frustration, leaving me no time to actually complete the game.

  5. ArmchairArmada Says:

    You mentioned C++. I decided not to use C++ mainly because I thought development time would have been significantly shortened with Python. C++ requires a lot of extra typing and any change that’s made requires editing a lot of other bits of code. With that said, however, if I used C++ I estimate I would have been able to do thousands of ray-triangle tests per frame. Python is VERY slow.

Leave a Reply


All posts, images, and comments are owned by their creators.