some optimizations
This commit is contained in:
@@ -64,24 +64,20 @@ void McpipClip::addData(McpipBlock* block, const bool& isMulti,
|
||||
|
||||
for (u32 i = 0; i < blockData->count / 3; i++) {
|
||||
for (u8 j = 0; j < 3; j++) {
|
||||
EEClipVertex vert = {mvp * blockData->vertices[i * 3 + j], Vec4(),
|
||||
blockData->textureCoords[i * 3 + j], Vec4()};
|
||||
|
||||
inputTriangle.push_back(vert);
|
||||
inputVerts[j] = mvp * blockData->vertices[i * 3 + j];
|
||||
inputTriangle[j] = {&inputVerts[j], nullptr,
|
||||
&blockData->textureCoords[i * 3 + j], nullptr};
|
||||
}
|
||||
|
||||
clippedTriangle.clear();
|
||||
u8 clippedSize =
|
||||
algorithm.clip(clippedTriangle, inputTriangle, algoSettings);
|
||||
|
||||
algorithm.clip(&clippedTriangle, inputTriangle, algoSettings);
|
||||
if (clippedSize == 0) continue;
|
||||
|
||||
inputTriangle.clear();
|
||||
|
||||
if (clippedTriangle.size() == 0) continue;
|
||||
|
||||
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());
|
||||
auto va = clippedTriangle[0];
|
||||
for (u8 j = 1; j <= clippedSize - 2; j++) {
|
||||
auto vb = clippedTriangle[j];
|
||||
auto vc = clippedTriangle[(j + 1) % clippedSize];
|
||||
clippedVertices.push_back(va);
|
||||
clippedVertices.push_back(vb);
|
||||
clippedVertices.push_back(vc);
|
||||
|
||||
+5
-5
@@ -52,6 +52,11 @@ StaPipBagPackagesBBox::StaPipBagPackagesBBox(Vec4* t_vertices,
|
||||
mainBBox = new RenderBBox(*bboxParts, 0, partsCount);
|
||||
}
|
||||
|
||||
StaPipBagPackagesBBox::~StaPipBagPackagesBBox() {
|
||||
delete bboxParts;
|
||||
delete mainBBox;
|
||||
}
|
||||
|
||||
const RenderBBox& StaPipBagPackagesBBox::getChildBBox1By3(
|
||||
const u32& index) const {
|
||||
TYRA_ASSERT(index < partsCount,
|
||||
@@ -106,9 +111,4 @@ std::string StaPipBagPackagesBBox::getPrint(const char* name) const {
|
||||
return res.str();
|
||||
}
|
||||
|
||||
StaPipBagPackagesBBox::~StaPipBagPackagesBBox() {
|
||||
delete bboxParts;
|
||||
delete mainBBox;
|
||||
}
|
||||
|
||||
} // namespace Tyra
|
||||
|
||||
@@ -34,26 +34,24 @@ void StaPipClipper::clip(StaPipQBuffer* buffer) {
|
||||
std::vector<EEClipVertex> clippedVertices;
|
||||
|
||||
for (u32 i = 0; i < buffer->size / 3; i++) {
|
||||
std::vector<EEClipVertex> inputTriangle;
|
||||
for (u8 j = 0; j < 3; j++) {
|
||||
EEClipVertex vert = {
|
||||
*mvp * buffer->vertices[i * 3 + j],
|
||||
buffer->bag->lighting ? buffer->normals[i * 3 + j] : Vec4(),
|
||||
buffer->bag->texture ? buffer->sts[i * 3 + j] : Vec4(),
|
||||
buffer->bag->color->many ? buffer->colors[i * 3 + j] : Vec4()};
|
||||
|
||||
inputTriangle.push_back(vert);
|
||||
inputVerts[j] = *mvp * buffer->vertices[i * 3 + j];
|
||||
inputTriangle[j] = {
|
||||
&inputVerts[j],
|
||||
buffer->bag->lighting ? &buffer->normals[i * 3 + j] : nullptr,
|
||||
buffer->bag->texture ? &buffer->sts[i * 3 + j] : nullptr,
|
||||
buffer->bag->color->many ? &buffer->colors[i * 3 + j] : nullptr};
|
||||
}
|
||||
|
||||
std::vector<EEClipVertex> clippedTriangle;
|
||||
algorithm.clip(&clippedTriangle, inputTriangle, algoSettings);
|
||||
u8 clippedSize =
|
||||
algorithm.clip(clippedTriangle, inputTriangle, algoSettings);
|
||||
|
||||
if (clippedTriangle.size() == 0) continue;
|
||||
if (clippedSize == 0) continue;
|
||||
|
||||
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());
|
||||
auto va = clippedTriangle[0];
|
||||
for (u8 j = 1; j <= clippedSize - 2; j++) {
|
||||
auto vb = clippedTriangle[j];
|
||||
auto vc = clippedTriangle[(j + 1) % clippedSize];
|
||||
clippedVertices.push_back(va);
|
||||
clippedVertices.push_back(vb);
|
||||
clippedVertices.push_back(vc);
|
||||
|
||||
@@ -91,7 +91,12 @@ void StaPipCore::render(StaPipBag* bag, const bool& frustumCull,
|
||||
frustumCheck = renderBbox->getMainBBox()->clipIsInFrustum(
|
||||
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);
|
||||
@@ -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;
|
||||
|
||||
qbufferRenderer.flushBuffers();
|
||||
|
||||
Reference in New Issue
Block a user