Commit d1fe8248 authored by Drake Arconis's avatar Drake Arconis
Browse files

Fix a possible crash due to null face

parent 6abf16e6
......@@ -3986,94 +3986,96 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a&
if (face_hit >= 0 && mDrawable->getNumFaces() > face_hit)
{
LLFace* face = mDrawable->getFace(face_hit);
bool ignore_alpha = false;
const LLTextureEntry* te = face->getTextureEntry();
if (te)
if (face)
{
LLMaterial* mat = te->getMaterialParams();
if (mat)
{
U8 mode = mat->getDiffuseAlphaMode();
bool ignore_alpha = false;
if (mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE ||
mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE)
const LLTextureEntry* te = face->getTextureEntry();
if (te)
{
LLMaterial* mat = te->getMaterialParams();
if (mat)
{
ignore_alpha = true;
U8 mode = mat->getDiffuseAlphaMode();
if (mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE ||
mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE)
{
ignore_alpha = true;
}
}
}
}
if (face &&
(ignore_alpha ||
pick_transparent ||
!face->getTexture() ||
!face->getTexture()->hasGLTexture() ||
face->getTexture()->getMask(face->surfaceToTexture(tc, p, n))))
{
local_end = p;
if (face_hitp != NULL)
if (
(ignore_alpha ||
pick_transparent ||
!face->getTexture() ||
!face->getTexture()->hasGLTexture() ||
face->getTexture()->getMask(face->surfaceToTexture(tc, p, n))))
{
*face_hitp = face_hit;
}
if (intersection != NULL)
{
if (transform)
{
LLVector3 v_p(p.getF32ptr());
intersection->load3(volumePositionToAgent(v_p).mV); // must map back to agent space
}
else
local_end = p;
if (face_hitp != NULL)
{
*intersection = p;
*face_hitp = face_hit;
}
}
if (normal != NULL)
{
if (transform)
if (intersection != NULL)
{
LLVector3 v_n(n.getF32ptr());
normal->load3(volumeDirectionToAgent(v_n).mV);
if (transform)
{
LLVector3 v_p(p.getF32ptr());
intersection->load3(volumePositionToAgent(v_p).mV); // must map back to agent space
}
else
{
*intersection = p;
}
}
else
if (normal != NULL)
{
*normal = n;
if (transform)
{
LLVector3 v_n(n.getF32ptr());
normal->load3(volumeDirectionToAgent(v_n).mV);
}
else
{
*normal = n;
}
(*normal).normalize3fast();
}
(*normal).normalize3fast();
}
if (tangent != NULL)
{
if (transform)
if (tangent != NULL)
{
LLVector3 v_tn(tn.getF32ptr());
if (transform)
{
LLVector3 v_tn(tn.getF32ptr());
LLVector4a trans_tangent;
trans_tangent.load3(volumeDirectionToAgent(v_tn).mV);
LLVector4a trans_tangent;
trans_tangent.load3(volumeDirectionToAgent(v_tn).mV);
LLVector4Logical mask;
mask.clear();
mask.setElement<3>();
LLVector4Logical mask;
mask.clear();
mask.setElement<3>();
tangent->setSelectWithMask(mask, tn, trans_tangent);
tangent->setSelectWithMask(mask, tn, trans_tangent);
}
else
{
*tangent = tn;
}
(*tangent).normalize3fast();
}
else
if (tex_coord != NULL)
{
*tangent = tn;
*tex_coord = tc;
}
(*tangent).normalize3fast();
}
if (tex_coord != NULL)
{
*tex_coord = tc;
ret = TRUE;
}
ret = TRUE;
}
}
}
......
......@@ -8176,13 +8176,14 @@ void LLPipeline::renderDeferredLighting()
}
sVisibleLightCount++;
if (camera->getOrigin().mV[0] > c[0] + s + 0.2f ||
camera->getOrigin().mV[0] < c[0] - s - 0.2f ||
camera->getOrigin().mV[1] > c[1] + s + 0.2f ||
camera->getOrigin().mV[1] < c[1] - s - 0.2f ||
camera->getOrigin().mV[2] > c[2] + s + 0.2f ||
camera->getOrigin().mV[2] < c[2] - s - 0.2f)
const auto& camera_origin = camera->getOrigin();
if (camera_origin.mV[0] > c[0] + s + 0.2f ||
camera_origin.mV[0] < c[0] - s - 0.2f ||
camera_origin.mV[1] > c[1] + s + 0.2f ||
camera_origin.mV[1] < c[1] - s - 0.2f ||
camera_origin.mV[2] > c[2] + s + 0.2f ||
camera_origin.mV[2] < c[2] - s - 0.2f)
{ //draw box if camera is outside box
if (render_local)
{
......@@ -8700,13 +8701,14 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
}
sVisibleLightCount++;
if (camera->getOrigin().mV[0] > c[0] + s + 0.2f ||
camera->getOrigin().mV[0] < c[0] - s - 0.2f ||
camera->getOrigin().mV[1] > c[1] + s + 0.2f ||
camera->getOrigin().mV[1] < c[1] - s - 0.2f ||
camera->getOrigin().mV[2] > c[2] + s + 0.2f ||
camera->getOrigin().mV[2] < c[2] - s - 0.2f)
const auto& camera_origin = camera->getOrigin();
if (camera_origin.mV[0] > c[0] + s + 0.2f ||
camera_origin.mV[0] < c[0] - s - 0.2f ||
camera_origin.mV[1] > c[1] + s + 0.2f ||
camera_origin.mV[1] < c[1] - s - 0.2f ||
camera_origin.mV[2] > c[2] + s + 0.2f ||
camera_origin.mV[2] < c[2] - s - 0.2f)
{ //draw box if camera is outside box
if (render_local)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment