| 871 | return bv_variable_create_float(0.0f); // asin() must have 1 argument! |
| 872 | } |
| 873 | bv_variable lib_common_atan(bv_program* prog, u8 count, bv_variable* args) |
| 874 | { |
| 875 | /* atan(genType y_over_x) */ |
| 876 | if (count == 1) { |
| 877 | if (args[0].type == bv_type_object) { // atan(vec3), ... |
| 878 | bv_object* vec = bv_variable_get_object(args[0]); |
| 879 | glm::vec4 vecData = glm::atan(sd::AsVector<4, float>(args[0])); |
| 880 | |
| 881 | bv_variable ret = Common::create_vec(prog, bv_type_float, vec->type->props.name_count); |
| 882 | bv_object* retObj = bv_variable_get_object(ret); |
| 883 | |
| 884 | for (u16 i = 0; i < retObj->type->props.name_count; i++) |
| 885 | retObj->prop[i] = bv_variable_create_float(vecData[i]); |
| 886 | |
| 887 | return ret; |
| 888 | } |
| 889 | else |
| 890 | return bv_variable_create_float(glm::atan(bv_variable_get_float(args[0]))); |
| 891 | } |
| 892 | /* atan2(genType y, genType x) */ |
| 893 | else if (count == 2) { |
| 894 | if (args[0].type == bv_type_object) { // atan(vec3), ... |
| 895 | bv_object* y = bv_variable_get_object(args[0]); |
| 896 | glm::vec4 yData = sd::AsVector<4, float>(args[0]); |
| 897 | |
| 898 | bv_object* x = bv_variable_get_object(args[1]); |
| 899 | glm::vec4 xData = sd::AsVector<4, float>(args[1]); |
| 900 | |
| 901 | bv_variable ret = Common::create_vec(prog, bv_type_float, y->type->props.name_count); |
| 902 | bv_object* retObj = bv_variable_get_object(ret); |
| 903 | |
| 904 | for (u16 i = 0; i < retObj->type->props.name_count; i++) |
| 905 | retObj->prop[i] = bv_variable_create_float(glm::atan(yData[i], xData[i])); |
| 906 | |
| 907 | return ret; |
| 908 | } |
| 909 | else |
| 910 | return bv_variable_create_float( |
| 911 | glm::atan( |
| 912 | bv_variable_get_float(bv_variable_cast(bv_type_float, args[0])), |
| 913 | bv_variable_get_float(bv_variable_cast(bv_type_float, args[1])) |
| 914 | ) |
| 915 | ); |
| 916 | } |
| 917 | |
| 918 | return bv_variable_create_float(0.0f); |
| 919 | } |
| 920 | bv_variable lib_common_cos(bv_program* prog, u8 count, bv_variable* args) |
| 921 | { |
| 922 | /* cos(genType) */ |
nothing calls this directly
no test coverage detected