Closed PeaceSells50 closed 7 years ago
Could you provide some use cases please?
I am breaking out Skeleton into its own resource. I would like to have a SmartPointer in Model pointing to a Skeleton resource. What I have had to do is make addRef and remRef public. So that when you call a function on Model to point to a Skeleton Resource it increments the refcount. And when you remove the Skeleton it decrements the refcount. It doesn't really seem like messing with the refcount outside the class itself is a very clean way to handle this problem. A smartpointer seems like the perfect way to handle this problem.
Resource references are managed manually in the whole engine. Is this something you can live with for now? It's little hard for me to decide, how to approach this problem without seeing actual source code. Or if it's necessary feel free to create some system for it, and we can discuss it then.
class LUMIX_RENDERER_API Model : public Resource { public: Skeleton* getSkeleton() { return m_skeleton; } void setSkeleton(Skeleton* skeleton) { if (!m_skeleton) { m_skeleton->remRef(); <- made public m_skeleton = NULL; }
m_skeleton = skeleton;
if (m_skeleton)
m_skeleton->addRef(); <- made public
}
private: Skeleton* m_skeleton; }
I am doing this at the moment. But I had to make some accessors public.
Yeah, this is clear to me. But I do not know what are all the places a skeleton is used, accessed or stored. How is it different from for example Material, which do not need smart pointer?
Not related to the smart pointe issue, I am just curious, what data does skeleton contain and is it necessary for it to be separated from a model?
Let us Skype this question.
Sure, but tomorrow evening
I would love to be able to create a SmartPointer to a resource. And test Invalid() instead of looking at the refcount. Also it would be nice to have something for things that are not resources. P.S. SmartHandles do not increase refcount act sort of like a c pointer.