-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparamcpu.cpp
More file actions
63 lines (59 loc) · 1.85 KB
/
paramcpu.cpp
File metadata and controls
63 lines (59 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "paramcpu.h"
#include "nodecpu.h"
#include "objectmanager.h"
ParamCPU::ParamCPU(ObjectManager* objectManager, SDNodeType type, NodeCPU* node) : objectManager(objectManager), type(type), node(node) {
gpuParamIndex = objectManager->paramData.pushDefaultParamData(type);
initInputFields();
}
void ParamCPU::initInputFields() {
void* data = objectManager->paramData.getParamData(type, gpuParamIndex);
switch (type) {
case PRIM_SPHERE: {
Sphere* sphere = (Sphere*)data;
inputFields.push_back(InputField("Radius", InputField::FLOAT, &sphere->r));
break;
}
case PRIM_BOX: {
Box* box = (Box*)data;
inputFields.push_back(InputField("Dimensions", InputField::VEC3, &box->dim));
break;
}
case OP_SMIN: {
SMin* smin = (SMin*)data;
inputFields.push_back(InputField("Smoothness", InputField::FLOAT, &smin->smoothness));
break;
}
case OP_SMAX: {
SMax* smax = (SMax*)data;
inputFields.push_back(InputField("Smoothness", InputField::FLOAT, &smax->smoothness));
break;
}
case SPOP_TWIST: {
Twist* twist = (Twist*)data;
inputFields.push_back(InputField("Intensity", InputField::FLOAT, &twist->intensity));
break;
}
case SPOP_REPEAT: {
Repeat* repeat = (Repeat*)data;
inputFields.push_back(InputField("Grid Cell Size", InputField::VEC3, &repeat->repDim));
inputFields.push_back(InputField("Repetition Count", InputField::VEC3, &repeat->repCount));
break;
}
case SPOP_PINCH: {
Pinch* pinch = (Pinch*)data;
inputFields.push_back(InputField("Intensity", InputField::FLOAT, &pinch->intensity));
break;
}
}
}
void ParamCPU::updateParams() {
objectManager->paramData.updateParamDataOnGPU(type, gpuParamIndex);
node->onUpdateParam();
}
void* ParamCPU::getParameter(const string& name) {
for (const InputField& field : inputFields) {
if (field.name == name)
return field.data;
}
return nullptr;
}