MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getFieldComponent

Function getFieldComponent

Engine/source/console/compiledEval.cpp:168–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168static void getFieldComponent(SimObject* object, StringTableEntry field, const char* array, StringTableEntry subField, char val[], S32 currentLocalRegister)
169{
170 const char* prevVal = NULL;
171
172 if (object && field)
173 prevVal = object->getDataField(field, array);
174 else if (currentLocalRegister != -1)
175 prevVal = gEvalState.getLocalStringVariable(currentLocalRegister);
176 else if (gEvalState.currentVariable)
177 prevVal = gEvalState.getStringVariable();
178
179 // Make sure we got a value.
180 if (prevVal && *prevVal)
181 {
182 static const StringTableEntry xyzw[] =
183 {
184 StringTable->insert("x"),
185 StringTable->insert("y"),
186 StringTable->insert("z"),
187 StringTable->insert("w")
188 };
189
190 static const StringTableEntry rgba[] =
191 {
192 StringTable->insert("r"),
193 StringTable->insert("g"),
194 StringTable->insert("b"),
195 StringTable->insert("a")
196 };
197
198 // Translate xyzw and rgba into the indexed component
199 // of the variable or field.
200 if (subField == xyzw[0] || subField == rgba[0])
201 dStrcpy(val, StringUnit::getUnit(prevVal, 0, " \t\n"), 128);
202
203 else if (subField == xyzw[1] || subField == rgba[1])
204 dStrcpy(val, StringUnit::getUnit(prevVal, 1, " \t\n"), 128);
205
206 else if (subField == xyzw[2] || subField == rgba[2])
207 dStrcpy(val, StringUnit::getUnit(prevVal, 2, " \t\n"), 128);
208
209 else if (subField == xyzw[3] || subField == rgba[3])
210 dStrcpy(val, StringUnit::getUnit(prevVal, 3, " \t\n"), 128);
211
212 else
213 val[0] = 0;
214 }
215 else
216 val[0] = 0;
217}
218
219static void setFieldComponent(SimObject* object, StringTableEntry field, const char* array, StringTableEntry subField, S32 currentLocalRegister)
220{

Callers 1

execMethod · 0.85

Calls 6

dStrcpyFunction · 0.85
getUnitFunction · 0.85
getDataFieldMethod · 0.80
getStringVariableMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected