Object implement Geometry
@@ -126,10 +126,16 @@ impl<G: Geometry, M: ForwardMaterial> Geometry for &Glue<G, M> {
impl<G: Geometry, M: ForwardMaterial> Object for Glue<G, M> {}
impl<G: Geometry, M: ForwardMaterial> Object for &Glue<G, M> {}
-pub trait Object: Drawable + Cullable {}
+pub trait Object: Drawable + Geometry {}
impl Object for &dyn Object {}
+impl Geometry for &dyn Object {
+ fn aabb(&self) -> &AxisAlignedBoundingBox {
+ (*self).aabb()
+ }
+}
+
pub trait Geometry: Shadable + Cullable {
fn aabb(&self) -> &AxisAlignedBoundingBox;
}
@@ -200,6 +206,26 @@ impl Shadable for &dyn Geometry {
}
}
+impl Shadable for &dyn Object {
+ fn render_forward(
+ &self,
+ material: &dyn ForwardMaterial,
+ camera: &Camera,
+ lights: &Lights,
+ ) -> Result<()> {
+ (*self).render_forward(material, camera, lights)
+ }
+
+ fn render_deferred(
+ &self,
+ material: &dyn DeferredMaterial,
+ camera: &Camera,
+ viewport: Viewport,
+ ) -> Result<()> {
+ (*self).render_deferred(material, camera, viewport)
+ }
+}
+
pub trait Cullable {
fn in_frustum(&self, camera: &Camera) -> bool;
}
