mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-28 11:20:53 +00:00
Changed: Minor changes
This commit is contained in:
parent
58c46d6815
commit
b639b89169
2 changed files with 41 additions and 41 deletions
|
@ -15,7 +15,7 @@
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "zone_utility.h"
|
#include "zone_utility.h"
|
||||||
//
|
//
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
#include "nel/misc/path.h"
|
#include "nel/misc/path.h"
|
||||||
#include "nel/misc/file.h"
|
#include "nel/misc/file.h"
|
||||||
|
@ -54,7 +54,7 @@ struct CPatchVertexInfo
|
||||||
uint patchIndex,
|
uint patchIndex,
|
||||||
uint patchVertex,
|
uint patchVertex,
|
||||||
const CVector &pos
|
const CVector &pos
|
||||||
)
|
)
|
||||||
: ZoneIndex(zoneIndex),
|
: ZoneIndex(zoneIndex),
|
||||||
PatchIndex(patchIndex),
|
PatchIndex(patchIndex),
|
||||||
PatchVertex(patchVertex),
|
PatchVertex(patchVertex),
|
||||||
|
@ -95,7 +95,7 @@ static CZone *LoadZone(uint16 xPos, uint16 yPos, std::string zoneExt)
|
||||||
{
|
{
|
||||||
std::string zoneName;
|
std::string zoneName;
|
||||||
::getZoneNameByCoord(xPos, yPos, zoneName);
|
::getZoneNameByCoord(xPos, yPos, zoneName);
|
||||||
std::auto_ptr<CZone> zone(new CZone);
|
std::auto_ptr<CZone> zone(new CZone);
|
||||||
std::string lookedUpZoneName = CPath::lookup(zoneName + zoneExt, false, false, false);
|
std::string lookedUpZoneName = CPath::lookup(zoneName + zoneExt, false, false, false);
|
||||||
if (lookedUpZoneName.empty()) return NULL;
|
if (lookedUpZoneName.empty()) return NULL;
|
||||||
CIFile iF;
|
CIFile iF;
|
||||||
|
@ -128,7 +128,7 @@ static void GetCandidateVertices(const CVector &pos,
|
||||||
float weldThreshold
|
float weldThreshold
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
dest.clear();
|
dest.clear();
|
||||||
CVector half(weldThreshold, weldThreshold, weldThreshold);
|
CVector half(weldThreshold, weldThreshold, weldThreshold);
|
||||||
qg.select(pos - half, pos + half);
|
qg.select(pos - half, pos + half);
|
||||||
for (TPVQuadGrid::CIterator it = qg.begin(); it != qg.end(); ++it)
|
for (TPVQuadGrid::CIterator it = qg.begin(); it != qg.end(); ++it)
|
||||||
|
@ -146,8 +146,8 @@ static void GetCandidateVertices(const CVector &pos,
|
||||||
//===========================================================================================================================
|
//===========================================================================================================================
|
||||||
/** Search a vertex of a patch that can be welded with the given vertex
|
/** Search a vertex of a patch that can be welded with the given vertex
|
||||||
* return -1 if none
|
* return -1 if none
|
||||||
*/
|
*/
|
||||||
static sint GetWeldableVertex(const CBezierPatch &bp, const CVector &pos, float weldThreshold)
|
static sint GetWeldableVertex(const CBezierPatch &bp, const CVector &pos, float weldThreshold)
|
||||||
{
|
{
|
||||||
for (uint k = 0; k < 4; ++k)
|
for (uint k = 0; k < 4; ++k)
|
||||||
{
|
{
|
||||||
|
@ -166,7 +166,7 @@ static sint GetWeldableVertex(const CBezierPatch &bp, const CVector &pos, float
|
||||||
static uint CheckZone(std::string middleZoneFile, float weldThreshold, float middleEdgeWeldThreshold)
|
static uint CheckZone(std::string middleZoneFile, float weldThreshold, float middleEdgeWeldThreshold)
|
||||||
{
|
{
|
||||||
uint numErrors = 0;
|
uint numErrors = 0;
|
||||||
uint k, l, m, n, p, q; // some loop counters
|
uint k, l, m, n, p, q; // some loop counters
|
||||||
// This avoid reporting errors twice (for readability)
|
// This avoid reporting errors twice (for readability)
|
||||||
std::set<CPatchIdentPair> errorPairs;
|
std::set<CPatchIdentPair> errorPairs;
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
|
|
||||||
std::auto_ptr<CZone> zones[9];
|
std::auto_ptr<CZone> zones[9];
|
||||||
std::string zoneNames[9];
|
std::string zoneNames[9];
|
||||||
CZoneInfo zoneInfos[9];
|
CZoneInfo zoneInfos[9];
|
||||||
uint16 xPos, yPos;
|
uint16 xPos, yPos;
|
||||||
const sint16 posOffs[][2] = { {0, 0}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1} };
|
const sint16 posOffs[][2] = { {0, 0}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1} };
|
||||||
|
|
||||||
|
@ -201,16 +201,16 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
nlinfo("Zones loading failed : %d", e.what());
|
nlinfo("Zones loading failed : %d", e.what());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// retrieve datas from zones //
|
// retrieve datas from zones //
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
for (k = 0; k < 9; ++k)
|
for (k = 0; k < 9; ++k)
|
||||||
{
|
{
|
||||||
::getZoneNameByCoord(xPos + posOffs[k][0], yPos + posOffs[k][1], zoneNames[k]);
|
::getZoneNameByCoord(xPos + posOffs[k][0], yPos + posOffs[k][1], zoneNames[k]);
|
||||||
if (zones[k].get() != NULL) zones[k]->retrieve(zoneInfos[k]);
|
if (zones[k].get() != NULL) zones[k]->retrieve(zoneInfos[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill the quad grid
|
// fill the quad grid
|
||||||
CAABBox zoneBBox = zones[0]->getZoneBB().getAABBox();
|
CAABBox zoneBBox = zones[0]->getZoneBB().getAABBox();
|
||||||
|
@ -222,7 +222,7 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
|
|
||||||
// insert vertices in quadgrid
|
// insert vertices in quadgrid
|
||||||
for (k = 0; k < 9; ++k)
|
for (k = 0; k < 9; ++k)
|
||||||
{
|
{
|
||||||
for (l = 0; l < zoneInfos[k].Patchs.size(); ++l)
|
for (l = 0; l < zoneInfos[k].Patchs.size(); ++l)
|
||||||
{
|
{
|
||||||
CPatchInfo &patch = zoneInfos[k].Patchs[l];
|
CPatchInfo &patch = zoneInfos[k].Patchs[l];
|
||||||
|
@ -236,7 +236,7 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
CVector half(weldThreshold, weldThreshold, weldThreshold);
|
CVector half(weldThreshold, weldThreshold, weldThreshold);
|
||||||
// yes, insert it in the tree
|
// yes, insert it in the tree
|
||||||
qg.insert(pos - half, pos + half, CPatchVertexInfo(k, l, m, pos));
|
qg.insert(pos - half, pos + half, CPatchVertexInfo(k, l, m, pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,11 +246,11 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
for (l = 0; l < zoneInfos[0].Patchs.size(); ++l)
|
for (l = 0; l < zoneInfos[0].Patchs.size(); ++l)
|
||||||
{
|
{
|
||||||
CPatchInfo &patch = zoneInfos[0].Patchs[l];
|
CPatchInfo &patch = zoneInfos[0].Patchs[l];
|
||||||
// deals with each border
|
// deals with each border
|
||||||
for (m = 0; m < 4; ++m)
|
for (m = 0; m < 4; ++m)
|
||||||
{
|
{
|
||||||
// if this border is said to be bound, no need to test..
|
// if this border is said to be bound, no need to test..
|
||||||
if (patch.BindEdges[m].NPatchs == 0)
|
if (patch.BindEdges[m].NPatchs == 0)
|
||||||
{
|
{
|
||||||
|
@ -271,10 +271,10 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
::GetCandidateVertices(patch.Patch.Vertices[vIndex[q]], qg, verts[q], l, 0, weldThreshold);
|
::GetCandidateVertices(patch.Patch.Vertices[vIndex[q]], qg, verts[q], l, 0, weldThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// 1 - 1 connectivity ? //
|
// 1 - 1 connectivity ? //
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// If there is a patch that is present in the 2 lists, then this is a 1-1 error
|
// If there is a patch that is present in the 2 lists, then this is a 1-1 error
|
||||||
for (n = 0; n < verts[0].size() && !errorFound; ++n)
|
for (n = 0; n < verts[0].size() && !errorFound; ++n)
|
||||||
{
|
{
|
||||||
|
@ -288,9 +288,9 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
CPatchIdentPair errPair = std::make_pair(pi1, pi2);
|
CPatchIdentPair errPair = std::make_pair(pi1, pi2);
|
||||||
//
|
//
|
||||||
if (std::find(errorPairs.begin(), errorPairs.end(), errPair) == errorPairs.end()) // error already displayed ?
|
if (std::find(errorPairs.begin(), errorPairs.end(), errPair) == errorPairs.end()) // error already displayed ?
|
||||||
{
|
{
|
||||||
nlinfo("**** Patch %d of zone %s has 1 - 1 connectivity error, try binding it with patch %d of zone %s",
|
nlinfo("**** Patch %d of zone %s has 1 - 1 connectivity error, try binding it with patch %d of zone %s",
|
||||||
l + 1, middleZoneName.c_str(), verts[0][n]->PatchIndex + 1, zoneNames[verts[0][n]->ZoneIndex].c_str());
|
l + 1, middleZoneName.c_str(), verts[0][n]->PatchIndex + 1, zoneNames[verts[0][n]->ZoneIndex].c_str());
|
||||||
errorPairs.insert(std::make_pair(pi2, pi1));
|
errorPairs.insert(std::make_pair(pi2, pi1));
|
||||||
++numErrors;
|
++numErrors;
|
||||||
}
|
}
|
||||||
|
@ -303,10 +303,10 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// 1 - 2 connectivity ? //
|
// 1 - 2 connectivity ? //
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
// get the position at the middle of that border
|
// get the position at the middle of that border
|
||||||
CVector middlePos = patch.Patch.eval( 0.5f * (indexToST[vIndex[0]][0] + indexToST[vIndex[1]][0]),
|
CVector middlePos = patch.Patch.eval( 0.5f * (indexToST[vIndex[0]][0] + indexToST[vIndex[1]][0]),
|
||||||
0.5f * (indexToST[vIndex[0]][1] + indexToST[vIndex[1]][1]) );
|
0.5f * (indexToST[vIndex[0]][1] + indexToST[vIndex[1]][1]) );
|
||||||
|
|
||||||
// for each vertex of this border
|
// for each vertex of this border
|
||||||
for (q = 0; q < 2 && !errorFound; ++q)
|
for (q = 0; q < 2 && !errorFound; ++q)
|
||||||
|
@ -330,24 +330,24 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
CPatchIdentPair errPair = std::make_pair(pi1, pi2);
|
CPatchIdentPair errPair = std::make_pair(pi1, pi2);
|
||||||
//
|
//
|
||||||
if (std::find(errorPairs.begin(), errorPairs.end(), errPair) == errorPairs.end()) // error already displayed ?
|
if (std::find(errorPairs.begin(), errorPairs.end(), errPair) == errorPairs.end()) // error already displayed ?
|
||||||
{
|
{
|
||||||
nlinfo("**** Patch %d of zone %s has 1 - 2 connectivity error, try binding it with patch %d of zone %s",
|
nlinfo("**** Patch %d of zone %s has 1 - 2 connectivity error, try binding it with patch %d of zone %s",
|
||||||
l + 1, middleZoneName.c_str(), pv.PatchIndex + 1, zoneNames[pv.ZoneIndex].c_str());
|
l + 1, middleZoneName.c_str(), pv.PatchIndex + 1, zoneNames[pv.ZoneIndex].c_str());
|
||||||
errorPairs.insert(std::make_pair(pi2, pi1));
|
errorPairs.insert(std::make_pair(pi2, pi1));
|
||||||
++numErrors;
|
++numErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
errorFound = true;
|
errorFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (errorFound) continue;
|
if (errorFound) continue;
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// 1 - 4 connectivity ? //
|
// 1 - 4 connectivity ? //
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
// compute points along the border.
|
// compute points along the border.
|
||||||
CVector borderPos[5];
|
CVector borderPos[5];
|
||||||
float lambda = 0.f;
|
float lambda = 0.f;
|
||||||
|
@ -356,12 +356,12 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
borderPos[n] = patch.Patch.eval((1.f - lambda) * indexToST[vIndex[0]][0] + lambda * indexToST[vIndex[1]][0],
|
borderPos[n] = patch.Patch.eval((1.f - lambda) * indexToST[vIndex[0]][0] + lambda * indexToST[vIndex[1]][0],
|
||||||
(1.f - lambda) * indexToST[vIndex[0]][1] + lambda * indexToST[vIndex[1]][1]);
|
(1.f - lambda) * indexToST[vIndex[0]][1] + lambda * indexToST[vIndex[1]][1]);
|
||||||
lambda += 0.25f;
|
lambda += 0.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find a patch that shares 2 consecutives vertices
|
// Try to find a patch that shares 2 consecutives vertices
|
||||||
for (k = 0; k < 4 && !errorFound; ++k)
|
for (k = 0; k < 4 && !errorFound; ++k)
|
||||||
{
|
{
|
||||||
::GetCandidateVertices(borderPos[k], qg, verts[0], l, 0, middleEdgeWeldThreshold);
|
::GetCandidateVertices(borderPos[k], qg, verts[0], l, 0, middleEdgeWeldThreshold);
|
||||||
for (p = 0; p < verts[0].size() && !errorFound; ++p)
|
for (p = 0; p < verts[0].size() && !errorFound; ++p)
|
||||||
{
|
{
|
||||||
const CPatchVertexInfo &pv = *(verts[0][p]);
|
const CPatchVertexInfo &pv = *(verts[0][p]);
|
||||||
|
@ -382,16 +382,16 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
CPatchIdentPair errPair = std::make_pair(pi1, pi2);
|
CPatchIdentPair errPair = std::make_pair(pi1, pi2);
|
||||||
//
|
//
|
||||||
if (std::find(errorPairs.begin(), errorPairs.end(), errPair) == errorPairs.end()) // error already displayed ?
|
if (std::find(errorPairs.begin(), errorPairs.end(), errPair) == errorPairs.end()) // error already displayed ?
|
||||||
{
|
{
|
||||||
nlinfo("**** Patch %d of zone %s has 1 - 4 connectivity error, try binding it with patch %d of zone %s",
|
nlinfo("**** Patch %d of zone %s has 1 - 4 connectivity error, try binding it with patch %d of zone %s",
|
||||||
l + 1, middleZoneName.c_str(), pv.PatchIndex + 1, zoneNames[pv.ZoneIndex].c_str());
|
l + 1, middleZoneName.c_str(), pv.PatchIndex + 1, zoneNames[pv.ZoneIndex].c_str());
|
||||||
++numErrors;
|
++numErrors;
|
||||||
errorPairs.insert(std::make_pair(pi2, pi1));
|
errorPairs.insert(std::make_pair(pi2, pi1));
|
||||||
}
|
}
|
||||||
errorFound = true;
|
errorFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,14 +406,14 @@ static uint CheckZone(std::string middleZoneFile, float weldThreshold, float mid
|
||||||
|
|
||||||
//=========================================================================================================================
|
//=========================================================================================================================
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
NLMISC::createDebug();
|
NLMISC::createDebug();
|
||||||
InfoLog->addNegativeFilter("adding the path");
|
InfoLog->addNegativeFilter("adding the path");
|
||||||
|
|
||||||
if (argc < 4)
|
if (argc < 4)
|
||||||
{
|
{
|
||||||
std::string appName = CFile::getFilename(std::string(argv[0]));
|
std::string appName = CFile::getFilename(std::string(argv[0]));
|
||||||
nlinfo("usage : %s <zonesDirectory><weldTheshold><middleEdgeWeldTheshold>\n", appName.empty() ? "zone_check_bind" : appName.c_str());
|
nlinfo("usage : %s <zonesDirectory><weldTheshold><middleEdgeWeldTheshold>\n", appName.empty() ? "zone_check_bind" : appName.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,10 +442,10 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// Filter addSearchPath
|
// Filter addSearchPath
|
||||||
CPath::addSearchPath(zonePaths);
|
CPath::addSearchPath(zonePaths);
|
||||||
|
|
||||||
// Contains all the zone in the directory
|
// Contains all the zone in the directory
|
||||||
std::vector<std::string> zoneNames;
|
std::vector<std::string> zoneNames;
|
||||||
|
|
||||||
CPath::getPathContent(zonePaths, true, false, true, zoneNames);
|
CPath::getPathContent(zonePaths, true, false, true, zoneNames);
|
||||||
|
|
||||||
uint numErrors = 0;
|
uint numErrors = 0;
|
||||||
|
@ -461,4 +461,4 @@ int main(int argc, char* argv[])
|
||||||
nlinfo("%d errors were found", numErrors);
|
nlinfo("%d errors were found", numErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1618,7 +1618,7 @@ nlassert(nodeLeaf->getType() == ICDBStructNode::TEXT);
|
||||||
// {
|
// {
|
||||||
// if( args.size() == 0 )
|
// if( args.size() == 0 )
|
||||||
// return false;
|
// return false;
|
||||||
//
|
//
|
||||||
// NLMEMORY::StatisticsReport( args[0].c_str(), args.size() > 1 );
|
// NLMEMORY::StatisticsReport( args[0].c_str(), args.size() > 1 );
|
||||||
// return true;
|
// return true;
|
||||||
//}
|
//}
|
||||||
|
@ -3873,7 +3873,7 @@ NLMISC_COMMAND(displayDatabaseEntry," display a database entry value","<entity i
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.displayNL("Unknown entity %s ",id.toString().c_str());
|
log.displayNL("Unknown entity %s ", id.toString().c_str());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue