| 2101 | return bv_variable_create_int(0); |
| 2102 | } |
| 2103 | bv_variable lib_common_smoothstep(bv_program* prog, u8 count, bv_variable* args) |
| 2104 | { |
| 2105 | /* mix(genType, genType, genType), mix(float, float, genType) also for genDType */ |
| 2106 | if (count == 3) { |
| 2107 | if (args[0].type == bv_type_object) { |
| 2108 | bv_object* vec = bv_variable_get_object(args[0]); |
| 2109 | |
| 2110 | // using: genType, float, genDType, double, genBType |
| 2111 | glm::vec4 edge0 = sd::AsVector<4, float>(args[0]); |
| 2112 | glm::vec4 edge1 = sd::AsVector<4, float>(args[1]); |
| 2113 | glm::vec4 x(0.0f); |
| 2114 | |
| 2115 | // get a |
| 2116 | if (args[2].type == bv_type_object) |
| 2117 | x = sd::AsVector<4, float>(args[2]); |
| 2118 | else |
| 2119 | x = glm::vec4(bv_variable_get_float(bv_variable_cast(bv_type_float, args[2]))); |
| 2120 | |
| 2121 | |
| 2122 | glm::vec4 vecData(0.0f); |
| 2123 | |
| 2124 | u8 vecSize = vec->type->props.name_count; |
| 2125 | |
| 2126 | if (vecSize == 2) { |
| 2127 | glm::vec2 res = glm::smoothstep(glm::vec2(edge0.x, edge0.y), glm::vec2(edge1.x, edge1.y), glm::vec2(x.x, x.y)); |
| 2128 | vecData.x = res.x; vecData.y = res.y; |
| 2129 | } |
| 2130 | else if (vecSize == 3) { |
| 2131 | glm::vec3 res = glm::smoothstep(glm::vec3(edge0.x, edge0.y, edge0.z), glm::vec3(edge1.x, edge1.y, edge1.z), glm::vec3(x.x, x.y, x.z)); |
| 2132 | vecData.x = res.x; vecData.y = res.y; vecData.z = res.z; |
| 2133 | } |
| 2134 | else if (vecSize == 4) |
| 2135 | vecData = glm::smoothstep(edge0, edge1, x); |
| 2136 | |
| 2137 | bv_variable ret = Common::create_vec(prog, bv_type_float, vecSize); |
| 2138 | bv_object* retObj = bv_variable_get_object(ret); |
| 2139 | |
| 2140 | for (u16 i = 0; i < retObj->type->props.name_count; i++) |
| 2141 | retObj->prop[i] = bv_variable_create_float(vecData[i]); |
| 2142 | |
| 2143 | return ret; |
| 2144 | } |
| 2145 | |
| 2146 | // smoothstep(float, float, genType) |
| 2147 | else { |
| 2148 | float edge0 = bv_variable_get_float(bv_variable_cast(bv_type_float, args[0])); |
| 2149 | float edge1 = bv_variable_get_float(bv_variable_cast(bv_type_float, args[1])); |
| 2150 | |
| 2151 | |
| 2152 | // get x |
| 2153 | if (args[2].type == bv_type_object) { |
| 2154 | glm::vec4 x = sd::AsVector<4, float>(args[2]); |
| 2155 | |
| 2156 | bv_object* vec = bv_variable_get_object(args[2]); |
| 2157 | |
| 2158 | glm::vec4 vecData(0.0f); |
| 2159 | |
| 2160 | u8 vecSize = vec->type->props.name_count; |
nothing calls this directly
no test coverage detected