#include <c4d_baselist.h>
The
VariableChanged
structure is essential for changing point/polygon counts in objects to allocate or remove multiple elements with a single
C4DAtom::Message()
call.
It can be used for example when sending
MSG_POINTS_CHANGED
and
MSG_POLYGONS_CHANGED
messages to objects, tags and keys.
The structure contains the number of elements (points or polygons) before and after the change, and optionally a translation map array.
Each element in the map represents an element before the change, and its value decides what element this corresponds to after the change. This is used to keep for example point selections and vertex maps valid.
范例: Adding a point to a point object.
VariableChanged vc;// Just for adding a point at the end of the point list a map is not needed
// Send the message to all tags and keys and let them return a boolean, telling us if everything is alright if (op->Message( MSG_POINTS_CHANGED , &vc)) { // Now all tags and structures have reacted and resized their memory part, so the new point can be accessed 向量 * points = op->GetPointW(); if (points) points[count] = 向量 (0, 0, 0); // Set data for the new point op->Message( MSG_UPDATE ); // Notify change to the object EventAdd (); }
范例: Inserting a point in a point object.
VariableChanged vc; Int32 count = op->GetPointCount(); // Get actual point count vc. old_cnt = count; vc. new_cnt = count+1; // Resize point count from count to count+1// Allocate a map vc. map = NewMemClear ( Int32 , count); if (vc. map != nullptr ) { Int32 i, pos = 5; // pos is the index to insert the point at
// The points below pos stay at the same point number for (i = 0; i <= pos; i++) vc. map [i] = i;
// The points above pos are shifted 1 step for (i = pos+1; i < count; i++) vc. map [i] = i+1;
// Send the message to all tags and keys and let them return a boolean, telling us if everything is alright if (op->Message( MSG_POINTS_CHANGED , &vc)) { // Now all tags and structures have reacted and resized their memory part, so the new point can be accessed 向量 * points= op->GetPointW(); if (points) points[pos] = 向量 (0, 0, 0); // Set data for the new point op->Message( MSG_UPDATE ); // Notify change to the object EventAdd (); } DeleteMem (vc. map ); }
公共成员函数 |
|
VariableChanged () |
Public Attributes |
|
Int32 | old_cnt |
Int32 | new_cnt |
Int32 * | map |
Int32 | vc_flags |
VariableChanged | ( | ) |
Default constructor.
Int32 old_cnt |
The number of elements before the change.
Int32 new_cnt |
The new number of elements.
Int32 * map |
The optional translation map.
Int32 vc_flags |
Flags: VC_FLAGS