Skip to content

Commit

Permalink
llprimitive merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyotl committed Apr 9, 2016
1 parent 691a539 commit d40256f
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 30 deletions.
4 changes: 4 additions & 0 deletions indra/llmath/llvolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ const U8 LL_SCULPT_TYPE_MESH = 5;
const U8 LL_SCULPT_TYPE_MASK = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE |
LL_SCULPT_TYPE_CYLINDER | LL_SCULPT_TYPE_MESH;

// for value checks, assign new value after adding new types
const U8 LL_SCULPT_TYPE_MAX = LL_SCULPT_TYPE_MESH;

const U8 LL_SCULPT_FLAG_INVERT = 64;
const U8 LL_SCULPT_FLAG_MIRROR = 128;
const U8 LL_SCULPT_FLAG_MASK = LL_SCULPT_FLAG_INVERT | LL_SCULPT_FLAG_MIRROR;

const S32 LL_SCULPT_MESH_MAX_FACES = 8;

Expand Down
5 changes: 1 addition & 4 deletions indra/llprimitive/llmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1539,10 +1539,7 @@ LLModel* LLModel::loadModelFromDomMesh(domMesh *mesh)

std::string LLModel::getName() const
{
if (!mRequestedLabel.empty())
return mRequestedLabel;
else
return mLabel;
return mRequestedLabel.empty() ? mLabel : mRequestedLabel;
}

//static
Expand Down
56 changes: 40 additions & 16 deletions indra/llprimitive/llprimitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "llprimtexturelist.h"
#include "imageids.h"
#include "llmaterialid.h"
#include "llvolume.h"

/**
* exported constants
Expand Down Expand Up @@ -321,6 +322,11 @@ S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMateri
return mTextureList.setMaterialParams(index, pMaterialParams);
}

LLMaterialPtr LLPrimitive::getTEMaterialParams(const U8 index)
{
return mTextureList.getMaterialParams(index);
}

//===============================================================
S32 LLPrimitive::setTEBumpShinyFullbright(const U8 index, const U8 bump)
{
Expand Down Expand Up @@ -987,8 +993,6 @@ BOOL LLPrimitive::setMaterial(U8 material)
}
}

const F32 LL_MAX_SCALE_S = 100.0f;
const F32 LL_MAX_SCALE_T = 100.0f;
S32 LLPrimitive::packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const
{
S32 face_index;
Expand Down Expand Up @@ -1843,9 +1847,12 @@ BOOL LLSculptParams::pack(LLDataPacker &dp) const

BOOL LLSculptParams::unpack(LLDataPacker &dp)
{
dp.unpackUUID(mSculptTexture, "texture");
dp.unpackU8(mSculptType, "type");

U8 type;
LLUUID id;
dp.unpackUUID(id, "texture");
dp.unpackU8(type, "type");

setSculptTexture(id, type);
return TRUE;
}

Expand All @@ -1870,8 +1877,7 @@ bool LLSculptParams::operator==(const LLNetworkData& data) const
void LLSculptParams::copy(const LLNetworkData& data)
{
const LLSculptParams *param = (LLSculptParams*)&data;
mSculptTexture = param->mSculptTexture;
mSculptType = param->mSculptType;
setSculptTexture(param->mSculptTexture, param->mSculptType);
}


Expand All @@ -1889,20 +1895,38 @@ LLSD LLSculptParams::asLLSD() const
bool LLSculptParams::fromLLSD(LLSD& sd)
{
const char *w;
w = "texture";
U8 type;
w = "type";
if (sd.has(w))
{
setSculptTexture( sd[w] );
} else goto fail;
w = "type";
type = sd[w].asInteger();
}
else return false;

w = "texture";
if (sd.has(w))
{
setSculptType( (U8)sd[w].asInteger() );
} else goto fail;

setSculptTexture(sd[w], type);
}
else return false;

return true;
fail:
return false;
}

void LLSculptParams::setSculptTexture(const LLUUID& texture_id, U8 sculpt_type)
{
U8 type = sculpt_type & LL_SCULPT_TYPE_MASK;
U8 flags = sculpt_type & LL_SCULPT_FLAG_MASK;
if (sculpt_type != (type | flags) || type > LL_SCULPT_TYPE_MAX)
{
mSculptTexture.set(SCULPT_DEFAULT_TEXTURE);
mSculptType = LL_SCULPT_TYPE_SPHERE;
}
else
{
mSculptTexture = texture_id;
mSculptType = sculpt_type;
}
}

//============================================================================
Expand Down
5 changes: 3 additions & 2 deletions indra/llprimitive/llprimitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,8 @@ class LLSculptParams : public LLNetworkData
operator LLSD() const { return asLLSD(); }
bool fromLLSD(LLSD& sd);

void setSculptTexture(const LLUUID& id) { mSculptTexture = id; }
void setSculptTexture(const LLUUID& texture_id, U8 sculpt_type);
LLUUID getSculptTexture() const { return mSculptTexture; }
void setSculptType(U8 type) { mSculptType = type; }
U8 getSculptType() const { return mSculptType; }
};

Expand Down Expand Up @@ -389,6 +388,8 @@ class LLPrimitive : public LLXform
virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed
virtual void setTESelected(const U8 te, bool sel);

LLMaterialPtr getTEMaterialParams(const U8 index);

void copyTEs(const LLPrimitive *primitive);
S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const;
S32 unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 data_size, U8 face_count, EMsgVariableType type);
Expand Down
12 changes: 11 additions & 1 deletion indra/llprimitive/llprimtexturelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ S32 LLPrimTextureList::copyTexture(const U8 index, const LLTextureEntry& te)
// we're changing an existing entry
llassert(mEntryList[index]);
delete (mEntryList[index]);
if (&te)
if (te != LLTextureEntry::null)
{
mEntryList[index] = te.newCopy();
}
Expand Down Expand Up @@ -377,6 +377,16 @@ S32 LLPrimTextureList::setMaterialParams(const U8 index, const LLMaterialPtr pMa
return TEM_CHANGE_NONE;
}

LLMaterialPtr LLPrimTextureList::getMaterialParams(const U8 index)
{
if (index < mEntryList.size())
{
return mEntryList[index]->getMaterialParams();
}

return LLMaterialPtr();
}

S32 LLPrimTextureList::size() const
{
return mEntryList.size();
Expand Down
2 changes: 2 additions & 0 deletions indra/llprimitive/llprimtexturelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class LLPrimTextureList
S32 setMaterialID(const U8 index, const LLMaterialID& pMaterialID);
S32 setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams);

LLMaterialPtr getMaterialParams(const U8 index);

S32 size() const;

// void forceResize(S32 new_size);
Expand Down
4 changes: 4 additions & 0 deletions indra/llprimitive/lltextureentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class LLTextureEntry

bool operator==(const LLTextureEntry &rhs) const;
bool operator!=(const LLTextureEntry &rhs) const;

// Added to allow use with std::map
//
bool operator <(const LLTextureEntry &rhs) const;

LLSD asLLSD() const;
void asLLSD(LLSD& sd) const;
Expand Down
8 changes: 4 additions & 4 deletions indra/newview/llpanelobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2141,17 +2141,17 @@ void LLPanelObject::sendSculpt()
return;

LLSculptParams sculpt_params;
LLUUID sculpt_id = LLUUID::null;

if (mCtrlSculptTexture)
sculpt_params.setSculptTexture(mCtrlSculptTexture->getImageAssetID());
sculpt_id = mCtrlSculptTexture->getImageAssetID();

U8 sculpt_type = 0;

if (mCtrlSculptType)
sculpt_type |= mCtrlSculptType->getCurrentIndex();

bool enabled = true;
enabled = sculpt_type != LL_SCULPT_TYPE_MESH;
bool enabled = sculpt_type != LL_SCULPT_TYPE_MESH;

if (mCtrlSculptMirror)
{
Expand All @@ -2168,7 +2168,7 @@ void LLPanelObject::sendSculpt()
if ((mCtrlSculptInvert) && (mCtrlSculptInvert->get()))
sculpt_type |= LL_SCULPT_FLAG_INVERT;

sculpt_params.setSculptType(sculpt_type);
sculpt_params.setSculptTexture(sculpt_id, sculpt_type);
mObject->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt_params, TRUE);
}

Expand Down
3 changes: 1 addition & 2 deletions indra/newview/lltooldraganddrop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,8 +1119,7 @@ void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj,
}

LLSculptParams sculpt_params;
sculpt_params.setSculptTexture(asset_id);
sculpt_params.setSculptType(LL_SCULPT_TYPE_MESH);
sculpt_params.setSculptTexture(asset_id, LL_SCULPT_TYPE_MESH);
hit_obj->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt_params, TRUE);

dialog_refresh_all();
Expand Down
2 changes: 1 addition & 1 deletion indra/newview/llviewerobjectbackup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ void LLObjectBackup::xmlToPrim(LLSD prim_llsd, LLViewerObject* object)
LLUUID t_id = sculpt.getSculptTexture();
if (mAssetMap.count(t_id))
{
sculpt.setSculptTexture(mAssetMap[t_id]);
sculpt.setSculptTexture(mAssetMap[t_id], sculpt.getSculptType());
}

object->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt, true);
Expand Down

0 comments on commit d40256f

Please sign in to comment.