So progress on kyuplex the past week has been all refactoring! I'm still a noob with C++ but I'm learning lots. Still reading Scott Meyers and it is opening my mind. Fascinating stuff, love it.
Anyway, so for kyuplex I'm redesigning the most base class: kxCube.
I plan on experimenting with some pseudo instancing and other optimizations. Since kxCube will be the basis for so much of kyuplex, I think all the extra time I am spending on it will pay off.
I've redesigned the mesh to it's most basic essence. Eight vertices, six normals, rendered with a call to drawVertexPrimitiveList with PrimitiveType EPT_QUADS. The bare minimum. Looks good to me so far.
I've refactored the class to not derive from an IMeshSceneNode but rather derive directly from ISceneNode, and just render itself directly from its own internal Vertex/Indice arrays. We are talking about just cubes here, it's not very complicated geometry, and I was getting very tired of accessing my vertices like this:
SMeshBuffer* buf= static_cast<SMeshBuffer*>( kxCube->getMesh(0)->getMeshBuffer(0));
buf->Vertices[...] etc.
I want direct access to the verts and indices because I am going to do some tricky stuff with them with pseudo instancing, as well as with the physics rigid bodies. I want to throw out kxMotionStates and just update the transforms manually because I intend on updating all instances manually and then batching them all together and making one draw call. Right now the MotionStates are updating the transforms every physics tick, but I just want to update them myself before each render, which is capped at 125 fps, so updates would occur less frequently. Hopefully this will yield acceptable performance. Right now, framerates are dropping dramatically when the playerCube fractures into only eight sub-cubes. I feel like fluid, well-performing physics is crucial to the look and feel of kyuplex, and so I am spending so much time optimizing and refactoring.
No comments:
Post a Comment