Imported existing code
This commit is contained in:
50
indra/llprimitive/CMakeLists.txt
Normal file
50
indra/llprimitive/CMakeLists.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
project(llprimitive)
|
||||
|
||||
include(00-Common)
|
||||
include(LLCommon)
|
||||
include(LLMath)
|
||||
include(LLMessage)
|
||||
include(LLXML)
|
||||
|
||||
include_directories(
|
||||
${LLCOMMON_INCLUDE_DIRS}
|
||||
${LLMATH_INCLUDE_DIRS}
|
||||
${LLMESSAGE_INCLUDE_DIRS}
|
||||
${LLXML_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(llprimitive_SOURCE_FILES
|
||||
llmaterialtable.cpp
|
||||
llprimitive.cpp
|
||||
lltextureanim.cpp
|
||||
lltextureentry.cpp
|
||||
lltreeparams.cpp
|
||||
llvolumemessage.cpp
|
||||
llvolumexml.cpp
|
||||
)
|
||||
|
||||
set(llprimitive_HEADER_FILES
|
||||
CMakeLists.txt
|
||||
|
||||
legacy_object_types.h
|
||||
llmaterialtable.h
|
||||
llprimitive.h
|
||||
lltextureanim.h
|
||||
lltextureentry.h
|
||||
lltreeparams.h
|
||||
lltree_common.h
|
||||
llvolumemessage.h
|
||||
llvolumexml.h
|
||||
material_codes.h
|
||||
object_flags.h
|
||||
)
|
||||
|
||||
set_source_files_properties(${llprimitive_HEADER_FILES}
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
|
||||
list(APPEND llprimitive_SOURCE_FILES ${llprimitive_HEADER_FILES})
|
||||
|
||||
add_library (llprimitive ${llprimitive_SOURCE_FILES})
|
||||
add_dependencies(llprimitive prepare)
|
||||
83
indra/llprimitive/legacy_object_types.h
Normal file
83
indra/llprimitive/legacy_object_types.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file legacy_object_types.h
|
||||
* @brief Byte codes for basic object and primitive types
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LEGACY_OBJECT_TYPES_H
|
||||
#define LL_LEGACY_OBJECT_TYPES_H
|
||||
|
||||
const S8 PLAYER = 'c';
|
||||
//const S8 BASIC_SHOT = 's';
|
||||
//const S8 BIG_SHOT = 'S';
|
||||
//const S8 TREE_SHOT = 'g';
|
||||
//const S8 PHYSICAL_BALL = 'b';
|
||||
|
||||
const S8 TREE = 'T';
|
||||
const S8 TREE_NEW = 'R';
|
||||
//const S8 SPARK = 'p';
|
||||
//const S8 SMOKE = 'q';
|
||||
//const S8 BOX = 'x';
|
||||
//const S8 CYLINDER = 'y';
|
||||
//const S8 CONE = 'o';
|
||||
//const S8 SPHERE = 'h';
|
||||
//const S8 BIRD = 'r'; // ascii 114
|
||||
//const S8 ATOR = 'a';
|
||||
//const S8 ROCK = 'k';
|
||||
|
||||
const S8 GRASS = 'd';
|
||||
const S8 PART_SYS = 'P';
|
||||
|
||||
//const S8 ORACLE = 'O';
|
||||
//const S8 TEXTBUBBLE = 't'; // Text bubble to show communication
|
||||
//const S8 DEMON = 'M'; // Maxwell's demon for scarfing legacy_object_types.h
|
||||
//const S8 CUBE = 'f';
|
||||
//const S8 LSL_TEST = 'L';
|
||||
//const S8 PRISM = '1';
|
||||
//const S8 PYRAMID = '2';
|
||||
//const S8 TETRAHEDRON = '3';
|
||||
//const S8 HALF_CYLINDER = '4';
|
||||
//const S8 HALF_CONE = '5';
|
||||
//const S8 HALF_SPHERE = '6';
|
||||
|
||||
const S8 PRIMITIVE_VOLUME = 'v';
|
||||
|
||||
// Misc constants
|
||||
|
||||
//const F32 AVATAR_RADIUS = 0.5f;
|
||||
//const F32 SHOT_RADIUS = 0.05f;
|
||||
//const F32 BIG_SHOT_RADIUS = 0.05f;
|
||||
//const F32 TREE_SIZE = 5.f;
|
||||
//const F32 BALL_SIZE = 4.f;
|
||||
|
||||
//const F32 SHOT_VELOCITY = 100.f;
|
||||
//const F32 GRENADE_BLAST_RADIUS = 5.f;
|
||||
|
||||
#endif
|
||||
|
||||
730
indra/llprimitive/llmaterialtable.cpp
Normal file
730
indra/llprimitive/llmaterialtable.cpp
Normal file
@@ -0,0 +1,730 @@
|
||||
/**
|
||||
* @file llmaterialtable.cpp
|
||||
* @brief Table of material names and IDs for viewer
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llmaterialtable.h"
|
||||
#include "llstl.h"
|
||||
#include "material_codes.h"
|
||||
#include "sound_ids.h"
|
||||
#include "imageids.h"
|
||||
|
||||
LLMaterialTable LLMaterialTable::basic(1);
|
||||
|
||||
/*
|
||||
Old Havok 1 constants
|
||||
|
||||
// these are the approximately correct friction values for various materials
|
||||
// however Havok1's friction dynamics are not very correct, so the effective
|
||||
// friction coefficients that result from these numbers are approximately
|
||||
// 25-50% too low, more incorrect for the lower values.
|
||||
F32 const LLMaterialTable::FRICTION_MIN = 0.2f;
|
||||
F32 const LLMaterialTable::FRICTION_GLASS = 0.2f; // borosilicate glass
|
||||
F32 const LLMaterialTable::FRICTION_LIGHT = 0.2f; //
|
||||
F32 const LLMaterialTable::FRICTION_METAL = 0.3f; // steel
|
||||
F32 const LLMaterialTable::FRICTION_PLASTIC = 0.4f; // HDPE
|
||||
F32 const LLMaterialTable::FRICTION_WOOD = 0.6f; // southern pine
|
||||
F32 const LLMaterialTable::FRICTION_FLESH = 0.60f; // saltwater
|
||||
F32 const LLMaterialTable::FRICTION_LAND = 0.78f; // dirt
|
||||
F32 const LLMaterialTable::FRICTION_STONE = 0.8f; // concrete
|
||||
F32 const LLMaterialTable::FRICTION_RUBBER = 0.9f; //
|
||||
F32 const LLMaterialTable::FRICTION_MAX = 0.95f; //
|
||||
*/
|
||||
|
||||
// #if LL_CURRENT_HAVOK_VERSION == LL_HAVOK_VERSION_460
|
||||
// Havok4 has more correct friction dynamics, however here we have to use
|
||||
// the "incorrect" equivalents for the legacy Havok1 behavior
|
||||
F32 const LLMaterialTable::FRICTION_MIN = 0.15f;
|
||||
F32 const LLMaterialTable::FRICTION_GLASS = 0.13f; // borosilicate glass
|
||||
F32 const LLMaterialTable::FRICTION_LIGHT = 0.14f; //
|
||||
F32 const LLMaterialTable::FRICTION_METAL = 0.22f; // steel
|
||||
F32 const LLMaterialTable::FRICTION_PLASTIC = 0.3f; // HDPE
|
||||
F32 const LLMaterialTable::FRICTION_WOOD = 0.44f; // southern pine
|
||||
F32 const LLMaterialTable::FRICTION_FLESH = 0.46f; // saltwater
|
||||
F32 const LLMaterialTable::FRICTION_LAND = 0.58f; // dirt
|
||||
F32 const LLMaterialTable::FRICTION_STONE = 0.6f; // concrete
|
||||
F32 const LLMaterialTable::FRICTION_RUBBER = 0.67f; //
|
||||
F32 const LLMaterialTable::FRICTION_MAX = 0.71f; //
|
||||
// #endif
|
||||
|
||||
F32 const LLMaterialTable::RESTITUTION_MIN = 0.02f;
|
||||
F32 const LLMaterialTable::RESTITUTION_LAND = LLMaterialTable::RESTITUTION_MIN;
|
||||
F32 const LLMaterialTable::RESTITUTION_FLESH = 0.2f; // saltwater
|
||||
F32 const LLMaterialTable::RESTITUTION_STONE = 0.4f; // concrete
|
||||
F32 const LLMaterialTable::RESTITUTION_METAL = 0.4f; // steel
|
||||
F32 const LLMaterialTable::RESTITUTION_WOOD = 0.5f; // southern pine
|
||||
F32 const LLMaterialTable::RESTITUTION_GLASS = 0.7f; // borosilicate glass
|
||||
F32 const LLMaterialTable::RESTITUTION_PLASTIC = 0.7f; // HDPE
|
||||
F32 const LLMaterialTable::RESTITUTION_LIGHT = 0.7f; //
|
||||
F32 const LLMaterialTable::RESTITUTION_RUBBER = 0.9f; //
|
||||
F32 const LLMaterialTable::RESTITUTION_MAX = 0.95f;
|
||||
|
||||
F32 const LLMaterialTable::DEFAULT_FRICTION = 0.5f;
|
||||
F32 const LLMaterialTable::DEFAULT_RESTITUTION = 0.4f;
|
||||
|
||||
LLMaterialTable::LLMaterialTable()
|
||||
{
|
||||
}
|
||||
|
||||
LLMaterialTable::LLMaterialTable(U8 isBasic)
|
||||
{
|
||||
initBasicTable();
|
||||
}
|
||||
|
||||
LLMaterialTable::~LLMaterialTable()
|
||||
{
|
||||
if (mCollisionSoundMatrix)
|
||||
{
|
||||
delete [] mCollisionSoundMatrix;
|
||||
mCollisionSoundMatrix = NULL;
|
||||
}
|
||||
|
||||
if (mSlidingSoundMatrix)
|
||||
{
|
||||
delete [] mSlidingSoundMatrix;
|
||||
mSlidingSoundMatrix = NULL;
|
||||
}
|
||||
|
||||
if (mRollingSoundMatrix)
|
||||
{
|
||||
delete [] mRollingSoundMatrix;
|
||||
mRollingSoundMatrix = NULL;
|
||||
}
|
||||
|
||||
for_each(mMaterialInfoList.begin(), mMaterialInfoList.end(), DeletePointer());
|
||||
mMaterialInfoList.clear();
|
||||
}
|
||||
|
||||
void LLMaterialTable::initBasicTable()
|
||||
{
|
||||
// *TODO: Translate
|
||||
add(LL_MCODE_STONE,std::string("Stone"), LL_DEFAULT_STONE_UUID);
|
||||
add(LL_MCODE_METAL,std::string("Metal"), LL_DEFAULT_METAL_UUID);
|
||||
add(LL_MCODE_GLASS,std::string("Glass"), LL_DEFAULT_GLASS_UUID);
|
||||
add(LL_MCODE_WOOD,std::string("Wood"), LL_DEFAULT_WOOD_UUID);
|
||||
add(LL_MCODE_FLESH,std::string("Flesh"), LL_DEFAULT_FLESH_UUID);
|
||||
add(LL_MCODE_PLASTIC,std::string("Plastic"), LL_DEFAULT_PLASTIC_UUID);
|
||||
add(LL_MCODE_RUBBER,std::string("Rubber"), LL_DEFAULT_RUBBER_UUID);
|
||||
add(LL_MCODE_LIGHT,std::string("Light"), LL_DEFAULT_LIGHT_UUID);
|
||||
|
||||
// specify densities for these materials. . .
|
||||
// these were taken from http://www.mcelwee.net/html/densities_of_various_materials.html
|
||||
|
||||
addDensity(LL_MCODE_STONE,30.f);
|
||||
addDensity(LL_MCODE_METAL,50.f);
|
||||
addDensity(LL_MCODE_GLASS,20.f);
|
||||
addDensity(LL_MCODE_WOOD,10.f);
|
||||
addDensity(LL_MCODE_FLESH,10.f);
|
||||
addDensity(LL_MCODE_PLASTIC,5.f);
|
||||
addDensity(LL_MCODE_RUBBER,0.5f); //
|
||||
addDensity(LL_MCODE_LIGHT,20.f); //
|
||||
|
||||
// add damage and energy values
|
||||
addDamageAndEnergy(LL_MCODE_STONE, 1.f, 1.f, 1.f); // concrete
|
||||
addDamageAndEnergy(LL_MCODE_METAL, 1.f, 1.f, 1.f); // steel
|
||||
addDamageAndEnergy(LL_MCODE_GLASS, 1.f, 1.f, 1.f); // borosilicate glass
|
||||
addDamageAndEnergy(LL_MCODE_WOOD, 1.f, 1.f, 1.f); // southern pine
|
||||
addDamageAndEnergy(LL_MCODE_FLESH, 1.f, 1.f, 1.f); // saltwater
|
||||
addDamageAndEnergy(LL_MCODE_PLASTIC, 1.f, 1.f, 1.f); // HDPE
|
||||
addDamageAndEnergy(LL_MCODE_RUBBER, 1.f, 1.f, 1.f); //
|
||||
addDamageAndEnergy(LL_MCODE_LIGHT, 1.f, 1.f, 1.f); //
|
||||
|
||||
addFriction(LL_MCODE_STONE,0.8f); // concrete
|
||||
addFriction(LL_MCODE_METAL,0.3f); // steel
|
||||
addFriction(LL_MCODE_GLASS,0.2f); // borosilicate glass
|
||||
addFriction(LL_MCODE_WOOD,0.6f); // southern pine
|
||||
addFriction(LL_MCODE_FLESH,0.9f); // saltwater
|
||||
addFriction(LL_MCODE_PLASTIC,0.4f); // HDPE
|
||||
addFriction(LL_MCODE_RUBBER,0.9f); //
|
||||
addFriction(LL_MCODE_LIGHT,0.2f); //
|
||||
|
||||
addRestitution(LL_MCODE_STONE,0.4f); // concrete
|
||||
addRestitution(LL_MCODE_METAL,0.4f); // steel
|
||||
addRestitution(LL_MCODE_GLASS,0.7f); // borosilicate glass
|
||||
addRestitution(LL_MCODE_WOOD,0.5f); // southern pine
|
||||
addRestitution(LL_MCODE_FLESH,0.3f); // saltwater
|
||||
addRestitution(LL_MCODE_PLASTIC,0.7f); // HDPE
|
||||
addRestitution(LL_MCODE_RUBBER,0.9f); //
|
||||
addRestitution(LL_MCODE_LIGHT,0.7f); //
|
||||
|
||||
addShatterSound(LL_MCODE_STONE,LLUUID("ea296329-0f09-4993-af1b-e6784bab1dc9"));
|
||||
addShatterSound(LL_MCODE_METAL,LLUUID("d1375446-1c4d-470b-9135-30132433b678"));
|
||||
addShatterSound(LL_MCODE_GLASS,LLUUID("85cda060-b393-48e6-81c8-2cfdfb275351"));
|
||||
addShatterSound(LL_MCODE_WOOD,LLUUID("6f00669f-15e0-4793-a63e-c03f62fee43a"));
|
||||
addShatterSound(LL_MCODE_FLESH,LLUUID("2d8c6f51-149e-4e23-8413-93a379b42b67"));
|
||||
addShatterSound(LL_MCODE_PLASTIC,LLUUID("d55c7f3c-e1c3-4ddc-9eff-9ef805d9190e"));
|
||||
addShatterSound(LL_MCODE_RUBBER,LLUUID("212b6d1e-8d9c-4986-b3aa-f3c6df8d987d"));
|
||||
addShatterSound(LL_MCODE_LIGHT,LLUUID("d55c7f3c-e1c3-4ddc-9eff-9ef805d9190e"));
|
||||
|
||||
// CollisionSounds
|
||||
mCollisionSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END];
|
||||
if (mCollisionSoundMatrix)
|
||||
{
|
||||
addCollisionSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_STONE_STONE);
|
||||
addCollisionSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_STONE_METAL);
|
||||
addCollisionSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_STONE_GLASS);
|
||||
addCollisionSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_STONE_WOOD);
|
||||
addCollisionSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_STONE_FLESH);
|
||||
addCollisionSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_STONE_PLASTIC);
|
||||
addCollisionSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_STONE_RUBBER);
|
||||
addCollisionSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_STONE_PLASTIC);
|
||||
|
||||
addCollisionSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_METAL_METAL);
|
||||
addCollisionSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_METAL_GLASS);
|
||||
addCollisionSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_METAL_WOOD);
|
||||
addCollisionSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_METAL_FLESH);
|
||||
addCollisionSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_METAL_PLASTIC);
|
||||
addCollisionSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_METAL_PLASTIC);
|
||||
addCollisionSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_METAL_RUBBER);
|
||||
|
||||
addCollisionSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_GLASS_GLASS);
|
||||
addCollisionSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_GLASS_WOOD);
|
||||
addCollisionSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_GLASS_FLESH);
|
||||
addCollisionSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_GLASS_PLASTIC);
|
||||
addCollisionSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_GLASS_RUBBER);
|
||||
addCollisionSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_GLASS_PLASTIC);
|
||||
|
||||
addCollisionSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_WOOD_WOOD);
|
||||
addCollisionSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_WOOD_FLESH);
|
||||
addCollisionSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_WOOD_PLASTIC);
|
||||
addCollisionSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_WOOD_RUBBER);
|
||||
addCollisionSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_WOOD_PLASTIC);
|
||||
|
||||
addCollisionSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_FLESH_FLESH);
|
||||
addCollisionSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_FLESH_PLASTIC);
|
||||
addCollisionSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_FLESH_RUBBER);
|
||||
addCollisionSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_FLESH_PLASTIC);
|
||||
|
||||
addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_RUBBER_RUBBER);
|
||||
addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_RUBBER_PLASTIC);
|
||||
addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_RUBBER_PLASTIC);
|
||||
|
||||
addCollisionSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_PLASTIC_PLASTIC);
|
||||
addCollisionSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_PLASTIC_PLASTIC);
|
||||
|
||||
addCollisionSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_PLASTIC_PLASTIC);
|
||||
}
|
||||
|
||||
// Sliding Sounds
|
||||
mSlidingSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END];
|
||||
if (mSlidingSoundMatrix)
|
||||
{
|
||||
addSlidingSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_SLIDE_STONE_STONE);
|
||||
addSlidingSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_SLIDE_STONE_WOOD);
|
||||
addSlidingSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_SLIDE_STONE_PLASTIC);
|
||||
addSlidingSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_SLIDE_STONE_RUBBER);
|
||||
addSlidingSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_SLIDE_STONE_PLASTIC);
|
||||
|
||||
addSlidingSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_SLIDE_METAL_METAL);
|
||||
addSlidingSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_SLIDE_METAL_GLASS);
|
||||
addSlidingSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_SLIDE_METAL_WOOD);
|
||||
addSlidingSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_SLIDE_METAL_FLESH);
|
||||
addSlidingSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_SLIDE_METAL_RUBBER);
|
||||
addSlidingSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
|
||||
|
||||
addSlidingSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
|
||||
|
||||
addSlidingSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_SLIDE_WOOD_WOOD);
|
||||
addSlidingSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_SLIDE_WOOD_FLESH);
|
||||
addSlidingSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_SLIDE_WOOD_PLASTIC);
|
||||
addSlidingSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_SLIDE_WOOD_PLASTIC);
|
||||
|
||||
addSlidingSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_SLIDE_FLESH_FLESH);
|
||||
addSlidingSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
|
||||
|
||||
addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_SLIDE_RUBBER_PLASTIC);
|
||||
addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_SLIDE_RUBBER_PLASTIC);
|
||||
|
||||
addSlidingSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
|
||||
addSlidingSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
|
||||
|
||||
addSlidingSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
|
||||
}
|
||||
|
||||
// Rolling Sounds
|
||||
mRollingSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END];
|
||||
if (mRollingSoundMatrix)
|
||||
{
|
||||
addRollingSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_ROLL_STONE_STONE);
|
||||
addRollingSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_ROLL_STONE_WOOD);
|
||||
addRollingSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_ROLL_STONE_PLASTIC);
|
||||
addRollingSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_ROLL_STONE_PLASTIC);
|
||||
|
||||
addRollingSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_ROLL_METAL_GLASS);
|
||||
addRollingSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_ROLL_METAL_WOOD);
|
||||
addRollingSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_ROLL_METAL_WOOD);
|
||||
addRollingSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_ROLL_METAL_WOOD);
|
||||
|
||||
addRollingSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_ROLL_GLASS_WOOD);
|
||||
addRollingSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
|
||||
|
||||
addRollingSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_ROLL_WOOD_WOOD);
|
||||
addRollingSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_ROLL_WOOD_FLESH);
|
||||
addRollingSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_ROLL_WOOD_PLASTIC);
|
||||
addRollingSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_ROLL_WOOD_PLASTIC);
|
||||
|
||||
addRollingSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_ROLL_FLESH_PLASTIC);
|
||||
addRollingSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_ROLL_FLESH_PLASTIC);
|
||||
|
||||
addRollingSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
|
||||
addRollingSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
|
||||
|
||||
addRollingSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_ROLL_PLASTIC_PLASTIC);
|
||||
addRollingSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_ROLL_PLASTIC_PLASTIC);
|
||||
|
||||
addRollingSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_ROLL_PLASTIC_PLASTIC);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLMaterialTable::add(U8 mcode, const std::string& name, const LLUUID &uuid)
|
||||
{
|
||||
LLMaterialInfo *infop;
|
||||
|
||||
infop = new LLMaterialInfo(mcode,name,uuid);
|
||||
if (!infop) return FALSE;
|
||||
|
||||
// Add at the end so the order in menus matches the order in this
|
||||
// file. JNC 11.30.01
|
||||
mMaterialInfoList.push_back(infop);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL LLMaterialTable::addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid)
|
||||
{
|
||||
if (mCollisionSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
|
||||
{
|
||||
mCollisionSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid;
|
||||
if (mcode != mcode2)
|
||||
{
|
||||
mCollisionSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL LLMaterialTable::addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid)
|
||||
{
|
||||
if (mSlidingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
|
||||
{
|
||||
mSlidingSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid;
|
||||
if (mcode != mcode2)
|
||||
{
|
||||
mSlidingSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL LLMaterialTable::addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid)
|
||||
{
|
||||
if (mRollingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
|
||||
{
|
||||
mRollingSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid;
|
||||
if (mcode != mcode2)
|
||||
{
|
||||
mRollingSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL LLMaterialTable::addShatterSound(U8 mcode, const LLUUID &uuid)
|
||||
{
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
infop->mShatterSoundID = uuid;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL LLMaterialTable::addDensity(U8 mcode, const F32 &density)
|
||||
{
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
infop->mDensity = density;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL LLMaterialTable::addRestitution(U8 mcode, const F32 &restitution)
|
||||
{
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
infop->mRestitution = restitution;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL LLMaterialTable::addFriction(U8 mcode, const F32 &friction)
|
||||
{
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
infop->mFriction = friction;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL LLMaterialTable::addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod)
|
||||
{
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
infop->mHPModifier = hp_mod;
|
||||
infop->mDamageModifier = damage_mod;
|
||||
infop->mEPModifier = ep_mod;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LLUUID LLMaterialTable::getDefaultTextureID(const std::string& name)
|
||||
{
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (name == infop->mName)
|
||||
{
|
||||
return infop->mDefaultTextureID;
|
||||
}
|
||||
}
|
||||
|
||||
return LLUUID::null;
|
||||
}
|
||||
|
||||
|
||||
LLUUID LLMaterialTable::getDefaultTextureID(U8 mcode)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
return infop->mDefaultTextureID;
|
||||
}
|
||||
}
|
||||
|
||||
return LLUUID::null;
|
||||
}
|
||||
|
||||
|
||||
U8 LLMaterialTable::getMCode(const std::string& name)
|
||||
{
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (name == infop->mName)
|
||||
{
|
||||
return infop->mMCode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
std::string LLMaterialTable::getName(U8 mcode)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
return infop->mName;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
LLUUID LLMaterialTable::getCollisionSoundUUID(U8 mcode, U8 mcode2)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
mcode2 &= LL_MCODE_MASK;
|
||||
|
||||
//llinfos << "code 1: " << ((U32) mcode) << " code 2:" << ((U32) mcode2) << llendl;
|
||||
if (mCollisionSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
|
||||
{
|
||||
return(mCollisionSoundMatrix[mcode * LL_MCODE_END + mcode2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//llinfos << "Null Sound" << llendl;
|
||||
return(SND_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
LLUUID LLMaterialTable::getSlidingSoundUUID(U8 mcode, U8 mcode2)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
mcode2 &= LL_MCODE_MASK;
|
||||
|
||||
if (mSlidingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
|
||||
{
|
||||
return(mSlidingSoundMatrix[mcode * LL_MCODE_END + mcode2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(SND_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
LLUUID LLMaterialTable::getRollingSoundUUID(U8 mcode, U8 mcode2)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
mcode2 &= LL_MCODE_MASK;
|
||||
|
||||
if (mRollingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
|
||||
{
|
||||
return(mRollingSoundMatrix[mcode * LL_MCODE_END + mcode2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(SND_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
LLUUID LLMaterialTable::getGroundCollisionSoundUUID(U8 mcode)
|
||||
{
|
||||
// Create material appropriate sounds for collisions with the ground
|
||||
// For now, simply return a single sound for all materials
|
||||
return SND_STONE_DIRT_02;
|
||||
}
|
||||
|
||||
LLUUID LLMaterialTable::getGroundSlidingSoundUUID(U8 mcode)
|
||||
{
|
||||
// Create material-specific sound for sliding on ground
|
||||
// For now, just return a single sound
|
||||
return SND_SLIDE_STONE_STONE_01;
|
||||
}
|
||||
|
||||
LLUUID LLMaterialTable::getGroundRollingSoundUUID(U8 mcode)
|
||||
{
|
||||
// Create material-specific sound for rolling on ground
|
||||
// For now, just return a single sound
|
||||
return SND_SLIDE_STONE_STONE_01;
|
||||
}
|
||||
|
||||
LLUUID LLMaterialTable::getCollisionParticleUUID(U8 mcode, U8 mcode2)
|
||||
{
|
||||
// Returns an appropriate UUID to use as sprite at collision betweeen objects
|
||||
// For now, just return a single image
|
||||
return IMG_SHOT;
|
||||
}
|
||||
|
||||
LLUUID LLMaterialTable::getGroundCollisionParticleUUID(U8 mcode)
|
||||
{
|
||||
// Returns an appropriate
|
||||
// For now, just return a single sound
|
||||
return IMG_SMOKE_POOF;
|
||||
}
|
||||
|
||||
|
||||
F32 LLMaterialTable::getDensity(U8 mcode)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
return infop->mDensity;
|
||||
}
|
||||
}
|
||||
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
F32 LLMaterialTable::getRestitution(U8 mcode)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
return infop->mRestitution;
|
||||
}
|
||||
}
|
||||
|
||||
return LLMaterialTable::DEFAULT_RESTITUTION;
|
||||
}
|
||||
|
||||
F32 LLMaterialTable::getFriction(U8 mcode)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
return infop->mFriction;
|
||||
}
|
||||
}
|
||||
|
||||
return LLMaterialTable::DEFAULT_FRICTION;
|
||||
}
|
||||
|
||||
F32 LLMaterialTable::getHPMod(U8 mcode)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
return infop->mHPModifier;
|
||||
}
|
||||
}
|
||||
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
F32 LLMaterialTable::getDamageMod(U8 mcode)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
return infop->mDamageModifier;
|
||||
}
|
||||
}
|
||||
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
F32 LLMaterialTable::getEPMod(U8 mcode)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
return infop->mEPModifier;
|
||||
}
|
||||
}
|
||||
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
LLUUID LLMaterialTable::getShatterSoundUUID(U8 mcode)
|
||||
{
|
||||
mcode &= LL_MCODE_MASK;
|
||||
for (info_list_t::iterator iter = mMaterialInfoList.begin();
|
||||
iter != mMaterialInfoList.end(); ++iter)
|
||||
{
|
||||
LLMaterialInfo *infop = *iter;
|
||||
if (mcode == infop->mMCode)
|
||||
{
|
||||
return infop->mShatterSoundID;
|
||||
}
|
||||
}
|
||||
|
||||
return SND_NULL;
|
||||
}
|
||||
187
indra/llprimitive/llmaterialtable.h
Normal file
187
indra/llprimitive/llmaterialtable.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
* @file llmaterialtable.h
|
||||
* @brief Table of material information for the viewer UI
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLMATERIALTABLE_H
|
||||
#define LL_LLMATERIALTABLE_H
|
||||
|
||||
#include "lluuid.h"
|
||||
#include "llstring.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
const U32 LLMATERIAL_INFO_NAME_LENGTH = 256;
|
||||
|
||||
// We've moved toward more reasonable mass values for the Havok4 engine.
|
||||
// The LEGACY_DEFAULT_OBJECT_DENSITY is used to maintain support for
|
||||
// legacy scripts code (llGetMass()) and script energy consumption.
|
||||
const F32 DEFAULT_OBJECT_DENSITY = 1000.0f; // per m^3
|
||||
const F32 LEGACY_DEFAULT_OBJECT_DENSITY = 10.0f;
|
||||
|
||||
// Avatars density depends on the collision shape used. The approximate
|
||||
// legacy volumes of avatars are:
|
||||
// Body_Length Body_Width Body_Fat Leg_Length Volume(m^3)
|
||||
// -------------------------------------------------------
|
||||
// min | min | min | min | 0.123 |
|
||||
// max | max | max | max | 0.208 |
|
||||
//
|
||||
// Either the avatar shape must be tweaked to match those volumes
|
||||
// or the DEFAULT_AVATAR_DENSITY must be adjusted to achieve the
|
||||
// legacy mass.
|
||||
//
|
||||
// The current density appears to be low because the mass and
|
||||
// inertia are computed as if the avatar were a cylinder which
|
||||
// has more volume than the actual collision shape of the avatar.
|
||||
// See the physics engine mass properties code for more info.
|
||||
const F32 DEFAULT_AVATAR_DENSITY = 445.3f; // was 444.24f;
|
||||
|
||||
|
||||
class LLMaterialInfo
|
||||
{
|
||||
public:
|
||||
U8 mMCode;
|
||||
std::string mName;
|
||||
LLUUID mDefaultTextureID;
|
||||
LLUUID mShatterSoundID;
|
||||
F32 mDensity; // kg/m^3
|
||||
F32 mFriction;
|
||||
F32 mRestitution;
|
||||
|
||||
// damage and energy constants
|
||||
F32 mHPModifier; // modifier on mass based HP total
|
||||
F32 mDamageModifier; // modifier on KE based damage
|
||||
F32 mEPModifier; // modifier on mass based EP total
|
||||
|
||||
LLMaterialInfo(U8 mcode, const std::string& name, const LLUUID &uuid)
|
||||
{
|
||||
init(mcode,name,uuid);
|
||||
};
|
||||
|
||||
void init(U8 mcode, const std::string& name, const LLUUID &uuid)
|
||||
{
|
||||
mDensity = 1000.f; // default to 1000.0 (water)
|
||||
mHPModifier = 1.f;
|
||||
mDamageModifier = 1.f;
|
||||
mEPModifier = 1.f;
|
||||
|
||||
mMCode = mcode;
|
||||
mName = name;
|
||||
mDefaultTextureID = uuid;
|
||||
};
|
||||
|
||||
~LLMaterialInfo()
|
||||
{
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
class LLMaterialTable
|
||||
{
|
||||
public:
|
||||
static const F32 FRICTION_MIN;
|
||||
static const F32 FRICTION_GLASS;
|
||||
static const F32 FRICTION_LIGHT;
|
||||
static const F32 FRICTION_METAL;
|
||||
static const F32 FRICTION_PLASTIC;
|
||||
static const F32 FRICTION_WOOD;
|
||||
static const F32 FRICTION_LAND;
|
||||
static const F32 FRICTION_STONE;
|
||||
static const F32 FRICTION_FLESH;
|
||||
static const F32 FRICTION_RUBBER;
|
||||
static const F32 FRICTION_MAX;
|
||||
|
||||
static const F32 RESTITUTION_MIN;
|
||||
static const F32 RESTITUTION_LAND;
|
||||
static const F32 RESTITUTION_FLESH;
|
||||
static const F32 RESTITUTION_STONE;
|
||||
static const F32 RESTITUTION_METAL;
|
||||
static const F32 RESTITUTION_WOOD;
|
||||
static const F32 RESTITUTION_GLASS;
|
||||
static const F32 RESTITUTION_PLASTIC;
|
||||
static const F32 RESTITUTION_LIGHT;
|
||||
static const F32 RESTITUTION_RUBBER;
|
||||
static const F32 RESTITUTION_MAX;
|
||||
|
||||
typedef std::list<LLMaterialInfo*> info_list_t;
|
||||
info_list_t mMaterialInfoList;
|
||||
|
||||
LLUUID *mCollisionSoundMatrix;
|
||||
LLUUID *mSlidingSoundMatrix;
|
||||
LLUUID *mRollingSoundMatrix;
|
||||
|
||||
static const F32 DEFAULT_FRICTION;
|
||||
static const F32 DEFAULT_RESTITUTION;
|
||||
|
||||
public:
|
||||
LLMaterialTable();
|
||||
LLMaterialTable(U8); // cheat with an overloaded constructor to build our basic table
|
||||
~LLMaterialTable();
|
||||
|
||||
void initBasicTable();
|
||||
|
||||
BOOL add(U8 mcode, const std::string& name, const LLUUID &uuid);
|
||||
BOOL addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
|
||||
BOOL addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
|
||||
BOOL addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
|
||||
BOOL addShatterSound(U8 mcode, const LLUUID &uuid);
|
||||
BOOL addDensity(U8 mcode, const F32 &density);
|
||||
BOOL addFriction(U8 mcode, const F32 &friction);
|
||||
BOOL addRestitution(U8 mcode, const F32 &restitution);
|
||||
BOOL addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod);
|
||||
|
||||
LLUUID getDefaultTextureID(const std::string& name); // LLUUID::null if not found
|
||||
LLUUID getDefaultTextureID(U8 mcode); // LLUUID::null if not found
|
||||
U8 getMCode(const std::string& name); // 0 if not found
|
||||
std::string getName(U8 mcode);
|
||||
|
||||
F32 getDensity(U8 mcode); // kg/m^3, 0 if not found
|
||||
F32 getFriction(U8 mcode); // physics values
|
||||
F32 getRestitution(U8 mcode); // physics values
|
||||
F32 getHPMod(U8 mcode);
|
||||
F32 getDamageMod(U8 mcode);
|
||||
F32 getEPMod(U8 mcode);
|
||||
|
||||
LLUUID getCollisionSoundUUID(U8 mcode, U8 mcode2);
|
||||
LLUUID getSlidingSoundUUID(U8 mcode, U8 mcode2);
|
||||
LLUUID getRollingSoundUUID(U8 mcode, U8 mcode2);
|
||||
LLUUID getShatterSoundUUID(U8 mcode); // LLUUID::null if not found
|
||||
|
||||
LLUUID getGroundCollisionSoundUUID(U8 mcode);
|
||||
LLUUID getGroundSlidingSoundUUID(U8 mcode);
|
||||
LLUUID getGroundRollingSoundUUID(U8 mcode);
|
||||
LLUUID getCollisionParticleUUID(U8 mcode, U8 mcode2);
|
||||
LLUUID getGroundCollisionParticleUUID(U8 mcode);
|
||||
|
||||
static LLMaterialTable basic;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
1891
indra/llprimitive/llprimitive.cpp
Normal file
1891
indra/llprimitive/llprimitive.cpp
Normal file
File diff suppressed because it is too large
Load Diff
620
indra/llprimitive/llprimitive.h
Normal file
620
indra/llprimitive/llprimitive.h
Normal file
@@ -0,0 +1,620 @@
|
||||
/**
|
||||
* @file llprimitive.h
|
||||
* @brief LLPrimitive base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLPRIMITIVE_H
|
||||
#define LL_LLPRIMITIVE_H
|
||||
|
||||
#include "lluuid.h"
|
||||
#include "v3math.h"
|
||||
#include "xform.h"
|
||||
#include "message.h"
|
||||
#include "llmemory.h"
|
||||
#include "llvolume.h"
|
||||
#include "lltextureentry.h"
|
||||
|
||||
// Moved to stdtypes.h --JC
|
||||
// typedef U8 LLPCode;
|
||||
class LLMessageSystem;
|
||||
class LLVolumeParams;
|
||||
class LLColor4;
|
||||
class LLColor3;
|
||||
class LLTextureEntry;
|
||||
class LLDataPacker;
|
||||
class LLVolumeMgr;
|
||||
|
||||
enum LLGeomType // NOTE: same vals as GL Ids
|
||||
{
|
||||
LLInvalid = 0,
|
||||
LLLineLoop = 2,
|
||||
LLLineStrip = 3,
|
||||
LLTriangles = 4,
|
||||
LLTriStrip = 5,
|
||||
LLTriFan = 6,
|
||||
LLQuads = 7,
|
||||
LLQuadStrip = 8
|
||||
};
|
||||
|
||||
class LLVolume;
|
||||
|
||||
/**
|
||||
* exported constants
|
||||
*/
|
||||
extern const F32 OBJECT_CUT_MIN;
|
||||
extern const F32 OBJECT_CUT_MAX;
|
||||
extern const F32 OBJECT_CUT_INC;
|
||||
extern const F32 OBJECT_MIN_CUT_INC;
|
||||
extern const F32 OBJECT_ROTATION_PRECISION;
|
||||
|
||||
extern const F32 OBJECT_TWIST_MIN;
|
||||
extern const F32 OBJECT_TWIST_MAX;
|
||||
extern const F32 OBJECT_TWIST_INC;
|
||||
|
||||
// This is used for linear paths,
|
||||
// since twist is used in a slightly different manner.
|
||||
extern const F32 OBJECT_TWIST_LINEAR_MIN;
|
||||
extern const F32 OBJECT_TWIST_LINEAR_MAX;
|
||||
extern const F32 OBJECT_TWIST_LINEAR_INC;
|
||||
|
||||
extern const F32 OBJECT_MIN_HOLE_SIZE;
|
||||
extern const F32 OBJECT_MAX_HOLE_SIZE_X;
|
||||
extern const F32 OBJECT_MAX_HOLE_SIZE_Y;
|
||||
|
||||
// Revolutions parameters.
|
||||
extern const F32 OBJECT_REV_MIN;
|
||||
extern const F32 OBJECT_REV_MAX;
|
||||
extern const F32 OBJECT_REV_INC;
|
||||
|
||||
extern const char *SCULPT_DEFAULT_TEXTURE;
|
||||
|
||||
//============================================================================
|
||||
|
||||
// TomY: Base class for things that pack & unpack themselves
|
||||
class LLNetworkData
|
||||
{
|
||||
public:
|
||||
// Extra parameter IDs
|
||||
enum
|
||||
{
|
||||
PARAMS_FLEXIBLE = 0x10,
|
||||
PARAMS_LIGHT = 0x20,
|
||||
PARAMS_SCULPT = 0x30
|
||||
};
|
||||
|
||||
public:
|
||||
U16 mType;
|
||||
virtual ~LLNetworkData() {};
|
||||
virtual BOOL pack(LLDataPacker &dp) const = 0;
|
||||
virtual BOOL unpack(LLDataPacker &dp) = 0;
|
||||
virtual bool operator==(const LLNetworkData& data) const = 0;
|
||||
virtual void copy(const LLNetworkData& data) = 0;
|
||||
static BOOL isValid(U16 param_type, U32 size);
|
||||
};
|
||||
|
||||
extern const F32 LIGHT_MIN_RADIUS;
|
||||
extern const F32 LIGHT_DEFAULT_RADIUS;
|
||||
extern const F32 LIGHT_MAX_RADIUS;
|
||||
extern const F32 LIGHT_MIN_FALLOFF;
|
||||
extern const F32 LIGHT_DEFAULT_FALLOFF;
|
||||
extern const F32 LIGHT_MAX_FALLOFF;
|
||||
extern const F32 LIGHT_MIN_CUTOFF;
|
||||
extern const F32 LIGHT_DEFAULT_CUTOFF;
|
||||
extern const F32 LIGHT_MAX_CUTOFF;
|
||||
|
||||
class LLLightParams : public LLNetworkData
|
||||
{
|
||||
protected:
|
||||
LLColor4 mColor; // alpha = intensity
|
||||
F32 mRadius;
|
||||
F32 mFalloff;
|
||||
F32 mCutoff;
|
||||
|
||||
public:
|
||||
LLLightParams();
|
||||
/*virtual*/ BOOL pack(LLDataPacker &dp) const;
|
||||
/*virtual*/ BOOL unpack(LLDataPacker &dp);
|
||||
/*virtual*/ bool operator==(const LLNetworkData& data) const;
|
||||
/*virtual*/ void copy(const LLNetworkData& data);
|
||||
// LLSD implementations here are provided by Eddy Stryker.
|
||||
// NOTE: there are currently unused in protocols
|
||||
LLSD asLLSD() const;
|
||||
operator LLSD() const { return asLLSD(); }
|
||||
bool fromLLSD(LLSD& sd);
|
||||
|
||||
|
||||
void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); }
|
||||
void setRadius(F32 radius) { mRadius = llclamp(radius, LIGHT_MIN_RADIUS, LIGHT_MAX_RADIUS); }
|
||||
void setFalloff(F32 falloff) { mFalloff = llclamp(falloff, LIGHT_MIN_FALLOFF, LIGHT_MAX_FALLOFF); }
|
||||
void setCutoff(F32 cutoff) { mCutoff = llclamp(cutoff, LIGHT_MIN_CUTOFF, LIGHT_MAX_CUTOFF); }
|
||||
|
||||
LLColor4 getColor() const { return mColor; }
|
||||
F32 getRadius() const { return mRadius; }
|
||||
F32 getFalloff() const { return mFalloff; }
|
||||
F32 getCutoff() const { return mCutoff; }
|
||||
};
|
||||
|
||||
//-------------------------------------------------
|
||||
// This structure is also used in the part of the
|
||||
// code that creates new flexible objects.
|
||||
//-------------------------------------------------
|
||||
|
||||
// These were made into enums so that they could be used as fixed size
|
||||
// array bounds.
|
||||
enum EFlexibleObjectConst
|
||||
{
|
||||
// "Softness" => [0,3], increments of 1
|
||||
// Represents powers of 2: 0 -> 1, 3 -> 8
|
||||
FLEXIBLE_OBJECT_MIN_SECTIONS = 0,
|
||||
FLEXIBLE_OBJECT_DEFAULT_NUM_SECTIONS = 2,
|
||||
FLEXIBLE_OBJECT_MAX_SECTIONS = 3
|
||||
};
|
||||
|
||||
// "Tension" => [0,10], increments of 0.1
|
||||
extern const F32 FLEXIBLE_OBJECT_MIN_TENSION;
|
||||
extern const F32 FLEXIBLE_OBJECT_DEFAULT_TENSION;
|
||||
extern const F32 FLEXIBLE_OBJECT_MAX_TENSION;
|
||||
|
||||
// "Drag" => [0,10], increments of 0.1
|
||||
extern const F32 FLEXIBLE_OBJECT_MIN_AIR_FRICTION;
|
||||
extern const F32 FLEXIBLE_OBJECT_DEFAULT_AIR_FRICTION;
|
||||
extern const F32 FLEXIBLE_OBJECT_MAX_AIR_FRICTION;
|
||||
|
||||
// "Gravity" = [-10,10], increments of 0.1
|
||||
extern const F32 FLEXIBLE_OBJECT_MIN_GRAVITY;
|
||||
extern const F32 FLEXIBLE_OBJECT_DEFAULT_GRAVITY;
|
||||
extern const F32 FLEXIBLE_OBJECT_MAX_GRAVITY;
|
||||
|
||||
// "Wind" = [0,10], increments of 0.1
|
||||
extern const F32 FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY;
|
||||
extern const F32 FLEXIBLE_OBJECT_DEFAULT_WIND_SENSITIVITY;
|
||||
extern const F32 FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY;
|
||||
|
||||
extern const F32 FLEXIBLE_OBJECT_MAX_INTERNAL_TENSION_FORCE;
|
||||
|
||||
extern const F32 FLEXIBLE_OBJECT_DEFAULT_LENGTH;
|
||||
extern const BOOL FLEXIBLE_OBJECT_DEFAULT_USING_COLLISION_SPHERE;
|
||||
extern const BOOL FLEXIBLE_OBJECT_DEFAULT_RENDERING_COLLISION_SPHERE;
|
||||
|
||||
|
||||
class LLFlexibleObjectData : public LLNetworkData
|
||||
{
|
||||
protected:
|
||||
S32 mSimulateLOD; // 2^n = number of simulated sections
|
||||
F32 mGravity;
|
||||
F32 mAirFriction; // higher is more stable, but too much looks like it's underwater
|
||||
F32 mWindSensitivity; // interacts with tension, air friction, and gravity
|
||||
F32 mTension; //interacts in complex ways with other parameters
|
||||
LLVector3 mUserForce; // custom user-defined force vector
|
||||
//BOOL mUsingCollisionSphere;
|
||||
//BOOL mRenderingCollisionSphere;
|
||||
|
||||
public:
|
||||
void setSimulateLOD(S32 lod) { mSimulateLOD = llclamp(lod, (S32)FLEXIBLE_OBJECT_MIN_SECTIONS, (S32)FLEXIBLE_OBJECT_MAX_SECTIONS); }
|
||||
void setGravity(F32 gravity) { mGravity = llclamp(gravity, FLEXIBLE_OBJECT_MIN_GRAVITY, FLEXIBLE_OBJECT_MAX_GRAVITY); }
|
||||
void setAirFriction(F32 friction) { mAirFriction = llclamp(friction, FLEXIBLE_OBJECT_MIN_AIR_FRICTION, FLEXIBLE_OBJECT_MAX_AIR_FRICTION); }
|
||||
void setWindSensitivity(F32 wind) { mWindSensitivity = llclamp(wind, FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY, FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY); }
|
||||
void setTension(F32 tension) { mTension = llclamp(tension, FLEXIBLE_OBJECT_MIN_TENSION, FLEXIBLE_OBJECT_MAX_TENSION); }
|
||||
void setUserForce(LLVector3 &force) { mUserForce = force; }
|
||||
|
||||
S32 getSimulateLOD() const { return mSimulateLOD; }
|
||||
F32 getGravity() const { return mGravity; }
|
||||
F32 getAirFriction() const { return mAirFriction; }
|
||||
F32 getWindSensitivity() const { return mWindSensitivity; }
|
||||
F32 getTension() const { return mTension; }
|
||||
LLVector3 getUserForce() const { return mUserForce; }
|
||||
|
||||
//------ the constructor for the structure ------------
|
||||
LLFlexibleObjectData();
|
||||
BOOL pack(LLDataPacker &dp) const;
|
||||
BOOL unpack(LLDataPacker &dp);
|
||||
bool operator==(const LLNetworkData& data) const;
|
||||
void copy(const LLNetworkData& data);
|
||||
LLSD asLLSD() const;
|
||||
operator LLSD() const { return asLLSD(); }
|
||||
bool fromLLSD(LLSD& sd);
|
||||
};// end of attributes structure
|
||||
|
||||
|
||||
|
||||
class LLSculptParams : public LLNetworkData
|
||||
{
|
||||
protected:
|
||||
LLUUID mSculptTexture;
|
||||
U8 mSculptType;
|
||||
|
||||
public:
|
||||
LLSculptParams();
|
||||
/*virtual*/ BOOL pack(LLDataPacker &dp) const;
|
||||
/*virtual*/ BOOL unpack(LLDataPacker &dp);
|
||||
/*virtual*/ bool operator==(const LLNetworkData& data) const;
|
||||
/*virtual*/ void copy(const LLNetworkData& data);
|
||||
LLSD asLLSD() const;
|
||||
operator LLSD() const { return asLLSD(); }
|
||||
bool fromLLSD(LLSD& sd);
|
||||
|
||||
void setSculptTexture(const LLUUID& id) { mSculptTexture = id; }
|
||||
LLUUID getSculptTexture() { return mSculptTexture; }
|
||||
void setSculptType(U8 type) { mSculptType = type; }
|
||||
U8 getSculptType() { return mSculptType; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class LLPrimitive : public LLXform
|
||||
{
|
||||
public:
|
||||
|
||||
// HACK for removing LLPrimitive's dependency on gVolumeMgr global.
|
||||
// If a different LLVolumeManager is instantiated and set early enough
|
||||
// then the LLPrimitive class will use it instead of gVolumeMgr.
|
||||
static LLVolumeMgr* getVolumeManager() { return sVolumeManager; }
|
||||
static void setVolumeManager( LLVolumeMgr* volume_manager);
|
||||
static bool cleanupVolumeManager();
|
||||
|
||||
// these flags influence how the RigidBody representation is built
|
||||
static const U32 PRIM_FLAG_PHANTOM = 0x1 << 0;
|
||||
static const U32 PRIM_FLAG_VOLUME_DETECT = 0x1 << 1;
|
||||
static const U32 PRIM_FLAG_DYNAMIC = 0x1 << 2;
|
||||
static const U32 PRIM_FLAG_AVATAR = 0x1 << 3;
|
||||
static const U32 PRIM_FLAG_SCULPT = 0x1 << 4;
|
||||
// not used yet, but soon
|
||||
static const U32 PRIM_FLAG_COLLISION_CALLBACK = 0x1 << 5;
|
||||
static const U32 PRIM_FLAG_CONVEX = 0x1 << 6;
|
||||
static const U32 PRIM_FLAG_DEFAULT_VOLUME = 0x1 << 7;
|
||||
static const U32 PRIM_FLAG_SITTING = 0x1 << 8;
|
||||
static const U32 PRIM_FLAG_SITTING_ON_GROUND = 0x1 << 9; // Set along with PRIM_FLAG_SITTING
|
||||
|
||||
LLPrimitive();
|
||||
virtual ~LLPrimitive();
|
||||
|
||||
static LLPrimitive *createPrimitive(LLPCode p_code);
|
||||
void init_primitive(LLPCode p_code);
|
||||
|
||||
void setPCode(const LLPCode pcode);
|
||||
const LLVolume *getVolumeConst() const { return mVolumep; } // HACK for Windoze confusion about ostream operator in LLVolume
|
||||
LLVolume *getVolume() const { return mVolumep; }
|
||||
virtual BOOL setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false);
|
||||
|
||||
// Modify texture entry properties
|
||||
inline BOOL validTE(const U8 te_num) const;
|
||||
const LLTextureEntry *getTE(const U8 te_num) const;
|
||||
|
||||
virtual void setNumTEs(const U8 num_tes);
|
||||
virtual void setAllTETextures(const LLUUID &tex_id);
|
||||
virtual void setTE(const U8 index, const LLTextureEntry &te);
|
||||
virtual S32 setTEColor(const U8 te, const LLColor4 &color);
|
||||
virtual S32 setTEColor(const U8 te, const LLColor3 &color);
|
||||
virtual S32 setTEAlpha(const U8 te, const F32 alpha);
|
||||
virtual S32 setTETexture(const U8 te, const LLUUID &tex_id);
|
||||
virtual S32 setTEScale (const U8 te, const F32 s, const F32 t);
|
||||
virtual S32 setTEScaleS(const U8 te, const F32 s);
|
||||
virtual S32 setTEScaleT(const U8 te, const F32 t);
|
||||
virtual S32 setTEOffset (const U8 te, const F32 s, const F32 t);
|
||||
virtual S32 setTEOffsetS(const U8 te, const F32 s);
|
||||
virtual S32 setTEOffsetT(const U8 te, const F32 t);
|
||||
virtual S32 setTERotation(const U8 te, const F32 r);
|
||||
virtual S32 setTEBumpShinyFullbright(const U8 te, const U8 bump);
|
||||
virtual S32 setTEBumpShiny(const U8 te, const U8 bump);
|
||||
virtual S32 setTEMediaTexGen(const U8 te, const U8 media);
|
||||
virtual S32 setTEBumpmap(const U8 te, const U8 bump);
|
||||
virtual S32 setTETexGen(const U8 te, const U8 texgen);
|
||||
virtual S32 setTEShiny(const U8 te, const U8 shiny);
|
||||
virtual S32 setTEFullbright(const U8 te, const U8 fullbright);
|
||||
virtual S32 setTEMediaFlags(const U8 te, const U8 flags);
|
||||
virtual S32 setTEGlow(const U8 te, const F32 glow);
|
||||
virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed
|
||||
|
||||
void setTEArrays(const U8 size,
|
||||
const LLUUID* image_ids,
|
||||
const F32* scale_s,
|
||||
const F32* scale_t);
|
||||
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);
|
||||
BOOL packTEMessage(LLMessageSystem *mesgsys) const;
|
||||
BOOL packTEMessage(LLDataPacker &dp) const;
|
||||
S32 unpackTEMessage(LLMessageSystem *mesgsys, char *block_name);
|
||||
S32 unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, const S32 block_num); // Variable num of blocks
|
||||
BOOL unpackTEMessage(LLDataPacker &dp);
|
||||
|
||||
#ifdef CHECK_FOR_FINITE
|
||||
inline void setPosition(const LLVector3& pos);
|
||||
inline void setPosition(const F32 x, const F32 y, const F32 z);
|
||||
inline void addPosition(const LLVector3& pos);
|
||||
|
||||
inline void setAngularVelocity(const LLVector3& avel);
|
||||
inline void setAngularVelocity(const F32 x, const F32 y, const F32 z);
|
||||
inline void setVelocity(const LLVector3& vel);
|
||||
inline void setVelocity(const F32 x, const F32 y, const F32 z);
|
||||
inline void setVelocityX(const F32 x);
|
||||
inline void setVelocityY(const F32 y);
|
||||
inline void setVelocityZ(const F32 z);
|
||||
inline void addVelocity(const LLVector3& vel);
|
||||
inline void setAcceleration(const LLVector3& accel);
|
||||
inline void setAcceleration(const F32 x, const F32 y, const F32 z);
|
||||
#else
|
||||
// Don't override the base LLXForm operators.
|
||||
// Special case for setPosition. If not check-for-finite, fall through to LLXform method.
|
||||
// void setPosition(F32 x, F32 y, F32 z)
|
||||
// void setPosition(LLVector3)
|
||||
|
||||
void setAngularVelocity(const LLVector3& avel) { mAngularVelocity = avel; }
|
||||
void setAngularVelocity(const F32 x, const F32 y, const F32 z) { mAngularVelocity.setVec(x,y,z); }
|
||||
void setVelocity(const LLVector3& vel) { mVelocity = vel; }
|
||||
void setVelocity(const F32 x, const F32 y, const F32 z) { mVelocity.setVec(x,y,z); }
|
||||
void setVelocityX(const F32 x) { mVelocity.mV[VX] = x; }
|
||||
void setVelocityY(const F32 y) { mVelocity.mV[VY] = y; }
|
||||
void setVelocityZ(const F32 z) { mVelocity.mV[VZ] = z; }
|
||||
void addVelocity(const LLVector3& vel) { mVelocity += vel; }
|
||||
void setAcceleration(const LLVector3& accel) { mAcceleration = accel; }
|
||||
void setAcceleration(const F32 x, const F32 y, const F32 z) { mAcceleration.setVec(x,y,z); }
|
||||
#endif
|
||||
|
||||
LLPCode getPCode() const { return mPrimitiveCode; }
|
||||
std::string getPCodeString() const { return pCodeToString(mPrimitiveCode); }
|
||||
const LLVector3& getAngularVelocity() const { return mAngularVelocity; }
|
||||
const LLVector3& getVelocity() const { return mVelocity; }
|
||||
const LLVector3& getAcceleration() const { return mAcceleration; }
|
||||
U8 getNumTEs() const { return mNumTEs; }
|
||||
|
||||
U8 getMaterial() const { return mMaterial; }
|
||||
|
||||
void setVolumeType(const U8 code);
|
||||
U8 getVolumeType();
|
||||
|
||||
void setTextureList(LLTextureEntry *listp);
|
||||
|
||||
inline BOOL isAvatar() const;
|
||||
inline BOOL isSittingAvatar() const;
|
||||
inline BOOL isSittingAvatarOnGround() const;
|
||||
|
||||
void setFlags(U32 flags) { mMiscFlags = flags; }
|
||||
void addFlags(U32 flags) { mMiscFlags |= flags; }
|
||||
void removeFlags(U32 flags) { mMiscFlags &= ~flags; }
|
||||
U32 getFlags() const { return mMiscFlags; }
|
||||
|
||||
static std::string pCodeToString(const LLPCode pcode);
|
||||
static LLPCode legacyToPCode(const U8 legacy);
|
||||
static U8 pCodeToLegacy(const LLPCode pcode);
|
||||
static bool getTESTAxes(const U8 face, U32* s_axis, U32* t_axis);
|
||||
|
||||
inline static BOOL isPrimitive(const LLPCode pcode);
|
||||
inline static BOOL isApp(const LLPCode pcode);
|
||||
|
||||
protected:
|
||||
LLPCode mPrimitiveCode; // Primitive code
|
||||
LLVector3 mVelocity; // how fast are we moving?
|
||||
LLVector3 mAcceleration; // are we under constant acceleration?
|
||||
LLVector3 mAngularVelocity; // angular velocity
|
||||
LLPointer<LLVolume> mVolumep;
|
||||
LLTextureEntry *mTextureList; // list of texture GUIDs, scales, offsets
|
||||
U8 mMaterial; // Material code
|
||||
U8 mNumTEs; // # of faces on the primitve
|
||||
U32 mMiscFlags; // home for misc bools
|
||||
|
||||
static LLVolumeMgr* sVolumeManager;
|
||||
};
|
||||
|
||||
inline BOOL LLPrimitive::isAvatar() const
|
||||
{
|
||||
return ( LL_PCODE_LEGACY_AVATAR == mPrimitiveCode ) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
inline BOOL LLPrimitive::isSittingAvatar() const
|
||||
{
|
||||
// this is only used server-side
|
||||
return ( LL_PCODE_LEGACY_AVATAR == mPrimitiveCode
|
||||
&& ((getFlags() & (PRIM_FLAG_SITTING | PRIM_FLAG_SITTING_ON_GROUND)) != 0) ) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
inline BOOL LLPrimitive::isSittingAvatarOnGround() const
|
||||
{
|
||||
// this is only used server-side
|
||||
return ( LL_PCODE_LEGACY_AVATAR == mPrimitiveCode
|
||||
&& ((getFlags() & PRIM_FLAG_SITTING_ON_GROUND) != 0) ) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
// static
|
||||
inline BOOL LLPrimitive::isPrimitive(const LLPCode pcode)
|
||||
{
|
||||
LLPCode base_type = pcode & LL_PCODE_BASE_MASK;
|
||||
|
||||
if (base_type && (base_type < LL_PCODE_APP))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// static
|
||||
inline BOOL LLPrimitive::isApp(const LLPCode pcode)
|
||||
{
|
||||
LLPCode base_type = pcode & LL_PCODE_BASE_MASK;
|
||||
|
||||
return (base_type == LL_PCODE_APP);
|
||||
}
|
||||
|
||||
|
||||
#ifdef CHECK_FOR_FINITE
|
||||
// Special case for setPosition. If not check-for-finite, fall through to LLXform method.
|
||||
void LLPrimitive::setPosition(const F32 x, const F32 y, const F32 z)
|
||||
{
|
||||
if (llfinite(x) && llfinite(y) && llfinite(z))
|
||||
{
|
||||
LLXform::setPosition(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "Non Finite in LLPrimitive::setPosition(x,y,z) for " << pCodeToString(mPrimitiveCode) << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
// Special case for setPosition. If not check-for-finite, fall through to LLXform method.
|
||||
void LLPrimitive::setPosition(const LLVector3& pos)
|
||||
{
|
||||
if (pos.isFinite())
|
||||
{
|
||||
LLXform::setPosition(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "Non Finite in LLPrimitive::setPosition(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setAngularVelocity(const LLVector3& avel)
|
||||
{
|
||||
if (avel.isFinite())
|
||||
{
|
||||
mAngularVelocity = avel;
|
||||
}
|
||||
else
|
||||
{
|
||||
llerror("Non Finite in LLPrimitive::setAngularVelocity", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setAngularVelocity(const F32 x, const F32 y, const F32 z)
|
||||
{
|
||||
if (llfinite(x) && llfinite(y) && llfinite(z))
|
||||
{
|
||||
mAngularVelocity.setVec(x,y,z);
|
||||
}
|
||||
else
|
||||
{
|
||||
llerror("Non Finite in LLPrimitive::setAngularVelocity", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setVelocity(const LLVector3& vel)
|
||||
{
|
||||
if (vel.isFinite())
|
||||
{
|
||||
mVelocity = vel;
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "Non Finite in LLPrimitive::setVelocity(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setVelocity(const F32 x, const F32 y, const F32 z)
|
||||
{
|
||||
if (llfinite(x) && llfinite(y) && llfinite(z))
|
||||
{
|
||||
mVelocity.setVec(x,y,z);
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "Non Finite in LLPrimitive::setVelocity(F32,F32,F32) for " << pCodeToString(mPrimitiveCode) << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setVelocityX(const F32 x)
|
||||
{
|
||||
if (llfinite(x))
|
||||
{
|
||||
mVelocity.mV[VX] = x;
|
||||
}
|
||||
else
|
||||
{
|
||||
llerror("Non Finite in LLPrimitive::setVelocityX", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setVelocityY(const F32 y)
|
||||
{
|
||||
if (llfinite(y))
|
||||
{
|
||||
mVelocity.mV[VY] = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
llerror("Non Finite in LLPrimitive::setVelocityY", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setVelocityZ(const F32 z)
|
||||
{
|
||||
if (llfinite(z))
|
||||
{
|
||||
mVelocity.mV[VZ] = z;
|
||||
}
|
||||
else
|
||||
{
|
||||
llerror("Non Finite in LLPrimitive::setVelocityZ", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::addVelocity(const LLVector3& vel)
|
||||
{
|
||||
if (vel.isFinite())
|
||||
{
|
||||
mVelocity += vel;
|
||||
}
|
||||
else
|
||||
{
|
||||
llerror("Non Finite in LLPrimitive::addVelocity", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setAcceleration(const LLVector3& accel)
|
||||
{
|
||||
if (accel.isFinite())
|
||||
{
|
||||
mAcceleration = accel;
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "Non Finite in LLPrimitive::setAcceleration(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setAcceleration(const F32 x, const F32 y, const F32 z)
|
||||
{
|
||||
if (llfinite(x) && llfinite(y) && llfinite(z))
|
||||
{
|
||||
mAcceleration.setVec(x,y,z);
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "Non Finite in LLPrimitive::setAcceleration(F32,F32,F32) for " << pCodeToString(mPrimitiveCode) << llendl;
|
||||
}
|
||||
}
|
||||
#endif // CHECK_FOR_FINITE
|
||||
|
||||
inline BOOL LLPrimitive::validTE(const U8 te_num) const
|
||||
{
|
||||
return (mNumTEs && te_num < mNumTEs);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
399
indra/llprimitive/llprimlinkinfo.h
Normal file
399
indra/llprimitive/llprimlinkinfo.h
Normal file
@@ -0,0 +1,399 @@
|
||||
/**
|
||||
* @file llprimlinkinfo.h
|
||||
* @author andrew@lindenlab.com
|
||||
* @brief A template for determining which prims in a set are linkable
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LL_PRIM_LINK_INFO_H
|
||||
#define LL_PRIM_LINK_INFO_H
|
||||
|
||||
// system includes
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
// common includes
|
||||
#include "stdtypes.h"
|
||||
#include "v3math.h"
|
||||
#include "llquaternion.h"
|
||||
#include "llsphere.h"
|
||||
|
||||
|
||||
const F32 MAX_OBJECT_SPAN = 54.f; // max distance from outside edge of an object to the farthest edge
|
||||
const F32 OBJECT_SPAN_BONUS = 2.f; // infinitesimally small prims can always link up to this distance
|
||||
const S32 MAX_PRIMS_PER_OBJECT = 256;
|
||||
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
class LLPrimLinkInfo
|
||||
{
|
||||
public:
|
||||
LLPrimLinkInfo();
|
||||
LLPrimLinkInfo( DATA_TYPE data, const LLSphere& sphere );
|
||||
~LLPrimLinkInfo();
|
||||
|
||||
void set( DATA_TYPE data, const LLSphere& sphere );
|
||||
void append( DATA_TYPE data, const LLSphere& sphere );
|
||||
void getData( std::list< DATA_TYPE >& data_list ) const;
|
||||
F32 getDiameter() const;
|
||||
LLVector3 getCenter() const;
|
||||
|
||||
// returns 'true' if this info can link with other_info
|
||||
bool canLink( const LLPrimLinkInfo< DATA_TYPE >& other_info );
|
||||
|
||||
S32 getPrimCount() const { return mDataMap.size(); }
|
||||
|
||||
void mergeLinkableSet( typename std::list< LLPrimLinkInfo < DATA_TYPE > >& unlinked );
|
||||
|
||||
void transform(const LLVector3& position, const LLQuaternion& rotation);
|
||||
|
||||
private:
|
||||
// returns number of merges made
|
||||
S32 merge(LLPrimLinkInfo< DATA_TYPE >& other_info);
|
||||
|
||||
// returns number of collapses made
|
||||
static S32 collapse(typename std::list< LLPrimLinkInfo < DATA_TYPE > >& unlinked );
|
||||
|
||||
void computeBoundingSphere();
|
||||
|
||||
// Internal utility to encapsulate the link rules
|
||||
F32 get_max_linkable_span(const LLSphere& first, const LLSphere& second);
|
||||
F32 get_span(const LLSphere& first, const LLSphere& second);
|
||||
|
||||
private:
|
||||
std::map< DATA_TYPE, LLSphere > mDataMap;
|
||||
LLSphere mBoundingSphere;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
LLPrimLinkInfo< DATA_TYPE >::LLPrimLinkInfo()
|
||||
: mBoundingSphere( LLVector3(0.f, 0.f, 0.f), 0.f )
|
||||
{
|
||||
}
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
LLPrimLinkInfo< DATA_TYPE >::LLPrimLinkInfo( DATA_TYPE data, const LLSphere& sphere)
|
||||
: mBoundingSphere(sphere)
|
||||
{
|
||||
mDataMap[data] = sphere;
|
||||
}
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
LLPrimLinkInfo< DATA_TYPE >::~LLPrimLinkInfo()
|
||||
{
|
||||
mDataMap.clear();
|
||||
}
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
void LLPrimLinkInfo< DATA_TYPE>::set( DATA_TYPE data, const LLSphere& sphere )
|
||||
{
|
||||
if (!mDataMap.empty())
|
||||
{
|
||||
mDataMap.clear();
|
||||
}
|
||||
mDataMap[data] = sphere;
|
||||
mBoundingSphere = sphere;
|
||||
}
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
void LLPrimLinkInfo< DATA_TYPE>::append( DATA_TYPE data, const LLSphere& sphere )
|
||||
{
|
||||
mDataMap[data] = sphere;
|
||||
if (!mBoundingSphere.contains(sphere))
|
||||
{
|
||||
computeBoundingSphere();
|
||||
}
|
||||
}
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
void LLPrimLinkInfo< DATA_TYPE >::getData( std::list< DATA_TYPE >& data_list) const
|
||||
{
|
||||
typename std::map< DATA_TYPE, LLSphere >::const_iterator map_itr;
|
||||
for (map_itr = mDataMap.begin(); map_itr != mDataMap.end(); ++map_itr)
|
||||
{
|
||||
data_list.push_back(map_itr->first);
|
||||
}
|
||||
}
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
F32 LLPrimLinkInfo< DATA_TYPE >::getDiameter() const
|
||||
{
|
||||
return 2.f * mBoundingSphere.getRadius();
|
||||
}
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
LLVector3 LLPrimLinkInfo< DATA_TYPE >::getCenter() const
|
||||
{
|
||||
return mBoundingSphere.getCenter();
|
||||
}
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
F32 LLPrimLinkInfo< DATA_TYPE >::get_max_linkable_span(const LLSphere& first, const LLSphere& second)
|
||||
{
|
||||
F32 max_span = 3.f * (first.getRadius() + second.getRadius()) + OBJECT_SPAN_BONUS;
|
||||
if (max_span > MAX_OBJECT_SPAN)
|
||||
{
|
||||
max_span = MAX_OBJECT_SPAN;
|
||||
}
|
||||
|
||||
return max_span;
|
||||
}
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
F32 LLPrimLinkInfo< DATA_TYPE >::get_span(const LLSphere& first, const LLSphere& second)
|
||||
{
|
||||
F32 span = (first.getCenter() - second.getCenter()).length()
|
||||
+ first.getRadius() + second.getRadius();
|
||||
return span;
|
||||
}
|
||||
|
||||
// static
|
||||
// returns 'true' if this info can link with any part of other_info
|
||||
template < typename DATA_TYPE >
|
||||
bool LLPrimLinkInfo< DATA_TYPE >::canLink(const LLPrimLinkInfo& other_info)
|
||||
{
|
||||
F32 max_span = get_max_linkable_span(mBoundingSphere, other_info.mBoundingSphere);
|
||||
|
||||
F32 span = get_span(mBoundingSphere, other_info.mBoundingSphere);
|
||||
|
||||
if (span <= max_span)
|
||||
{
|
||||
// The entire other_info fits inside the max span.
|
||||
return TRUE;
|
||||
}
|
||||
else if (span > max_span + 2.f * other_info.mBoundingSphere.getRadius())
|
||||
{
|
||||
// there is no way any piece of other_info could link with this one
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// there may be a piece of other_info that is linkable
|
||||
typename std::map< DATA_TYPE, LLSphere >::const_iterator map_itr;
|
||||
for (map_itr = other_info.mDataMap.begin(); map_itr != other_info.mDataMap.end(); ++map_itr)
|
||||
{
|
||||
const LLSphere& other_sphere = (*map_itr).second;
|
||||
max_span = get_max_linkable_span(mBoundingSphere, other_sphere);
|
||||
|
||||
span = get_span(mBoundingSphere, other_sphere);
|
||||
|
||||
if (span <= max_span)
|
||||
{
|
||||
// found one piece that is linkable
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// merges elements of 'unlinked'
|
||||
// returns number of links made (NOT final prim count, NOR linked prim count)
|
||||
// and removes any linkable infos from 'unlinked'
|
||||
template < typename DATA_TYPE >
|
||||
void LLPrimLinkInfo< DATA_TYPE >::mergeLinkableSet(std::list< LLPrimLinkInfo< DATA_TYPE > > & unlinked)
|
||||
{
|
||||
bool linked_something = true;
|
||||
while (linked_something)
|
||||
{
|
||||
linked_something = false;
|
||||
|
||||
typename std::list< LLPrimLinkInfo< DATA_TYPE > >::iterator other_itr = unlinked.begin();
|
||||
while ( other_itr != unlinked.end()
|
||||
&& getPrimCount() < MAX_PRIMS_PER_OBJECT )
|
||||
{
|
||||
S32 merge_count = merge(*other_itr);
|
||||
if (merge_count > 0)
|
||||
{
|
||||
linked_something = true;
|
||||
}
|
||||
if (0 == (*other_itr).getPrimCount())
|
||||
{
|
||||
unlinked.erase(other_itr++);
|
||||
}
|
||||
else
|
||||
{
|
||||
++other_itr;
|
||||
}
|
||||
}
|
||||
if (!linked_something
|
||||
&& unlinked.size() > 1)
|
||||
{
|
||||
S32 collapse_count = collapse(unlinked);
|
||||
if (collapse_count > 0)
|
||||
{
|
||||
linked_something = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// transforms all of the spheres into a new reference frame
|
||||
template < typename DATA_TYPE >
|
||||
void LLPrimLinkInfo< DATA_TYPE >::transform(const LLVector3& position, const LLQuaternion& rotation)
|
||||
{
|
||||
typename std::map< DATA_TYPE, LLSphere >::iterator map_itr;
|
||||
for (map_itr = mDataMap.begin(); map_itr != mDataMap.end(); ++map_itr)
|
||||
{
|
||||
(*map_itr).second.setCenter((*map_itr).second.getCenter() * rotation + position);
|
||||
}
|
||||
mBoundingSphere.setCenter(mBoundingSphere.getCenter() * rotation + position);
|
||||
}
|
||||
|
||||
// private
|
||||
// returns number of links made
|
||||
template < typename DATA_TYPE >
|
||||
S32 LLPrimLinkInfo< DATA_TYPE >::merge(LLPrimLinkInfo& other_info)
|
||||
{
|
||||
S32 link_count = 0;
|
||||
|
||||
// F32 other_radius = other_info.mBoundingSphere.getRadius();
|
||||
// other_info.computeBoundingSphere();
|
||||
// if ( other_radius != other_info.mBoundingSphere.getRadius() )
|
||||
// {
|
||||
// llinfos << "Other bounding sphere changed!!" << llendl;
|
||||
// }
|
||||
|
||||
// F32 this_radius = mBoundingSphere.getRadius();
|
||||
// computeBoundingSphere();
|
||||
// if ( this_radius != mBoundingSphere.getRadius() )
|
||||
// {
|
||||
// llinfos << "This bounding sphere changed!!" << llendl;
|
||||
// }
|
||||
|
||||
|
||||
F32 max_span = get_max_linkable_span(mBoundingSphere, other_info.mBoundingSphere);
|
||||
|
||||
// F32 center_dist = (mBoundingSphere.getCenter() - other_info.mBoundingSphere.getCenter()).length();
|
||||
// llinfos << "objects are " << center_dist << "m apart" << llendl;
|
||||
F32 span = get_span(mBoundingSphere, other_info.mBoundingSphere);
|
||||
|
||||
F32 span_limit = max_span + (2.f * other_info.mBoundingSphere.getRadius());
|
||||
if (span > span_limit)
|
||||
{
|
||||
// there is no way any piece of other_info could link with this one
|
||||
// llinfos << "span too large: " << span << " vs. " << span_limit << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool completely_linkable = (span <= max_span) ? true : false;
|
||||
|
||||
typename std::map< DATA_TYPE, LLSphere >::iterator map_itr = other_info.mDataMap.begin();
|
||||
while (map_itr != other_info.mDataMap.end()
|
||||
&& getPrimCount() < MAX_PRIMS_PER_OBJECT )
|
||||
{
|
||||
DATA_TYPE other_data = (*map_itr).first;
|
||||
LLSphere& other_sphere = (*map_itr).second;
|
||||
|
||||
if (!completely_linkable)
|
||||
{
|
||||
max_span = get_max_linkable_span(mBoundingSphere, other_sphere);
|
||||
|
||||
F32 span = get_span(mBoundingSphere, other_sphere);
|
||||
|
||||
if (span > max_span)
|
||||
{
|
||||
++map_itr;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
mDataMap[other_data] = other_sphere;
|
||||
++link_count;
|
||||
|
||||
if (!mBoundingSphere.contains(other_sphere) )
|
||||
{
|
||||
computeBoundingSphere();
|
||||
}
|
||||
|
||||
// remove from the other info
|
||||
other_info.mDataMap.erase(map_itr++);
|
||||
}
|
||||
|
||||
if (link_count > 0 && other_info.getPrimCount() > 0)
|
||||
{
|
||||
other_info.computeBoundingSphere();
|
||||
}
|
||||
return link_count;
|
||||
}
|
||||
|
||||
// links any linkable elements of unlinked
|
||||
template < typename DATA_TYPE >
|
||||
S32 LLPrimLinkInfo< DATA_TYPE >::collapse(std::list< LLPrimLinkInfo< DATA_TYPE > > & unlinked)
|
||||
{
|
||||
S32 link_count = 0;
|
||||
bool linked_something = true;
|
||||
while (linked_something)
|
||||
{
|
||||
linked_something = false;
|
||||
|
||||
typename std::list< LLPrimLinkInfo< DATA_TYPE > >::iterator this_itr = unlinked.begin();
|
||||
typename std::list< LLPrimLinkInfo< DATA_TYPE > >::iterator other_itr = this_itr;
|
||||
++other_itr;
|
||||
while ( other_itr != unlinked.end() )
|
||||
|
||||
{
|
||||
S32 merge_count = (*this_itr).merge(*other_itr);
|
||||
if (merge_count > 0)
|
||||
{
|
||||
linked_something = true;
|
||||
link_count += merge_count;
|
||||
}
|
||||
if (0 == (*other_itr).getPrimCount())
|
||||
{
|
||||
unlinked.erase(other_itr++);
|
||||
}
|
||||
else
|
||||
{
|
||||
++other_itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return link_count;
|
||||
}
|
||||
|
||||
|
||||
template < typename DATA_TYPE >
|
||||
void LLPrimLinkInfo< DATA_TYPE >::computeBoundingSphere()
|
||||
{
|
||||
std::vector< LLSphere > sphere_list;
|
||||
typename std::map< DATA_TYPE, LLSphere >::const_iterator map_itr;
|
||||
for (map_itr = mDataMap.begin(); map_itr != mDataMap.end(); ++map_itr)
|
||||
{
|
||||
sphere_list.push_back(map_itr->second);
|
||||
}
|
||||
mBoundingSphere = LLSphere::getBoundingSphere(sphere_list);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
245
indra/llprimitive/lltextureanim.cpp
Normal file
245
indra/llprimitive/lltextureanim.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/**
|
||||
* @file lltextureanim.cpp
|
||||
* @brief LLTextureAnim base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "lltextureanim.h"
|
||||
#include "message.h"
|
||||
#include "lldatapacker.h"
|
||||
|
||||
const S32 TA_BLOCK_SIZE = 16;
|
||||
|
||||
LLTextureAnim::LLTextureAnim()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
LLTextureAnim::~LLTextureAnim()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LLTextureAnim::reset()
|
||||
{
|
||||
mMode = 0;
|
||||
mFace = -1;
|
||||
mSizeX = 4;
|
||||
mSizeY = 4;
|
||||
mStart = 0.f;
|
||||
mLength = 0.f;
|
||||
mRate = 1.f;
|
||||
}
|
||||
|
||||
BOOL LLTextureAnim::equals(const LLTextureAnim &other) const
|
||||
{
|
||||
if (mMode != other.mMode)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (mFace != other.mFace)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (mSizeX != other.mSizeX)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (mSizeY != other.mSizeY)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (mStart != other.mStart)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (mLength != other.mLength)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (mRate != other.mRate)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
void LLTextureAnim::packTAMessage(LLMessageSystem *mesgsys) const
|
||||
{
|
||||
U8 data[TA_BLOCK_SIZE];
|
||||
data[0] = mMode;
|
||||
data[1] = mFace;
|
||||
data[2] = mSizeX;
|
||||
data[3] = mSizeY;
|
||||
htonmemcpy(data + 4, &mStart, MVT_F32, sizeof(F32));
|
||||
htonmemcpy(data + 8, &mLength, MVT_F32, sizeof(F32));
|
||||
htonmemcpy(data + 12, &mRate, MVT_F32, sizeof(F32));
|
||||
|
||||
mesgsys->addBinaryDataFast(_PREHASH_TextureAnim, data, TA_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
|
||||
void LLTextureAnim::packTAMessage(LLDataPacker &dp) const
|
||||
{
|
||||
U8 data[TA_BLOCK_SIZE];
|
||||
data[0] = mMode;
|
||||
data[1] = mFace;
|
||||
data[2] = mSizeX;
|
||||
data[3] = mSizeY;
|
||||
htonmemcpy(data + 4, &mStart, MVT_F32, sizeof(F32));
|
||||
htonmemcpy(data + 8, &mLength, MVT_F32, sizeof(F32));
|
||||
htonmemcpy(data + 12, &mRate, MVT_F32, sizeof(F32));
|
||||
|
||||
dp.packBinaryData(data, TA_BLOCK_SIZE, "TextureAnimation");
|
||||
}
|
||||
|
||||
|
||||
void LLTextureAnim::unpackTAMessage(LLMessageSystem *mesgsys, const S32 block_num)
|
||||
{
|
||||
S32 size = mesgsys->getSizeFast(_PREHASH_ObjectData, block_num, _PREHASH_TextureAnim);
|
||||
|
||||
if (size != TA_BLOCK_SIZE)
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
llwarns << "Bad size " << size << " for TA block, ignoring." << llendl;
|
||||
}
|
||||
mMode = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
U8 data[TA_BLOCK_SIZE];
|
||||
mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_TextureAnim, data, TA_BLOCK_SIZE, block_num);
|
||||
|
||||
mMode = data[0];
|
||||
mFace = data[1];
|
||||
if (mMode & LLTextureAnim::SMOOTH)
|
||||
{
|
||||
mSizeX = llmax((U8)0, data[2]);
|
||||
mSizeY = llmax((U8)0, data[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSizeX = llmax((U8)1, data[2]);
|
||||
mSizeY = llmax((U8)1, data[3]);
|
||||
}
|
||||
htonmemcpy(&mStart, data + 4, MVT_F32, sizeof(F32));
|
||||
htonmemcpy(&mLength, data + 8, MVT_F32, sizeof(F32));
|
||||
htonmemcpy(&mRate, data + 12, MVT_F32, sizeof(F32));
|
||||
}
|
||||
|
||||
void LLTextureAnim::unpackTAMessage(LLDataPacker &dp)
|
||||
{
|
||||
S32 size;
|
||||
U8 data[TA_BLOCK_SIZE];
|
||||
dp.unpackBinaryData(data, size, "TextureAnimation");
|
||||
if (size != TA_BLOCK_SIZE)
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
llwarns << "Bad size " << size << " for TA block, ignoring." << llendl;
|
||||
}
|
||||
mMode = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
mMode = data[0];
|
||||
mFace = data[1];
|
||||
mSizeX = llmax((U8)1, data[2]);
|
||||
mSizeY = llmax((U8)1, data[3]);
|
||||
htonmemcpy(&mStart, data + 4, MVT_F32, sizeof(F32));
|
||||
htonmemcpy(&mLength, data + 8, MVT_F32, sizeof(F32));
|
||||
htonmemcpy(&mRate, data + 12, MVT_F32, sizeof(F32));
|
||||
}
|
||||
|
||||
LLSD LLTextureAnim::asLLSD() const
|
||||
{
|
||||
LLSD sd;
|
||||
sd["mode"] = mMode;
|
||||
sd["face"] = mFace;
|
||||
sd["sizeX"] = mSizeX;
|
||||
sd["sizeY"] = mSizeY;
|
||||
sd["start"] = mStart;
|
||||
sd["length"] = mLength;
|
||||
sd["rate"] = mRate;
|
||||
return sd;
|
||||
}
|
||||
|
||||
bool LLTextureAnim::fromLLSD(LLSD& sd)
|
||||
{
|
||||
const char *w;
|
||||
w = "mode";
|
||||
if (sd.has(w))
|
||||
{
|
||||
mMode = (U8)sd[w].asInteger();
|
||||
} else goto fail;
|
||||
|
||||
w = "face";
|
||||
if (sd.has(w))
|
||||
{
|
||||
mFace = (S8)sd[w].asInteger();
|
||||
} else goto fail;
|
||||
|
||||
w = "sizeX";
|
||||
if (sd.has(w))
|
||||
{
|
||||
mSizeX = (U8)sd[w].asInteger();
|
||||
} else goto fail;
|
||||
|
||||
w = "sizeY";
|
||||
if (sd.has(w))
|
||||
{
|
||||
mSizeY = (U8)sd[w].asInteger();
|
||||
} else goto fail;
|
||||
|
||||
w = "start";
|
||||
if (sd.has(w))
|
||||
{
|
||||
mStart = (F32)sd[w].asReal();
|
||||
} else goto fail;
|
||||
|
||||
w = "length";
|
||||
if (sd.has(w))
|
||||
{
|
||||
mLength = (F32)sd[w].asReal();
|
||||
} else goto fail;
|
||||
|
||||
w = "rate";
|
||||
if (sd.has(w))
|
||||
{
|
||||
mRate = (F32)sd[w].asReal();
|
||||
} else goto fail;
|
||||
|
||||
return true;
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
78
indra/llprimitive/lltextureanim.h
Normal file
78
indra/llprimitive/lltextureanim.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file lltextureanim.h
|
||||
* @brief LLTextureAnim base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLTEXTUREANIM_H
|
||||
#define LL_LLTEXTUREANIM_H
|
||||
|
||||
#include "stdtypes.h"
|
||||
#include "llsd.h"
|
||||
|
||||
class LLMessageSystem;
|
||||
class LLDataPacker;
|
||||
|
||||
class LLTextureAnim
|
||||
{
|
||||
public:
|
||||
LLTextureAnim();
|
||||
virtual ~LLTextureAnim();
|
||||
|
||||
virtual void reset();
|
||||
void packTAMessage(LLMessageSystem *mesgsys) const;
|
||||
void packTAMessage(LLDataPacker &dp) const;
|
||||
void unpackTAMessage(LLMessageSystem *mesgsys, const S32 block_num);
|
||||
void unpackTAMessage(LLDataPacker &dp);
|
||||
BOOL equals(const LLTextureAnim &other) const;
|
||||
LLSD asLLSD() const;
|
||||
operator LLSD() const { return asLLSD(); }
|
||||
bool fromLLSD(LLSD& sd);
|
||||
|
||||
enum
|
||||
{
|
||||
ON = 0x01,
|
||||
LOOP = 0x02,
|
||||
REVERSE = 0x04,
|
||||
PING_PONG = 0x08,
|
||||
SMOOTH = 0x10,
|
||||
ROTATE = 0x20,
|
||||
SCALE = 0x40,
|
||||
};
|
||||
|
||||
public:
|
||||
U8 mMode;
|
||||
S8 mFace;
|
||||
U8 mSizeX;
|
||||
U8 mSizeY;
|
||||
F32 mStart;
|
||||
F32 mLength;
|
||||
F32 mRate; // Rate in frames per second.
|
||||
};
|
||||
#endif
|
||||
392
indra/llprimitive/lltextureentry.cpp
Normal file
392
indra/llprimitive/lltextureentry.cpp
Normal file
@@ -0,0 +1,392 @@
|
||||
/**
|
||||
* @file lltextureentry.cpp
|
||||
* @brief LLTextureEntry base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "lltextureentry.h"
|
||||
#include "llsdutil.h"
|
||||
|
||||
const U8 DEFAULT_BUMP_CODE = 0; // no bump or shininess
|
||||
|
||||
const LLTextureEntry LLTextureEntry::null;
|
||||
|
||||
//===============================================================
|
||||
LLTextureEntry::LLTextureEntry()
|
||||
{
|
||||
init(LLUUID::null,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE);
|
||||
}
|
||||
|
||||
LLTextureEntry::LLTextureEntry(const LLUUID& tex_id)
|
||||
{
|
||||
init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE);
|
||||
}
|
||||
|
||||
LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs)
|
||||
{
|
||||
mID = rhs.mID;
|
||||
mScaleS = rhs.mScaleS;
|
||||
mScaleT = rhs.mScaleT;
|
||||
mOffsetS = rhs.mOffsetS;
|
||||
mOffsetT = rhs.mOffsetT;
|
||||
mRotation = rhs.mRotation;
|
||||
mColor = rhs.mColor;
|
||||
mBump = rhs.mBump;
|
||||
mMediaFlags = rhs.mMediaFlags;
|
||||
mGlow = rhs.mGlow;
|
||||
}
|
||||
|
||||
LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs)
|
||||
{
|
||||
if (this != &rhs)
|
||||
{
|
||||
mID = rhs.mID;
|
||||
mScaleS = rhs.mScaleS;
|
||||
mScaleT = rhs.mScaleT;
|
||||
mOffsetS = rhs.mOffsetS;
|
||||
mOffsetT = rhs.mOffsetT;
|
||||
mRotation = rhs.mRotation;
|
||||
mColor = rhs.mColor;
|
||||
mBump = rhs.mBump;
|
||||
mMediaFlags = rhs.mMediaFlags;
|
||||
mGlow = rhs.mGlow;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void LLTextureEntry::init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump)
|
||||
{
|
||||
setID(tex_id);
|
||||
|
||||
mScaleS = scale_s;
|
||||
mScaleT = scale_t;
|
||||
mOffsetS = offset_s;
|
||||
mOffsetT = offset_t;
|
||||
mRotation = rotation;
|
||||
mBump = bump;
|
||||
mMediaFlags = 0x0;
|
||||
mGlow = 0;
|
||||
|
||||
setColor(LLColor4(1.f, 1.f, 1.f, 1.f));
|
||||
}
|
||||
|
||||
LLTextureEntry::~LLTextureEntry()
|
||||
{
|
||||
}
|
||||
|
||||
bool LLTextureEntry::operator!=(const LLTextureEntry &rhs) const
|
||||
{
|
||||
if (mID != rhs.mID) return(true);
|
||||
if (mScaleS != rhs.mScaleS) return(true);
|
||||
if (mScaleT != rhs.mScaleT) return(true);
|
||||
if (mOffsetS != rhs.mOffsetS) return(true);
|
||||
if (mOffsetT != rhs.mOffsetT) return(true);
|
||||
if (mRotation != rhs.mRotation) return(true);
|
||||
if (mColor != rhs.mColor) return (true);
|
||||
if (mBump != rhs.mBump) return (true);
|
||||
if (mMediaFlags != rhs.mMediaFlags) return (true);
|
||||
if (mGlow != rhs.mGlow) return (true);
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool LLTextureEntry::operator==(const LLTextureEntry &rhs) const
|
||||
{
|
||||
if (mID != rhs.mID) return(false);
|
||||
if (mScaleS != rhs.mScaleS) return(false);
|
||||
if (mScaleT != rhs.mScaleT) return(false);
|
||||
if (mOffsetS != rhs.mOffsetS) return(false);
|
||||
if (mOffsetT != rhs.mOffsetT) return(false);
|
||||
if (mRotation != rhs.mRotation) return(false);
|
||||
if (mColor != rhs.mColor) return (false);
|
||||
if (mBump != rhs.mBump) return (false);
|
||||
if (mMediaFlags != rhs.mMediaFlags) return false;
|
||||
if (mGlow != rhs.mGlow) return false;
|
||||
return(true);
|
||||
}
|
||||
|
||||
LLSD LLTextureEntry::asLLSD() const
|
||||
{
|
||||
LLSD sd;
|
||||
|
||||
sd["imageid"] = getID();
|
||||
sd["colors"] = ll_sd_from_color4(getColor());
|
||||
sd["scales"] = mScaleS;
|
||||
sd["scalet"] = mScaleT;
|
||||
sd["offsets"] = mOffsetS;
|
||||
sd["offsett"] = mOffsetT;
|
||||
sd["imagerot"] = getRotation();
|
||||
sd["bump"] = getBumpShiny();
|
||||
sd["fullbright"] = getFullbright();
|
||||
sd["media_flags"] = getMediaTexGen();
|
||||
sd["glow"] = getGlow();
|
||||
|
||||
return sd;
|
||||
}
|
||||
|
||||
bool LLTextureEntry::fromLLSD(LLSD& sd)
|
||||
{
|
||||
const char *w, *x;
|
||||
w = "imageid";
|
||||
if (sd.has(w))
|
||||
{
|
||||
setID( sd[w] );
|
||||
} else goto fail;
|
||||
w = "colors";
|
||||
if (sd.has(w))
|
||||
{
|
||||
setColor( ll_color4_from_sd(sd["colors"]) );
|
||||
} else goto fail;
|
||||
w = "scales";
|
||||
x = "scalet";
|
||||
if (sd.has(w) && sd.has(x))
|
||||
{
|
||||
setScale( (F32)sd[w].asReal(), (F32)sd[x].asReal() );
|
||||
} else goto fail;
|
||||
w = "offsets";
|
||||
x = "offsett";
|
||||
if (sd.has(w) && sd.has(x))
|
||||
{
|
||||
setOffset( (F32)sd[w].asReal(), (F32)sd[x].asReal() );
|
||||
} else goto fail;
|
||||
w = "imagerot";
|
||||
if (sd.has(w))
|
||||
{
|
||||
setRotation( (F32)sd[w].asReal() );
|
||||
} else goto fail;
|
||||
w = "bump";
|
||||
if (sd.has(w))
|
||||
{
|
||||
setBumpShiny( sd[w].asInteger() );
|
||||
} else goto fail;
|
||||
w = "fullbright";
|
||||
if (sd.has(w))
|
||||
{
|
||||
setFullbright( sd[w].asInteger() );
|
||||
} else goto fail;
|
||||
w = "media_flags";
|
||||
if (sd.has(w))
|
||||
{
|
||||
setMediaTexGen( sd[w].asInteger() );
|
||||
} else goto fail;
|
||||
w = "glow";
|
||||
if (sd.has(w))
|
||||
{
|
||||
setGlow((F32)sd[w].asReal() );
|
||||
}
|
||||
|
||||
return true;
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setID(const LLUUID &tex_id)
|
||||
{
|
||||
if (mID != tex_id)
|
||||
{
|
||||
mID = tex_id;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setScale(F32 s, F32 t)
|
||||
{
|
||||
S32 retval = 0;
|
||||
|
||||
if ( (mScaleS != s)
|
||||
||(mScaleT != t))
|
||||
{
|
||||
mScaleS = s;
|
||||
mScaleT = t;
|
||||
|
||||
retval = TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setColor(const LLColor4 &color)
|
||||
{
|
||||
if (mColor != color)
|
||||
{
|
||||
mColor = color;
|
||||
return TEM_CHANGE_COLOR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setColor(const LLColor3 &color)
|
||||
{
|
||||
if (mColor != color)
|
||||
{
|
||||
// This preserves alpha.
|
||||
mColor.setVec(color);
|
||||
return TEM_CHANGE_COLOR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setAlpha(const F32 alpha)
|
||||
{
|
||||
if (mColor.mV[VW] != alpha)
|
||||
{
|
||||
mColor.mV[VW] = alpha;
|
||||
return TEM_CHANGE_COLOR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setOffset(F32 s, F32 t)
|
||||
{
|
||||
S32 retval = 0;
|
||||
|
||||
if ( (mOffsetS != s)
|
||||
||(mOffsetT != t))
|
||||
{
|
||||
mOffsetS = s;
|
||||
mOffsetT = t;
|
||||
|
||||
retval = TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setRotation(F32 theta)
|
||||
{
|
||||
if (mRotation != theta)
|
||||
{
|
||||
mRotation = theta;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setBumpShinyFullbright(U8 bump)
|
||||
{
|
||||
if (mBump != bump)
|
||||
{
|
||||
mBump = bump;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setMediaTexGen(U8 media)
|
||||
{
|
||||
if (mMediaFlags != media)
|
||||
{
|
||||
mMediaFlags = media;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setBumpmap(U8 bump)
|
||||
{
|
||||
bump &= TEM_BUMP_MASK;
|
||||
if (getBumpmap() != bump)
|
||||
{
|
||||
mBump &= ~TEM_BUMP_MASK;
|
||||
mBump |= bump;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setFullbright(U8 fullbright)
|
||||
{
|
||||
fullbright &= TEM_FULLBRIGHT_MASK;
|
||||
if (getFullbright() != fullbright)
|
||||
{
|
||||
mBump &= ~(TEM_FULLBRIGHT_MASK<<TEM_FULLBRIGHT_SHIFT);
|
||||
mBump |= fullbright << TEM_FULLBRIGHT_SHIFT;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setShiny(U8 shiny)
|
||||
{
|
||||
shiny &= TEM_SHINY_MASK;
|
||||
if (getShiny() != shiny)
|
||||
{
|
||||
mBump &= ~(TEM_SHINY_MASK<<TEM_SHINY_SHIFT);
|
||||
mBump |= shiny << TEM_SHINY_SHIFT;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setBumpShiny(U8 bump_shiny)
|
||||
{
|
||||
bump_shiny &= TEM_BUMP_SHINY_MASK;
|
||||
if (getBumpShiny() != bump_shiny)
|
||||
{
|
||||
mBump &= ~TEM_BUMP_SHINY_MASK;
|
||||
mBump |= bump_shiny;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setMediaFlags(U8 media_flags)
|
||||
{
|
||||
media_flags &= TEM_MEDIA_MASK;
|
||||
if (getMediaFlags() != media_flags)
|
||||
{
|
||||
mMediaFlags &= ~TEM_MEDIA_MASK;
|
||||
mMediaFlags |= media_flags;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setTexGen(U8 tex_gen)
|
||||
{
|
||||
tex_gen &= TEM_TEX_GEN_MASK;
|
||||
if (getTexGen() != tex_gen)
|
||||
{
|
||||
mMediaFlags &= ~TEM_TEX_GEN_MASK;
|
||||
mMediaFlags |= tex_gen;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
S32 LLTextureEntry::setGlow(F32 glow)
|
||||
{
|
||||
if (mGlow != glow)
|
||||
{
|
||||
mGlow = glow;
|
||||
return TEM_CHANGE_TEXTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
158
indra/llprimitive/lltextureentry.h
Normal file
158
indra/llprimitive/lltextureentry.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* @file lltextureentry.h
|
||||
* @brief LLTextureEntry base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLTEXTUREENTRY_H
|
||||
#define LL_LLTEXTUREENTRY_H
|
||||
|
||||
#include "lluuid.h"
|
||||
#include "v4color.h"
|
||||
#include "llsd.h"
|
||||
|
||||
const S32 TEM_CHANGE_COLOR = 0x1;
|
||||
const S32 TEM_CHANGE_TEXTURE = 0x2;
|
||||
const S32 TEM_INVALID = 0x4;
|
||||
|
||||
const S32 TEM_BUMPMAP_COUNT = 32;
|
||||
|
||||
// The Bump Shiny Fullbright values are bits in an eight bit field:
|
||||
// +----------+
|
||||
// | SSFBBBBB | S = Shiny, F = Fullbright, B = Bumpmap
|
||||
// | 76543210 |
|
||||
// +----------+
|
||||
const S32 TEM_BUMP_MASK = 0x1f; // 5 bits
|
||||
const S32 TEM_FULLBRIGHT_MASK = 0x01; // 1 bit
|
||||
const S32 TEM_SHINY_MASK = 0x03; // 2 bits
|
||||
const S32 TEM_BUMP_SHINY_MASK = (0xc0 | 0x1f);
|
||||
const S32 TEM_FULLBRIGHT_SHIFT = 5;
|
||||
const S32 TEM_SHINY_SHIFT = 6;
|
||||
|
||||
// The Media Tex Gen values are bits in a bit field:
|
||||
// +----------+
|
||||
// | .....TTM | M = Media Flags (web page), T = LLTextureEntry::eTexGen, . = unused
|
||||
// | 76543210 |
|
||||
// +----------+
|
||||
const S32 TEM_MEDIA_MASK = 0x01;
|
||||
const S32 TEM_TEX_GEN_MASK = 0x06;
|
||||
const S32 TEM_TEX_GEN_SHIFT = 1;
|
||||
|
||||
|
||||
class LLTextureEntry
|
||||
{
|
||||
public:
|
||||
|
||||
typedef enum e_texgen
|
||||
{
|
||||
TEX_GEN_DEFAULT = 0x00,
|
||||
TEX_GEN_PLANAR = 0x02,
|
||||
TEX_GEN_SPHERICAL = 0x04,
|
||||
TEX_GEN_CYLINDRICAL = 0x06
|
||||
} eTexGen;
|
||||
|
||||
LLTextureEntry();
|
||||
LLTextureEntry(const LLUUID& tex_id);
|
||||
LLTextureEntry(const LLTextureEntry &rhs);
|
||||
|
||||
LLTextureEntry &operator=(const LLTextureEntry &rhs);
|
||||
~LLTextureEntry();
|
||||
|
||||
bool operator==(const LLTextureEntry &rhs) const;
|
||||
bool operator!=(const LLTextureEntry &rhs) const;
|
||||
|
||||
LLSD asLLSD() const;
|
||||
operator LLSD() const { return asLLSD(); }
|
||||
bool fromLLSD(LLSD& sd);
|
||||
|
||||
void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump);
|
||||
|
||||
// These return a TEM_ flag from above to indicate if something changed.
|
||||
S32 setID (const LLUUID &tex_id);
|
||||
S32 setColor(const LLColor4 &color);
|
||||
S32 setColor(const LLColor3 &color);
|
||||
S32 setAlpha(const F32 alpha);
|
||||
S32 setScale(F32 s, F32 t);
|
||||
S32 setOffset(F32 s, F32 t);
|
||||
S32 setRotation(F32 theta);
|
||||
|
||||
S32 setBumpmap(U8 bump);
|
||||
S32 setFullbright(U8 bump);
|
||||
S32 setShiny(U8 bump);
|
||||
S32 setBumpShiny(U8 bump);
|
||||
S32 setBumpShinyFullbright(U8 bump);
|
||||
|
||||
S32 setMediaFlags(U8 media_flags);
|
||||
S32 setTexGen(U8 texGen);
|
||||
S32 setMediaTexGen(U8 media);
|
||||
S32 setGlow(F32 glow);
|
||||
|
||||
const LLUUID &getID() const { return mID; }
|
||||
const LLColor4 &getColor() const { return mColor; }
|
||||
void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; }
|
||||
void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; }
|
||||
F32 getRotation() const { return mRotation; }
|
||||
void getRotation(F32 *theta) const { *theta = mRotation; }
|
||||
|
||||
U8 getBumpmap() const { return mBump & TEM_BUMP_MASK; }
|
||||
U8 getFullbright() const { return (mBump>>TEM_FULLBRIGHT_SHIFT) & TEM_FULLBRIGHT_MASK; }
|
||||
U8 getShiny() const { return (mBump>>TEM_SHINY_SHIFT) & TEM_SHINY_MASK; }
|
||||
U8 getBumpShiny() const { return mBump & TEM_BUMP_SHINY_MASK; }
|
||||
U8 getBumpShinyFullbright() const { return mBump; }
|
||||
|
||||
U8 getMediaFlags() const { return mMediaFlags & TEM_MEDIA_MASK; }
|
||||
U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; }
|
||||
U8 getMediaTexGen() const { return mMediaFlags; }
|
||||
F32 getGlow() const { return mGlow; }
|
||||
|
||||
// Media flags
|
||||
enum { MF_NONE = 0x0, MF_WEB_PAGE = 0x1 };
|
||||
|
||||
public:
|
||||
F32 mScaleS; // S, T offset
|
||||
F32 mScaleT; // S, T offset
|
||||
F32 mOffsetS; // S, T offset
|
||||
F32 mOffsetT; // S, T offset
|
||||
F32 mRotation; // anti-clockwise rotation in rad about the bottom left corner
|
||||
|
||||
static const LLTextureEntry null;
|
||||
protected:
|
||||
LLUUID mID; // Texture GUID
|
||||
LLColor4 mColor;
|
||||
U8 mBump; // Bump map, shiny, and fullbright
|
||||
U8 mMediaFlags; // replace with web page, movie, etc.
|
||||
F32 mGlow;
|
||||
|
||||
// NOTE: when adding new data to this class, in addition to adding it to the serializers asLLSD/fromLLSD and the
|
||||
// message packers (e.g. LLPrimitive::packTEMessage) you must also implement its copy in LLPrimitive::copyTEs()
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
67
indra/llprimitive/lltree_common.h
Normal file
67
indra/llprimitive/lltree_common.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @file lltree_common.h
|
||||
* @brief LLTree_gene_0 base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
// Common data for trees shared between simulator and viewer
|
||||
|
||||
#ifndef LL_LLTREE_COMMON_H
|
||||
#define LL_LLTREE_COMMON_H
|
||||
|
||||
struct LLTree_gene_0
|
||||
{
|
||||
LLTree_gene_0()
|
||||
: scale(0),
|
||||
branches(0),
|
||||
twist(0),
|
||||
droop(0),
|
||||
species(0),
|
||||
trunk_depth(0),
|
||||
branch_thickness(0),
|
||||
max_depth(0),
|
||||
scale_step(0)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// The genome for a tree, species 0
|
||||
//
|
||||
U8 scale; // Scales size of the tree ( / 50 = meter)
|
||||
U8 branches; // When tree forks, how many branches emerge?
|
||||
U8 twist; // twist about old branch axis for each branch (convert to degrees by dividing/255 * 180)
|
||||
U8 droop; // Droop away from old branch axis (convert to degrees by dividing/255 * 180)
|
||||
U8 species; // Branch coloring index
|
||||
U8 trunk_depth; // max recursions in the main trunk
|
||||
U8 branch_thickness; // Scales thickness of trunk ( / 50 = meter)
|
||||
U8 max_depth; // Branch Recursions to flower
|
||||
U8 scale_step; // How much to multiply scale size at each recursion 0-1.f to convert to float
|
||||
};
|
||||
|
||||
#endif
|
||||
211
indra/llprimitive/lltreeparams.cpp
Normal file
211
indra/llprimitive/lltreeparams.cpp
Normal file
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
* @file lltreeparams.cpp
|
||||
* @brief implementation of the LLTreeParams class.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llmath.h"
|
||||
|
||||
#include "lltreeparams.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
LLTreeParams::LLTreeParams()
|
||||
{
|
||||
|
||||
// llinfos << "TREE PARAMS INITIALIZED" << llendl;
|
||||
// init to basic something or other...
|
||||
mShape = SR_TEND_FLAME;
|
||||
mLevels = 1;
|
||||
mScale = 15;
|
||||
mScaleV = 0;
|
||||
|
||||
mBaseSize = 0.3f;
|
||||
|
||||
mRatio = 0.015f;
|
||||
mRatioPower = 1.3f;
|
||||
|
||||
mLobes = 0;
|
||||
mLobeDepth = .1f;
|
||||
|
||||
mFlare = 1.2f;
|
||||
mFlarePercentage = 0.1f;
|
||||
mFlareRes = 3;
|
||||
|
||||
//mAttractionUp = .5f;
|
||||
|
||||
mBaseSplits = 0;
|
||||
|
||||
mScale0 = 2.0;
|
||||
mScaleV0 = 0.0;
|
||||
|
||||
// level 0
|
||||
|
||||
// scaling
|
||||
mLength[0] = 1.0f;
|
||||
mLengthV[0] = 0;
|
||||
mTaper[0] = 1.0f;
|
||||
|
||||
// stem splits
|
||||
mSegSplits[0] = 0.15f;
|
||||
mSplitAngle[0] = 15.0f;
|
||||
mSplitAngleV[0] = 10.0f;
|
||||
|
||||
mVertices[0] = 5;
|
||||
|
||||
// curvature
|
||||
mCurveRes[0] = 4;
|
||||
mCurve[0] = 0;
|
||||
mCurveV[0] = 25;
|
||||
mCurveBack[0] = 0;
|
||||
|
||||
// level 1
|
||||
|
||||
// scaling
|
||||
mLength[1] = .3f;
|
||||
mLengthV[1] = 0.05f;
|
||||
mTaper[1] = 1.0f;
|
||||
|
||||
// angle params
|
||||
mDownAngle[0] = 60.0f;
|
||||
mDownAngleV[0] = 20.0f;
|
||||
mRotate[0] = 140.0f;
|
||||
mRotateV[0] = 0.0f;
|
||||
mBranches[0] = 35;
|
||||
|
||||
mVertices[1] = 3;
|
||||
|
||||
// stem splits
|
||||
mSplitAngle[1] = 0.0f;
|
||||
mSplitAngleV[1] = 0.0f;
|
||||
mSegSplits[1] = 0.0f;
|
||||
|
||||
// curvature
|
||||
mCurveRes[1] = 4;
|
||||
mCurve[1] = 0;
|
||||
mCurveV[1] = 0;
|
||||
mCurveBack[1] = 40;
|
||||
|
||||
// level 2
|
||||
mLength[2] = .6f;
|
||||
mLengthV[2] = .1f;
|
||||
mTaper[2] = 1;
|
||||
|
||||
mDownAngle[1] = 30;
|
||||
mDownAngleV[1] = 10;
|
||||
mRotate[1] = 140;
|
||||
mRotateV[1] = 0;
|
||||
|
||||
mBranches[1] = 20;
|
||||
mVertices[2] = 3;
|
||||
|
||||
mSplitAngle[2] = 0;
|
||||
mSplitAngleV[2] = 0;
|
||||
mSegSplits[2] = 0;
|
||||
|
||||
mCurveRes[2] = 3;
|
||||
mCurve[2] = 10;
|
||||
mCurveV[2] = 150;
|
||||
mCurveBack[2] = 0;
|
||||
|
||||
// level 3
|
||||
mLength[3] = .4f;
|
||||
mLengthV[3] = 0;
|
||||
mTaper[3] = 1;
|
||||
|
||||
mDownAngle[2] = 45;
|
||||
mDownAngleV[2] = 10;
|
||||
mRotate[2] = 140;
|
||||
mRotateV[2] = 0;
|
||||
|
||||
mBranches[2] = 5;
|
||||
mVertices[3] = 3;
|
||||
|
||||
|
||||
mSplitAngle[3] = 0;
|
||||
mSplitAngleV[3] = 0;
|
||||
mSegSplits[3] = 0;
|
||||
|
||||
mCurveRes[3] = 2;
|
||||
mCurve[3] = 0;
|
||||
mCurveV[3] = 0;
|
||||
mCurveBack[3] = 0;
|
||||
|
||||
mLeaves = 0;
|
||||
mLeafScaleX = 1.0f;
|
||||
mLeafScaleY = 1.0f;
|
||||
|
||||
mLeafQuality = 1.25;
|
||||
}
|
||||
|
||||
LLTreeParams::~LLTreeParams()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
F32 LLTreeParams::ShapeRatio(EShapeRatio shape, F32 ratio)
|
||||
{
|
||||
switch (shape) {
|
||||
case (SR_CONICAL):
|
||||
return (.2f + .8f * ratio);
|
||||
case (SR_SPHERICAL):
|
||||
return (.2f + .8f * sinf(F_PI*ratio));
|
||||
case (SR_HEMISPHERICAL):
|
||||
return (.2f + .8f * sinf(.5*F_PI*ratio));
|
||||
case (SR_CYLINDRICAL):
|
||||
return (1);
|
||||
case (SR_TAPERED_CYLINDRICAL):
|
||||
return (.5f + .5f * ratio);
|
||||
case (SR_FLAME):
|
||||
if (ratio <= .7f) {
|
||||
return ratio/.7f;
|
||||
} else {
|
||||
return ((1 - ratio)/.3f);
|
||||
}
|
||||
case (SR_INVERSE_CONICAL):
|
||||
return (1 - .8f * ratio);
|
||||
case (SR_TEND_FLAME):
|
||||
if (ratio <= .7) {
|
||||
return (.5f + .5f*(ratio/.7f));
|
||||
} else {
|
||||
return (.5f + .5f * (1 - ratio)/.3f);
|
||||
}
|
||||
case (SR_ENVELOPE):
|
||||
return 1;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
207
indra/llprimitive/lltreeparams.h
Normal file
207
indra/llprimitive/lltreeparams.h
Normal file
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
* @file lltreeparams.h
|
||||
* @brief Implementation of the LLTreeParams class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLTREEPARAMS_H
|
||||
#define LL_LLTREEPARAMS_H
|
||||
|
||||
/* for information about formulas associated with each type
|
||||
* check the Weber + Penn paper
|
||||
*/
|
||||
enum EShapeRatio { SR_CONICAL, SR_SPHERICAL, SR_HEMISPHERICAL,
|
||||
SR_CYLINDRICAL, SR_TAPERED_CYLINDRICAL, SR_FLAME,
|
||||
SR_INVERSE_CONICAL, SR_TEND_FLAME, SR_ENVELOPE};
|
||||
|
||||
const U32 TREE_BLOCK_SIZE = 16;
|
||||
|
||||
const U8 MAX_NUM_LEVELS = 4;
|
||||
|
||||
class LLTreeParams
|
||||
{
|
||||
public:
|
||||
LLTreeParams();
|
||||
virtual ~LLTreeParams();
|
||||
|
||||
static F32 ShapeRatio(EShapeRatio shape, F32 ratio);
|
||||
|
||||
public:
|
||||
|
||||
// Variables with an asterick (*) cannot be modified without a re-instancing the
|
||||
// trunk/branches
|
||||
|
||||
// Variables with an exclamation point (!) should probably not be modified outside and instead
|
||||
// be tied directly to the species
|
||||
|
||||
// Variables with a tilde (~) should be tied to a range specified by the
|
||||
// species type but still slightly controllable by the user
|
||||
|
||||
// GENERAL
|
||||
|
||||
//! determines length/radius of branches on tree -- ie: general 'shape'
|
||||
EShapeRatio mShape;
|
||||
|
||||
//! number of recursive branch levels...limit to MAX_NUM_LEVELS
|
||||
U8 mLevels;
|
||||
|
||||
//~ percentage of trunk at bottom without branches
|
||||
F32 mBaseSize;
|
||||
|
||||
//~ the general scale + variance of tree
|
||||
F32 mScale, mScaleV;
|
||||
|
||||
// general scale of tree
|
||||
F32 mScale0, mScaleV0;
|
||||
|
||||
|
||||
|
||||
// LOBING
|
||||
|
||||
//*! number of peaks in the radial distance about the perimeter
|
||||
U8 mLobes;
|
||||
// even numbers = obvius symmetry ... use odd numbers
|
||||
|
||||
//*! magnitude of the variations as a fraction of the radius
|
||||
F32 mLobeDepth;
|
||||
|
||||
|
||||
|
||||
// FLARE
|
||||
|
||||
//*! causes exponential expansion near base of trunk
|
||||
F32 mFlare;
|
||||
// scales radius base by min 1 to '1 + flare'
|
||||
|
||||
//*! percentage of the height of the trunk to flair -- likely less than baseSize
|
||||
F32 mFlarePercentage;
|
||||
|
||||
//*! number of cross sections to make for the flair
|
||||
U8 mFlareRes;
|
||||
|
||||
|
||||
|
||||
// LEAVES
|
||||
|
||||
//~ number of leaves to make
|
||||
U8 mLeaves;
|
||||
|
||||
//! scale of the leaves
|
||||
F32 mLeafScaleX, mLeafScaleY;
|
||||
|
||||
// quality/density of leaves
|
||||
F32 mLeafQuality;
|
||||
|
||||
// several params don't have level 0 values
|
||||
|
||||
// BRANCHES
|
||||
|
||||
//~ angle away from parent
|
||||
F32 mDownAngle[MAX_NUM_LEVELS - 1];
|
||||
F32 mDownAngleV[MAX_NUM_LEVELS - 1];
|
||||
|
||||
//~ rotation around parent
|
||||
F32 mRotate[MAX_NUM_LEVELS - 1];
|
||||
F32 mRotateV[MAX_NUM_LEVELS - 1];
|
||||
|
||||
//~ num branches to spawn
|
||||
U8 mBranches[MAX_NUM_LEVELS - 1];
|
||||
|
||||
//~ fractional length of branch. 1 = same length as parent branch
|
||||
F32 mLength[MAX_NUM_LEVELS];
|
||||
F32 mLengthV[MAX_NUM_LEVELS];
|
||||
|
||||
//!~ ratio and ratiopower determine radius/length
|
||||
F32 mRatio, mRatioPower;
|
||||
|
||||
//*! taper of branches
|
||||
F32 mTaper[MAX_NUM_LEVELS];
|
||||
// 0 - non-tapering cylinder
|
||||
// 1 - taper to a point
|
||||
// 2 - taper to a spherical end
|
||||
// 3 - periodic tapering (concatenated spheres)
|
||||
|
||||
//! SEG SPLITTING
|
||||
U8 mBaseSplits; //! num segsplits at first curve cross section of trunk
|
||||
F32 mSegSplits[MAX_NUM_LEVELS]; //~ splits per cross section. 1 = 1 split per section
|
||||
F32 mSplitAngle[MAX_NUM_LEVELS]; //~ angle that splits go from parent (tempered by height)
|
||||
F32 mSplitAngleV[MAX_NUM_LEVELS]; //~ variance of the splits
|
||||
|
||||
// CURVE
|
||||
F32 mCurve[MAX_NUM_LEVELS]; //* general, 1-axis, overall curve of branch
|
||||
F32 mCurveV[MAX_NUM_LEVELS]; //* curve variance at each cross section from general overall curve
|
||||
U8 mCurveRes[MAX_NUM_LEVELS]; //* number of cross sections for curve
|
||||
F32 mCurveBack[MAX_NUM_LEVELS]; //* curveback is amount branch curves back towards
|
||||
|
||||
// vertices per cross section
|
||||
U8 mVertices[MAX_NUM_LEVELS];
|
||||
|
||||
// * no longer useful with pre-instanced branches
|
||||
// specifies upward tendency of branches.
|
||||
//F32 mAttractionUp;
|
||||
// 1 = each branch will slightly go upwards by the end of the branch
|
||||
// >1 = branches tend to go upwards earlier in their length
|
||||
// pruning not implemented
|
||||
// Prune parameters
|
||||
//F32 mPruneRatio;
|
||||
//F32 mPruneWidth, mPruneWidthPeak;
|
||||
//F32 mPrunePowerLow, mPrunePowerHigh;
|
||||
|
||||
|
||||
// NETWORK MESSAGE DATA
|
||||
// Below is the outline for network messages regarding trees.
|
||||
// The general idea is that a user would pick a general 'tree type' (the first variable)
|
||||
// and then several 'open ended' variables like 'branchiness' and 'leafiness'.
|
||||
// The effect that each of these general user variables would then affect the actual
|
||||
// tree parameters (like # branches, # segsplits) in different ways depending on
|
||||
// the tree type selected. Essentially, each tree type should have a formula
|
||||
// that expands the 'leafiness' and 'branchiness' user variables into actual
|
||||
// values for the tree parameters.
|
||||
|
||||
// These formulas aren't made yet and will certainly require some tuning. The
|
||||
// estimates below for the # bits required seems like a good guesstimate.
|
||||
|
||||
// VARIABLE - # bits (range) - VARIABLES AFFECTED
|
||||
// tree type - 5 bits (32) -
|
||||
// branches - 6 bits (64) - numBranches
|
||||
// splits - 6 bits (64) - segsplits
|
||||
// leafiness - 3 bits (8) - numLeaves
|
||||
// branch spread - 5 bits (32) - splitAngle(V), rotate(V)
|
||||
// angle - 5 bits (32) - downAngle(V)
|
||||
// branch length - 6 bits (64) - branchlength(V)
|
||||
// randomness - 7 bits (128) - percentage for randomness of the (V)'s
|
||||
// basesize - 5 bits (32) - basesize
|
||||
|
||||
// total - 48 bits
|
||||
|
||||
//U8 mNetSpecies;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
561
indra/llprimitive/llvolumemessage.cpp
Normal file
561
indra/llprimitive/llvolumemessage.cpp
Normal file
@@ -0,0 +1,561 @@
|
||||
/**
|
||||
* @file llvolumemessage.cpp
|
||||
* @brief LLVolumeMessage base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "message.h"
|
||||
#include "llvolumemessage.h"
|
||||
#include "lldatapacker.h"
|
||||
|
||||
//============================================================================
|
||||
|
||||
// LLVolumeMessage is just a wrapper class; all members are static
|
||||
|
||||
//============================================================================
|
||||
|
||||
bool LLVolumeMessage::packProfileParams(
|
||||
const LLProfileParams* params,
|
||||
LLMessageSystem *mesgsys)
|
||||
{
|
||||
// Default to cylinder
|
||||
static LLProfileParams defaultparams(LL_PCODE_PROFILE_CIRCLE, U16(0), U16(0), U16(0));
|
||||
|
||||
if (!params)
|
||||
params = &defaultparams;
|
||||
|
||||
U8 tempU8;
|
||||
U16 tempU16;
|
||||
|
||||
tempU8 = params->getCurveType();
|
||||
mesgsys->addU8Fast(_PREHASH_ProfileCurve, tempU8);
|
||||
|
||||
tempU16 = (U16) llround( params->getBegin() / CUT_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_ProfileBegin, tempU16);
|
||||
|
||||
tempU16 = 50000 - (U16) llround(params->getEnd() / CUT_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_ProfileEnd, tempU16);
|
||||
|
||||
tempU16 = (U16) llround(params->getHollow() / HOLLOW_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_ProfileHollow, tempU16);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::packProfileParams(
|
||||
const LLProfileParams* params,
|
||||
LLDataPacker &dp)
|
||||
{
|
||||
// Default to cylinder
|
||||
static LLProfileParams defaultparams(LL_PCODE_PROFILE_CIRCLE, U16(0), U16(0), U16(0));
|
||||
|
||||
if (!params)
|
||||
params = &defaultparams;
|
||||
|
||||
U8 tempU8;
|
||||
U16 tempU16;
|
||||
|
||||
tempU8 = params->getCurveType();
|
||||
dp.packU8(tempU8, "Curve");
|
||||
|
||||
tempU16 = (U16) llround( params->getBegin() / CUT_QUANTA);
|
||||
dp.packU16(tempU16, "Begin");
|
||||
|
||||
tempU16 = 50000 - (U16) llround(params->getEnd() / CUT_QUANTA);
|
||||
dp.packU16(tempU16, "End");
|
||||
|
||||
tempU16 = (U16) llround(params->getHollow() / HOLLOW_QUANTA);
|
||||
dp.packU16(tempU16, "Hollow");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::unpackProfileParams(
|
||||
LLProfileParams* params,
|
||||
LLMessageSystem* mesgsys,
|
||||
char* block_name,
|
||||
S32 block_num)
|
||||
{
|
||||
bool ok = true;
|
||||
U8 temp_u8;
|
||||
U16 temp_u16;
|
||||
F32 temp_f32;
|
||||
|
||||
mesgsys->getU8Fast(block_name, _PREHASH_ProfileCurve, temp_u8, block_num);
|
||||
params->setCurveType(temp_u8);
|
||||
|
||||
mesgsys->getU16Fast(block_name, _PREHASH_ProfileBegin, temp_u16, block_num);
|
||||
temp_f32 = temp_u16 * CUT_QUANTA;
|
||||
if (temp_f32 > 1.f)
|
||||
{
|
||||
llwarns << "Profile begin out of range: " << temp_f32
|
||||
<< ". Clamping to 0.0." << llendl;
|
||||
temp_f32 = 0.f;
|
||||
ok = false;
|
||||
}
|
||||
params->setBegin(temp_f32);
|
||||
|
||||
mesgsys->getU16Fast(block_name, _PREHASH_ProfileEnd, temp_u16, block_num);
|
||||
temp_f32 = temp_u16 * CUT_QUANTA;
|
||||
if (temp_f32 > 1.f)
|
||||
{
|
||||
llwarns << "Profile end out of range: " << 1.f - temp_f32
|
||||
<< ". Clamping to 1.0." << llendl;
|
||||
temp_f32 = 1.f;
|
||||
ok = false;
|
||||
}
|
||||
params->setEnd(1.f - temp_f32);
|
||||
|
||||
mesgsys->getU16Fast(block_name, _PREHASH_ProfileHollow, temp_u16, block_num);
|
||||
temp_f32 = temp_u16 * HOLLOW_QUANTA;
|
||||
if (temp_f32 > 1.f)
|
||||
{
|
||||
llwarns << "Profile hollow out of range: " << temp_f32
|
||||
<< ". Clamping to 0.0." << llendl;
|
||||
temp_f32 = 0.f;
|
||||
ok = false;
|
||||
}
|
||||
params->setHollow(temp_f32);
|
||||
|
||||
/*
|
||||
llinfos << "Unpacking Profile Block " << block_num << llendl;
|
||||
llinfos << "Curve: " << (U32)getCurve() << llendl;
|
||||
llinfos << "Begin: " << getBegin() << llendl;
|
||||
llinfos << "End: " << getEnd() << llendl;
|
||||
llinfos << "Hollow: " << getHollow() << llendl;
|
||||
*/
|
||||
return ok;
|
||||
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::unpackProfileParams(
|
||||
LLProfileParams* params,
|
||||
LLDataPacker &dp)
|
||||
{
|
||||
bool ok = true;
|
||||
U8 temp_u8;
|
||||
U16 temp_u16;
|
||||
F32 temp_f32;
|
||||
|
||||
dp.unpackU8(temp_u8, "Curve");
|
||||
params->setCurveType(temp_u8);
|
||||
|
||||
dp.unpackU16(temp_u16, "Begin");
|
||||
temp_f32 = temp_u16 * CUT_QUANTA;
|
||||
if (temp_f32 > 1.f)
|
||||
{
|
||||
llwarns << "Profile begin out of range: " << temp_f32 << llendl;
|
||||
llwarns << "Clamping to 0.0" << llendl;
|
||||
temp_f32 = 0.f;
|
||||
ok = false;
|
||||
}
|
||||
params->setBegin(temp_f32);
|
||||
|
||||
dp.unpackU16(temp_u16, "End");
|
||||
temp_f32 = temp_u16 * CUT_QUANTA;
|
||||
if (temp_f32 > 1.f)
|
||||
{
|
||||
llwarns << "Profile end out of range: " << 1.f - temp_f32 << llendl;
|
||||
llwarns << "Clamping to 1.0" << llendl;
|
||||
temp_f32 = 1.f;
|
||||
ok = false;
|
||||
}
|
||||
params->setEnd(1.f - temp_f32);
|
||||
|
||||
dp.unpackU16(temp_u16, "Hollow");
|
||||
temp_f32 = temp_u16 * HOLLOW_QUANTA;
|
||||
if (temp_f32 > 1.f)
|
||||
{
|
||||
llwarns << "Profile hollow out of range: " << temp_f32 << llendl;
|
||||
llwarns << "Clamping to 0.0" << llendl;
|
||||
temp_f32 = 0.f;
|
||||
ok = false;
|
||||
}
|
||||
params->setHollow(temp_f32);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
// Quantization:
|
||||
// For cut begin, range is 0 to 1, quanta is 0.005, 0 maps to 0
|
||||
// For cut end, range is 0 to 1, quanta is 0.005, 1 maps to 0
|
||||
// For scale, range is 0 to 1, quanta is 0.01, 0 maps to 0, 1 maps to 100
|
||||
// For shear, range is -0.5 to 0.5, quanta is 0.01, 0 maps to 0
|
||||
// For taper, range is -1 to 1, quanta is 0.01, 0 maps to 0
|
||||
bool LLVolumeMessage::packPathParams(
|
||||
const LLPathParams* params,
|
||||
LLMessageSystem *mesgsys)
|
||||
{
|
||||
// Default to cylinder with no cut, top same size as bottom, no shear, no twist
|
||||
static LLPathParams defaultparams(LL_PCODE_PATH_LINE, U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), 0);
|
||||
if (!params)
|
||||
params = &defaultparams;
|
||||
|
||||
U8 curve = params->getCurveType();
|
||||
mesgsys->addU8Fast(_PREHASH_PathCurve, curve);
|
||||
|
||||
U16 begin = (U16) llround(params->getBegin() / CUT_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_PathBegin, begin);
|
||||
|
||||
U16 end = 50000 - (U16) llround(params->getEnd() / CUT_QUANTA);
|
||||
mesgsys->addU16Fast(_PREHASH_PathEnd, end);
|
||||
|
||||
// Avoid truncation problem with direct F32->U8 cast.
|
||||
// (e.g., (U8) (0.50 / 0.01) = (U8) 49.9999999 = 49 not 50.
|
||||
|
||||
U8 pack_scale_x = 200 - (U8) llround(params->getScaleX() / SCALE_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathScaleX, pack_scale_x );
|
||||
|
||||
U8 pack_scale_y = 200 - (U8) llround(params->getScaleY() / SCALE_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathScaleY, pack_scale_y );
|
||||
|
||||
U8 pack_shear_x = (U8) llround(params->getShearX() / SHEAR_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathShearX, pack_shear_x );
|
||||
|
||||
U8 pack_shear_y = (U8) llround(params->getShearY() / SHEAR_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathShearY, pack_shear_y );
|
||||
|
||||
S8 twist = (S8) llround(params->getTwist() / SCALE_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathTwist, twist);
|
||||
|
||||
S8 twist_begin = (S8) llround(params->getTwistBegin() / SCALE_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathTwistBegin, twist_begin);
|
||||
|
||||
S8 radius_offset = (S8) llround(params->getRadiusOffset() / SCALE_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathRadiusOffset, radius_offset);
|
||||
|
||||
S8 taper_x = (S8) llround(params->getTaperX() / TAPER_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathTaperX, taper_x);
|
||||
|
||||
S8 taper_y = (S8) llround(params->getTaperY() / TAPER_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathTaperY, taper_y);
|
||||
|
||||
U8 revolutions = (U8) llround( (params->getRevolutions() - 1.0f) / REV_QUANTA);
|
||||
mesgsys->addU8Fast(_PREHASH_PathRevolutions, revolutions);
|
||||
|
||||
S8 skew = (S8) llround(params->getSkew() / SCALE_QUANTA);
|
||||
mesgsys->addS8Fast(_PREHASH_PathSkew, skew);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::packPathParams(
|
||||
const LLPathParams* params,
|
||||
LLDataPacker &dp)
|
||||
{
|
||||
// Default to cylinder with no cut, top same size as bottom, no shear, no twist
|
||||
static LLPathParams defaultparams(LL_PCODE_PATH_LINE, U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), 0);
|
||||
if (!params)
|
||||
params = &defaultparams;
|
||||
|
||||
U8 curve = params->getCurveType();
|
||||
dp.packU8(curve, "Curve");
|
||||
|
||||
U16 begin = (U16) llround(params->getBegin() / CUT_QUANTA);
|
||||
dp.packU16(begin, "Begin");
|
||||
|
||||
U16 end = 50000 - (U16) llround(params->getEnd() / CUT_QUANTA);
|
||||
dp.packU16(end, "End");
|
||||
|
||||
// Avoid truncation problem with direct F32->U8 cast.
|
||||
// (e.g., (U8) (0.50 / 0.01) = (U8) 49.9999999 = 49 not 50.
|
||||
|
||||
U8 pack_scale_x = 200 - (U8) llround(params->getScaleX() / SCALE_QUANTA);
|
||||
dp.packU8(pack_scale_x, "ScaleX");
|
||||
|
||||
U8 pack_scale_y = 200 - (U8) llround(params->getScaleY() / SCALE_QUANTA);
|
||||
dp.packU8(pack_scale_y, "ScaleY");
|
||||
|
||||
S8 pack_shear_x = (S8) llround(params->getShearX() / SHEAR_QUANTA);
|
||||
dp.packU8(*(U8 *)&pack_shear_x, "ShearX");
|
||||
|
||||
S8 pack_shear_y = (S8) llround(params->getShearY() / SHEAR_QUANTA);
|
||||
dp.packU8(*(U8 *)&pack_shear_y, "ShearY");
|
||||
|
||||
S8 twist = (S8) llround(params->getTwist() / SCALE_QUANTA);
|
||||
dp.packU8(*(U8 *)&twist, "Twist");
|
||||
|
||||
S8 twist_begin = (S8) llround(params->getTwistBegin() / SCALE_QUANTA);
|
||||
dp.packU8(*(U8 *)&twist_begin, "TwistBegin");
|
||||
|
||||
S8 radius_offset = (S8) llround(params->getRadiusOffset() / SCALE_QUANTA);
|
||||
dp.packU8(*(U8 *)&radius_offset, "RadiusOffset");
|
||||
|
||||
S8 taper_x = (S8) llround(params->getTaperX() / TAPER_QUANTA);
|
||||
dp.packU8(*(U8 *)&taper_x, "TaperX");
|
||||
|
||||
S8 taper_y = (S8) llround(params->getTaperY() / TAPER_QUANTA);
|
||||
dp.packU8(*(U8 *)&taper_y, "TaperY");
|
||||
|
||||
U8 revolutions = (U8) llround( (params->getRevolutions() - 1.0f) / REV_QUANTA);
|
||||
dp.packU8(*(U8 *)&revolutions, "Revolutions");
|
||||
|
||||
S8 skew = (S8) llround(params->getSkew() / SCALE_QUANTA);
|
||||
dp.packU8(*(U8 *)&skew, "Skew");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::unpackPathParams(
|
||||
LLPathParams* params,
|
||||
LLMessageSystem* mesgsys,
|
||||
char* block_name,
|
||||
S32 block_num)
|
||||
{
|
||||
U8 curve;
|
||||
mesgsys->getU8Fast(block_name, _PREHASH_PathCurve, curve, block_num);
|
||||
params->setCurveType(curve);
|
||||
|
||||
U16 begin;
|
||||
mesgsys->getU16Fast(block_name, _PREHASH_PathBegin, begin, block_num);
|
||||
params->setBegin((F32)(begin * CUT_QUANTA));
|
||||
|
||||
U16 end;
|
||||
mesgsys->getU16Fast(block_name, _PREHASH_PathEnd, end, block_num);
|
||||
params->setEnd((F32)((50000 - end) * CUT_QUANTA));
|
||||
|
||||
U8 pack_scale_x, pack_scale_y;
|
||||
mesgsys->getU8Fast(block_name, _PREHASH_PathScaleX, pack_scale_x, block_num);
|
||||
mesgsys->getU8Fast(block_name, _PREHASH_PathScaleY, pack_scale_y, block_num);
|
||||
F32 x = (F32) (200 - pack_scale_x) * SCALE_QUANTA;
|
||||
F32 y = (F32) (200 - pack_scale_y) * SCALE_QUANTA;
|
||||
params->setScale( x, y );
|
||||
|
||||
S8 shear_x_quant, shear_y_quant;
|
||||
mesgsys->getS8Fast(block_name, _PREHASH_PathShearX, shear_x_quant, block_num);
|
||||
mesgsys->getS8Fast(block_name, _PREHASH_PathShearY, shear_y_quant, block_num);
|
||||
F32 shear_x = (F32) shear_x_quant * SHEAR_QUANTA;
|
||||
F32 shear_y = (F32) shear_y_quant * SHEAR_QUANTA;
|
||||
params->setShear( shear_x, shear_y );
|
||||
|
||||
S8 twist;
|
||||
mesgsys->getS8Fast(block_name, _PREHASH_PathTwist, twist, block_num );
|
||||
params->setTwist((F32)(twist * SCALE_QUANTA));
|
||||
|
||||
S8 twist_begin;
|
||||
mesgsys->getS8Fast(block_name, _PREHASH_PathTwistBegin, twist_begin, block_num );
|
||||
params->setTwistBegin((F32)(twist_begin * SCALE_QUANTA));
|
||||
|
||||
S8 radius_offset;
|
||||
mesgsys->getS8Fast(block_name, _PREHASH_PathRadiusOffset, radius_offset, block_num );
|
||||
params->setRadiusOffset((F32)(radius_offset * SCALE_QUANTA));
|
||||
|
||||
S8 taper_x_quant, taper_y_quant;
|
||||
mesgsys->getS8Fast(block_name, _PREHASH_PathTaperX, taper_x_quant, block_num );
|
||||
mesgsys->getS8Fast(block_name, _PREHASH_PathTaperY, taper_y_quant, block_num );
|
||||
F32 taper_x = (F32)(taper_x_quant * TAPER_QUANTA);
|
||||
F32 taper_y = (F32)(taper_y_quant * TAPER_QUANTA);
|
||||
params->setTaper( taper_x, taper_y );
|
||||
|
||||
U8 revolutions;
|
||||
mesgsys->getU8Fast(block_name, _PREHASH_PathRevolutions, revolutions, block_num );
|
||||
params->setRevolutions((F32)(revolutions * REV_QUANTA + 1.0f));
|
||||
|
||||
S8 skew;
|
||||
mesgsys->getS8Fast(block_name, _PREHASH_PathSkew, skew, block_num );
|
||||
params->setSkew((F32)(skew * SCALE_QUANTA));
|
||||
|
||||
/*
|
||||
llinfos << "Unpacking Path Block " << block_num << llendl;
|
||||
llinfos << "Curve: " << (U32)params->getCurve() << llendl;
|
||||
llinfos << "Begin: " << params->getBegin() << llendl;
|
||||
llinfos << "End: " << params->getEnd() << llendl;
|
||||
llinfos << "Scale: " << params->getScale() << llendl;
|
||||
llinfos << "Twist: " << params->getTwist() << llendl;
|
||||
*/
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::unpackPathParams(LLPathParams* params, LLDataPacker &dp)
|
||||
{
|
||||
U8 value;
|
||||
S8 svalue;
|
||||
U16 temp_u16;
|
||||
|
||||
dp.unpackU8(value, "Curve");
|
||||
params->setCurveType( value );
|
||||
|
||||
dp.unpackU16(temp_u16, "Begin");
|
||||
params->setBegin((F32)(temp_u16 * CUT_QUANTA));
|
||||
|
||||
dp.unpackU16(temp_u16, "End");
|
||||
params->setEnd((F32)((50000 - temp_u16) * CUT_QUANTA));
|
||||
|
||||
dp.unpackU8(value, "ScaleX");
|
||||
F32 x = (F32) (200 - value) * SCALE_QUANTA;
|
||||
dp.unpackU8(value, "ScaleY");
|
||||
F32 y = (F32) (200 - value) * SCALE_QUANTA;
|
||||
params->setScale( x, y );
|
||||
|
||||
dp.unpackU8(value, "ShearX");
|
||||
svalue = *(S8 *)&value;
|
||||
F32 shear_x = (F32) svalue * SHEAR_QUANTA;
|
||||
dp.unpackU8(value, "ShearY");
|
||||
svalue = *(S8 *)&value;
|
||||
F32 shear_y = (F32) svalue * SHEAR_QUANTA;
|
||||
params->setShear( shear_x, shear_y );
|
||||
|
||||
dp.unpackU8(value, "Twist");
|
||||
svalue = *(S8 *)&value;
|
||||
params->setTwist((F32)(svalue * SCALE_QUANTA));
|
||||
|
||||
dp.unpackU8(value, "TwistBegin");
|
||||
svalue = *(S8 *)&value;
|
||||
params->setTwistBegin((F32)(svalue * SCALE_QUANTA));
|
||||
|
||||
dp.unpackU8(value, "RadiusOffset");
|
||||
svalue = *(S8 *)&value;
|
||||
params->setRadiusOffset((F32)(svalue * SCALE_QUANTA));
|
||||
|
||||
dp.unpackU8(value, "TaperX");
|
||||
svalue = *(S8 *)&value;
|
||||
params->setTaperX((F32)(svalue * TAPER_QUANTA));
|
||||
|
||||
dp.unpackU8(value, "TaperY");
|
||||
svalue = *(S8 *)&value;
|
||||
params->setTaperY((F32)(svalue * TAPER_QUANTA));
|
||||
|
||||
dp.unpackU8(value, "Revolutions");
|
||||
params->setRevolutions((F32)(value * REV_QUANTA + 1.0f));
|
||||
|
||||
dp.unpackU8(value, "Skew");
|
||||
svalue = *(S8 *)&value;
|
||||
params->setSkew((F32)(svalue * SCALE_QUANTA));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
// static
|
||||
bool LLVolumeMessage::constrainVolumeParams(LLVolumeParams& params)
|
||||
{
|
||||
U32 bad = 0;
|
||||
|
||||
// This is called immediately after an unpack. feed the raw data
|
||||
// through the checked setters to constraint it to a valid set of
|
||||
// volume params.
|
||||
bad |= params.setType(params.getProfileParams().getCurveType(),
|
||||
params.getPathParams().getCurveType()) ? 0 : 1;
|
||||
bad |= params.setBeginAndEndS(params.getProfileParams().getBegin(),
|
||||
params.getProfileParams().getEnd()) ? 0 : 2;
|
||||
bad |= params.setBeginAndEndT(params.getPathParams().getBegin(),
|
||||
params.getPathParams().getEnd()) ? 0 : 4;
|
||||
bad |= params.setHollow(params.getProfileParams().getHollow()) ? 0 : 8;
|
||||
bad |= params.setTwistBegin(params.getPathParams().getTwistBegin()) ? 0 : 0x10;
|
||||
bad |= params.setTwistEnd(params.getPathParams().getTwistEnd()) ? 0 : 0x20;
|
||||
bad |= params.setRatio(params.getPathParams().getScaleX(),
|
||||
params.getPathParams().getScaleY()) ? 0 : 0x40;
|
||||
bad |= params.setShear(params.getPathParams().getShearX(),
|
||||
params.getPathParams().getShearY()) ? 0 : 0x80;
|
||||
bad |= params.setTaper(params.getPathParams().getTaperX(),
|
||||
params.getPathParams().getTaperY()) ? 0 : 0x100;
|
||||
bad |= params.setRevolutions(params.getPathParams().getRevolutions()) ? 0 : 0x200;
|
||||
bad |= params.setRadiusOffset(params.getPathParams().getRadiusOffset()) ? 0 : 0x400;
|
||||
bad |= params.setSkew(params.getPathParams().getSkew()) ? 0 : 0x800;
|
||||
if(bad)
|
||||
{
|
||||
llwarns << "LLVolumeMessage::constrainVolumeParams() - "
|
||||
<< "forced to constrain incoming volume params: "
|
||||
<< llformat("0x%04x",bad) << llendl;
|
||||
}
|
||||
return bad ? false : true;
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::packVolumeParams(const LLVolumeParams* params, LLMessageSystem *mesgsys)
|
||||
{
|
||||
// llinfos << "pack volume" << llendl;
|
||||
if (params)
|
||||
{
|
||||
packPathParams(¶ms->getPathParams(), mesgsys);
|
||||
packProfileParams(¶ms->getProfileParams(), mesgsys);
|
||||
}
|
||||
else
|
||||
{
|
||||
packPathParams(0, mesgsys);
|
||||
packProfileParams(0, mesgsys);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::packVolumeParams(const LLVolumeParams* params, LLDataPacker &dp)
|
||||
{
|
||||
// llinfos << "pack volume" << llendl;
|
||||
if (params)
|
||||
{
|
||||
packPathParams(¶ms->getPathParams(), dp);
|
||||
packProfileParams(¶ms->getProfileParams(), dp);
|
||||
}
|
||||
else
|
||||
{
|
||||
packPathParams(0, dp);
|
||||
packProfileParams(0, dp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::unpackVolumeParams(
|
||||
LLVolumeParams* params,
|
||||
LLMessageSystem* mesgsys,
|
||||
char* block_name,
|
||||
S32 block_num)
|
||||
{
|
||||
bool ok = true;
|
||||
ok &= unpackPathParams(
|
||||
¶ms->getPathParams(),
|
||||
mesgsys,
|
||||
block_name,
|
||||
block_num);
|
||||
ok &= unpackProfileParams(
|
||||
¶ms->getProfileParams(),
|
||||
mesgsys,
|
||||
block_name,
|
||||
block_num);
|
||||
ok &= constrainVolumeParams(*params);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool LLVolumeMessage::unpackVolumeParams(
|
||||
LLVolumeParams* params,
|
||||
LLDataPacker &dp)
|
||||
{
|
||||
bool ok = true;
|
||||
ok &= unpackPathParams(¶ms->getPathParams(), dp);
|
||||
ok &= unpackProfileParams(¶ms->getProfileParams(), dp);
|
||||
ok &= constrainVolumeParams(*params);
|
||||
return ok;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
98
indra/llprimitive/llvolumemessage.h
Normal file
98
indra/llprimitive/llvolumemessage.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* @file llvolumemessage.h
|
||||
* @brief LLVolumeMessage base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLVOLUMEMESSAGE_H
|
||||
#define LL_LLVOLUMEMESSAGE_H
|
||||
|
||||
#include "llvolume.h"
|
||||
|
||||
class LLMessageSystem;
|
||||
class LLDataPacker;
|
||||
|
||||
// wrapper class for some volume/message functions
|
||||
class LLVolumeMessage
|
||||
{
|
||||
protected:
|
||||
// The profile and path params are protected since they do not do
|
||||
// any kind of parameter validation or clamping. Use the public
|
||||
// pack and unpack volume param methods below
|
||||
|
||||
static bool packProfileParams(
|
||||
const LLProfileParams* params,
|
||||
LLMessageSystem* mesgsys);
|
||||
static bool packProfileParams(
|
||||
const LLProfileParams* params,
|
||||
LLDataPacker& dp);
|
||||
static bool unpackProfileParams(
|
||||
LLProfileParams* params,
|
||||
LLMessageSystem* mesgsys,
|
||||
char* block_name,
|
||||
S32 block_num = 0);
|
||||
static bool unpackProfileParams(LLProfileParams* params, LLDataPacker& dp);
|
||||
|
||||
static bool packPathParams(
|
||||
const LLPathParams* params,
|
||||
LLMessageSystem* mesgsys);
|
||||
static bool packPathParams(const LLPathParams* params, LLDataPacker& dp);
|
||||
static bool unpackPathParams(
|
||||
LLPathParams* params,
|
||||
LLMessageSystem* mesgsys,
|
||||
char* block_name,
|
||||
S32 block_num = 0);
|
||||
static bool unpackPathParams(LLPathParams* params, LLDataPacker& dp);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief This method constrains any volume params to make them valid.
|
||||
*
|
||||
* @param[in,out] Possibly invalid params in, always valid out.
|
||||
* @return Returns true if the in params were valid, and therefore
|
||||
* unchanged.
|
||||
*/
|
||||
static bool constrainVolumeParams(LLVolumeParams& params);
|
||||
|
||||
static bool packVolumeParams(
|
||||
const LLVolumeParams* params,
|
||||
LLMessageSystem* mesgsys);
|
||||
static bool packVolumeParams(
|
||||
const LLVolumeParams* params,
|
||||
LLDataPacker& dp);
|
||||
static bool unpackVolumeParams(
|
||||
LLVolumeParams* params,
|
||||
LLMessageSystem* mesgsys,
|
||||
char* block_name,
|
||||
S32 block_num = 0);
|
||||
static bool unpackVolumeParams(LLVolumeParams* params, LLDataPacker &dp);
|
||||
};
|
||||
|
||||
#endif // LL_LLVOLUMEMESSAGE_H
|
||||
|
||||
81
indra/llprimitive/llvolumexml.cpp
Normal file
81
indra/llprimitive/llvolumexml.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @file llvolumexml.cpp
|
||||
* @brief LLVolumeXml base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llvolumexml.h"
|
||||
|
||||
//============================================================================
|
||||
|
||||
// LLVolumeXml is just a wrapper class; all members are static
|
||||
|
||||
//============================================================================
|
||||
|
||||
LLXMLNode *LLVolumeXml::exportProfileParams(const LLProfileParams* params)
|
||||
{
|
||||
LLXMLNode *ret = new LLXMLNode("profile", FALSE);
|
||||
|
||||
ret->createChild("curve_type", TRUE)->setByteValue(1, ¶ms->getCurveType());
|
||||
ret->createChild("interval", FALSE)->setFloatValue(2, ¶ms->getBegin());
|
||||
ret->createChild("hollow", FALSE)->setFloatValue(1, ¶ms->getHollow());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
LLXMLNode *LLVolumeXml::exportPathParams(const LLPathParams* params)
|
||||
{
|
||||
LLXMLNode *ret = new LLXMLNode("path", FALSE);
|
||||
ret->createChild("curve_type", TRUE)->setByteValue(1, ¶ms->getCurveType());
|
||||
ret->createChild("interval", FALSE)->setFloatValue(2, ¶ms->getBegin());
|
||||
ret->createChild("scale", FALSE)->setFloatValue(2, params->getScale().mV);
|
||||
ret->createChild("shear", FALSE)->setFloatValue(2, params->getShear().mV);
|
||||
ret->createChild("twist_interval", FALSE)->setFloatValue(2, ¶ms->getTwistBegin());
|
||||
ret->createChild("radius_offset", FALSE)->setFloatValue(1, ¶ms->getRadiusOffset());
|
||||
ret->createChild("taper", FALSE)->setFloatValue(2, params->getTaper().mV);
|
||||
ret->createChild("revolutions", FALSE)->setFloatValue(1, ¶ms->getRevolutions());
|
||||
ret->createChild("skew", FALSE)->setFloatValue(1, ¶ms->getSkew());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
LLXMLNode *LLVolumeXml::exportVolumeParams(const LLVolumeParams* params)
|
||||
{
|
||||
LLXMLNode *ret = new LLXMLNode("shape", FALSE);
|
||||
|
||||
exportPathParams(¶ms->getPathParams())->setParent(ret);
|
||||
exportProfileParams(¶ms->getProfileParams())->setParent(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
51
indra/llprimitive/llvolumexml.h
Normal file
51
indra/llprimitive/llvolumexml.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file llvolumexml.h
|
||||
* @brief LLVolumeXml base class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLVOLUMEXML_H
|
||||
#define LL_LLVOLUMEXML_H
|
||||
|
||||
#include "llvolume.h"
|
||||
#include "llxmlnode.h"
|
||||
|
||||
// wrapper class for some volume/message functions
|
||||
class LLVolumeXml
|
||||
{
|
||||
public:
|
||||
static LLXMLNode* exportProfileParams(const LLProfileParams* params);
|
||||
|
||||
static LLXMLNode* exportPathParams(const LLPathParams* params);
|
||||
|
||||
static LLXMLNode* exportVolumeParams(const LLVolumeParams* params);
|
||||
};
|
||||
|
||||
#endif // LL_LLVOLUMEXML_H
|
||||
|
||||
59
indra/llprimitive/material_codes.h
Normal file
59
indra/llprimitive/material_codes.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @file material_codes.h
|
||||
* @brief Material_codes definitions
|
||||
*
|
||||
* $LicenseInfo:firstyear=2000&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2000-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_MATERIAL_CODES_H
|
||||
#define LL_MATERIAL_CODES_H
|
||||
|
||||
#include "lluuid.h"
|
||||
|
||||
// material types
|
||||
const U8 LL_MCODE_STONE = 0;
|
||||
const U8 LL_MCODE_METAL = 1;
|
||||
const U8 LL_MCODE_GLASS = 2;
|
||||
const U8 LL_MCODE_WOOD = 3;
|
||||
const U8 LL_MCODE_FLESH = 4;
|
||||
const U8 LL_MCODE_PLASTIC = 5;
|
||||
const U8 LL_MCODE_RUBBER = 6;
|
||||
const U8 LL_MCODE_LIGHT = 7;
|
||||
const U8 LL_MCODE_END = 8;
|
||||
const U8 LL_MCODE_MASK = 0x0F;
|
||||
|
||||
const LLUUID LL_DEFAULT_STONE_UUID("87c5765b-aa26-43eb-b8c6-c09a1ca6208e");
|
||||
const LLUUID LL_DEFAULT_METAL_UUID("6f3c53e9-ba60-4010-8f3e-30f51a762476");
|
||||
const LLUUID LL_DEFAULT_GLASS_UUID("b4ba225c-373f-446d-9f7e-6cb7b5cf9b3d");
|
||||
const LLUUID LL_DEFAULT_WOOD_UUID("89556747-24cb-43ed-920b-47caed15465f");
|
||||
const LLUUID LL_DEFAULT_FLESH_UUID("80736669-e4b9-450e-8890-d5169f988a50");
|
||||
const LLUUID LL_DEFAULT_PLASTIC_UUID("304fcb4e-7d33-4339-ba80-76d3d22dc11a");
|
||||
const LLUUID LL_DEFAULT_RUBBER_UUID("9fae0bc5-666d-477e-9f70-84e8556ec867");
|
||||
const LLUUID LL_DEFAULT_LIGHT_UUID("00000000-0000-0000-0000-000000000000");
|
||||
|
||||
#endif
|
||||
86
indra/llprimitive/object_flags.h
Normal file
86
indra/llprimitive/object_flags.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @file object_flags.h
|
||||
* @brief Flags for object creation and transmission
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_OBJECT_FLAGS_H
|
||||
#define LL_OBJECT_FLAGS_H
|
||||
|
||||
// downstream flags from sim->viewer
|
||||
const U32 FLAGS_USE_PHYSICS = 0x00000001;
|
||||
const U32 FLAGS_CREATE_SELECTED = 0x00000002;
|
||||
const U32 FLAGS_OBJECT_MODIFY = 0x00000004;
|
||||
const U32 FLAGS_OBJECT_COPY = 0x00000008;
|
||||
const U32 FLAGS_OBJECT_ANY_OWNER = 0x00000010;
|
||||
const U32 FLAGS_OBJECT_YOU_OWNER = 0x00000020;
|
||||
const U32 FLAGS_SCRIPTED = 0x00000040;
|
||||
const U32 FLAGS_HANDLE_TOUCH = 0x00000080;
|
||||
const U32 FLAGS_OBJECT_MOVE = 0x00000100;
|
||||
const U32 FLAGS_TAKES_MONEY = 0x00000200;
|
||||
const U32 FLAGS_PHANTOM = 0x00000400;
|
||||
const U32 FLAGS_INVENTORY_EMPTY = 0x00000800;
|
||||
|
||||
const U32 FLAGS_JOINT_HINGE = 0x00001000;
|
||||
const U32 FLAGS_JOINT_P2P = 0x00002000;
|
||||
const U32 FLAGS_JOINT_LP2P = 0x00004000;
|
||||
// const U32 FLAGS_JOINT_WHEEL = 0x00008000;
|
||||
const U32 FLAGS_INCLUDE_IN_SEARCH = 0x00008000;
|
||||
|
||||
const U32 FLAGS_ALLOW_INVENTORY_DROP = 0x00010000;
|
||||
const U32 FLAGS_OBJECT_TRANSFER = 0x00020000;
|
||||
const U32 FLAGS_OBJECT_GROUP_OWNED = 0x00040000;
|
||||
//const U32 FLAGS_OBJECT_YOU_OFFICER = 0x00080000;
|
||||
|
||||
const U32 FLAGS_CAMERA_DECOUPLED = 0x00100000;
|
||||
const U32 FLAGS_ANIM_SOURCE = 0x00200000;
|
||||
const U32 FLAGS_CAMERA_SOURCE = 0x00400000;
|
||||
|
||||
const U32 FLAGS_CAST_SHADOWS = 0x00800000;
|
||||
|
||||
const U32 FLAGS_OBJECT_OWNER_MODIFY = 0x10000000;
|
||||
|
||||
const U32 FLAGS_TEMPORARY_ON_REZ = 0x20000000;
|
||||
const U32 FLAGS_TEMPORARY = 0x40000000;
|
||||
const U32 FLAGS_ZLIB_COMPRESSED = 0x80000000;
|
||||
|
||||
const U32 FLAGS_LOCAL = FLAGS_ANIM_SOURCE | FLAGS_CAMERA_SOURCE;
|
||||
|
||||
typedef enum e_havok_joint_type
|
||||
{
|
||||
HJT_INVALID = 0,
|
||||
HJT_HINGE = 1,
|
||||
HJT_POINT = 2,
|
||||
// HJT_LPOINT = 3,
|
||||
// HJT_WHEEL = 4,
|
||||
HJT_EOF = 3
|
||||
} EHavokJointType;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user