Game Development Community

Pathed camera in T3D

by Rich Adam · in Torque 3D Professional · 07/23/2010 (7:16 pm) · 3 replies

I have implemented Tim Heldna's pathed cameras in T3D and I am getting a "write out of bounds" error after the camera completes about 40 or so path nodes.

For some reason I am exceeding the maxWriteBitNum limit in writeBits() by using the pathed camera.

What could be causing this write out of bounds condition?

Thanks in advance for your reply.

out of boundingly yours,
rda

#1
07/27/2010 (3:21 pm)
Here is the answer to the question above. There is a define in platformNet.h that looks like:

#ifndef MAXPACKETSIZE
#define MAXPACKETSIZE 1500
#endif

There is also a constant defined in pathCamera that looks like:

enum Constants {
NodeWindow = 128 // Maximum number of active nodes
};

These 2 values are incompatible as each node comprises 40 bytes of data and when all of the node data is send in packUpdate for a path that contains a large number of nodes, it exceeds the size of the buffer triggering an assert.

My fix is to make the max number of nodes dependent on the MAXPACKETSIZE and it looks like:


in PlatformNet.h:

#ifndef MAXPACKETSIZE
#define MAXPACKETSIZE 2125 // my choice for the size (default was 1500)
#endif

in pathManager.h add:

#define PATH_PACKET_SIZE 40 // number of bytes in a path node packet


in pathCamera.h

enum Constants {
NodeWindow = MAXPACKETSIZE/PATH_PACKET_SIZE // Maximum number of active nodes
};

#2
07/28/2010 (2:26 pm)
I thought that packets that exceeded the max packet size were broken up and sent in multiple packets.
#3
07/28/2010 (5:53 pm)
I think that I read somewhere that splitting packets doesn't happen because Torque has no system for putting them back together again at the other end.

So rather than exceeding size, it just creates lag as the packets queue up.