Thursday, April 09, 2015

Malloc in BinaryReader and BinaryWriter

In my efforts to write a malloc-free network library for Unity3D, I discovered that BinaryReader and BinaryWriter perform malloc operations when reading/writing floats and doubles.

It seems this is the case, because C# does not allow bit shifting operations on these types, which is used to turn these types into 4 or 8 bytes.

I ended up using this code to convert these types without using the builtin BitConverter (which performs a malloc!)

float[] FLOAT = new float[1];

public float ReadFloat ()
   Buffer.BlockCopy(buffer, (int)readStream.Position, FLOAT, 0, 4);
   readStream.Position += 4;
   return FLOAT[0];

public void Write (float value)
   FLOAT[0] = value;
   Buffer.BlockCopy(FLOAT, 0, buffer, (int)writeStream.Position, 4);
   writeStream.Position += 4;

Thursday, November 13, 2014

Python-3 Game Server

I've been working on something new. I get a lot of projects where I have to add multiuser functionality. Finally I've made the jump to Python 3, and built a generic multi-user game server, so I can stop rewriting this sort of thing for every new project. It's using the most excellent asyncio framework, with aiopg for Postgresql support.

The server code is on GitHub, the Unity3D client is still in progress.

Those tedious functions, such as Registration, Authentication, Reset Password, Messaging, Rooms and Object storage are solved, may I never have to write a "Reset Password" module again!

Thursday, October 09, 2014

4 Million Vertices of Procedural Spacecraft

Still lots of improvements to be made... but it is definitely getting better.

Wednesday, October 08, 2014

Procedural Spacecraft

I applied the greeble system to another spacecraft shell, trying to make some kind of freighter.

This highlighted a few issues. Greebles need to tile, rather than stretch. They also need to take collisions into account when determining placement.

Sunday, October 05, 2014

Popular Posts