Browse Source

More work on joints

Panagiotis Christopoulos Charitos 7 years ago
parent
commit
0f7989d6f1
41 changed files with 238 additions and 144 deletions
  1. 16 0
      samples/physics_playground/Main.cpp
  2. 7 1
      src/anki/physics/Common.cpp
  3. 5 5
      src/anki/physics/PhysicsBody.cpp
  4. 21 2
      src/anki/physics/PhysicsJoint.cpp
  5. 16 0
      src/anki/physics/PhysicsJoint.h
  6. 14 8
      src/anki/physics/PhysicsPlayerController.cpp
  7. 2 23
      src/anki/physics/PhysicsWorld.cpp
  8. 8 17
      src/anki/physics/PhysicsWorld.h
  9. 8 4
      src/anki/scene/BodyNode.cpp
  10. 6 6
      src/anki/scene/CameraNode.cpp
  11. 8 8
      src/anki/scene/DecalNode.cpp
  12. 8 8
      src/anki/scene/LightNode.cpp
  13. 4 4
      src/anki/scene/ModelNode.cpp
  14. 4 4
      src/anki/scene/OccluderNode.cpp
  15. 4 4
      src/anki/scene/ParticleEmitterNode.cpp
  16. 9 9
      src/anki/scene/PlayerNode.cpp
  17. 4 4
      src/anki/scene/ReflectionProbeNode.cpp
  18. 4 4
      src/anki/scene/ReflectionProxyNode.cpp
  19. 1 1
      src/anki/scene/SceneGraph.cpp
  20. 1 1
      src/anki/scene/components/BodyComponent.h
  21. 1 1
      src/anki/scene/components/DecalComponent.h
  22. 1 1
      src/anki/scene/components/FrustumComponent.cpp
  23. 1 1
      src/anki/scene/components/FrustumComponent.h
  24. 52 2
      src/anki/scene/components/JointComponent.cpp
  25. 9 1
      src/anki/scene/components/JointComponent.h
  26. 1 1
      src/anki/scene/components/LensFlareComponent.h
  27. 1 1
      src/anki/scene/components/LightComponent.cpp
  28. 1 1
      src/anki/scene/components/LightComponent.h
  29. 2 2
      src/anki/scene/components/MoveComponent.cpp
  30. 3 3
      src/anki/scene/components/MoveComponent.h
  31. 1 1
      src/anki/scene/components/PlayerControllerComponent.h
  32. 1 1
      src/anki/scene/components/ReflectionProxyComponent.cpp
  33. 1 1
      src/anki/scene/components/ReflectionProxyComponent.h
  34. 3 3
      src/anki/scene/components/SceneComponent.cpp
  35. 3 4
      src/anki/scene/components/SceneComponent.h
  36. 2 2
      src/anki/scene/components/ScriptComponent.cpp
  37. 1 1
      src/anki/scene/components/ScriptComponent.h
  38. 1 1
      src/anki/scene/components/SkinComponent.cpp
  39. 1 1
      src/anki/scene/components/SkinComponent.h
  40. 1 1
      src/anki/scene/components/SpatialComponent.cpp
  41. 1 1
      src/anki/scene/components/SpatialComponent.h

+ 16 - 0
samples/physics_playground/Main.cpp

@@ -31,6 +31,22 @@ Error MyApp::sampleExtraInit()
 
 
 	player->addChild(&cam);
 	player->addChild(&cam);
 
 
+	// Create a body component with joint
+	{
+		ModelNode* monkey;
+		ANKI_CHECK(
+			getSceneGraph().newSceneNode<ModelNode>("monkey_p2p", monkey, "assets/SuzanneMaterial-material.ankimdl"));
+
+		BodyNode* body;
+		ANKI_CHECK(getSceneGraph().newSceneNode<BodyNode>("bmonkey_p2p", body, "assets/Suzanne.ankicl"));
+		body->getComponent<BodyComponent>().setTransform(
+			Transform(Vec4(-2.0f, 4.0f, -3.0f, 0.0f), Mat3x4::getIdentity(), 1.0f));
+
+		body->addChild(monkey);
+
+		body->getComponent<JointComponent>().newHingeJoint(Vec3(0.2f, 1.0f, 0.0f), Vec3(1, 0, 0));
+	}
+
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 

+ 7 - 1
src/anki/physics/Common.cpp

@@ -12,7 +12,13 @@ namespace anki
 
 
 void PhysicsPtrDeleter::operator()(PhysicsObject* ptr)
 void PhysicsPtrDeleter::operator()(PhysicsObject* ptr)
 {
 {
-	ptr->getWorld().deleteObjectDeferred(ptr);
+	if(ptr == nullptr)
+	{
+		return;
+	}
+
+	auto alloc = ptr->getAllocator();
+	alloc.deleteInstance(ptr);
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 5 - 5
src/anki/physics/PhysicsBody.cpp

@@ -49,6 +49,8 @@ PhysicsBody::PhysicsBody(PhysicsWorld* world, const PhysicsBodyInitInfo& init)
 	cInfo.m_friction = init.m_friction;
 	cInfo.m_friction = init.m_friction;
 	m_body = getAllocator().newInstance<btRigidBody>(cInfo);
 	m_body = getAllocator().newInstance<btRigidBody>(cInfo);
 
 
+	// Add to world
+	auto lock = getWorld().lockWorld();
 	getWorld().getBtWorld()->addRigidBody(m_body);
 	getWorld().getBtWorld()->addRigidBody(m_body);
 }
 }
 
 
@@ -56,14 +58,12 @@ PhysicsBody::~PhysicsBody()
 {
 {
 	if(m_body)
 	if(m_body)
 	{
 	{
+		auto lock = getWorld().lockWorld();
 		getWorld().getBtWorld()->removeRigidBody(m_body);
 		getWorld().getBtWorld()->removeRigidBody(m_body);
-		getAllocator().deleteInstance(m_body);
 	}
 	}
 
 
-	if(m_motionState)
-	{
-		getAllocator().deleteInstance(m_motionState);
-	}
+	getAllocator().deleteInstance(m_body);
+	getAllocator().deleteInstance(m_motionState);
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 21 - 2
src/anki/physics/PhysicsJoint.cpp

@@ -19,9 +19,18 @@ PhysicsJoint::~PhysicsJoint()
 {
 {
 	if(m_joint)
 	if(m_joint)
 	{
 	{
+		auto lock = getWorld().lockWorld();
 		getWorld().getBtWorld()->removeConstraint(m_joint);
 		getWorld().getBtWorld()->removeConstraint(m_joint);
-		getAllocator().deleteInstance(m_joint);
 	}
 	}
+
+	getAllocator().deleteInstance(m_joint);
+}
+
+void PhysicsJoint::addToWorld()
+{
+	ANKI_ASSERT(m_joint);
+	auto lock = getWorld().lockWorld();
+	getWorld().getBtWorld()->addConstraint(m_joint);
 }
 }
 
 
 PhysicsPoint2PointJoint::PhysicsPoint2PointJoint(PhysicsWorld* world, PhysicsBodyPtr bodyA, const Vec3& relPos)
 PhysicsPoint2PointJoint::PhysicsPoint2PointJoint(PhysicsWorld* world, PhysicsBodyPtr bodyA, const Vec3& relPos)
@@ -31,7 +40,17 @@ PhysicsPoint2PointJoint::PhysicsPoint2PointJoint(PhysicsWorld* world, PhysicsBod
 	m_joint = getAllocator().newInstance<btPoint2PointConstraint>(*m_bodyA->getBtBody(), toBt(relPos));
 	m_joint = getAllocator().newInstance<btPoint2PointConstraint>(*m_bodyA->getBtBody(), toBt(relPos));
 	m_joint->setUserConstraintPtr(static_cast<PhysicsJoint*>(this));
 	m_joint->setUserConstraintPtr(static_cast<PhysicsJoint*>(this));
 
 
-	getWorld().getBtWorld()->addConstraint(m_joint);
+	addToWorld();
+}
+
+PhysicsHingeJoint::PhysicsHingeJoint(PhysicsWorld* world, PhysicsBodyPtr bodyA, const Vec3& relPos, const Vec3& axis)
+	: PhysicsJoint(world)
+{
+	m_bodyA = bodyA;
+	m_joint = getAllocator().newInstance<btHingeConstraint>(*m_bodyA->getBtBody(), toBt(relPos), toBt(axis));
+	m_joint->setUserConstraintPtr(static_cast<PhysicsJoint*>(this));
+
+	addToWorld();
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 16 - 0
src/anki/physics/PhysicsJoint.h

@@ -13,6 +13,7 @@ namespace anki
 /// @addtogroup physics
 /// @addtogroup physics
 /// @{
 /// @{
 
 
+/// Joint base class. Joints connect two (or a single one) rigid bodies together.
 class PhysicsJoint : public PhysicsObject
 class PhysicsJoint : public PhysicsObject
 {
 {
 public:
 public:
@@ -20,12 +21,20 @@ public:
 
 
 	~PhysicsJoint();
 	~PhysicsJoint();
 
 
+	void setBreakingImpulseThreshold(F32 impulse)
+	{
+		m_joint->setBreakingImpulseThreshold(impulse);
+	}
+
 protected:
 protected:
 	btTypedConstraint* m_joint = nullptr;
 	btTypedConstraint* m_joint = nullptr;
 	PhysicsBodyPtr m_bodyA;
 	PhysicsBodyPtr m_bodyA;
 	PhysicsBodyPtr m_bodyB;
 	PhysicsBodyPtr m_bodyB;
+
+	void addToWorld();
 };
 };
 
 
+/// Point 2 point joint.
 class PhysicsPoint2PointJoint : public PhysicsJoint
 class PhysicsPoint2PointJoint : public PhysicsJoint
 {
 {
 public:
 public:
@@ -33,6 +42,13 @@ public:
 
 
 	PhysicsPoint2PointJoint(PhysicsWorld* world, PhysicsBodyPtr bodyA, PhysicsBodyPtr bodyB);
 	PhysicsPoint2PointJoint(PhysicsWorld* world, PhysicsBodyPtr bodyA, PhysicsBodyPtr bodyB);
 };
 };
+
+/// Hinge joint.
+class PhysicsHingeJoint : public PhysicsJoint
+{
+public:
+	PhysicsHingeJoint(PhysicsWorld* world, PhysicsBodyPtr bodyA, const Vec3& relPos, const Vec3& axis);
+};
 /// @}
 /// @}
 
 
 } // end namespace anki
 } // end namespace anki

+ 14 - 8
src/anki/physics/PhysicsPlayerController.cpp

@@ -24,12 +24,15 @@ PhysicsPlayerController::PhysicsPlayerController(PhysicsWorld* world, const Phys
 	m_controller = getAllocator().newInstance<btKinematicCharacterController>(
 	m_controller = getAllocator().newInstance<btKinematicCharacterController>(
 		m_ghostObject, m_convexShape, init.m_stepHeight, btVector3(0, 1, 0));
 		m_ghostObject, m_convexShape, init.m_stepHeight, btVector3(0, 1, 0));
 
 
-	btDynamicsWorld* btworld = getWorld().getBtWorld();
+	{
+		auto lock = getWorld().lockWorld();
+		btDynamicsWorld* btworld = getWorld().getBtWorld();
 
 
-	btworld->addCollisionObject(m_ghostObject,
-		btBroadphaseProxy::CharacterFilter,
-		btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter);
-	btworld->addAction(m_controller);
+		btworld->addCollisionObject(m_ghostObject,
+			btBroadphaseProxy::CharacterFilter,
+			btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter);
+		btworld->addAction(m_controller);
+	}
 
 
 	// Need to call this else the player is upside down
 	// Need to call this else the player is upside down
 	moveToPosition(init.m_position);
 	moveToPosition(init.m_position);
@@ -37,8 +40,11 @@ PhysicsPlayerController::PhysicsPlayerController(PhysicsWorld* world, const Phys
 
 
 PhysicsPlayerController::~PhysicsPlayerController()
 PhysicsPlayerController::~PhysicsPlayerController()
 {
 {
-	getWorld().getBtWorld()->removeAction(m_controller);
-	getWorld().getBtWorld()->removeCollisionObject(m_ghostObject);
+	{
+		auto lock = getWorld().lockWorld();
+		getWorld().getBtWorld()->removeAction(m_controller);
+		getWorld().getBtWorld()->removeCollisionObject(m_ghostObject);
+	}
 
 
 	getAllocator().deleteInstance(m_controller);
 	getAllocator().deleteInstance(m_controller);
 	getAllocator().deleteInstance(m_ghostObject);
 	getAllocator().deleteInstance(m_ghostObject);
@@ -47,7 +53,7 @@ PhysicsPlayerController::~PhysicsPlayerController()
 
 
 void PhysicsPlayerController::moveToPosition(const Vec4& position)
 void PhysicsPlayerController::moveToPosition(const Vec4& position)
 {
 {
-	ANKI_LOCK_PHYS_WORLD();
+	auto lock = getWorld().lockWorld();
 
 
 	getWorld().getBtWorld()->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(
 	getWorld().getBtWorld()->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(
 		m_ghostObject->getBroadphaseHandle(), getWorld().getBtWorld()->getDispatcher());
 		m_ghostObject->getBroadphaseHandle(), getWorld().getBtWorld()->getDispatcher());

+ 2 - 23
src/anki/physics/PhysicsWorld.cpp

@@ -32,8 +32,6 @@ PhysicsWorld::PhysicsWorld()
 
 
 PhysicsWorld::~PhysicsWorld()
 PhysicsWorld::~PhysicsWorld()
 {
 {
-	cleanupMarkedForDeletion();
-
 	m_alloc.deleteInstance(m_world);
 	m_alloc.deleteInstance(m_world);
 	m_alloc.deleteInstance(m_solver);
 	m_alloc.deleteInstance(m_solver);
 	m_alloc.deleteInstance(m_dispatcher);
 	m_alloc.deleteInstance(m_dispatcher);
@@ -72,30 +70,11 @@ Error PhysicsWorld::create(AllocAlignedCallback allocCb, void* allocCbData)
 
 
 Error PhysicsWorld::update(Second dt)
 Error PhysicsWorld::update(Second dt)
 {
 {
-	// Do cleanup of marked for deletion
-	cleanupMarkedForDeletion();
-
 	// Update
 	// Update
-	m_world->stepSimulation(dt, 1, 1.0 / 60.0);
+	auto lock = lockWorld();
+	m_world->stepSimulation(dt, 2, 1.0 / 60.0);
 
 
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-void PhysicsWorld::cleanupMarkedForDeletion()
-{
-	LockGuard<Mutex> lock(m_mtx);
-
-	while(!m_forDeletion.isEmpty())
-	{
-		auto it = m_forDeletion.getBegin();
-		PhysicsObject* obj = *it;
-
-		// Remove from objects marked for deletion
-		m_forDeletion.erase(m_alloc, it);
-
-		// Finaly, delete it
-		m_alloc.deleteInstance(obj);
-	}
-}
-
 } // end namespace anki
 } // end namespace anki

+ 8 - 17
src/anki/physics/PhysicsWorld.h

@@ -27,7 +27,6 @@ public:
 	PhysicsPtr<T> newInstance(TArgs&&... args)
 	PhysicsPtr<T> newInstance(TArgs&&... args)
 	{
 	{
 		PhysicsPtr<T> out;
 		PhysicsPtr<T> out;
-		LockGuard<Mutex> lock(m_mtx);
 		T* ptr = m_alloc.template newInstance<T>(this, std::forward<TArgs>(args)...);
 		T* ptr = m_alloc.template newInstance<T>(this, std::forward<TArgs>(args)...);
 		out.reset(ptr);
 		out.reset(ptr);
 		return out;
 		return out;
@@ -36,7 +35,12 @@ public:
 	/// Do the update.
 	/// Do the update.
 	Error update(Second dt);
 	Error update(Second dt);
 
 
-	HeapAllocator<U8> getAllocator()
+	HeapAllocator<U8> getAllocator() const
+	{
+		return m_alloc;
+	}
+
+	HeapAllocator<U8>& getAllocator()
 	{
 	{
 		return m_alloc;
 		return m_alloc;
 	}
 	}
@@ -48,15 +52,9 @@ anki_internal:
 		return m_world;
 		return m_world;
 	}
 	}
 
 
-	void deleteObjectDeferred(PhysicsObject* obj)
-	{
-		LockGuard<Mutex> lock(m_mtx);
-		m_forDeletion.pushBack(m_alloc, obj);
-	}
-
 	F32 getCollisionMargin() const
 	F32 getCollisionMargin() const
 	{
 	{
-		return 0.04;
+		return 0.04f;
 	}
 	}
 
 
 	ANKI_USE_RESULT LockGuard<Mutex> lockWorld() const
 	ANKI_USE_RESULT LockGuard<Mutex> lockWorld() const
@@ -66,6 +64,7 @@ anki_internal:
 
 
 private:
 private:
 	HeapAllocator<U8> m_alloc;
 	HeapAllocator<U8> m_alloc;
+	mutable Mutex m_mtx;
 
 
 	btBroadphaseInterface* m_broadphase = nullptr;
 	btBroadphaseInterface* m_broadphase = nullptr;
 	btGhostPairCallback* m_gpc = nullptr;
 	btGhostPairCallback* m_gpc = nullptr;
@@ -75,17 +74,9 @@ private:
 	btSequentialImpulseConstraintSolver* m_solver = nullptr;
 	btSequentialImpulseConstraintSolver* m_solver = nullptr;
 	btDiscreteDynamicsWorld* m_world = nullptr;
 	btDiscreteDynamicsWorld* m_world = nullptr;
 
 
-	mutable Mutex m_mtx;
-	List<PhysicsObject*> m_forDeletion;
-
 	template<typename T, typename... TArgs>
 	template<typename T, typename... TArgs>
 	PhysicsPtr<T> newObjectInternal(TArgs&&... args);
 	PhysicsPtr<T> newObjectInternal(TArgs&&... args);
-
-	void cleanupMarkedForDeletion();
 };
 };
-
-/// Lock the bullet physics world.
-#define ANKI_LOCK_PHYS_WORLD() auto lock = getWorld().lockWorld()
 /// @}
 /// @}
 
 
 } // end namespace anki
 } // end namespace anki

+ 8 - 4
src/anki/scene/BodyNode.cpp

@@ -6,6 +6,7 @@
 #include <anki/scene/BodyNode.h>
 #include <anki/scene/BodyNode.h>
 #include <anki/scene/components/BodyComponent.h>
 #include <anki/scene/components/BodyComponent.h>
 #include <anki/scene/components/MoveComponent.h>
 #include <anki/scene/components/MoveComponent.h>
+#include <anki/scene/components/JointComponent.h>
 #include <anki/scene/SceneGraph.h>
 #include <anki/scene/SceneGraph.h>
 #include <anki/physics/PhysicsWorld.h>
 #include <anki/physics/PhysicsWorld.h>
 #include <anki/resource/ResourceManager.h>
 #include <anki/resource/ResourceManager.h>
@@ -22,15 +23,15 @@ public:
 	{
 	{
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode& node, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		BodyComponent& bodyc = node.getComponent<BodyComponent>();
+		BodyComponent& bodyc = m_node->getComponent<BodyComponent>();
 
 
-		if(bodyc.getTimestamp() == node.getGlobalTimestamp())
+		if(bodyc.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
-			MoveComponent& move = node.getComponent<MoveComponent>();
+			MoveComponent& move = m_node->getComponent<MoveComponent>();
 			move.setLocalTransform(bodyc.getTransform());
 			move.setLocalTransform(bodyc.getTransform());
 		}
 		}
 
 
@@ -58,6 +59,9 @@ Error BodyNode::init(const CString& resourceFname)
 	init.m_shape = m_rsrc->getShape();
 	init.m_shape = m_rsrc->getShape();
 	m_body = getSceneGraph().getPhysicsWorld().newInstance<PhysicsBody>(init);
 	m_body = getSceneGraph().getPhysicsWorld().newInstance<PhysicsBody>(init);
 
 
+	// Joint component
+	newComponent<JointComponent>(this);
+
 	// Body component
 	// Body component
 	newComponent<BodyComponent>(this, m_body);
 	newComponent<BodyComponent>(this, m_body);
 
 

+ 6 - 6
src/anki/scene/CameraNode.cpp

@@ -19,14 +19,14 @@ public:
 	{
 	{
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode& node, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		MoveComponent& move = node.getComponent<MoveComponent>();
+		MoveComponent& move = m_node->getComponent<MoveComponent>();
 		if(move.getTimestamp() == getGlobalTimestamp())
 		if(move.getTimestamp() == getGlobalTimestamp())
 		{
 		{
-			CameraNode& cam = static_cast<CameraNode&>(node);
+			CameraNode& cam = *static_cast<CameraNode*>(m_node);
 			cam.onMoveComponentUpdate(move);
 			cam.onMoveComponentUpdate(move);
 		}
 		}
 
 
@@ -43,14 +43,14 @@ public:
 	{
 	{
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode& node, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		FrustumComponent& fr = node.getComponent<FrustumComponent>();
+		FrustumComponent& fr = m_node->getComponent<FrustumComponent>();
 		if(fr.getTimestamp() == getGlobalTimestamp())
 		if(fr.getTimestamp() == getGlobalTimestamp())
 		{
 		{
-			CameraNode& cam = static_cast<CameraNode&>(node);
+			CameraNode& cam = *static_cast<CameraNode*>(m_node);
 			cam.onFrustumComponentUpdate(fr);
 			cam.onFrustumComponentUpdate(fr);
 		}
 		}
 
 

+ 8 - 8
src/anki/scene/DecalNode.cpp

@@ -20,15 +20,15 @@ public:
 	{
 	{
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode& node, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		MoveComponent& movec = node.getComponent<MoveComponent>();
+		MoveComponent& movec = m_node->getComponent<MoveComponent>();
 
 
-		if(movec.getTimestamp() == node.getGlobalTimestamp())
+		if(movec.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
-			static_cast<DecalNode&>(node).onMove(movec);
+			static_cast<DecalNode*>(m_node)->onMove(movec);
 		}
 		}
 
 
 		return Error::NONE;
 		return Error::NONE;
@@ -44,15 +44,15 @@ public:
 	{
 	{
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode& node, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		DecalComponent& decalc = node.getComponent<DecalComponent>();
+		DecalComponent& decalc = m_node->getComponent<DecalComponent>();
 
 
-		if(decalc.getTimestamp() == node.getGlobalTimestamp())
+		if(decalc.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
-			static_cast<DecalNode&>(node).onDecalUpdated();
+			static_cast<DecalNode*>(m_node)->onDecalUpdated();
 		}
 		}
 
 
 		return Error::NONE;
 		return Error::NONE;

+ 8 - 8
src/anki/scene/LightNode.cpp

@@ -21,13 +21,13 @@ public:
 	{
 	{
 	}
 	}
 
 
-	Error update(SceneNode& node, Second, Second, Bool& updated) override
+	Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
-		LightNode& lnode = static_cast<LightNode&>(node);
+		LightNode& lnode = *static_cast<LightNode*>(m_node);
 
 
-		const MoveComponent& move = node.getComponentAt<MoveComponent>(0);
-		if(move.getTimestamp() == node.getGlobalTimestamp())
+		const MoveComponent& move = m_node->getComponentAt<MoveComponent>(0);
+		if(move.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
 			// Move updated
 			// Move updated
 			lnode.onMoveUpdate(move);
 			lnode.onMoveUpdate(move);
@@ -46,13 +46,13 @@ public:
 	{
 	{
 	}
 	}
 
 
-	Error update(SceneNode& node, Second, Second, Bool& updated) override
+	Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
-		LightNode& lnode = static_cast<LightNode&>(node);
+		LightNode& lnode = *static_cast<LightNode*>(m_node);
 
 
-		LightComponent& light = node.getComponentAt<LightComponent>(getIndex() - 1);
-		if(light.getTimestamp() == node.getGlobalTimestamp())
+		LightComponent& light = m_node->getComponentAt<LightComponent>(getIndex() - 1);
+		if(light.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
 			// Shape updated
 			// Shape updated
 			lnode.onShapeUpdate(light);
 			lnode.onShapeUpdate(light);

+ 4 - 4
src/anki/scene/ModelNode.cpp

@@ -135,14 +135,14 @@ public:
 	{
 	{
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode& node, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		const MoveComponent& move = node.getComponent<MoveComponent>();
-		if(move.getTimestamp() == node.getGlobalTimestamp())
+		const MoveComponent& move = m_node->getComponent<MoveComponent>();
+		if(move.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
-			ModelNode& mnode = static_cast<ModelNode&>(node);
+			ModelNode& mnode = *static_cast<ModelNode*>(m_node);
 			mnode.onMoveComponentUpdate(move);
 			mnode.onMoveComponentUpdate(move);
 		}
 		}
 
 

+ 4 - 4
src/anki/scene/OccluderNode.cpp

@@ -21,14 +21,14 @@ public:
 	{
 	{
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode& node, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		MoveComponent& move = node.getComponent<MoveComponent>();
-		if(move.getTimestamp() == node.getGlobalTimestamp())
+		MoveComponent& move = m_node->getComponent<MoveComponent>();
+		if(move.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
-			OccluderNode& mnode = static_cast<OccluderNode&>(node);
+			OccluderNode& mnode = *static_cast<OccluderNode*>(m_node);
 			mnode.onMoveComponentUpdate(move);
 			mnode.onMoveComponentUpdate(move);
 		}
 		}
 
 

+ 4 - 4
src/anki/scene/ParticleEmitterNode.cpp

@@ -192,14 +192,14 @@ public:
 	{
 	{
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode& node, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false; // Don't care about updates for this component
 		updated = false; // Don't care about updates for this component
 
 
-		MoveComponent& move = node.getComponent<MoveComponent>();
-		if(move.getTimestamp() == node.getGlobalTimestamp())
+		MoveComponent& move = m_node->getComponent<MoveComponent>();
+		if(move.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
-			static_cast<ParticleEmitterNode&>(node).onMoveComponentUpdate(move);
+			static_cast<ParticleEmitterNode*>(m_node)->onMoveComponentUpdate(move);
 		}
 		}
 
 
 		return Error::NONE;
 		return Error::NONE;

+ 9 - 9
src/anki/scene/PlayerNode.cpp

@@ -23,19 +23,19 @@ public:
 	{
 	{
 	}
 	}
 
 
-	Error update(SceneNode& node, Second, Second, Bool& updated) override
+	Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		PlayerControllerComponent& playerc = node.getComponent<PlayerControllerComponent>();
-		const Input& in = node.getSceneGraph().getInput();
+		PlayerControllerComponent& playerc = m_node->getComponent<PlayerControllerComponent>();
+		const Input& in = m_node->getSceneGraph().getInput();
 		const F32 ang = toRad(7.0);
 		const F32 ang = toRad(7.0);
 
 
 		F32 y = in.getMousePosition().y();
 		F32 y = in.getMousePosition().y();
 		F32 x = in.getMousePosition().x();
 		F32 x = in.getMousePosition().x();
-		if(playerc.getTimestamp() == node.getGlobalTimestamp() || y != 0.0 || x != 0.0)
+		if(playerc.getTimestamp() == m_node->getGlobalTimestamp() || y != 0.0 || x != 0.0)
 		{
 		{
-			MoveComponent& move = node.getComponent<MoveComponent>();
+			MoveComponent& move = m_node->getComponent<MoveComponent>();
 
 
 			// Set origin
 			// Set origin
 			Vec4 origin = playerc.getTransform().getOrigin();
 			Vec4 origin = playerc.getTransform().getOrigin();
@@ -69,13 +69,13 @@ public:
 	{
 	{
 	}
 	}
 
 
-	Error update(SceneNode& node, Second, Second, Bool& updated) override
+	Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		PlayerControllerComponent& playerc = node.getComponent<PlayerControllerComponent>();
-		MoveComponent& move = node.getComponent<MoveComponent>();
-		const Input& in = node.getSceneGraph().getInput();
+		PlayerControllerComponent& playerc = m_node->getComponent<PlayerControllerComponent>();
+		MoveComponent& move = m_node->getComponent<MoveComponent>();
+		const Input& in = m_node->getSceneGraph().getInput();
 
 
 		const F32 speed = 0.5;
 		const F32 speed = 0.5;
 
 

+ 4 - 4
src/anki/scene/ReflectionProbeNode.cpp

@@ -26,15 +26,15 @@ public:
 	{
 	{
 	}
 	}
 
 
-	Error update(SceneNode& node, Second, Second, Bool& updated) override
+	Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		MoveComponent& move = node.getComponent<MoveComponent>();
-		if(move.getTimestamp() == node.getGlobalTimestamp())
+		MoveComponent& move = m_node->getComponent<MoveComponent>();
+		if(move.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
 			// Move updated
 			// Move updated
-			ReflectionProbeNode& dnode = static_cast<ReflectionProbeNode&>(node);
+			ReflectionProbeNode& dnode = *static_cast<ReflectionProbeNode*>(m_node);
 			dnode.onMoveUpdate(move);
 			dnode.onMoveUpdate(move);
 		}
 		}
 
 

+ 4 - 4
src/anki/scene/ReflectionProxyNode.cpp

@@ -22,15 +22,15 @@ public:
 	{
 	{
 	}
 	}
 
 
-	Error update(SceneNode& node, Second, Second, Bool& updated) final
+	Error update(Second, Second, Bool& updated) final
 	{
 	{
 		updated = false;
 		updated = false;
 
 
-		MoveComponent& move = node.getComponent<MoveComponent>();
-		if(move.getTimestamp() == node.getGlobalTimestamp())
+		MoveComponent& move = m_node->getComponent<MoveComponent>();
+		if(move.getTimestamp() == m_node->getGlobalTimestamp())
 		{
 		{
 			// Move updated
 			// Move updated
-			ReflectionProxyNode& dnode = static_cast<ReflectionProxyNode&>(node);
+			ReflectionProxyNode& dnode = *static_cast<ReflectionProxyNode*>(m_node);
 			dnode.onMoveUpdate(move);
 			dnode.onMoveUpdate(move);
 		}
 		}
 
 

+ 1 - 1
src/anki/scene/SceneGraph.cpp

@@ -272,7 +272,7 @@ Error SceneGraph::updateNode(Second prevTime, Second crntTime, SceneNode& node)
 	Timestamp componentTimestam = 0;
 	Timestamp componentTimestam = 0;
 	err = node.iterateComponents([&](SceneComponent& comp) -> Error {
 	err = node.iterateComponents([&](SceneComponent& comp) -> Error {
 		Bool updated = false;
 		Bool updated = false;
-		Error e = comp.updateReal(node, prevTime, crntTime, updated);
+		Error e = comp.updateReal(prevTime, crntTime, updated);
 		componentTimestam = max(componentTimestam, comp.getTimestamp());
 		componentTimestam = max(componentTimestam, comp.getTimestamp());
 
 
 		return e;
 		return e;

+ 1 - 1
src/anki/scene/components/BodyComponent.h

@@ -43,7 +43,7 @@ public:
 		return m_body;
 		return m_body;
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode&, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		m_trf = m_body->getTransform(updated);
 		m_trf = m_body->getTransform(updated);
 		return Error::NONE;
 		return Error::NONE;

+ 1 - 1
src/anki/scene/components/DecalComponent.h

@@ -74,7 +74,7 @@ public:
 	}
 	}
 
 
 	/// Implements SceneComponent::update.
 	/// Implements SceneComponent::update.
-	ANKI_USE_RESULT Error update(SceneNode&, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		updated = m_markedForUpdate;
 		updated = m_markedForUpdate;
 
 

+ 1 - 1
src/anki/scene/components/FrustumComponent.cpp

@@ -26,7 +26,7 @@ FrustumComponent::~FrustumComponent()
 	m_coverageBuff.m_depthMap.destroy(getAllocator());
 	m_coverageBuff.m_depthMap.destroy(getAllocator());
 }
 }
 
 
-Error FrustumComponent::update(SceneNode& node, Second, Second, Bool& updated)
+Error FrustumComponent::update(Second, Second, Bool& updated)
 {
 {
 	updated = false;
 	updated = false;
 
 

+ 1 - 1
src/anki/scene/components/FrustumComponent.h

@@ -111,7 +111,7 @@ public:
 
 
 	/// @name SceneComponent overrides
 	/// @name SceneComponent overrides
 	/// @{
 	/// @{
-	ANKI_USE_RESULT Error update(SceneNode&, Second, Second, Bool& updated) override;
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override;
 	/// @}
 	/// @}
 
 
 	void setEnabledVisibilityTests(FrustumComponentVisibilityTestFlag bits)
 	void setEnabledVisibilityTests(FrustumComponentVisibilityTestFlag bits)

+ 52 - 2
src/anki/scene/components/JointComponent.cpp

@@ -16,14 +16,58 @@ JointComponent::~JointComponent()
 	m_jointList.destroy(getAllocator());
 	m_jointList.destroy(getAllocator());
 }
 }
 
 
-void JointComponent::newPoint2PointJoint(const Vec3& relPosA)
+Vec3 JointComponent::computeLocalPivotFromFactors(const PhysicsBodyPtr& body, const Vec3& factors)
+{
+	btTransform identityTrf;
+	identityTrf.setIdentity();
+	btVector3 aabbmin, aabbmax, center;
+	body->getBtBody()->getCollisionShape()->getAabb(identityTrf, aabbmin, aabbmax);
+
+	center = (aabbmin + aabbmax) * 0.5f;
+
+	Vec3 out;
+	for(U i = 0; i < 3; ++i)
+	{
+		const F32 factor = factors[i];
+		ANKI_ASSERT(factor >= -1.0f || factor <= 1.0f);
+		const F32 dist = aabbmax[i] - center[i];
+		out[i] = dist * factor + center[i];
+	}
+
+	return out;
+}
+
+void JointComponent::newPoint2PointJoint(const Vec3& relPosFactor, F32 brakingImpulse)
+{
+	BodyComponent* bodyc = m_node->tryGetComponent<BodyComponent>();
+
+	if(bodyc)
+	{
+		Vec3 relPos = computeLocalPivotFromFactors(bodyc->getPhysicsBody(), relPosFactor);
+
+		PhysicsJointPtr joint =
+			getSceneGraph().getPhysicsWorld().newInstance<PhysicsPoint2PointJoint>(bodyc->getPhysicsBody(), relPos);
+		joint->setBreakingImpulseThreshold(brakingImpulse);
+
+		m_jointList.pushBack(getAllocator(), joint);
+	}
+	else
+	{
+		ANKI_SCENE_LOGW("Can't create new joint. The node is missing a body component");
+	}
+}
+
+void JointComponent::newHingeJoint(const Vec3& relPosFactor, const Vec3& axis, F32 brakingImpulse)
 {
 {
 	BodyComponent* bodyc = m_node->tryGetComponent<BodyComponent>();
 	BodyComponent* bodyc = m_node->tryGetComponent<BodyComponent>();
 
 
 	if(bodyc)
 	if(bodyc)
 	{
 	{
+		Vec3 relPos = computeLocalPivotFromFactors(bodyc->getPhysicsBody(), relPosFactor);
+
 		PhysicsJointPtr joint =
 		PhysicsJointPtr joint =
-			getSceneGraph().getPhysicsWorld().newInstance<PhysicsPoint2PointJoint>(bodyc->getPhysicsBody(), relPosA);
+			getSceneGraph().getPhysicsWorld().newInstance<PhysicsHingeJoint>(bodyc->getPhysicsBody(), relPos, axis);
+		joint->setBreakingImpulseThreshold(brakingImpulse);
 
 
 		m_jointList.pushBack(getAllocator(), joint);
 		m_jointList.pushBack(getAllocator(), joint);
 	}
 	}
@@ -33,4 +77,10 @@ void JointComponent::newPoint2PointJoint(const Vec3& relPosA)
 	}
 	}
 }
 }
 
 
+Error JointComponent::update(Second prevTime, Second crntTime, Bool& updated)
+{
+	// TODO
+	return Error::NONE;
+}
+
 } // end namespace anki
 } // end namespace anki

+ 9 - 1
src/anki/scene/components/JointComponent.h

@@ -27,10 +27,18 @@ public:
 
 
 	~JointComponent();
 	~JointComponent();
 
 
-	void newPoint2PointJoint(const Vec3& relPosA);
+	void newPoint2PointJoint(const Vec3& relPosFactor, F32 brakingImpulse = MAX_F32);
+
+	void newHingeJoint(const Vec3& relPosFactor, const Vec3& axis, F32 brakingImpulse = MAX_F32);
+
+	ANKI_USE_RESULT Error update(Second prevTime, Second crntTime, Bool& updated) override;
 
 
 private:
 private:
 	List<PhysicsJointPtr> m_jointList;
 	List<PhysicsJointPtr> m_jointList;
+
+	/// Given a 3 coodrinates that lie in [-1.0, +1.0] compute a pivot point that lies into the AABB of the collision
+	/// shape of the body.
+	static Vec3 computeLocalPivotFromFactors(const PhysicsBodyPtr& body, const Vec3& factors);
 };
 };
 /// @}
 /// @}
 
 

+ 1 - 1
src/anki/scene/components/LensFlareComponent.h

@@ -74,7 +74,7 @@ public:
 	}
 	}
 
 
 	/// Implements SceneComponent::update.
 	/// Implements SceneComponent::update.
-	Error update(SceneNode& node, Second prevTime, Second crntTime, Bool& updated) override
+	Error update(Second prevTime, Second crntTime, Bool& updated) override
 	{
 	{
 		updated = false;
 		updated = false;
 		return Error::NONE;
 		return Error::NONE;

+ 1 - 1
src/anki/scene/components/LightComponent.cpp

@@ -17,7 +17,7 @@ LightComponent::LightComponent(SceneNode* node, LightComponentType type)
 	m_radius = 1.0;
 	m_radius = 1.0;
 }
 }
 
 
-Error LightComponent::update(SceneNode&, Second, Second, Bool& updated)
+Error LightComponent::update(Second, Second, Bool& updated)
 {
 {
 	updated = false;
 	updated = false;
 
 

+ 1 - 1
src/anki/scene/components/LightComponent.h

@@ -121,7 +121,7 @@ public:
 		m_flags.set(SHADOW, x);
 		m_flags.set(SHADOW, x);
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode&, Second, Second, Bool& updated) override;
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override;
 
 
 	void setupPointLightQueueElement(PointLightQueueElement& el) const
 	void setupPointLightQueueElement(PointLightQueueElement& el) const
 	{
 	{

+ 2 - 2
src/anki/scene/components/MoveComponent.cpp

@@ -20,9 +20,9 @@ MoveComponent::~MoveComponent()
 {
 {
 }
 }
 
 
-Error MoveComponent::update(SceneNode& node, Second, Second, Bool& updated)
+Error MoveComponent::update(Second, Second, Bool& updated)
 {
 {
-	updated = updateWorldTransform(node);
+	updated = updateWorldTransform(*m_node);
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 

+ 3 - 3
src/anki/scene/components/MoveComponent.h

@@ -111,11 +111,11 @@ public:
 	/// Update self and children world transform recursively, if root node. Need to call this at every frame.
 	/// Update self and children world transform recursively, if root node. Need to call this at every frame.
 	/// @note Don't update if child because we start from roots and go to children and we don't want a child to be
 	/// @note Don't update if child because we start from roots and go to children and we don't want a child to be
 	///       updated before the parent
 	///       updated before the parent
-	ANKI_USE_RESULT Error update(SceneNode&, Second, Second, Bool& updated) override;
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override;
 
 
-	ANKI_USE_RESULT Error onUpdate(SceneNode& node, Second prevTime, Second crntTime) final
+	ANKI_USE_RESULT Error onUpdate(Second prevTime, Second crntTime) final
 	{
 	{
-		return onMoveComponentUpdate(node, prevTime, crntTime);
+		return onMoveComponentUpdate(*m_node, prevTime, crntTime);
 	}
 	}
 	/// @}
 	/// @}
 
 

+ 1 - 1
src/anki/scene/components/PlayerControllerComponent.h

@@ -48,7 +48,7 @@ public:
 		m_player->moveToPosition(pos);
 		m_player->moveToPosition(pos);
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode&, Second, Second, Bool& updated) override
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override
 	{
 	{
 		m_trf = m_player->getTransform(updated);
 		m_trf = m_player->getTransform(updated);
 		return Error::NONE;
 		return Error::NONE;

+ 1 - 1
src/anki/scene/components/ReflectionProxyComponent.cpp

@@ -18,7 +18,7 @@ void ReflectionProxyComponent::setQuad(U index, const Vec4& a, const Vec4& b, co
 	m_faces[index].m_vertices[3] = d;
 	m_faces[index].m_vertices[3] = d;
 }
 }
 
 
-Error ReflectionProxyComponent::update(SceneNode& node, Second prevTime, Second crntTime, Bool& updated)
+Error ReflectionProxyComponent::update(Second prevTime, Second crntTime, Bool& updated)
 {
 {
 	if(m_dirty)
 	if(m_dirty)
 	{
 	{

+ 1 - 1
src/anki/scene/components/ReflectionProxyComponent.h

@@ -48,7 +48,7 @@ public:
 		return m_faces;
 		return m_faces;
 	}
 	}
 
 
-	ANKI_USE_RESULT Error update(SceneNode& node, Second prevTime, Second crntTime, Bool& updated) final;
+	ANKI_USE_RESULT Error update(Second prevTime, Second crntTime, Bool& updated) final;
 
 
 private:
 private:
 	DynamicArray<Face> m_faces; ///< Quads.
 	DynamicArray<Face> m_faces; ///< Quads.

+ 3 - 3
src/anki/scene/components/SceneComponent.cpp

@@ -35,12 +35,12 @@ Timestamp SceneComponent::getGlobalTimestamp() const
 	return m_node->getGlobalTimestamp();
 	return m_node->getGlobalTimestamp();
 }
 }
 
 
-Error SceneComponent::updateReal(SceneNode& node, Second prevTime, Second crntTime, Bool& updated)
+Error SceneComponent::updateReal(Second prevTime, Second crntTime, Bool& updated)
 {
 {
-	Error err = update(node, prevTime, crntTime, updated);
+	Error err = update(prevTime, crntTime, updated);
 	if(!err && updated)
 	if(!err && updated)
 	{
 	{
-		err = onUpdate(node, prevTime, crntTime);
+		err = onUpdate(prevTime, crntTime);
 
 
 		if(!err)
 		if(!err)
 		{
 		{

+ 3 - 4
src/anki/scene/components/SceneComponent.h

@@ -64,24 +64,23 @@ public:
 	Timestamp getGlobalTimestamp() const;
 	Timestamp getGlobalTimestamp() const;
 
 
 	/// Do some updating
 	/// Do some updating
-	/// @param[in,out] node Scene node of this component.
 	/// @param prevTime Previous update time.
 	/// @param prevTime Previous update time.
 	/// @param crntTime Current update time.
 	/// @param crntTime Current update time.
 	/// @param[out] updated true if an update happened.
 	/// @param[out] updated true if an update happened.
-	virtual ANKI_USE_RESULT Error update(SceneNode& node, Second prevTime, Second crntTime, Bool& updated)
+	virtual ANKI_USE_RESULT Error update(Second prevTime, Second crntTime, Bool& updated)
 	{
 	{
 		updated = false;
 		updated = false;
 		return Error::NONE;
 		return Error::NONE;
 	}
 	}
 
 
 	/// Called if SceneComponent::update returned true.
 	/// Called if SceneComponent::update returned true.
-	virtual ANKI_USE_RESULT Error onUpdate(SceneNode& node, Second prevTime, Second crntTime)
+	virtual ANKI_USE_RESULT Error onUpdate(Second prevTime, Second crntTime)
 	{
 	{
 		return Error::NONE;
 		return Error::NONE;
 	}
 	}
 
 
 	/// Called only by the SceneGraph
 	/// Called only by the SceneGraph
-	ANKI_USE_RESULT Error updateReal(SceneNode& node, Second prevTime, Second crntTime, Bool& updated);
+	ANKI_USE_RESULT Error updateReal(Second prevTime, Second crntTime, Bool& updated);
 
 
 	U64 getUuid() const
 	U64 getUuid() const
 	{
 	{

+ 2 - 2
src/anki/scene/components/ScriptComponent.cpp

@@ -36,7 +36,7 @@ Error ScriptComponent::load(CString fname)
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-Error ScriptComponent::update(SceneNode& node, Second prevTime, Second crntTime, Bool& updated)
+Error ScriptComponent::update(Second prevTime, Second crntTime, Bool& updated)
 {
 {
 	updated = false;
 	updated = false;
 	lua_State* lua = &m_env->getLuaState();
 	lua_State* lua = &m_env->getLuaState();
@@ -45,7 +45,7 @@ Error ScriptComponent::update(SceneNode& node, Second prevTime, Second crntTime,
 	lua_getglobal(lua, "update");
 	lua_getglobal(lua, "update");
 
 
 	// Push args
 	// Push args
-	LuaBinder::pushVariableToTheStack(lua, &node);
+	LuaBinder::pushVariableToTheStack(lua, m_node);
 	lua_pushnumber(lua, prevTime);
 	lua_pushnumber(lua, prevTime);
 	lua_pushnumber(lua, crntTime);
 	lua_pushnumber(lua, crntTime);
 
 

+ 1 - 1
src/anki/scene/components/ScriptComponent.h

@@ -27,7 +27,7 @@ public:
 
 
 	ANKI_USE_RESULT Error load(CString fname);
 	ANKI_USE_RESULT Error load(CString fname);
 
 
-	ANKI_USE_RESULT Error update(SceneNode&, Second prevTime, Second crntTime, Bool& updated) override;
+	ANKI_USE_RESULT Error update(Second prevTime, Second crntTime, Bool& updated) override;
 
 
 private:
 private:
 	ScriptResourcePtr m_script;
 	ScriptResourcePtr m_script;

+ 1 - 1
src/anki/scene/components/SkinComponent.cpp

@@ -34,7 +34,7 @@ void SkinComponent::playAnimation(U track, AnimationResourcePtr anim, F64 startT
 	m_tracks[track].m_repeat = repeat;
 	m_tracks[track].m_repeat = repeat;
 }
 }
 
 
-Error SkinComponent::update(SceneNode& node, Second prevTime, Second crntTime, Bool& updated)
+Error SkinComponent::update(Second prevTime, Second crntTime, Bool& updated)
 {
 {
 	updated = false;
 	updated = false;
 	const F64 timeDiff = crntTime - prevTime;
 	const F64 timeDiff = crntTime - prevTime;

+ 1 - 1
src/anki/scene/components/SkinComponent.h

@@ -27,7 +27,7 @@ public:
 
 
 	~SkinComponent();
 	~SkinComponent();
 
 
-	ANKI_USE_RESULT Error update(SceneNode&, Second, Second, Bool& updated) override;
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override;
 
 
 	void playAnimation(U track, AnimationResourcePtr anim, F64 startTime, Bool repeat);
 	void playAnimation(U track, AnimationResourcePtr anim, F64 startTime, Bool repeat);
 
 

+ 1 - 1
src/anki/scene/components/SpatialComponent.cpp

@@ -30,7 +30,7 @@ SpatialComponent::~SpatialComponent()
 	}
 	}
 }
 }
 
 
-Error SpatialComponent::update(SceneNode&, Second, Second, Bool& updated)
+Error SpatialComponent::update(Second, Second, Bool& updated)
 {
 {
 	updated = m_markedForUpdate;
 	updated = m_markedForUpdate;
 	if(updated)
 	if(updated)

+ 1 - 1
src/anki/scene/components/SpatialComponent.h

@@ -90,7 +90,7 @@ public:
 
 
 	/// @name SceneComponent overrides
 	/// @name SceneComponent overrides
 	/// @{
 	/// @{
-	ANKI_USE_RESULT Error update(SceneNode&, Second, Second, Bool& updated) override;
+	ANKI_USE_RESULT Error update(Second, Second, Bool& updated) override;
 	/// @}
 	/// @}
 
 
 private:
 private: