VariableChanged Struct Reference

#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;
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

// 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()

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.

注意
A map element can be NOTOK .

◆  vc_flags

Int32 vc_flags

Flags: VC_FLAGS

VariableChanged::map
Int32 * map
定义: c4d_baselist.h:675
NewMemClear
#define NewMemClear(T, cnt)
定义: defaultallocator.h:205
VariableChanged
定义: c4d_baselist.h:666
MSG_POINTS_CHANGED
#define MSG_POINTS_CHANGED
The points have changed. The corresponding data is VariableChanged.
定义: c4d_baselist.h:338
VariableChanged::new_cnt
Int32 new_cnt
The new number of elements.
定义: c4d_baselist.h:674
MSG_UPDATE
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
定义: c4d_baselist.h:340
maxon::Vec3< maxon::Float64, 1 >
maxon::DeleteMem
void DeleteMem(T *&p)
定义: defaultallocator.h:258
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
VariableChanged::old_cnt
Int32 old_cnt
The number of elements before the change.
定义: c4d_baselist.h:673
向量
maxon::Vec3< maxon::Float64, 1 > Vector
定义: ge_math.h:145
EventAdd
void EventAdd(EVENT eventflag=EVENT::NONE)