   Method to render the BSP in directx
  Hi I am new to using directx to render a BSP tree. This is what i did.Before Game Loop:1. I created the BSP tree using the index as I thought creating many duplicate vertex would cost alot of memeory.2. After the BSP tree is created, i load the vertex buffer with the vertex.During Game Loop:1. I check whether the eye is infront or behind the splitting plane then i tranverse down the tree pushing the index at the nodes into a - vector<WORD> index.2. After the tranversal is done, I create the index buffer using the vector<WORD> index, then i draw the scence. Next I destroy the index buffer and prepare for the next loop.I am rendering using default_interval.Is this the correct method? I rendered the mesh car.x from the Directx SDK sample mesh and the fps was at 12-15. Is this normal or am i doing it wrongly?   
  From your description, I'd be saying it's your usage of std::vector and IB's that's killing you.Creating/recreating resources inside a game loop is never a good idea, sometimes you have no choice, but for the most part you can (and should) avoid it.The simple thing here is to change your index buffer so that it's dynamic (D3DUSAGE_DYNAMIC iirc) and of a size that you think can store all your data (usually making it a bit bigger is okay) and then use the Lock() mechanisms to just overwrite data each frame.overwriting the data each frame is still not necessarily the quickest option, but it'll definitely be faster than what you've currently got. If you can, try and "dump" your data from system memory to the IB instead of copying per-element in a loop.You might well find that the greatest improvement you can make is going to be a change of architecture (macro optimization) rather than little tweaks (micro optimization). I can't really give you an answer to this as such, but break out some profiling tools (e.g. PIX for windows) and maybe pen/paper to draw out execution paths...For example, in my quadtree implementation some years back, I found that storing lots and lots of duplicate index buffers chewed up an extra 500-600kb of storage, but gave me a lot more speed (less resource switching/modifying). For modern video cards, that extra storage is really nothing to worry about [smile]This change was more of a macro optimization as I changed the fundamental algorithm/process for rendering, rather than trying to optimize each-and-every call/operation...hthJack   ;  Thanks for the answer. Using D3DUSAGE_DYNAMIC stablise the fps at certain numbers which varies for different mesh. I suspect the low fps in thoes high index mesh is due to the extensive time take to tranverse the depth of the tree. Is there any way to speed up the tree tranvsal? My current method is to use recursion to travel down the tree. Is using a stack to tranverse the tree faster?20955 index -> 29-31 fps?Is there any way to increase the fps?Could syou uggest some macro optimization for a bsp tree? Currently my bsp is the same as the one in this article from gamedev:http://www.gamedev.net/reference/articles/article657.asp   ;Quote:Original post by littlekidThanks for the answer. Using D3DUSAGE_DYNAMIC stablise the fps at certain numbers which varies for different mesh. I suspect the low fps in thoes high index mesh is due to the extensive time take to tranverse the depth of the tree.You need to run some profiling - guessing where you're losing time is like walking in the countryside without a map [wink] Quote:Original post by littlekidIs there any way to speed up the tree tranvsal? My current method is to use recursion to travel down the tree. Is using a stack to tranverse the tree faster?Difficult to say, until you have some precise instrumentation you're not going to know for sure. Usually for things like trees, reducing the number of nodes it checks, and restructuring it is the best bet...Quote:Original post by littlekidCould syou uggest some macro optimization for a bsp tree? Currently my bsp is the same as the one in this article from gamedev:http://www.gamedev.net/reference/articles/article657.aspI've never had any need to implement a BSP tree in my software, so I'm not the best person to answer this.Maybe someone else can post some ideas here, failing that you could try the people in the Graphics Programming & Theory forum.hthJack   