finished tutorial 7

This commit is contained in:
h4570
2022-08-23 22:31:07 +02:00
parent 9f831c7a6f
commit 989d2702e8
24 changed files with 439 additions and 25 deletions
@@ -22,7 +22,7 @@ class MeshMaterial {
explicit MeshMaterial(const MeshMaterial& material);
~MeshMaterial();
u8 isMother, lightmapFlag;
bool isMother, lightmapFlag;
u32 id;
@@ -49,7 +49,7 @@ class DynamicPipeline : public Renderer3DPipeline {
*/
void render(const DynamicMesh* mesh);
void render(const DynamicMesh* mesh, const DynPipOptions& options);
void render(const DynamicMesh* mesh, const DynPipOptions* options = nullptr);
void render(const DynamicMesh* mesh, const DynPipOptions* options);
private:
RendererCore* rendererCore;
@@ -48,7 +48,7 @@ class StaticPipeline : public Renderer3DPipeline {
*/
void render(const StaticMesh* mesh);
void render(const StaticMesh* mesh, const StaPipOptions& options);
void render(const StaticMesh* mesh, const StaPipOptions* options = nullptr);
void render(const StaticMesh* mesh, const StaPipOptions* options);
private:
StapipBagBBoxesCacher cacher;
+4
View File
@@ -53,6 +53,10 @@ class Color {
void operator-=(const float& v);
void operator*=(const float& v);
void operator/=(const float& v);
Color operator+(const float& v) const;
Color operator-(const float& v) const;
Color operator*(const float& v) const;
Color operator/(const float& v) const;
inline void set(const Color& v) { copy(this, v.rgba); }
inline void set(const float* v) { copy(this, v); }
@@ -30,11 +30,11 @@ MeshMaterial::MeshMaterial(const MeshBuilderData& data,
id = rand() % 1000000;
if (data.lightMapEnabled) {
lightmapFlag = false;
lightmapFlag = true;
TYRA_ASSERT(material->frames[0]->colors != nullptr,
"Colors faces are required");
} else {
lightmapFlag = true;
lightmapFlag = false;
}
ambient.set(material->ambient);
@@ -112,9 +112,10 @@ void DynamicPipeline::render(const DynamicMesh* mesh,
auto* texture =
rendererCore->texture.repository.getByMeshMaterialId(material->id);
TYRA_ASSERT(
texture, "Texture for material: ", material->name, "Id: ", material->id,
"Was not found in texture repository! Did you forget to add texture?");
TYRA_ASSERT(texture, "Texture for material: ", material->name,
"Id: ", material->id,
"Was not found in texture repository! Did you forget to add "
"texture or disable texture coords loading in mesh?");
for (u32 k = 0; k < partsCount; k++) {
auto& buffer = buffers[bufferIndex];
@@ -96,7 +96,7 @@ void StaticPipeline::render(const StaticMesh* mesh,
u32 maxVertCount = core.getMaxVertCountByBag(&bag);
StaPipBagPackagesBBox* bbox = nullptr;
if (bag.info->frustumCulling == PipelineFrustumCulling_Precise) {
if (bag.info->frustumCulling == PipelineInfoBagFrustumCulling_Precise) {
bbox = cacher.getBBoxesByMesh(materialFrame, maxVertCount);
}
@@ -143,9 +143,9 @@ StaPipColorBag* StaticPipeline::getColorBag(
auto* result = new StaPipColorBag();
if (material->lightmapFlag) {
result->single = &material->ambient;
} else {
result->many = materialFrame->colors;
} else {
result->single = &material->ambient;
}
return result;
@@ -160,10 +160,10 @@ StaPipTextureBag* StaticPipeline::getTextureBag(
result->texture =
rendererCore->texture.repository.getByMeshMaterialId(material->id);
TYRA_ASSERT(
result->texture, "Texture for material: ", material->name,
"Id: ", material->id,
"Was not found in texture repository! Did you forget to add texture?");
TYRA_ASSERT(result->texture, "Texture for material: ", material->name,
"Id: ", material->id,
"Was not found in texture repository! Did you forget to add "
"texture or disable texture coords loading in mesh?");
result->coordinates = materialFrame->textureCoords;
+24
View File
@@ -47,6 +47,30 @@ void Color::operator/=(const float& v) {
a /= v;
}
Color Color::operator+(const float& v) const {
Color result = *this;
result += v;
return result;
}
Color Color::operator-(const float& v) const {
Color result = *this;
result -= v;
return result;
}
Color Color::operator*(const float& v) const {
Color result = *this;
result *= v;
return result;
}
Color Color::operator/(const float& v) const {
Color result = *this;
result /= v;
return result;
}
void Color::set(const float& t_r, const float& t_g, const float& t_b,
const float& t_a) {
r = t_r;