some optimizations

This commit is contained in:
h4570
2022-07-26 23:16:21 +02:00
parent 97e44507ff
commit 10164beadf
14 changed files with 177 additions and 107 deletions
@@ -48,8 +48,9 @@ class McpipClip {
packet2_t* staticPacket; packet2_t* staticPacket;
u16 vu1DBufferSize; u16 vu1DBufferSize;
std::vector<EEClipVertex> clippedTriangle; Vec4 inputVerts[3];
std::vector<EEClipVertex> inputTriangle; EEClipVertexPtrs inputTriangle[3];
EEClipVertex clippedTriangle[9];
Vec4 vertexBuffers[2][108]; Vec4 vertexBuffers[2][108];
Vec4 texCoordBuffers[2][108]; Vec4 texCoordBuffers[2][108];
@@ -18,7 +18,12 @@ namespace Tyra {
class PipelineOptions { class PipelineOptions {
public: public:
PipelineOptions() { lighting = nullptr; } PipelineOptions() {
lighting = nullptr;
antiAliasingEnabled = false;
blendingEnabled = true;
shadingType = TyraShadingFlat;
}
~PipelineOptions() {} ~PipelineOptions() {}
PipelineFrustumCulling frustumCulling; PipelineFrustumCulling frustumCulling;
@@ -39,6 +39,10 @@ class StaPipClipper {
EEClipAlgorithm algorithm; EEClipAlgorithm algorithm;
M4x4* mvp; M4x4* mvp;
Vec4 inputVerts[3];
EEClipVertexPtrs inputTriangle[3];
EEClipVertex clippedTriangle[9];
void perspectiveDivide(std::vector<EEClipVertex>* vertices); void perspectiveDivide(std::vector<EEClipVertex>* vertices);
void moveDataToBuffer(const std::vector<EEClipVertex>& vertices, void moveDataToBuffer(const std::vector<EEClipVertex>& vertices,
StaPipQBuffer* buffer); StaPipQBuffer* buffer);
@@ -28,25 +28,25 @@ class EEClipAlgorithm {
void init(const RendererSettings& settings); void init(const RendererSettings& settings);
void clip(std::vector<EEClipVertex>* o_vertices, u8 clip(EEClipVertex* o_vertices, EEClipVertexPtrs* i_vertices,
const std::vector<EEClipVertex>& vertices, const EEClipAlgorithmSettings& settings);
const EEClipAlgorithmSettings& settings);
static float clipMargin; static float clipMargin;
private: private:
float halfWidth, halfHeight, near, far; float halfWidth, halfHeight, near, far;
std::vector<EEClipVertex> tempVertices; EEClipVertex* tempVertices;
float getValueByPlane(const EEClipVertex& v, const int& plane); float getValueByPlane(const EEClipVertex& v, const int& plane);
bool isInside(const int& plane, const float& v, const float& w, bool isInside(const int& plane, const float& v, const float& w,
const float& planeLimitValue); const float& planeLimitValue);
void clipAgainstPlane(const std::vector<EEClipVertex>& original, /** @return clipped size */
std::vector<EEClipVertex>* clipped, const int& plane, u8 clipAgainstPlane(EEClipVertex* original, const u8& originalSize,
const float& planeLimitValue, EEClipVertex* clipped, const int& plane,
const EEClipAlgorithmSettings& settings); const float& planeLimitValue,
const EEClipAlgorithmSettings& settings);
}; };
} // namespace Tyra } // namespace Tyra
@@ -18,4 +18,8 @@ struct EEClipVertex {
Vec4 position, normal, st, color; Vec4 position, normal, st, color;
}; };
struct EEClipVertexPtrs {
Vec4 *position, *normal, *st, *color;
};
} // namespace Tyra } // namespace Tyra
@@ -31,7 +31,9 @@ MeshBuilderData* TyrobjLoader::load(const char* fullpath, const u16& count,
auto rawFilename = getFilenameWithoutExtension(path); auto rawFilename = getFilenameWithoutExtension(path);
auto extension = getExtensionOfFilename(path); auto extension = getExtensionOfFilename(path);
auto firstFile = rawFilename + "1." + extension; std::string firstFile = path;
if (count > 1) firstFile = rawFilename + "1." + extension;
FILE* firstFileHandler = fopen(firstFile.c_str(), "rb"); FILE* firstFileHandler = fopen(firstFile.c_str(), "rb");
TYRA_ASSERT(firstFileHandler != nullptr, "Failed to load: ", firstFile); TYRA_ASSERT(firstFileHandler != nullptr, "Failed to load: ", firstFile);
auto data = scan(firstFileHandler, count); auto data = scan(firstFileHandler, count);
@@ -46,10 +48,12 @@ MeshBuilderData* TyrobjLoader::load(const char* fullpath, const u16& count,
result->manyColorsEnabled = data.colorsCount > 0; result->manyColorsEnabled = data.colorsCount > 0;
for (u16 i = 1; i <= count; i++) { for (u16 i = 1; i <= count; i++) {
auto path = rawFilename + std::to_string(i) + "." + extension; std::string filePath = rawFilename + std::to_string(i) + "." + extension;
FILE* fileHandler = fopen(path.c_str(), "rb"); if (count == 1) filePath = path;
TYRA_ASSERT(fileHandler != nullptr, "Failed to load: ", path);
loadFile(fileHandler, path, i - 1, data, result); FILE* fileHandler = fopen(filePath.c_str(), "rb");
TYRA_ASSERT(fileHandler != nullptr, "Failed to load: ", filePath);
loadFile(fileHandler, filePath, i - 1, data, result);
fclose(fileHandler); fclose(fileHandler);
} }
@@ -64,24 +64,20 @@ void McpipClip::addData(McpipBlock* block, const bool& isMulti,
for (u32 i = 0; i < blockData->count / 3; i++) { for (u32 i = 0; i < blockData->count / 3; i++) {
for (u8 j = 0; j < 3; j++) { for (u8 j = 0; j < 3; j++) {
EEClipVertex vert = {mvp * blockData->vertices[i * 3 + j], Vec4(), inputVerts[j] = mvp * blockData->vertices[i * 3 + j];
blockData->textureCoords[i * 3 + j], Vec4()}; inputTriangle[j] = {&inputVerts[j], nullptr,
&blockData->textureCoords[i * 3 + j], nullptr};
inputTriangle.push_back(vert);
} }
clippedTriangle.clear(); u8 clippedSize =
algorithm.clip(clippedTriangle, inputTriangle, algoSettings);
algorithm.clip(&clippedTriangle, inputTriangle, algoSettings); if (clippedSize == 0) continue;
inputTriangle.clear(); auto va = clippedTriangle[0];
for (u8 j = 1; j <= clippedSize - 2; j++) {
if (clippedTriangle.size() == 0) continue; auto vb = clippedTriangle[j];
auto vc = clippedTriangle[(j + 1) % clippedSize];
auto va = clippedTriangle.at(0);
for (u32 j = 1; j <= clippedTriangle.size() - 2; j++) {
auto vb = clippedTriangle.at(j);
auto vc = clippedTriangle.at((j + 1) % clippedTriangle.size());
clippedVertices.push_back(va); clippedVertices.push_back(va);
clippedVertices.push_back(vb); clippedVertices.push_back(vb);
clippedVertices.push_back(vc); clippedVertices.push_back(vc);
@@ -52,6 +52,11 @@ StaPipBagPackagesBBox::StaPipBagPackagesBBox(Vec4* t_vertices,
mainBBox = new RenderBBox(*bboxParts, 0, partsCount); mainBBox = new RenderBBox(*bboxParts, 0, partsCount);
} }
StaPipBagPackagesBBox::~StaPipBagPackagesBBox() {
delete bboxParts;
delete mainBBox;
}
const RenderBBox& StaPipBagPackagesBBox::getChildBBox1By3( const RenderBBox& StaPipBagPackagesBBox::getChildBBox1By3(
const u32& index) const { const u32& index) const {
TYRA_ASSERT(index < partsCount, TYRA_ASSERT(index < partsCount,
@@ -106,9 +111,4 @@ std::string StaPipBagPackagesBBox::getPrint(const char* name) const {
return res.str(); return res.str();
} }
StaPipBagPackagesBBox::~StaPipBagPackagesBBox() {
delete bboxParts;
delete mainBBox;
}
} // namespace Tyra } // namespace Tyra
@@ -34,26 +34,24 @@ void StaPipClipper::clip(StaPipQBuffer* buffer) {
std::vector<EEClipVertex> clippedVertices; std::vector<EEClipVertex> clippedVertices;
for (u32 i = 0; i < buffer->size / 3; i++) { for (u32 i = 0; i < buffer->size / 3; i++) {
std::vector<EEClipVertex> inputTriangle;
for (u8 j = 0; j < 3; j++) { for (u8 j = 0; j < 3; j++) {
EEClipVertex vert = { inputVerts[j] = *mvp * buffer->vertices[i * 3 + j];
*mvp * buffer->vertices[i * 3 + j], inputTriangle[j] = {
buffer->bag->lighting ? buffer->normals[i * 3 + j] : Vec4(), &inputVerts[j],
buffer->bag->texture ? buffer->sts[i * 3 + j] : Vec4(), buffer->bag->lighting ? &buffer->normals[i * 3 + j] : nullptr,
buffer->bag->color->many ? buffer->colors[i * 3 + j] : Vec4()}; buffer->bag->texture ? &buffer->sts[i * 3 + j] : nullptr,
buffer->bag->color->many ? &buffer->colors[i * 3 + j] : nullptr};
inputTriangle.push_back(vert);
} }
std::vector<EEClipVertex> clippedTriangle; u8 clippedSize =
algorithm.clip(&clippedTriangle, inputTriangle, algoSettings); algorithm.clip(clippedTriangle, inputTriangle, algoSettings);
if (clippedTriangle.size() == 0) continue; if (clippedSize == 0) continue;
auto va = clippedTriangle.at(0); auto va = clippedTriangle[0];
for (u32 j = 1; j <= clippedTriangle.size() - 2; j++) { for (u8 j = 1; j <= clippedSize - 2; j++) {
auto vb = clippedTriangle.at(j); auto vb = clippedTriangle[j];
auto vc = clippedTriangle.at((j + 1) % clippedTriangle.size()); auto vc = clippedTriangle[(j + 1) % clippedSize];
clippedVertices.push_back(va); clippedVertices.push_back(va);
clippedVertices.push_back(vb); clippedVertices.push_back(vb);
clippedVertices.push_back(vc); clippedVertices.push_back(vc);
@@ -91,7 +91,12 @@ void StaPipCore::render(StaPipBag* bag, const bool& frustumCull,
frustumCheck = renderBbox->getMainBBox()->clipIsInFrustum( frustumCheck = renderBbox->getMainBBox()->clipIsInFrustum(
rendererCore->renderer3D.frustumPlanes.getAll(), *bag->info->model); rendererCore->renderer3D.frustumPlanes.getAll(), *bag->info->model);
if (frustumCheck == OUTSIDE_FRUSTUM) return; if (frustumCheck == OUTSIDE_FRUSTUM) {
if (frustumCull && !bbox) {
delete renderBbox;
}
return;
}
} }
packager.setRenderBBox(renderBbox); packager.setRenderBBox(renderBbox);
@@ -157,7 +162,9 @@ void StaPipCore::render(StaPipBag* bag, const bool& frustumCull,
} }
} }
if (frustumCull && !bbox) delete renderBbox; if (frustumCull && !bbox) {
delete renderBbox;
}
if (texBuffers) delete texBuffers; if (texBuffers) delete texBuffers;
qbufferRenderer.flushBuffers(); qbufferRenderer.flushBuffers();
@@ -12,34 +12,52 @@
namespace Tyra { namespace Tyra {
EEClipAlgorithm::EEClipAlgorithm() {} EEClipAlgorithm::EEClipAlgorithm() { tempVertices = new EEClipVertex[9]; }
EEClipAlgorithm::~EEClipAlgorithm() {} EEClipAlgorithm::~EEClipAlgorithm() { delete[] tempVertices; }
float EEClipAlgorithm::clipMargin = -10.0F; float EEClipAlgorithm::clipMargin = -10.0F;
void EEClipAlgorithm::init(const RendererSettings& settings) { void EEClipAlgorithm::init(const RendererSettings& settings) {
halfWidth = settings.getWidth() / 2; // halfWidth = settings.getWidth() / 2;
halfHeight = settings.getHeight() / 2; // halfHeight = settings.getHeight() / 2;
halfWidth = 0.5F;
halfHeight = 0.5F;
near = settings.getNear() - (-clipMargin); near = settings.getNear() - (-clipMargin);
far = -settings.getFar(); far = -settings.getFar();
} }
void EEClipAlgorithm::clip(std::vector<EEClipVertex>* o_vertices, u8 EEClipAlgorithm::clip(EEClipVertex* o_vertices, EEClipVertexPtrs* i_vertices,
const std::vector<EEClipVertex>& vertices, const EEClipAlgorithmSettings& settings) {
const EEClipAlgorithmSettings& settings) { for (int i = 0; i < 3; i++) {
tempVertices.clear(); o_vertices[i].position = *i_vertices[i].position;
if (settings.lerpColors) o_vertices[i].color = *i_vertices[i].color;
for (u32 i = 0; i < vertices.size(); i++) { if (settings.lerpNormals) o_vertices[i].normal = *i_vertices[i].normal;
o_vertices->push_back(vertices.at(i)); if (settings.lerpTexCoords) o_vertices[i].st = *i_vertices[i].st;
} }
clipAgainstPlane(*o_vertices, &tempVertices, 1, halfWidth, settings); u8 tempVerticesSize = 0;
clipAgainstPlane(tempVertices, o_vertices, 1, -halfWidth, settings); u8 outputSize = 0;
clipAgainstPlane(*o_vertices, &tempVertices, 2, halfHeight, settings);
clipAgainstPlane(tempVertices, o_vertices, 2, -halfHeight, settings); tempVerticesSize =
clipAgainstPlane(*o_vertices, &tempVertices, 3, near, settings); clipAgainstPlane(o_vertices, 3, tempVertices, 1, halfWidth, settings);
clipAgainstPlane(tempVertices, o_vertices, 4, far, settings);
outputSize = clipAgainstPlane(tempVertices, tempVerticesSize, o_vertices, 1,
-halfWidth, settings);
tempVerticesSize = clipAgainstPlane(o_vertices, outputSize, tempVertices, 2,
halfHeight, settings);
outputSize = clipAgainstPlane(tempVertices, tempVerticesSize, o_vertices, 2,
-halfHeight, settings);
tempVerticesSize =
clipAgainstPlane(o_vertices, outputSize, tempVertices, 3, near, settings);
outputSize = clipAgainstPlane(tempVertices, tempVerticesSize, o_vertices, 4,
far, settings);
return outputSize;
} }
float EEClipAlgorithm::getValueByPlane(const EEClipVertex& v, float EEClipAlgorithm::getValueByPlane(const EEClipVertex& v,
@@ -70,22 +88,23 @@ bool EEClipAlgorithm::isInside(const int& plane, const float& v, const float& w,
} }
} }
void EEClipAlgorithm::clipAgainstPlane( u8 EEClipAlgorithm::clipAgainstPlane(EEClipVertex* original,
const std::vector<EEClipVertex>& original, const u8& originalSize,
std::vector<EEClipVertex>* clipped, const int& plane, EEClipVertex* clipped, const int& plane,
const float& planeLimitValue, const EEClipAlgorithmSettings& settings) { const float& planeLimitValue,
clipped->clear(); const EEClipAlgorithmSettings& settings) {
int clippedSize = 0;
for (u32 i = 0; i < original.size(); i++) { for (u32 i = 0; i < originalSize; i++) {
auto a = original.at(i); auto a = original[i];
auto b = original.at((i + 1) % original.size()); auto b = original[(i + 1) % originalSize];
auto apx = getValueByPlane(a, plane); auto apx = getValueByPlane(a, plane);
auto bpx = getValueByPlane(b, plane); auto bpx = getValueByPlane(b, plane);
auto aIsInside = isInside(plane, apx, a.position.w, planeLimitValue); auto aIsInside = isInside(plane, apx, a.position.w, planeLimitValue);
auto bIsInside = isInside(plane, bpx, b.position.w, planeLimitValue); auto bIsInside = isInside(plane, bpx, b.position.w, planeLimitValue);
if (aIsInside) { if (aIsInside) {
clipped->push_back(a); clipped[clippedSize++] = a;
} }
if (aIsInside != bIsInside) { if (aIsInside != bIsInside) {
@@ -96,17 +115,22 @@ void EEClipAlgorithm::clipAgainstPlane(
((b.position.w - a.position.w) * planeLimitValue - ((b.position.w - a.position.w) * planeLimitValue -
(bpx - apx)); (bpx - apx));
EEClipVertex nb = { auto index = clippedSize++;
Vec4::getByLerp(a.position, b.position, p),
settings.lerpNormals ? Vec4::getByLerp(a.normal, b.normal, p)
: Vec4(),
settings.lerpTexCoords ? Vec4::getByLerp(a.st, b.st, p) : Vec4(),
settings.lerpColors ? Vec4::getByLerp(a.color, b.color, p) : Vec4(),
};
clipped->push_back(nb); clipped[index].position = Vec4::getByLerp(a.position, b.position, p);
if (settings.lerpNormals)
clipped[index].normal = Vec4::getByLerp(a.normal, b.normal, p);
if (settings.lerpTexCoords)
clipped[index].st = Vec4::getByLerp(a.st, b.st, p);
if (settings.lerpColors)
clipped[index].color = Vec4::getByLerp(a.color, b.color, p);
} }
} }
return clippedSize;
} }
} // namespace Tyra } // namespace Tyra
@@ -77,7 +77,6 @@ void RendererCoreGS::allocateBuffers() {
zBuffer.address = zBuffer.address =
graph_vram_allocate(frameBuffers[0].width, frameBuffers[0].height, graph_vram_allocate(frameBuffers[0].width, frameBuffers[0].height,
zBuffer.zsm, GRAPH_ALIGN_PAGE); zBuffer.zsm, GRAPH_ALIGN_PAGE);
TYRA_LOG("Framebuffers, zBuffer set and allocated!");
graph_set_mode(GRAPH_MODE_INTERLACED, GRAPH_MODE_NTSC, GRAPH_MODE_FRAME, graph_set_mode(GRAPH_MODE_INTERLACED, GRAPH_MODE_NTSC, GRAPH_MODE_FRAME,
GRAPH_ENABLE); GRAPH_ENABLE);
@@ -95,6 +94,8 @@ void RendererCoreGS::allocateBuffers() {
spaceOccupiedByZBuffer = spaceOccupiedByFrameBuffers; spaceOccupiedByZBuffer = spaceOccupiedByFrameBuffers;
spaceOccupiedByFrameBuffers *= 2; spaceOccupiedByFrameBuffers *= 2;
TYRA_LOG("Framebuffers, zBuffer set and allocated!");
} }
void RendererCoreGS::initDrawingEnvironment() { void RendererCoreGS::initDrawingEnvironment() {
+2
View File
@@ -30,6 +30,7 @@ class H4570 : public Game {
private: private:
Engine* engine; Engine* engine;
StaticMesh* skybox;
DynamicMesh* cube; DynamicMesh* cube;
StaticMesh* staticMesh; StaticMesh* staticMesh;
DynamicMesh* warrior; DynamicMesh* warrior;
@@ -44,6 +45,7 @@ class H4570 : public Game {
MinecraftPipeline mcPip; MinecraftPipeline mcPip;
DynamicPipeline dynpip; DynamicPipeline dynpip;
StaticPipeline stapip; StaticPipeline stapip;
StaPipOptions* skyboxOptions;
StaPipOptions* staOptions; StaPipOptions* staOptions;
DynPipOptions* dynOptions; DynPipOptions* dynOptions;
Texture* warriorTex; Texture* warriorTex;
+44 -20
View File
@@ -30,6 +30,7 @@ H4570::~H4570() {}
StaticMesh* getStaticMesh(Renderer* renderer); StaticMesh* getStaticMesh(Renderer* renderer);
DynamicMesh* getWarrior(Renderer* renderer); DynamicMesh* getWarrior(Renderer* renderer);
StaticMesh* getSkybox(Renderer* renderer);
DynamicMesh* getCube(Renderer* renderer); DynamicMesh* getCube(Renderer* renderer);
StaPipOptions* getStaPipOptions(); StaPipOptions* getStaPipOptions();
DynPipOptions* getDynPipOptions(); DynPipOptions* getDynPipOptions();
@@ -48,6 +49,7 @@ void H4570::init() {
engine->renderer.setClearScreenColor(Color(64.0F, 64.0F, 64.0F)); engine->renderer.setClearScreenColor(Color(64.0F, 64.0F, 64.0F));
staticMesh = getStaticMesh(&engine->renderer); staticMesh = getStaticMesh(&engine->renderer);
skybox = getSkybox(&engine->renderer);
cube = getCube(&engine->renderer); cube = getCube(&engine->renderer);
@@ -55,7 +57,7 @@ void H4570::init() {
warriorTex = engine->renderer.core.texture.repository.getBySpriteOrMesh( warriorTex = engine->renderer.core.texture.repository.getBySpriteOrMesh(
warrior->getMaterial(0)->getId()); warrior->getMaterial(0)->getId());
warriorsCount = 22; warriorsCount = 12;
warriors = new DynamicMesh*[warriorsCount]; warriors = new DynamicMesh*[warriorsCount];
for (u8 i = 0; i < warriorsCount; i++) { for (u8 i = 0; i < warriorsCount; i++) {
warriors[i] = new DynamicMesh(*warrior); warriors[i] = new DynamicMesh(*warrior);
@@ -71,6 +73,11 @@ void H4570::init() {
} }
staOptions = getStaPipOptions(); staOptions = getStaPipOptions();
skyboxOptions = new StaPipOptions();
skyboxOptions->fullClipChecks = true;
skyboxOptions->frustumCulling = PipelineFrustumCulling_Precise;
dynOptions = getDynPipOptions(); dynOptions = getDynPipOptions();
cameraPosition = Vec4(0.0F, 0.0F, 20.0F); cameraPosition = Vec4(0.0F, 0.0F, 20.0F);
@@ -88,9 +95,8 @@ void H4570::init() {
u32 rows = 16; // 64 u32 rows = 16; // 64
u32 columns = 16; // 64 u32 columns = 16; // 64
blocksCount = rows * columns; blocksCount = rows * columns;
float initialCameraZ = -400.0F;
float offset = 40.0F; float offset = 4.0F;
blocks = new McpipBlock[blocksCount]; blocks = new McpipBlock[blocksCount];
translations = new M4x4[blocksCount]; translations = new M4x4[blocksCount];
rotations = new M4x4[blocksCount]; rotations = new M4x4[blocksCount];
@@ -101,10 +107,9 @@ void H4570::init() {
u32 column = i % columns; u32 column = i % columns;
u32 row = i / rows; u32 row = i / rows;
scales[i].scale(10.0F);
translations[i].translateX(row * offset - center); translations[i].translateX(row * offset - center);
translations[i].translateY(column * offset - center); translations[i].translateY(column * offset - center);
translations[i].translateZ(initialCameraZ); translations[i].translateZ(-50.0F);
u32 randRow = rand() % (rows + 1); u32 randRow = rand() % (rows + 1);
u32 randColumn = rand() % (columns + 1); u32 randColumn = rand() % (columns + 1);
@@ -117,7 +122,7 @@ void H4570::init() {
} }
// engine->audio.playSong(); // engine->audio.playSong();
engine->renderer.setFrameLimit(false); // engine->renderer.setFrameLimit(false);
} }
u32 counter = 0; u32 counter = 0;
@@ -132,6 +137,8 @@ void H4570::loop() {
for (u8 i = 0; i < warriorsCount; i++) warriors[i]->animate(); for (u8 i = 0; i < warriorsCount; i++) warriors[i]->animate();
cube->animate(); cube->animate();
skybox->rotation.rotateY(0.02F);
engine->renderer.beginFrame(CameraInfo3D(&cameraPosition, &cameraLookAt)); engine->renderer.beginFrame(CameraInfo3D(&cameraPosition, &cameraLookAt));
{ {
for (u32 i = 0; i < blocksCount; i++) { for (u32 i = 0; i < blocksCount; i++) {
@@ -142,25 +149,28 @@ void H4570::loop() {
blocks[i].model = translations[i] * rotations[i] * scales[i]; blocks[i].model = translations[i] * rotations[i] * scales[i];
} }
engine->renderer.renderer2D.render(picture); // engine->renderer.renderer2D.render(picture);
engine->renderer.renderer3D.usePipeline(&stapip); engine->renderer.renderer3D.usePipeline(&stapip);
{ stapip.render(staticMesh, staOptions); }
engine->renderer.renderer3D.usePipeline(&dynpip);
{ {
dynpip.render(cube); // stapip.render(staticMesh, staOptions);
Threading::switchThread(); stapip.render(skybox, skyboxOptions);
for (u8 i = 0; i < warriorsCount; i++) {
dynpip.render(warriors[i], dynOptions);
if (i == 5) Threading::switchThread();
if (i == 10) Threading::switchThread();
if (i == 15) Threading::switchThread();
}
} }
engine->renderer.renderer3D.usePipeline(&mcPip); // engine->renderer.renderer3D.usePipeline(&dynpip);
{ mcPip.render(blocks, blocksCount, blocksTex); } // {
// dynpip.render(cube);
// Threading::switchThread();
// for (u8 i = 0; i < warriorsCount; i++) {
// dynpip.render(warriors[i], dynOptions);
// if (i == 5) Threading::switchThread();
// if (i == 10) Threading::switchThread();
// if (i == 15) Threading::switchThread();
// }
// }
// engine->renderer.renderer3D.usePipeline(&mcPip);
// { mcPip.render(blocks, blocksCount, blocksTex); }
} }
engine->renderer.endFrame(); engine->renderer.endFrame();
} }
@@ -178,6 +188,20 @@ StaticMesh* getStaticMesh(Renderer* renderer) {
return result; return result;
} }
StaticMesh* getSkybox(Renderer* renderer) {
TyrobjLoader loader;
auto* data =
loader.load(FileUtils::fromCwd("skybox/skybox.tyrobj"), 1, 50.0F, true);
auto* result = new StaticMesh(*data);
result->translation.translateZ(-30.0F);
delete data;
renderer->core.texture.repository.addByMesh(
result, FileUtils::fromCwd("skybox/"), "png");
return result;
}
DynamicMesh* getWarrior(Renderer* renderer) { DynamicMesh* getWarrior(Renderer* renderer) {
MD2Loader loader; MD2Loader loader;
auto* data = loader.load(FileUtils::fromCwd("warrior.md2"), .08F, false); auto* data = loader.load(FileUtils::fromCwd("warrior.md2"), .08F, false);