Automated merge from mesh-development

meow-7.2.2
Loren Shih 2010-12-22 12:49:54 -05:00
commit 8de11e98cc
11 changed files with 1009 additions and 920 deletions

View File

@ -27,6 +27,7 @@
#include "linden_common.h"
#include "llmodel.h"
#include "llconvexdecomposition.h"
#include "llsdserialize.h"
#include "llvector4a.h"
@ -57,7 +58,15 @@ const int MODEL_NAMES_LENGTH = sizeof(model_names) / sizeof(std::string);
LLModel::LLModel(LLVolumeParams& params, F32 detail)
: LLVolume(params, detail), mNormalizedScale(1,1,1), mNormalizedTranslation(0,0,0)
{
mDecompID = -1;
}
LLModel::~LLModel()
{
if (mDecompID >= 0)
{
LLConvexDecomposition::getInstance()->deleteDecomposition(mDecompID);
}
}
void load_face_from_dom_inputs(LLVolumeFace& face, const domInputLocalOffset_Array& inputs, U32 min_idx, U32 max_idx)
@ -941,11 +950,10 @@ void LLModel::normalizeVolumeFaces()
LLVector4a size;
size.setSub(max, min);
// To make the model fit within
// the unit cube with only the largest
// dimensions fitting on the surface of the cube,
// calculate the largest extent on any axis
F32 scale = 1.f/llmax(llmax(size[0], size[1]), size[2]);
// Compute scale as reciprocal of size
LLVector4a scale;
scale.splat(1.f);
scale.div(size);
for (U32 i = 0; i < mVolumeFaces.size(); ++i)
{
@ -974,7 +982,10 @@ void LLModel::normalizeVolumeFaces()
// we would need to multiply the model
// by to get the original size of the
// model instead of the normalized size.
mNormalizedScale = LLVector3(1,1,1) / scale;
LLVector4a normalized_scale;
normalized_scale.splat(1.f);
normalized_scale.div(scale);
mNormalizedScale.set(normalized_scale.getF32ptr());
mNormalizedTranslation.set(trans.getF32ptr());
mNormalizedTranslation *= -1.f;
}

View File

@ -56,6 +56,8 @@ public:
typedef std::vector<LLVector3> hull;
LLModel(LLVolumeParams& params, F32 detail);
~LLModel();
static LLSD writeModel(
std::string filename,
LLModel* physics,
@ -193,6 +195,7 @@ public:
LLVector3 mNormalizedTranslation;
// convex hull decomposition
S32 mDecompID;
convex_hull_decomposition mConvexHullDecomp;
void setConvexHullDecomposition(
const convex_hull_decomposition& decomp);

File diff suppressed because it is too large Load Diff

View File

@ -201,6 +201,8 @@ protected:
void initDecompControls();
void setStatusMessage(const std::string& msg);
LLModelPreview* mModelPreview;
LLPhysicsDecomp::decomp_params mDecompParams;
@ -211,8 +213,9 @@ protected:
U32 mGLName;
static S32 sUploadAmount;
LLPointer<DecompRequest> mCurRequest;
std::set<LLPointer<DecompRequest> > mCurRequest;
std::string mStatusMessage;
std::map<std::string, bool> mViewOption;
//use "disabled" as false by default
@ -220,7 +223,7 @@ protected:
LLMenuButton* mViewOptionMenuButton;
LLToggleableMenu* mViewOptionMenu;
LLMutex* mStatusLock;
};
class LLMeshFilePicker : public LLFilePickerThread

View File

@ -36,6 +36,8 @@
#include "llfloatermodelpreview.h"
#include "llfloaterreg.h"
#include "llslider.h"
#include "lltoolmgr.h"
#include "llviewerwindow.h"
static const std::string stateNames[]={
@ -125,6 +127,107 @@ bool LLFloaterModelWizard::onEnableBack()
return true;
}
//-----------------------------------------------------------------------------
// handleMouseDown()
//-----------------------------------------------------------------------------
BOOL LLFloaterModelWizard::handleMouseDown(S32 x, S32 y, MASK mask)
{
if (mPreviewRect.pointInRect(x, y))
{
bringToFront( x, y );
gFocusMgr.setMouseCapture(this);
gViewerWindow->hideCursor();
mLastMouseX = x;
mLastMouseY = y;
return TRUE;
}
return LLFloater::handleMouseDown(x, y, mask);
}
//-----------------------------------------------------------------------------
// handleMouseUp()
//-----------------------------------------------------------------------------
BOOL LLFloaterModelWizard::handleMouseUp(S32 x, S32 y, MASK mask)
{
gFocusMgr.setMouseCapture(FALSE);
gViewerWindow->showCursor();
return LLFloater::handleMouseUp(x, y, mask);
}
//-----------------------------------------------------------------------------
// handleHover()
//-----------------------------------------------------------------------------
BOOL LLFloaterModelWizard::handleHover (S32 x, S32 y, MASK mask)
{
MASK local_mask = mask & ~MASK_ALT;
if (mModelPreview && hasMouseCapture())
{
if (local_mask == MASK_PAN)
{
// pan here
mModelPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f);
}
else if (local_mask == MASK_ORBIT)
{
F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f;
F32 pitch_radians = (F32)(y - mLastMouseY) * 0.02f;
mModelPreview->rotate(yaw_radians, pitch_radians);
}
else
{
F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f;
F32 zoom_amt = (F32)(y - mLastMouseY) * 0.02f;
mModelPreview->rotate(yaw_radians, 0.f);
mModelPreview->zoom(zoom_amt);
}
mModelPreview->refresh();
LLUI::setMousePositionLocal(this, mLastMouseX, mLastMouseY);
}
if (!mPreviewRect.pointInRect(x, y) || !mModelPreview)
{
return LLFloater::handleHover(x, y, mask);
}
else if (local_mask == MASK_ORBIT)
{
gViewerWindow->setCursor(UI_CURSOR_TOOLCAMERA);
}
else if (local_mask == MASK_PAN)
{
gViewerWindow->setCursor(UI_CURSOR_TOOLPAN);
}
else
{
gViewerWindow->setCursor(UI_CURSOR_TOOLZOOMIN);
}
return TRUE;
}
//-----------------------------------------------------------------------------
// handleScrollWheel()
//-----------------------------------------------------------------------------
BOOL LLFloaterModelWizard::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
if (mPreviewRect.pointInRect(x, y) && mModelPreview)
{
mModelPreview->zoom((F32)clicks * -0.2f);
mModelPreview->refresh();
}
return TRUE;
}
BOOL LLFloaterModelWizard::postBuild()
{
LLView* preview_panel = getChild<LLView>("preview_panel");

View File

@ -36,6 +36,11 @@ public:
/*virtual*/ BOOL postBuild();
void draw();
BOOL handleMouseDown(S32 x, S32 y, MASK mask);
BOOL handleMouseUp(S32 x, S32 y, MASK mask);
BOOL handleHover(S32 x, S32 y, MASK mask);
BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
private:
enum EWizardState
{
@ -62,6 +67,8 @@ private:
LLRect mPreviewRect;
int mState;
S32 mLastMouseX;
S32 mLastMouseY;
};

View File

@ -1396,6 +1396,7 @@ LLMeshUploadThread::DecompRequest::DecompRequest(LLModel* mdl, LLModel* base_mod
{
mStage = "single_hull";
mModel = mdl;
mDecompID = &mdl->mDecompID;
mBaseModel = base_model;
mThread = thread;
@ -2262,6 +2263,9 @@ void LLMeshRepository::notifyLoadedMeshes()
mInventoryQ.pop();
}
}
//call completed callbacks on finished decompositions
mDecompThread->notifyCompleted();
if (!mThread->mWaiting)
{ //curl thread is churning, wait for it to go idle
@ -3229,9 +3233,8 @@ void LLPhysicsDecomp::doDecomposition()
mCurRequest->mHullMesh.clear();
mCurRequest->setStatusMessage("FAIL");
mCurRequest->completed();
mCurRequest = NULL;
completeCurrent();
}
else
{
@ -3282,13 +3285,33 @@ void LLPhysicsDecomp::doDecomposition()
LLMutexLock lock(mMutex);
mCurRequest->setStatusMessage("FAIL");
mCurRequest->completed();
mCurRequest = NULL;
completeCurrent();
}
}
}
void LLPhysicsDecomp::completeCurrent()
{
LLMutexLock lock(mMutex);
mCompletedQ.push(mCurRequest);
mCurRequest = NULL;
}
void LLPhysicsDecomp::notifyCompleted()
{
if (!mCompletedQ.empty())
{
LLMutexLock lock(mMutex);
while (!mCompletedQ.empty())
{
Request* req = mCompletedQ.front();
req->completed();
mCompletedQ.pop();
}
}
}
void make_box(LLPhysicsDecomp::Request * request)
{
LLVector3 min,max;
@ -3406,18 +3429,17 @@ void LLPhysicsDecomp::doDecompositionSingleHull()
{
LLMutexLock lock(mMutex);
mCurRequest->completed();
mCurRequest = NULL;
completeCurrent();
}
}
void LLPhysicsDecomp::run()
{
LLConvexDecomposition::getInstance()->initThread();
mInited = true;
LLConvexDecomposition* decomp = LLConvexDecomposition::getInstance();
decomp->initThread();
mInited = true;
static const LLCDStageData* stages = NULL;
static S32 num_stages = 0;
@ -3443,6 +3465,13 @@ void LLPhysicsDecomp::run()
mRequestQ.pop();
}
S32& id = *(mCurRequest->mDecompID);
if (id == -1)
{
decomp->genDecomposition(id);
}
decomp->bindDecomposition(id);
if (mCurRequest->mStage == "single_hull")
{
doDecompositionSingleHull();
@ -3454,7 +3483,7 @@ void LLPhysicsDecomp::run()
}
}
LLConvexDecomposition::getInstance()->quitThread();
decomp->quitThread();
//delete mSignal;
delete mMutex;

View File

@ -157,6 +157,7 @@ public:
{
public:
//input params
S32* mDecompID;
std::string mStage;
std::vector<LLVector3> mPositions;
std::vector<U16> mIndices;
@ -167,8 +168,12 @@ public:
std::vector<LLPointer<LLVertexBuffer> > mHullMesh;
LLModel::convex_hull_decomposition mHull;
//status message callback, called from decomposition thread
virtual S32 statusCallback(const char* status, S32 p1, S32 p2) = 0;
//completed callback, called from the main thread
virtual void completed() = 0;
virtual void setStatusMessage(const std::string& msg);
};
@ -193,6 +198,9 @@ public:
void doDecompositionSingleHull();
virtual void run();
void completeCurrent();
void notifyCompleted();
std::map<std::string, S32> mStageID;
@ -201,6 +209,8 @@ public:
LLPointer<Request> mCurRequest;
std::queue<LLPointer<Request> > mCompletedQ;
};
class LLMeshRepoThread : public LLThread

View File

@ -64,7 +64,7 @@
<text bottom_delta="25" left="25" width="100" follows="bottom|left">Upload Details</text>
<panel top_pad="5" border="true" left="15" width="290" height="70" follows="bottom|left"
bevel_style="in" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text left="25" follows="bottom|left" width="140" height="15" name="streaming cost">
Resource Cost: [COST]
</text>
@ -222,30 +222,25 @@
label="Physics"
name="physics_panel">
<!-- PHYSICS STEP ONE-->
<!-- PHYSICS GEOMETRY-->
<panel
follows="top|left"
name="physics step 1"
name="physics geometry"
left="0"
top="0"
width="260"
height="450"
visible="true">
width="300"
height="80"
visible="true"
border="true"
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text follows="left|top" bottom="40" height="30" left="10" font="SansSerifBig">
Step 1: Geometry
</text>
<radio_group follows="top|left" top_pad="5" width="240" height="70" name="physics_load_radio" value="physics_load_from_file">
<radio_item bottom="50" name="physics_load_from_file" label="Load from file"/>
<radio_item bottom="0" name="physics_use_lod" label="Use Level of Detail"/>
<radio_group follows="top|left" top="10" width="240" height="40" name="physics_load_radio" value="physics_load_from_file">
<radio_item bottom="0" name="physics_load_from_file" label="File:"/>
<radio_item bottom="23" name="physics_use_lod" label="Use Level of Detail:"/>
</radio_group>
<line_editor follows="left|top" bottom_delta="-25" width="140" left="30" value="" name="physics_file" height="20"/>
<button bottom_delta="3" name="physics_browse" label="Browse..." left_pad="5" follows="left|top" width="70" height="25"/>
<combo_box left="30" bottom_delta="40" follows="left|top" height="18"
name="physics_lod_combo" width="90" tool_tip="LOD to use for physics shape">
<combo_box left="180" top="10" follows="left|top" height="18"
name="physics_lod_combo" width="110" tool_tip="LOD to use for physics shape">
<combo_item name="physics_lowest">
Lowest
</combo_item>
@ -260,120 +255,103 @@
</combo_item>
</combo_box>
<line_editor follows="left|top" top_pad="5" width="140" left="60" value="" name="physics_file" height="20"/>
<button left_pad="10" name="physics_browse" label="Browse..." follows="left|top" width="70" height="20"/>
<!--
<text follows="top|left" name="physics_triangles" top_pad="15" height="15" left="10">
Triangles: [TRIANGLES]
</text>
<text follows="top|left" name="physics_hulls" top_pad="5" height="15">
Hulls: [HULLS]
</text>
<text follows="top|left" name="physics_points" top_pad="5" height="15">
Points: [POINTS]
</text>
<text follows="top|left" left="140" width="100" bottom_delta="-40" height="15">
Layer:
</text>
<combo_box name="physics_layer" follows="top|left" width="100" height="20" top_pad="5"/>
-->
<button bottom="440" left="180" width="80" follows="bottom|right" label="Optimize" name="physics_optimize" height="20"/>
</panel>
<check_box name="physics_optimize" follows="left|top" width="130" left="10" top_pad="5" height="20" label="Optimize"/>
<check_box name="physics_use_hull" follows="left|top" width="130" left_pad="5" height="20" label="Use Convex Hull"/>
-->
</panel>
<!-- PHYSICS STEP 2-->
<!-- PHYSICS ANALYSIS-->
<panel
follows="top|left"
name="physics step 2"
name="physics analysis"
top_pad="0"
left="0"
top="0"
width="260"
height="450"
visible="false">
width="300"
height="130"
visible="true"
border="true"
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text follows="left|top" bottom="40" height="30" left="10" font="SansSerifBig">
Step 2: Decompose
Step 1: Analysis
</text>
<text top_pad="100" follows="top|left" height="15">
Decompose Method:
<text top_pad="5" width="50" follows="top|left" height="15">
Method:
</text>
<combo_box name="Method" follows="top|left" top_pad="5" height="20" width="100"/>
<text top_pad="10" follows="top|left" height="15">
<combo_box name="Method" follows="top|left" left_pad="5" bottom_delta="2" height="20" width="80"/>
<text left="160" bottom_delta="-2" width="50" follows="top|left" height="15">
Quality:
</text>
<combo_box name="Decompose Quality" follows="top|left" top_pad="5" height="20" width="100"/>
<combo_box name="Decompose Quality" bottom_delta="2" follows="top|left" left_pad="5" height="20" width="80"/>
<slider name="Smooth" left="10" width="280" follows="top|left" top_pad="10" height="20" label="Smooth:"/>
<check_box name="Simplify Coplanar" follows="top|left" top_pad="10" height="15" label="Simplify Coplaner"/>
<check_box name="Close Holes (Slow)" follows="top|left" top_pad="10" height="15" label="Close Holes (slow)"/>
<slider name="Cosine%" width="240" follows="top|left" top_pad="10" height="20" label="Cosine %"/>
<text follows="top|left" top_pad="20" height="30" width="260">
"Note: Only models that have been Decomposed"
"can be made Physical or used as Vehicles."
</text>
<button bottom="440" left="90" width="80" follows="bottom|right" label="&lt;&lt; Back" name="decompose_back" height="20"/>
<button left_pad="5" width="90" follows="bottom|right" label="Decompose" name="Decompose" height="20"/>
<button left="200" bottom_delta="0" width="90" follows="top|left" label="Analyze" name="Decompose" height="20"/>
</panel>
<!-- PHYSICS STEP 3 -->
<panel
<!-- PHYSICS SIMPLIFICATION -->
<panel
follows="top|left"
name="physics step 3"
name="physics simplification"
left="0"
top="0"
width="260"
height="450"
visible="false">
top_pad="0"
width="300"
height="150"
visible="true"
border="true"
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text follows="left|top" bottom="40" height="30" left="10" font="SansSerifBig">
Step 3: Simplify
Step 2: Simplification
</text>
<text left="10" top_pad="100" height="15" width="240" follows="top|left">
Simplify Method:
<text left="10" top_pad="5" height="15" width="140" follows="top|left">
Method:
</text>
<combo_box top_pad="5" height="20" width="100" follows="top|left" name="Simplify Method"/>
<combo_box left_pad="5" height="20" width="120" follows="top|left" name="Simplify Method"/>
<slider name="Combine Quality" label="Combine Quality:" label_width="100" width="260" follows="top|left" top_pad="10" height="20"/>
<slider name="Detail Scale" label="Detail Scale:" label_width="100" width="260" follows="top|left" top_pad="10" height="20"/>
<slider name="Retain%" label="Retain %:" label_width="100" width="260" follows="top|left" top_pad="10" height="20"/>
<button bottom="440" left="90" width="80" follows="bottom|right" label="&lt;&lt; Back" name="simplify_back" height="20"/>
<button left_pad="5" width="90" follows="bottom|right" label="Simplify" name="Simplify" height="20"/>
<slider left="10" name="Combine Quality" label="Passes:" label_width="120" width="270" follows="top|left" top_pad="10" height="20"/>
<slider name="Detail Scale" label="Detail Scale:" label_width="120" width="270" follows="top|left" top_pad="10" height="20"/>
<slider name="Retain%" label="Retain:" label_width="120" width="270" follows="top|left" bottom_delta="0" left_delta="0" visible="false" height="20"/>
<button left="190" width="90" follows="top|left" label="Simplify" name="Simplify" height="20"/>
</panel>
<!-- INFO PANEL -->
<panel
left="0"
top="35"
width="260"
top_pad="0"
width="300"
height="100"
follows="left|top"
name="physics info"
visible="false">
visible="true"
border="true"
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text follows="top|left" name="physics_triangles" top_pad="15" height="15" left="10">
Triangles: [TRIANGLES]
</text>
<text follows="top|left" name="physics_hulls" top_pad="5" height="15">
Hulls: [HULLS]
<slider name="physics_explode" follows="top|left" top="10" left="10" label="Preview Spread:" min_val="0.0" max_val="3.0" height="20" width="280"/>
<text follows="top|left" name="physics_triangles" top_pad="10" height="15" left="10">
Triangles: [TRIANGLES]
</text>
<text follows="top|left" name="physics_points" top_pad="5" height="15">
Points: [POINTS]
Vertices: [POINTS]
</text>
<text follows="top|left" name="physics_hulls" top_pad="5" height="15">
Hulls: [HULLS]
</text>
<text follows="top|left" left="140" width="100" bottom_delta="-40" height="15">
Layer:
</text>
<combo_box name="physics_layer" follows="top|left" width="100" height="20" top_pad="5"/>
<slider name="physics_explode" follows="top|left" top_pad="25" left="10" label="Explode" min_val="0.0" max_val="3.0" height="20" width="240"/>
</panel>
</panel>

View File

@ -208,23 +208,8 @@
left="10"
word_wrap="true">
Note:
Advanced users familiar with 3d content creation tools may prefer to use the Advanced Mesh Import window.
Advanced users familiar with 3d content creation tools may prefer to use the Advanced Mesh Import window.
</text>
<combo_box left_pad="0" top_delta="0" follows="left|top" list_position="below" height="18"
name="preview_lod_combo_2" width="90" tool_tip="LOD to view in preview render">
<combo_item name="high">
High
</combo_item>
<combo_item name="medium">
Medium
</combo_item>
<combo_item name="lowest">
Lowest
</combo_item>
<combo_item name="low">
Low
</combo_item>
</combo_box>
</panel>
</panel>
@ -390,7 +375,7 @@
layout="topleft"
left="220"
max_val="2"
initial_vauel="1"
initial_value="1"
min_val="0"
name="accuracy_slider"
show_text="false"

View File

@ -1058,23 +1058,23 @@ anguage Infrstructure (CLI) international standard</string>
<key>windows</key>
<map>
<key>md5sum</key>
<string>50fb24b9ad5baf16cbd7b7bf8a607010</string>
<string>5ae8bab01189c5dbbc6f383c751e031a</string>
<key>url</key>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.3-windows-20101015a.tar.bz2</uri>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.3-windows-20101222.tar.bz2</uri>
</map>
<key>linux</key>
<map>
<key>md5sum</key>
<string>6711cd0dbade656b468f895843fc3709</string>
<string>f63424076d4fadd133950af0cf9c3564</string>
<key>url</key>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.2-linux-20100928.tar.bz2</uri>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.3-linux-20101222.tar.bz2</uri>
</map>
<key>darwin</key>
<map>
<key>md5sum</key>
<string>a6969a966e83ac3f0dc652df3e499797</string>
<string>47ef880db4aea1a9561194c54fc28433</string>
<key>url</key>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-darwin-20100914.tar.bz2</uri>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.3-darwin-20101222.tar.bz2</uri>
</map>
</map>
</map>