internal: add bounding box to SceneAsset & subclasses
This commit is contained in:
@@ -53,7 +53,14 @@ namespace thermion
|
|||||||
return _materialInstanceCount;
|
return _materialInstanceCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Box &getBoundingBox() const { return _boundingBox; }
|
const Aabb getBoundingBox() const override
|
||||||
|
{
|
||||||
|
return Aabb {
|
||||||
|
|
||||||
|
.min = _boundingBox.getMin(), // center - halfExtent
|
||||||
|
.max = _boundingBox.getMax() // center + halfExtent
|
||||||
|
};
|
||||||
|
}
|
||||||
VertexBuffer *getVertexBuffer() const { return _vertexBuffer; }
|
VertexBuffer *getVertexBuffer() const { return _vertexBuffer; }
|
||||||
IndexBuffer *getIndexBuffer() const { return _indexBuffer; }
|
IndexBuffer *getIndexBuffer() const { return _indexBuffer; }
|
||||||
|
|
||||||
@@ -137,7 +144,6 @@ namespace thermion
|
|||||||
utils::Entity _entity;
|
utils::Entity _entity;
|
||||||
RenderableManager::PrimitiveType _primitiveType;
|
RenderableManager::PrimitiveType _primitiveType;
|
||||||
std::vector<std::unique_ptr<GeometrySceneAsset>> _instances;
|
std::vector<std::unique_ptr<GeometrySceneAsset>> _instances;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace thermion
|
} // namespace thermion
|
||||||
@@ -73,6 +73,10 @@ namespace thermion
|
|||||||
return _asset;
|
return _asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Aabb getBoundingBox() const override {
|
||||||
|
return _asset->getBoundingBox();
|
||||||
|
}
|
||||||
|
|
||||||
void addAllEntities(Scene *scene) override
|
void addAllEntities(Scene *scene) override
|
||||||
{
|
{
|
||||||
scene->addEntities(_asset->getEntities(), _asset->getEntityCount());
|
scene->addEntities(_asset->getEntities(), _asset->getEntityCount());
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ namespace thermion
|
|||||||
return std::nullptr_t();
|
return std::nullptr_t();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Aabb getBoundingBox() const override {
|
||||||
|
return _instance->getBoundingBox();
|
||||||
|
}
|
||||||
|
|
||||||
SceneAssetType getType() override
|
SceneAssetType getType() override
|
||||||
{
|
{
|
||||||
return SceneAsset::SceneAssetType::Gltf;
|
return SceneAsset::SceneAssetType::Gltf;
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ class SceneAsset {
|
|||||||
virtual ~SceneAsset() {
|
virtual ~SceneAsset() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual const Aabb getBoundingBox() const = 0;
|
||||||
|
|
||||||
virtual SceneAssetType getType() = 0;
|
virtual SceneAssetType getType() = 0;
|
||||||
|
|
||||||
virtual utils::Entity getEntity() {
|
virtual utils::Entity getEntity() {
|
||||||
|
|||||||
@@ -30,11 +30,15 @@ namespace thermion
|
|||||||
auto& rm = _engine->getRenderableManager();
|
auto& rm = _engine->getRenderableManager();
|
||||||
|
|
||||||
if(materialInstanceCount > 0) {
|
if(materialInstanceCount > 0) {
|
||||||
|
|
||||||
|
TRACE("Instance entity count : %d", instance->getEntityCount());
|
||||||
|
|
||||||
for(int i = 0; i < instance->getEntityCount(); i++) {
|
for(int i = 0; i < instance->getEntityCount(); i++) {
|
||||||
auto renderableInstance = rm.getInstance(instance->getEntities()[i]);
|
auto renderableInstance = rm.getInstance(instance->getEntities()[i]);
|
||||||
if(!renderableInstance.isValid()) {
|
if(!renderableInstance.isValid()) {
|
||||||
Log("Instance is not renderable");
|
TRACE("Instance child entity %d not renderable", i);
|
||||||
} else {
|
} else {
|
||||||
|
TRACE("Instance child entity %d renderable", i);
|
||||||
for(int i = 0; i < materialInstanceCount; i++) {
|
for(int i = 0; i < materialInstanceCount; i++) {
|
||||||
rm.setMaterialInstanceAt(renderableInstance, i, materialInstances[i]);
|
rm.setMaterialInstanceAt(renderableInstance, i, materialInstances[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user