From 216cbe3eecbcc31d3ba92e14a32e3165542750bb Mon Sep 17 00:00:00 2001 From: kearwood Date: Thu, 7 Jul 2022 22:51:16 -0700 Subject: [PATCH] PipelineInfo::CullMode and PipelineInfo::RasterMode are no longer within the PipelineInfo class, enabling easier forward declaration. KRMaterial::bind now accepts remaining parameters required to set up the pipeline. Removed GL calls from KRModel. Replaced ifdef guards with pragma once. KRMesh::model_format_t changed to ModelFormat and is no longer within KRMesh, enabling easier forward declaration. --- kraken/KRAmbientZone.cpp | 2 +- kraken/KRAmbientZone.h | 6 +- kraken/KRAnimation.h | 7 +- kraken/KRAnimationAttribute.h | 5 +- kraken/KRAnimationCurve.h | 5 +- kraken/KRAnimationCurveManager.h | 6 +- kraken/KRAnimationLayer.h | 5 +- kraken/KRAnimationManager.h | 6 +- kraken/KRAudioBuffer.h | 5 +- kraken/KRAudioManager.h | 5 +- kraken/KRAudioSample.h | 5 +- kraken/KRAudioSource.cpp | 2 +- kraken/KRAudioSource.h | 5 +- kraken/KRBehavior.h | 5 +- kraken/KRBone.cpp | 2 +- kraken/KRBone.h | 6 +- kraken/KRBundle.h | 5 +- kraken/KRBundleManager.h | 5 +- kraken/KRCamera.cpp | 20 +- kraken/KRCamera.h | 5 +- kraken/KRCollider.cpp | 2 +- kraken/KRCollider.h | 6 +- kraken/KRContext.h | 6 +- kraken/KRContextObject.h | 5 +- kraken/KRDSP.h | 5 +- kraken/KRDataBlock.h | 5 +- kraken/KRDevice.h | 5 +- kraken/KRDeviceManager.h | 7 +- kraken/KRDirectionalLight.cpp | 4 +- kraken/KRDirectionalLight.h | 5 +- kraken/KREngine-common.h | 6 +- kraken/KRHelpers.h | 4 +- kraken/KRLODGroup.h | 6 +- kraken/KRLODSet.h | 6 +- kraken/KRLight.cpp | 26 +-- kraken/KRLight.h | 5 +- kraken/KRLocator.h | 6 +- kraken/KRMaterial.cpp | 9 +- kraken/KRMaterial.h | 14 +- kraken/KRMaterialManager.h | 7 +- kraken/KRMesh.cpp | 87 ++++----- kraken/KRMesh.h | 28 +-- kraken/KRMeshCube.cpp | 2 +- kraken/KRMeshQuad.cpp | 2 +- kraken/KRMeshSphere.cpp | 2 +- kraken/KRParticleSystemNewtonian.cpp | 6 +- kraken/KRPipeline.cpp | 50 ++--- kraken/KRPipeline.h | 266 +++++++++++++-------------- kraken/KRPipelineManager.cpp | 10 +- kraken/KRPipelineManager.h | 6 +- kraken/KRPointLight.cpp | 6 +- kraken/KRResource+fbx.cpp | 2 +- kraken/KRResource+obj.cpp | 2 +- kraken/KRReverbZone.cpp | 2 +- kraken/KRScene.cpp | 4 +- kraken/KRSprite.cpp | 6 +- 56 files changed, 315 insertions(+), 417 deletions(-) diff --git a/kraken/KRAmbientZone.cpp b/kraken/KRAmbientZone.cpp index d9f249c..e9c8114 100755 --- a/kraken/KRAmbientZone.cpp +++ b/kraken/KRAmbientZone.cpp @@ -140,7 +140,7 @@ void KRAmbientZone::render(RenderInfo& ri) info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; + info.rasterMode = RasterMode::kAdditive; info.modelFormat = sphereModel->getModelFormat(); info.vertexAttributes = sphereModel->getVertexAttributes(); diff --git a/kraken/KRAmbientZone.h b/kraken/KRAmbientZone.h index 64c71b4..16efdab 100755 --- a/kraken/KRAmbientZone.h +++ b/kraken/KRAmbientZone.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRAMBIENT_ZONE_H -#define KRAMBIENT_ZONE_H +#pragma once #include "KRResource.h" #include "KRNode.h" @@ -72,6 +71,3 @@ private: std::string m_ambient; float m_ambient_gain; }; - - -#endif diff --git a/kraken/KRAnimation.h b/kraken/KRAnimation.h index 165600c..7fcb48e 100755 --- a/kraken/KRAnimation.h +++ b/kraken/KRAnimation.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRANIMATION_H -#define KRANIMATION_H +#pragma once #include "KREngine-common.h" #include "KRContextObject.h" @@ -83,7 +82,3 @@ private: float m_duration; float m_start_time; }; - - - -#endif diff --git a/kraken/KRAnimationAttribute.h b/kraken/KRAnimationAttribute.h index 4c68b19..eaa01e6 100755 --- a/kraken/KRAnimationAttribute.h +++ b/kraken/KRAnimationAttribute.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRANIMATIONATTRIBUTE_H -#define KRANIMATIONATTRIBUTE_H +#pragma once #include "KRContextObject.h" #include "KREngine-common.h" @@ -67,5 +66,3 @@ private: KRNode *m_target; KRAnimationCurve *m_curve; }; - -#endif diff --git a/kraken/KRAnimationCurve.h b/kraken/KRAnimationCurve.h index 6aab6d8..90f771e 100755 --- a/kraken/KRAnimationCurve.h +++ b/kraken/KRAnimationCurve.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRANIMATIONCURVE_H -#define KRANIMATIONCURVE_H +#pragma once #include "KREngine-common.h" #include "KRContextObject.h" @@ -82,5 +81,3 @@ private: }; - -#endif diff --git a/kraken/KRAnimationCurveManager.h b/kraken/KRAnimationCurveManager.h index 18c31ff..78cfb59 100755 --- a/kraken/KRAnimationCurveManager.h +++ b/kraken/KRAnimationCurveManager.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRANIMATIONCURVEMANAGER_H -#define KRANIMATIONCURVEMANAGER_H +#pragma once #include "KREngine-common.h" @@ -61,6 +60,3 @@ private: unordered_map m_animationCurves; }; - - -#endif diff --git a/kraken/KRAnimationLayer.h b/kraken/KRAnimationLayer.h index 9b38437..9ae83e8 100755 --- a/kraken/KRAnimationLayer.h +++ b/kraken/KRAnimationLayer.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRANIMATIONLAYER_H -#define KRANIMATIONLAYER_H +#pragma once #include "KRContextObject.h" #include "KREngine-common.h" @@ -92,5 +91,3 @@ private: std::vector m_attributes; }; - -#endif diff --git a/kraken/KRAnimationManager.h b/kraken/KRAnimationManager.h index 19fe0f6..67f500b 100755 --- a/kraken/KRAnimationManager.h +++ b/kraken/KRAnimationManager.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRANIMATIONMANAGER_H -#define KRANIMATIONMANAGER_H +#pragma once #include "KREngine-common.h" @@ -67,6 +66,3 @@ private: set m_animationsToUpdate; }; - - -#endif diff --git a/kraken/KRAudioBuffer.h b/kraken/KRAudioBuffer.h index 3c286ff..1f7afea 100755 --- a/kraken/KRAudioBuffer.h +++ b/kraken/KRAudioBuffer.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRAUDIO_BUFFER_H -#define KRAUDIO_BUFFER_H +#pragma once #include "KREngine-common.h" #include "KRDataBlock.h" @@ -61,5 +60,3 @@ private: KRAudioSample *m_audioSample; }; - -#endif /* defined(KRAUDIO_BUFFER_H) */ diff --git a/kraken/KRAudioManager.h b/kraken/KRAudioManager.h index 8d8c48f..9639ceb 100755 --- a/kraken/KRAudioManager.h +++ b/kraken/KRAudioManager.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRAUDIO_MANAGER_H -#define KRAUDIO_MANAGER_H +#pragma once #include "KREngine-common.h" @@ -254,5 +253,3 @@ private: bool m_anticlick_block; bool m_high_quality_hrtf; // If true, 4 HRTF samples will be interpolated; if false, the nearest HRTF sample will be used without interpolation }; - -#endif /* defined(KRAUDIO_MANAGER_H) */ diff --git a/kraken/KRAudioSample.h b/kraken/KRAudioSample.h index 1d8dff0..fd9e291 100755 --- a/kraken/KRAudioSample.h +++ b/kraken/KRAudioSample.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRAUDIOSAMPLE_H -#define KRAUDIOSAMPLE_H +#pragma once #include "KREngine-common.h" #include "KRContextObject.h" @@ -109,5 +108,3 @@ private: static void PopulateBuffer(KRAudioSample *sound, int index, void *data); }; - -#endif /* defined(KRAUDIOSAMPLE_H) */ diff --git a/kraken/KRAudioSource.cpp b/kraken/KRAudioSource.cpp index fa0bcdd..ddebdd6 100755 --- a/kraken/KRAudioSource.cpp +++ b/kraken/KRAudioSource.cpp @@ -206,7 +206,7 @@ void KRAudioSource::render(RenderInfo& ri) info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; + info.rasterMode = RasterMode::kAdditive; info.modelFormat = sphereModel->getModelFormat(); info.vertexAttributes = sphereModel->getVertexAttributes(); diff --git a/kraken/KRAudioSource.h b/kraken/KRAudioSource.h index 76af371..ce879a3 100755 --- a/kraken/KRAudioSource.h +++ b/kraken/KRAudioSource.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRAUDIOSOURCE_H -#define KRAUDIOSOURCE_H +#pragma once #include "KREngine-common.h" #include "KRResource.h" @@ -156,5 +155,3 @@ private: bool m_enable_occlusion; bool m_enable_obstruction; }; - -#endif /* defined(KRAUDIOSOURCE_H) */ diff --git a/kraken/KRBehavior.h b/kraken/KRBehavior.h index 3e8e435..c5faf50 100755 --- a/kraken/KRBehavior.h +++ b/kraken/KRBehavior.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRBEHAVIOR_H -#define KRBEHAVIOR_H +#pragma once #include #include @@ -69,5 +68,3 @@ public: private: KRNode *__node; }; - -#endif /* defined(KRBEHAVIOR_H) */ diff --git a/kraken/KRBone.cpp b/kraken/KRBone.cpp index 195e192..6a764aa 100755 --- a/kraken/KRBone.cpp +++ b/kraken/KRBone.cpp @@ -90,7 +90,7 @@ void KRBone::render(RenderInfo& ri) info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditiveNoTest; + info.rasterMode = RasterMode::kAdditiveNoTest; info.modelFormat = sphereModel->getModelFormat(); info.vertexAttributes = sphereModel->getVertexAttributes(); diff --git a/kraken/KRBone.h b/kraken/KRBone.h index 90a843d..a126875 100755 --- a/kraken/KRBone.h +++ b/kraken/KRBone.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRBONE_H -#define KRBONE_H +#pragma once #include "KRResource.h" #include "KRNode.h" @@ -56,6 +55,3 @@ public: private: Matrix4 m_bind_pose; }; - - -#endif diff --git a/kraken/KRBundle.h b/kraken/KRBundle.h index 6861158..34937b7 100755 --- a/kraken/KRBundle.h +++ b/kraken/KRBundle.h @@ -28,8 +28,7 @@ // authors and should not be interpreted as representing official policies, either expressed // or implied, of Kearwood Gilbert. // -#ifndef KRBUNDLE_H -#define KRBUNDLE_H +#pragma once #include "KREngine-common.h" #include "KRResource.h" @@ -50,5 +49,3 @@ private: KRDataBlock *m_pData; static size_t RoundUpSize(size_t s); }; - -#endif /* defined(KRBUNDLE_H) */ diff --git a/kraken/KRBundleManager.h b/kraken/KRBundleManager.h index 9167593..267ba8b 100755 --- a/kraken/KRBundleManager.h +++ b/kraken/KRBundleManager.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRBUNDLEMANAGER_H -#define KRBUNDLEMANAGER_H +#pragma once #include "KRResourceManager.h" @@ -59,5 +58,3 @@ public: private: unordered_map m_bundles; }; - -#endif /* defined(KRBUNDLEMANAGER_H) */ diff --git a/kraken/KRCamera.cpp b/kraken/KRCamera.cpp index 2e4f5ce..f9fcf2b 100755 --- a/kraken/KRCamera.cpp +++ b/kraken/KRCamera.cpp @@ -227,7 +227,7 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS info.shader_name = &shader_name; info.pCamera = this; info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT; - info.rasterMode = PipelineInfo::RasterMode::kAlphaBlend; + info.rasterMode = RasterMode::kAlphaBlend; info.vertexAttributes = sphereMesh->getVertexAttributes(); info.modelFormat = sphereMesh->getModelFormat(); KRPipeline* testPipeline = m_pContext->getPipelineManager()->getPipeline(compositeSurface, info); @@ -256,8 +256,8 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS info.shader_name = &shader_name; info.pCamera = this; info.renderPass = KRNode::RENDER_PASS_FORWARD_OPAQUE; - info.rasterMode = PipelineInfo::RasterMode::kOpaqueNoDepthWrite; - info.cullMode = PipelineInfo::CullMode::kCullNone; + info.rasterMode = RasterMode::kOpaqueNoDepthWrite; + info.cullMode = CullMode::kCullNone; KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(compositeSurface, info); pPipeline->bind(commandBuffer, *this, m_viewport, Matrix4(), nullptr, nullptr, nullptr, KRNode::RENDER_PASS_FORWARD_OPAQUE, Vector3::Zero(), 0.0f, Vector4::Zero()); @@ -344,9 +344,9 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS info.shader_name = &shader_name; info.pCamera = this; info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; + info.rasterMode = RasterMode::kAdditive; info.vertexAttributes = vertices.getVertexAttributes(); - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; KRPipeline *pVisShader = getContext().getPipelineManager()->getPipeline(compositeSurface, info); m_pContext->getMeshManager()->bindVBO(commandBuffer, &vertices, 1.0f); @@ -566,8 +566,8 @@ void KRCamera::renderPost(VkCommandBuffer& commandBuffer, KRSurface& surface) info.shader_name = &shader_name; info.pCamera = this; info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT; - info.rasterMode = PipelineInfo::RasterMode::kOpaqueNoTest; - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP; + info.rasterMode = RasterMode::kOpaqueNoTest; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; info.vertexAttributes = vertices.getVertexAttributes(); KRPipeline *postShader = m_pContext->getPipelineManager()->getPipeline(surface, info); @@ -742,10 +742,10 @@ void KRCamera::renderPost(VkCommandBuffer& commandBuffer, KRSurface& surface) info.shader_name = &shader_name; info.pCamera = this; info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT; - info.rasterMode = PipelineInfo::RasterMode::kAlphaBlendNoTest; - info.cullMode = PipelineInfo::CullMode::kCullNone; + info.rasterMode = RasterMode::kAlphaBlendNoTest; + info.cullMode = CullMode::kCullNone; info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA); - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline *fontShader = m_pContext->getPipelineManager()->getPipeline(surface, info); fontShader->bind(commandBuffer, *this, m_viewport, Matrix4(), nullptr, nullptr, nullptr, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, Vector3::Zero(), 0.0f, Vector4::Zero()); diff --git a/kraken/KRCamera.h b/kraken/KRCamera.h index a7bd408..373cf4e 100755 --- a/kraken/KRCamera.h +++ b/kraken/KRCamera.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRCAMERA_H -#define KRCAMERA_H +#pragma once #include "KREngine-common.h" @@ -118,5 +117,3 @@ private: int m_frame_times[KRAKEN_FPS_AVERAGE_FRAME_COUNT]; int m_frame_times_filled; }; - -#endif diff --git a/kraken/KRCollider.cpp b/kraken/KRCollider.cpp index 28fa53d..cce52b2 100755 --- a/kraken/KRCollider.cpp +++ b/kraken/KRCollider.cpp @@ -213,7 +213,7 @@ void KRCollider::render(RenderInfo& ri) info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; + info.rasterMode = RasterMode::kAdditive; info.modelFormat = m_model->getModelFormat(); info.vertexAttributes = m_model->getVertexAttributes(); diff --git a/kraken/KRCollider.h b/kraken/KRCollider.h index 176da25..5abdd16 100755 --- a/kraken/KRCollider.h +++ b/kraken/KRCollider.h @@ -29,10 +29,10 @@ // or implied, of Kearwood Gilbert. // +#pragma once + #include "KREngine-common.h" -#ifndef KRCOLLIDER_H -#define KRCOLLIDER_H #define KRAKEN_COLLIDER_PHYSICS 1 #define KRAKEN_COLLIDER_AUDIO 2 @@ -80,5 +80,3 @@ private: void loadModel(); }; - -#endif /* defined(KRCOLLIDER_H) */ diff --git a/kraken/KRContext.h b/kraken/KRContext.h index df3590a..a4171f2 100755 --- a/kraken/KRContext.h +++ b/kraken/KRContext.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KREngine_KRContext_h -#define KREngine_KRContext_h +#pragma once #include "KREngine-common.h" #include "KRBundleManager.h" @@ -52,6 +51,7 @@ class KRAudioManager; class KRPresentationThread; class KRStreamerThread; +class KRDeviceManager; class KRContext { public: @@ -203,5 +203,3 @@ private: unordered_map m_surfaceHandleMap; }; - -#endif diff --git a/kraken/KRContextObject.h b/kraken/KRContextObject.h index ab1e124..4a90656 100755 --- a/kraken/KRContextObject.h +++ b/kraken/KRContextObject.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRCONTEXTOBJECT_H -#define KRCONTEXTOBJECT_H +#pragma once class KRContext; @@ -44,5 +43,3 @@ public: protected: KRContext *m_pContext; }; - -#endif diff --git a/kraken/KRDSP.h b/kraken/KRDSP.h index de4659f..f530197 100644 --- a/kraken/KRDSP.h +++ b/kraken/KRDSP.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef _KRDSP_H -#define _KRDSP_H +#pragma once #include "KREngine-common.h" @@ -90,5 +89,3 @@ void Accumulate(SplitComplex *buffer, const SplitComplex *buffer2, size_t count) void Multiply(const SplitComplex *a, const SplitComplex *b, SplitComplex *c, size_t count); } // namespace KRDSP - -#endif // _KRDSP_H diff --git a/kraken/KRDataBlock.h b/kraken/KRDataBlock.h index e7dc5d9..8c0b1a5 100755 --- a/kraken/KRDataBlock.h +++ b/kraken/KRDataBlock.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KREngine_KRDataBlock_h -#define KREngine_KRDataBlock_h +#pragma once #include "KREngine-common.h" @@ -127,5 +126,3 @@ private: void assertLocked(); }; - -#endif diff --git a/kraken/KRDevice.h b/kraken/KRDevice.h index 821920b..90bf0a3 100644 --- a/kraken/KRDevice.h +++ b/kraken/KRDevice.h @@ -32,8 +32,7 @@ #include "KREngine-common.h" #include "KRContextObject.h" -#ifndef KRDEVICE_H -#define KRDEVICE_H +#pragma once class KRDevice : public KRContextObject { @@ -68,5 +67,3 @@ public: VmaAllocator m_allocator; private: }; - -#endif // KRDEVICE_H diff --git a/kraken/KRDeviceManager.h b/kraken/KRDeviceManager.h index 28fc2ae..dd2956c 100644 --- a/kraken/KRDeviceManager.h +++ b/kraken/KRDeviceManager.h @@ -29,14 +29,13 @@ // or implied, of Kearwood Gilbert. // +#pragma once + #include "KREngine-common.h" #include "KRContext.h" #include "KRDevice.h" -#ifndef KRDEVICEMANAGER_H -#define KRDEVICEMANAGER_H - class KRDeviceManager : KRContextObject { public: @@ -61,5 +60,3 @@ private: VkInstance m_vulkanInstance; }; - -#endif // KRDEVICEMANAGER_H diff --git a/kraken/KRDirectionalLight.cpp b/kraken/KRDirectionalLight.cpp index efd0112..b9ef99c 100755 --- a/kraken/KRDirectionalLight.cpp +++ b/kraken/KRDirectionalLight.cpp @@ -146,10 +146,10 @@ void KRDirectionalLight::render(RenderInfo& ri) { info.pCamera = ri.camera; info.directional_lights = &this_light; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditiveNoTest; + info.rasterMode = RasterMode::kAdditiveNoTest; info.vertexAttributes = vertices.getVertexAttributes(); - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_DIRECTION_VIEW_SPACE, light_direction_view_space); diff --git a/kraken/KRDirectionalLight.h b/kraken/KRDirectionalLight.h index 22fc95d..e186ec8 100755 --- a/kraken/KRDirectionalLight.h +++ b/kraken/KRDirectionalLight.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KREngine_KRDirectionalLight_h -#define KREngine_KRDirectionalLight_h +#pragma once #include "KRLight.h" @@ -55,5 +54,3 @@ protected: }; - -#endif diff --git a/kraken/KREngine-common.h b/kraken/KREngine-common.h index 24327bb..6c7efc0 100755 --- a/kraken/KREngine-common.h +++ b/kraken/KREngine-common.h @@ -29,9 +29,7 @@ // or implied, of Kearwood Gilbert. // - -#ifndef KRENGINE_COMMON_H -#define KRENGINE_COMMON_H +#pragma once #define KRENGINE_MAX_GPU_COUNT 4 #define KRENGINE_DEBUG_GPU_LABELS 1 @@ -266,6 +264,4 @@ typedef int KrSurfaceHandle; #include "KRBehavior.h" -#endif - using namespace kraken; diff --git a/kraken/KRHelpers.h b/kraken/KRHelpers.h index 20db425..aeac46f 100644 --- a/kraken/KRHelpers.h +++ b/kraken/KRHelpers.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRHELPERS_H -#define KRHELPERS_H +#pragma once #include "vector2.h" #include "vector3.h" @@ -65,4 +64,3 @@ namespace kraken { const Vector3 getXMLAttribute(const std::string &base_name, ::tinyxml2::XMLElement *e, const Vector3 &default_value); } // namespace kraken -#endif diff --git a/kraken/KRLODGroup.h b/kraken/KRLODGroup.h index ebaecd5..be3254f 100755 --- a/kraken/KRLODGroup.h +++ b/kraken/KRLODGroup.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRLODGROUP_H -#define KRLODGROUP_H +#pragma once #include "KRResource.h" #include "KRNode.h" @@ -62,6 +61,3 @@ private: AABB m_reference; // Point of reference, used for distance calculation. Usually set to the bounding box center bool m_use_world_units; }; - - -#endif diff --git a/kraken/KRLODSet.h b/kraken/KRLODSet.h index f12244f..718cac7 100755 --- a/kraken/KRLODSet.h +++ b/kraken/KRLODSet.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRLODSET_H -#define KRLODSET_H +#pragma once #include "KRResource.h" #include "KRNode.h" @@ -52,6 +51,3 @@ public: virtual kraken_stream_level getStreamLevel(const KRViewport &viewport); }; - - -#endif diff --git a/kraken/KRLight.cpp b/kraken/KRLight.cpp index 6c2ed80..6318d55 100755 --- a/kraken/KRLight.cpp +++ b/kraken/KRLight.cpp @@ -264,10 +264,10 @@ void KRLight::render(RenderInfo& ri) { info.directional_lights = &this_directional_light; info.spot_lights = &this_spot_light; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; - info.cullMode = PipelineInfo::CullMode::kCullNone; + info.rasterMode = RasterMode::kAdditive; + info.cullMode = CullMode::kCullNone; info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA); - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info); pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_COLOR, m_color * ri.camera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity); @@ -313,10 +313,10 @@ void KRLight::render(RenderInfo& ri) { info.directional_lights = &this_directional_light; info.spot_lights = &this_spot_light; info.renderPass = KRNode::RENDER_PASS_ADDITIVE_PARTICLES; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; - info.cullMode = PipelineInfo::CullMode::kCullNone; + info.rasterMode = RasterMode::kAdditive; + info.cullMode = CullMode::kCullNone; info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX); - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline *pFogShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info); @@ -360,8 +360,8 @@ void KRLight::render(RenderInfo& ri) { info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; - info.cullMode = PipelineInfo::CullMode::kCullNone; + info.rasterMode = RasterMode::kAdditive; + info.cullMode = CullMode::kCullNone; info.modelFormat = sphereModel->getModelFormat(); info.vertexAttributes = sphereModel->getVertexAttributes(); @@ -413,10 +413,10 @@ void KRLight::render(RenderInfo& ri) { info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditiveNoTest; - info.cullMode = PipelineInfo::CullMode::kCullNone; + info.rasterMode = RasterMode::kAdditiveNoTest; + info.cullMode = CullMode::kCullNone; info.vertexAttributes = vertices.getVertexAttributes(); - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); @@ -528,8 +528,8 @@ void KRLight::renderShadowBuffers(RenderInfo& ri) info.shader_name = &shader_name; info.pCamera = ri.camera; info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT; - info.rasterMode = PipelineInfo::RasterMode::kOpaqueLessTest; // TODO - This is sub-optimal. Evaluate increasing depth buffer resolution instead of disabling depth test. - info.cullMode = PipelineInfo::CullMode::kCullNone; // Disabling culling, which eliminates some self-cast shadow artifacts + info.rasterMode = RasterMode::kOpaqueLessTest; // TODO - This is sub-optimal. Evaluate increasing depth buffer resolution instead of disabling depth test. + info.cullMode = CullMode::kCullNone; // Disabling culling, which eliminates some self-cast shadow artifacts KRPipeline *shadowShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info); shadowShader->bind(ri.commandBuffer, *ri.camera, m_shadowViewports[iShadow], Matrix4(), nullptr, nullptr, nullptr, KRNode::RENDER_PASS_SHADOWMAP, Vector3::Zero(), 0.0f, Vector4::Zero()); diff --git a/kraken/KRLight.h b/kraken/KRLight.h index d5aeb9d..cb0b995 100755 --- a/kraken/KRLight.h +++ b/kraken/KRLight.h @@ -28,8 +28,7 @@ // authors and should not be interpreted as representing official policies, either expressed // or implied, of Kearwood Gilbert. // -#ifndef KRLIGHT_H -#define KRLIGHT_H +#pragma once #include "KRResource.h" #include "KRNode.h" @@ -104,5 +103,3 @@ protected: virtual int configureShadowBufferViewports(const KRViewport &viewport); void renderShadowBuffers(RenderInfo& ri); }; - -#endif diff --git a/kraken/KRLocator.h b/kraken/KRLocator.h index 65f5dd2..cd34ba3 100755 --- a/kraken/KRLocator.h +++ b/kraken/KRLocator.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRLOCATOR_H -#define KRLOCATOR_H +#pragma once #include "KRResource.h" #include "KRNode.h" @@ -56,6 +55,3 @@ private: unordered_map m_userBoolAttributes; unordered_map m_userStringAttributes; }; - - -#endif diff --git a/kraken/KRMaterial.cpp b/kraken/KRMaterial.cpp index a71e894..4d36cb8 100755 --- a/kraken/KRMaterial.cpp +++ b/kraken/KRMaterial.cpp @@ -302,7 +302,7 @@ void KRMaterial::getTextures() } } -bool KRMaterial::bind(const KRNode::RenderInfo& ri, const std::vector &bones, const std::vector &bind_poses, const Matrix4 &matModel, KRTexture *pLightMap, const Vector3 &rim_color, float rim_power, float lod_coverage) +void KRMaterial::bind(const KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_t vertexAttributes, CullMode cullMode, const std::vector &bones, const std::vector &bind_poses, const Matrix4 &matModel, KRTexture *pLightMap, const Vector3 &rim_color, float rim_power, float lod_coverage) { bool bLightMap = pLightMap && ri.camera->settings.bEnableLightMap; @@ -344,9 +344,12 @@ bool KRMaterial::bind(const KRNode::RenderInfo& ri, const std::vector info.bNormalMapOffset = m_normalMapOffset != default_offset && bNormalMap; info.bReflectionMapOffset = m_reflectionMapOffset != default_offset && bReflectionMap; info.bAlphaTest = bAlphaTest; - info.rasterMode = bAlphaBlend ? PipelineInfo::RasterMode::kAlphaBlend : PipelineInfo::RasterMode::kOpaque; + info.rasterMode = bAlphaBlend ? RasterMode::kAlphaBlend : RasterMode::kOpaque; info.bRimColor = rim_power != 0.0f; info.renderPass = ri.renderPass; + info.modelFormat = modelFormat; + info.vertexAttributes = vertexAttributes; + info.cullMode = cullMode; KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); // Bind bones @@ -434,8 +437,6 @@ bool KRMaterial::bind(const KRNode::RenderInfo& ri, const std::vector } pShader->bind(ri.commandBuffer, *ri.camera, ri.viewport, matModel, &ri.point_lights, &ri.directional_lights, &ri.spot_lights, ri.renderPass, rim_color, rim_power, Vector4::Zero()); - - return true; } const std::string &KRMaterial::getName() const diff --git a/kraken/KRMaterial.h b/kraken/KRMaterial.h index 886d677..d01097d 100755 --- a/kraken/KRMaterial.h +++ b/kraken/KRMaterial.h @@ -29,6 +29,10 @@ // or implied, of Kearwood Gilbert. // +#pragma once + + + #include "KREngine-common.h" #include "KRTexture.h" @@ -39,10 +43,8 @@ #include "KRScene.h" #include "KRBone.h" -#ifndef KRMATERIAL_H -#define KRMATERIAL_H - - +enum class CullMode : __uint32_t; +enum class ModelFormat : __uint8_t; class KRTextureManager; class KRContext; @@ -83,7 +85,7 @@ public: bool isTransparent(); const std::string &getName() const; - bool bind(const KRNode::RenderInfo& ri, const std::vector& bones, const std::vector& bind_poses, const Matrix4& matModel, KRTexture* pLightMap, const Vector3& rim_color, float rim_power, float lod_coverage = 0.0f); + void bind(const KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_t vertexAttributes, CullMode cullMode, const std::vector& bones, const std::vector& bind_poses, const Matrix4& matModel, KRTexture* pLightMap, const Vector3& rim_color, float rim_power, float lod_coverage = 0.0f); bool needsVertexTangents(); @@ -134,5 +136,3 @@ private: void getTextures(); }; - -#endif diff --git a/kraken/KRMaterialManager.h b/kraken/KRMaterialManager.h index 7a5d467..59c2044 100755 --- a/kraken/KRMaterialManager.h +++ b/kraken/KRMaterialManager.h @@ -29,8 +29,7 @@ // or implied, of Kearwood Gilbert. // -#ifndef KRMATERIALMANAGER_H -#define KRMATERIALMANAGER_H +#pragma once #include "KREngine-common.h" @@ -40,6 +39,7 @@ #include "KRTextureManager.h" #include "KRMaterialManager.h" +class KRMaterial; using std::map; @@ -63,6 +63,3 @@ private: KRPipelineManager *m_pPipelineManager; }; - -#endif - diff --git a/kraken/KRMesh.cpp b/kraken/KRMesh.cpp index c85978d..6f8bca7 100755 --- a/kraken/KRMesh.cpp +++ b/kraken/KRMesh.cpp @@ -279,26 +279,27 @@ void KRMesh::render(const KRNode::RenderInfo& ri, const std::string& object_name for(int i=0; i < (int)bones.size(); i++) { bone_bind_poses.push_back(getBoneBindPose(i)); } - if(pMaterial->bind(ri, bones, bone_bind_poses, matModel, pLightMap, rim_color, rim_power, lod_coverage)) { - switch(pMaterial->getAlphaMode()) { - case KRMaterial::KRMATERIAL_ALPHA_MODE_OPAQUE: // Non-transparent materials - case KRMaterial::KRMATERIAL_ALPHA_MODE_TEST: // Alpha in diffuse texture is interpreted as punch-through when < 0.5 - renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage); - break; - case KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE: // Blended alpha with backface culling - renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage); - break; - case KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE: // Blended alpha rendered in two passes. First pass renders backfaces; second pass renders frontfaces. - // Render back faces first - GLDEBUG(glCullFace(GL_FRONT)); - renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage); + + switch(pMaterial->getAlphaMode()) { + case KRMaterial::KRMATERIAL_ALPHA_MODE_OPAQUE: // Non-transparent materials + case KRMaterial::KRMATERIAL_ALPHA_MODE_TEST: // Alpha in diffuse texture is interpreted as punch-through when < 0.5 + pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullBack, bones, bone_bind_poses, matModel, pLightMap, rim_color, rim_power, lod_coverage); + renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage); + break; + case KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE: // Blended alpha with backface culling + pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullBack, bones, bone_bind_poses, matModel, pLightMap, rim_color, rim_power, lod_coverage); + renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage); + break; + case KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE: // Blended alpha rendered in two passes. First pass renders backfaces; second pass renders frontfaces. + // Render back faces first + pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullFront, bones, bone_bind_poses, matModel, pLightMap, rim_color, rim_power, lod_coverage); + renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage); - // Render front faces second - GLDEBUG(glCullFace(GL_BACK)); - renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage); - break; - } + // Render front faces second + pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullBack, bones, bone_bind_poses, matModel, pLightMap, rim_color, rim_power, lod_coverage); + renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage); + break; } } } @@ -357,7 +358,7 @@ void KRMesh::createDataBlocks(KRMeshManager::KRVBOData::vbo_type t) int32_t vertex_count = pHeader->vertex_count; int vbo_index=0; - if(getModelFormat() == KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) { + if(getModelFormat() == ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) { int index_group = getSubmesh(iSubmesh)->index_group; int index_group_offset = getSubmesh(iSubmesh)->index_group_offset; @@ -457,7 +458,7 @@ void KRMesh::renderSubmesh(VkCommandBuffer& commandBuffer, int iSubmesh, KRNode: int cVertexes = pSubmesh->vertex_count; int vbo_index=0; - if(getModelFormat() == KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) { + if(getModelFormat() == ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) { int index_group = getSubmesh(iSubmesh)->index_group; int index_group_offset = getSubmesh(iSubmesh)->index_group_offset; @@ -497,12 +498,12 @@ void KRMesh::renderSubmesh(VkCommandBuffer& commandBuffer, int iSubmesh, KRNode: if(iVertex + cVertexes >= MAX_VBO_SIZE) { assert(iVertex + (MAX_VBO_SIZE - iVertex) <= cBufferVertexes); switch (getModelFormat()) { - case KRENGINE_MODEL_FORMAT_TRIANGLES: - case KRENGINE_MODEL_FORMAT_STRIP: + case ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_STRIP: vkCmdDraw(commandBuffer, (MAX_VBO_SIZE - iVertex), 1, iVertex, 0); break; - case KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: - case KRENGINE_MODEL_FORMAT_INDEXED_STRIP: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_STRIP: vkCmdDrawIndexed(commandBuffer, (MAX_VBO_SIZE - iVertex), 1, iVertex, 0, 0); break; } @@ -515,10 +516,10 @@ void KRMesh::renderSubmesh(VkCommandBuffer& commandBuffer, int iSubmesh, KRNode: assert(iVertex + cVertexes <= cBufferVertexes); switch (getModelFormat()) { - case KRENGINE_MODEL_FORMAT_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES: GLDEBUG(glDrawArrays(GL_TRIANGLES, iVertex, cVertexes)); break; - case KRENGINE_MODEL_FORMAT_STRIP: + case ModelFormat::KRENGINE_MODEL_FORMAT_STRIP: GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, iVertex, cVertexes)); break; default: @@ -626,7 +627,7 @@ void KRMesh::LoadData(const KRMesh::mesh_info &mi, bool calculate_normals, bool pHeader->bone_count = (__int32_t)bone_count; pHeader->index_count = (__int32_t)index_count; pHeader->index_base_count = (__int32_t)index_base_count; - pHeader->model_format = mi.format; + pHeader->model_format = (__int32_t)mi.format; strcpy(pHeader->szTag, "KROBJPACK1.2 "); updateAttributeOffsets(); @@ -704,7 +705,7 @@ void KRMesh::LoadData(const KRMesh::mesh_info &mi, bool calculate_normals, bool *index_base_data++ = (*itr).second; } - if(getModelFormat() == KRENGINE_MODEL_FORMAT_TRIANGLES) { + if(getModelFormat() == ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES) { // Calculate missing surface normals and tangents //cout << " Calculate surface normals and tangents\n"; if(calculate_normals || calculate_tangents) { @@ -1147,9 +1148,9 @@ Matrix4 KRMesh::getBoneBindPose(int bone_index) return Matrix4::Create(getBone(bone_index)->bind_pose); } -KRMesh::model_format_t KRMesh::getModelFormat() const +ModelFormat KRMesh::getModelFormat() const { - model_format_t f = (model_format_t)getHeader()->model_format; + ModelFormat f = (ModelFormat)getHeader()->model_format; return f; } @@ -1195,8 +1196,8 @@ bool KRMesh::rayCast(const Vector3 &start, const Vector3 &dir, HitInfo &hitinfo) // int vertex_start = getSubmesh(submesh_index)->start_vertex; int vertex_count = getVertexCount(submesh_index); switch(getModelFormat()) { - case KRENGINE_MODEL_FORMAT_TRIANGLES: - case KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: for(int triangle_index=0; triangle_index < vertex_count / 3; triangle_index++) { int tri_vert_index[3]; // FINDME, HACK! This is not very efficient for indexed collider meshes... tri_vert_index[0] = getTriangleVertexIndex(submesh_index, triangle_index*3); @@ -1212,8 +1213,8 @@ bool KRMesh::rayCast(const Vector3 &start, const Vector3 &dir, HitInfo &hitinfo) NOTE: Not yet supported: - case KRENGINE_MODEL_FORMAT_STRIP: - case KRENGINE_MODEL_FORMAT_INDEXED_STRIP: + case ModelFormat::KRENGINE_MODEL_FORMAT_STRIP: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_STRIP: for(int triangle_index=0; triangle_index < vertex_count - 2; triangle_index++) { int tri_vert_index[3]; tri_vert_index[0] = getTriangleVertexIndex(submesh_index, vertex_start + triangle_index*3); @@ -1241,8 +1242,8 @@ bool KRMesh::sphereCast(const Matrix4 &model_to_world, const Vector3 &v0, const for(int submesh_index=0; submesh_index < getSubmeshCount(); submesh_index++) { int vertex_count = getVertexCount(submesh_index); switch(getModelFormat()) { - case KRENGINE_MODEL_FORMAT_TRIANGLES: - case KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: for(int triangle_index=0; triangle_index < vertex_count / 3; triangle_index++) { int tri_vert_index[3]; // FINDME, HACK! This is not very efficient for indexed collider meshes... tri_vert_index[0] = getTriangleVertexIndex(submesh_index, triangle_index*3); @@ -1264,8 +1265,8 @@ bool KRMesh::sphereCast(const Matrix4 &model_to_world, const Vector3 &v0, const NOTE: Not yet supported: - case KRENGINE_MODEL_FORMAT_STRIP: - case KRENGINE_MODEL_FORMAT_INDEXED_STRIP: + case ModelFormat::KRENGINE_MODEL_FORMAT_STRIP: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_STRIP: for(int triangle_index=0; triangle_index < vertex_count - 2; triangle_index++) { int tri_vert_index[3]; tri_vert_index[0] = getTriangleVertexIndex(submesh_index, vertex_start + triangle_index*3); @@ -1511,7 +1512,7 @@ void KRMesh::convertToIndexed() KRContext::Log(KRContext::LOG_LEVEL_INFORMATION, "Convert to indexed, before: %i after: %i (%.2f%% saving)", getHeader()->vertex_count, mi.vertices.size(), ((float)getHeader()->vertex_count - (float)mi.vertices.size()) / (float)getHeader()->vertex_count * 100.0f); - mi.format = KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES; + mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES; m_pData->unlock(); LoadData(mi, false, false); @@ -1520,7 +1521,7 @@ void KRMesh::convertToIndexed() void KRMesh::optimize() { switch(getModelFormat()) { - case KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: optimizeIndexes(); break; default: @@ -1546,7 +1547,7 @@ void KRMesh::getIndexedRange(int index_group, int &start_index_offset, int &star int KRMesh::getTriangleVertexIndex(int submesh, int index) const { switch(getModelFormat()) { - case KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: { __uint16_t *index_data = getIndexData(); @@ -1572,7 +1573,7 @@ int KRMesh::getTriangleVertexIndex(int submesh, int index) const void KRMesh::optimizeIndexes() { m_pData->lock(); - if(getModelFormat() == KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) { + if(getModelFormat() == ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) { __uint16_t *new_indices = (__uint16_t *)malloc(0x10000 * sizeof(__uint16_t)); __uint16_t *vertex_mapping = (__uint16_t *)malloc(0x10000 * sizeof(__uint16_t)); @@ -1653,7 +1654,7 @@ void KRMesh::optimizeIndexes() free(new_indices); free(vertex_mapping); free(new_vertex_data); - } // if(getModelFormat() == KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) + } // if(getModelFormat() == ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) m_pData->unlock(); } diff --git a/kraken/KRMesh.h b/kraken/KRMesh.h index 27bb5ae..0c2e47c 100755 --- a/kraken/KRMesh.h +++ b/kraken/KRMesh.h @@ -28,6 +28,9 @@ // authors and should not be interpreted as representing official policies, either expressed // or implied, of Kearwood Gilbert. // + +#pragma once + #include "KREngine-common.h" #include "KRContext.h" @@ -47,9 +50,6 @@ using namespace kraken; #define BUFFER_OFFSET(i) ((char *)NULL + (i)) -#ifndef KRMesh_I -#define KRMesh_I - #include "KRMaterialManager.h" #include "KRCamera.h" #include "KRViewport.h" @@ -57,6 +57,14 @@ using namespace kraken; class KRMaterial; class KRNode; +enum class ModelFormat : __uint8_t +{ + KRENGINE_MODEL_FORMAT_TRIANGLES = 0, + KRENGINE_MODEL_FORMAT_STRIP, + KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES, + KRENGINE_MODEL_FORMAT_INDEXED_STRIP +}; + class KRMesh : public KRResource { public: @@ -87,15 +95,10 @@ public: KRENGINE_NUM_ATTRIBUTES } vertex_attrib_t; - typedef enum { - KRENGINE_MODEL_FORMAT_TRIANGLES = 0, - KRENGINE_MODEL_FORMAT_STRIP, - KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES, - KRENGINE_MODEL_FORMAT_INDEXED_STRIP - } model_format_t; + typedef struct { - model_format_t format; + ModelFormat format; std::vector vertices; std::vector<__uint16_t> vertex_indexes; std::vector > vertex_index_bases; @@ -213,7 +216,7 @@ public: Matrix4 getBoneBindPose(int bone_index); - model_format_t getModelFormat() const; + ModelFormat getModelFormat() const; bool lineCast(const Vector3 &v0, const Vector3 &v1, HitInfo &hitinfo) const; bool rayCast(const Vector3 &v0, const Vector3 &dir, HitInfo &hitinfo) const; @@ -289,6 +292,3 @@ private: }; - - -#endif // KRMesh_I \ No newline at end of file diff --git a/kraken/KRMeshCube.cpp b/kraken/KRMeshCube.cpp index b35b987..5348f65 100755 --- a/kraken/KRMeshCube.cpp +++ b/kraken/KRMeshCube.cpp @@ -57,7 +57,7 @@ KRMeshCube::KRMeshCube(KRContext &context) : KRMesh(context, "__cube") mi.submesh_starts.push_back(0); mi.submesh_lengths.push_back((int)mi.vertices.size()); mi.material_names.push_back(""); - mi.format = KRENGINE_MODEL_FORMAT_STRIP; + mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; LoadData(mi, true, true); diff --git a/kraken/KRMeshQuad.cpp b/kraken/KRMeshQuad.cpp index e823fbb..e978501 100755 --- a/kraken/KRMeshQuad.cpp +++ b/kraken/KRMeshQuad.cpp @@ -52,7 +52,7 @@ KRMeshQuad::KRMeshQuad(KRContext &context) : KRMesh(context, "__quad") mi.submesh_starts.push_back(0); mi.submesh_lengths.push_back((int)mi.vertices.size()); mi.material_names.push_back(""); - mi.format = KRENGINE_MODEL_FORMAT_STRIP; + mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; LoadData(mi, true, true); } diff --git a/kraken/KRMeshSphere.cpp b/kraken/KRMeshSphere.cpp index 5946a78..6b1a804 100755 --- a/kraken/KRMeshSphere.cpp +++ b/kraken/KRMeshSphere.cpp @@ -112,7 +112,7 @@ KRMeshSphere::KRMeshSphere(KRContext &context) : KRMesh(context, "__sphere") mi.material_names.push_back(""); - mi.format = KRENGINE_MODEL_FORMAT_TRIANGLES; + mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; LoadData(mi, true, true); } diff --git a/kraken/KRParticleSystemNewtonian.cpp b/kraken/KRParticleSystemNewtonian.cpp index cd46eed..a0a6fc8 100755 --- a/kraken/KRParticleSystemNewtonian.cpp +++ b/kraken/KRParticleSystemNewtonian.cpp @@ -98,10 +98,10 @@ void KRParticleSystemNewtonian::render(RenderInfo& ri) { info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; - info.cullMode = PipelineInfo::CullMode::kCullNone; + info.rasterMode = RasterMode::kAdditive; + info.cullMode = CullMode::kCullNone; info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA); - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline *pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info); pParticleShader->setUniform(KRPipeline::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f); diff --git a/kraken/KRPipeline.cpp b/kraken/KRPipeline.cpp index a7b0ae4..3dcc985 100644 --- a/kraken/KRPipeline.cpp +++ b/kraken/KRPipeline.cpp @@ -110,7 +110,7 @@ const char *KRPipeline::KRENGINE_UNIFORM_NAMES[] = { "fade_color", // KRENGINE_UNIFORM_FADE_COLOR }; -KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInfo& info, const char* szKey, const std::vector& shaders, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat) +KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInfo& info, const char* szKey, const std::vector& shaders, uint32_t vertexAttributes, ModelFormat modelFormat) : KRContextObject(context) , m_pushConstantBuffer(nullptr) , m_pushConstantBufferSize(0) @@ -251,12 +251,12 @@ KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInf VkPipelineInputAssemblyStateCreateInfo inputAssembly{}; inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; switch (modelFormat) { - case KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: - case KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES: + case ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES: inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; break; - case KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_INDEXED_STRIP: - case KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP: + case ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_STRIP: + case ModelFormat::KRENGINE_MODEL_FORMAT_STRIP: inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; break; } @@ -290,13 +290,13 @@ KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInf rasterizer.polygonMode = VK_POLYGON_MODE_FILL; rasterizer.lineWidth = 1.0f; switch (info.cullMode) { - case PipelineInfo::CullMode::kCullBack: + case CullMode::kCullBack: rasterizer.cullMode = VK_CULL_MODE_BACK_BIT; break; - case PipelineInfo::CullMode::kCullFront: + case CullMode::kCullFront: rasterizer.cullMode = VK_CULL_MODE_FRONT_BIT; break; - case PipelineInfo::CullMode::kCullNone: + case CullMode::kCullNone: rasterizer.cullMode = VK_CULL_MODE_NONE; break; } @@ -319,24 +319,24 @@ KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInf colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; switch (info.rasterMode) { - case PipelineInfo::RasterMode::kOpaque: - case PipelineInfo::RasterMode::kOpaqueLessTest: - case PipelineInfo::RasterMode::kOpaqueNoTest: - case PipelineInfo::RasterMode::kOpaqueNoDepthWrite: + case RasterMode::kOpaque: + case RasterMode::kOpaqueLessTest: + case RasterMode::kOpaqueNoTest: + case RasterMode::kOpaqueNoDepthWrite: colorBlendAttachment.blendEnable = VK_FALSE; colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO; colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD; break; - case PipelineInfo::RasterMode::kAlphaBlend: - case PipelineInfo::RasterMode::kAlphaBlendNoTest: + case RasterMode::kAlphaBlend: + case RasterMode::kAlphaBlendNoTest: colorBlendAttachment.blendEnable = VK_TRUE; colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD; break; - case PipelineInfo::RasterMode::kAdditive: - case PipelineInfo::RasterMode::kAdditiveNoTest: + case RasterMode::kAdditive: + case RasterMode::kAdditiveNoTest: colorBlendAttachment.blendEnable = VK_TRUE; colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE; @@ -393,29 +393,29 @@ KRPipeline::KRPipeline(KRContext& context, KRSurface& surface, const PipelineInf VkPipelineDepthStencilStateCreateInfo depthStencil{}; depthStencil.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; switch (info.rasterMode) { - case PipelineInfo::RasterMode::kOpaque: - case PipelineInfo::RasterMode::kOpaqueLessTest: + case RasterMode::kOpaque: + case RasterMode::kOpaqueLessTest: depthStencil.depthTestEnable = VK_TRUE; depthStencil.depthWriteEnable = VK_TRUE; break; - case PipelineInfo::RasterMode::kOpaqueNoTest: + case RasterMode::kOpaqueNoTest: depthStencil.depthTestEnable = VK_FALSE; depthStencil.depthWriteEnable = VK_TRUE; break; - case PipelineInfo::RasterMode::kOpaqueNoDepthWrite: - case PipelineInfo::RasterMode::kAlphaBlend: - case PipelineInfo::RasterMode::kAdditive: + case RasterMode::kOpaqueNoDepthWrite: + case RasterMode::kAlphaBlend: + case RasterMode::kAdditive: depthStencil.depthTestEnable = VK_TRUE; depthStencil.depthWriteEnable = VK_FALSE; break; - case PipelineInfo::RasterMode::kAlphaBlendNoTest: - case PipelineInfo::RasterMode::kAdditiveNoTest: + case RasterMode::kAlphaBlendNoTest: + case RasterMode::kAdditiveNoTest: depthStencil.depthTestEnable = VK_FALSE; depthStencil.depthWriteEnable = VK_FALSE; break; } - if (info.rasterMode == PipelineInfo::RasterMode::kOpaqueLessTest) { + if (info.rasterMode == RasterMode::kOpaqueLessTest) { depthStencil.depthCompareOp = VK_COMPARE_OP_LESS; } else { depthStencil.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL; diff --git a/kraken/KRPipeline.h b/kraken/KRPipeline.h index 3a17700..475fd9c 100644 --- a/kraken/KRPipeline.h +++ b/kraken/KRPipeline.h @@ -30,9 +30,7 @@ // - -#ifndef KRPIPELINE_H -#define KRPIPELINE_H +#pragma once #include "KREngine-common.h" #include "KRCamera.h" @@ -44,134 +42,138 @@ class KRShader; class KRSurface; class KRRenderPass; +enum class ModelFormat : __uint8_t; + +enum class CullMode : uint32_t { + kCullBack = 0, + kCullFront, + kCullNone +}; + +// Note: RasterMode is likely to be refactored later to a bitfield +enum class RasterMode : uint32_t { + kOpaque = 0, + /* + kOpaque is equivalent to: + + // Disable blending + glDisable(GL_BLEND)); + + // Enable z-buffer write + glDepthMask(GL_TRUE); + + // Enable z-buffer test + glEnable(GL_DEPTH_TEST)) + glDepthFunc(GL_LEQUAL); + glDepthRangef(0.0, 1.0); + */ + kOpaqueNoDepthWrite, + /* + kOpaque is equivalent to: + + // Disable blending + glDisable(GL_BLEND)); + + // Disable z-buffer write + glDepthMask(GL_FALSE); + + // Enable z-buffer test + glEnable(GL_DEPTH_TEST)) + glDepthFunc(GL_LEQUAL); + glDepthRangef(0.0, 1.0); + */ + kOpaqueLessTest, + /* + kOpaqueLessTest is equivalent to: + + // Disable blending + glDisable(GL_BLEND)); + + // Enable z-buffer write + glDepthMask(GL_TRUE); + + // Enable z-buffer test + glEnable(GL_DEPTH_TEST)) + glDepthFunc(GL_LESS); + glDepthRangef(0.0, 1.0); + */ + kOpaqueNoTest, + /* + kOpaqueNoTest is equivalent to: + + // Disable blending + glDisable(GL_BLEND)); + + // Enable z-buffer write + glDepthMask(GL_TRUE); + + // Disable z-buffer test + glDisable(GL_DEPTH_TEST) + */ + kAlphaBlend, + /* + kAlphaBlend is equivalent to: + + // Enable alpha blending + glEnable(GL_BLEND)); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); + + // Disable z-buffer write + glDepthMask(GL_FALSE); + + // Enable z-buffer test + glEnable(GL_DEPTH_TEST)) + glDepthFunc(GL_LEQUAL); + glDepthRangef(0.0, 1.0); + */ + kAlphaBlendNoTest, + /* + kAlphaBlendNoTest is equivalent to: + + // Enable alpha blending + glEnable(GL_BLEND)); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); + + // Disable z-buffer write + glDepthMask(GL_FALSE); + + // Disable z-buffer test + glDisable(GL_DEPTH_TEST) + */ + kAdditive, + /* + kAdditive is equivalent to: + + // Enable additive blending + glEnable(GL_BLEND)); + glBlendFunc(GL_ONE, GL_ONE)); + + // Disable z-buffer write + glDepthMask(GL_FALSE); + + // Enable z-buffer test + glEnable(GL_DEPTH_TEST)) + glDepthFunc(GL_LEQUAL); + glDepthRangef(0.0, 1.0); + */ + kAdditiveNoTest, + /* + kAdditive is equivalent to: + + // Enable additive blending + glEnable(GL_BLEND)); + glBlendFunc(GL_ONE, GL_ONE)); + + // Disable z-buffer write + glDepthMask(GL_FALSE); + + // Disable z-buffer test + glDisable(GL_DEPTH_TEST) + */ +}; + class PipelineInfo { public: - // Note: RasterMode is likely to be refactored later to a bitfield - enum class RasterMode : uint32_t { - kOpaque = 0, -/* - kOpaque is equivalent to: - - // Disable blending - glDisable(GL_BLEND)); - - // Enable z-buffer write - glDepthMask(GL_TRUE); - - // Enable z-buffer test - glEnable(GL_DEPTH_TEST)) - glDepthFunc(GL_LEQUAL); - glDepthRangef(0.0, 1.0); -*/ - kOpaqueNoDepthWrite, -/* - kOpaque is equivalent to: - - // Disable blending - glDisable(GL_BLEND)); - - // Disable z-buffer write - glDepthMask(GL_FALSE); - - // Enable z-buffer test - glEnable(GL_DEPTH_TEST)) - glDepthFunc(GL_LEQUAL); - glDepthRangef(0.0, 1.0); -*/ - kOpaqueLessTest, -/* - kOpaqueLessTest is equivalent to: - - // Disable blending - glDisable(GL_BLEND)); - - // Enable z-buffer write - glDepthMask(GL_TRUE); - - // Enable z-buffer test - glEnable(GL_DEPTH_TEST)) - glDepthFunc(GL_LESS); - glDepthRangef(0.0, 1.0); -*/ - kOpaqueNoTest, -/* - kOpaqueNoTest is equivalent to: - - // Disable blending - glDisable(GL_BLEND)); - - // Enable z-buffer write - glDepthMask(GL_TRUE); - - // Disable z-buffer test - glDisable(GL_DEPTH_TEST) -*/ - kAlphaBlend, -/* - kAlphaBlend is equivalent to: - - // Enable alpha blending - glEnable(GL_BLEND)); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); - - // Disable z-buffer write - glDepthMask(GL_FALSE); - - // Enable z-buffer test - glEnable(GL_DEPTH_TEST)) - glDepthFunc(GL_LEQUAL); - glDepthRangef(0.0, 1.0); -*/ - kAlphaBlendNoTest, -/* - kAlphaBlendNoTest is equivalent to: - - // Enable alpha blending - glEnable(GL_BLEND)); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); - - // Disable z-buffer write - glDepthMask(GL_FALSE); - - // Disable z-buffer test - glDisable(GL_DEPTH_TEST) -*/ - kAdditive, -/* - kAdditive is equivalent to: - - // Enable additive blending - glEnable(GL_BLEND)); - glBlendFunc(GL_ONE, GL_ONE)); - - // Disable z-buffer write - glDepthMask(GL_FALSE); - - // Enable z-buffer test - glEnable(GL_DEPTH_TEST)) - glDepthFunc(GL_LEQUAL); - glDepthRangef(0.0, 1.0); -*/ - kAdditiveNoTest, - /* - kAdditive is equivalent to: - - // Enable additive blending - glEnable(GL_BLEND)); - glBlendFunc(GL_ONE, GL_ONE)); - - // Disable z-buffer write - glDepthMask(GL_FALSE); - - // Disable z-buffer test - glDisable(GL_DEPTH_TEST) - */ - }; - enum class CullMode : uint32_t { - kCullBack = 0, - kCullFront, - kCullNone - }; const std::string* shader_name; KRCamera* pCamera; const std::vector* point_lights; @@ -197,14 +199,14 @@ public: RasterMode rasterMode; CullMode cullMode; uint32_t vertexAttributes; - KRMesh::model_format_t modelFormat; + ModelFormat modelFormat; KRNode::RenderPass renderPass; }; class KRPipeline : public KRContextObject { public: - KRPipeline(KRContext& context, KRSurface& surface, const PipelineInfo& info, const char* szKey, const std::vector& shaders, uint32_t vertexAttributes, KRMesh::model_format_t modelFormat); + KRPipeline(KRContext& context, KRSurface& surface, const PipelineInfo& info, const char* szKey, const std::vector& shaders, uint32_t vertexAttributes, ModelFormat modelFormat); virtual ~KRPipeline(); const char *getKey() const; @@ -305,5 +307,3 @@ private: VkPipelineLayout m_pushConstantsLayout; }; - -#endif diff --git a/kraken/KRPipelineManager.cpp b/kraken/KRPipelineManager.cpp index 93f6736..1f9fc93 100644 --- a/kraken/KRPipelineManager.cpp +++ b/kraken/KRPipelineManager.cpp @@ -72,7 +72,7 @@ KRPipeline* KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf key.second.push_back(surface.m_swapChain->m_extent.width); key.second.push_back(surface.m_swapChain->m_extent.height); key.second.push_back(info.vertexAttributes); - key.second.push_back(info.modelFormat); + key.second.push_back((int)info.modelFormat); // TODO - Add renderPass unique identifier to key PipelineMap::iterator itr = m_pipelines.find(key); if (itr != m_pipelines.end()) { @@ -220,10 +220,10 @@ KRPipeline *KRPipelineManager::getPipeline(KRSurface& surface, const PipelineInf stream << "\n#define HAS_REFLECTION_CUBE_MAP " << (info.bReflectionCubeMap ? "1" : "0"); stream << "\n#define ALPHA_TEST " << (info.bAlphaTest ? "1" : "0"); - stream << "\n#define ALPHA_BLEND " << ((info.rasterMode == PipelineInfo::RasterMode::kAlphaBlend - || info.rasterMode == PipelineInfo::RasterMode::kAlphaBlendNoTest - || info.rasterMode == PipelineInfo::RasterMode::kAdditive - || info.rasterMode == PipelineInfo::RasterMode::kAdditiveNoTest) ? "1" : "0"); + stream << "\n#define ALPHA_BLEND " << ((info.rasterMode == RasterMode::kAlphaBlend + || info.rasterMode == RasterMode::kAlphaBlendNoTest + || info.rasterMode == RasterMode::kAdditive + || info.rasterMode == RasterMode::kAdditiveNoTest) ? "1" : "0"); stream << "\n#define ENABLE_PER_PIXEL " << (info.pCamera->settings.bEnablePerPixel ? "1" : "0"); stream << "\n#define DEBUG_PSSM " << (info.pCamera->settings.bDebugPSSM ? "1" : "0"); diff --git a/kraken/KRPipelineManager.h b/kraken/KRPipelineManager.h index 49484c7..60df189 100644 --- a/kraken/KRPipelineManager.h +++ b/kraken/KRPipelineManager.h @@ -29,6 +29,7 @@ // or implied, of Kearwood Gilbert. // +#pragma once #include "KREngine-common.h" @@ -43,9 +44,6 @@ using std::vector; #include "KRPipeline.h" -#ifndef KRPIPELINEMANAGER_H -#define KRPIPELINEMANAGER_H - class KRPipeline; class PipelineInfo; class KRCamera; @@ -67,5 +65,3 @@ private: typedef std::map >, KRPipeline*> PipelineMap; PipelineMap m_pipelines; }; - -#endif diff --git a/kraken/KRPointLight.cpp b/kraken/KRPointLight.cpp index 3bd1d4b..dff9635 100755 --- a/kraken/KRPointLight.cpp +++ b/kraken/KRPointLight.cpp @@ -103,13 +103,13 @@ void KRPointLight::render(RenderInfo& ri) info.point_lights = &this_light; info.renderPass = ri.renderPass; if (bInsideLight) { - info.rasterMode = bVisualize ? PipelineInfo::RasterMode::kAdditiveNoTest : PipelineInfo::RasterMode::kAlphaBlendNoTest; + info.rasterMode = bVisualize ? RasterMode::kAdditiveNoTest : RasterMode::kAlphaBlendNoTest; } else { - info.rasterMode = bVisualize ? PipelineInfo::RasterMode::kAdditive : PipelineInfo::RasterMode::kAlphaBlend; + info.rasterMode = bVisualize ? RasterMode::kAdditive : RasterMode::kAlphaBlend; } info.vertexAttributes = bInsideLight ? m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES.getVertexAttributes() : 1 << KRMesh::KRENGINE_ATTRIB_VERTEX; - info.modelFormat = bInsideLight ? KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP : KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_TRIANGLES; + info.modelFormat = bInsideLight ? ModelFormat::KRENGINE_MODEL_FORMAT_STRIP : ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_LIGHT_COLOR, m_color); diff --git a/kraken/KRResource+fbx.cpp b/kraken/KRResource+fbx.cpp index 8cbefc3..63276d0 100755 --- a/kraken/KRResource+fbx.cpp +++ b/kraken/KRResource+fbx.cpp @@ -1282,7 +1282,7 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) { void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxMesh* pMesh) { KRMesh::mesh_info mi; - mi.format = KRMesh::KRENGINE_MODEL_FORMAT_TRIANGLES; + mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; typedef struct { float weights[KRENGINE_MAX_BONE_WEIGHTS_PER_VERTEX]; diff --git a/kraken/KRResource+obj.cpp b/kraken/KRResource+obj.cpp index 459a6bd..81bebb4 100755 --- a/kraken/KRResource+obj.cpp +++ b/kraken/KRResource+obj.cpp @@ -349,7 +349,7 @@ KRMesh* KRResource::LoadObj(KRContext &context, const std::string& path) // std::vector<__uint16_t> vertex_indexes; // std::vector > vertex_index_bases; - mi.format = KRMesh::KRENGINE_MODEL_FORMAT_TRIANGLES; + mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; new_mesh->LoadData(mi, true, false); } diff --git a/kraken/KRReverbZone.cpp b/kraken/KRReverbZone.cpp index 80db209..932881f 100755 --- a/kraken/KRReverbZone.cpp +++ b/kraken/KRReverbZone.cpp @@ -137,7 +137,7 @@ void KRReverbZone::render(RenderInfo& ri) info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAlphaBlend; + info.rasterMode = RasterMode::kAlphaBlend; info.modelFormat = sphereModel->getModelFormat(); info.vertexAttributes = sphereModel->getVertexAttributes(); diff --git a/kraken/KRScene.cpp b/kraken/KRScene.cpp index ea35a35..5b7e4ce 100755 --- a/kraken/KRScene.cpp +++ b/kraken/KRScene.cpp @@ -293,9 +293,9 @@ void KRScene::render(KRNode::RenderInfo& ri, KROctreeNode* pOctreeNode, unordere info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; + info.rasterMode = RasterMode::kAdditive; info.vertexAttributes = vertices.getVertexAttributes(); - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; KRPipeline* pPipeline = getContext().getPipelineManager()->getPipeline(*ri.surface, info); pPipeline->bind(ri.commandBuffer, *info.pCamera, ri.viewport, matModel, info.point_lights, info.directional_lights, info.spot_lights, info.renderPass, Vector3::Zero(), 0.0f, Vector4::Zero()); diff --git a/kraken/KRSprite.cpp b/kraken/KRSprite.cpp index d7798fa..7b09d1e 100755 --- a/kraken/KRSprite.cpp +++ b/kraken/KRSprite.cpp @@ -152,10 +152,10 @@ void KRSprite::render(RenderInfo& ri) { info.directional_lights = &ri.directional_lights; info.spot_lights = &ri.spot_lights; info.renderPass = ri.renderPass; - info.rasterMode = PipelineInfo::RasterMode::kAdditive; - info.cullMode = PipelineInfo::CullMode::kCullNone; + info.rasterMode = RasterMode::kAdditive; + info.cullMode = CullMode::kCullNone; info.vertexAttributes = vertices.getVertexAttributes(); - info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP; + info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP; KRPipeline *pShader = getContext().getPipelineManager()->getPipeline(*ri.surface, info); pShader->setUniform(KRPipeline::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);