Fixed some really stupid bugs.

This commit is contained in:
chronokun 2015-07-22 23:22:52 +12:00
parent 435a16977c
commit 091f81edcb
3 changed files with 16 additions and 6 deletions

View File

@ -14,6 +14,7 @@
#endif
// Platform Libraries
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

View File

@ -32,11 +32,17 @@ TPlanePoints GetPlanePoints(const TVector3f* _kpPoints, const size_t _kNumPoints
}
const TVector3f kCenter = ScalarMultiply(TVector3f(), Temp, (1.0f / (float)_kNumPoints));
float fWidth = 1.0f;
for(size_t i = 0; i < _kNumPoints; ++i)
{
fWidth = std::max(fWidth, VectorMagnitude(Subtract(TVector3f(), _kpPoints[i], kCenter)));
}
// Find Tangent
const TVector3f kTangent = ScalarMultiply(TVector3f(), Normalize(TVector3f(), Subtract(TVector3f(), _kpPoints[1], _kpPoints[0])), 8192.0f);
const TVector3f kTangent = ScalarMultiply(TVector3f(), Normalize(TVector3f(), Subtract(TVector3f(), _kpPoints[1], _kpPoints[0])), fWidth);
// Find BiTangent
const TVector3f kBiTangent = ScalarMultiply(TVector3f(), Normalize(TVector3f(), CrossProduct(TVector3f(), kNormal, kTangent)), 8192.0f);
const TVector3f kBiTangent = ScalarMultiply(TVector3f(), Normalize(TVector3f(), CrossProduct(TVector3f(), kNormal, kTangent)), fWidth);
PlanePoints.m_A = Add(TVector3f(), kCenter, kBiTangent);
PlanePoints.m_B = kCenter;

View File

@ -140,7 +140,7 @@ EParserState CMapParser::ParseBrush(const std::string _Line)
EParserState CMapParser::ParseVertex(const std::string _Line)
{
const size_t kszLineSize = 256;
const size_t kszLineSize = 2048;
char pcLine[kszLineSize];
const char* kpcDelim = " \t";
char* pcToken;
@ -184,7 +184,7 @@ EParserState CMapParser::ParseVertex(const std::string _Line)
EParserState CMapParser::ParseFace(const std::string _Line)
{
const size_t kszLineSize = 256;
const size_t kszLineSize = 2048;
char pcLine[kszLineSize];
const char* kpcDelim = " \t";
char* pcToken;
@ -195,6 +195,8 @@ EParserState CMapParser::ParseFace(const std::string _Line)
int iTokenNum = 0;
std::string material;
std::vector<int> Indices;
while(pcToken != nullptr)
{
@ -209,7 +211,7 @@ EParserState CMapParser::ParseFace(const std::string _Line)
return(PARSERSTATE_BRUSH);
}
}
else if(iTokenNum < 9)
else
{
if(std::isdigit(pcToken[0], std::locale()) || pcToken[0] == '-')
{
@ -218,7 +220,7 @@ EParserState CMapParser::ParseFace(const std::string _Line)
}
else
{
return(PARSERSTATE_BRUSH);
material = pcToken;
}
}
@ -228,6 +230,7 @@ EParserState CMapParser::ParseFace(const std::string _Line)
TFace Face;
Face.m_Indices = Indices;
Face.m_Material = material;
this->m_WorldSpawn.m_Brushes[this->m_WorldSpawn.m_Brushes.size()-1].m_Faces.push_back(Face);
return(PARSERSTATE_FACE);
}