Fixed bug in material loader that resulted in corrupted displays for materials with > 64 characters in the name

--HG--
extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%4099
This commit is contained in:
kearwood
2012-09-13 23:59:28 +00:00
parent fc1216ffa2
commit 283460acc7
3 changed files with 34 additions and 30 deletions

View File

@@ -90,7 +90,8 @@ void KRInstance::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume
projectionMatrix = pCamera->getProjectionMatrix();
}
if(m_pModel != NULL && (getExtents(pContext).test_intersect(frustrumVolume) || renderPass == RENDER_PASS_SHADOWMAP)) {
if(m_pModel != NULL) {
if(getExtents(pContext).test_intersect(frustrumVolume) || renderPass == RENDER_PASS_SHADOWMAP) {
//if(m_pModel != NULL && (getBounds().visible(viewMatrix * projectionMatrix) || renderPass == RENDER_PASS_SHADOWMAP)) {
if(m_pLightMap == NULL && m_lightMap.size()) {
@@ -116,6 +117,7 @@ void KRInstance::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume
}
}
}
}
#endif
@@ -125,6 +127,7 @@ void KRInstance::calcExtents(KRContext *pContext)
KRNode::calcExtents(pContext);
loadModel();
if(m_pModel != NULL) {
KRMesh *pMesh = m_pModel->getMesh();
KRBoundingVolume mesh_bounds = KRBoundingVolume(pMesh->getMinPoint(), pMesh->getMaxPoint(), m_modelMatrix);
if(m_pExtents) {
@@ -133,6 +136,7 @@ void KRInstance::calcExtents(KRContext *pContext)
m_pExtents = new KRBoundingVolume(mesh_bounds);
}
}
}
bool KRInstance::hasTransparency() {
if(m_pModel) {
@@ -145,6 +149,7 @@ bool KRInstance::hasTransparency() {
KRAABB KRInstance::getBounds() {
calcModelMatrix();
loadModel();
assert(m_pModel != NULL);
KRMesh *pMesh = m_pModel->getMesh();
KRVector3 meshMin = pMesh->getMinPoint();

View File

@@ -97,7 +97,7 @@ vector<KRMesh::Submesh *> KRMesh::getSubmeshes() {
pSubmesh->vertex_count = pPackMaterial->vertex_count;
strncpy(pSubmesh->szMaterialName, pPackMaterial->szName, 256);
pSubmesh->szMaterialName[63] = '\0';
pSubmesh->szMaterialName[255] = '\0';
//fprintf(stderr, "Submesh material: \"%s\"\n", pSubmesh->szMaterialName);
m_submeshes.push_back(pSubmesh);
}

View File

@@ -67,7 +67,6 @@ KRModel::~KRModel() {
void KRModel::render(KRCamera *pCamera, KRContext *pContext, KRMat4 &matModelToView, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRTexture *pLightMap, KRNode::RenderPass renderPass) {
//fprintf(stderr, "Rendering model: %s\n", m_name.c_str());
if(renderPass != KRNode::RENDER_PASS_FLARES) {
if(m_materials.size() == 0) {