Commit e1ba0cda authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Add sources

parent 93ce50e8
This diff is collapsed.
Source code
========
The license for the source code in this distribution should be clearly
marked on each source file. Unless otherwise specified, the source
code in this distribution ("Source Code") is provided by Linden Lab to
you under the terms of the GNU Lesser General Public License, version 2.1
("LGPL"), 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/LGPL-license.txt in this distribution, or
online at http://secondlife.com/developers/opensource/lgplv2_1
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.
Logos and trademarks
==============
"Second Life" and "Linden Lab" are registered trademarks of Linden
Research, Inc. Other trademarks include (but are not limited to): the
names Linden and Linden Research, as well as the Linden Lab Hexagon
Design and the Second Life Hand Design logos.
Use of logos and trademarks are subject to the Linden Lab trademark
policy, available at:
http://secondlife.com/corporate/trademark/
/**
* @file llconvexdecomposition.cpp
* @brief LLConvexDecomposition interface definition
*
* $LicenseInfo:firstyear=2011&license=lgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_CONVEX_DECOMPOSITION
#define LL_CONVEX_DECOMPOSITION
typedef int bool32;
#if defined(_WIN32) || defined(_WIN64)
#define LLCD_CALL __cdecl
#else
#define LLCD_CALL
#endif
struct LLCDParam
{
enum LLCDParamType
{
LLCD_INVALID = 0,
LLCD_INTEGER,
LLCD_FLOAT,
LLCD_BOOLEAN,
LLCD_ENUM
};
struct LLCDEnumItem
{
const char* mName;
int mValue;
};
union LLCDValue
{
float mFloat;
int mIntOrEnumValue;
bool32 mBool;
};
union LLCDParamDetails
{
struct {
LLCDValue mLow;
LLCDValue mHigh;
LLCDValue mDelta;
} mRange;
struct {
int mNumEnums;
LLCDEnumItem* mEnumsArray;
} mEnumValues;
};
const char* mName;
const char* mDescription;
LLCDParamType mType;
LLCDParamDetails mDetails;
LLCDValue mDefault;
int mStage;
// WARNING: Only the LLConvexDecomposition implementation
// should change this value
int mReserved;
};
struct LLCDStageData
{
const char* mName;
const char* mDescription;
bool32 mSupportsCallback;
};
struct LLCDMeshData
{
enum IndexType
{
INT_16,
INT_32
};
const float* mVertexBase;
int mVertexStrideBytes;
int mNumVertices;
const void* mIndexBase;
IndexType mIndexType;
int mIndexStrideBytes;
int mNumTriangles;
};
struct LLCDHull
{
const float* mVertexBase;
int mVertexStrideBytes;
int mNumVertices;
};
enum LLCDResult
{
LLCD_OK = 0,
LLCD_UNKOWN_ERROR,
LLCD_NULL_PTR,
LLCD_INVALID_STAGE,
LLCD_UNKNOWN_PARAM,
LLCD_BAD_VALUE,
LLCD_REQUEST_OUT_OF_RANGE,
LLCD_INVALID_MESH_DATA,
LLCD_INVALID_HULL_DATA,
LLCD_STAGE_NOT_READY,
LLCD_INVALID_THREAD,
LLCD_NOT_IMPLEMENTED
};
// This callback will receive a string describing the current subtask being performed
// as well as a pair of numbers indicating progress. (The values should not be interpreted
// as a completion percentage as 'current' may be greater than 'final'.)
// If the callback returns zero, the decomposition will be terminated
typedef int (LLCD_CALL *llcdCallbackFunc)(const char* description, int current, int final);
class LLConvexDecomposition
{
public:
// Obtain a pointer to the actual implementation
static LLConvexDecomposition* getInstance();
/// @returns false if this is the stub
static bool isFunctional();
static LLCDResult initSystem();
static LLCDResult initThread();
static LLCDResult quitThread();
static LLCDResult quitSystem();
// Generate a decomposition object handle
virtual void genDecomposition(int& decomp) = 0;
// Delete decomposition object handle
virtual void deleteDecomposition(int decomp) = 0;
// Bind given decomposition handle
// Commands operate on currently bound decomposition
virtual void bindDecomposition(int decomp) = 0;
// Sets *paramsOut to the address of the LLCDParam array and returns
// the number of parameters
virtual int getParameters(const LLCDParam** paramsOut) = 0;
// Sets *stagesOut to the address of the LLCDStageData array and returns
// the number of stages
virtual int getStages(const LLCDStageData** stagesOut) = 0;
// Set a parameter by name. Pass enum values as integers.
virtual LLCDResult setParam(const char* name, float val) = 0;
virtual LLCDResult setParam(const char* name, int val) = 0;
virtual LLCDResult setParam(const char* name, bool val) = 0;
// Set incoming mesh data. Data is copied to local buffers and will
// persist until the next setMeshData call
virtual LLCDResult setMeshData( const LLCDMeshData* data, bool vertex_based ) = 0;
// Register a callback to be called periodically during the specified stage
// See the typedef above for more information
virtual LLCDResult registerCallback( int stage, llcdCallbackFunc callback ) = 0;
// Execute the specified decomposition stage
virtual LLCDResult executeStage(int stage) = 0;
virtual LLCDResult buildSingleHull() = 0 ;
// Gets the number of hulls generated by the specified decompositions stage
virtual int getNumHullsFromStage(int stage) = 0;
// Populates hullOut to reference the internal copy of the requested hull
// The data will persist only until the next executeStage call for that stage.
virtual LLCDResult getHullFromStage( int stage, int hull, LLCDHull* hullOut ) = 0;
virtual LLCDResult getSingleHull( LLCDHull* hullOut ) = 0 ;
// TODO: Implement lock of some kind to disallow this call if data not yet ready
// Populates the meshDataOut to reference the utility's copy of the mesh geometry
// for the hull and stage specified.
// You must copy this data if you want to continue using it after the next executeStage
// call
virtual LLCDResult getMeshFromStage( int stage, int hull, LLCDMeshData* meshDataOut) = 0;
// Creates a mesh from hullIn and temporarily stores it internally in the utility.
// The mesh data persists only until the next call to getMeshFromHull
virtual LLCDResult getMeshFromHull( LLCDHull* hullIn, LLCDMeshData* meshOut ) = 0;
// Takes meshIn, generates a single convex hull from it, converts that to a mesh
// stored internally, and populates meshOut to reference the internally stored data.
// The data is persistent only until the next call to generateSingleHullMeshFromMesh
virtual LLCDResult generateSingleHullMeshFromMesh( LLCDMeshData* meshIn, LLCDMeshData* meshOut) = 0;
//
/// Debug
virtual void loadMeshData(const char* fileIn, LLCDMeshData** meshDataOut) = 0;
private:
static bool s_isInitialized;
};
#endif //LL_CONVEX_DECOMPOSITION
/**
* @file llpathinglib.cpp
* @author prep@lindenlab.com
* @brief LLPathingLib interface definition
*
* $LicenseInfo:firstyear=2012&license=lgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_PATHING_LIBRARY
#define LL_PATHING_LIBRARY
#include "llpreprocessor.h"
#include "llsd.h"
#include "v3dmath.h"
#include "v4math.h"
#include "v4color.h"
#include "v4coloru.h"
#include "llphysicsextensions.h"
typedef int bool32;
#if defined(_WIN32) || defined(_WIN64)
#define LLCD_CALL __cdecl
#else
#define LLCD_CALL
#endif
class LLRender;
//=============================================================================
class LLPathingLib
{
public:
enum LLShapeType
{
LLST_WalkableObjects = 0,
LLST_ObstacleObjects,
LLST_MaterialPhantoms,
LLST_ExclusionPhantoms,
LLST_MaxShapeTypes = LLST_ExclusionPhantoms+1,
LLST_None = LLST_MaxShapeTypes+2,
LLST_SimpleBox = LLST_None+1,
LLST_SimpleCapsule = LLST_SimpleBox+1,
};
enum LLShapeTypeFlag
{
LLSTB_WalkableObjects = 0x1 << 1,
LLSTB_ObstacleObjects = 0x1 << 2,
LLSTB_MaterialPhantoms = 0x1 << 3,
LLSTB_ExclusionPhantoms = 0x1 << 4,
LLSTB_None = 0x1 << 5
};
enum LLPLPathBookEnd
{
LLPL_START = 0,
LLPL_END,
};
enum LLPLResult
{
LLPL_OK = 0,
LLPL_NOTSET,
LLPL_ERROR,
LLPL_NO_NAVMESH,
LLPL_UNKOWN_ERROR,
LLPL_NO_PATH,
LLPL_PATH_GENERATED_OK,
LLPL_NOT_IMPLEMENTED,
};
enum LLPLCharacterType
{
LLPL_CHARACTER_TYPE_A = 4,
LLPL_CHARACTER_TYPE_B = 3,
LLPL_CHARACTER_TYPE_C = 2,
LLPL_CHARACTER_TYPE_D = 1,
LLPL_CHARACTER_TYPE_NONE = 0
};
struct PathingPacket
{
PathingPacket() : mHasPointA(false), mHasPointB(false), mCharacterWidth(0.0f), mCharacterType(LLPL_CHARACTER_TYPE_NONE) {}
bool mHasPointA;
LLVector3 mStartPointA;
LLVector3 mEndPointA;
bool mHasPointB;
LLVector3 mStartPointB;
LLVector3 mEndPointB;
F32 mCharacterWidth;
LLPLCharacterType mCharacterType;
};
struct NavMeshColors
{
LLColor4U mWalkable;
LLColor4U mObstacle;
LLColor4U mMaterial;
LLColor4U mExclusion;
LLColor4U mConnectedEdge;
LLColor4U mBoundaryEdge;
LLColor4 mHeatColorBase;
LLColor4 mHeatColorMax;
LLColor4U mFaceColor;
LLColor4U mStarValid;
LLColor4U mStarInvalid;
LLColor4U mTestPath;
LLColor4U mWaterColor;
};
public:
//Ctor
LLPathingLib() {}
virtual ~LLPathingLib() {}
/// @returns false if this is the stub
static bool isFunctional();
// Obtain a pointer to the actual implementation
static LLPathingLib* getInstance();
static LLPathingLib::LLPLResult initSystem();
static LLPathingLib::LLPLResult quitSystem();
//Extract and store navmesh data from the llsd datablock sent down by the server
virtual LLPLResult extractNavMeshSrcFromLLSD( const LLSD::Binary& dataBlock, int dir ) = 0;
//Stitch any stored navmeshes together
virtual void processNavMeshData( ) = 0;
//Method used to generate and visualize a path on the viewers navmesh
virtual LLPLResult generatePath( const PathingPacket& pathingPacket ) = 0;
//Set the material type for the heatmap type
virtual void setNavMeshMaterialType( LLPLCharacterType materialType ) = 0;
//Set the various navmesh colors
virtual void setNavMeshColors( const NavMeshColors& color ) = 0;
//The entry method to rendering the client side navmesh
virtual void renderNavMesh() = 0;
//The entry method to rendering the client side navmesh edges
virtual void renderNavMeshEdges() = 0;
//The entry method to render the client navmesh shapes VBO
virtual void renderNavMeshShapesVBO( U32 shapeRenderFlags ) = 0;
//The entry method to render the clients designated path
virtual void renderPath() = 0;
//The entry method to render the capsule bookends for the clients designated path
virtual void renderPathBookend( LLRender& gl, LLPathingLib::LLPLPathBookEnd type ) = 0;
//Renders all of the generated simple shapes (using their default transforms)
virtual void renderSimpleShapes( LLRender& gl, F32 regionsWaterHeight ) = 0;
//Method called from second life to create a capsule from properties of a character
virtual void createPhysicsCapsuleRep( F32 length, F32 radius, BOOL horizontal, const LLUUID& id ) = 0;
//Removes any cached physics capsule using a list of cached uuids
virtual void cleanupPhysicsCapsuleRepResiduals() = 0;
//Renders a selected uuids physics rep
virtual void renderSimpleShapeCapsuleID( LLRender& gl, const LLUUID& id, const LLVector3& pos, const LLQuaternion& rot ) = 0;
//Method to delete any vbo's that are currently being managed by the pathing library
virtual void cleanupVBOManager( ) = 0;
//Method to cleanup any allocations within the implementation
virtual void cleanupResidual( ) = 0;
private:
static bool s_isInitialized;
};
#endif //LL_PATHING_LIBRARY
/**
* @file llphysicsextensions.h
* @author nyx@lindenlab.com
* @brief LLPhysicsExtensions core shared initialization
* routines
*
* $LicenseInfo:firstyear=2012&license=lgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_PHYSICS_EXTENSIONS
#define LL_PHYSICS_EXTENSIONS
#include "llpreprocessor.h"
#include "llsd.h"
#include "v3dmath.h"
#define LLPHYSICSEXTENSIONS_VERSION "1.0"
typedef int bool32;
class LLPhysicsExtensions
{
public:
// Obtain a pointer to the actual implementation
static LLPhysicsExtensions* getInstance();
/// @returns false if this is the stub
static bool isFunctional();
static bool initSystem();
static bool quitSystem();
private:
static bool s_isInitialized;
};
#endif //LL_PATHING_LIBRARY
/**
* @file windowsincludes.h
* @author prep@lindenlab.com
* @brief includes that need to be involved in the windows version
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2002, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// TODO: reference additional headers your program requires here
# -*- cmake -*-
project(llphysicsextensions)
include(00-Common)
include(Variables)
include(LLCommon)
include(LLMath)
set(LLPHYSICSEXTENSIONS_LIB_NAME llphysicsextensions)
if (WINDOWS)
set(LLPHYSICSEXTENSIONS_LIBRARIES ${LLPHYSICSEXTENSIONS_LIB_NAME}.lib)
else (WINDOWS)
set(LLPHYSICSEXTENSIONS_LIBRARIES ${LLPHYSICSEXTENSIONS_LIB_NAME}.a)
endif (WINDOWS)
set(LLPHYSICSEXTENSIONS_INCLUDE_DIR
${LIBS_PREBUILT_DIR}/include/llphysicsextensions)
set(LLPHYSICSEXTENSIONS_DEBUG_LIBRARY_PATH ${LIBS_PREBUILT_DIR}/lib/debug)
set(LLPHYSICSEXTENSIONS_RELEASE_LIBRARY_PATH ${LIBS_PREBUILT_DIR}/lib/release)
#set(LLPHYSICSEXTENSIONS_LIBRARIES_LIBRARIES
# debug ${LLPHYSICSEXTENSIONS_DEBUG_LIB}
# optimized ${LLPHYSICSEXTENTIONS_RELEASE_LIB}
#)
if (LINUX)
list(INSERT LLPHYSICSEXTENSIONS_LIBRARIES 0 -Wl,--start-group)
list(APPEND LLPHYSICSEXTENSIONS_LIBRARIES -Wl,--end-group)
endif (LINUX)
include_directories(
${CMAKE_SOURCE_DIR}/llphysicsextensions