@@ -175,53 +175,60 @@ void OvRendering::Core::ABaseRenderer::Blit(
175175 p_dst.Unbind ();
176176}
177177
178+ bool OvRendering::Core::ABaseRenderer::IsDrawable (const Entities::Drawable& p_drawable) const
179+ {
180+ return
181+ p_drawable.mesh &&
182+ p_drawable.material &&
183+ p_drawable.material ->IsValid ()&&
184+ p_drawable.material ->SupportsProjectionMode (m_frameDescriptor.camera ->GetProjectionMode ()) &&
185+ p_drawable.material ->GetGPUInstances () > 0 ;
186+ }
187+
178188void OvRendering::Core::ABaseRenderer::DrawEntity (
179189 OvRendering::Data::PipelineState p_pso,
180190 const Entities::Drawable& p_drawable
181191)
182192{
183193 ZoneScoped;
184194
185- auto material = p_drawable.material ;
186- auto mesh = p_drawable.mesh ;
195+ OVASSERT (IsDrawable (p_drawable), " Submitted an entity that isn't properly configured!" );
187196
188- OVASSERT (material.has_value (), " Missing material instance!" );
197+ p_pso.depthWriting = p_drawable.stateMask .depthWriting ;
198+ p_pso.colorWriting .mask = p_drawable.stateMask .colorWriting ? 0xFF : 0x00 ;
199+ p_pso.blending = p_drawable.stateMask .blendable ;
200+ p_pso.userInterface = p_drawable.stateMask .userInterface ;
201+ p_pso.culling = p_drawable.stateMask .frontfaceCulling || p_drawable.stateMask .backfaceCulling ;
202+ p_pso.depthTest = p_drawable.stateMask .depthTest ;
189203
190- const auto gpuInstances = material->GetGPUInstances ();
191- const auto projectionMode = m_frameDescriptor.camera ->GetProjectionMode ();
192-
193- if (mesh && material->IsValid () && material->SupportsProjectionMode (projectionMode) && gpuInstances > 0 )
204+ if (p_pso.culling )
194205 {
195- p_pso.depthWriting = p_drawable.stateMask .depthWriting ;
196- p_pso.colorWriting .mask = p_drawable.stateMask .colorWriting ? 0xFF : 0x00 ;
197- p_pso.blending = p_drawable.stateMask .blendable ;
198- p_pso.userInterface = p_drawable.stateMask .userInterface ;
199- p_pso.culling = p_drawable.stateMask .frontfaceCulling || p_drawable.stateMask .backfaceCulling ;
200- p_pso.depthTest = p_drawable.stateMask .depthTest ;
201-
202- if (p_pso.culling )
206+ if (p_drawable.stateMask .backfaceCulling && p_drawable.stateMask .frontfaceCulling )
207+ {
208+ p_pso.cullFace = Settings::ECullFace::FRONT_AND_BACK;
209+ }
210+ else
203211 {
204- if (p_drawable.stateMask .backfaceCulling && p_drawable.stateMask .frontfaceCulling )
205- {
206- p_pso.cullFace = Settings::ECullFace::FRONT_AND_BACK;
207- }
208- else
209- {
210- p_pso.cullFace =
211- p_drawable.stateMask .backfaceCulling ?
212- Settings::ECullFace::BACK :
213- Settings::ECullFace::FRONT;
214- }
212+ p_pso.cullFace =
213+ p_drawable.stateMask .backfaceCulling ?
214+ Settings::ECullFace::BACK :
215+ Settings::ECullFace::FRONT;
215216 }
217+ }
216218
217- material->Bind (
218- &m_emptyTexture->GetTexture (),
219- p_drawable.featureSetOverride .has_value () ?
220- OvTools::Utils::OptRef<const Data::FeatureSet>(p_drawable.featureSetOverride .value ()) :
221- std::nullopt
222- );
219+ p_drawable. material ->Bind (
220+ &m_emptyTexture->GetTexture (),
221+ p_drawable.featureSetOverride .has_value () ?
222+ OvTools::Utils::OptRef<const Data::FeatureSet>(p_drawable.featureSetOverride .value ()) :
223+ std::nullopt
224+ );
223225
224- m_driver.Draw (p_pso, mesh.value (), p_drawable.primitiveMode , gpuInstances);
225- material->Unbind ();
226- }
226+ m_driver.Draw (
227+ p_pso,
228+ p_drawable.mesh .value (),
229+ p_drawable.primitiveMode ,
230+ p_drawable.material ->GetGPUInstances ()
231+ );
232+
233+ p_drawable.material ->Unbind ();
227234}
0 commit comments