Panagiotis Christopoulos Charitos před 2 roky
rodič
revize
8d0da33417

+ 3 - 2
AnKi/Importer/GltfImporter.cpp

@@ -1012,6 +1012,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapRaii<CString
 
 	ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newSceneNode(\"%s\")\n", nodeName.cstr()));
 	ANKI_CHECK(m_sceneFile.writeText("lcomp = node:newLightComponent()\n"));
+	ANKI_CHECK(m_sceneFile.writeTextf("lcomp:setLightComponentType(LightComponentType.k%s)\n", lightTypeStr.cstr()));
 
 	Vec3 color(light.color[0], light.color[1], light.color[2]);
 	color *= light.intensity;
@@ -1135,7 +1136,7 @@ Error GltfImporter::writeCamera(const cgltf_node& node,
 	ANKI_IMPORTER_LOGV("Importing camera %s", getNodeName(node).cstr());
 
 	ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newSceneNode(\"%s\")\n", getNodeName(node).cstr()));
-	ANKI_CHECK(m_sceneFile.writeText("scene:setActiveCameraNode(node:getSceneNodeBase())\n"));
+	ANKI_CHECK(m_sceneFile.writeText("scene:setActiveCameraNode(node)\n"));
 	ANKI_CHECK(m_sceneFile.writeText("comp = node:newCameraComponent()\n"));
 
 	ANKI_CHECK(m_sceneFile.writeTextf("comp:setPerspective(%f, %f, getMainRenderer():getAspectRatio() * %f, %f)\n",
@@ -1153,7 +1154,7 @@ Error GltfImporter::writeModelNode(const cgltf_node& node, const HashMapRaii<CSt
 
 	const StringRaii modelFname = computeModelResourceFilename(*node.mesh);
 
-	ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newSceneComponent(\"%s\")\n", getNodeName(node).cstr()));
+	ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newSceneNode(\"%s\")\n", getNodeName(node).cstr()));
 	ANKI_CHECK(m_sceneFile.writeTextf("node:newModelComponent():loadModelResource(\"%s%s\")\n", m_rpath.cstr(),
 									  modelFname.cstr()));
 

+ 3 - 2
AnKi/Scene/Components/DecalComponent.cpp

@@ -71,11 +71,12 @@ Error DecalComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 		const Vec4 extend(halfBoxSize.x(), halfBoxSize.y(), halfBoxSize.z(), 0.0f);
 		const Obb obbL(center, Mat3x4::getIdentity(), extend);
 		m_obb = obbL.getTransformed(info.m_node->getWorldTransform());
-
 		m_spatial.setBoundingShape(m_obb);
-		m_spatial.update(info.m_node->getSceneGraph().getOctree());
 	}
 
+	const Bool spatialUpdated = m_spatial.update(info.m_node->getSceneGraph().getOctree());
+	updated = updated || spatialUpdated;
+
 	return Error::kNone;
 }
 

+ 6 - 0
AnKi/Scene/Components/DecalComponent.h

@@ -28,6 +28,12 @@ public:
 
 	~DecalComponent();
 
+	Bool isEnabled() const
+	{
+		return m_layers[LayerType::kDiffuse].m_bindlessTextureIndex != kMaxU32
+			   || m_layers[LayerType::kRoughnessMetalness].m_bindlessTextureIndex != kMaxU32;
+	}
+
 	void loadDiffuseImageResource(CString fname, F32 blendFactor)
 	{
 		setLayer(fname, blendFactor, LayerType::kDiffuse);

+ 3 - 2
AnKi/Scene/Components/FogDensityComponent.cpp

@@ -34,10 +34,11 @@ Error FogDensityComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 			const Sphere sphere(m_worldPos, m_sphereRadius);
 			m_spatial.setBoundingShape(sphere);
 		}
-
-		m_spatial.update(info.m_node->getSceneGraph().getOctree());
 	}
 
+	const Bool spatialUpdated = m_spatial.update(info.m_node->getSceneGraph().getOctree());
+	updated = updated || spatialUpdated;
+
 	return Error::kNone;
 }
 

+ 3 - 1
AnKi/Scene/Components/GlobalIlluminationProbeComponent.cpp

@@ -75,9 +75,11 @@ Error GlobalIlluminationProbeComponent::update(SceneComponentUpdateInfo& info, B
 
 		const Aabb aabb(-m_halfSize + m_worldPos, m_halfSize + m_worldPos);
 		m_spatial.setBoundingShape(aabb);
-		m_spatial.update(info.m_node->getSceneGraph().getOctree());
 	}
 
+	const Bool spatialUpdated = m_spatial.update(info.m_node->getSceneGraph().getOctree());
+	updated = updated || spatialUpdated;
+
 	return Error::kNone;
 }
 

+ 3 - 1
AnKi/Scene/Components/LensFlareComponent.cpp

@@ -47,9 +47,11 @@ Error LensFlareComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 
 		const Aabb aabb(m_worldPosition - (kAabbSize / 2.0f), m_worldPosition + (kAabbSize / 2.0f));
 		m_spatial.setBoundingShape(aabb);
-		m_spatial.update(info.m_node->getSceneGraph().getOctree());
 	}
 
+	const Bool spatialUpdated = m_spatial.update(info.m_node->getSceneGraph().getOctree());
+	updated = updated || spatialUpdated;
+
 	return Error::kNone;
 }
 

+ 5 - 5
AnKi/Scene/Components/LightComponent.cpp

@@ -69,7 +69,6 @@ Error LightComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 	{
 		const Sphere sphere(m_worldTransform.getOrigin(), m_point.m_radius);
 		m_spatial.setBoundingShape(sphere);
-		m_spatial.update(info.m_node->getSceneGraph().getOctree());
 
 		if(m_shadow)
 		{
@@ -128,9 +127,7 @@ Error LightComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 			worldPoints[i] = m_spot.m_edgePointsWspace[i].xyz();
 		}
 		worldPoints[4] = m_worldTransform.getOrigin().xyz();
-
 		m_spatial.setBoundingShape(ConstWeakArray<Vec3>(worldPoints));
-		m_spatial.update(info.m_node->getSceneGraph().getOctree());
 
 		if(m_shadow)
 		{
@@ -168,9 +165,11 @@ Error LightComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 	{
 		// Update the scene bounds always
 		info.m_node->getSceneGraph().getOctree().getActualSceneBounds(m_dir.m_sceneMin, m_dir.m_sceneMax);
-		updated = updated || m_spatial.update(info.m_node->getSceneGraph().getOctree());
 	}
 
+	const Bool spatialUpdated = m_spatial.update(info.m_node->getSceneGraph().getOctree());
+	updated = updated || spatialUpdated;
+
 	return Error::kNone;
 }
 
@@ -330,9 +329,10 @@ void LightComponent::setupDirectionalLightQueueElement(const Frustum& primaryFru
 	}
 }
 
-void LightComponent::onDestroyReal(SceneNode& node)
+void LightComponent::onDestroy(SceneNode& node)
 {
 	deleteArray(node.getMemoryPool(), m_frustums, m_frustumCount);
+	m_spatial.removeFromOctree(node.getSceneGraph().getOctree());
 }
 
 } // end namespace anki

+ 1 - 1
AnKi/Scene/Components/LightComponent.h

@@ -210,7 +210,7 @@ private:
 
 	Error update(SceneComponentUpdateInfo& info, Bool& updated);
 
-	void onDestroyReal(SceneNode& node);
+	void onDestroy(SceneNode& node);
 };
 /// @}
 

+ 3 - 1
AnKi/Scene/Components/ModelComponent.cpp

@@ -203,9 +203,11 @@ Error ModelComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 		const Aabb aabbWorld = aabbLocal.getTransformed(info.m_node->getWorldTransform());
 
 		m_spatial.setBoundingShape(aabbWorld);
-		m_spatial.update(info.m_node->getSceneGraph().getOctree());
 	}
 
+	const Bool spatialUpdated = m_spatial.update(info.m_node->getSceneGraph().getOctree());
+	updated = updated || spatialUpdated;
+
 	return Error::kNone;
 }
 

+ 8 - 1
AnKi/Scene/Components/ReflectionProbeComponent.cpp

@@ -85,10 +85,17 @@ Error ReflectionProbeComponent::update(SceneComponentUpdateInfo& info, Bool& upd
 
 		Aabb aabbWorld(-m_halfSize + m_worldPos, m_halfSize + m_worldPos);
 		m_spatial.setBoundingShape(aabbWorld);
-		m_spatial.update(info.m_node->getSceneGraph().getOctree());
 	}
 
+	const Bool spatialUpdated = m_spatial.update(info.m_node->getSceneGraph().getOctree());
+	updated = updated || spatialUpdated;
+
 	return Error::kNone;
 }
 
+void ReflectionProbeComponent::onDestroy(SceneNode& node)
+{
+	m_spatial.removeFromOctree(node.getSceneGraph().getOctree());
+}
+
 } // end namespace anki

+ 2 - 0
AnKi/Scene/Components/ReflectionProbeComponent.h

@@ -76,6 +76,8 @@ private:
 
 	Error update(SceneComponentUpdateInfo& info, Bool& updated);
 
+	void onDestroy(SceneNode& node);
+
 	static void reflectionProbeQueueElementFeedbackCallback(Bool fillRenderQueuesOnNextFrame, void* userData)
 	{
 		ANKI_ASSERT(userData);

+ 1 - 0
AnKi/Scene/Components/SkyboxComponent.cpp

@@ -23,6 +23,7 @@ SkyboxComponent::SkyboxComponent(SceneNode* node)
 
 SkyboxComponent::~SkyboxComponent()
 {
+	m_spatial.removeFromOctree(m_node->getSceneGraph().getOctree());
 }
 
 void SkyboxComponent::loadImageResource(CString filename)

+ 5 - 0
AnKi/Scene/Components/UiComponent.cpp

@@ -15,4 +15,9 @@ Error UiComponent::updateReal(SceneComponentUpdateInfo& info, Bool& updated)
 	return Error::kNone;
 }
 
+void UiComponent::onDestroy(SceneNode& node)
+{
+	m_spatial.removeFromOctree(node.getSceneGraph().getOctree());
+}
+
 } // end namespace anki

+ 2 - 0
AnKi/Scene/Components/UiComponent.h

@@ -50,6 +50,8 @@ private:
 	Spatial m_spatial;
 
 	Error updateReal(SceneComponentUpdateInfo& info, Bool& updated);
+
+	void onDestroy(SceneNode& node);
 };
 /// @}
 

+ 5 - 0
AnKi/Scene/Frustum.cpp

@@ -201,6 +201,8 @@ Bool Frustum::update()
 void Frustum::setCoverageBuffer(F32* depths, U32 width, U32 height)
 {
 	ANKI_ASSERT(m_pool);
+	ANKI_ASSERT(depths && width > 0 && height > 0);
+
 	const U32 elemCount = width * height;
 	if(m_depthMap.getSize() != elemCount) [[unlikely]]
 	{
@@ -211,6 +213,9 @@ void Frustum::setCoverageBuffer(F32* depths, U32 width, U32 height)
 	{
 		memcpy(m_depthMap.getBegin(), depths, elemCount * sizeof(F32));
 	}
+
+	m_depthMapWidth = width;
+	m_depthMapHeight = height;
 }
 
 } // end namespace anki

+ 1 - 0
AnKi/Scene/Frustum.h

@@ -214,6 +214,7 @@ public:
 			depthBuff = ConstWeakArray<F32>(&m_depthMap[0], m_depthMap.getSize());
 			width = m_depthMapWidth;
 			height = m_depthMapHeight;
+			ANKI_ASSERT(width > 0 && height > 0);
 		}
 		else
 		{

+ 4 - 2
AnKi/Scene/Spatial.h

@@ -13,7 +13,7 @@ namespace anki {
 /// @addtogroup scene
 /// @{
 
-/// XXX
+/// A class that assists with visibility testing.
 class Spatial
 {
 public:
@@ -77,7 +77,7 @@ public:
 	template<typename TVec>
 	void setBoundingShape(ConstWeakArray<TVec> points)
 	{
-		ANKI_ASSERT(pointCount > 0);
+		ANKI_ASSERT(points.getSize() > 0);
 		TVec min(kMaxF32), max(kMinF32);
 		for(const TVec& point : points)
 		{
@@ -89,6 +89,8 @@ public:
 		m_dirty = true;
 	}
 
+	/// Should be called each frame.
+	/// @return True if updated.
 	Bool update(Octree& octree)
 	{
 		const Bool updated = m_dirty;

+ 16 - 5
AnKi/Scene/Visibility.cpp

@@ -289,6 +289,7 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 
 	// Iterate
 	RenderQueueView& result = m_frcCtx->m_queueViews[taskId];
+	[[maybe_unused]] U32 visibleCount = 0;
 	for(U i = 0; i < m_spatialToTestCount; ++i)
 	{
 		Spatial* spatial = m_spatialsToTest[i];
@@ -303,8 +304,8 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 		if(comp.getClassId() == ModelComponent::getStaticClassId())
 		{
 			const ModelComponent& modelc = static_cast<ModelComponent&>(comp);
-			if(!modelc.isEnabled() || (frustumFlags.m_gatherShadowCasterModelComponents && !modelc.getCastsShadow())
-			   || !isInside())
+			const Bool isShadowFrustum = frustumFlags.m_gatherShadowCasterModelComponents;
+			if(!modelc.isEnabled() || (isShadowFrustum && !modelc.getCastsShadow()) || !isInside())
 			{
 				continue;
 			}
@@ -314,7 +315,8 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 			const U8 lod = computeLod(primaryFrustum, distanceFromCamera);
 
 			WeakArray<RenderableQueueElement> elements;
-			modelc.setupRenderableQueueElements(lod, RenderingTechnique::kGBuffer, pool, elements);
+			modelc.setupRenderableQueueElements(
+				lod, (isShadowFrustum) ? RenderingTechnique::kShadow : RenderingTechnique::kGBuffer, pool, elements);
 			for(RenderableQueueElement& el : elements)
 			{
 				el.m_distanceFromCamera = distanceFromCamera;
@@ -535,12 +537,13 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 		}
 		else if(comp.getClassId() == DecalComponent::getStaticClassId())
 		{
-			if(!frustumFlags.m_gatherDecalComponents || !isInside())
+			const DecalComponent& decalc = static_cast<DecalComponent&>(comp);
+
+			if(!frustumFlags.m_gatherDecalComponents || !isInside() || !decalc.isEnabled())
 			{
 				continue;
 			}
 
-			const DecalComponent& decalc = static_cast<DecalComponent&>(comp);
 			DecalQueueElement* el = result.m_decals.newElement(pool);
 			decalc.setupDecalQueueElement(*el);
 		}
@@ -622,10 +625,18 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 			}
 		}
 
+		++visibleCount;
+
 		// Update timestamp
 		Timestamp& timestamp = m_frcCtx->m_queueViews[taskId].m_timestamp;
+		ANKI_ASSERT(comp.getTimestamp() > 0);
 		timestamp = max(timestamp, comp.getTimestamp());
 	} // end for
+
+	if(visibleCount)
+	{
+		ANKI_ASSERT(m_frcCtx->m_queueViews[taskId].m_timestamp > 0);
+	}
 }
 
 void CombineResultsTask::combine()

+ 121 - 24
AnKi/Script/Scene.cpp

@@ -61,7 +61,7 @@ static EventManager* getEventManager(lua_State* l)
 using WeakArraySceneNodePtr = WeakArray<SceneNode*>;
 using WeakArrayBodyComponentPtr = WeakArray<BodyComponent*>;
 
-LuaUserDataTypeInfo luaUserDataTypeInfoLightComponentType = {8882904392405402561, "LightComponentType", 0, nullptr,
+LuaUserDataTypeInfo luaUserDataTypeInfoLightComponentType = {8470718832422191469, "LightComponentType", 0, nullptr,
 															 nullptr};
 
 template<>
@@ -99,7 +99,7 @@ static inline void wrapLightComponentType(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoWeakArraySceneNodePtr = {
-	-3020378466417181270, "WeakArraySceneNodePtr", LuaUserData::computeSizeForGarbageCollected<WeakArraySceneNodePtr>(),
+	7648049382558596903, "WeakArraySceneNodePtr", LuaUserData::computeSizeForGarbageCollected<WeakArraySceneNodePtr>(),
 	nullptr, nullptr};
 
 template<>
@@ -219,7 +219,7 @@ static inline void wrapWeakArraySceneNodePtr(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoWeakArrayBodyComponentPtr = {
-	2813543515544492920, "WeakArrayBodyComponentPtr",
+	2844651208788358574, "WeakArrayBodyComponentPtr",
 	LuaUserData::computeSizeForGarbageCollected<WeakArrayBodyComponentPtr>(), nullptr, nullptr};
 
 template<>
@@ -338,7 +338,7 @@ static inline void wrapWeakArrayBodyComponentPtr(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoLightComponent = {3445786717536908066, "LightComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoLightComponent = {2051671713191047644, "LightComponent",
 														 LuaUserData::computeSizeForGarbageCollected<LightComponent>(),
 														 nullptr, nullptr};
 
@@ -950,7 +950,7 @@ static inline void wrapLightComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoDecalComponent = {7701141861636541348, "DecalComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoDecalComponent = {-6375158924580135380, "DecalComponent",
 														 LuaUserData::computeSizeForGarbageCollected<DecalComponent>(),
 														 nullptr, nullptr};
 
@@ -1125,7 +1125,7 @@ static inline void wrapDecalComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoLensFlareComponent = {
-	-4647970621966936034, "LensFlareComponent", LuaUserData::computeSizeForGarbageCollected<LensFlareComponent>(),
+	4847224422471887212, "LensFlareComponent", LuaUserData::computeSizeForGarbageCollected<LensFlareComponent>(),
 	nullptr, nullptr};
 
 template<>
@@ -1288,7 +1288,7 @@ static inline void wrapLensFlareComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoBodyComponent = {5529617183972728483, "BodyComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoBodyComponent = {-3360293820096925301, "BodyComponent",
 														LuaUserData::computeSizeForGarbageCollected<BodyComponent>(),
 														nullptr, nullptr};
 
@@ -1403,7 +1403,7 @@ static inline void wrapBodyComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoTriggerComponent = {
-	-3849443020168727725, "TriggerComponent", LuaUserData::computeSizeForGarbageCollected<TriggerComponent>(), nullptr,
+	-4365175945097504171, "TriggerComponent", LuaUserData::computeSizeForGarbageCollected<TriggerComponent>(), nullptr,
 	nullptr};
 
 template<>
@@ -1567,7 +1567,7 @@ static inline void wrapTriggerComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoFogDensityComponent = {
-	-4107329472796162819, "FogDensityComponent", LuaUserData::computeSizeForGarbageCollected<FogDensityComponent>(),
+	-7391383425727995182, "FogDensityComponent", LuaUserData::computeSizeForGarbageCollected<FogDensityComponent>(),
 	nullptr, nullptr};
 
 template<>
@@ -1771,7 +1771,7 @@ static inline void wrapFogDensityComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoCameraComponent = {
-	-6649477839392550391, "CameraComponent", LuaUserData::computeSizeForGarbageCollected<CameraComponent>(), nullptr,
+	-7105818723081000535, "CameraComponent", LuaUserData::computeSizeForGarbageCollected<CameraComponent>(), nullptr,
 	nullptr};
 
 template<>
@@ -1956,7 +1956,7 @@ static inline void wrapCameraComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoGlobalIlluminationProbeComponent = {
-	-5887865092928128243, "GlobalIlluminationProbeComponent",
+	-5007409144360466985, "GlobalIlluminationProbeComponent",
 	LuaUserData::computeSizeForGarbageCollected<GlobalIlluminationProbeComponent>(), nullptr, nullptr};
 
 template<>
@@ -2203,7 +2203,7 @@ static inline void wrapGlobalIlluminationProbeComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoReflectionProbeComponent = {
-	6977997981567334363, "ReflectionProbeComponent",
+	-1111061106649305375, "ReflectionProbeComponent",
 	LuaUserData::computeSizeForGarbageCollected<ReflectionProbeComponent>(), nullptr, nullptr};
 
 template<>
@@ -2319,7 +2319,7 @@ static inline void wrapReflectionProbeComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoParticleEmitterComponent = {
-	-8291679345502040614, "ParticleEmitterComponent",
+	9102723145048747833, "ParticleEmitterComponent",
 	LuaUserData::computeSizeForGarbageCollected<ParticleEmitterComponent>(), nullptr, nullptr};
 
 template<>
@@ -2383,7 +2383,7 @@ static inline void wrapParticleEmitterComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoModelComponent = {-8343176842848085925, "ModelComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoModelComponent = {8602243248022601624, "ModelComponent",
 														 LuaUserData::computeSizeForGarbageCollected<ModelComponent>(),
 														 nullptr, nullptr};
 
@@ -2447,7 +2447,7 @@ static inline void wrapModelComponent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoSkinComponent = {-5744768758294589673, "SkinComponent",
+LuaUserDataTypeInfo luaUserDataTypeInfoSkinComponent = {-2946407153477599658, "SkinComponent",
 														LuaUserData::computeSizeForGarbageCollected<SkinComponent>(),
 														nullptr, nullptr};
 
@@ -2512,7 +2512,7 @@ static inline void wrapSkinComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoSkyboxComponent = {
-	-3250262943401629180, "SkyboxComponent", LuaUserData::computeSizeForGarbageCollected<SkyboxComponent>(), nullptr,
+	966403218142762218, "SkyboxComponent", LuaUserData::computeSizeForGarbageCollected<SkyboxComponent>(), nullptr,
 	nullptr};
 
 template<>
@@ -2814,7 +2814,7 @@ static inline void wrapSkyboxComponent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoSceneNode = {
-	-5171272945378548186, "SceneNode", LuaUserData::computeSizeForGarbageCollected<SceneNode>(), nullptr, nullptr};
+	-6418421503265120645, "SceneNode", LuaUserData::computeSizeForGarbageCollected<SceneNode>(), nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<SceneNode>()
@@ -2952,6 +2952,101 @@ static int wrapSceneNodesetMarkedForDeletion(lua_State* l)
 	return 0;
 }
 
+/// Pre-wrap method SceneNode::setLocalTransform.
+static inline int pwrapSceneNodesetLocalTransform(lua_State* l)
+{
+	[[maybe_unused]] LuaUserData* ud;
+	[[maybe_unused]] void* voidp;
+	[[maybe_unused]] PtrSize size;
+
+	if(LuaBinder::checkArgsCount(l, 2)) [[unlikely]]
+	{
+		return -1;
+	}
+
+	// Get "this" as "self"
+	if(LuaBinder::checkUserData(l, 1, luaUserDataTypeInfoSceneNode, ud))
+	{
+		return -1;
+	}
+
+	SceneNode* self = ud->getData<SceneNode>();
+
+	// Pop arguments
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoTransform;
+	if(LuaBinder::checkUserData(l, 2, luaUserDataTypeInfoTransform, ud)) [[unlikely]]
+	{
+		return -1;
+	}
+
+	Transform* iarg0 = ud->getData<Transform>();
+	const Transform& arg0(*iarg0);
+
+	// Call the method
+	self->setLocalTransform(arg0);
+
+	return 0;
+}
+
+/// Wrap method SceneNode::setLocalTransform.
+static int wrapSceneNodesetLocalTransform(lua_State* l)
+{
+	int res = pwrapSceneNodesetLocalTransform(l);
+	if(res >= 0)
+	{
+		return res;
+	}
+
+	lua_error(l);
+	return 0;
+}
+
+/// Pre-wrap method SceneNode::getLocalTransform.
+static inline int pwrapSceneNodegetLocalTransform(lua_State* l)
+{
+	[[maybe_unused]] LuaUserData* ud;
+	[[maybe_unused]] void* voidp;
+	[[maybe_unused]] PtrSize size;
+
+	if(LuaBinder::checkArgsCount(l, 1)) [[unlikely]]
+	{
+		return -1;
+	}
+
+	// Get "this" as "self"
+	if(LuaBinder::checkUserData(l, 1, luaUserDataTypeInfoSceneNode, ud))
+	{
+		return -1;
+	}
+
+	SceneNode* self = ud->getData<SceneNode>();
+
+	// Call the method
+	const Transform& ret = self->getLocalTransform();
+
+	// Push return value
+	voidp = lua_newuserdata(l, sizeof(LuaUserData));
+	ud = static_cast<LuaUserData*>(voidp);
+	luaL_setmetatable(l, "Transform");
+	extern LuaUserDataTypeInfo luaUserDataTypeInfoTransform;
+	ud->initPointed(&luaUserDataTypeInfoTransform, &ret);
+
+	return 1;
+}
+
+/// Wrap method SceneNode::getLocalTransform.
+static int wrapSceneNodegetLocalTransform(lua_State* l)
+{
+	int res = pwrapSceneNodegetLocalTransform(l);
+	if(res >= 0)
+	{
+		return res;
+	}
+
+	lua_error(l);
+	return 0;
+}
+
 /// Pre-wrap method SceneNode::newComponent<LightComponent>.
 static inline int pwrapSceneNodenewLightComponent(lua_State* l)
 {
@@ -3635,6 +3730,8 @@ static inline void wrapSceneNode(lua_State* l)
 	LuaBinder::pushLuaCFuncMethod(l, "getName", wrapSceneNodegetName);
 	LuaBinder::pushLuaCFuncMethod(l, "addChild", wrapSceneNodeaddChild);
 	LuaBinder::pushLuaCFuncMethod(l, "setMarkedForDeletion", wrapSceneNodesetMarkedForDeletion);
+	LuaBinder::pushLuaCFuncMethod(l, "setLocalTransform", wrapSceneNodesetLocalTransform);
+	LuaBinder::pushLuaCFuncMethod(l, "getLocalTransform", wrapSceneNodegetLocalTransform);
 	LuaBinder::pushLuaCFuncMethod(l, "newLightComponent", wrapSceneNodenewLightComponent);
 	LuaBinder::pushLuaCFuncMethod(l, "newLensFlareComponent", wrapSceneNodenewLensFlareComponent);
 	LuaBinder::pushLuaCFuncMethod(l, "newDecalComponent", wrapSceneNodenewDecalComponent);
@@ -3653,7 +3750,7 @@ static inline void wrapSceneNode(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoSceneGraph = {
-	-2801263306404830005, "SceneGraph", LuaUserData::computeSizeForGarbageCollected<SceneGraph>(), nullptr, nullptr};
+	4404392498251306351, "SceneGraph", LuaUserData::computeSizeForGarbageCollected<SceneGraph>(), nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<SceneGraph>()
@@ -3838,7 +3935,7 @@ static inline void wrapSceneGraph(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoEvent = {-1180022002827014850, "Event",
+LuaUserDataTypeInfo luaUserDataTypeInfoEvent = {-2615825556924573234, "Event",
 												LuaUserData::computeSizeForGarbageCollected<Event>(), nullptr, nullptr};
 
 template<>
@@ -3904,7 +4001,7 @@ static inline void wrapEvent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoLightEvent = {
-	2010298559895204981, "LightEvent", LuaUserData::computeSizeForGarbageCollected<LightEvent>(), nullptr, nullptr};
+	-7526125475964903318, "LightEvent", LuaUserData::computeSizeForGarbageCollected<LightEvent>(), nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<LightEvent>()
@@ -4023,7 +4120,7 @@ static inline void wrapLightEvent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoScriptEvent = {
-	4043286328613241983, "ScriptEvent", LuaUserData::computeSizeForGarbageCollected<ScriptEvent>(), nullptr, nullptr};
+	5801110807774236969, "ScriptEvent", LuaUserData::computeSizeForGarbageCollected<ScriptEvent>(), nullptr, nullptr};
 
 template<>
 const LuaUserDataTypeInfo& LuaUserData::getDataTypeInfoFor<ScriptEvent>()
@@ -4039,7 +4136,7 @@ static inline void wrapScriptEvent(lua_State* l)
 }
 
 LuaUserDataTypeInfo luaUserDataTypeInfoJitterMoveEvent = {
-	7325010007952194221, "JitterMoveEvent", LuaUserData::computeSizeForGarbageCollected<JitterMoveEvent>(), nullptr,
+	2781319554345824117, "JitterMoveEvent", LuaUserData::computeSizeForGarbageCollected<JitterMoveEvent>(), nullptr,
 	nullptr};
 
 template<>
@@ -4114,7 +4211,7 @@ static inline void wrapJitterMoveEvent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoAnimationEvent = {-2300461946199365403, "AnimationEvent",
+LuaUserDataTypeInfo luaUserDataTypeInfoAnimationEvent = {-8336736108646720888, "AnimationEvent",
 														 LuaUserData::computeSizeForGarbageCollected<AnimationEvent>(),
 														 nullptr, nullptr};
 
@@ -4131,7 +4228,7 @@ static inline void wrapAnimationEvent(lua_State* l)
 	lua_settop(l, 0);
 }
 
-LuaUserDataTypeInfo luaUserDataTypeInfoEventManager = {-7534189128278721780, "EventManager",
+LuaUserDataTypeInfo luaUserDataTypeInfoEventManager = {-4700410720940509872, "EventManager",
 													   LuaUserData::computeSizeForGarbageCollected<EventManager>(),
 													   nullptr, nullptr};
 

+ 8 - 0
AnKi/Script/Scene.xml

@@ -393,6 +393,14 @@ using WeakArrayBodyComponentPtr = WeakArray<BodyComponent*>;
 					</args>
 				</method>
 				<method name="setMarkedForDeletion"></method>
+				<method name="setLocalTransform">
+					<args>
+						<arg>const Transform&amp;</arg>
+					</args>
+				</method>
+				<method name="getLocalTransform">
+					<return>const Transform&amp;</return>
+				</method>
 				<method name="newComponent&lt;LightComponent&gt;" alias="newLightComponent">
 					<return>LightComponent*</return>
 				</method>

+ 1 - 1
AnKi/Util/Assert.h

@@ -22,7 +22,7 @@ void akassert(const char* exprTxt, const char* file, int line, const char* func)
 #	define ANKI_ASSERT(x) \
 		do \
 		{ \
-			if(ANKI_UNLIKELY(!(x))) \
+			if(!(x)) [[unlikely]] \
 			{ \
 				anki::akassert(#x, ANKI_FILE, __LINE__, ANKI_FUNC); \
 				ANKI_UNREACHABLE(); \

+ 37 - 36
Samples/SimpleScene/Assets/Scene.lua

@@ -1,101 +1,102 @@
--- Generated by: C:\Users\godli\src\anki\out\build\x64-Debug\Bin\GltfImporter.exe CornellBox.gltf .. -rpath Assets -texrpath Assets -v
+-- Generated by: C:\src\anki\out\build\x64-Debug\Bin\GltfImporter.exe CornellBox.gltf .. -rpath Assets -texrpath Assets -v
 local scene = getSceneGraph()
 local events = getEventManager()
 
-node = scene:newModelNode("Mesh_0")
-node:getSceneNodeBase():getModelComponent():loadModelResource("Assets/Mesh_0_backWall_24a9b01d8fc47286.ankimdl")
+node = scene:newSceneNode("Mesh_0")
+node:newModelComponent():loadModelResource("Assets/Mesh_0_backWall_24a9b01d8fc47286.ankimdl")
 trf = Transform.new()
 trf:setOrigin(Vec4.new(0.000000, 0.000000, 0.000000, 0))
 rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000000, 1.000000, 0.000000, 0.000000, -1.000000, -0.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(5.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newModelNode("Mesh_1")
-node:getSceneNodeBase():getModelComponent():loadModelResource("Assets/Mesh_1_ceiling_3aa8abc0da9fdec8.ankimdl")
+node = scene:newSceneNode("Mesh_1")
+node:newModelComponent():loadModelResource("Assets/Mesh_1_ceiling_3aa8abc0da9fdec8.ankimdl")
 trf = Transform.new()
 trf:setOrigin(Vec4.new(0.000000, 0.000000, 0.000000, 0))
 rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000000, 1.000000, 0.000000, 0.000000, -1.000000, -0.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(5.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newModelNode("Mesh_2")
-node:getSceneNodeBase():getModelComponent():loadModelResource("Assets/Mesh_2_floor_cc46c84f817f093a.ankimdl")
+node = scene:newSceneNode("Mesh_2")
+node:newModelComponent():loadModelResource("Assets/Mesh_2_floor_cc46c84f817f093a.ankimdl")
 trf = Transform.new()
 trf:setOrigin(Vec4.new(0.000000, 0.000000, 0.000000, 0))
 rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000000, 1.000000, 0.000000, 0.000000, -1.000000, -0.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(5.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newModelNode("Mesh_3")
-node:getSceneNodeBase():getModelComponent():loadModelResource("Assets/Mesh_3_leftWall_acf66dd2ebcb73e6.ankimdl")
+node = scene:newSceneNode("Mesh_3")
+node:newModelComponent():loadModelResource("Assets/Mesh_3_leftWall_acf66dd2ebcb73e6.ankimdl")
 trf = Transform.new()
 trf:setOrigin(Vec4.new(0.000000, 0.000000, 0.000000, 0))
 rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000000, 1.000000, 0.000000, 0.000000, -1.000000, -0.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(5.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newModelNode("Mesh_4")
-node:getSceneNodeBase():getModelComponent():loadModelResource("Assets/Mesh_4_light_82ddb9b3263c8f6e.ankimdl")
+node = scene:newSceneNode("Mesh_4")
+node:newModelComponent():loadModelResource("Assets/Mesh_4_light_82ddb9b3263c8f6e.ankimdl")
 trf = Transform.new()
 trf:setOrigin(Vec4.new(0.000000, 0.000000, 0.000000, 0))
 rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000000, 1.000000, 0.000000, 0.000000, -1.000000, -0.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(5.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newModelNode("Mesh_5")
-node:getSceneNodeBase():getModelComponent():loadModelResource("Assets/Mesh_5_rightWall_46f15190068c514a.ankimdl")
+node = scene:newSceneNode("Mesh_5")
+node:newModelComponent():loadModelResource("Assets/Mesh_5_rightWall_46f15190068c514a.ankimdl")
 trf = Transform.new()
 trf:setOrigin(Vec4.new(0.000000, 0.000000, 0.000000, 0))
 rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000000, 1.000000, 0.000000, 0.000000, -1.000000, -0.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(5.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newModelNode("Mesh_6")
-node:getSceneNodeBase():getModelComponent():loadModelResource("Assets/Mesh_6_shortBox_6c09f7141caa6339.ankimdl")
+node = scene:newSceneNode("Mesh_6")
+node:newModelComponent():loadModelResource("Assets/Mesh_6_shortBox_6c09f7141caa6339.ankimdl")
 trf = Transform.new()
 trf:setOrigin(Vec4.new(0.000000, 0.000000, 0.000000, 0))
 rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000000, 1.000000, 0.000000, 0.000000, -1.000000, -0.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(5.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newModelNode("Mesh_7")
-node:getSceneNodeBase():getModelComponent():loadModelResource("Assets/Mesh_7_tallBox_e327ec5ce1a1e7eb.ankimdl")
+node = scene:newSceneNode("Mesh_7")
+node:newModelComponent():loadModelResource("Assets/Mesh_7_tallBox_e327ec5ce1a1e7eb.ankimdl")
 trf = Transform.new()
 trf:setOrigin(Vec4.new(0.000000, 0.000000, 0.000000, 0))
 rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000000, 1.000000, 0.000000, 0.000000, -1.000000, -0.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(5.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newPerspectiveCameraNode("Camera")
-scene:setActiveCameraNode(node:getSceneNodeBase())
-frustumc = node:getSceneNodeBase():getFrustumComponent()
-frustumc:setPerspective(0.100000, 500.000000, getMainRenderer():getAspectRatio() * 1.024779, 1.024779)
+node = scene:newSceneNode("Camera")
+scene:setActiveCameraNode(node)
+comp = node:newCameraComponent()
+comp:setPerspective(0.100000, 500.000000, getMainRenderer():getAspectRatio() * 1.024779, 1.024779)
 trf = Transform.new()
 trf:setOrigin(Vec4.new(0.217066, 6.668793, 17.325689, 0))
 rot = Mat3x4.new()
 rot:setAll(0.999854, -0.000334, 0.017085, 0.000000, -0.001690, 0.992972, 0.118341, 0.000000, -0.017005, -0.118352, 0.992826, 0.000000)
 trf:setRotation(rot)
 trf:setScale(1.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newPointLightNode("Point")
-lcomp = node:getSceneNodeBase():getLightComponent()
+node = scene:newSceneNode("Point")
+lcomp = node:newLightComponent()
+lcomp:setLightComponentType(LightComponentType.kPoint)
 lcomp:setDiffuseColor(Vec4.new(10.000000, 10.000000, 10.000000, 1))
 lcomp:setShadowEnabled(1)
 lcomp:setRadius(20.000000)
@@ -105,10 +106,10 @@ rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.000000, 1.000000, 0.000000, 0.000000, -1.000000, -0.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(1.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)
 
-node = scene:newGlobalIlluminationProbeNode("Cube.011")
-comp = node:getSceneNodeBase():getGlobalIlluminationProbeComponent()
+node = scene:newSceneNode("Cube.011")
+comp = node:newGlobalIlluminationProbeComponent()
 comp:setBoxVolumeSize(Vec3.new(11.824861, 11.571836, 11.040863))
 trf = Transform.new()
 trf:setOrigin(Vec4.new(-0.064907, 4.847455, -0.144611, 0))
@@ -116,4 +117,4 @@ rot = Mat3x4.new()
 rot:setAll(1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000)
 trf:setRotation(rot)
 trf:setScale(1.000000)
-node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)
+node:setLocalTransform(trf)

+ 2 - 2
ThirdParty/ImGui/CMakeLists.txt

@@ -5,9 +5,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..)
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/../..)
 if(NOT MSVC)
-	add_compile_options(-std=c++17)
+	add_compile_options(-std=c++20)
 else()
-	add_compile_options(/std:c++17)
+	add_compile_options(/std:c++20)
 endif()
 
 add_library(AnKiImGui ${SRC})