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

Function lib_common_abs

src/CommonLibrary.cpp:1098–1137  ·  view source on GitHub ↗

mathematics */

Source from the content-addressed store, hash-verified

1096
1097 /* mathematics */
1098 bv_variable lib_common_abs(bv_program* prog, u8 count, bv_variable* args)
1099 {
1100 /* abs(genType), abs(genIType) */
1101 if (count == 1) {
1102 if (args[0].type == bv_type_object) {
1103 bv_object* vec = bv_variable_get_object(args[0]);
1104
1105 // abs(vec)
1106 if (vec->prop[0].type == bv_type_float) {
1107 glm::vec4 vecData = glm::abs(sd::AsVector<4, float>(args[0]));
1108
1109 bv_variable ret = Common::create_vec(prog, bv_type_float, vec->type->props.name_count);
1110 bv_object* retObj = bv_variable_get_object(ret);
1111
1112 for (u16 i = 0; i < retObj->type->props.name_count; i++)
1113 retObj->prop[i] = bv_variable_create_float(vecData[i]);
1114
1115 return ret;
1116 }
1117 // abs(ivec)
1118 else if (vec->prop[0].type == bv_type_int) {
1119 glm::ivec4 vecData = glm::abs(sd::AsVector<4, int>(args[0])); // acos takes only float vectors
1120
1121 bv_variable ret = Common::create_vec(prog, bv_type_int, vec->type->props.name_count);
1122 bv_object* retObj = bv_variable_get_object(ret);
1123
1124 for (u16 i = 0; i < retObj->type->props.name_count; i++)
1125 retObj->prop[i] = bv_variable_create_int(vecData[i]);
1126
1127 return ret;
1128 }
1129 }
1130 else if (args[0].type == bv_type_float)
1131 return bv_variable_create_float(glm::abs(bv_variable_get_float(args[0])));
1132 else
1133 return bv_variable_create_int(glm::abs(bv_variable_get_int(args[0])));
1134 }
1135
1136 return bv_variable_create_int(0);
1137 }
1138 bv_variable lib_common_ceil(bv_program* prog, u8 count, bv_variable* args)
1139 {
1140 /* ceil(genType) */

Callers

nothing calls this directly

Calls 1

create_vecFunction · 0.85

Tested by

no test coverage detected