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

Function lib_common_mat_operator_array_get

src/CommonLibrary.cpp:736–763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

734 return bv_variable_create_void();
735 }
736 bv_variable lib_common_mat_operator_array_get(bv_program* prog, bv_object* me, u8 count, bv_variable* args)
737 {
738 bv_variable ret = bv_variable_create_void();
739 sd::Matrix* myData = (sd::Matrix*)me->user_data;
740
741 if (count == 1) {
742 int index = 0;
743
744 if (bv_type_is_integer(args[0].type))
745 index = bv_variable_get_int(args[0]);
746 else if (args[0].type == bv_type_float)
747 index = bv_variable_get_float(args[0]);
748
749 // TODO: how should we handle array index out of bounds?
750 if (index >= me->type->props.name_count)
751 index = me->type->props.name_count - 1;
752 if (index < 0)
753 index = 0;
754
755 ret = create_vec(prog, myData->Type, myData->Rows);
756
757 bv_object* retObj = bv_variable_get_object(ret);
758 for (u16 i = 0; i < retObj->type->props.name_count; i++)
759 retObj->prop[i] = bv_variable_cast(myData->Type, bv_variable_create_float(myData->Data[index][i]));
760 }
761
762 return ret;
763 }
764 bv_variable lib_common_mat_operator_array_set(bv_program* prog, bv_object* me, u8 count, bv_variable* args)
765 {
766 u8 argCount = count;

Callers

nothing calls this directly

Calls 1

create_vecFunction · 0.85

Tested by

no test coverage detected