mirror of https://github.com/AxioDL/metaforce.git
VISIGen linux fixes
This commit is contained in:
parent
7bbf8852de
commit
e0e966b241
|
@ -28,7 +28,7 @@ EPVSVisSetState CPVSVisSet::GetVisible(u32 idx) const
|
|||
}
|
||||
|
||||
/* This is a light lookup */
|
||||
u32 lightTest = idx - numFeatures + x4_numBits;
|
||||
u32 lightTest = idx - numFeatures + idx;
|
||||
const u8* ptr = &x10_ptr[lightTest / 8];
|
||||
lightTest &= 0x7;
|
||||
if (lightTest != 0x7)
|
||||
|
|
|
@ -287,7 +287,15 @@ int main(int argc, const char** argv)
|
|||
|
||||
renderer.Run(UpdatePercent);
|
||||
clientRunning = false;
|
||||
pthread_kill(mainThread, SIGUSR2);
|
||||
|
||||
XLockDisplay(xDisp);
|
||||
XClientMessageEvent exitEvent = {};
|
||||
exitEvent.type = ClientMessage;
|
||||
exitEvent.window = windowId;
|
||||
exitEvent.format = 32;
|
||||
XSendEvent(xDisp, windowId, 0, 0, (XEvent*)&exitEvent);
|
||||
XFlush(xDisp);
|
||||
XUnlockDisplay(xDisp);
|
||||
});
|
||||
initcv.wait(outerLk);
|
||||
|
||||
|
@ -317,9 +325,11 @@ int main(int argc, const char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
printf("Joining\n");
|
||||
renderer.Terminate();
|
||||
if (clientThread.joinable())
|
||||
clientThread.join();
|
||||
|
||||
printf("Returning\n");
|
||||
return renderer.ReturnVal();
|
||||
}
|
||||
|
|
|
@ -203,8 +203,9 @@ static const int NumChildTable[] =
|
|||
void VISIBuilder::Node::calculateSizesAndOffs(size_t& cur, size_t leafSz)
|
||||
{
|
||||
cur += 1;
|
||||
flags |= 0x18;
|
||||
|
||||
if (flags)
|
||||
if (flags & 0x7)
|
||||
{
|
||||
int splits[3];
|
||||
splits[0] = (flags & 0x1) ? 2 : 1;
|
||||
|
@ -245,7 +246,6 @@ void VISIBuilder::Node::calculateSizesAndOffs(size_t& cur, size_t leafSz)
|
|||
else
|
||||
{
|
||||
cur += leafSz;
|
||||
flags |= 0x18;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ std::vector<uint8_t> VISIBuilder::build(const zeus::CAABox& fullAabb,
|
|||
Log.report(logvisor::Info, "Started!");
|
||||
|
||||
size_t featureCount = modelCount + entities.size();
|
||||
renderCache.m_lightMetaBit = featureCount + lights.size();
|
||||
renderCache.m_lightMetaBit = featureCount;
|
||||
|
||||
Progress prog(updatePercent);
|
||||
bool& terminate = renderCache.m_renderer.m_terminate;
|
||||
|
@ -318,13 +318,12 @@ std::vector<uint8_t> VISIBuilder::build(const zeus::CAABox& fullAabb,
|
|||
return {};
|
||||
|
||||
// Lights cache their CPVSVisSet result enum as 2 bits
|
||||
size_t leafBitsCount = featureCount + lights.size() * 3;
|
||||
size_t leafBitsCount = featureCount + lights.size() * 2;
|
||||
size_t leafBytesCount = ROUND_UP_8(leafBitsCount) / 8;
|
||||
|
||||
// Calculate octree size and store relative offsets
|
||||
size_t octreeSz = 0;
|
||||
rootNode.calculateSizesAndOffs(octreeSz, leafBytesCount);
|
||||
octreeSz += 1; // Terminator node
|
||||
|
||||
size_t visiSz = 34 + entities.size() * 4 + lights.size() * leafBytesCount + 36 + octreeSz;
|
||||
size_t roundedVisiSz = ROUND_UP_32(visiSz);
|
||||
|
@ -355,11 +354,10 @@ std::vector<uint8_t> VISIBuilder::build(const zeus::CAABox& fullAabb,
|
|||
|
||||
w.writeVec3fBig(fullAabb.min);
|
||||
w.writeVec3fBig(fullAabb.max);
|
||||
w.writeUint32Big(leafBitsCount);
|
||||
w.writeUint32Big(featureCount + lights.size());
|
||||
w.writeUint32Big(lights.size());
|
||||
w.writeUint32Big(octreeSz);
|
||||
rootNode.writeNodes(w, leafBytesCount);
|
||||
w.writeUByte(0x10);
|
||||
|
||||
w.seekAlign32();
|
||||
|
||||
|
|
|
@ -415,7 +415,6 @@ void VISIRenderer::RenderPVSEntitiesAndLights(const std::function<void(int)>& pa
|
|||
{
|
||||
if (!frustum.pointFrustumTest(light.point))
|
||||
{
|
||||
++idx;
|
||||
++lightIdx;
|
||||
continue;
|
||||
}
|
||||
|
@ -427,14 +426,9 @@ void VISIRenderer::RenderPVSEntitiesAndLights(const std::function<void(int)>& pa
|
|||
glGetQueryObjectiv(m_query, GL_QUERY_RESULT, &res);
|
||||
EPVSVisSetState state = m_totalAABB.pointInside(light.point) ?
|
||||
EPVSVisSetState::EndOfTree : EPVSVisSetState::OutOfBounds;
|
||||
if (res)
|
||||
{
|
||||
passFunc(idx);
|
||||
if (state == EPVSVisSetState::EndOfTree)
|
||||
state = EPVSVisSetState::NodeFound;
|
||||
}
|
||||
if (res && state == EPVSVisSetState::EndOfTree)
|
||||
state = EPVSVisSetState::NodeFound;
|
||||
lightPassFunc(lightIdx, state);
|
||||
++idx;
|
||||
++lightIdx;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue