calling CustomDataTypeClass::Calculate() [SOLVED]
-
On 27/07/2016 at 03:40, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R17
Platform:
Language(s) : C++ ;---------
Hi! I'm trying to interpolate between two GeData values. But when I call CustomDataTypeClass::Calculate(),
it always gives me GV_CALC_ERR_UNDEFINED . Does someone know what I'm doing wrong?Thanks a lot in advance,
-Niklas
GeData InterpolateValues(GeData const& left, GeData const& right, BaseList2D* node, Float w) { Int32 const type = left.GetType(); if (type != right.GetType()) return left; // Load the CustomDataTypeClass plugin for this datatype. CUSTOMDATATYPEPLUGIN* plug = FindCustomDataTypePlugin(left.GetType()); if (!plug) return left; auto data = static_cast<CustomDataTypeClass*>(plug->adr); if (!data) return left; GeData res = left; GvError err = (data->*plug->Calculate)( GV_CALC_MIX, left.GetCustomDataType(type), right.GetCustomDataType(type), res.GetCustomDataType(type), w); if (err != GV_IO_ERR_NONE) { // Always gets here with err == GV_CALC_ERR_UNDEFINED GePrint("Oh Noes! " + String::IntToString(err)); } return res; }
// Calling example GeData l(10); GeData r(50); GeData res = InterpolateValues(l, r, nullptr, 0.5); Int32 val = res.GetInt32();
-
On 28/07/2016 at 08:22, xxxxxxxx wrote:
Hi Niklas,
I'm terribly sorry, I haven't found as much time to investigate it, as I had planned and wished.
Just wanted to let you know, I'm on it.
What I found so far: Your Calculate() call ends up in the "base implementation" of that function, which does nothing more than returning GV_CALC_ERR_UNDEFINED. So actually under the given circumstances, the result is actually correct
I'll continue with this tomorrow. -
On 29/07/2016 at 08:58, xxxxxxxx wrote:
Hi Niklas,
the reason is quite simple: Only very few custom data types implement Calculate(). From the public ones, SplineData is actually the only one (and even this implements only GV_CALC_CLR, GV_CALC_ADD and GV_CALC_MIX).
So actually your example is correct, but it works only on data types that implemented Calculate()... SplineData that is. -
On 29/07/2016 at 10:51, xxxxxxxx wrote:
Thank you for your time and effort, Andreas. Originally I didn't expect FindCustomDataTypePlugin()
to actually return not-null for any of the standard datatypes (LONG, REAL, etc.), but since it did, I
expected it to be implemented for these types as well.Anyway, now that I know I just do some special handling for the datatypes that I want to support
proper interpolation for, and eventually use the CustomDataTypePlugin for any ID that I don't know
or don't handle.Thanks again!
Niklas