MCPcopy Create free account
hub / github.com/defold/defold / MulPerElem

Function MulPerElem

engine/script/src/script_vmath.cpp:2362–2390  ·  view source on GitHub ↗

performs an element wise multiplication of two vectors * * Performs an element wise multiplication between two vectors of the same type * The returned value is a vector defined as (e.g. for a vector3): * * v = vmath.mul_per_elem(a, b) = vmath.vector3(a.x * b.x, a.y * b.y, a.z * b.z) * * @name vmath.mul_per_elem * @param v1 [type:vector3|vector4]

Source from the content-addressed store, hash-verified

2360 * ```
2361 */
2362 static int MulPerElem(lua_State* L)
2363 {
2364 void* argument1 = 0;
2365 void* argument2 = 0;
2366 const ScriptUserType type1 = CheckUserData(L, 1, &argument1);
2367 const ScriptUserType type2 = CheckUserData(L, 2, &argument2);
2368
2369 if (type1 != type2)
2370 {
2371 return luaL_error(L, "%s.%s Arguments needs to be of same type!", SCRIPT_LIB_NAME, "mul_per_elem");
2372 }
2373 if (type1 == SCRIPT_TYPE_VECTOR3)
2374 {
2375 Vector3* v1 = (Vector3*)argument1;
2376 Vector3* v2 = (Vector3*)argument2;
2377 PushVector3(L, dmVMath::MulPerElem(*v1, *v2));
2378 }
2379 else if (type1 == SCRIPT_TYPE_VECTOR4)
2380 {
2381 Vector4* v1 = (Vector4*)argument1;
2382 Vector4* v2 = (Vector4*)argument2;
2383 PushVector4(L, dmVMath::MulPerElem(*v1, *v2));
2384 }
2385 else
2386 {
2387 return luaL_error(L, "%s.%s accepts (%s|%s) as arguments.", SCRIPT_LIB_NAME, "mul_per_elem", SCRIPT_TYPE_NAME_VECTOR3, SCRIPT_TYPE_NAME_VECTOR4);
2388 }
2389 return 1;
2390 }
2391
2392 /*# creates a new quaternion from matrix4
2393 *

Callers 1

Calls 4

CheckUserDataFunction · 0.85
luaL_errorFunction · 0.85
PushVector3Function · 0.85
PushVector4Function · 0.85

Tested by

no test coverage detected