Merge remote-tracking branch 'singu/master'

This commit is contained in:
Aleric Inglewood
2013-09-23 01:43:52 +02:00
17 changed files with 244 additions and 58 deletions

4
README
View File

@@ -15,8 +15,8 @@ Singularity Viewer is a SecondLife(tm) protocol compatible client application.
It can be used to access SecondLife services as well as a number of others such
as those based upon the OpenSim platform.
Singulariy is maintained by a small group of volunteers who can be contacted
both, in-world (SingularityViewer group) as well on IRC (#SingularityViewer
Singularity is maintained by a small group of volunteers who can be contacted
both, in-world (SingularityViewer group) as well as on IRC (#SingularityViewer
@ FreeNode). Bug requests and features requests can be submitted through our
Issue Tracker (http://code.google.com/p/singularity-viewer/issues/list or from
the viewer menu: Help --> Bug Reporting --> Singularity Issue Tracker...)

View File

@@ -25,7 +25,7 @@
<!--Default for now-->
<RenderTerrainLODFactor value="1.0"/>
<!--Default for now-->
<RenderTreeLODFactor value="0.5"/>
<RenderTreeLODFactor value="0.75"/>
<!--Try Impostors-->
<RenderUseImpostors value="TRUE"/>
<!--Default for now-->

View File

@@ -25,7 +25,7 @@
<!--Default for now-->
<RenderTerrainLODFactor value="1.0"/>
<!--Default for now-->
<RenderTreeLODFactor value="0.5"/>
<RenderTreeLODFactor value="1.0"/>
<!--Try Impostors-->
<RenderUseImpostors value="TRUE"/>
<!--Default for now-->

View File

@@ -846,6 +846,17 @@ Found in Advanced->Rendering->Info Displays</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>SLBShowFPS</key>
<map>
<key>Comment</key>
<string>Show FPS</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>LogShowHistoryLines</key>
<map>
<key>Comment</key>
@@ -12210,7 +12221,7 @@ This should be as low as possible, but too low may break functionality</string>
<integer>0</integer>
</map>
<!--<key>RenderAnimateTrees</key>
<key>RenderAnimateTrees</key>
<map>
<key>Comment</key>
<string>Use GL matrix ops to animate tree branches.</string>
@@ -12220,7 +12231,7 @@ This should be as low as possible, but too low may break functionality</string>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>-->
</map>
<key>RenderNoAlpha</key>
<map>
<key>Comment</key>

View File

@@ -25,7 +25,7 @@
<!--Default for now-->
<RenderTerrainLODFactor value="2.0"/>
<!--Default for now-->
<RenderTreeLODFactor value="1.0"/>
<RenderTreeLODFactor value="2.0"/>
<!--Try Impostors-->
<RenderUseImpostors value="TRUE"/>
<!--Default for now-->

View File

@@ -90,7 +90,7 @@ RenderTerrainDetail 1 0
RenderTerrainScale 1 12.0
RenderTerrainLODFactor 1 1
RenderTransparentWater 1 0
RenderTreeLODFactor 1 0
RenderTreeLODFactor 1 0.125
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
VertexShaderEnable 1 0
@@ -155,7 +155,7 @@ RenderTerrainDetail 1 1
RenderTerrainScale 1 7.0
RenderTerrainLODFactor 1 2.0
RenderTransparentWater 1 1
RenderTreeLODFactor 1 0.5
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
VertexShaderEnable 1 1
@@ -186,7 +186,7 @@ RenderTerrainDetail 1 1
RenderTerrainScale 1 5.0
RenderTerrainLODFactor 1 2.0
RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderTreeLODFactor 1 2.0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 2.0
VertexShaderEnable 1 1

View File

@@ -87,7 +87,7 @@ RenderTerrainDetail 1 0
RenderTerrainScale 1 12.0
RenderTerrainLODFactor 1 1
RenderTransparentWater 1 0
RenderTreeLODFactor 1 0
RenderTreeLODFactor 1 0.125
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 0.5
VertexShaderEnable 1 0
@@ -151,7 +151,7 @@ RenderTerrainDetail 1 1
RenderTerrainScale 1 7.0
RenderTerrainLODFactor 1 2.0
RenderTransparentWater 1 1
RenderTreeLODFactor 1 0.5
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
VertexShaderEnable 1 1
@@ -184,7 +184,7 @@ RenderTerrainDetail 1 1
RenderTerrainScale 1 5.0
RenderTerrainLODFactor 1 2.0
RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderTreeLODFactor 1 2.0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 2.0
VertexShaderEnable 1 1

View File

@@ -90,7 +90,7 @@ RenderTerrainDetail 1 0
RenderTerrainScale 1 12.0
RenderTerrainLODFactor 1 1
RenderTransparentWater 1 0
RenderTreeLODFactor 1 0
RenderTreeLODFactor 1 0.125
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 0.5
VertexShaderEnable 1 0
@@ -155,7 +155,7 @@ RenderTerrainDetail 1 1
RenderTerrainScale 1 7.0
RenderTerrainLODFactor 1 2.0
RenderTransparentWater 1 1
RenderTreeLODFactor 1 0.5
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
VertexShaderEnable 1 1
@@ -188,7 +188,7 @@ RenderTerrainDetail 1 1
RenderTerrainScale 1 5.0
RenderTerrainLODFactor 1 2.0
RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderTreeLODFactor 1 2.0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 2.0
VertexShaderEnable 1 1

View File

@@ -104,12 +104,12 @@ void LLDrawPoolTree::render(S32 pass)
LLGLState test(GL_ALPHA_TEST, LLGLSLShader::sNoFixedFunction ? 0 : 1);
LLOverrideFaceColor color(this, 1.f, 1.f, 1.f, 1.f);
/*static const LLCachedControl<bool> render_animate_trees("RenderAnimateTrees",false);
if (render_animate_trees)
static LLCachedControl<bool> sRenderAnimateTrees("RenderAnimateTrees", false);
if (sRenderAnimateTrees)
{
renderTree();
}
else*/
else
gGL.getTexUnit(sDiffTex)->bind(mTexturep);
for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
@@ -209,7 +209,7 @@ void LLDrawPoolTree::endShadowPass(S32 pass)
gDeferredTreeShadowProgram.unbind();
}
/*
//
void LLDrawPoolTree::renderTree(BOOL selecting)
{
LLGLState normalize(GL_NORMALIZE, TRUE);
@@ -331,7 +331,7 @@ void LLDrawPoolTree::renderTree(BOOL selecting)
//gGL.popMatrix();
}
}
}*/
}//
BOOL LLDrawPoolTree::verify() const
{

View File

@@ -75,8 +75,8 @@ public:
static S32 sDiffTex;
//private:
//void renderTree(BOOL selecting = FALSE);
private:
void renderTree(BOOL selecting = FALSE);
};
#endif // LL_LLDRAWPOOLTREE_H

View File

@@ -642,7 +642,7 @@ void settings_setup_listeners()
gSavedSettings.getControl("OctreeAlphaDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
gSavedSettings.getControl("OctreeAttachmentSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
gSavedSettings.getControl("RenderMaxTextureIndex")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
//gSavedSettings.getControl("RenderAnimateTrees")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
gSavedSettings.getControl("RenderAnimateTrees")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
gSavedSettings.getControl("RenderDepthOfField")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));

View File

@@ -1204,6 +1204,7 @@ void init_debug_ui_menu(LLMenuGL* menu)
menu->addChild(new LLMenuItemCheckGL("Show Render Info", menu_toggle_control, NULL, menu_check_control, (void*)"DebugShowRenderInfo"));
menu->addChild(new LLMenuItemCheckGL("Show Matrices", menu_toggle_control, NULL, menu_check_control, (void*)"DebugShowRenderMatrices"));
menu->addChild(new LLMenuItemCheckGL("Show Color Under Cursor", menu_toggle_control, NULL, menu_check_control, (void*)"DebugShowColor"));
menu->addChild(new LLMenuItemCheckGL("Show FPS", menu_toggle_control, NULL, menu_check_control, (void*)"SLBShowFPS"));
menu->createJumpKeys();
}

View File

@@ -309,6 +309,13 @@ public:
U32 ypos = 64;
const U32 y_inc = 20;
static const LLCachedControl<bool> slb_show_fps("SLBShowFPS");
if (slb_show_fps)
{
addText(xpos+280, ypos+5, llformat("FPS %3.1f", LLViewerStats::getInstance()->mFPSStat.getMeanPerSec()));
ypos += y_inc;
}
static const LLCachedControl<bool> debug_show_time("DebugShowTime");
if (debug_show_time)
{

View File

@@ -2530,7 +2530,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
!(attached_object->mDrawable->getSpatialBridge() &&
attached_object->mDrawable->getSpatialBridge()->getRadius() < 2.0));
if (visibleAttachment && attached_object && !attached_object->isDead() && attachment->getValid())
if (visibleAttachment && attached_object && attached_object->mDrawable && !attached_object->isDead() && attachment->getValid())
{
// if selecting any attachments, update all of them as non-damped
if (LLSelectMgr::getInstance()->getSelection()->getObjectCount() && LLSelectMgr::getInstance()->getSelection()->isAttachment())

View File

@@ -49,6 +49,7 @@
#include "llagentcamera.h"
#include "lldrawable.h"
#include "llface.h"
#include "llselectmgr.h"
#include "llviewercamera.h"
#include "llviewertexturelist.h"
#include "llviewerobjectlist.h"
@@ -57,6 +58,7 @@
#include "noise.h"
#include "pipeline.h"
#include "llspatialpartition.h"
//#include "llviewerwindow.h"
#include "llnotificationsutil.h"
#include "raytrace.h"
#include "llglslshader.h"
@@ -356,12 +358,47 @@ U32 LLVOTree::processUpdateMessage(LLMessageSystem *mesgsys,
void LLVOTree::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
{
const U16 FRAMES_PER_WIND_UPDATE = 20; // How many frames between wind update per tree
const F32 TREE_WIND_SENSITIVITY = 0.005f;
const F32 TREE_TRUNK_STIFFNESS = 0.1f;
if (mDead || !(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_TREE)))
{
return;
}
S32 trunk_LOD = sMAX_NUM_TREE_LOD_LEVELS ;
static LLCachedControl<bool> sRenderAnimateTrees(gSavedSettings, "RenderAnimateTrees");
if (sRenderAnimateTrees)
{
F32 mass_inv;
// For all tree objects, update the trunk bending with the current wind
// Walk sprite list in order away from viewer
if (!(mFrameCount % FRAMES_PER_WIND_UPDATE))
{
// If needed, Get latest wind for this tree
mWind = mRegionp->mWind.getVelocity(getPositionRegion());
}
mFrameCount++;
mass_inv = 1.f/(5.f + mDepth*mBranches*0.2f);
mTrunkVel += (mWind * mass_inv * TREE_WIND_SENSITIVITY); // Pull in direction of wind
mTrunkVel -= (mTrunkBend * mass_inv * TREE_TRUNK_STIFFNESS); // Restoring force in direction of trunk
mTrunkBend += mTrunkVel;
mTrunkVel *= 0.99f; // Add damping
if (mTrunkBend.length() > 1.f)
{
mTrunkBend.normalize();
}
if (mTrunkVel.length() > 1.f)
{
mTrunkVel.normalize();
}
}
S32 trunk_LOD = sMAX_NUM_TREE_LOD_LEVELS;
F32 app_angle = getAppAngle()*LLVOTree::sTreeFactor;
for (S32 j = 0; j < sMAX_NUM_TREE_LOD_LEVELS; j++)
@@ -373,41 +410,45 @@ void LLVOTree::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
}
}
if (mReferenceBuffer.isNull())
if (!sRenderAnimateTrees)
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE);
}
else if (trunk_LOD != mTrunkLOD)
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, FALSE);
}
else
{
// we're not animating but we may *still* need to
// regenerate the mesh if we moved, since position
// and rotation are baked into the mesh.
// *TODO: I don't know what's so special about trees
// that they don't get REBUILD_POSITION automatically
// at a higher level.
const LLVector3 &this_position = getPositionRegion();
if (this_position != mLastPosition)
if (mReferenceBuffer.isNull())
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION);
mLastPosition = this_position;
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE);
}
else if (trunk_LOD != mTrunkLOD)
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, FALSE);
}
else
{
const LLQuaternion &this_rotation = getRotation();
if (this_rotation != mLastRotation)
// we're not animating but we may *still* need to
// regenerate the mesh if we moved, since position
// and rotation are baked into the mesh.
// *TODO: I don't know what's so special about trees
// that they don't get REBUILD_POSITION automatically
// at a higher level.
const LLVector3 &this_position = getPositionRegion();
if (this_position != mLastPosition)
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION);
mLastRotation = this_rotation;
mLastPosition = this_position;
}
else
{
const LLQuaternion &this_rotation = getRotation();
if (this_rotation != mLastRotation)
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION);
mLastRotation = this_rotation;
}
}
}
}
mTrunkLOD = trunk_LOD;
//return TRUE;
}
const F32 TREE_BLEND_MIN = 1.f;
@@ -540,8 +581,9 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
max_indices += sLODIndexCount[lod];
max_vertices += sLODVertexCount[lod];
}
mReferenceBuffer = new LLVertexBuffer(LLDrawPoolTree::VERTEX_DATA_MASK, 0);
static LLCachedControl<bool> sRenderAnimateTrees(gSavedSettings, "RenderAnimateTrees");
mReferenceBuffer = new LLVertexBuffer(LLDrawPoolTree::VERTEX_DATA_MASK, sRenderAnimateTrees ? GL_STATIC_DRAW_ARB : 0);
mReferenceBuffer->allocateBuffer(max_vertices, max_indices, TRUE);
LLStrider<LLVector3> vertices;
@@ -844,10 +886,18 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
llassert(vertex_count == max_vertices);
llassert(index_count == max_indices);
}
//generate tree mesh
updateMesh();
static LLCachedControl<bool> sRenderAnimateTrees(gSavedSettings, "RenderAnimateTrees");
if (sRenderAnimateTrees)
{
mDrawable->getFace(0)->setVertexBuffer(mReferenceBuffer);
}
else
{
//generate tree mesh
updateMesh();
}
return TRUE;
}
@@ -1314,3 +1364,110 @@ LLTreePartition::LLTreePartition()
mLODPeriod = 1;
}
void LLVOTree::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
std::vector<LLVector3> &normals,
const LLVector3& obj_cam_vec,
const LLMatrix4& local_matrix,
const LLMatrix3& normal_matrix)
{
vertices.clear();
normals.clear();
F32 height = mBillboardScale; // *mBillboardRatio * 0.5;
F32 width = height * mTrunkAspect;
LLVector3 position1 = LLVector3(-width * 0.5, 0, 0) * local_matrix;
LLVector3 position2 = LLVector3(-width * 0.5, 0, height) * local_matrix;
LLVector3 position3 = LLVector3(width * 0.5, 0, height) * local_matrix;
LLVector3 position4 = LLVector3(width * 0.5, 0, 0) * local_matrix;
LLVector3 position5 = LLVector3(0, -width * 0.5, 0) * local_matrix;
LLVector3 position6 = LLVector3(0, -width * 0.5, height) * local_matrix;
LLVector3 position7 = LLVector3(0, width * 0.5, height) * local_matrix;
LLVector3 position8 = LLVector3(0, width * 0.5, 0) * local_matrix;
LLVector3 normal = (position1 - position2) % (position2 - position3);
normal.normalize();
vertices.push_back(position1);
normals.push_back(normal);
vertices.push_back(position2);
normals.push_back(normal);
vertices.push_back(position2);
normals.push_back(normal);
vertices.push_back(position3);
normals.push_back(normal);
vertices.push_back(position3);
normals.push_back(normal);
vertices.push_back(position4);
normals.push_back(normal);
vertices.push_back(position4);
normals.push_back(normal);
vertices.push_back(position1);
normals.push_back(normal);
normal = (position5 - position6) % (position6 - position7);
normal.normalize();
vertices.push_back(position5);
normals.push_back(normal);
vertices.push_back(position6);
normals.push_back(normal);
vertices.push_back(position6);
normals.push_back(normal);
vertices.push_back(position7);
normals.push_back(normal);
vertices.push_back(position7);
normals.push_back(normal);
vertices.push_back(position8);
normals.push_back(normal);
vertices.push_back(position8);
normals.push_back(normal);
vertices.push_back(position5);
normals.push_back(normal);
}
void LLVOTree::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_point)
{
LLVector3 position;
LLQuaternion rotation;
if (mDrawable->isActive())
{
if (mDrawable->isSpatialRoot())
{
position = LLVector3();
rotation = LLQuaternion();
}
else
{
position = mDrawable->getPosition();
rotation = mDrawable->getRotation();
}
}
else
{
position = getPosition() + getRegion()->getOriginAgent();
rotation = getRotation();
}
// trees have bizzare scaling rules... because it's cool to make needless exceptions
// PS: the trees are the last remaining tidbit of Philip's code. take a look sometime.
F32 radius = getScale().length() * 0.05f;
LLVector3 scale = LLVector3(1, 1, 1) * radius;
// compose final matrix
LLMatrix4 local_matrix;
local_matrix.initAll(scale, rotation, position);
generateSilhouetteVertices(nodep->mSilhouetteVertices, nodep->mSilhouetteNormals,
LLVector3(0, 0, 0), local_matrix, LLMatrix3());
nodep->mSilhouetteExists = TRUE;
}

View File

@@ -39,6 +39,7 @@
class LLFace;
class LLDrawPool;
class LLSelectNode;
class LLViewerFetchedTexture;
class LLVOTree : public LLViewerObject
@@ -122,8 +123,9 @@ public:
LLVector3* 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
);
LLVector3* bi_normal = NULL); // return the surface bi-normal at the intersection point
void generateSilhouette(LLSelectNode* nodep, const LLVector3& view_point);
static S32 sMaxTreeSpecies;
@@ -162,6 +164,7 @@ public:
friend class LLDrawPoolTree;
protected:
LLVector3 mTrunkBend; // Accumulated wind (used for blowing trees)
LLVector3 mTrunkVel; //
LLVector3 mWind;
LLPointer<LLVertexBuffer> mReferenceBuffer; //reference geometry for generating tree mesh
@@ -201,6 +204,13 @@ protected:
static S32 sLODVertexCount[4];
static S32 sLODSlices[4];
static F32 sLODAngles[4];
private:
void generateSilhouetteVertices(std::vector<LLVector3> &vertices,
std::vector<LLVector3> &normals,
const LLVector3& view_vec,
const LLMatrix4& mat,
const LLMatrix3& norm_mat);
};
#endif

View File

@@ -89,7 +89,7 @@
<text bottom_delta="-25" height="12" left="215" name="MeshDetailText">Level of Detail:</text>
<slider bottom_delta="-22" control_name="RenderVolumeLODFactor" height="16" increment="0.09375" label=" Objects:" label_width="79" max_val="2" min_val="0.5" name="ObjectMeshDetail" show_text="false" width="223"/>
<slider bottom_delta="-18" control_name="RenderFlexTimeFactor" height="16" increment="0.1" label=" Flexiprims:" label_width="79" max_val="1" min_val="0" name="FlexibleMeshDetail" show_text="false" width="223"/>
<slider bottom_delta="-18" control_name="RenderTreeLODFactor" height="16" increment="0.125" label=" Trees:" label_width="79" max_val="1" min_val="0" name="TreeMeshDetail" show_text="false" width="223"/>
<slider bottom_delta="-18" control_name="RenderTreeLODFactor" height="16" increment="0.125" label=" Trees:" label_width="79" max_val="2" min_val="0" name="TreeMeshDetail" show_text="false" width="223"/>
<slider bottom_delta="-18" control_name="RenderAvatarLODFactor" height="16" increment="0.125" label=" Avatars:" label_width="79" max_val="1" min_val="0" name="AvatarMeshDetail" show_text="false" width="223"/>
<slider bottom_delta="-18" control_name="RenderTerrainLODFactor" height="16" increment="0.125" label=" Terrain:" label_width="79" max_val="2" min_val="1" name="TerrainMeshDetail" show_text="false" width="223"/>
<slider bottom_delta="-18" control_name="WLSkyDetail" height="16" decimal_digits="0" increment="8" label=" Sky:" label_width="79" max_val="128" min_val="16" name="SkyMeshDetail" show_text="false" width="223"/>