ADD: object movement system
This commit is contained in:
@@ -344,6 +344,28 @@ void SceneManager::addMeshInstance(const std::string &name, std::shared_ptr<Mesh
|
||||
dynamicMeshInstances[name] = std::move(inst);
|
||||
}
|
||||
|
||||
bool SceneManager::getMeshInstanceTransform(const std::string &name, glm::mat4 &outTransform)
|
||||
{
|
||||
auto it = dynamicMeshInstances.find(name);
|
||||
if (it == dynamicMeshInstances.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
outTransform = it->second.transform;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SceneManager::setMeshInstanceTransform(const std::string &name, const glm::mat4 &transform)
|
||||
{
|
||||
auto it = dynamicMeshInstances.find(name);
|
||||
if (it == dynamicMeshInstances.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
it->second.transform = transform;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SceneManager::removeMeshInstance(const std::string &name)
|
||||
{
|
||||
return dynamicMeshInstances.erase(name) > 0;
|
||||
@@ -391,6 +413,17 @@ bool SceneManager::removeGLTFInstance(const std::string &name)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SceneManager::getGLTFInstanceTransform(const std::string &name, glm::mat4 &outTransform)
|
||||
{
|
||||
auto it = dynamicGLTFInstances.find(name);
|
||||
if (it == dynamicGLTFInstances.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
outTransform = it->second.transform;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SceneManager::setGLTFInstanceTransform(const std::string &name, const glm::mat4 &transform)
|
||||
{
|
||||
auto it = dynamicGLTFInstances.find(name);
|
||||
|
||||
@@ -95,6 +95,8 @@ public:
|
||||
void addMeshInstance(const std::string &name, std::shared_ptr<MeshAsset> mesh,
|
||||
const glm::mat4 &transform = glm::mat4(1.f),
|
||||
std::optional<BoundsType> boundsType = {});
|
||||
bool getMeshInstanceTransform(const std::string &name, glm::mat4 &outTransform);
|
||||
bool setMeshInstanceTransform(const std::string &name, const glm::mat4 &transform);
|
||||
bool removeMeshInstance(const std::string &name);
|
||||
void clearMeshInstances();
|
||||
|
||||
@@ -108,6 +110,7 @@ public:
|
||||
void addGLTFInstance(const std::string &name, std::shared_ptr<LoadedGLTF> scene,
|
||||
const glm::mat4 &transform = glm::mat4(1.f));
|
||||
bool removeGLTFInstance(const std::string &name);
|
||||
bool getGLTFInstanceTransform(const std::string &name, glm::mat4 &outTransform);
|
||||
bool setGLTFInstanceTransform(const std::string &name, const glm::mat4 &transform);
|
||||
void clearGLTFInstances();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user