bags refactor

This commit is contained in:
h4570
2022-07-18 23:42:24 +02:00
parent 0953ce3f19
commit f08fc1c8d3
19 changed files with 215 additions and 71 deletions
@@ -11,9 +11,10 @@
#pragma once
#include "math/vec4.hpp"
#include "renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.hpp"
#include "renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp"
#include "./dynpip_color_bag.hpp"
#include "./dynpip_lighting_bag.hpp"
#include "./dynpip_texture_bag.hpp"
#include "renderer/core/texture/models/texture.hpp"
@@ -35,17 +36,27 @@ class DynPipBag {
/** Mandatory. Object color(s). */
DynPipColorBag* color;
/** Mandatory. Vertex count. */
/** Mandatory. Vertex count per frame. */
u32 count;
/** Mandatory. Vertices. */
Vec4* vertices;
/** Mandatory. From (frame) vertices */
Vec4* verticesFrom;
/** Mandatory. To (frame) vertices */
Vec4* verticesTo;
/**
* Mandatory.
* State of animation interpolation
* (between from and to)
*/
float interpolation;
/** Optional. Texture coordinates and image. */
DynPipTextureBag* texture;
/** Optional. Object lighting. */
PipelineLightingBag* lighting;
DynPipLightingBag* lighting;
void print() const;
void print(const char* name) const;
@@ -23,10 +23,12 @@ class DynPipColorBag {
~DynPipColorBag();
/** Optional. Single color for all vertices. */
Color* single;
Color* singleFrom;
Color* singleTo;
/** Optional. Color per vertex. */
Color* many;
Color* manyFrom;
Color* manyTo;
};
} // namespace Tyra
@@ -0,0 +1,34 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "math/vec4.hpp"
#include "renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp"
namespace Tyra {
class DynPipLightingBag {
public:
DynPipLightingBag();
~DynPipLightingBag();
/** Mandatory. Model matrix for lights. */
M4x4* lightMatrix;
/** Mandatory. Lighting normals per vertex. */
Vec4* normalsFrom;
Vec4* normalsTo;
/** Mandatory. Directional lights */
PipelineDirLightsBag* dirLights;
};
} // namespace Tyra
@@ -21,7 +21,8 @@ class DynPipTextureBag {
~DynPipTextureBag();
/** Mandatory. Texture coordinates per vertex. */
Vec4* coordinates;
Vec4* coordinatesFrom;
Vec4* coordinatesTo;
/** Mandatory. Texture image. */
Texture* texture;
@@ -27,10 +27,6 @@ class DynamicPipeline : public Renderer3DPipeline {
void onUse();
/**
* Render 3D data via "meshes".
* This render() method is a bridge to core.render() method.
*/
void render(DynamicMesh* mesh, const DynPipOptions* options = nullptr);
};
@@ -16,15 +16,12 @@
namespace Tyra {
enum PipelineLightingBagMode { Auto, Manual };
enum PipelineDirLightsBagMode { Auto, Manual };
class PipelineLightingBag {
class PipelineDirLightsBag {
public:
explicit PipelineLightingBag(const bool& manual = false);
~PipelineLightingBag();
Vec4* normals;
M4x4* lightMatrix;
explicit PipelineDirLightsBag(const bool& manual = false);
~PipelineDirLightsBag();
void setAmbientColor(const Color& color);
void setDirectionalLightColors(Color* colors, const u8& count);
@@ -47,7 +44,7 @@ class PipelineLightingBag {
void deallocate();
void forceDeallocate();
u8 isAllocated;
PipelineLightingBagMode mode;
PipelineDirLightsBagMode mode;
Vec4* lightColors;
Vec4* lightDirections;
@@ -11,9 +11,9 @@
#pragma once
#include "math/vec4.hpp"
#include "renderer/3d/pipeline/shared/bag/pipeline_lighting_bag.hpp"
#include "renderer/3d/pipeline/shared/bag/pipeline_info_bag.hpp"
#include "./stapip_color_bag.hpp"
#include "./stapip_lighting_bag.hpp"
#include "./stapip_texture_bag.hpp"
#include "renderer/core/texture/models/texture.hpp"
#include "./packaging/stapip_bag_packages_bbox.hpp"
@@ -46,7 +46,7 @@ class StaPipBag {
StaPipTextureBag* texture;
/** Optional. Object lighting. */
PipelineLightingBag* lighting;
StaPipLightingBag* lighting;
/**
* @param maxVertCount This parameter is available in renderer API.
@@ -0,0 +1,33 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "math/vec4.hpp"
#include "renderer/3d/pipeline/shared/bag/pipeline_dir_lights_bag.hpp"
namespace Tyra {
class StaPipLightingBag {
public:
StaPipLightingBag();
~StaPipLightingBag();
/** Mandatory. Model matrix for lights. */
M4x4* lightMatrix;
/** Mandatory. Lighting normals per vertex. */
Vec4* normals;
/** Mandatory. Directional lights */
PipelineDirLightsBag* dirLights;
};
} // namespace Tyra
@@ -29,7 +29,7 @@ class StaticPipeline : public Renderer3DPipeline {
void onUse();
/**
* Render 3D data via "meshes".
* Render 3D via "meshes".
* This render() method is a bridge to core.render() method.
*/
void render(DynamicMesh* mesh, const StaPipOptions* options = nullptr);
@@ -47,10 +47,10 @@ class StaticPipeline : public Renderer3DPipeline {
MeshFrame* frameFrom, MeshFrame* frameTo) const;
StaPipTextureBag* getTextureBag(DynamicMesh* mesh, MeshMaterial* material,
MeshFrame* frameFrom, MeshFrame* frameTo);
PipelineLightingBag* getLightingBag(DynamicMesh* mesh, MeshMaterial* material,
M4x4* model, MeshFrame* frameFrom,
MeshFrame* frameTo,
const StaPipOptions* options) const;
StaPipLightingBag* getLightingBag(DynamicMesh* mesh, MeshMaterial* material,
M4x4* model, MeshFrame* frameFrom,
MeshFrame* frameTo,
const StaPipOptions* options) const;
void deallocDrawBags(StaPipBag* bag, MeshMaterial* material) const;
void setLightingColorsCache(StaPipLightingOptions* lightingOptions);