Sync for properties ?


photo

Recommended Posts

Hello,

I added some custom node properties on an Node that are then read by world expressions to drive some effects (rotor wash particles, rotor speed, smoke and wind interaction).

So basically my setup is:

- in worldlogic.cpp, catch CIGI message for the effect and call script.usc function

- this script fct then changes a specific node property

- a world expression reads the node properties and drives the effects

This setup provides to me maximum flexibility because I can tune the world expression in the editor, and I can keep the effect logic out of the world script/cpp. And the world expression can be embedded with its effect in a NodeReference, so it's self-contained.

But the slaves are not updated! So I must be missing something here. Can the node property be replicated? Is it a correct way to do things?

Thank you.

 

Link to post

Hi, Amerio!

But the slaves are not updated!
If you use WorldExpressions for transformation of the nodes (or change "enabled" flags, or for changing parameters of the particles) then you just need to:
1) Call MasterInterface::addSyncNode(const NodePtr &node) once for all dynamically changing objects in these groups.
2) Disable WorldExpressions on slave machines to avoid conflicts in logic between Expression and Syncker.
It seems to me that all this can be done even in the WorldExpression itself.
For example:

#ifdef HAS_SYNCKER
Node node = getNode();
if (!node.hasVariable())
{
	if (engine.syncker.isMasterInitialized())
	{
		MasterInterface master = engine.syncker.getMaster();
		
		// add nodes to Syncker
		master.addSyncNode(<node1>);
		master.addSyncNode(<node2>);
		master.addSyncNode(<node3>);
		master.addSyncNode(<node4>);
		// ...
	}
	else if (engine.syncker.isSlaveInitialized())
	{
		// disable all logic of this WorldExpression
		node.setEnabled(0);
	}
	
	// this block of code need to call once!
	// the simplest way is using unnamed variable
	node.setVariable(1);
}
#endif


Can the node property be replicated?
Unfortunately, no. But, you can write your own parser of UDP User messages. Look at this:
On Master:
SynckerInterface::addCallback(MasterInterface::UDP_USER_SEND, MakeCallback(function_for_sending_property_parameters));
void function_for_sending_property_parameters(BlobPtr &message_to_send)  { ... }

On Slave:
SynckerInterface::addCallback(SlaveInterface::UDP_USER_RECEIVE, MakeCallback(function_for_receiving_property_parameters));
void function_for_receiving_property_parameters(BlobPtr &received_message)  { ... }

It looks a bit more complicated in development (compared with the code above), but this way a more flexible, fast and takes less memory.

Is it a correct way to do things?
I think, yes. Why not.
 

Best regards,
Alexander

  • Like 1
Link to post