Browse Source

Add grenades to physics sample

Panagiotis Christopoulos Charitos 10 months ago
parent
commit
3f9ecc6350
40 changed files with 790 additions and 434 deletions
  1. 6 6
      AnKi/Importer/GltfImporter.cpp
  2. 6 8
      AnKi/Physics/PhysicsBody.cpp
  3. 4 4
      AnKi/Physics/PhysicsBody.h
  4. 1 1
      AnKi/Physics/PhysicsWorld.cpp
  5. 28 9
      AnKi/Scene/Components/BodyComponent.cpp
  6. 5 2
      AnKi/Scene/Components/BodyComponent.h
  7. 1 1
      AnKi/Scene/Components/ParticleEmitterComponent.cpp
  8. 62 34
      AnKi/Scene/Components/TriggerComponent.cpp
  9. 11 1
      AnKi/Scene/Components/TriggerComponent.h
  10. 48 48
      AnKi/Script/Math.cpp
  11. 12 9
      AnKi/Script/Math.xml
  12. 40 32
      AnKi/Script/Scene.cpp
  13. 2 1
      AnKi/Script/Scene.xml
  14. BIN
      Samples/PhysicsPlayground/Assets/Asphalt_004_COLOR_png.ankitex
  15. BIN
      Samples/PhysicsPlayground/Assets/Asphalt_004_NRM_png.ankitex
  16. BIN
      Samples/PhysicsPlayground/Assets/Asphalt_004_ROUGH_png.ankitex
  17. BIN
      Samples/PhysicsPlayground/Assets/Icosphere_834d64c142beaa13.ankimesh
  18. BIN
      Samples/PhysicsPlayground/Assets/M61_model_M61_grenade_BaseColor.ankitex
  19. BIN
      Samples/PhysicsPlayground/Assets/M61_model_M61_grenade_Metalness-M61_model_M61_grenade_Roughness.ankitex
  20. BIN
      Samples/PhysicsPlayground/Assets/MESH_grenade_818651700502e14b.ankimesh
  21. 8 0
      Samples/PhysicsPlayground/Assets/MESH_grenade_MTL_grenade_85852a78645563d8.ankimdl
  22. 29 0
      Samples/PhysicsPlayground/Assets/MTL_grenade_4346150e31bdb957.ankimtl
  23. 420 254
      Samples/PhysicsPlayground/Assets/Scene.lua
  24. BIN
      Samples/PhysicsPlayground/Assets/Stone_Wall_007_COLOR_png.ankitex
  25. BIN
      Samples/PhysicsPlayground/Assets/Stone_Wall_007_NORM_png.ankitex
  26. BIN
      Samples/PhysicsPlayground/Assets/Stone_Wall_007_ROUGH_png.ankitex
  27. BIN
      Samples/PhysicsPlayground/Assets/Suzanne_e3526e1428c0763c.ankimesh
  28. BIN
      Samples/PhysicsPlayground/Assets/armColor.ankitex
  29. BIN
      Samples/PhysicsPlayground/Assets/armNormal.ankitex
  30. BIN
      Samples/PhysicsPlayground/Assets/armRoughness.ankitex
  31. 29 0
      Samples/PhysicsPlayground/Assets/arms_3a4232ebbd425e7a.ankimtl
  32. BIN
      Samples/PhysicsPlayground/Assets/boomstickColor.ankitex
  33. BIN
      Samples/PhysicsPlayground/Assets/boomstickNormal.ankitex
  34. 29 0
      Samples/PhysicsPlayground/Assets/boomstick_89a614a521ace7fd.ankimtl
  35. BIN
      Samples/PhysicsPlayground/Assets/boomstickmetallic-boomstickRoughness.ankitex
  36. BIN
      Samples/PhysicsPlayground/Assets/sleevegloveLOW.001_893660395596b206.ankimesh
  37. 12 0
      Samples/PhysicsPlayground/Assets/sleevegloveLOW.001_arms_boomstick_76e1c49d9efa9619.ankimdl
  38. 3 3
      Samples/PhysicsPlayground/Assets/walls.001_2469a4d42c8d129c.ankimtl
  39. 3 3
      Samples/PhysicsPlayground/Assets/walls_9619132fa258d22d.ankimtl
  40. 31 18
      Samples/PhysicsPlayground/Main.cpp

+ 6 - 6
AnKi/Importer/GltfImporter.cpp

@@ -877,7 +877,7 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 					const ImporterString meshFname = computeMeshResourceFilename(*node.mesh);
 
 					ANKI_CHECK(m_sceneFile.writeText("comp:setCollisionShapeType(BodyComponentCollisionShapeType.kFromModelComponent)\n"));
-					ANKI_CHECK(m_sceneFile.writeText("comp:teleportTo(trf)\n"));
+					ANKI_CHECK(m_sceneFile.writeText("comp:teleportTo(trf:getOrigin(), trf:getRotation())\n"));
 				}
 			}
 		}
@@ -908,17 +908,17 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 Error GltfImporter::writeTransform(const Transform& trf)
 {
 	ANKI_CHECK(m_sceneFile.writeText("trf = Transform.new()\n"));
-	ANKI_CHECK(m_sceneFile.writeTextf("trf:setOrigin(Vec4.new(%f, %f, %f, 0))\n", trf.getOrigin().x(), trf.getOrigin().y(), trf.getOrigin().z()));
+	ANKI_CHECK(m_sceneFile.writeTextf("trf:setOrigin(Vec3.new(%f, %f, %f))\n", trf.getOrigin().x(), trf.getOrigin().y(), trf.getOrigin().z()));
 
-	ANKI_CHECK(m_sceneFile.writeText("rot = Mat3x4.new()\n"));
+	ANKI_CHECK(m_sceneFile.writeText("rot = Mat3.new()\n"));
 	ANKI_CHECK(m_sceneFile.writeText("rot:setAll("));
-	for(U i = 0; i < 12; i++)
+	for(U i = 0; i < 9; i++)
 	{
-		ANKI_CHECK(m_sceneFile.writeTextf((i != 11) ? "%f, " : "%f)\n", trf.getRotation()[i]));
+		ANKI_CHECK(m_sceneFile.writeTextf((i != 8) ? "%f, " : "%f)\n", trf.getRotation().getRotationPart()[i]));
 	}
 	ANKI_CHECK(m_sceneFile.writeText("trf:setRotation(rot)\n"));
 
-	ANKI_CHECK(m_sceneFile.writeTextf("trf:setScale(Vec4.new(%f, %f, %f, 0))\n", trf.getScale().x(), trf.getScale().y(), trf.getScale().z()));
+	ANKI_CHECK(m_sceneFile.writeTextf("trf:setScale(Vec3.new(%f, %f, %f))\n", trf.getScale().x(), trf.getScale().y(), trf.getScale().z()));
 
 	ANKI_CHECK(m_sceneFile.writeText("node:setLocalTransform(trf)\n"));
 

+ 6 - 8
AnKi/Physics/PhysicsBody.cpp

@@ -107,17 +107,15 @@ void PhysicsBody::init(const PhysicsBodyInitInfo& init)
 	setUserData(init.m_userData);
 }
 
-void PhysicsBody::setTransform(const Transform& trf)
+void PhysicsBody::setPositionAndRotation(Vec3 position, const Mat3& rotation)
 {
-	ANKI_ASSERT(trf.getScale() == m_worldTrf.getScale() && "Can't handle dynamic scaling for now");
-
-	const JPH::RVec3 pos = toJPH(trf.getOrigin().xyz());
-	const JPH::Quat rot = toJPH(Quat(trf.getRotation()));
+	const JPH::RVec3 pos = toJPH(position);
+	const JPH::Quat rot = toJPH(Quat(rotation));
 
 	PhysicsWorld::getSingleton().m_jphPhysicsSystem->GetBodyInterfaceNoLock().SetPositionAndRotation(m_jphBody->GetID(), pos, rot,
 																									 JPH::EActivation::Activate);
-
-	m_worldTrf = trf;
+	m_worldTrf.setOrigin(position.xyz0());
+	m_worldTrf.setRotation(rotation);
 	++m_worldTrfVersion;
 }
 
@@ -173,7 +171,7 @@ void PhysicsBody::postPhysicsUpdate()
 			toAnKi(PhysicsWorld::getSingleton().m_jphPhysicsSystem->GetBodyInterfaceNoLock().GetWorldTransform(m_jphBody->GetID()));
 		if(newTrf != m_worldTrf)
 		{
-			m_worldTrf = newTrf;
+			m_worldTrf = Transform(newTrf.getOrigin(), newTrf.getRotation(), m_worldTrf.getScale());
 			++m_worldTrfVersion;
 		}
 	}

+ 4 - 4
AnKi/Physics/PhysicsBody.h

@@ -72,7 +72,7 @@ public:
 		return m_worldTrf;
 	}
 
-	void setTransform(const Transform& trf);
+	void setPositionAndRotation(Vec3 position, const Mat3& rotation);
 
 	/// @param force In Newton and in world space.
 	/// @param relPos The position to apply the force. It's in the local space of the body.
@@ -121,13 +121,13 @@ private:
 	PhysicsTriggerCallbacks* m_triggerCallbacks = nullptr;
 	PhysicsCollisionFilterCallback* m_collisionFilterCallback = nullptr;
 
-	Transform m_worldTrf;
-	U32 m_worldTrfVersion = 1;
+	F32 m_mass = 0.0f;
 
+	U32 m_worldTrfVersion : 30 = 1;
 	U32 m_activated : 1 = false;
 	U32 m_isTrigger : 1 = false;
 
-	F32 m_mass = 0.0f;
+	Transform m_worldTrf;
 
 	PhysicsBody();
 

+ 1 - 1
AnKi/Physics/PhysicsWorld.cpp

@@ -449,7 +449,7 @@ void PhysicsWorld::update(Second dt)
 		}
 	}
 
-	constexpr I32 collisionSteps = 1;
+	constexpr I32 collisionSteps = 2;
 	m_jphPhysicsSystem->Update(F32(dt), collisionSteps, &m_tempAllocator, &m_jobSystem);
 
 	// Post-update work

+ 28 - 9
AnKi/Scene/Components/BodyComponent.cpp

@@ -25,12 +25,15 @@ BodyComponent::~BodyComponent()
 {
 }
 
-void BodyComponent::teleportTo(const Transform& trf)
+void BodyComponent::teleportTo(Vec3 position, const Mat3& rotation)
 {
-	m_teleportTrf = trf;
+	m_teleportPosition = position;
+	m_teleportedRotation = rotation;
 	m_teleported = true;
 
-	m_node->setLocalTransform(trf); // Set that just to be sure
+	// Set those just to be sure
+	m_node->setLocalOrigin(position.xyz0());
+	m_node->setLocalRotation(Mat3x4(Vec3(0.0f), rotation, Vec3(1.0f)));
 }
 
 Error BodyComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
@@ -51,7 +54,15 @@ Error BodyComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 
 		PhysicsBodyInitInfo init;
 		init.m_mass = m_mass;
-		init.m_transform = (m_teleported) ? m_teleportTrf : m_node->getWorldTransform();
+		if(m_teleported)
+		{
+			init.m_transform = Transform(m_teleportPosition, m_teleportedRotation, m_node->getLocalTransform().getScale().xyz());
+			m_teleported = false; // Cancel teleportation since the body was re-created
+		}
+		else
+		{
+			init.m_transform = m_node->getLocalTransform();
+		}
 
 		if(m_mass == 0.0f)
 		{
@@ -83,26 +94,34 @@ Error BodyComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 
 		m_body = PhysicsWorld::getSingleton().newPhysicsBody(init);
 		m_body->setUserData(this);
-
-		m_teleported = false; // Cancel teleportation since the body was re-created
 	}
 
 	if(m_teleported)
 	{
 		updated = true;
 		m_teleported = false;
-		m_body->setTransform(m_teleportTrf);
+		m_body->setPositionAndRotation(m_teleportPosition, m_teleportedRotation);
 	}
 
-	if(m_body->getTransform() != info.m_node->getWorldTransform())
+	U32 version;
+	Transform bodyTrf = m_body->getTransform(&version);
+	if(version != m_transformVersion)
 	{
+		m_transformVersion = version;
 		updated = true;
 		info.m_node->setLocalTransform(m_body->getTransform());
 	}
 
 	if(m_force.getLengthSquared() > 0.0f)
 	{
-		m_body->applyForce(m_force, m_forcePosition);
+		if(m_forcePosition != 0.0f)
+		{
+			m_body->applyForce(m_force, m_forcePosition);
+		}
+		else
+		{
+			m_body->applyForce(m_force);
+		}
 		m_force = Vec3(0.0f);
 	}
 

+ 5 - 2
AnKi/Scene/Components/BodyComponent.h

@@ -102,7 +102,7 @@ public:
 		m_forcePosition = relativePosition;
 	}
 
-	void teleportTo(const Transform& trf);
+	void teleportTo(Vec3 position, const Mat3& rotation);
 
 	SceneNode& getSceneNode()
 	{
@@ -136,11 +136,14 @@ private:
 
 	F32 m_mass = 0.0f;
 
-	Transform m_teleportTrf;
+	Vec3 m_teleportPosition;
+	Mat3 m_teleportedRotation;
 
 	Vec3 m_force = Vec3(0.0f);
 	Vec3 m_forcePosition = Vec3(0.0f);
 
+	U32 m_transformVersion = 0;
+
 	Bool m_teleported = false;
 
 	BodyComponentCollisionShapeType m_shapeType = BodyComponentCollisionShapeType::kCount;

+ 1 - 1
AnKi/Scene/Components/ParticleEmitterComponent.cpp

@@ -179,7 +179,7 @@ public:
 		Vec3 pos = getRandom(props.m_particle.m_minStartingPosition, props.m_particle.m_maxStartingPosition);
 		pos = trf.transform(pos);
 
-		m_body->setTransform(Transform(pos.xyz0(), trf.getRotation(), Vec4(1.0f, 1.0f, 1.0f, 0.0f)));
+		m_body->setPositionAndRotation(pos, trf.getRotation().getRotationPart());
 		m_crntPosition = pos;
 	}
 

+ 62 - 34
AnKi/Scene/Components/TriggerComponent.cpp

@@ -69,55 +69,83 @@ TriggerComponent::~TriggerComponent()
 {
 }
 
-void TriggerComponent::setSphereVolumeRadius(F32 radius)
+void TriggerComponent::setType(TriggerComponentShapeType type)
 {
-	// Need to re-create it
-	m_shape = PhysicsWorld::getSingleton().newSphereCollisionShape(radius);
-
-	PhysicsBodyInitInfo init;
-	init.m_isTrigger = true;
-	init.m_shape = m_shape.get();
-	init.m_transform = m_node->getWorldTransform();
-	init.m_layer = PhysicsLayer::kTrigger;
-
-	m_trigger = PhysicsWorld::getSingleton().newPhysicsBody(init);
-	m_trigger->setUserData(this);
-	m_trigger->setPhysicsTriggerCallbacks(&m_callbacks);
-	m_trigger->setTransform(m_node->getWorldTransform());
+	if(type != m_type)
+	{
+		// Force to recreate
+		m_trigger.reset(nullptr);
+		m_shape.reset(nullptr);
+		m_type = type;
+	}
 }
 
 Error TriggerComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 {
-	if(m_trigger) [[likely]]
+	if(m_type == TriggerComponentShapeType::kCount)
 	{
-		if(!m_resetEnter || !m_resetExit)
-		{
-			updated = true;
-		}
+		return Error::kNone;
+	}
 
-		if(m_resetEnter)
+	if(m_trigger && info.m_node->movedThisFrame() && info.m_node->getWorldTransform().getScale() != m_trigger->getTransform().getScale())
+	{
+		// Body will need to be re-created on scale change
+		m_trigger.reset(nullptr);
+	}
+
+	if(!m_trigger)
+	{
+		// Create it
+
+		updated = true;
+
+		if(m_type == TriggerComponentShapeType::kSphere)
 		{
-			// None entered, cleanup
-			m_bodiesEnter.destroy();
+			m_shape = PhysicsWorld::getSingleton().newSphereCollisionShape(1.0f);
 		}
-
-		if(m_resetExit)
+		else
 		{
-			// None exited, cleanup
-			m_bodiesExit.destroy();
+			m_shape = PhysicsWorld::getSingleton().newBoxCollisionShape(Vec3(1.0f));
 		}
 
-		// Prepare them for the next frame
-		m_resetEnter = true;
-		m_resetExit = true;
+		PhysicsBodyInitInfo init;
+		init.m_isTrigger = true;
+		init.m_shape = m_shape.get();
+		init.m_transform = info.m_node->getWorldTransform();
+		init.m_layer = PhysicsLayer::kTrigger;
 
-		if(info.m_node->movedThisFrame())
-		{
-			updated = true;
-			m_trigger->setTransform(info.m_node->getWorldTransform());
-		}
+		m_trigger = PhysicsWorld::getSingleton().newPhysicsBody(init);
+		m_trigger->setUserData(this);
+		m_trigger->setPhysicsTriggerCallbacks(&m_callbacks);
+	}
+	else if(info.m_node->movedThisFrame())
+	{
+		updated = true;
+		m_trigger->setPositionAndRotation(info.m_node->getWorldTransform().getOrigin().xyz(),
+										  info.m_node->getWorldTransform().getRotation().getRotationPart());
 	}
 
+	if(!m_resetEnter || !m_resetExit)
+	{
+		updated = true;
+	}
+
+	if(m_resetEnter)
+	{
+		// None entered, cleanup
+		m_bodiesEnter.destroy();
+	}
+
+	if(m_resetExit)
+	{
+		// None exited, cleanup
+		m_bodiesExit.destroy();
+	}
+
+	// Prepare them for the next frame
+	m_resetEnter = true;
+	m_resetExit = true;
+
 	return Error::kNone;
 }
 

+ 11 - 1
AnKi/Scene/Components/TriggerComponent.h

@@ -13,6 +13,14 @@ namespace anki {
 /// @addtogroup scene
 /// @{
 
+/// @memberof TriggerComponent
+enum class TriggerComponentShapeType
+{
+	kSphere,
+	kBox,
+	kCount
+};
+
 /// Trigger component.
 class TriggerComponent : public SceneComponent
 {
@@ -23,7 +31,7 @@ public:
 
 	~TriggerComponent();
 
-	void setSphereVolumeRadius(F32 radius);
+	void setType(TriggerComponentShapeType type);
 
 	WeakArray<SceneNode*> getSceneNodesEnter()
 	{
@@ -46,6 +54,8 @@ private:
 	SceneDynamicArray<SceneNode*> m_bodiesEnter;
 	SceneDynamicArray<SceneNode*> m_bodiesExit;
 
+	TriggerComponentShapeType m_type = TriggerComponentShapeType::kCount;
+
 	Bool m_resetEnter = true;
 	Bool m_resetExit = true;
 

+ 48 - 48
AnKi/Script/Math.cpp

@@ -26,7 +26,7 @@ static void deserializeVec2(const void* data, LuaUserData& self)
 	obj->deserialize(data);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoVec2 = {594303304060146034, "Vec2", LuaUserData::computeSizeForGarbageCollected<Vec2>(), serializeVec2,
+LuaUserDataTypeInfo luaUserDataTypeInfoVec2 = {7803499094187981619, "Vec2", LuaUserData::computeSizeForGarbageCollected<Vec2>(), serializeVec2,
 											   deserializeVec2};
 
 template<>
@@ -1035,7 +1035,7 @@ static void deserializeVec3(const void* data, LuaUserData& self)
 	obj->deserialize(data);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoVec3 = {5669632566763941038, "Vec3", LuaUserData::computeSizeForGarbageCollected<Vec3>(), serializeVec3,
+LuaUserDataTypeInfo luaUserDataTypeInfoVec3 = {6911238639175218670, "Vec3", LuaUserData::computeSizeForGarbageCollected<Vec3>(), serializeVec3,
 											   deserializeVec3};
 
 template<>
@@ -2180,7 +2180,7 @@ static void deserializeVec4(const void* data, LuaUserData& self)
 	obj->deserialize(data);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoVec4 = {-7510298399639860788, "Vec4", LuaUserData::computeSizeForGarbageCollected<Vec4>(), serializeVec4,
+LuaUserDataTypeInfo luaUserDataTypeInfoVec4 = {-5133042424981777357, "Vec4", LuaUserData::computeSizeForGarbageCollected<Vec4>(), serializeVec4,
 											   deserializeVec4};
 
 template<>
@@ -3411,7 +3411,7 @@ static inline void wrapVec4(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoMat3 = {-8522796721639548452, "Mat3", LuaUserData::computeSizeForGarbageCollected<Mat3>(), nullptr, nullptr};
+LuaUserDataTypeInfo luaUserDataTypeInfoMat3 = {6777119210890395568, "Mat3", LuaUserData::computeSizeForGarbageCollected<Mat3>(), nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<Mat3>()
@@ -3797,7 +3797,7 @@ static inline void wrapMat3(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoMat3x4 = {6107000574328002637, "Mat3x4", LuaUserData::computeSizeForGarbageCollected<Mat3x4>(), nullptr,
+LuaUserDataTypeInfo luaUserDataTypeInfoMat3x4 = {8812777471101110980, "Mat3x4", LuaUserData::computeSizeForGarbageCollected<Mat3x4>(), nullptr,
 												 nullptr};
 
 template<>
@@ -4202,7 +4202,7 @@ static inline void wrapMat3x4(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoTransform = {-1440284075251026678, "Transform", LuaUserData::computeSizeForGarbageCollected<Transform>(),
+LuaUserDataTypeInfo luaUserDataTypeInfoTransform = {5321497660535424691, "Transform", LuaUserData::computeSizeForGarbageCollected<Transform>(),
 													nullptr, nullptr};
 
 template<>
@@ -4248,32 +4248,32 @@ static inline int pwrapTransformCtor1(lua_State* l)
 	}
 
 	// Pop arguments
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec4;
-	if(LuaBinder::checkUserData(l, 1, luaUserDataTypeInfoVec4, ud)) [[unlikely]]
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec3;
+	if(LuaBinder::checkUserData(l, 1, luaUserDataTypeInfoVec3, ud)) [[unlikely]]
 	{
 		return -1;
 	}
 
-	Vec4* iarg0 = ud->getData<Vec4>();
-	Vec4 arg0(*iarg0);
+	Vec3* iarg0 = ud->getData<Vec3>();
+	Vec3 arg0(*iarg0);
 
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoMat3x4;
-	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoMat3x4, ud)) [[unlikely]]
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoMat3;
+	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoMat3, ud)) [[unlikely]]
 	{
 		return -1;
 	}
 
-	Mat3x4* iarg1 = ud->getData<Mat3x4>();
-	Mat3x4 arg1(*iarg1);
+	Mat3* iarg1 = ud->getData<Mat3>();
+	Mat3 arg1(*iarg1);
 
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec4;
-	if(LuaBinder::checkUserData(l, 3, luaUserDataTypeInfoVec4, ud)) [[unlikely]]
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec3;
+	if(LuaBinder::checkUserData(l, 3, luaUserDataTypeInfoVec3, ud)) [[unlikely]]
 	{
 		return -1;
 	}
 
-	Vec4* iarg2 = ud->getData<Vec4>();
-	Vec4 arg2(*iarg2);
+	Vec3* iarg2 = ud->getData<Vec3>();
+	Vec3 arg2(*iarg2);
 
 	// Create user data
 	size = LuaUserData::computeSizeForGarbageCollected<Transform>();
@@ -4411,16 +4411,16 @@ static inline int pwrapTransformgetOrigin(lua_State* l)
 	Transform* self = ud->getData<Transform>();
 
 	// Call the method
-	Vec4 ret = self->getOrigin();
+	Vec3 ret = self->getOrigin().xyz();
 
 	// Push return value
-	size = LuaUserData::computeSizeForGarbageCollected<Vec4>();
+	size = LuaUserData::computeSizeForGarbageCollected<Vec3>();
 	voidp = lua_newuserdata(l, size);
-	luaL_setmetatable(l, "Vec4");
+	luaL_setmetatable(l, "Vec3");
 	ud = static_cast<LuaUserData*>(voidp);
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec4;
-	ud->initGarbageCollected(&luaUserDataTypeInfoVec4);
-	::new(ud->getData<Vec4>()) Vec4(std::move(ret));
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec3;
+	ud->initGarbageCollected(&luaUserDataTypeInfoVec3);
+	::new(ud->getData<Vec3>()) Vec3(std::move(ret));
 
 	return 1;
 }
@@ -4459,14 +4459,14 @@ static inline int pwrapTransformsetOrigin(lua_State* l)
 	Transform* self = ud->getData<Transform>();
 
 	// Pop arguments
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec4;
-	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoVec4, ud)) [[unlikely]]
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec3;
+	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoVec3, ud)) [[unlikely]]
 	{
 		return -1;
 	}
 
-	Vec4* iarg0 = ud->getData<Vec4>();
-	const Vec4& arg0(*iarg0);
+	Vec3* iarg0 = ud->getData<Vec3>();
+	const Vec3& arg0(*iarg0);
 
 	// Call the method
 	self->setOrigin(arg0);
@@ -4508,16 +4508,16 @@ static inline int pwrapTransformgetRotation(lua_State* l)
 	Transform* self = ud->getData<Transform>();
 
 	// Call the method
-	Mat3x4 ret = self->getRotation();
+	Mat3 ret = self->getRotation().getRotationPart();
 
 	// Push return value
-	size = LuaUserData::computeSizeForGarbageCollected<Mat3x4>();
+	size = LuaUserData::computeSizeForGarbageCollected<Mat3>();
 	voidp = lua_newuserdata(l, size);
-	luaL_setmetatable(l, "Mat3x4");
+	luaL_setmetatable(l, "Mat3");
 	ud = static_cast<LuaUserData*>(voidp);
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoMat3x4;
-	ud->initGarbageCollected(&luaUserDataTypeInfoMat3x4);
-	::new(ud->getData<Mat3x4>()) Mat3x4(std::move(ret));
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoMat3;
+	ud->initGarbageCollected(&luaUserDataTypeInfoMat3);
+	::new(ud->getData<Mat3>()) Mat3(std::move(ret));
 
 	return 1;
 }
@@ -4556,14 +4556,14 @@ static inline int pwrapTransformsetRotation(lua_State* l)
 	Transform* self = ud->getData<Transform>();
 
 	// Pop arguments
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoMat3x4;
-	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoMat3x4, ud)) [[unlikely]]
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoMat3;
+	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoMat3, ud)) [[unlikely]]
 	{
 		return -1;
 	}
 
-	Mat3x4* iarg0 = ud->getData<Mat3x4>();
-	const Mat3x4& arg0(*iarg0);
+	Mat3* iarg0 = ud->getData<Mat3>();
+	const Mat3& arg0(*iarg0);
 
 	// Call the method
 	self->setRotation(arg0);
@@ -4605,16 +4605,16 @@ static inline int pwrapTransformgetScale(lua_State* l)
 	Transform* self = ud->getData<Transform>();
 
 	// Call the method
-	Vec4 ret = self->getScale();
+	Vec3 ret = self->getScale().xyz();
 
 	// Push return value
-	size = LuaUserData::computeSizeForGarbageCollected<Vec4>();
+	size = LuaUserData::computeSizeForGarbageCollected<Vec3>();
 	voidp = lua_newuserdata(l, size);
-	luaL_setmetatable(l, "Vec4");
+	luaL_setmetatable(l, "Vec3");
 	ud = static_cast<LuaUserData*>(voidp);
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec4;
-	ud->initGarbageCollected(&luaUserDataTypeInfoVec4);
-	::new(ud->getData<Vec4>()) Vec4(std::move(ret));
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec3;
+	ud->initGarbageCollected(&luaUserDataTypeInfoVec3);
+	::new(ud->getData<Vec3>()) Vec3(std::move(ret));
 
 	return 1;
 }
@@ -4653,14 +4653,14 @@ static inline int pwrapTransformsetScale(lua_State* l)
 	Transform* self = ud->getData<Transform>();
 
 	// Pop arguments
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec4;
-	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoVec4, ud)) [[unlikely]]
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec3;
+	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoVec3, ud)) [[unlikely]]
 	{
 		return -1;
 	}
 
-	Vec4* iarg0 = ud->getData<Vec4>();
-	const Vec4& arg0(*iarg0);
+	Vec3* iarg0 = ud->getData<Vec3>();
+	const Vec3& arg0(*iarg0);
 
 	// Call the method
 	self->setScale(arg0);

+ 12 - 9
AnKi/Script/Math.xml

@@ -468,9 +468,9 @@ namespace anki {]]></head>
 				<constructor></constructor>
 				<constructor>
 					<args>
-						<arg>Vec4</arg>
-						<arg>Mat3x4</arg>
-						<arg>Vec4</arg>
+						<arg>Vec3</arg>
+						<arg>Mat3</arg>
+						<arg>Vec3</arg>
 					</args>
 				</constructor>
 			</constructors>
@@ -481,27 +481,30 @@ namespace anki {]]></head>
 					</args>
 				</method>
 				<method name="getOrigin">
-					<return>Vec4</return>
+					<overrideCall>Vec3 ret = self->getOrigin().xyz();</overrideCall>
+					<return>Vec3</return>
 				</method>
 				<method name="setOrigin">
 					<args>
-						<arg>const Vec4&amp;</arg>
+						<arg>const Vec3&amp;</arg>
 					</args>
 				</method>
 				<method name="getRotation">
-					<return>Mat3x4</return>
+					<overrideCall>Mat3 ret = self->getRotation().getRotationPart();</overrideCall>
+					<return>Mat3</return>
 				</method>
 				<method name="setRotation">
 					<args>
-						<arg>const Mat3x4&amp;</arg>
+						<arg>const Mat3&amp;</arg>
 					</args>
 				</method>
 				<method name="getScale">
-					<return>Vec4</return>
+					<overrideCall>Vec3 ret = self->getScale().xyz();</overrideCall>
+					<return>Vec3</return>
 				</method>
 				<method name="setScale">
 					<args>
-						<arg>const Vec4&amp;</arg>
+						<arg>const Vec3&amp;</arg>
 					</args>
 				</method>
 			</methods>

+ 40 - 32
AnKi/Script/Scene.cpp

@@ -60,7 +60,7 @@ static EventManager* getEventManager(lua_State* l)
 
 using WeakArraySceneNodePtr = WeakArray<SceneNode*>;
 
-LuaUserDataTypeInfo luaUserDataTypeInfoLightComponentType = {9069794947595355041, "LightComponentType", 0, nullptr, nullptr};
+LuaUserDataTypeInfo luaUserDataTypeInfoLightComponentType = {2674406225469400027, "LightComponentType", 0, nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<LightComponentType>()
@@ -95,7 +95,7 @@ static inline void wrapLightComponentType(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoBodyComponentCollisionShapeType = {4012303373488841237, "BodyComponentCollisionShapeType", 0, nullptr,
+LuaUserDataTypeInfo luaUserDataTypeInfoBodyComponentCollisionShapeType = {-5580892498850764437, "BodyComponentCollisionShapeType", 0, nullptr,
 																		  nullptr};
 
 template<>
@@ -140,7 +140,7 @@ static inline void wrapBodyComponentCollisionShapeType(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoWeakArraySceneNodePtr = {
-	-4465466740417030284, "WeakArraySceneNodePtr", LuaUserData::computeSizeForGarbageCollected<WeakArraySceneNodePtr>(), nullptr, nullptr};
+	-254060125832002206, "WeakArraySceneNodePtr", LuaUserData::computeSizeForGarbageCollected<WeakArraySceneNodePtr>(), nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<WeakArraySceneNodePtr>()
@@ -258,7 +258,7 @@ static inline void wrapWeakArraySceneNodePtr(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoLightComponent = {1627842491458315331, "LightComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoLightComponent = {3282295762251865100, "LightComponent",
 														 LuaUserData::computeSizeForGarbageCollected<LightComponent>(), nullptr, nullptr};
 
 template<>
@@ -869,7 +869,7 @@ static inline void wrapLightComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoDecalComponent = {1156947010128629167, "DecalComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoDecalComponent = {-456899332027010335, "DecalComponent",
 														 LuaUserData::computeSizeForGarbageCollected<DecalComponent>(), nullptr, nullptr};
 
 template<>
@@ -1041,7 +1041,7 @@ static inline void wrapDecalComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoLensFlareComponent = {-6804037317475103760, "LensFlareComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoLensFlareComponent = {-4856462475495820968, "LensFlareComponent",
 															 LuaUserData::computeSizeForGarbageCollected<LensFlareComponent>(), nullptr, nullptr};
 
 template<>
@@ -1204,7 +1204,7 @@ static inline void wrapLensFlareComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoBodyComponent = {-6173350858840068269, "BodyComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoBodyComponent = {-8135061707117828021, "BodyComponent",
 														LuaUserData::computeSizeForGarbageCollected<BodyComponent>(), nullptr, nullptr};
 
 template<>
@@ -1450,7 +1450,7 @@ static inline int pwrapBodyComponentteleportTo(lua_State* l)
 	[[maybe_unused]] void* voidp;
 	[[maybe_unused]] PtrSize size;
 
-	if(LuaBinder::checkArgsCount(l, 2)) [[unlikely]]
+	if(LuaBinder::checkArgsCount(l, 3)) [[unlikely]]
 	{
 		return -1;
 	}
@@ -1464,17 +1464,26 @@ static inline int pwrapBodyComponentteleportTo(lua_State* l)
 	BodyComponent* self = ud->getData<BodyComponent>();
 
 	// Pop arguments
-	extern LuaUserDataTypeInfo luaUserDataTypeInfoTransform;
-	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoTransform, ud)) [[unlikely]]
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoVec3;
+	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoVec3, ud)) [[unlikely]]
 	{
 		return -1;
 	}
 
-	Transform* iarg0 = ud->getData<Transform>();
-	const Transform& arg0(*iarg0);
+	Vec3* iarg0 = ud->getData<Vec3>();
+	Vec3 arg0(*iarg0);
+
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoMat3;
+	if(LuaBinder::checkUserData(l, 3, luaUserDataTypeInfoMat3, ud)) [[unlikely]]
+	{
+		return -1;
+	}
+
+	Mat3* iarg1 = ud->getData<Mat3>();
+	const Mat3& arg1(*iarg1);
 
 	// Call the method
-	self->teleportTo(arg0);
+	self->teleportTo(arg0, arg1);
 
 	return 0;
 }
@@ -1505,7 +1514,7 @@ static inline void wrapBodyComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoTriggerComponent = {5790819453583864773, "TriggerComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoTriggerComponent = {-6461553722135554456, "TriggerComponent",
 														   LuaUserData::computeSizeForGarbageCollected<TriggerComponent>(), nullptr, nullptr};
 
 template<>
@@ -1619,7 +1628,7 @@ static inline void wrapTriggerComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoFogDensityComponent = {-99769539089360673, "FogDensityComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoFogDensityComponent = {-2183674474479979269, "FogDensityComponent",
 															  LuaUserData::computeSizeForGarbageCollected<FogDensityComponent>(), nullptr, nullptr};
 
 template<>
@@ -1822,7 +1831,7 @@ static inline void wrapFogDensityComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoCameraComponent = {-68521109795181851, "CameraComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoCameraComponent = {610757795420988947, "CameraComponent",
 														  LuaUserData::computeSizeForGarbageCollected<CameraComponent>(), nullptr, nullptr};
 
 template<>
@@ -1904,8 +1913,8 @@ static inline void wrapCameraComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoGlobalIlluminationProbeComponent = {
-	-8940003758257335788, "GlobalIlluminationProbeComponent", LuaUserData::computeSizeForGarbageCollected<GlobalIlluminationProbeComponent>(),
-	nullptr, nullptr};
+	5309437820755545492, "GlobalIlluminationProbeComponent", LuaUserData::computeSizeForGarbageCollected<GlobalIlluminationProbeComponent>(), nullptr,
+	nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<GlobalIlluminationProbeComponent>()
@@ -2151,7 +2160,7 @@ static inline void wrapGlobalIlluminationProbeComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoReflectionProbeComponent = {
-	-111826572912818668, "ReflectionProbeComponent", LuaUserData::computeSizeForGarbageCollected<ReflectionProbeComponent>(), nullptr, nullptr};
+	-84348997957100053, "ReflectionProbeComponent", LuaUserData::computeSizeForGarbageCollected<ReflectionProbeComponent>(), nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<ReflectionProbeComponent>()
@@ -2266,7 +2275,7 @@ static inline void wrapReflectionProbeComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoParticleEmitterComponent = {
-	3350524044897346812, "ParticleEmitterComponent", LuaUserData::computeSizeForGarbageCollected<ParticleEmitterComponent>(), nullptr, nullptr};
+	-2118211078468454570, "ParticleEmitterComponent", LuaUserData::computeSizeForGarbageCollected<ParticleEmitterComponent>(), nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<ParticleEmitterComponent>()
@@ -2328,7 +2337,7 @@ static inline void wrapParticleEmitterComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoModelComponent = {-9059782793959299070, "ModelComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoModelComponent = {-4016341380854106055, "ModelComponent",
 														 LuaUserData::computeSizeForGarbageCollected<ModelComponent>(), nullptr, nullptr};
 
 template<>
@@ -2391,7 +2400,7 @@ static inline void wrapModelComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoSkinComponent = {5797775506072060908, "SkinComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoSkinComponent = {-1288506652033682062, "SkinComponent",
 														LuaUserData::computeSizeForGarbageCollected<SkinComponent>(), nullptr, nullptr};
 
 template<>
@@ -2454,7 +2463,7 @@ static inline void wrapSkinComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoSkyboxComponent = {-3942881413516893543, "SkyboxComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoSkyboxComponent = {-6285180326855513401, "SkyboxComponent",
 														  LuaUserData::computeSizeForGarbageCollected<SkyboxComponent>(), nullptr, nullptr};
 
 template<>
@@ -2945,7 +2954,7 @@ static inline void wrapSkyboxComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoSceneNode = {-3261474765783124766, "SceneNode", LuaUserData::computeSizeForGarbageCollected<SceneNode>(),
+LuaUserDataTypeInfo luaUserDataTypeInfoSceneNode = {8870940414344917067, "SceneNode", LuaUserData::computeSizeForGarbageCollected<SceneNode>(),
 													nullptr, nullptr};
 
 template<>
@@ -4782,7 +4791,7 @@ static inline void wrapSceneNode(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoSceneGraph = {2311127321533935429, "SceneGraph", LuaUserData::computeSizeForGarbageCollected<SceneGraph>(),
+LuaUserDataTypeInfo luaUserDataTypeInfoSceneGraph = {2821236780501471659, "SceneGraph", LuaUserData::computeSizeForGarbageCollected<SceneGraph>(),
 													 nullptr, nullptr};
 
 template<>
@@ -4968,8 +4977,7 @@ static inline void wrapSceneGraph(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoEvent = {-4718494666009094294, "Event", LuaUserData::computeSizeForGarbageCollected<Event>(), nullptr,
-												nullptr};
+LuaUserDataTypeInfo luaUserDataTypeInfoEvent = {-975557255717293050, "Event", LuaUserData::computeSizeForGarbageCollected<Event>(), nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<Event>()
@@ -5033,7 +5041,7 @@ static inline void wrapEvent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoLightEvent = {8360443534716675988, "LightEvent", LuaUserData::computeSizeForGarbageCollected<LightEvent>(),
+LuaUserDataTypeInfo luaUserDataTypeInfoLightEvent = {3064430689606199710, "LightEvent", LuaUserData::computeSizeForGarbageCollected<LightEvent>(),
 													 nullptr, nullptr};
 
 template<>
@@ -5152,7 +5160,7 @@ static inline void wrapLightEvent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoScriptEvent = {-5828444576659958894, "ScriptEvent", LuaUserData::computeSizeForGarbageCollected<ScriptEvent>(),
+LuaUserDataTypeInfo luaUserDataTypeInfoScriptEvent = {-8308300101523367893, "ScriptEvent", LuaUserData::computeSizeForGarbageCollected<ScriptEvent>(),
 													  nullptr, nullptr};
 
 template<>
@@ -5168,7 +5176,7 @@ static inline void wrapScriptEvent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoJitterMoveEvent = {-1382509976775521529, "JitterMoveEvent",
+LuaUserDataTypeInfo luaUserDataTypeInfoJitterMoveEvent = {6072769684148144301, "JitterMoveEvent",
 														  LuaUserData::computeSizeForGarbageCollected<JitterMoveEvent>(), nullptr, nullptr};
 
 template<>
@@ -5243,7 +5251,7 @@ static inline void wrapJitterMoveEvent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoAnimationEvent = {-7656461176932586107, "AnimationEvent",
+LuaUserDataTypeInfo luaUserDataTypeInfoAnimationEvent = {5397926449655054349, "AnimationEvent",
 														 LuaUserData::computeSizeForGarbageCollected<AnimationEvent>(), nullptr, nullptr};
 
 template<>
@@ -5259,7 +5267,7 @@ static inline void wrapAnimationEvent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoEventManager = {-1263917656658635236, "EventManager",
+LuaUserDataTypeInfo luaUserDataTypeInfoEventManager = {4611480409820016375, "EventManager",
 													   LuaUserData::computeSizeForGarbageCollected<EventManager>(), nullptr, nullptr};
 
 template<>

+ 2 - 1
AnKi/Script/Scene.xml

@@ -220,7 +220,8 @@ using WeakArraySceneNodePtr = WeakArray<SceneNode*>;
 				</method>
 				<method name="teleportTo">
 					<args>
-						<arg>const Transform&amp;</arg>
+						<arg>Vec3</arg>
+						<arg>const Mat3&amp;</arg>
 					</args>
 				</method>
 			</methods>

BIN
Samples/PhysicsPlayground/Assets/Asphalt_004_COLOR_png.ankitex


BIN
Samples/PhysicsPlayground/Assets/Asphalt_004_NRM_png.ankitex


BIN
Samples/PhysicsPlayground/Assets/Asphalt_004_ROUGH_png.ankitex


BIN
Samples/PhysicsPlayground/Assets/Icosphere_834d64c142beaa13.ankimesh


BIN
Samples/PhysicsPlayground/Assets/M61_model_M61_grenade_BaseColor.ankitex


BIN
Samples/PhysicsPlayground/Assets/M61_model_M61_grenade_Metalness-M61_model_M61_grenade_Roughness.ankitex


BIN
Samples/PhysicsPlayground/Assets/MESH_grenade_818651700502e14b.ankimesh


+ 8 - 0
Samples/PhysicsPlayground/Assets/MESH_grenade_MTL_grenade_85852a78645563d8.ankimdl

@@ -0,0 +1,8 @@
+<model>
+	<modelPatches>
+		<modelPatch>
+			<mesh>Assets/MESH_grenade_818651700502e14b.ankimesh</mesh>
+			<material>Assets/MTL_grenade_4346150e31bdb957.ankimtl</material>
+		</modelPatch>
+	</modelPatches>
+</model>

+ 29 - 0
Samples/PhysicsPlayground/Assets/MTL_grenade_4346150e31bdb957.ankimtl

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- This file is auto generated by ImporterMaterial.cpp -->
+<material shadows="1">
+	<shaderProgram name="GBufferGeneric">
+		<mutation>
+			<mutator name="DIFFUSE_TEX" value="1"/>
+			<mutator name="SPECULAR_TEX" value="0"/>
+			<mutator name="ROUGHNESS_METALNESS_TEX" value="1"/>
+			<mutator name="NORMAL_TEX" value="0"/>
+			<mutator name="PARALLAX" value="0"/>
+			<mutator name="EMISSIVE_TEX" value="0"/>
+			<mutator name="ALPHA_TEST" value="0"/>
+		</mutation>
+	</shaderProgram>
+
+	<inputs>
+		
+		<input name="m_diffuseTex" value="Assets/M61_model_M61_grenade_BaseColor.ankitex"/>
+		<input name="m_diffuseScale" value="1.000000 1.000000 1.000000 1.000000"/>
+		<input name="m_specularScale" value="0.040000 0.040000 0.040000"/>
+		<input name="m_roughnessMetalnessTex" value="Assets/M61_model_M61_grenade_Metalness-M61_model_M61_grenade_Roughness.ankitex"/>
+		<input name="m_roughnessScale" value="1.000000"/>
+		<input name="m_metalnessScale" value="1.000000"/>
+		
+		<input name="m_emissionScale" value="0.000000 0.000000 0.000000"/>
+		<input name="m_subsurface" value="0.000000"/>
+		
+	</inputs>
+</material>

File diff suppressed because it is too large
+ 420 - 254
Samples/PhysicsPlayground/Assets/Scene.lua


BIN
Samples/PhysicsPlayground/Assets/Stone_Wall_007_COLOR_png.ankitex


BIN
Samples/PhysicsPlayground/Assets/Stone_Wall_007_NORM_png.ankitex


BIN
Samples/PhysicsPlayground/Assets/Stone_Wall_007_ROUGH_png.ankitex


BIN
Samples/PhysicsPlayground/Assets/Suzanne_e3526e1428c0763c.ankimesh


BIN
Samples/PhysicsPlayground/Assets/armColor.ankitex


BIN
Samples/PhysicsPlayground/Assets/armNormal.ankitex


BIN
Samples/PhysicsPlayground/Assets/armRoughness.ankitex


+ 29 - 0
Samples/PhysicsPlayground/Assets/arms_3a4232ebbd425e7a.ankimtl

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- This file is auto generated by ImporterMaterial.cpp -->
+<material shadows="1">
+	<shaderProgram name="GBufferGeneric">
+		<mutation>
+			<mutator name="DIFFUSE_TEX" value="1"/>
+			<mutator name="SPECULAR_TEX" value="0"/>
+			<mutator name="ROUGHNESS_METALNESS_TEX" value="1"/>
+			<mutator name="NORMAL_TEX" value="1"/>
+			<mutator name="PARALLAX" value="0"/>
+			<mutator name="EMISSIVE_TEX" value="0"/>
+			<mutator name="ALPHA_TEST" value="0"/>
+		</mutation>
+	</shaderProgram>
+
+	<inputs>
+		
+		<input name="m_diffuseTex" value="Assets/armColor.ankitex"/>
+		<input name="m_diffuseScale" value="1.000000 1.000000 1.000000 1.000000"/>
+		<input name="m_specularScale" value="0.040000 0.040000 0.040000"/>
+		<input name="m_roughnessMetalnessTex" value="Assets/armRoughness.ankitex"/>
+		<input name="m_roughnessScale" value="1.000000"/>
+		<input name="m_metalnessScale" value="0.000000"/>
+		<input name="m_normalTex" value="Assets/armNormal.ankitex"/>
+		<input name="m_emissionScale" value="0.000000 0.000000 0.000000"/>
+		<input name="m_subsurface" value="0.000000"/>
+		
+	</inputs>
+</material>

BIN
Samples/PhysicsPlayground/Assets/boomstickColor.ankitex


BIN
Samples/PhysicsPlayground/Assets/boomstickNormal.ankitex


+ 29 - 0
Samples/PhysicsPlayground/Assets/boomstick_89a614a521ace7fd.ankimtl

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- This file is auto generated by ImporterMaterial.cpp -->
+<material shadows="1">
+	<shaderProgram name="GBufferGeneric">
+		<mutation>
+			<mutator name="DIFFUSE_TEX" value="1"/>
+			<mutator name="SPECULAR_TEX" value="0"/>
+			<mutator name="ROUGHNESS_METALNESS_TEX" value="1"/>
+			<mutator name="NORMAL_TEX" value="1"/>
+			<mutator name="PARALLAX" value="0"/>
+			<mutator name="EMISSIVE_TEX" value="0"/>
+			<mutator name="ALPHA_TEST" value="0"/>
+		</mutation>
+	</shaderProgram>
+
+	<inputs>
+		
+		<input name="m_diffuseTex" value="Assets/boomstickColor.ankitex"/>
+		<input name="m_diffuseScale" value="1.000000 1.000000 1.000000 1.000000"/>
+		<input name="m_specularScale" value="0.040000 0.040000 0.040000"/>
+		<input name="m_roughnessMetalnessTex" value="Assets/boomstickmetallic-boomstickRoughness.ankitex"/>
+		<input name="m_roughnessScale" value="1.000000"/>
+		<input name="m_metalnessScale" value="1.000000"/>
+		<input name="m_normalTex" value="Assets/boomstickNormal.ankitex"/>
+		<input name="m_emissionScale" value="0.000000 0.000000 0.000000"/>
+		<input name="m_subsurface" value="0.000000"/>
+		
+	</inputs>
+</material>

BIN
Samples/PhysicsPlayground/Assets/boomstickmetallic-boomstickRoughness.ankitex


BIN
Samples/PhysicsPlayground/Assets/sleevegloveLOW.001_893660395596b206.ankimesh


+ 12 - 0
Samples/PhysicsPlayground/Assets/sleevegloveLOW.001_arms_boomstick_76e1c49d9efa9619.ankimdl

@@ -0,0 +1,12 @@
+<model>
+	<modelPatches>
+		<modelPatch>
+			<mesh subMeshIndex="0">Assets/sleevegloveLOW.001_893660395596b206.ankimesh</mesh>
+			<material>Assets/arms_3a4232ebbd425e7a.ankimtl</material>
+		</modelPatch>
+		<modelPatch>
+			<mesh subMeshIndex="1">Assets/sleevegloveLOW.001_893660395596b206.ankimesh</mesh>
+			<material>Assets/boomstick_89a614a521ace7fd.ankimtl</material>
+		</modelPatch>
+	</modelPatches>
+</model>

+ 3 - 3
Samples/PhysicsPlayground/Assets/walls.001_2469a4d42c8d129c.ankimtl

@@ -15,13 +15,13 @@
 
 	<inputs>
 		
-		<input name="m_diffuseTex" value="Assets/Stone_Wall_007_COLOR.ankitex"/>
+		<input name="m_diffuseTex" value="Assets/Stone_Wall_007_COLOR_png.ankitex"/>
 		<input name="m_diffuseScale" value="1.000000 1.000000 1.000000 1.000000"/>
 		<input name="m_specularScale" value="0.040000 0.040000 0.040000"/>
-		<input name="m_roughnessMetalnessTex" value="Assets/Stone_Wall_007_ROUGH.ankitex"/>
+		<input name="m_roughnessMetalnessTex" value="Assets/Stone_Wall_007_ROUGH_png.ankitex"/>
 		<input name="m_roughnessScale" value="1.000000"/>
 		<input name="m_metalnessScale" value="0.000000"/>
-		<input name="m_normalTex" value="Assets/Stone_Wall_007_NORM.ankitex"/>
+		<input name="m_normalTex" value="Assets/Stone_Wall_007_NORM_png.ankitex"/>
 		<input name="m_emissionScale" value="0.000000 0.000000 0.000000"/>
 		<input name="m_subsurface" value="0.000000"/>
 		

+ 3 - 3
Samples/PhysicsPlayground/Assets/walls_9619132fa258d22d.ankimtl

@@ -15,13 +15,13 @@
 
 	<inputs>
 		
-		<input name="m_diffuseTex" value="Assets/Asphalt_004_COLOR.ankitex"/>
+		<input name="m_diffuseTex" value="Assets/Asphalt_004_COLOR_png.ankitex"/>
 		<input name="m_diffuseScale" value="1.000000 1.000000 1.000000 1.000000"/>
 		<input name="m_specularScale" value="0.040000 0.040000 0.040000"/>
-		<input name="m_roughnessMetalnessTex" value="Assets/Asphalt_004_ROUGH.ankitex"/>
+		<input name="m_roughnessMetalnessTex" value="Assets/Asphalt_004_ROUGH_png.ankitex"/>
 		<input name="m_roughnessScale" value="1.000000"/>
 		<input name="m_metalnessScale" value="0.000000"/>
-		<input name="m_normalTex" value="Assets/Asphalt_004_NRM.ankitex"/>
+		<input name="m_normalTex" value="Assets/Asphalt_004_NRM_png.ankitex"/>
 		<input name="m_emissionScale" value="0.000000 0.000000 0.000000"/>
 		<input name="m_subsurface" value="0.000000"/>
 		

+ 31 - 18
Samples/PhysicsPlayground/Main.cpp

@@ -86,7 +86,11 @@ Error MyApp::sampleExtraInit()
 	if(1)
 	{
 		SceneNode& cam = SceneGraph::getSingleton().getActiveCameraNode();
-		cam.setLocalTransform(Transform(Vec4(0.0, 2.0, 5.0, 0.0), Mat3x4::getIdentity(), Vec4(1.0f, 1.0f, 1.0f, 0.0f)));
+		cam.setLocalTransform(Transform(Vec4(0.0, 2.0, 0.0, 0.0), Mat3x4::getIdentity(), Vec4(1.0f, 1.0f, 1.0f, 0.0f)));
+
+		SceneNode& arm = SceneGraph::getSingleton().findSceneNode("arm");
+		arm.setLocalTransform(Transform(Vec3(0.065f, -0.13f, -0.4f), Mat3(Euler(0.0f, kPi, 0.0f)), Vec3(1.0f, 1.0f, 1.0f)));
+		arm.setParent(&cam);
 
 		SceneNode* player;
 		ANKI_CHECK(SceneGraph::getSingleton().newSceneNode("player", player));
@@ -104,7 +108,7 @@ Error MyApp::sampleExtraInit()
 		BodyComponent* bodyc = base->newComponent<BodyComponent>();
 		bodyc->setBoxExtend(Vec3(0.1f));
 		bodyc->setCollisionShapeType(BodyComponentCollisionShapeType::kAabb);
-		bodyc->teleportTo(Transform(Vec4(-0.0f, 5.0f, -3.0f, 0.0f), Mat3x4::getIdentity(), Vec4(1.0f, 1.0f, 1.0f, 0.0f)));
+		bodyc->teleportTo(Vec3(-0.0f, 5.0f, -3.0f), Mat3::getIdentity());
 
 		SceneNode* joint;
 		ANKI_CHECK(SceneGraph::getSingleton().newSceneNode("hinge", joint));
@@ -122,7 +126,7 @@ Error MyApp::sampleExtraInit()
 
 		bodyc = monkey->newComponent<BodyComponent>();
 		bodyc->setCollisionShapeType(BodyComponentCollisionShapeType::kFromModelComponent);
-		bodyc->teleportTo(Transform(Vec4(-0.0f, 4.8f - height / 2.0f, -3.0f, 0.0f), Mat3x4::getIdentity(), Vec4(1.0f, 1.0f, 1.0f, 0.0f)));
+		bodyc->teleportTo(Vec3(-0.0f, 4.8f - height / 2.0f, -3.0f), Mat3::getIdentity());
 		bodyc->setMass(2.0f);
 
 		joint->addChild(monkey);
@@ -140,7 +144,7 @@ Error MyApp::sampleExtraInit()
 		BodyComponent* bodyc = base->newComponent<BodyComponent>();
 		bodyc->setBoxExtend(Vec3(0.1f));
 		bodyc->setCollisionShapeType(BodyComponentCollisionShapeType::kAabb);
-		bodyc->teleportTo(trf);
+		bodyc->teleportTo(trf.getOrigin().xyz(), trf.getRotation().getRotationPart());
 
 		trf.setOrigin(trf.getOrigin() - Vec4(0.0f, 0.5f, 0.0f, 0.0f));
 
@@ -166,7 +170,7 @@ Error MyApp::sampleExtraInit()
 
 			BodyComponent* bodyc = monkey->newComponent<BodyComponent>();
 			bodyc->setCollisionShapeType(BodyComponentCollisionShapeType::kFromModelComponent);
-			bodyc->teleportTo(trf);
+			bodyc->teleportTo(trf.getOrigin().xyz(), trf.getRotation().getRotationPart());
 			bodyc->setMass(1.0f);
 			joint->addChild(monkey);
 
@@ -182,8 +186,9 @@ Error MyApp::sampleExtraInit()
 		SceneNode* node;
 		ANKI_CHECK(SceneGraph::getSingleton().newSceneNode("trigger", node));
 		TriggerComponent* triggerc = node->newComponent<TriggerComponent>();
-		triggerc->setSphereVolumeRadius(1.8f);
-		node->setLocalTransform(Transform(Vec4(4.0f, 0.5f, 0.0f, 0.0f), Mat3x4::getIdentity(), Vec4(1.0f, 1.0f, 1.0f, 0.0f)));
+		triggerc->setType(TriggerComponentShapeType::kSphere);
+		node->setLocalScale(Vec4(1.8f, 1.8f, 1.8f, 0.0f));
+		node->setLocalOrigin(Vec4(4.0f, 0.5f, 0.0f, 0.0f));
 	}
 
 	Input::getSingleton().lockCursor(true);
@@ -347,33 +352,41 @@ Error MyApp::userMainLoop(Bool& quit, [[maybe_unused]] Second elapsedTime)
 				dir.normalize();
 			}
 
-			playerc.setVelocity(speed, jumpSpeed, dir, crouch);
+			F32 speed1 = speed;
+			if(Input::getSingleton().getKey(KeyCode::kLeftShift))
+			{
+				speed1 *= 2.0f;
+			}
+			playerc.setVelocity(speed1, jumpSpeed, dir, crouch);
 		}
 	}
 
 	if(Input::getSingleton().getMouseButton(MouseButton::kLeft) == 1)
 	{
-		ANKI_LOGI("Firing a monkey");
+		ANKI_LOGI("Firing a grenade");
 
 		static U32 instance = 0;
 
 		Transform camTrf = SceneGraph::getSingleton().getActiveCameraNode().getWorldTransform();
-
-		SceneNode* monkey;
-		ANKI_CHECK(SceneGraph::getSingleton().newSceneNode(String().sprintf("FireMonkey%u", instance++).toCString(), monkey));
-		ModelComponent* modelc = monkey->newComponent<ModelComponent>();
-		modelc->loadModelResource("Assets/Suzanne_dynamic_36043dae41fe12d5.ankimdl");
+		const Vec3 newPos = camTrf.getOrigin().xyz() + camTrf.getRotation().getZAxis() * -3.0f;
+		camTrf.setOrigin(newPos.xyz0());
+
+		SceneNode* grenade;
+		ANKI_CHECK(SceneGraph::getSingleton().newSceneNode(String().sprintf("Grenade%u", instance++).toCString(), grenade));
+		grenade->setLocalScale(Vec3(2.8f).xyz0());
+		ModelComponent* modelc = grenade->newComponent<ModelComponent>();
+		modelc->loadModelResource("Assets/MESH_grenade_MTL_grenade_85852a78645563d8.ankimdl");
 		// monkey->getFirstComponentOfType<MoveComponent>().setLocalTransform(camTrf);
 
-		BodyComponent* bodyc = monkey->newComponent<BodyComponent>();
+		BodyComponent* bodyc = grenade->newComponent<BodyComponent>();
 		bodyc->setCollisionShapeType(BodyComponentCollisionShapeType::kFromModelComponent);
-		bodyc->teleportTo(camTrf);
+		bodyc->teleportTo(camTrf.getOrigin().xyz(), camTrf.getRotation().getRotationPart());
 		bodyc->setMass(1.0f);
 
-		bodyc->applyForce(camTrf.getRotation().getZAxis().xyz() * -1500.0f, Vec3(0.0f, 0.0f, 0.0f));
+		bodyc->applyForce(camTrf.getRotation().getZAxis().xyz() * -1200.0f, Vec3(0.0f, 0.0f, 0.0f));
 
 		// Create the destruction event
-		ANKI_CHECK(createDestructionEvent(monkey));
+		ANKI_CHECK(createDestructionEvent(grenade));
 	}
 
 	if(Input::getSingleton().getMouseButton(MouseButton::kRight) == 1)

Some files were not shown because too many files changed in this diff