MCPcopy Create free account
hub / github.com/dfranx/ShaderDebugger / lib_common_vec_constructor

Function lib_common_vec_constructor

src/CommonLibrary.cpp:316–352  ·  view source on GitHub ↗

vectors and operators */

Source from the content-addressed store, hash-verified

314
315 /* vectors and operators */
316 bv_variable lib_common_vec_constructor(bv_program* prog, bv_object* me, u8 count, bv_variable* args)
317 {
318 bv_type type = sd::GetVectorTypeFromName(me->type->name);
319 u8 size = me->type->props.name_count;
320
321 u8 propSet = 0;
322 for (u8 i = 0; i < count; i++) {
323 bv_variable* arg = &args[i];
324
325 // vector
326 if (arg->type == bv_type_object) {
327 bv_object* vec = bv_variable_get_object(*arg);
328
329 for (u16 i = 0; i < vec->type->props.name_count; i++) {
330 me->prop[propSet] = bv_variable_cast(type, vec->prop[i]);
331 propSet++;
332 }
333 }
334 // scalar
335 else {
336 me->prop[propSet] = bv_variable_cast(type, *arg);
337 propSet++;
338 }
339 }
340
341 // set all other members
342 if (propSet == 0 || (propSet != size)) {
343 bv_variable val = bv_variable_create_float(0.0f);
344 if (propSet != size && propSet != 0)
345 val = me->prop[0];
346
347 for (u8 i = propSet; i < size; i++)
348 me->prop[i] = bv_variable_cast(type, val);
349 }
350
351 return bv_variable_create_void();
352 }
353 bv_variable lib_common_vec_operator_equal(bv_program* prog, bv_object* me, u8 count, bv_variable* args)
354 {
355 bv_variable ret = bv_variable_create_uchar(0);

Callers

nothing calls this directly

Calls 1

GetVectorTypeFromNameFunction · 0.85

Tested by

no test coverage detected