Effector plugin is only executing in deformation mode
-
hi there , i'm trying to make an effector plugin but the effector implementation only runs in deformer mode , i checked the DropEffectorplugin provided in the sdk, but for some reason "ModifyPoints" is only executing in deformer mode, and also the "InitPoints" is not executing when using the effector with mograph (matrix , cloner ...), here are the functions i'm overriding:
class MyEffector : public EffectorData { virtual Bool InitEffector(GeListNode* node); virtual Bool Message(GeListNode* node, Int32 type, void* t_data); virtual Bool GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags); virtual Bool GetDEnabling(GeListNode* node, const DescID& id, const GeData& t_data, DESCFLAGS_ENABLE flags, const BaseContainer* itemdesc); virtual void InitPoints(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, MoData* md, BaseThread* thread); void ModifyPoints(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, MoData* md, BaseThread* thread); static NodeData* Alloc() { return NewObjClear(MyEffector ); }; }
-
Hello @aghiad322,
Thank you for reaching out to us. This is not a general talk topic, this is clearly related to the Cinema 4D SDK. I have moved your topic, due to that you are also missing tag information such as language, OS, and SDK version. I removed the
Plugin-Information
tag and addedC++
, you would have to add the rest.About your Question
The easiest way to answer your question is by starting out with the fact that I just tested the drop effector example in both in
2024.2.0
and the current beta, and it works fine:You showing us just your declarations alone does not help that much here.
You are overwriting the correct methods to implement a Mograph particle modifier, the 'effector'-part of an effector. I would in fact recommend removing
::Message
,::GetDEnabling
, and::GetDDescription
while you have troubles to remove sources of extra problems. If I understand you correctly, this part here in your plugin works, where the effector behaves like a deformer:
But the Mograph particle modification aspect, the 'effector', does not? Without seeing your actual code, the definitions, and your resource files/GUI, it will be impossible to answer your question. Please make sure that your code is executable/compileable, it does not help us when get some fragments where we then have to invent the rest ourself. It is often best to share a project or - if you want to - even a whole solution.
Cheers,
FerdinandPS: I also noticed that you do not implement
NodeData::GetAccessedObjects
while our most recentdropeffector.cpp
does. This is fine when you are pre2024
and fine to a certain degree when you are on2024
as this method only has severe performance implications but no functional ones. So, it is fine to omit it to 'get something going'. But when you are on 2024, you should use our latest code example in case you have not, and the ignore::GetAccessedObjects
if you want to, as these code examples do change over time. -
-
@ferdinand exactly it works fine as a deformer like the second image you provided, i also tested in in 2024.1 it's not working as well, but after some experimenting i ran into weird behaviour , so for the matrix it only works if i put the effector as a child of the matrix and in points deformer mode . and if i added the effector to the effector list of the matrix without being a child of the matrix it wont work, i didn't provide method's definition because they aren't being executed in the first place (when set break point in debug mode it wont be reached), here is a screen recording of it
-
Hello @aghiad322,
You showing us the video of your problem is nice as a bonus, but we still need your code. We cannot and will not help you otherwise. Please follow the instructions lined out above and in our Support Procedures.
Please make sure that your code is executable/compileable, it does not help us when get some fragments where we then have to invent the rest ourself. It is often best to share a project or - if you want to - even a whole solution.
Cheers,
Ferdinand -
@ferdinand i managed to figure out that it's caused by the "Message()" function , if i uncomment the "Message" definition and declaration the problem comes back again even if i left the Message definition blank, here is the compilable code , c4d 26
Effector.zip -
Hello @aghiad322,
Good to hear that you found the culprit yourself. As pointed out in my first posting, it is often a good idea to disable all unnecessary methods in
NodeData
plugins such asMessage
,GetDDescription
,GetDenabling
orGet/SetDParamater
when you run into troubles.I have not built and run your code, but the likely reason for why you run into troubles is because your
NodeData::Message
consumes all messages it receives; the two messages you handle seem to do nothing dangerous. But when you return just flat outtrue
at the end of the method, your node will consume all messages it receives. Our code examples are unfortunately often a bad example when it comes to this and sometimes do it too, as you can get away in 'simple cases' with this bad behavior.To fix this issue, you would simply have to call the base implementation of
EffectorData::Message
as the default return value. You can find an example for this pattern in objectdata_loftedmesh.cpp for example. First you must invoke this macro in your class declaration:class EchoMotion : public EffectorData { INSTANCEOF(EchoMotion, EffectorData) // ... }
Then you would call the base implementation like this. You could also do it manually without the macro, but it makes things a bit nicer:
Bool EchoMotion::Message(GeListNode* node, Int32 type, void* t_data) { switch (type) { // ... } // This line will consume all messages you do not handle in this method. I.e., when there is a // message implementation in one of the bases NodeData::, ObjectData::, or EffectorData::Message, // you will cut off your plugin from it. // return true // It is therefore important to call in methods like NodeData::Message, ::GetDDescription, or // ::GetAccessedObjects the base method. You can always do it, but in certain cases it does not // make too much sense, as for example all the node execution methods such as ObjetctData:: // GetVirtualObjects, TagData::Execute, or EffectorData::ModifyPoints. return SUPER::Message(node, type, data); }
As I said, I have not run your code, but this is very likely what caused your problems because Mograph is notorious for spamming everything and everyone with messages, and you severing your plugin from that will certainly break things.
Cheers,
Ferdinand -
@ferdinand Thanks a lot it worked