Request: CIGI callback before sending a message to Host


Recommended Posts


We have a specific requirement that we can't fulfill at the moment. In some case, our Host expect some IG responses messages to have additional data put in a custom messages.

To give a specific use case, for some LOS/HAT queries our Host requires the IG to send the velocities of the point of intersection (useful when landing on a moving platform for example). As this is not part of CIGI standard protocol, our legacy IG send these info in additional messages alongside the LOS responses.

I think this could be implemented easily if we had the possibility to add a callback to the CIGIConnector which would be called right before putting a message in the send queue.

As a suggestion, here is a possible prototype

void setSendPacketCallback ( int cigi_opcode, Unigine::CallbackBase * func );

//Prototype of the callback:
//template <class CIGIPACKET> bool sendPacket(int cigi_opcode, CIGIPACKET* packet);
//returns true if the packet should be sent (eventually after being modified).
//returns false if the packet should not be sent (discarded).
//The callback can modify the packet data if necessary, or discard it completely by returning false.
//The callback can append another message in the queue by calling addPacket(). In this case
//the added message will be placed somewhere after the packet in the same emission.
//The added message shouldn't be of the same type of packet (risk of infinite recursion) and cannot be a StartOfFrame.

This could also be used to have the IG self-react on some responses message, eg. for debug purposes.

  • Like 1
Link to post

Hello Stephane,

It's sounds like easy to implementation and more likely you can expect it in the following 2.14 release.

Thanks for the suggestion!

Link to post

Hi, nice to hear it'd be easy to add.

As an additional request, would it be possible to have a callback with the WorldIntersection data (or equivalent) computed during a LOS/HAT/HOT? This would be used because the CIGI response itself may not contain enough data to determine exactly what have been intersected. As an example, The host will send a HOT extended, the IG will send a HOT extended response which doesn't contain the ID or the local coordinate of the intersected entity, which are required to compute the point of contact velocity. Hence, having a callback called with the intersection data computed by the HOT would allow us to prepare the custom message to be sent alongside the HOT response.

Of course, you may have a better suggestion to solve this problem (returning the point of contact velocity) so please advise :)



Link to post

yes, of course, there will be access to intersection.

about contact velocity: any node has getOldWorldTransform method. you can get moment velocity

auto prev_point_world = contact_point_world * inverse(node_world_transform) * old_node_world_transform;
auto point_velocity = (contact_point_world - prev_point_world) / Game::getIFps(); 


  • Like 1
Link to post