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

Function lib_common_modf

src/CommonLibrary.cpp:1965–2008  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1963 return bv_variable_create_float(0.0f);
1964 }
1965 bv_variable lib_common_modf(bv_program* prog, u8 count, bv_variable* args)
1966 {
1967 /* modf(genType, out genType), modf(float, out float), also for genDType */
1968 if (count == 2) {
1969 if (args[0].type == bv_type_object) {
1970 bv_object* vec = bv_variable_get_object(args[0]);
1971
1972 // using: genType, float, genDType, double
1973 glm::vec4 x = sd::AsVector<4, float>(args[0]);
1974 glm::vec4 retData(0.0f), outValData(0.0f);
1975
1976 retData = glm::modf(x, outValData);
1977
1978 // param out value
1979 bv_variable* outPtr = bv_variable_get_pointer(args[1]);
1980 bv_object* outObj = bv_variable_get_object(*outPtr);
1981 for (u16 i = 0; i < outObj->type->props.name_count; i++)
1982 outObj->prop[i] = bv_variable_create_float(outValData[i]);
1983
1984 // return value
1985 bv_variable ret = Common::create_vec(prog, bv_type_float, vec->type->props.name_count);
1986 bv_object* retObj = bv_variable_get_object(ret);
1987 for (u16 i = 0; i < retObj->type->props.name_count; i++)
1988 retObj->prop[i] = bv_variable_create_float(retData[i]);
1989
1990 return ret;
1991 }
1992
1993 // modf(float, float)
1994 else {
1995 float x = bv_variable_get_float(bv_variable_cast(bv_type_float, args[0]));
1996 float outVal = 0.0f;
1997
1998 float retVal = glm::modf(x, outVal);
1999
2000 bv_variable* outPtr = bv_variable_get_pointer(args[1]);
2001 bv_variable_set_float(outPtr, outVal);
2002
2003 return bv_variable_create_float(retVal);
2004 }
2005 }
2006
2007 return bv_variable_create_float(0.0f);
2008 }
2009 bv_variable lib_common_pow(bv_program* prog, u8 count, bv_variable* args)
2010 {
2011 /* pow(genType y, genType x) */

Callers

nothing calls this directly

Calls 1

create_vecFunction · 0.85

Tested by

no test coverage detected