diff options
author | HampusM <hampus@hampusmat.com> | 2024-08-04 17:49:18 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-08-04 17:49:18 +0200 |
commit | a83164950aedb40ab3f213d50a757ed07eabd7cc (patch) | |
tree | f096e6793caa6933797df5b99cee358e7587388d /engine | |
parent | a1649c20c7af13844f46b9da18a79a83a0fc01e1 (diff) |
feat(engine): add component making a object not be drawn
Diffstat (limited to 'engine')
-rw-r--r-- | engine/src/draw_flags.rs | 4 | ||||
-rw-r--r-- | engine/src/renderer/opengl.rs | 24 |
2 files changed, 18 insertions, 10 deletions
diff --git a/engine/src/draw_flags.rs b/engine/src/draw_flags.rs index c8c11c9..23ea22f 100644 --- a/engine/src/draw_flags.rs +++ b/engine/src/draw_flags.rs @@ -47,3 +47,7 @@ pub enum PolygonModeFace #[default] FrontAndBack, } + +/// Component that makes a object not be drawn. +#[derive(Debug, Clone, Copy, Component)] +pub struct NoDraw; diff --git a/engine/src/renderer/opengl.rs b/engine/src/renderer/opengl.rs index 108c504..911f0df 100644 --- a/engine/src/renderer/opengl.rs +++ b/engine/src/renderer/opengl.rs @@ -7,6 +7,7 @@ use std::process::abort; use cstr::cstr; use ecs::component::local::Local; +use ecs::query::options::{Not, With}; use ecs::sole::Single; use ecs::system::{Into as _, System}; use ecs::{Component, Query}; @@ -14,7 +15,7 @@ use ecs::{Component, Query}; use crate::camera::Camera; use crate::color::Color; use crate::data_types::dimens::Dimens; -use crate::draw_flags::{DrawFlags, PolygonModeConfig}; +use crate::draw_flags::{DrawFlags, NoDraw, PolygonModeConfig}; use crate::event::{Present as PresentEvent, Start as StartEvent}; use crate::lighting::{DirectionalLight, GlobalLight, PointLight}; use crate::material::{Flags as MaterialFlags, Material}; @@ -96,15 +97,18 @@ fn initialize(window: Single<Window>) } fn render( - query: Query<( - Mesh, - ShaderProgram, - Material, - Option<MaterialFlags>, - Option<Position>, - Option<Scale>, - Option<DrawFlags>, - )>, + query: Query< + ( + Mesh, + ShaderProgram, + Material, + Option<MaterialFlags>, + Option<Position>, + Option<Scale>, + Option<DrawFlags>, + ), + Not<With<NoDraw>>, + >, point_light_query: Query<(PointLight,)>, directional_lights: Query<(DirectionalLight,)>, camera_query: Query<(Camera,)>, |