VariableChanged Struct Reference

#include <c4d_baselist.h>

Detailed Description

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.

Example: Adding a point to a point object.

Int32 count = op->GetPointCount(); // Get actual point count
vc.new_cnt = count+1; // Resize point count from count to count+1
// 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
Vector* points = op->GetPointW();
if (points)
points[count] = Vector(0, 0, 0); // Set data for the new point
op->Message(MSG_UPDATE); // Notify change to the object
}
Py_ssize_t count
Definition: abstract.h:640
void EventAdd(EVENT eventflag=EVENT::NONE)
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:145
maxon::Int32 Int32
Definition: ge_sys_math.h:60
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
Definition: c4d_baselist.h:358
#define MSG_POINTS_CHANGED
The points have changed. The corresponding data is VariableChanged.
Definition: c4d_baselist.h:356
PyObject * op
Definition: object.h:520
Definition: c4d_baselist.h:706
Int32 old_cnt
The number of elements before the change.
Definition: c4d_baselist.h:712
Int32 new_cnt
The new number of elements.
Definition: c4d_baselist.h:713

Example: Inserting a point in a point object.

Int32 count = op->GetPointCount(); // Get actual point count
vc.new_cnt = count+1; // Resize point count from count to count+1
// Allocate a map
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
Vector* points= op->GetPointW();
if (points)
points[pos] = Vector(0, 0, 0); // Set data for the new point
op->Message(MSG_UPDATE); // Notify change to the object
}
}
Py_ssize_t i
Definition: abstract.h:645
void Py_ssize_t * pos
Definition: dictobject.h:50
for(i=0;i< length;i++)
Definition: unicodeobject.h:61
#define NewMemClear(T, cnt)
Definition: defaultallocator.h:204
void DeleteMem(T *&p)
Definition: defaultallocator.h:257
Int32 * map
Definition: c4d_baselist.h:714

Public Member Functions

 VariableChanged ()
 

Public Attributes

Int32 old_cnt
 
Int32 new_cnt
 
Int32map
 
Int32 vc_flags
 

Constructor & Destructor Documentation

◆ VariableChanged()

Default constructor.

Member Data Documentation

◆ old_cnt

Int32 old_cnt

The number of elements before the change.

◆ new_cnt

Int32 new_cnt

The new number of elements.

◆ map

Int32 * map

The optional translation map.

Note
A map element can be NOTOK.

◆ vc_flags

Int32 vc_flags

Flags: VC_FLAGS