SL-16478 Fix for octree and render batch debug display not working with rigged meshes.
parent
828e584329
commit
dd03246735
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
* @file debugSkinnedV.glsl
|
||||
*
|
||||
* $LicenseInfo:firstyear=2021&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2011, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat4 modelview_matrix;
|
||||
|
||||
mat4 getObjectSkinnedTransform();
|
||||
|
||||
ATTRIBUTE vec3 position;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 mat = getObjectSkinnedTransform();
|
||||
mat = modelview_matrix * mat;
|
||||
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
|
||||
|
||||
gl_Position = projection_matrix*vec4(pos, 1.0);
|
||||
}
|
||||
|
||||
|
|
@ -27,8 +27,21 @@ uniform mat4 modelview_projection_matrix;
|
|||
|
||||
ATTRIBUTE vec3 position;
|
||||
|
||||
#ifdef HAS_SKIN
|
||||
mat4 getObjectSkinnedTransform();
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat4 modelview_matrix;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef HAS_SKIN
|
||||
mat4 mat = getObjectSkinnedTransform();
|
||||
mat = modelview_matrix * mat;
|
||||
vec4 pos = mat * vec4(position.xyz,1.0);
|
||||
gl_Position = projection_matrix * pos;
|
||||
#else
|
||||
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -590,7 +590,13 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba
|
|||
bool LLRenderPass::uploadMatrixPalette(LLDrawInfo& params)
|
||||
{
|
||||
// upload matrix palette to shader
|
||||
const LLVOAvatar::MatrixPaletteCache& mpc = params.mAvatar->updateSkinInfoMatrixPalette(params.mSkinInfo);
|
||||
return uploadMatrixPalette(params.mAvatar, params.mSkinInfo);
|
||||
}
|
||||
|
||||
//static
|
||||
bool LLRenderPass::uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinInfo)
|
||||
{
|
||||
const LLVOAvatar::MatrixPaletteCache& mpc = avatar->updateSkinInfoMatrixPalette(skinInfo);
|
||||
U32 count = mpc.mMatrixPalette.size();
|
||||
|
||||
if (count == 0)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ class LLViewerTexture;
|
|||
class LLViewerFetchedTexture;
|
||||
class LLSpatialGroup;
|
||||
class LLDrawInfo;
|
||||
class LLVOAvatar;
|
||||
class LLMeshSkinInfo;
|
||||
|
||||
class LLDrawPool
|
||||
{
|
||||
|
|
@ -204,6 +206,7 @@ public:
|
|||
virtual void pushRiggedMaskBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE);
|
||||
virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE);
|
||||
static bool uploadMatrixPalette(LLDrawInfo& params);
|
||||
static bool uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinInfo);
|
||||
virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE);
|
||||
virtual void renderRiggedGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1593,10 +1593,14 @@ void renderOctree(LLSpatialGroup* group)
|
|||
gGL.flush();
|
||||
glLineWidth(1.f);
|
||||
gGL.flush();
|
||||
|
||||
LLVOAvatar* lastAvatar = nullptr;
|
||||
U64 lastMeshId = 0;
|
||||
|
||||
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
|
||||
if(!drawable)
|
||||
if(!drawable || drawable->getNumFaces() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1607,6 +1611,27 @@ void renderOctree(LLSpatialGroup* group)
|
|||
gGL.translatef(trans.mV[0], trans.mV[1], trans.mV[2]);
|
||||
}
|
||||
|
||||
LLFace* face = drawable->getFace(0);
|
||||
bool rigged = face->isState(LLFace::RIGGED);
|
||||
gDebugProgram.bind(rigged);
|
||||
|
||||
gGL.diffuseColor4f(1, 0, 0, 1);
|
||||
|
||||
if (rigged)
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
if (lastAvatar != face->mAvatar ||
|
||||
lastMeshId != face->mSkinInfo->mHash)
|
||||
{
|
||||
if (!LLRenderPass::uploadMatrixPalette(face->mAvatar, face->mSkinInfo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
lastAvatar = face->mAvatar;
|
||||
lastMeshId = face->mSkinInfo->mHash;
|
||||
}
|
||||
}
|
||||
for (S32 j = 0; j < drawable->getNumFaces(); j++)
|
||||
{
|
||||
LLFace* face = drawable->getFace(j);
|
||||
|
|
@ -1625,19 +1650,25 @@ void renderOctree(LLSpatialGroup* group)
|
|||
continue;
|
||||
}
|
||||
|
||||
face->getVertexBuffer()->setBuffer(LLVertexBuffer::MAP_VERTEX);
|
||||
face->getVertexBuffer()->setBuffer(LLVertexBuffer::MAP_VERTEX | (rigged ? LLVertexBuffer::MAP_WEIGHT4 : 0));
|
||||
//drawBox((face->mExtents[0] + face->mExtents[1])*0.5f,
|
||||
// (face->mExtents[1]-face->mExtents[0])*0.5f);
|
||||
face->getVertexBuffer()->draw(LLRender::TRIANGLES, face->getIndicesCount(), face->getIndicesStart());
|
||||
}
|
||||
}
|
||||
|
||||
if (rigged)
|
||||
{
|
||||
gGL.popMatrix();
|
||||
}
|
||||
|
||||
if (!group->getSpatialPartition()->isBridge())
|
||||
{
|
||||
gGL.popMatrix();
|
||||
}
|
||||
}
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
gDebugProgram.bind(); // make sure non-rigged variant is bound
|
||||
gGL.diffuseColor4f(1,1,1,1);
|
||||
}
|
||||
}
|
||||
|
|
@ -2778,6 +2809,8 @@ void renderBatchSize(LLDrawInfo* params)
|
|||
bool bind = false;
|
||||
if (params->mAvatar)
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
bind = true;
|
||||
old_shader->mRiggedVariant->bind();
|
||||
LLRenderPass::uploadMatrixPalette(*params);
|
||||
|
|
@ -2789,6 +2822,7 @@ void renderBatchSize(LLDrawInfo* params)
|
|||
|
||||
if (bind)
|
||||
{
|
||||
gGL.popMatrix();
|
||||
old_shader->bind();
|
||||
}
|
||||
}
|
||||
|
|
@ -3941,7 +3975,8 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset,
|
|||
{
|
||||
mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset);
|
||||
|
||||
mDebugColor = (rand() << 16) + rand();
|
||||
mDebugColor = (rand() << 16) + rand();
|
||||
((U8*)&mDebugColor)[3] = 200;
|
||||
}
|
||||
|
||||
LLDrawInfo::~LLDrawInfo()
|
||||
|
|
|
|||
|
|
@ -3664,20 +3664,10 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
|
|||
gDebugProgram.mShaderFiles.push_back(make_pair("interface/debugF.glsl", GL_FRAGMENT_SHADER_ARB));
|
||||
gDebugProgram.mRiggedVariant = &gSkinnedDebugProgram;
|
||||
gDebugProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE];
|
||||
success = gDebugProgram.createShader(NULL, NULL);
|
||||
success = make_rigged_variant(gDebugProgram, gSkinnedDebugProgram);
|
||||
success = success && gDebugProgram.createShader(NULL, NULL);
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
gSkinnedDebugProgram.mName = "Skinned Debug Shader";
|
||||
gSkinnedDebugProgram.mFeatures.hasObjectSkinning = true;
|
||||
gSkinnedDebugProgram.mShaderFiles.clear();
|
||||
gSkinnedDebugProgram.mShaderFiles.push_back(make_pair("interface/debugSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gSkinnedDebugProgram.mShaderFiles.push_back(make_pair("interface/debugF.glsl", GL_FRAGMENT_SHADER_ARB));
|
||||
gSkinnedDebugProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE];
|
||||
success = gSkinnedDebugProgram.createShader(NULL, NULL);
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
gClipProgram.mName = "Clip Shader";
|
||||
|
|
|
|||
|
|
@ -1767,6 +1767,7 @@ void LLViewerWindow::handleDataCopy(LLWindow *window, S32 data_type, void *data)
|
|||
|
||||
BOOL LLViewerWindow::handleTimerEvent(LLWindow *window)
|
||||
{
|
||||
//TODO: just call this every frame from gatherInput instead of using a convoluted 30fps timer callback
|
||||
if (LLViewerJoystick::getInstance()->getOverrideCamera())
|
||||
{
|
||||
LLViewerJoystick::getInstance()->updateStatus();
|
||||
|
|
|
|||
Loading…
Reference in New Issue