Filling vertex_color for SceneHook



  • Since...

    cds.vertex_color = GeAllocTypeNC(SVector,pcnt);

    Doesn't seems to be valid anymore for R20, I was trying to use:

    Vector32* color_lst = NewMemClear(Vector32, pcnt);

    But I'm getting and error:

    No viable conversion from 'maxon::ResultPtr<Vector32>' (aka 'maxon::ResultMemT<maxon::Vec3<float, 1> *>') to 'Vector32 *' (aka 'Vec3<float, 1> *')

    So, how can we fill the vertex_color list, now?


  • Global Moderator

    Hi,

    GeAllocTypeNC() was already removed from the API with version R15 (see API Change List in R15 and maybe more interesting for you Transition to Cinema 4D R15 API).

    You are already on the right track using NewMem(), now in R20, there's an additional change, which bites you here: The error handling.

    This indeed is quite an important topic and (of course no bragging involved at all) a really nice feature in the new MAXON API. But it's also the one thing that causes most needed changes for R20. The point is, here at MAXON we do not take error checking lightly. Actually quite the opposite, we enforce error handling where ever we can and our internal developers have no chance to get away without.

    So, before I provide the solution, here the recommendation to take the time to read the manuals about the Error System.
    Additionally I recommend the manuals about classic API Entity Creation and Destruction and its MAXON API sibling about Memory Allocation. The additional means you get provided with in the new MAXON API can really make your life easier.

    I apologize for writing so much before coming to your actual issue.

    In the end NewMemClear() now returns an Error Result, which basically encapsulates the actual return value and needs to be evaluated in order to get the actual return value. No worries, this is done in a highly optimized form, so it should not impede your code's performance in any way.
    If you take a look at our SDK examples, you will find quite a few places, where error handling in conjunction with NewMem is demonstrated in various ways.

    Cheers,
    Andreas