Currently there are two ways to store data of variable type. The first one is GeData, the class that is used in most of the SDK for example in BaseContainer. The second one is the void*
data that is used in Graph View. This document describes how the Graph View data type system works.
Note: Types registered with CustomDataTypeClass are automatically included in the Graph View type system as well.
Value vs. Data
The actual format of the data stored in the void*
pointer is determined by its value, described by a GvValueID. This is all you need to know to be able to perform calculations with the data or convert it to other types.
Similar kinds of data can share a common value. The combination of a symbol/name and a value is called a data, described by a GvDataID. For example both the normal and the color data types could be implemented as a vector value.
The different data types are grouped in value groups. However, currently there is only one group, so you can ignore this feature most of the time.
- Note
- FindCustomDataTypePlugin() will always return a valid plugin when fed a GvValueID. You cannot convert a GvValueID to a GvDataID directly, though you can do CallCustomDataType(pl, GetDataID).
Raw Format
For the common built-in types (Int32, Float, Vector, Matrix, BaseTime and String) the void*
pointer simply points to the data type in question. For custom data types it instead points to the GvHelper structure. Please observe that generally these pointers are to an array that you should index with the current CPU ID.
- Note
- Normally you should not need to manipulate these raw values.
Dynamic Data
GvDynamicData is a convenience structure that stores both the void*
data pointer and a GvDataInfo structure with the handlers. There are several ways to get a dynamic data structure:
Many of these functions are implemented in clear code in c4d_graphview.h and c4d_graphview.cpp, so you can see how they work.
Examples
Getting a GeData from a calculated port:
{
if (success)
*success = false;
if (!node || !port)
{
if (pl && CallCustomDataType(pl, ConvertGvToGeData)(data.
data, 0, result))
{
if (success)
*success = true;
}
}
return result;
}
CUSTOMDATATYPEPLUGIN * FindCustomDataTypePlugin(Int32 type)
Definition: c4d_gedata.h:83
Definition: c4d_graphview.h:429
Bool GetPortDescription(GvPortIO port, Int32 id, GvPortDescription *pd)
Definition: c4d_graphview.h:618
Definition: c4d_graphview.h:938
Int32 GetMainID(void)
Definition: c4d_graphview.h:1006
Bool GetData(void *d, GvValueID type, GvRun *r)
Definition: c4d_graphview.h:1177
GvPortIO GetIO(void)
Definition: c4d_graphview.h:994
Contains helper functions for controlling node evaluation. Cannot be instantiated.
Definition: c4d_graphview.h:314
GvDataInfo * GetDataTypeInfo(GvDataID id)
Definition: c4d_graphview.h:2386
maxon::Bool Bool
Definition: ge_sys_math.h:55
Bool GvAllocDynamicData(GvNode *bn, GvDynamicData &data, GvCalc *c, Int32 id)
Definition: c4d_graphview.h:2697
GvWorld * GvGetWorld(void)
void GvFreeDynamicData(GvDynamicData &data)
Definition: c4d_graphview.h:2708
GvDataID data_id
The data ID.
Definition: c4d_graphview_def.h:1014
GvValueID value_id
Value ID.
Definition: c4d_graphview_def.h:858
Definition: c4d_graphview_def.h:1074
GV_VALUE_HANDLER * value_handler
Definition: c4d_graphview_def.h:1076
GV_DATA_HANDLER * data_handler
Definition: c4d_graphview_def.h:1075
Represents a GV data and information about its data type.
Definition: c4d_graphview_def.h:1243
void * data
Data pointer.
Definition: c4d_graphview_def.h:1249
GvDataInfo * info
Data type information.
Definition: c4d_graphview_def.h:1250
Port description data.
Definition: c4d_graphview_def.h:1145
GvDataID data_id
Data type ID: GvDataID.
Definition: c4d_graphview_def.h:1153
Setting the port data from a GeData:
{
if (!node || !port || !run)
return false;
return false;
if (info==nullptr)
return false;
if (pl==nullptr)
return false;
if (!CallCustomDataType(pl, ConvertGeDataToGv)(ge_data, data.
data, 0))
return false;
return false
return true;
}
Bool SetData(const void *d, GvValueID type, GvRun *r)
Definition: c4d_graphview.h:1274
Getting a Thinking Particles particle ID from a port:
{
if (!port || !node || !run)
return NOTOK;
GeData p = GvGetPortGeData(node, port, run);
{
if (!helper || !helper->pid)
return NOTOK;
return *(helper->pid);
}
Setting a Thinking Particles particle ID in a port:
{
if (!port || !node || !run)
return NOTOK;
{
} helper;
helper.pid = &pid;
return GvSetPortGeData(p, node, port, run);
}
#define ID_TP_DATA_TYPE_PARTICLE
Particle data type ID.
Definition: c4d_particles.h:31
Int32 GetType(void) const
Definition: c4d_gedata.h:407
CustomDataType * GetCustomDataType(Int32 datatype) const
Definition: c4d_gedata.h:507
#define NOTOK
Definition: ge_sys_math.h:267
maxon::Int32 Int32
Definition: ge_sys_math.h:60
Base class for custom data types.
Definition: c4d_customdatatype.h:51