Add new queries to TransformManager and Scene.
This commit is contained in:
@@ -63,7 +63,7 @@ class UTILS_PUBLIC Scene : public FilamentAPI {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set the SkyBox,
|
||||
* Sets the SkyBox.
|
||||
*
|
||||
* The Skybox is drawn last and covers all pixels not touched by geometry.
|
||||
*
|
||||
@@ -122,6 +122,13 @@ public:
|
||||
* @return The total number of Light objects in the Scene.
|
||||
*/
|
||||
size_t getLightCount() const noexcept;
|
||||
|
||||
/**
|
||||
* Returns true if the given entity is in the Scene.
|
||||
*
|
||||
* @return Whether the given entity is in the Scene.
|
||||
*/
|
||||
bool hasEntity(utils::Entity entity) const noexcept;
|
||||
};
|
||||
|
||||
} // namespace filament
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
void destroy(utils::Entity e) noexcept;
|
||||
|
||||
/**
|
||||
* Re-parent an entity to a new one.
|
||||
* Re-parents an entity to a new one.
|
||||
* @param i The instance of the transform component to re-parent
|
||||
* @param newParent The instance of the new parent transform
|
||||
* @attention It is an error to re-parent an entity to a descendant and will cause undefined behaviour.
|
||||
@@ -114,7 +114,30 @@ public:
|
||||
void setParent(Instance i, Instance newParent) noexcept;
|
||||
|
||||
/**
|
||||
* Set a local transform of a transform component.
|
||||
* Returns the parent of a transform component, or the null entity if it is a root.
|
||||
* @param i The instance of the transform component to query.
|
||||
*/
|
||||
utils::Entity getParent(Instance i) const noexcept;
|
||||
|
||||
/**
|
||||
* Returns the number of children of a transform component.
|
||||
* @param i The instance of the transform component to query.
|
||||
* @return The number of children of the queried component.
|
||||
*/
|
||||
size_t getChildCount(Instance i) const noexcept;
|
||||
|
||||
/**
|
||||
* Gets a list of children for a transform component.
|
||||
*
|
||||
* @param i The instance of the transform component to query.
|
||||
* @param chidren Pointer to array-of-Entity. The array must have at least "count" elements.
|
||||
* @param count The maximum number of children to retrieve.
|
||||
* @return The number of children written to the pointer.
|
||||
*/
|
||||
size_t getChildren(Instance i, utils::Entity* children, size_t count) const noexcept;
|
||||
|
||||
/**
|
||||
* Sets a local transform of a transform component.
|
||||
* @param ci The instance of the transform component to set the local transform to.
|
||||
* @param localTransform The local transform (i.e. relative to the parent).
|
||||
* @see getTransform()
|
||||
|
||||
@@ -349,6 +349,10 @@ size_t FScene::getLightCount() const noexcept {
|
||||
return count;
|
||||
}
|
||||
|
||||
bool FScene::hasEntity(Entity entity) const noexcept {
|
||||
return mEntities.find(entity) != mEntities.end();
|
||||
}
|
||||
|
||||
void FScene::setSkybox(FSkybox const* skybox) noexcept {
|
||||
std::swap(mSkybox, skybox);
|
||||
if (skybox) {
|
||||
@@ -424,4 +428,8 @@ size_t Scene::getLightCount() const noexcept {
|
||||
return upcast(this)->getLightCount();
|
||||
}
|
||||
|
||||
bool Scene::hasEntity(Entity entity) const noexcept {
|
||||
return upcast(this)->hasEntity(entity);
|
||||
}
|
||||
|
||||
} // namespace filament
|
||||
|
||||
@@ -69,6 +69,28 @@ void FTransformManager::setParent(Instance i, Instance parent) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
Entity FTransformManager::getParent(Instance i) const noexcept {
|
||||
i = mManager[i].parent;
|
||||
return i ? mManager.getEntity(i) : Entity();
|
||||
}
|
||||
|
||||
size_t FTransformManager::getChildCount(Instance i) const noexcept {
|
||||
size_t count = 0;
|
||||
for (Instance ci = mManager[i].firstChild; ci; ci = mManager[ci].next, ++count);
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t FTransformManager::getChildren(Instance i, utils::Entity* children,
|
||||
size_t count) const noexcept {
|
||||
Instance ci = mManager[i].firstChild;
|
||||
size_t numWritten = 0;
|
||||
while (ci && numWritten < count) {
|
||||
children[numWritten++] = mManager.getEntity(ci);
|
||||
ci = mManager[ci].next;
|
||||
}
|
||||
return numWritten;
|
||||
}
|
||||
|
||||
void FTransformManager::destroy(Entity e) noexcept {
|
||||
// update the reference of the element we're removing
|
||||
auto& manager = mManager;
|
||||
@@ -392,6 +414,19 @@ void TransformManager::setParent(Instance i, Instance newParent) noexcept {
|
||||
upcast(this)->setParent(i, newParent);
|
||||
}
|
||||
|
||||
utils::Entity TransformManager::getParent(Instance i) const noexcept {
|
||||
return upcast(this)->getParent(i);
|
||||
}
|
||||
|
||||
size_t TransformManager::getChildCount(Instance i) const noexcept {
|
||||
return upcast(this)->getChildCount(i);
|
||||
}
|
||||
|
||||
size_t TransformManager::getChildren(Instance i, utils::Entity* children,
|
||||
size_t count) const noexcept {
|
||||
return upcast(this)->getChildren(i, children, count);
|
||||
}
|
||||
|
||||
void TransformManager::openLocalTransformTransaction() noexcept {
|
||||
upcast(this)->openLocalTransformTransaction();
|
||||
}
|
||||
|
||||
@@ -62,6 +62,12 @@ public:
|
||||
|
||||
void setParent(Instance i, Instance newParent) noexcept;
|
||||
|
||||
utils::Entity getParent(Instance i) const noexcept;
|
||||
|
||||
size_t getChildCount(Instance i) const noexcept;
|
||||
|
||||
size_t getChildren(Instance i, utils::Entity* children, size_t count) const noexcept;
|
||||
|
||||
void openLocalTransformTransaction() noexcept;
|
||||
|
||||
void commitLocalTransformTransaction() noexcept;
|
||||
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
|
||||
size_t getRenderableCount() const noexcept;
|
||||
size_t getLightCount() const noexcept;
|
||||
bool hasEntity(utils::Entity entity) const noexcept;
|
||||
|
||||
public:
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user