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

Function lib_common_vec_operator_array_set

src/CommonLibrary.cpp:564–588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

562 return ret;
563 }
564 bv_variable lib_common_vec_operator_array_set(bv_program* prog, bv_object* me, u8 count, bv_variable* args)
565 {
566 u8 indCount = 0;
567 if (count > 1)
568 indCount = bv_variable_get_int(args[0]);
569
570 if (indCount == 1 && count > 2) {
571 int index = 0;
572
573 if (bv_type_is_integer(args[1].type))
574 index = bv_variable_get_int(args[1]);
575 else if (args[1].type == bv_type_float)
576 index = bv_variable_get_float(args[1]);
577
578 // TODO: how should we handle array index out of bounds?
579 if (index >= me->type->props.name_count)
580 index = me->type->props.name_count - 1;
581 if (index < 0)
582 index = 0;
583
584 me->prop[index] = bv_variable_cast(me->prop[index].type, args[2]);
585 }
586
587 return bv_variable_create_void();
588 }
589
590 /* matrices and operators */
591 bv_variable lib_common_mat_constructor(bv_program* prog, bv_object* me, u8 count, bv_variable* args)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected