moving to xna4
Now that the Xna4 Beta is out, our team decided to take the plunge.
A few things to be aware of
- Xna4 is VS2010 only.
but xna4+vs2010 can live side-by-side xna3.1+vs2008
- Xna4CTP uninstall is a PoS (broken)
use the XNA Game Studio cleanup tool if you run into problems uninstalling any version of XNA. (you will)
- Resharper 4.5 does not work on VS2010
upgrade to 5.0!
- Resharper 5.0 doesnt really work on VS2008
a lot of key commands are broken :(
- XNA4 contains breaking changes.
especially in rendering. hope you like refactoring.
Now is an ideal time to upgrade:
we are rewriting our rendering system, so best to do this as part of our shift to xna4, especially looking at a “fixed function fallback” system.
We already did some tests to make sure our code isnt a nightmare to port, so good times.
-JasonS
incremental redesign of Novaleaf Engine
we are about 2/3 through our post e3 “fix up” month, and thought i’d share a tiny bit on what we are doing:
What was wrong with our E3 demo:
The e3 demo was pretty, but had some technical issues:
- world objects were atomic only:
this means buildings were a single, opaque object. not because we only support atomic objects, but I didn’t want to spend time finishing the implemenation of composite objects until we were sure about the entire workflow, which leads to:
- the game object system was not extensible:
our “Element” system (atomic and composite) was high performance, but extending it was not easy: a single manager class that needed to be extended as a monolithic singleton. not good for supporting various game object categories.
- the visualization system was a nightmare:
well not a nightmare really, the system worked, but was overly complex architecture, plus difficult to extend. We have a deferred rendering pipeline, and the rendering system was designed with only that in mind. So extending rendering for use with particles, etc was difficult.
- rendering suffered performance issues:
CPU stalls waiting for the GPU, plus mysterious cpu spikes of up to 30ms shows significant risk in the current rendering architecture
- misc system design issues:
the particle system and physics system were fairly poorly designed (lacked required features) and need some architecture changes
Tomorrow, I’ll start talking about the steps we are taking to resolve these issues.
-JasonS
Everything you ever wanted to know about CF.NET performance
my thoughts on scenegraphs
Some posts on how to use or not use scenegraphs got me to write up a little on how we use them:
we use a spatial query for game objects, but a composite object (such as a building) may be made of sub-objects, so i basically have a scenegraph for those.
this also lets a composite objects manage their own collision resolutions, extending the base functionality where needed.
so a hybrid approach!
- JasonS
new sandcastle is out
At Novaleaf, we use Sandcastle to generate code documentation.
Not only code documentation, but as part of our “Novaleaf Simplified Process”, a major concept is “Close To Code”, meaning if possible, all documentation should be done in the code files.
So, code documentation tools are very important to our development methodology.
We are about 2 weeks away from moving to Xna4, which requires VS2010, and would let us support use of .Net 4.0, so i was happy to find out today that a new .NET 4.0 version of sandcastle is released.
- JasonS
Gamefest 2010 presentations
A msdn blog noted that the gamefest 2010 content is up and available to download
get the US or UK content
enjoy!
-JasonS
1 little, 2 little, 3 little endians
I came across my first “endianness” bug yesterday.
Previously, I was vauguely aware of bit-packing order differences on various platforms, but as it never impacted me or my team directly, I’ve never given it a second thought (especially thanks to the .Net and XNA framework’s great abstraction abilities).
Yesterday however, our graphics dev was trying to do this:
[StructLayout(LayoutKind.Explicit)]
struct SomeStruct
{
[FieldOffset(0)]
int sortOrder;
[FieldOffset(0)]
short prefix;
[FieldOffset(2)]
short suffix;
}
To me (and I suppose our graphic dev), this just logically should work. The lower bits being the more significant.
but we ran into a problem. the sortOrder wasn’t putting structs with the prefix before the suffix.
So first steps? use Visual Studio’s awesome IDE.
- Switch the watch window to hexidecimal display: this will very clearly show how the bytes are packed. and on windows we saw that what we expected the value of sortOrder to be was flipped around (suffix was more significant than prefix). This gave the clue that this was an endianness problem.
- to further analyze the struct’s layout, you can open up the Memory window, which will show you the bytes in RAM. this was used as an additional validation that yes, the bytes were in the proper memory order as expected by placing the prefix before suffix in RAM, but was being consumed in opposite-expected byte order.
Of course, since we are targeting cross platform, we have to be aware that XBox360 is big endian, while windows is little endian.
Thus, the final solution is this:
[StructLayout(LayoutKind.Explicit)]struct SomeStruct
{
[FieldOffset(0)] int sortOrder;
#if WINDOWS
[FieldOffset(2)]
#else
[FieldOffset(0)]
#endif
short prefix;
#if WINDOWS
[FieldOffset(0)]
#else
[FieldOffset(2)]
#endif
short suffix;
}
Note that we are saying only windows is little endian, while everything else is big-endian. this may be a problem for WP7, but suprisingly everyone seems wishy-washy over what endianness it is (I don’t have the emulator on my system to check)
-JasonS
Spatial Partitioning for dynamic worlds
I posted this as an answer to an xna forums question on what spatial partitioning to use for dynamic worlds. No sense wasting perfectly good blog-copy, right? :D
I am trying to decide which algorithm I should use for partitioning the game world. My game is 3D and has dynamic objects. I was thinking about maybe an Octree would be good, but come to think of it, it has to calculate EVERY frame because of the dynamic objects. So, my question is this. What would be the best space partitioning for a 3D game for collision and culling that has dynamic objects?
i’m developing a xna game/engine focused on a dynamic, densely populated world, and my choice is the simple grid (well, a hierarchy grid) this is because, as you mention, trees need to be repartitioned based on density changes. grids do not. what partition an object is in depends on it’s size. right now we are using 2 grids, with a 5m, and 50m cell size. objects in the 5m grid must be less than 5m in diameter (so each object is in at most 4 cells) while we do not have that restriction in the 50m grid (effectively using this for overflow, as in our game large objects don’t move around too frequently)
i would mention that we are using a 2d grid, not a 3d grid, as while the world is 3d, it is mostly spatially aligned to a 2d plane.
for various reasons, most games/engines use static environments, and as such you will have a hard time finding good online research on grids (most people love sexy quadtrees) though there are some good books (Realtime collision detection) that give great explanations on core concepts needed for any spatial partitioning system.
And as for what it’d be called, either plain “grid” or perhaps “Hierarchical Grid”
I hope that helps.
-JasonS