Unstaged changes cleanup. Further vectorization. Change in binormal/bitangent calculation.

This commit is contained in:
Shyotl
2013-10-09 14:47:06 -05:00
parent b473661cf4
commit f25eb07fab
51 changed files with 1987 additions and 1895 deletions

View File

@@ -30,7 +30,7 @@ ATTRIBUTE vec3 position;
ATTRIBUTE vec4 diffuse_color;
ATTRIBUTE vec3 normal;
ATTRIBUTE vec2 texcoord0;
ATTRIBUTE vec3 binormal;
ATTRIBUTE vec4 tangent;
VARYING vec3 vary_mat0;
VARYING vec3 vary_mat1;
@@ -52,8 +52,8 @@ void main()
vec3 n = normalize((mat * vec4(normal.xyz+position.xyz, 1.0)).xyz-pos.xyz);
vec3 b = normalize((mat * vec4(binormal.xyz+position.xyz, 1.0)).xyz-pos.xyz);
vec3 t = cross(b, n);
vec3 t = normalize((mat * vec4(tangent.xyz+position.xyz, 1.0)).xyz-pos.xyz);
vec3 b = cross(n, t) * tangent.w;
vary_mat0 = vec3(t.x, b.x, n.x);
vary_mat1 = vec3(t.y, b.y, n.y);

View File

@@ -31,7 +31,7 @@ ATTRIBUTE vec3 position;
ATTRIBUTE vec4 diffuse_color;
ATTRIBUTE vec3 normal;
ATTRIBUTE vec2 texcoord0;
ATTRIBUTE vec3 binormal;
ATTRIBUTE vec4 tangent;
VARYING vec3 vary_mat0;
VARYING vec3 vary_mat1;
@@ -46,8 +46,8 @@ void main()
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
vec3 n = normalize(normal_matrix * normal);
vec3 b = normalize(normal_matrix * binormal);
vec3 t = cross(b, n);
vec3 t = normalize(normal_matrix * tangent.xyz);
vec3 b = cross(n, t) * tangent.w;
vary_mat0 = vec3(t.x, b.x, n.x);
vary_mat1 = vec3(t.y, b.y, n.y);

View File

@@ -2093,7 +2093,6 @@ uniform sampler2D diffuseMap;
uniform vec2 rcp_screen_res;
uniform vec4 rcp_frame_opt;
uniform vec4 rcp_frame_opt2;
uniform vec2 screen_res;
VARYING vec2 vary_fragcoord;
VARYING vec2 vary_tc;

View File

@@ -25,12 +25,12 @@
uniform mat3 normal_matrix;
ATTRIBUTE vec3 binormal;
ATTRIBUTE vec4 tangent;
VARYING vec4 binormal_out;
VARYING vec4 tangent_out;
void main()
{
binormal_out = vec4(normal_matrix * binormal, 0.0);
tangent_out = vec4(normal_matrix * tangent.xyz, tangent.w);
}

View File

@@ -190,7 +190,7 @@ public:
RIGGED_DEFERRED_BUMP_MASK = LLVertexBuffer::MAP_VERTEX |
LLVertexBuffer::MAP_NORMAL |
LLVertexBuffer::MAP_TEXCOORD0 |
LLVertexBuffer::MAP_BINORMAL |
LLVertexBuffer::MAP_TANGENT |
LLVertexBuffer::MAP_COLOR |
LLVertexBuffer::MAP_WEIGHT4,
RIGGED_DEFERRED_SIMPLE_MASK = LLVertexBuffer::MAP_VERTEX |

View File

@@ -851,7 +851,7 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type);
LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type);
U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_BINORMAL | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_COLOR;
U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_COLOR;
for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i)
{

View File

@@ -511,7 +511,7 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color)
{
LLGLEnable poly_offset(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.f,-1.f);
mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0);
mVertexBuffer->setBuffer(mVertexBuffer->getTypeMask());
mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex);
}
@@ -789,6 +789,12 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
size.mul(scale);
}
// Catch potential badness from normalization before it happens
//
llassert(mat_normal.mMatrix[0].isFinite3() && (mat_normal.mMatrix[0].dot3(mat_normal.mMatrix[0]).getF32() > F_APPROXIMATELY_ZERO));
llassert(mat_normal.mMatrix[1].isFinite3() && (mat_normal.mMatrix[1].dot3(mat_normal.mMatrix[1]).getF32() > F_APPROXIMATELY_ZERO));
llassert(mat_normal.mMatrix[2].isFinite3() && (mat_normal.mMatrix[2].dot3(mat_normal.mMatrix[2]).getF32() > F_APPROXIMATELY_ZERO));
mat_normal.mMatrix[0].normalize3fast();
mat_normal.mMatrix[1].normalize3fast();
mat_normal.mMatrix[2].normalize3fast();
@@ -874,7 +880,7 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
// integrated with getGeometryVolume() for its texture coordinate
// generation - but i'll leave that to someone more familiar
// with the implications.
LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, LLVector3 position, LLVector3 normal)
LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, const LLVector4a& position, const LLVector4a& normal)
{
LLVector2 tc = surface_coord;
@@ -894,7 +900,9 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, LLVector3 position,
LLVector4a& center = *(mDrawablep->getVOVolume()->getVolume()->getVolumeFace(mTEOffset).mCenter);
LLVector4a volume_position;
volume_position.load3(mDrawablep->getVOVolume()->agentPositionToVolume(position).mV);
LLVector3 v_position(position.getF32ptr());
volume_position.load3(mDrawablep->getVOVolume()->agentPositionToVolume(v_position).mV);
if (!mDrawablep->getVOVolume()->isVolumeGlobal())
{
@@ -904,7 +912,8 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, LLVector3 position,
}
LLVector4a volume_normal;
volume_normal.load3(mDrawablep->getVOVolume()->agentDirectionToVolume(normal).mV);
LLVector3 v_normal(normal.getF32ptr());
volume_normal.load3(mDrawablep->getVOVolume()->agentDirectionToVolume(v_normal).mV);
volume_normal.normalize3fast();
if (texgen == LLTextureEntry::TEX_GEN_PLANAR)
@@ -937,7 +946,12 @@ void LLFace::getPlanarProjectedParams(LLQuaternion* face_rot, LLVector3* face_po
const LLMatrix4& vol_mat = getWorldMatrix();
const LLVolumeFace& vf = getViewerObject()->getVolume()->getVolumeFace(mTEOffset);
const LLVector4a& normal4a = vf.mNormals[0];
const LLVector4a& binormal4a = vf.mBinormals[0];
const LLVector4a& tangent = vf.mTangents[0];
LLVector4a binormal4a;
binormal4a.setCross3(normal4a, tangent);
binormal4a.mul(tangent.getF32ptr()[3]);
LLVector2 projected_binormal;
planarProjection(projected_binormal, normal4a, *vf.mCenter, binormal4a);
projected_binormal -= LLVector2(0.5f, 0.5f); // this normally happens in xform()
@@ -1067,7 +1081,7 @@ void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf)
{
LLFastTimer t(FTM_FACE_GEOM_VOLUME);
U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 |
LLVertexBuffer::MAP_BINORMAL | LLVertexBuffer::MAP_NORMAL;
LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_NORMAL;
if (vf.mWeights)
{
@@ -1080,11 +1094,11 @@ void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf)
buff->allocateBuffer(vf.mNumVertices, 0, true);
LLStrider<LLVector4a> f_vert;
LLStrider<LLVector3> f_binorm;
LLStrider<LLVector4a> f_tangent;
LLStrider<LLVector3> f_norm;
LLStrider<LLVector2> f_tc;
buff->getBinormalStrider(f_binorm);
buff->getTangentStrider(f_tangent);
buff->getVertexStrider(f_vert);
buff->getNormalStrider(f_norm);
buff->getTexCoord0Strider(f_tc);
@@ -1092,7 +1106,7 @@ void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf)
for (U32 i = 0; i < (U32)vf.mNumVertices; ++i)
{
*f_vert++ = vf.mPositions[i];
(*f_binorm++).set(vf.mBinormals[i].getF32ptr());
*f_tangent++ = vf.mTangents[i];
*f_tc++ = vf.mTexCoords[i];
(*f_norm++).set(vf.mNormals[i].getF32ptr());
}
@@ -1133,7 +1147,7 @@ static LLFastTimer::DeclareTimer FTM_FACE_GEOM_TEXTURE("Texture");
static LLFastTimer::DeclareTimer FTM_FACE_GEOM_COLOR("Color");
static LLFastTimer::DeclareTimer FTM_FACE_GEOM_EMISSIVE("Emissive");
static LLFastTimer::DeclareTimer FTM_FACE_GEOM_WEIGHTS("Weights");
static LLFastTimer::DeclareTimer FTM_FACE_GEOM_BINORMAL("Binormal");
static LLFastTimer::DeclareTimer FTM_FACE_GEOM_TANGENT("Binormal");
static LLFastTimer::DeclareTimer FTM_FACE_GEOM_FEEDBACK("Face Feedback");
static LLFastTimer::DeclareTimer FTM_FACE_GEOM_FEEDBACK_POSITION("Feedback Position");
@@ -1207,7 +1221,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
LLStrider<LLVector2> tex_coords1;
LLStrider<LLVector3> norm;
LLStrider<LLColor4U> colors;
LLStrider<LLVector3> binorm;
LLStrider<LLVector3> tangent;
LLStrider<U16> indicesp;
LLStrider<LLVector4> wght;
@@ -1229,7 +1243,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
bool rebuild_emissive = rebuild_color && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE);
bool rebuild_tcoord = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_TCOORD);
bool rebuild_normal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
bool rebuild_binormal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_BINORMAL);
bool rebuild_tangent = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TANGENT);
bool rebuild_weights = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_WEIGHT4);
const LLTextureEntry *tep = mVObjp->getTE(f);
@@ -1374,7 +1388,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
if (vf.mVertexBuffer.isNull() || buff->getNumVerts() != vf.mNumVertices)
{
mVObjp->getVolume()->genBinormals(f);
mVObjp->getVolume()->genTangents(f);
LLFace::cacheFaceInVRAM(vf);
buff = (LLVertexBuffer*) vf.mVertexBuffer.get();
}
@@ -1459,15 +1473,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
glEndTransformFeedback();
}
if (rebuild_binormal)
if (rebuild_tangent)
{
LLFastTimer t(FTM_FACE_GEOM_FEEDBACK_BINORMAL);
gTransformBinormalProgram.bind();
LLFastTimer t(FTM_FACE_GEOM_TANGENT);
gTransformTangentProgram.bind();
mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_BINORMAL, mGeomIndex, mGeomCount);
mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_TANGENT, mGeomIndex, mGeomCount);
glBeginTransformFeedback(GL_POINTS);
buff->setBuffer(LLVertexBuffer::MAP_BINORMAL);
buff->setBuffer(LLVertexBuffer::MAP_TANGENT);
push_for_transform(buff, vf.mNumVertices, mGeomCount);
glEndTransformFeedback();
}
@@ -1529,7 +1543,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
if (bump_code)
{
mVObjp->getVolume()->genBinormals(f);
mVObjp->getVolume()->genTangents(f);
F32 offset_multiple;
switch( bump_code )
{
@@ -1578,7 +1592,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
U8 texgen = getTextureEntry()->getTexGen();
if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT)
{ //planar texgen needs binormals
mVObjp->getVolume()->genBinormals(f);
mVObjp->getVolume()->genTangents(f);
}
U8 tex_mode = 0;
@@ -1789,11 +1803,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
for (S32 i = 0; i < num_vertices; i++)
{
LLVector4a tangent;
tangent.setCross3(vf.mBinormals[i], vf.mNormals[i]);
LLVector4a tangent = vf.mTangents[i];
LLVector4a binorm;
binorm.setCross3(vf.mNormals[i], tangent);
binorm.mul(tangent.getF32ptr()[3]);
LLMatrix4a tangent_to_object;
tangent_to_object.setRows(tangent, vf.mBinormals[i], vf.mNormals[i]);
tangent_to_object.setRows(tangent, binorm, vf.mNormals[i]);
LLVector4a t;
tangent_to_object.rotate(binormal_dir, t);
LLVector4a binormal;
@@ -1899,7 +1916,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
LLFastTimer t(FTM_FACE_GEOM_NORMAL);
mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, map_range);
F32* normals = (F32*) norm.get();
for (S32 i = 0; i < num_vertices; i++)
{
LLVector4a normal;
@@ -1915,19 +1931,27 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
}
}
if (rebuild_binormal)
if (rebuild_tangent)
{
LLFastTimer t(FTM_FACE_GEOM_BINORMAL);
mVertexBuffer->getBinormalStrider(binorm, mGeomIndex, mGeomCount, map_range);
F32* binormals = (F32*) binorm.get();
LLFastTimer t(FTM_FACE_GEOM_TANGENT);
mVertexBuffer->getTangentStrider(tangent, mGeomIndex, mGeomCount, map_range);
F32* tangents = (F32*) tangent.get();
mVObjp->getVolume()->genTangents(f);
LLVector4Logical mask;
mask.clear();
mask.setElement<3>();
for (S32 i = 0; i < num_vertices; i++)
{
LLVector4a binormal;
mat_normal.rotate(vf.mBinormals[i], binormal);
binormal.normalize3fast();
binormal.store4a(binormals);
binormals += 4;
{
LLVector4a tangent_out;
mat_normal.rotate(vf.mTangents[i], tangent_out);
tangent_out.normalize3fast();
tangent_out.setSelectWithMask(mask, vf.mTangents[i], tangent_out);
tangent_out.store4a(tangents);
tangents += 4;
}
if (map_range)

View File

@@ -121,7 +121,7 @@ public:
LLXformMatrix* getXform() const { return mXform; }
BOOL hasGeometry() const { return mGeomCount > 0; }
LLVector3 getPositionAgent() const;
LLVector2 surfaceToTexture(LLVector2 surface_coord, LLVector3 position, LLVector3 normal);
LLVector2 surfaceToTexture(LLVector2 surface_coord, const LLVector4a& position, const LLVector4a& normal);
void getPlanarProjectedParams(LLQuaternion* face_rot, LLVector3* face_pos, F32* scale) const;
bool calcAlignedPlanarTE(const LLFace* align_to, LLVector2* st_offset,
LLVector2* st_scale, F32* st_rot) const;

View File

@@ -293,6 +293,9 @@ void LLVolumeImplFlexible::onSetVolume(const LLVolumeParams &volume_params, cons
void LLVolumeImplFlexible::updateRenderRes()
{
if (!mAttributes)
return;
LLDrawable* drawablep = mVO->mDrawable;
S32 new_res = mAttributes->getSimulateLOD();
@@ -424,7 +427,7 @@ void LLVolumeImplFlexible::doFlexibleUpdate()
}
}
if(!mInitialized)
if(!mInitialized || !mAttributes)
{
//the object is not visible
return ;
@@ -682,15 +685,17 @@ void LLVolumeImplFlexible::doFlexibleUpdate()
new_point = &path->mPath[i];
LLVector3 pos = newSection[i].mPosition * rel_xform;
LLQuaternion rot = mSection[i].mAxisRotation * newSection[i].mRotation * delta_rot;
if (!mUpdated || (new_point->mPos-pos).magVec()/mVO->mDrawable->mDistanceWRTCamera > 0.001f)
LLVector3 np(new_point->mPos.getF32ptr());
if (!mUpdated || (np-pos).magVec()/mVO->mDrawable->mDistanceWRTCamera > 0.001f)
{
new_point->mPos = newSection[i].mPosition * rel_xform;
new_point->mPos.load3((newSection[i].mPosition * rel_xform).mV);
mUpdated = FALSE;
}
new_point->mRot = rot;
new_point->mScale = newSection[i].mScale;
new_point->mRot.loadu(LLMatrix3(rot));
new_point->mScale.set(newSection[i].mScale.mV[0], newSection[i].mScale.mV[1], 0,1);
new_point->mTexT = ((F32)i)/(num_render_sections);
}

View File

@@ -208,7 +208,7 @@ void LLHUDIcon::render()
renderIcon(FALSE);
}
BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3* intersection)
BOOL LLHUDIcon::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, LLVector4a* intersection)
{
if (mHidden)
return FALSE;
@@ -281,23 +281,18 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
LLVector4a upper_right;
upper_right.setAdd(lower_right, y_scalea);
LLVector4a enda;
enda.load3(end.mV);
LLVector4a starta;
starta.load3(start.mV);
LLVector4a dir;
dir.setSub(enda, starta);
dir.setSub(end, start);
F32 a,b,t;
if (LLTriangleRayIntersect(upper_right, upper_left, lower_right, starta, dir, a,b,t) ||
LLTriangleRayIntersect(upper_left, lower_left, lower_right, starta, dir, a,b,t))
if (LLTriangleRayIntersect(upper_right, upper_left, lower_right, start, dir, a,b,t) ||
LLTriangleRayIntersect(upper_left, lower_left, lower_right, start, dir, a,b,t))
{
if (intersection)
{
dir.mul(t);
starta.add(dir);
*intersection = LLVector3(starta.getF32ptr());
intersection->setAdd(start, dir);
}
return TRUE;
}
@@ -337,12 +332,12 @@ LLHUDIcon* LLHUDIcon::handlePick(S32 pick_id)
}
//static
LLHUDIcon* LLHUDIcon::lineSegmentIntersectAll(const LLVector3& start, const LLVector3& end, LLVector3* intersection)
LLHUDIcon* LLHUDIcon::lineSegmentIntersectAll(const LLVector4a& start, const LLVector4a& end, LLVector4a* intersection)
{
icon_instance_t::iterator icon_it;
LLVector3 local_end = end;
LLVector3 position;
LLVector4a local_end = end;
LLVector4a position;
LLHUDIcon* ret = NULL;
for(icon_it = sIconInstances.begin(); icon_it != sIconInstances.end(); ++icon_it)

View File

@@ -68,7 +68,7 @@ public:
static S32 generatePickIDs(S32 start_id, S32 step_size);
static LLHUDIcon* handlePick(S32 pick_id);
static LLHUDIcon* lineSegmentIntersectAll(const LLVector3& start, const LLVector3& end, LLVector3* intersection);
static LLHUDIcon* lineSegmentIntersectAll(const LLVector4a& start, const LLVector4a& end, LLVector4a* intersection);
static void updateAll();
static void cleanupDeadIcons();
@@ -79,7 +79,7 @@ public:
BOOL getHidden() const { return mHidden; }
void setHidden( BOOL hide ) { mHidden = hide; }
BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3* intersection);
BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, LLVector4a* intersection);
protected:
LLHUDIcon(const U8 type);

View File

@@ -120,7 +120,7 @@ LLHUDNameTag::~LLHUDNameTag()
}
BOOL LLHUDNameTag::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render)
BOOL LLHUDNameTag::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, LLVector4a& intersection, BOOL debug_render)
{
if (!mVisible || mHidden)
{
@@ -218,16 +218,23 @@ BOOL LLHUDNameTag::lineSegmentIntersect(const LLVector3& start, const LLVector3&
gGL.vertex3fv(v[2].mV);
gGL.end();
}
LLVector3 dir = end-start;
LLVector4a dir;
dir.setSub(end,start);
F32 a, b, t;
if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, a, b, t, FALSE) ||
LLTriangleRayIntersect(v[2], v[3], v[0], start, dir, a, b, t, FALSE) )
LLVector4a v0,v1,v2,v3;
v0.load3(v[0].mV);
v1.load3(v[1].mV);
v2.load3(v[2].mV);
v3.load3(v[3].mV);
if (LLTriangleRayIntersect(v0, v1, v2, start, dir, a, b, t) ||
LLTriangleRayIntersect(v2, v3, v0, start, dir, a, b, t) )
{
if (t <= 1.f)
{
intersection = start + dir*t;
dir.mul(t);
intersection.setAdd(start, dir);
return TRUE;
}
}

View File

@@ -126,7 +126,7 @@ public:
void setHidden( BOOL hide ) { mHidden = hide; }
void shift(const LLVector3& offset);
BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render = FALSE);
BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, LLVector4a& intersection, BOOL debug_render = FALSE);
static void shiftAll(const LLVector3& offset);
static void addPickable(std::set<LLViewerObject*> &pick_list);

View File

@@ -2944,9 +2944,9 @@ void renderNormals(LLDrawable* drawablep)
gGL.vertex3fv(face.mPositions[j].getF32ptr());
gGL.vertex3fv(p.getF32ptr());
if (face.mBinormals)
if (face.mTangents)
{
n.setMul(face.mBinormals[j], scale);
n.setMul(face.mTangents[j], scale);
p.setAdd(face.mPositions[j], n);
gGL.diffuseColor4f(0,1,1,1);
@@ -3694,11 +3694,17 @@ void renderRaycast(LLDrawable* drawablep)
gGL.translatef(trans.mV[0], trans.mV[1], trans.mV[2]);
gGL.multMatrix((F32*) vobj->getRelativeXform().mMatrix);
LLVector3 start, end;
LLVector4a start, end;
if (transform)
{
start = vobj->agentPositionToVolume(gDebugRaycastStart);
end = vobj->agentPositionToVolume(gDebugRaycastEnd);
LLVector3 v_start(gDebugRaycastStart.getF32ptr());
LLVector3 v_end(gDebugRaycastEnd.getF32ptr());
v_start = vobj->agentPositionToVolume(v_start);
v_end = vobj->agentPositionToVolume(v_end);
start.load3(v_start.mV);
end.load3(v_end.mV);
}
else
{
@@ -3706,11 +3712,8 @@ void renderRaycast(LLDrawable* drawablep)
end = gDebugRaycastEnd;
}
LLVector4a starta, enda;
starta.load3(start.mV);
enda.load3(end.mV);
LLVector4a dir;
dir.setSub(enda, starta);
dir.setSub(end, start);
gGL.flush();
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
@@ -3733,10 +3736,11 @@ void renderRaycast(LLDrawable* drawablep)
((LLVolumeFace*) &face)->createOctree();
}
LLRenderOctreeRaycast render(starta, dir, &t);
LLRenderOctreeRaycast render(start, dir, &t);
render.traverse(face.mOctree);
}
gGL.popMatrix();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
@@ -3757,10 +3761,18 @@ void renderRaycast(LLDrawable* drawablep)
// draw intersection point
gGL.pushMatrix();
gGL.loadMatrix(gGLModelView);
LLVector3 translate = gDebugRaycastIntersection;
LLVector3 translate(gDebugRaycastIntersection.getF32ptr());
gGL.translatef(translate.mV[0], translate.mV[1], translate.mV[2]);
LLCoordFrame orient;
orient.lookDir(gDebugRaycastNormal, gDebugRaycastBinormal);
LLVector4a debug_binormal;
debug_binormal.setCross3(gDebugRaycastNormal, gDebugRaycastTangent);
debug_binormal.mul(gDebugRaycastTangent.getF32ptr()[3]);
LLVector3 normal(gDebugRaycastNormal.getF32ptr());
LLVector3 binormal(debug_binormal.getF32ptr());
orient.lookDir(normal, binormal);
LLMatrix4 rotation;
orient.getRotMatrixToParent(rotation);
gGL.multMatrix((float*)rotation.mMatrix);
@@ -4261,28 +4273,30 @@ BOOL LLSpatialPartition::isVisible(const LLVector3& v)
return TRUE;
}
LL_ALIGN_PREFIX(16)
class LLOctreeIntersect : public LLSpatialGroup::OctreeTraveler
{
public:
LLVector3 mStart;
LLVector3 mEnd;
LL_ALIGN_16(LLVector4a mStart);
LL_ALIGN_16(LLVector4a mEnd);
S32 *mFaceHit;
LLVector3 *mIntersection;
LLVector4a *mIntersection;
LLVector2 *mTexCoord;
LLVector3 *mNormal;
LLVector3 *mBinormal;
LLVector4a *mNormal;
LLVector4a *mTangent;
LLDrawable* mHit;
BOOL mPickTransparent;
LLOctreeIntersect(LLVector3 start, LLVector3 end, BOOL pick_transparent,
S32* face_hit, LLVector3* intersection, LLVector2* tex_coord, LLVector3* normal, LLVector3* binormal)
LLOctreeIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent,
S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent)
: mStart(start),
mEnd(end),
mFaceHit(face_hit),
mIntersection(intersection),
mTexCoord(tex_coord),
mNormal(normal),
mBinormal(binormal),
mTangent(tangent),
mHit(NULL),
mPickTransparent(pick_transparent)
{
@@ -4315,23 +4329,22 @@ public:
size = group->mBounds[1];
center = group->mBounds[0];
LLVector3 local_start = mStart;
LLVector3 local_end = mEnd;
LLVector4a local_start = mStart;
LLVector4a local_end = mEnd;
if (group->mSpatialPartition->isBridge())
{
LLMatrix4 local_matrix = group->mSpatialPartition->asBridge()->mDrawable->getRenderMatrix();
local_matrix.invert();
local_start = mStart * local_matrix;
local_end = mEnd * local_matrix;
LLMatrix4a local_matrix4a;
local_matrix4a.loadu(local_matrix);
local_matrix4a.affineTransform(mStart, local_start);
local_matrix4a.affineTransform(mEnd, local_end);
}
LLVector4a start, end;
start.load3(local_start.mV);
end.load3(local_end.mV);
if (LLLineSegmentBoxIntersect(start, end, center, size))
if (LLLineSegmentBoxIntersect(local_start, local_end, center, size))
{
check(child);
}
@@ -4362,14 +4375,14 @@ public:
if (vobj)
{
LLVector3 intersection;
LLVector4a intersection;
bool skip_check = false;
if (vobj->isAvatar())
{
LLVOAvatar* avatar = (LLVOAvatar*) vobj;
if (avatar->isSelf() && gFloaterTools->getVisible())
{
LLViewerObject* hit = avatar->lineSegmentIntersectRiggedAttachments(mStart, mEnd, -1, mPickTransparent, mFaceHit, &intersection, mTexCoord, mNormal, mBinormal);
LLViewerObject* hit = avatar->lineSegmentIntersectRiggedAttachments(mStart, mEnd, -1, mPickTransparent, mFaceHit, &intersection, mTexCoord, mNormal, mTangent);
if (hit)
{
mEnd = intersection;
@@ -4389,7 +4402,7 @@ public:
}
}
if (!skip_check && vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mFaceHit, &intersection, mTexCoord, mNormal, mBinormal))
if (!skip_check && vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mFaceHit, &intersection, mTexCoord, mNormal, mTangent))
{
mEnd = intersection; // shorten ray so we only find CLOSER hits
if (mIntersection)
@@ -4404,19 +4417,19 @@ public:
return false;
}
};
} LL_ALIGN_POSTFIX(16);
LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
BOOL pick_transparent,
S32* face_hit, // return the face hit
LLVector3* intersection, // return the intersection point
LLVector4a* intersection, // return the intersection point
LLVector2* tex_coord, // return the texture coordinates of the intersection point
LLVector3* normal, // return the surface normal at the intersection point
LLVector3* bi_normal // return the surface bi-normal at the intersection point
LLVector4a* normal, // return the surface normal at the intersection point
LLVector4a* tangent // return the surface tangent at the intersection point
)
{
LLOctreeIntersect intersect(start, end, pick_transparent, face_hit, intersection, tex_coord, normal, bi_normal);
LLOctreeIntersect intersect(start, end, pick_transparent, face_hit, intersection, tex_coord, normal, tangent);
LLDrawable* drawable = intersect.check(mOctree);
return drawable;

View File

@@ -457,13 +457,13 @@ public:
LLSpatialGroup *put(LLDrawable *drawablep, BOOL was_visible = FALSE);
BOOL remove(LLDrawable *drawablep, LLSpatialGroup *curp);
LLDrawable* lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
LLDrawable* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
BOOL pick_transparent,
S32* face_hit, // return the face hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL // return the surface tangent at the intersection point
);
@@ -695,7 +695,7 @@ class LLVolumeGeometryManager: public LLGeometryManager
virtual void rebuildGeom(LLSpatialGroup* group);
virtual void rebuildMesh(LLSpatialGroup* group);
virtual void getGeometry(LLSpatialGroup* group);
void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort = FALSE, BOOL batch_textures = FALSE);
void genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace** faces, U32 face_count, BOOL distance_sort = FALSE, BOOL batch_textures = FALSE, BOOL no_materials = FALSE);
void registerFace(LLSpatialGroup* group, LLFace* facep, U32 type);
};

View File

@@ -3904,19 +3904,19 @@ LLViewerObject* LLViewerObject::getRootEdit() const
}
BOOL LLViewerObject::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
BOOL LLViewerObject::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
S32 face,
BOOL pick_transparent,
S32* face_hit,
LLVector3* intersection,
LLVector4a* intersection,
LLVector2* tex_coord,
LLVector3* normal,
LLVector3* bi_normal)
LLVector4a* normal,
LLVector4a* tangent)
{
return false;
}
BOOL LLViewerObject::lineSegmentBoundingBox(const LLVector3& start, const LLVector3& end)
BOOL LLViewerObject::lineSegmentBoundingBox(const LLVector4a& start, const LLVector4a& end)
{
if (mDrawable.isNull() || mDrawable->isDead())
{
@@ -3933,11 +3933,7 @@ BOOL LLViewerObject::lineSegmentBoundingBox(const LLVector3& start, const LLVect
size.setSub(ext[1], ext[0]);
size.mul(0.5f);
LLVector4a starta, enda;
starta.load3(start.mV);
enda.load3(end.mV);
return LLLineSegmentBoxIntersect(starta, enda, center, size);
return LLLineSegmentBoxIntersect(start, end, center, size);
}
U8 LLViewerObject::getMediaType() const

View File

@@ -262,17 +262,17 @@ public:
//detect if given line segment (in agent space) intersects with this viewer object.
//returns TRUE if intersection detected and returns information about intersection
virtual BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
virtual BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
S32 face = -1, // which face to check, -1 = ALL_SIDES
BOOL pick_transparent = FALSE,
S32* face_hit = NULL, // which face was hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL // return the surface tangent at the intersection point
);
virtual BOOL lineSegmentBoundingBox(const LLVector3& start, const LLVector3& end);
virtual BOOL lineSegmentBoundingBox(const LLVector4a& start, const LLVector4a& end);
virtual const LLVector3d getPositionGlobal() const;
virtual const LLVector3 &getPositionRegion() const;

View File

@@ -77,7 +77,7 @@ LLGLSLShader gTransformPositionProgram(LLViewerShaderMgr::SHADER_TRANSFORM);
LLGLSLShader gTransformTexCoordProgram(LLViewerShaderMgr::SHADER_TRANSFORM);
LLGLSLShader gTransformNormalProgram(LLViewerShaderMgr::SHADER_TRANSFORM);
LLGLSLShader gTransformColorProgram(LLViewerShaderMgr::SHADER_TRANSFORM);
LLGLSLShader gTransformBinormalProgram(LLViewerShaderMgr::SHADER_TRANSFORM);
LLGLSLShader gTransformTangentProgram(LLViewerShaderMgr::SHADER_TRANSFORM);
//utility shaders
LLGLSLShader gOcclusionProgram(LLViewerShaderMgr::SHADER_INTERFACE);
@@ -2747,16 +2747,16 @@ BOOL LLViewerShaderMgr::loadTransformShaders()
if (success)
{
gTransformBinormalProgram.mName = "Binormal Transform Shader";
gTransformBinormalProgram.mShaderFiles.clear();
gTransformBinormalProgram.mShaderFiles.push_back(make_pair("transform/binormalV.glsl", GL_VERTEX_SHADER_ARB));
gTransformBinormalProgram.mShaderLevel = mVertexShaderLevel[SHADER_TRANSFORM];
gTransformTangentProgram.mName = "Binormal Transform Shader";
gTransformTangentProgram.mShaderFiles.clear();
gTransformTangentProgram.mShaderFiles.push_back(make_pair("transform/binormalV.glsl", GL_VERTEX_SHADER_ARB));
gTransformTangentProgram.mShaderLevel = mVertexShaderLevel[SHADER_TRANSFORM];
const char* varyings[] = {
"binormal_out",
"tangent_out",
};
success = gTransformBinormalProgram.createShader(NULL, NULL, 1, varyings);
success = gTransformTangentProgram.createShader(NULL, NULL, 1, varyings);
}

View File

@@ -234,7 +234,7 @@ extern LLGLSLShader gTransformPositionProgram;
extern LLGLSLShader gTransformTexCoordProgram;
extern LLGLSLShader gTransformNormalProgram;
extern LLGLSLShader gTransformColorProgram;
extern LLGLSLShader gTransformBinormalProgram;
extern LLGLSLShader gTransformTangentProgram;
//utility shaders
extern LLGLSLShader gOcclusionProgram;
extern LLGLSLShader gOcclusionCubeProgram;
@@ -244,7 +244,6 @@ extern LLGLSLShader gSplatTextureRectProgram;
extern LLGLSLShader gGlowCombineFXAAProgram;
extern LLGLSLShader gDebugProgram;
extern LLGLSLShader gClipProgram;
extern LLGLSLShader gAlphaMaskProgram;
//output tex0[tc0] + tex1[tc1]
extern LLGLSLShader gTwoTextureAddProgram;

View File

@@ -218,13 +218,13 @@ BOOL gShowOverlayTitle = FALSE;
BOOL gPickTransparent = TRUE;
LLViewerObject* gDebugRaycastObject = NULL;
LLVector3 gDebugRaycastIntersection;
LLVector2 gDebugRaycastTexCoord;
LLVector3 gDebugRaycastNormal;
LLVector3 gDebugRaycastBinormal;
S32 gDebugRaycastFaceHit;
LLVector3 gDebugRaycastStart;
LLVector3 gDebugRaycastEnd;
LLVector4a gDebugRaycastIntersection;
LLVector2 gDebugRaycastTexCoord;
LLVector4a gDebugRaycastNormal;
LLVector4a gDebugRaycastTangent;
S32 gDebugRaycastFaceHit;
LLVector4a gDebugRaycastStart;
LLVector4a gDebugRaycastEnd;
// HUD display lines in lower right
BOOL gDisplayWindInfo = FALSE;
@@ -3038,7 +3038,7 @@ void LLViewerWindow::updateUI()
&gDebugRaycastIntersection,
&gDebugRaycastTexCoord,
&gDebugRaycastNormal,
&gDebugRaycastBinormal,
&gDebugRaycastTangent,
&gDebugRaycastStart,
&gDebugRaycastEnd);
}
@@ -3982,7 +3982,7 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_trans
}
LLHUDIcon* LLViewerWindow::cursorIntersectIcon(S32 mouse_x, S32 mouse_y, F32 depth,
LLVector3* intersection)
LLVector4a* intersection)
{
S32 x = mouse_x;
S32 y = mouse_y;
@@ -3999,9 +3999,11 @@ LLHUDIcon* LLViewerWindow::cursorIntersectIcon(S32 mouse_x, S32 mouse_y, F32 dep
LLVector3 mouse_world_start = mouse_point_global;
LLVector3 mouse_world_end = mouse_point_global + mouse_direction_global * depth;
return LLHUDIcon::lineSegmentIntersectAll(mouse_world_start, mouse_world_end, intersection);
LLVector4a start, end;
start.load3(mouse_world_start.mV);
end.load3(mouse_world_end.mV);
return LLHUDIcon::lineSegmentIntersectAll(start, end, intersection);
}
LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 depth,
@@ -4009,12 +4011,12 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
S32 this_face,
BOOL pick_transparent,
S32* face_hit,
LLVector3 *intersection,
LLVector4a *intersection,
LLVector2 *uv,
LLVector3 *normal,
LLVector3 *binormal,
LLVector3* start,
LLVector3* end)
LLVector4a *normal,
LLVector4a *tangent,
LLVector4a* start,
LLVector4a* end)
{
S32 x = mouse_x;
S32 y = mouse_y;
@@ -4049,17 +4051,27 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
if (!LLViewerJoystick::getInstance()->getOverrideCamera())
{ //always set raycast intersection to mouse_world_end unless
//flycam is on (for DoF effect)
gDebugRaycastIntersection = mouse_world_end;
gDebugRaycastIntersection.load3(mouse_world_end.mV);
}
LLVector4a mw_start;
mw_start.load3(mouse_world_start.mV);
LLVector4a mw_end;
mw_end.load3(mouse_world_end.mV);
LLVector4a mh_start;
mh_start.load3(mouse_hud_start.mV);
LLVector4a mh_end;
mh_end.load3(mouse_hud_end.mV);
if (start)
{
*start = mouse_world_start;
*start = mw_start;
}
if (end)
{
*end = mouse_world_end;
*end = mw_end;
}
LLViewerObject* found = NULL;
@@ -4068,25 +4080,25 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
{
if (this_object->isHUDAttachment()) // is a HUD object?
{
if (this_object->lineSegmentIntersect(mouse_hud_start, mouse_hud_end, this_face, pick_transparent,
face_hit, intersection, uv, normal, binormal))
if (this_object->lineSegmentIntersect(mh_start, mh_end, this_face, pick_transparent,
face_hit, intersection, uv, normal, tangent))
{
found = this_object;
}
}
}
else // is a world object
{
if (this_object->lineSegmentIntersect(mouse_world_start, mouse_world_end, this_face, pick_transparent,
face_hit, intersection, uv, normal, binormal))
if (this_object->lineSegmentIntersect(mw_start, mw_end, this_face, pick_transparent,
face_hit, intersection, uv, normal, tangent))
{
found = this_object;
}
}
}
}
}
else // check ALL objects
{
found = gPipeline.lineSegmentIntersectInHUD(mouse_hud_start, mouse_hud_end, pick_transparent,
face_hit, intersection, uv, normal, binormal);
found = gPipeline.lineSegmentIntersectInHUD(mh_start, mh_end, pick_transparent,
face_hit, intersection, uv, normal, tangent);
// [RLVa:KB] - Checked: 2009-12-28 (RLVa-1.1.0k) | Modified: RLVa-1.1.0k
if ( (rlv_handler_t::isEnabled()) && (LLToolCamera::getInstance()->hasMouseCapture()) && (gKeyboard->currentMask(TRUE) & MASK_ALT) )
@@ -4097,8 +4109,8 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
if (!found) // if not found in HUD, look in world:
{
found = gPipeline.lineSegmentIntersectInWorld(mouse_world_start, mouse_world_end, pick_transparent,
face_hit, intersection, uv, normal, binormal);
found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent,
face_hit, intersection, uv, normal, tangent);
// [RLVa:KB] - Checked: 2010-01-02 (RLVa-1.1.0l) | Added: RLVa-1.1.0l
#ifdef RLV_EXTENSION_CMD_INTERACT
@@ -4118,6 +4130,10 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
}
#endif // RLV_EXTENSION_CMD_INTERACT
// [/RLVa:KB]
if (found && !pick_transparent)
{
gDebugRaycastIntersection = *intersection;
}
}
}
@@ -5815,6 +5831,7 @@ LLPickInfo::LLPickInfo()
mXYCoords(-1, -1),
mIntersection(),
mNormal(),
mTangent(),
mBinormal(),
mHUDIcon(NULL),
mPickTransparent(FALSE)
@@ -5836,6 +5853,7 @@ LLPickInfo::LLPickInfo(const LLCoordGL& mouse_pos,
mSTCoords(-1.f, -1.f),
mXYCoords(-1, -1),
mNormal(),
mTangent(),
mBinormal(),
mHUDIcon(NULL),
mPickTransparent(pick_transparent)
@@ -5846,19 +5864,26 @@ void LLPickInfo::fetchResults()
{
S32 face_hit = -1;
LLVector3 intersection, normal, binormal;
LLVector4a intersection, normal;
LLVector4a tangent;
LLVector2 uv;
LLHUDIcon* hit_icon = gViewerWindow->cursorIntersectIcon(mMousePt.mX, mMousePt.mY, 512.f, &intersection);
LLVector4a origin;
origin.load3(LLViewerCamera::getInstance()->getOrigin().mV);
F32 icon_dist = 0.f;
if (hit_icon)
{
icon_dist = (LLViewerCamera::getInstance()->getOrigin()-intersection).magVec();
LLVector4a delta;
delta.setSub(intersection, origin);
icon_dist = delta.getLength3().getF32();
}
LLViewerObject* hit_object = gViewerWindow->cursorIntersect(mMousePt.mX, mMousePt.mY, 512.f,
NULL, -1, mPickTransparent, &face_hit,
&intersection, &uv, &normal, &binormal);
&intersection, &uv, &normal, &tangent);
mPickPt = mMousePt;
@@ -5868,9 +5893,13 @@ void LLPickInfo::fetchResults()
LLViewerObject* objectp = hit_object;
LLVector4a delta;
delta.setSub(origin, intersection);
if (hit_icon &&
(!objectp ||
icon_dist < (LLViewerCamera::getInstance()->getOrigin()-intersection).magVec()))
icon_dist < delta.getLength3().getF32()))
{
// was this name referring to a hud icon?
mHUDIcon = hit_icon;
@@ -5907,11 +5936,16 @@ void LLPickInfo::fetchResults()
{
mPickType = PICK_OBJECT;
}
mObjectOffset = gAgentCamera.calcFocusOffset(objectp, intersection, mPickPt.mX, mPickPt.mY);
LLVector3 v_intersection(intersection.getF32ptr());
mObjectOffset = gAgentCamera.calcFocusOffset(objectp, v_intersection, mPickPt.mX, mPickPt.mY);
mObjectID = objectp->mID;
mObjectFace = (te_offset == NO_FACE) ? -1 : (S32)te_offset;
mPosGlobal = gAgent.getPosGlobalFromAgent(intersection);
mPosGlobal = gAgent.getPosGlobalFromAgent(v_intersection);
if (mWantSurfaceInfo)
{
@@ -5955,7 +5989,16 @@ void LLPickInfo::getSurfaceInfo()
mIntersection = LLVector3(0,0,0);
mNormal = LLVector3(0,0,0);
mBinormal = LLVector3(0,0,0);
mTangent = LLVector4(0,0,0,0);
LLVector4a tangent;
LLVector4a intersection;
LLVector4a normal;
tangent.clear();
normal.clear();
intersection.clear();
LLViewerObject* objectp = getObject();
if (objectp)
@@ -5963,10 +6006,10 @@ void LLPickInfo::getSurfaceInfo()
if (gViewerWindow->cursorIntersect(llround((F32)mMousePt.mX), llround((F32)mMousePt.mY), 1024.f,
objectp, -1, mPickTransparent,
&mObjectFace,
&mIntersection,
&intersection,
&mSTCoords,
&mNormal,
&mBinormal))
&normal,
&tangent))
{
// if we succeeded with the intersect above, compute the texture coordinates:
@@ -5975,10 +6018,26 @@ void LLPickInfo::getSurfaceInfo()
LLFace* facep = objectp->mDrawable->getFace(mObjectFace);
if (facep)
{
mUVCoords = facep->surfaceToTexture(mSTCoords, mIntersection, mNormal);
mUVCoords = facep->surfaceToTexture(mSTCoords, intersection, normal);
}
}
mIntersection.set(intersection.getF32ptr());
mNormal.set(normal.getF32ptr());
mTangent.set(tangent.getF32ptr());
//extrapoloate binormal from normal and tangent
LLVector4a binormal;
binormal.setCross3(normal, tangent);
binormal.mul(tangent.getF32ptr()[3]);
mBinormal.set(binormal.getF32ptr());
mBinormal.normalize();
mNormal.normalize();
mTangent.normalize();
// and XY coords:
updateXYCoords();

View File

@@ -115,6 +115,7 @@ public:
LLVector2 mSTCoords;
LLCoordScreen mXYCoords;
LLVector3 mNormal;
LLVector4 mTangent;
LLVector3 mBinormal;
BOOL mPickTransparent;
void getSurfaceInfo();
@@ -347,19 +348,19 @@ public:
static void hoverPickCallback(const LLPickInfo& pick_info);
LLHUDIcon* cursorIntersectIcon(S32 mouse_x, S32 mouse_y, F32 depth,
LLVector3* intersection);
LLVector4a* intersection);
LLViewerObject* cursorIntersect(S32 mouse_x = -1, S32 mouse_y = -1, F32 depth = 512.f,
LLViewerObject *this_object = NULL,
S32 this_face = -1,
BOOL pick_transparent = FALSE,
S32* face_hit = NULL,
LLVector3 *intersection = NULL,
LLVector4a *intersection = NULL,
LLVector2 *uv = NULL,
LLVector3 *normal = NULL,
LLVector3 *binormal = NULL,
LLVector3* start = NULL,
LLVector3* end = NULL);
LLVector4a *normal = NULL,
LLVector4a *tangent = NULL,
LLVector4a* start = NULL,
LLVector4a* end = NULL);
// Returns a pointer to the last object hit
@@ -509,13 +510,13 @@ extern LLFrameTimer gAwayTimer; // tracks time before setting the avatar awa
extern LLFrameTimer gAwayTriggerTimer; // how long the avatar has been away
extern LLViewerObject* gDebugRaycastObject;
extern LLVector3 gDebugRaycastIntersection;
extern LLVector4a gDebugRaycastIntersection;
extern LLVector2 gDebugRaycastTexCoord;
extern LLVector3 gDebugRaycastNormal;
extern LLVector3 gDebugRaycastBinormal;
extern LLVector4a gDebugRaycastNormal;
extern LLVector4a gDebugRaycastTangent;
extern S32 gDebugRaycastFaceHit;
extern LLVector3 gDebugRaycastStart;
extern LLVector3 gDebugRaycastEnd;
extern LLVector4a gDebugRaycastStart;
extern LLVector4a gDebugRaycastEnd;
extern BOOL gDisplayCameraPos;
extern BOOL gDisplayWindInfo;

View File

@@ -1729,19 +1729,20 @@ void LLVOAvatar::renderCollisionVolumes()
if (mNameText.notNull())
{
LLVector3 unused;
mNameText->lineSegmentIntersect(LLVector3(0,0,0), LLVector3(0,0,1), unused, TRUE);
LLVector4a unused;
mNameText->lineSegmentIntersect(unused, unused, unused, TRUE);
}
}
BOOL LLVOAvatar::lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
BOOL LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
S32 face,
BOOL pick_transparent,
S32* face_hit,
LLVector3* intersection,
LLVector4a* intersection,
LLVector2* tex_coord,
LLVector3* normal,
LLVector3* bi_normal)
LLVector4a* normal,
LLVector4a* tangent)
{
if ((isSelf() && !gAgent.needsRenderAvatar()) || !LLPipeline::sPickAvatar)
{
@@ -1758,8 +1759,8 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
glh::matrix4f inverse = mat.inverse();
glh::matrix4f norm_mat = inverse.transpose();
glh::vec3f p1(start.mV);
glh::vec3f p2(end.mV);
glh::vec3f p1(start.getF32ptr());
glh::vec3f p2(end.getF32ptr());
inverse.mult_matrix_vec(p1);
inverse.mult_matrix_vec(p2);
@@ -1778,12 +1779,12 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
if (intersection)
{
*intersection = LLVector3(res_pos.v);
intersection->load3(res_pos.v);
}
if (normal)
{
*normal = LLVector3(res_norm.v);
normal->load3(res_norm.v);
}
return TRUE;
@@ -1817,7 +1818,8 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
}
}
LLVector3 position;
LLVector4a position;
if (mNameText.notNull() && mNameText->lineSegmentIntersect(start, end, position))
{
if (intersection)
@@ -1831,14 +1833,14 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
return FALSE;
}
LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector3& start, const LLVector3& end,
LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector4a& start, const LLVector4a& end,
S32 face,
BOOL pick_transparent,
S32* face_hit,
LLVector3* intersection,
LLVector4a* intersection,
LLVector2* tex_coord,
LLVector3* normal,
LLVector3* bi_normal)
LLVector4a* normal,
LLVector4a* tangent)
{
static const LLCachedControl<bool> allow_mesh_picking("SGAllowRiggedMeshSelection");
@@ -1851,8 +1853,8 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector
if (lineSegmentBoundingBox(start, end))
{
LLVector3 local_end = end;
LLVector3 local_intersection;
LLVector4a local_end = end;
LLVector4a local_intersection;
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
iter != mAttachmentPoints.end();
@@ -1866,7 +1868,7 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector
{
LLViewerObject* attached_object = (*attachment_iter);
if (attached_object->lineSegmentIntersect(start, local_end, face, pick_transparent, face_hit, &local_intersection, tex_coord, normal, bi_normal))
if (attached_object->lineSegmentIntersect(start, local_end, face, pick_transparent, face_hit, &local_intersection, tex_coord, normal, tangent))
{
local_end = local_intersection;
if (intersection)

View File

@@ -201,22 +201,22 @@ public:
/*virtual*/ void updateRegion(LLViewerRegion *regionp);
/*virtual*/ void updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax);
/*virtual*/ void getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax);
/*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
/*virtual*/ BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
S32 face = -1, // which face to check, -1 = ALL_SIDES
BOOL pick_transparent = FALSE,
S32* face_hit = NULL, // which face was hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL); // return the surface bi-normal at the intersection point
LLViewerObject* lineSegmentIntersectRiggedAttachments(const LLVector3& start, const LLVector3& end,
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL); // return the surface tangent at the intersection point
LLViewerObject* lineSegmentIntersectRiggedAttachments(const LLVector4a& start, const LLVector4a& end,
S32 face = -1, // which face to check, -1 = ALL_SIDES
BOOL pick_transparent = FALSE,
S32* face_hit = NULL, // which face was hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL); // return the surface bi-normal at the intersection point
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL); // return the surface tangent at the intersection point
//--------------------------------------------------------------------
// LLCharacter interface and related

View File

@@ -789,8 +789,8 @@ void LLVOGrass::updateDrawable(BOOL force_damped)
}
// virtual
BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
BOOL LLVOGrass::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent)
{
BOOL ret = FALSE;
@@ -801,7 +801,8 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
return FALSE;
}
LLVector3 dir = end-start;
LLVector4a dir;
dir.setSub(end, start);
mPatch = mRegionp->getLand().resolvePatchRegion(getPositionRegion());
@@ -869,23 +870,31 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
U32 idx0 = 0,idx1 = 0,idx2 = 0;
if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, a, b, t, FALSE))
LLVector4a v0a,v1a,v2a,v3a;
v0a.load3(v[0].mV);
v1a.load3(v[1].mV);
v2a.load3(v[2].mV);
v3a.load3(v[3].mV);
if (LLTriangleRayIntersect(v0a, v1a, v2a, start, dir, a, b, t))
{
hit = TRUE;
idx0 = 0; idx1 = 1; idx2 = 2;
}
else if (LLTriangleRayIntersect(v[1], v[3], v[2], start, dir, a, b, t, FALSE))
else if (LLTriangleRayIntersect(v1a, v3a, v2a, start, dir, a, b, t))
{
hit = TRUE;
idx0 = 1; idx1 = 3; idx2 = 2;
}
else if (LLTriangleRayIntersect(v[2], v[1], v[0], start, dir, a, b, t, FALSE))
else if (LLTriangleRayIntersect(v2a, v1a, v0a, start, dir, a, b, t))
{
normal1 = -normal1;
hit = TRUE;
idx0 = 2; idx1 = 1; idx2 = 0;
}
else if (LLTriangleRayIntersect(v[2], v[3], v[1], start, dir, a, b, t, FALSE))
else if (LLTriangleRayIntersect(v2a, v3a, v1a, start, dir, a, b, t))
{
normal1 = -normal1;
hit = TRUE;
@@ -908,7 +917,8 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
closest_t = t;
if (intersection != NULL)
{
*intersection = start+dir*closest_t;
dir.mul(closest_t);
intersection->setAdd(start, dir);
}
if (tex_coord != NULL)
@@ -918,7 +928,7 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
if (normal != NULL)
{
*normal = normal1;
normal->load3(normal1.mV);
}
ret = TRUE;
}

View File

@@ -81,14 +81,14 @@ public:
/*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate.
/*virtual*/ void idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
/*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
/*virtual*/ BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
S32 face = -1, // which face to check, -1 = ALL_SIDES
BOOL pick_transparent = FALSE,
S32* face_hit = NULL, // which face was hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL // return the surface tangent at the intersection point
);
static S32 sMaxGrassSpecies;

View File

@@ -103,10 +103,10 @@ public:
glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
if (data_mask & MAP_BINORMAL)
if (data_mask & MAP_TANGENT)
{
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TANGENT], (void*)(base + mOffsets[TYPE_TANGENT]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
if (data_mask & MAP_TEXCOORD0)
@@ -942,8 +942,8 @@ void LLVOSurfacePatch::getGeomSizesEast(const S32 stride, const S32 east_stride,
}
}
BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent)
{
@@ -952,7 +952,9 @@ BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector3& start, const LLVect
return FALSE;
}
LLVector3 delta = end-start;
LLVector4a da;
da.setSub(end, start);
LLVector3 delta(da.getF32ptr());
LLVector3 pdelta = delta;
pdelta.mV[2] = 0;
@@ -961,7 +963,9 @@ BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector3& start, const LLVect
F32 tdelta = 1.f/plength;
LLVector3 origin = start - mRegionp->getOriginAgent();
LLVector3 v_start(start.getF32ptr());
LLVector3 origin = v_start - mRegionp->getOriginAgent();
if (mRegionp->getLandHeightRegion(origin) > origin.mV[2])
{
@@ -1016,12 +1020,12 @@ BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector3& start, const LLVect
{
sample.mV[2] = mRegionp->getLandHeightRegion(sample);
}
*intersection = sample + mRegionp->getOriginAgent();
intersection->load3((sample + mRegionp->getOriginAgent()).mV);
}
if (normal)
{
*normal = mRegionp->getLand().resolveNormalGlobal(mRegionp->getPosGlobalFromRegion(sample));
normal->load3((mRegionp->getLand().resolveNormalGlobal(mRegionp->getPosGlobalFromRegion(sample))).mV);
}
return TRUE;

View File

@@ -85,14 +85,14 @@ public:
void dirtyPatch();
void dirtyGeom();
/*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
/*virtual*/ BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
S32 face = -1, // which face to check, -1 = ALL_SIDES
BOOL pick_transparent = FALSE,
S32* face_hit = NULL, // which face was hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL // return the surface tangent at the intersection point
);
BOOL mDirtiedPatch;

View File

@@ -1253,8 +1253,8 @@ void LLVOTree::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
mDrawable->setPositionGroup(pos);
}
BOOL LLVOTree::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
BOOL LLVOTree::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent)
{
@@ -1283,16 +1283,19 @@ BOOL LLVOTree::lineSegmentIntersect(const LLVector3& start, const LLVector3& end
LLVector3 pos, norm;
if (linesegment_tetrahedron(start, end, center, size, quat, pos, norm))
LLVector3 start3(start.getF32ptr());
LLVector3 end3(end.getF32ptr());
if (linesegment_tetrahedron(start3, end3, center, size, quat, pos, norm))
{
if (intersection)
{
*intersection = pos;
intersection->load3(pos.mV);
}
if (normal)
{
*normal = norm;
normal->load3(norm.mV);
}
return TRUE;
}

View File

@@ -115,14 +115,14 @@ public:
U32 drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop, F32 branches, F32 alpha);
/*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
/*virtual*/ BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
S32 face = -1, // which face to check, -1 = ALL_SIDES
BOOL pick_transparent = FALSE,
S32* face_hit = NULL, // which face was hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL // return the surface tangent at the intersection point
);
static S32 sMaxTreeSpecies;

View File

@@ -1053,13 +1053,17 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params_in, const S32 detail, bo
{ //already cached
break;
}
volume->genBinormals(i);
volume->genTangents(i);
LLFace::cacheFaceInVRAM(face);
}
}
return TRUE;
}
return FALSE;
}
@@ -1218,7 +1222,7 @@ BOOL LLVOVolume::calcLOD()
else
{
distance = mDrawable->mDistanceWRTCamera;
radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length();
radius = getVolume() ? getVolume()->mLODScaleBias.scaledVec(getScale()).length() : getScale().length();
}
@@ -3589,8 +3593,8 @@ LLVector3 LLVOVolume::volumeDirectionToAgent(const LLVector3& dir) const
}
BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent)
{
if (!mbCanSelect ||
@@ -3631,23 +3635,25 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
if (volume)
{
LLVector3 v_start, v_end, v_dir;
LLVector4a local_start = start;
LLVector4a local_end = end;
if (transform)
{
v_start = agentPositionToVolume(start);
v_end = agentPositionToVolume(end);
}
else
{
v_start = start;
v_end = end;
}
LLVector3 v_start(start.getF32ptr());
LLVector3 v_end(end.getF32ptr());
LLVector3 p;
LLVector3 n;
v_start = agentPositionToVolume(v_start);
v_end = agentPositionToVolume(v_end);
local_start.load3(v_start.mV);
local_end.load3(v_end.mV);
}
LLVector4a p;
LLVector4a n;
LLVector2 tc;
LLVector3 bn;
LLVector4a tn;
if (intersection != NULL)
{
@@ -3664,9 +3670,9 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
n = *normal;
}
if (bi_normal != NULL)
if (tangent != NULL)
{
bn = *bi_normal;
tn = *tangent;
}
S32 face_hit = -1;
@@ -3692,8 +3698,8 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
continue;
}
face_hit = volume->lineSegmentIntersect(v_start, v_end, i,
&p, &tc, &n, &bn);
face_hit = volume->lineSegmentIntersect(local_start, local_end, i,
&p, &tc, &n, &tn);
if (face_hit >= 0 && mDrawable->getNumFaces() > face_hit)
{
@@ -3702,7 +3708,7 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
if (face &&
(pick_transparent || !face->getTexture() || !face->getTexture()->hasGLTexture() || face->getTexture()->getMask(face->surfaceToTexture(tc, p, n))))
{
v_end = p;
local_end = p;
if (face_hitp != NULL)
{
*face_hitp = face_hit;
@@ -3712,7 +3718,9 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
{
if (transform)
{
*intersection = volumePositionToAgent(p); // must map back to agent space
LLVector3 v_p(p.getF32ptr());
intersection->load3(volumePositionToAgent(v_p).mV); // must map back to agent space
}
else
{
@@ -3724,27 +3732,36 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
{
if (transform)
{
*normal = volumeDirectionToAgent(n);
LLVector3 v_n(n.getF32ptr());
normal->load3(volumeDirectionToAgent(v_n).mV);
}
else
{
*normal = n;
}
(*normal).normVec();
(*normal).normalize3fast();
}
if (bi_normal != NULL)
if (tangent != NULL)
{
if (transform)
{
*bi_normal = volumeDirectionToAgent(bn);
LLVector3 v_tn(tn.getF32ptr());
LLVector4a trans_tangent;
trans_tangent.load3(volumeDirectionToAgent(v_tn).mV);
LLVector4Logical mask;
mask.clear();
mask.setElement<3>();
tangent->setSelectWithMask(mask, tn, trans_tangent);
}
else
{
*bi_normal = bn;
*tangent = tn;
}
(*bi_normal).normVec();
(*tangent).normalize3fast();
}
if (tex_coord != NULL)
@@ -4262,11 +4279,18 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
mFaceList.clear();
std::vector<LLFace*> fullbright_faces;
std::vector<LLFace*> bump_faces;
std::vector<LLFace*> simple_faces;
const U32 MAX_FACE_COUNT = 4096;
static LLFace** fullbright_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64);
static LLFace** bump_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64);
static LLFace** simple_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64);
static LLFace** alpha_faces = (LLFace**) ll_aligned_malloc(MAX_FACE_COUNT*sizeof(LLFace*),64);
U32 fullbright_count = 0;
U32 bump_count = 0;
U32 simple_count = 0;
U32 alpha_count = 0;
std::vector<LLFace*> alpha_faces;
U32 useage = group->mSpatialPartition->mBufferUsage;
static const LLCachedControl<S32> render_max_vbo_size("RenderMaxVBOSize", 512);
@@ -4623,7 +4647,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{
if (facep->canRenderAsMask())
{ //can be treated as alpha mask
simple_faces.push_back(facep);
if (simple_count < MAX_FACE_COUNT)
{
simple_faces[simple_count++] = facep;
}
}
else
{
@@ -4631,7 +4658,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{ //only treat as alpha in the pipeline if < 100% transparent
drawablep->setState(LLDrawable::HAS_ALPHA);
}
alpha_faces.push_back(facep);
if (alpha_count < MAX_FACE_COUNT)
{
alpha_faces[alpha_count++] = facep;
}
}
}
else
@@ -4645,34 +4675,52 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
&& LLPipeline::sRenderBump)
{
if (te->getBumpmap())
{ //needs normal + binormal
bump_faces.push_back(facep);
{ //needs normal + tangent
if (bump_count < MAX_FACE_COUNT)
{
bump_faces[bump_count++] = facep;
}
}
else if (te->getShiny() || !te->getFullbright())
{ //needs normal
simple_faces.push_back(facep);
if (simple_count < MAX_FACE_COUNT)
{
simple_faces[simple_count++] = facep;
}
}
else
{ //doesn't need normal
facep->setState(LLFace::FULLBRIGHT);
fullbright_faces.push_back(facep);
if (fullbright_count < MAX_FACE_COUNT)
{
fullbright_faces[fullbright_count++] = facep;
}
}
}
else
{
if (te->getBumpmap() && LLPipeline::sRenderBump)
{ //needs normal + binormal
bump_faces.push_back(facep);
{ //needs normal + tangent
if (bump_count < MAX_FACE_COUNT)
{
bump_faces[bump_count++] = facep;
}
}
else if ((te->getShiny() && LLPipeline::sRenderBump) ||
!(te->getFullbright() || bake_sunlight))
{ //needs normal
simple_faces.push_back(facep);
if (simple_count < MAX_FACE_COUNT)
{
simple_faces[simple_count++] = facep;
}
}
else
{ //doesn't need normal
facep->setState(LLFace::FULLBRIGHT);
fullbright_faces.push_back(facep);
if (fullbright_count < MAX_FACE_COUNT)
{
fullbright_faces[fullbright_count++] = facep;
}
}
}
}
@@ -4714,18 +4762,18 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
if (batch_textures)
{
bump_mask |= LLVertexBuffer::MAP_BINORMAL;
genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, TRUE);
genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, FALSE, TRUE);
genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, FALSE, TRUE);
genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, TRUE, TRUE);
bump_mask |= LLVertexBuffer::MAP_TANGENT;
genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, simple_count, FALSE, TRUE);
genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, fullbright_count, FALSE, TRUE);
genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, bump_count, FALSE, TRUE);
genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, alpha_count, TRUE, TRUE);
}
else
{
genDrawInfo(group, simple_mask, simple_faces);
genDrawInfo(group, fullbright_mask, fullbright_faces);
genDrawInfo(group, bump_mask, bump_faces, FALSE, TRUE);
genDrawInfo(group, alpha_mask, alpha_faces, TRUE);
genDrawInfo(group, simple_mask, simple_faces, simple_count);
genDrawInfo(group, fullbright_mask, fullbright_faces, fullbright_count);
genDrawInfo(group, bump_mask, bump_faces, bump_count, FALSE, TRUE);
genDrawInfo(group, alpha_mask, alpha_faces, alpha_count, TRUE);
}
@@ -4767,13 +4815,17 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
{
LLFastTimer ftm(FTM_REBUILD_VOLUME_VB);
LLFastTimer t(FTM_REBUILD_VOLUME_GEN_DRAW_INFO); //make sure getgeometryvolume shows up in the right place in timers
S32 num_mapped_vertex_buffer = LLVertexBuffer::sMappedCount ;
group->mBuilt = 1.f;
std::set<LLVertexBuffer*> mapped_buffers;
OctreeGuard guard(group->mOctreeNode);
S32 num_mapped_vertex_buffer = LLVertexBuffer::sMappedCount ;
const U32 MAX_BUFFER_COUNT = 4096;
static LLVertexBuffer* locked_buffer[MAX_BUFFER_COUNT];
U32 buffer_count = 0;
for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
{
LLDrawable* drawablep = *drawable_iter;
@@ -4807,9 +4859,9 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
}
if (buff->isLocked())
if (buff->isLocked() && buffer_count < MAX_BUFFER_COUNT)
{
mapped_buffers.insert(buff);
locked_buffer[buffer_count++] = buff;
}
}
}
@@ -4825,7 +4877,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
}
}
for (std::set<LLVertexBuffer*>::iterator iter = mapped_buffers.begin(); iter != mapped_buffers.end(); ++iter)
for (LLVertexBuffer** iter = locked_buffer, ** end_iter = locked_buffer+buffer_count; iter != end_iter; ++iter)
{
(*iter)->flush();
}
@@ -4904,7 +4956,7 @@ static LLFastTimer::DeclareTimer FTM_GEN_DRAW_INFO_RESIZE_VB("Resize VB");
void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort, BOOL batch_textures)
void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace** faces, U32 face_count, BOOL distance_sort, BOOL batch_textures, BOOL no_materials)
{
LLFastTimer t(FTM_REBUILD_VOLUME_GEN_DRAW_INFO);
@@ -4931,17 +4983,18 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
if (!distance_sort)
{
//sort faces by things that break batches
std::sort(faces.begin(), faces.end(), CompareBatchBreakerModified());
std::sort(faces, faces+face_count, CompareBatchBreakerModified());
}
else
{
//sort faces by distance
std::sort(faces.begin(), faces.end(), LLFace::CompareDistanceGreater());
std::sort(faces, faces+face_count, LLFace::CompareDistanceGreater());
}
}
bool hud_group = group->isHUDGroup() ;
std::vector<LLFace*>::iterator face_iter = faces.begin();
LLFace** face_iter = faces;
LLFace** end_faces = faces+face_count;
LLSpatialGroup::buffer_map_t buffer_map;
@@ -4973,7 +5026,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
//NEVER use more than 16 texture index channels (workaround for prevalent driver bug)
texture_index_channels = llmin(texture_index_channels, 16);
while (face_iter != faces.end())
while (face_iter != end_faces)
{
//pull off next face
LLFace* facep = *face_iter;
@@ -4999,11 +5052,15 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
U32 index_count = facep->getIndicesCount();
U32 geom_count = facep->getGeomCount();
//sum up vertices needed for this render batch
std::vector<LLFace*>::iterator i = face_iter;
LLFace** i = face_iter;
++i;
std::vector<LLViewerTexture*> texture_list;
const U32 MAX_TEXTURE_COUNT = 32;
static LLViewerTexture* texture_list[MAX_TEXTURE_COUNT];
U32 texture_count = 0;
{
LLFastTimer t(FTM_GEN_DRAW_INFO_FACE_SIZE);
@@ -5011,11 +5068,15 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
{
U8 cur_tex = 0;
facep->setTextureIndex(cur_tex);
texture_list.push_back(tex);
if (texture_count < MAX_TEXTURE_COUNT)
{
texture_list[texture_count++] = tex;
}
if (can_batch_texture(facep))
{
while (i != faces.end())
{ //populate texture_list with any textures that can be batched
//move i to the next unbatchable face
while (i != end_faces)
{
facep = *i;
if (!can_batch_texture(facep))
@@ -5028,7 +5089,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
if (distance_sort)
{ //textures might be out of order, see if texture exists in current batch
bool found = false;
for (U32 tex_idx = 0; tex_idx < texture_list.size(); ++tex_idx)
for (U32 tex_idx = 0; tex_idx < texture_count; ++tex_idx)
{
if (facep->getTexture() == texture_list[tex_idx])
{
@@ -5040,7 +5101,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
if (!found)
{
cur_tex = texture_list.size();
cur_tex = texture_count;
}
}
else
@@ -5055,7 +5116,10 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
tex = facep->getTexture();
texture_list.push_back(tex);
if (texture_count < MAX_TEXTURE_COUNT)
{
texture_list[texture_count++] = tex;
}
}
if (geom_count + facep->getGeomCount() > max_vertices)
@@ -5074,7 +5138,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
}
else
{
while (i != faces.end() &&
while (i != end_faces &&
(LLPipeline::sTextureBindTest || (distance_sort || (*i)->getTexture() == tex)))
{
facep = *i;

View File

@@ -142,14 +142,14 @@ public:
/*virtual*/ U32 getTriangleCount(S32* vcount = NULL) const;
/*virtual*/ U32 getHighLODTriangleCount();
/*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
/*virtual*/ BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
S32 face = -1, // which face to check, -1 = ALL_SIDES
BOOL pick_transparent = FALSE,
S32* face_hit = NULL, // which face was hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL // return the surface tangent at the intersection point
);
LLVector3 agentPositionToVolume(const LLVector3& pos) const;

View File

@@ -6167,20 +6167,20 @@ BOOL LLPipeline::getRenderHighlights(void*)
return sRenderHighlight;
}
LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end,
LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, const LLVector4a& end,
BOOL pick_transparent,
S32* face_hit,
LLVector3* intersection, // return the intersection point
LLVector4a* intersection, // return the intersection point
LLVector2* tex_coord, // return the texture coordinates of the intersection point
LLVector3* normal, // return the surface normal at the intersection point
LLVector3* bi_normal // return the surface bi-normal at the intersection point
LLVector4a* normal, // return the surface normal at the intersection point
LLVector4a* tangent // return the surface tangent at the intersection point
)
{
LLDrawable* drawable = NULL;
LLVector3 local_end = end;
LLVector4a local_end = end;
LLVector3 position;
LLVector4a position;
sPickAvatar = FALSE; //LLToolMgr::getInstance()->inBuildMode() ? FALSE : TRUE;
@@ -6200,7 +6200,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start,
LLSpatialPartition* part = region->getSpatialPartition(j);
if (part && hasRenderType(part->mDrawableType))
{
LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, bi_normal);
LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, tangent);
if (hit)
{
drawable = hit;
@@ -6215,8 +6215,8 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start,
{
//save hit info in case we need to restore
//due to attachment override
LLVector3 local_normal;
LLVector3 local_binormal;
LLVector4a local_normal;
LLVector4a local_tangent;
LLVector2 local_texcoord;
S32 local_face_hit = -1;
@@ -6228,14 +6228,22 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start,
{
local_texcoord = *tex_coord;
}
if (bi_normal)
if (tangent)
{
local_binormal = *bi_normal;
local_tangent = *tangent;
}
else
{
local_tangent.clear();
}
if (normal)
{
local_normal = *normal;
}
else
{
local_normal.clear();
}
const F32 ATTACHMENT_OVERRIDE_DIST = 0.1f;
@@ -6249,12 +6257,15 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start,
LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_BRIDGE);
if (part && hasRenderType(part->mDrawableType))
{
LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, bi_normal);
LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, tangent);
if (hit)
{
LLVector4a delta;
delta.setSub(position, local_end);
if (!drawable ||
!drawable->getVObj()->isAttachment() ||
(position-local_end).magVec() > ATTACHMENT_OVERRIDE_DIST)
delta.getLength3().getF32() > ATTACHMENT_OVERRIDE_DIST)
{ //avatar overrides if previously hit drawable is not an attachment or
//attachment is far enough away from detected intersection
drawable = hit;
@@ -6272,9 +6283,9 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start,
{
*tex_coord = local_texcoord;
}
if (bi_normal)
if (tangent)
{
*bi_normal = local_binormal;
*tangent = local_tangent;
}
if (normal)
{
@@ -6308,13 +6319,13 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start,
return drawable ? drawable->getVObj().get() : NULL;
}
LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end,
LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector4a& start, const LLVector4a& end,
BOOL pick_transparent,
S32* face_hit,
LLVector3* intersection, // return the intersection point
LLVector4a* intersection, // return the intersection point
LLVector2* tex_coord, // return the texture coordinates of the intersection point
LLVector3* normal, // return the surface normal at the intersection point
LLVector3* bi_normal // return the surface bi-normal at the intersection point
LLVector4a* normal, // return the surface normal at the intersection point
LLVector4a* tangent // return the surface tangent at the intersection point
)
{
LLDrawable* drawable = NULL;
@@ -6334,7 +6345,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, co
LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD);
if (part)
{
LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, face_hit, intersection, tex_coord, normal, bi_normal);
LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, face_hit, intersection, tex_coord, normal, tangent);
if (hit)
{
drawable = hit;
@@ -6815,13 +6826,18 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
{
if (LLViewerJoystick::getInstance()->getOverrideCamera())
{ //focus on point under cursor
focus_point = gDebugRaycastIntersection;
focus_point.set(gDebugRaycastIntersection.getF32ptr());
}
else if (gAgentCamera.cameraMouselook())
{ //focus on point under mouselook crosshairs
LLVector4a result;
result.clear();
gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE,
NULL,
&focus_point);
NULL,
&result);
focus_point.set(result.getF32ptr());
}
else if(gAgent.getRegion())
{

View File

@@ -189,21 +189,21 @@ public:
void markMeshDirty(LLSpatialGroup* group);
//get the object between start and end that's closest to start.
LLViewerObject* lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end,
LLViewerObject* lineSegmentIntersectInWorld(const LLVector4a& start, const LLVector4a& end,
BOOL pick_transparent,
S32* face_hit, // return the face hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL // return the surface tangent at the intersection point
);
LLViewerObject* lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end,
LLViewerObject* lineSegmentIntersectInHUD(const LLVector4a& start, const LLVector4a& end,
BOOL pick_transparent,
S32* face_hit, // return the face hit
LLVector3* intersection = NULL, // return the intersection point
LLVector4a* intersection = NULL, // return the intersection point
LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
LLVector3* normal = NULL, // return the surface normal at the intersection point
LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
LLVector4a* normal = NULL, // return the surface normal at the intersection point
LLVector4a* tangent = NULL // return the surface tangent at the intersection point
);
// Something about these textures has changed. Dirty them.