浏览代码

Everything works now

Panagiotis Christopoulos Charitos 11 年之前
父节点
当前提交
e5bd54a590

+ 1 - 1
include/anki/resource/ResourcePointer.inl.h

@@ -74,7 +74,7 @@ void ResourcePointer<T, TResourceManager>::load(
 		std::memcpy(&m_cb->m_uuid[0], &filename[0], len + 1);
 
 		// Reset the memory pool if no-one is using it
-		if(pool.getAllocationsCount() > 0)
+		if(pool.getAllocationsCount() == 0)
 		{
 			pool.reset();
 		}

+ 3 - 3
include/anki/scene/Camera.h

@@ -32,7 +32,7 @@ public:
 	/// @name Constructors/Destructor
 	/// @{
 	Camera(
-		const char* name, SceneGraph* scene, // SceneNode
+		const CString& name, SceneGraph* scene, // SceneNode
 		Type type, Frustum* frustum); // Self
 
 	virtual ~Camera();
@@ -97,7 +97,7 @@ class PerspectiveCamera: public Camera
 public:
 	/// @name Constructors
 	/// @{
-	PerspectiveCamera(const char* name, SceneGraph* scene);
+	PerspectiveCamera(const CString& name, SceneGraph* scene);
 	/// @}
 
 	/// @name Accessors
@@ -147,7 +147,7 @@ class OrthographicCamera: public Camera
 public:
 	/// @name Constructors
 	/// @{
-	OrthographicCamera(const char* name, SceneGraph* scene);
+	OrthographicCamera(const CString& name, SceneGraph* scene);
 	/// @}
 
 	/// @name Accessors

+ 5 - 3
include/anki/scene/InstanceNode.h

@@ -18,7 +18,7 @@ class InstanceComponent: public SceneComponent
 {
 public:
 	InstanceComponent(SceneNode* node)
-		: SceneComponent(INSTANCE_COMPONENT, node)
+	:	SceneComponent(INSTANCE_COMPONENT, node)
 	{}
 
 	static constexpr Type getClassType()
@@ -32,8 +32,10 @@ class InstanceNode: public SceneNode, public InstanceComponent,
 	public MoveComponent
 {
 public:
-	InstanceNode(const char* name, SceneGraph* scene)
-		: SceneNode(name, scene), InstanceComponent(this), MoveComponent(this)
+	InstanceNode(const CString& name, SceneGraph* scene)
+	:	SceneNode(name, scene), 
+		InstanceComponent(this), 
+		MoveComponent(this)
 	{
 		addComponent(static_cast<InstanceComponent*>(this));
 		addComponent(static_cast<MoveComponent*>(this));

+ 3 - 3
include/anki/scene/ModelNode.h

@@ -27,7 +27,7 @@ public:
 	/// @name Constructors/Destructor
 	/// @{
 	ModelPatchNode(
-		const char* name, SceneGraph* scene, // Scene
+		const CString& name, SceneGraph* scene, // Scene
 		const ModelPatchBase* modelPatch); // Self
 
 	~ModelPatchNode();
@@ -83,8 +83,8 @@ public:
 	/// @name Constructors/Destructor
 	/// @{
 	ModelNode(
-		const char* name, SceneGraph* scene, // SceneNode
-		const char* modelFname); // Self
+		const CString& name, SceneGraph* scene, // SceneNode
+		const CString& modelFname); // Self
 
 	virtual ~ModelNode();
 	/// @}

+ 2 - 2
include/anki/scene/ParticleEmitter.h

@@ -157,8 +157,8 @@ class ParticleEmitter: public SceneNode, public SpatialComponent,
 
 public:
 	ParticleEmitter(
-		const char* name, SceneGraph* scene, // SceneNode
-		const char* filename); // Self
+		const CString& name, SceneGraph* scene, // SceneNode
+		const CString& filename); // Self
 
 	~ParticleEmitter();
 

+ 1 - 1
include/anki/scene/SceneGraph.h

@@ -155,7 +155,7 @@ public:
 
 	/// Create a new SceneNode
 	template<typename Node, typename... Args>
-	Node* newSceneNode(const char* name, Args&&... args)
+	Node* newSceneNode(const CString& name, Args&&... args)
 	{
 		Node* node;
 		SceneAllocator<Node> al = m_alloc;

+ 3 - 3
include/anki/scene/StaticGeometryNode.h

@@ -44,7 +44,7 @@ public:
 	/// @name Constructors/Destructor
 	/// @{
 	StaticGeometryPatchNode(
-		const char* name, SceneGraph* scene, // Scene
+		const CString& name, SceneGraph* scene, // Scene
 		const ModelPatchBase* modelPatch); // Self
 
 	~StaticGeometryPatchNode();
@@ -86,8 +86,8 @@ class StaticGeometryNode: public SceneNode
 {
 public:
 	StaticGeometryNode(
-		const char* name, SceneGraph* scene, // Scene
-		const char* filename); // Self
+		const CString& name, SceneGraph* scene, // Scene
+		const CString& filename); // Self
 
 	~StaticGeometryNode();
 

+ 1 - 0
src/core/App.cpp

@@ -175,6 +175,7 @@ void App::init(const ConfigSet& config)
 	rinit.m_cacheDir = m_cacheDir.toCString();
 	rinit.m_allocCallback = m_allocCb;
 	rinit.m_allocCallbackData = m_allocCbData;
+	rinit.m_tempAllocatorMemorySize = 1024 * 1024 * 2;
 	m_resources = m_heapAlloc.newInstance<ResourceManager>(rinit);
 
 	// Renderer

+ 10 - 10
src/scene/Camera.cpp

@@ -13,13 +13,13 @@ namespace anki {
 
 //==============================================================================
 Camera::Camera(
-	const char* name, SceneGraph* scene, // SceneNode
+	const CString& name, SceneGraph* scene, // SceneNode
 	Type type, Frustum* frustum) 
-	:	SceneNode(name, scene), 
-		MoveComponent(this),
-		FrustumComponent(this, frustum),
-		SpatialComponent(this),
-		m_type(type)
+:	SceneNode(name, scene), 
+	MoveComponent(this),
+	FrustumComponent(this, frustum),
+	SpatialComponent(this),
+	m_type(type)
 {
 	// Init components
 	addComponent(static_cast<MoveComponent*>(this));
@@ -82,8 +82,8 @@ void Camera::moveUpdate(MoveComponent& move)
 //==============================================================================
 
 //==============================================================================
-PerspectiveCamera::PerspectiveCamera(const char* name, SceneGraph* scene)
-	: Camera(name, scene, Type::PERSPECTIVE, &m_frustum)
+PerspectiveCamera::PerspectiveCamera(const CString& name, SceneGraph* scene)
+:	Camera(name, scene, Type::PERSPECTIVE, &m_frustum)
 {}
 
 //==============================================================================
@@ -91,8 +91,8 @@ PerspectiveCamera::PerspectiveCamera(const char* name, SceneGraph* scene)
 //==============================================================================
 
 //==============================================================================
-OrthographicCamera::OrthographicCamera(const char* name, SceneGraph* scene)
-	: Camera(name, scene, Type::ORTHOGRAPHIC, &m_frustum)
+OrthographicCamera::OrthographicCamera(const CString& name, SceneGraph* scene)
+:	Camera(name, scene, Type::ORTHOGRAPHIC, &m_frustum)
 {}
 
 } // end namespace anki

+ 12 - 12
src/scene/ModelNode.cpp

@@ -19,12 +19,12 @@ namespace anki {
 
 //==============================================================================
 ModelPatchNode::ModelPatchNode(
-	const char* name, SceneGraph* scene,
+	const CString& name, SceneGraph* scene,
 	const ModelPatchBase* modelPatch)
-	:	SceneNode(name, scene),
-		RenderComponent(this),
-		SpatialComponent(this), 
-		m_modelPatch(modelPatch)
+:	SceneNode(name, scene),
+	RenderComponent(this),
+	SpatialComponent(this), 
+	m_modelPatch(modelPatch)
 {
 	addComponent(static_cast<RenderComponent*>(this));
 	addComponent(static_cast<SpatialComponent*>(this));
@@ -211,12 +211,12 @@ void ModelPatchNode::frameUpdate(F32, F32, SceneNode::UpdateType uptype)
 
 //==============================================================================
 ModelNode::ModelNode(
-	const char* name, SceneGraph* scene,
-	const char* modelFname)
-	: 	SceneNode(name, scene),
-		MoveComponent(this),
-		m_transforms(getSceneAllocator()),
-		m_transformsTimestamp(0)
+	const CString& name, SceneGraph* scene,
+	const CString& modelFname)
+: 	SceneNode(name, scene),
+	MoveComponent(this),
+	m_transforms(getSceneAllocator()),
+	m_transformsTimestamp(0)
 {
 	addComponent(static_cast<MoveComponent*>(this));
 
@@ -225,7 +225,7 @@ ModelNode::ModelNode(
 	for(const ModelPatchBase* patch : m_model->getModelPatches())
 	{
 		ModelPatchNode* mpn = 
-			getSceneGraph().newSceneNode<ModelPatchNode>(nullptr, patch);
+			getSceneGraph().newSceneNode<ModelPatchNode>(CString(), patch);
 
 		SceneObject::addChild(mpn);
 	}

+ 2 - 2
src/scene/ParticleEmitter.cpp

@@ -201,8 +201,8 @@ void Particle::revive(const ParticleEmitter& pe,
 
 //==============================================================================
 ParticleEmitter::ParticleEmitter(
-	const char* name, SceneGraph* scene,
-	const char* filename)
+	const CString& name, SceneGraph* scene,
+	const CString& filename)
 :	SceneNode(name, scene),
 	SpatialComponent(this),
 	MoveComponent(this),

+ 9 - 8
src/scene/StaticGeometryNode.cpp

@@ -24,11 +24,11 @@ StaticGeometrySpatial::StaticGeometrySpatial(
 
 //==============================================================================
 StaticGeometryPatchNode::StaticGeometryPatchNode(
-	const char* name, SceneGraph* scene, const ModelPatchBase* modelPatch)
-	:	SceneNode(name, scene),
-		SpatialComponent(this),
-		RenderComponent(this),
-		m_modelPatch(modelPatch)
+	const CString& name, SceneGraph* scene, const ModelPatchBase* modelPatch)
+:	SceneNode(name, scene),
+	SpatialComponent(this),
+	RenderComponent(this),
+	m_modelPatch(modelPatch)
 {
 	addComponent(static_cast<SpatialComponent*>(this));
 	addComponent(static_cast<RenderComponent*>(this));
@@ -117,7 +117,7 @@ void StaticGeometryPatchNode::buildRendering(RenderingBuildData& data)
 
 //==============================================================================
 StaticGeometryNode::StaticGeometryNode(
-	const char* name, SceneGraph* scene, const char* filename)
+	const CString& name, SceneGraph* scene, const CString& filename)
 :	SceneNode(name, scene)
 {
 	m_model.load(filename, &getResourceManager());
@@ -125,11 +125,12 @@ StaticGeometryNode::StaticGeometryNode(
 	U i = 0;
 	for(const ModelPatchBase* patch : m_model->getModelPatches())
 	{
-		std::string newname = name + std::to_string(i);
+		SceneString newname(getSceneAllocator());
+		newname.sprintf("%s_%u", &name[0], i);
 
 		StaticGeometryPatchNode* node = 
 			getSceneGraph().newSceneNode<StaticGeometryPatchNode>(
-			newname.c_str(), patch);
+			newname.toCString(), patch);
 		(void)node;
 
 		++i;

+ 8 - 2
src/util/Exception.cpp

@@ -57,8 +57,11 @@ Exception::Exception(const char* file, I line, const char* func,
 		freeAligned(out);
 	}
 
+#if ANKI_DEBUG == 1
+	fprintf(stderr, "Exception thrown\n");
+#endif
+
 #if ANKI_ABORT_ON_THROW == 1
-	std::cerr << m_err << std::endl;
 	abort();
 #endif
 }
@@ -71,8 +74,11 @@ Exception::Exception(const Exception& e) noexcept
 	m_err = reinterpret_cast<char*>(mallocAligned(std::strlen(e.m_err) + 1, 1));
 	std::strcpy(m_err, e.m_err);
 
+#if ANKI_DEBUG == 1
+	fprintf(stderr, "Exception thrown\n");
+#endif
+
 #if ANKI_ABORT_ON_THROW == 1
-	std::cerr << m_err << std::endl;
 	abort();
 #endif
 }