diff options
| author | Bryan O'Sullivan <bos@lindenlab.com> | 2008-06-02 21:14:31 +0000 | 
|---|---|---|
| committer | Bryan O'Sullivan <bos@lindenlab.com> | 2008-06-02 21:14:31 +0000 | 
| commit | 9db949eec327df4173fde3de934a87bedb0db13c (patch) | |
| tree | aeffa0f0e68b1d2ceb74d460cbbd22652c9cd159 /indra/llmath | |
| parent | 419e13d0acaabf5e1e02e9b64a07648bce822b2f (diff) | |
svn merge -r88066:88786 svn+ssh://svn.lindenlab.com/svn/linden/branches/cmake-9-merge
dataserver-is-deprecated
for-fucks-sake-whats-with-these-commit-markers
Diffstat (limited to 'indra/llmath')
| -rw-r--r-- | indra/llmath/CMakeLists.txt | 81 | ||||
| -rw-r--r-- | indra/llmath/llmath.h | 13 | ||||
| -rw-r--r-- | indra/llmath/lloctree.h | 2 | ||||
| -rw-r--r-- | indra/llmath/llquaternion.cpp | 2 | ||||
| -rw-r--r-- | indra/llmath/llsdutil_math.cpp | 172 | ||||
| -rw-r--r-- | indra/llmath/v3color.h | 4 | 
6 files changed, 265 insertions, 9 deletions
diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt new file mode 100644 index 0000000000..6a329fabb6 --- /dev/null +++ b/indra/llmath/CMakeLists.txt @@ -0,0 +1,81 @@ +# -*- cmake -*- + +project(llmath) + +include(00-Common) +include(LLCommon) + +include_directories( +    ${LLCOMMON_INCLUDE_DIRS} +    ) + +set(llmath_SOURCE_FILES +    llbboxlocal.cpp +    llcamera.cpp +    llcoordframe.cpp +    llline.cpp +    llperlin.cpp +    llquaternion.cpp +    llrect.cpp +    llsphere.cpp +    llvolume.cpp +    llvolumemgr.cpp +    llsdutil_math.cpp +    m3math.cpp +    m4math.cpp +    raytrace.cpp +    v2math.cpp +    v3color.cpp +    v3dmath.cpp +    v3math.cpp +    v4color.cpp +    v4coloru.cpp +    v4math.cpp +    xform.cpp +    ) + +set(llmath_HEADER_FILES +    CMakeLists.txt + +    camera.h +    coordframe.h +    llbboxlocal.h +    llcamera.h +    llcoord.h +    llcoordframe.h +    llinterp.h +    llline.h +    llmath.h +    lloctree.h +    llperlin.h +    llplane.h +    llquantize.h +    llquaternion.h +    llrect.h +    llsphere.h +    lltreenode.h +    llv4math.h +    llv4matrix3.h +    llv4matrix4.h +    llv4vector3.h +    llvolume.h +    llvolumemgr.h +    m3math.h +    m4math.h +    raytrace.h +    v2math.h +    v3color.h +    v3dmath.h +    v3math.h +    v4color.h +    v4coloru.h +    v4math.h +    xform.h +    ) + +set_source_files_properties(${llmath_HEADER_FILES} +                            PROPERTIES HEADER_FILE_ONLY TRUE) + +list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES}) + +add_library (llmath ${llmath_SOURCE_FILES}) diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index 5dfddff4eb..bf98801508 100644 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -33,8 +33,7 @@  #define LLMATH_H  #include <cmath> -//#include <math.h> -//#include <stdlib.h> +#include <cstdlib>  #include "lldefs.h"  // work around for Windows & older gcc non-standard function names. @@ -102,13 +101,13 @@ inline BOOL is_approx_zero( F32 f ) { return (-F_APPROXIMATELY_ZERO < f) && (f <  inline BOOL is_approx_equal(F32 x, F32 y)  {  	const S32 COMPARE_MANTISSA_UP_TO_BIT = 0x02; -	return (abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT); +	return (std::abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);  }  inline BOOL is_approx_equal(F64 x, F64 y)  {  	const S64 COMPARE_MANTISSA_UP_TO_BIT = 0x02; -	return (abs((S32) ((U64&)x - (U64&)y) ) < COMPARE_MANTISSA_UP_TO_BIT); +	return (std::abs((S32) ((U64&)x - (U64&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);  }  inline BOOL is_approx_equal_fraction(F32 x, F32 y, U32 frac_bits) @@ -155,17 +154,17 @@ inline BOOL is_approx_equal_fraction(F64 x, F64 y, U32 frac_bits)  inline S32 llabs(const S32 a)  { -	return S32(labs(a)); +	return S32(std::labs(a));  }  inline F32 llabs(const F32 a)  { -	return F32(fabs(a)); +	return F32(std::fabs(a));  }  inline F64 llabs(const F64 a)  { -	return F64(fabs(a)); +	return F64(std::fabs(a));  }  inline S32 lltrunc( F32 f ) diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 80211fb0a2..25b7100eb7 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -37,7 +37,7 @@  #include <vector>  #include <set> -#ifdef LL_RELEASE_FOR_DOWNLOAD +#if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG  #define OCT_ERRS LL_WARNS("OctreeErrors")  #else  #define OCT_ERRS LL_ERRS("OctreeErrors") diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp index c3e84e366d..7711d0881d 100644 --- a/indra/llmath/llquaternion.cpp +++ b/indra/llmath/llquaternion.cpp @@ -791,7 +791,7 @@ LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order)  const char *OrderToString( const LLQuaternion::Order order )  { -	char *p = NULL; +	const char *p = NULL;  	switch( order )  	{  	default: diff --git a/indra/llmath/llsdutil_math.cpp b/indra/llmath/llsdutil_math.cpp new file mode 100644 index 0000000000..04b9d892e7 --- /dev/null +++ b/indra/llmath/llsdutil_math.cpp @@ -0,0 +1,172 @@ +/**  + * @file llsdutil_math.cpp + * @author Phoenix + * @date 2006-05-24 + * @brief Implementation of classes, functions, etc, for using structured data. + * + * $LicenseInfo:firstyear=2006&license=viewergpl$ + *  + * Copyright (c) 2006-2007, 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://secondlife.com/developers/opensource/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://secondlife.com/developers/opensource/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 "llsdutil.h" + +#include "v3math.h" +#include "v4math.h" +#include "v3dmath.h" +#include "v2math.h" +#include "llquaternion.h" +#include "v4color.h" + +#if LL_WINDOWS +#	define WIN32_LEAN_AND_MEAN +#	include <winsock2.h>	// for htonl +#elif LL_LINUX || LL_SOLARIS +#	include <netinet/in.h> +#elif LL_DARWIN +#	include <arpa/inet.h> +#endif + +#include "llsdserialize.h" + +// vector3 +LLSD ll_sd_from_vector3(const LLVector3& vec) +{ +	LLSD rv; +	rv.append((F64)vec.mV[VX]); +	rv.append((F64)vec.mV[VY]); +	rv.append((F64)vec.mV[VZ]); +	return rv; +} + +LLVector3 ll_vector3_from_sd(const LLSD& sd, S32 start_index) +{ +	LLVector3 rv; +	rv.mV[VX] = (F32)sd[start_index].asReal(); +	rv.mV[VY] = (F32)sd[++start_index].asReal(); +	rv.mV[VZ] = (F32)sd[++start_index].asReal(); +	return rv; +} + +// vector4 +LLSD ll_sd_from_vector4(const LLVector4& vec) +{ +	LLSD rv; +	rv.append((F64)vec.mV[VX]); +	rv.append((F64)vec.mV[VY]); +	rv.append((F64)vec.mV[VZ]); +	rv.append((F64)vec.mV[VW]); +	return rv; +} + +LLVector4 ll_vector4_from_sd(const LLSD& sd, S32 start_index) +{ +	LLVector4 rv; +	rv.mV[VX] = (F32)sd[start_index].asReal(); +	rv.mV[VY] = (F32)sd[++start_index].asReal(); +	rv.mV[VZ] = (F32)sd[++start_index].asReal(); +	rv.mV[VW] = (F32)sd[++start_index].asReal(); +	return rv; +} + +// vector3d +LLSD ll_sd_from_vector3d(const LLVector3d& vec) +{ +	LLSD rv; +	rv.append(vec.mdV[VX]); +	rv.append(vec.mdV[VY]); +	rv.append(vec.mdV[VZ]); +	return rv; +} + +LLVector3d ll_vector3d_from_sd(const LLSD& sd, S32 start_index) +{ +	LLVector3d rv; +	rv.mdV[VX] = sd[start_index].asReal(); +	rv.mdV[VY] = sd[++start_index].asReal(); +	rv.mdV[VZ] = sd[++start_index].asReal(); +	return rv; +} + +//vector2 +LLSD ll_sd_from_vector2(const LLVector2& vec) +{ +	LLSD rv; +	rv.append((F64)vec.mV[VX]); +	rv.append((F64)vec.mV[VY]); +	return rv; +} + +LLVector2 ll_vector2_from_sd(const LLSD& sd) +{ +	LLVector2 rv; +	rv.mV[VX] = (F32)sd[0].asReal(); +	rv.mV[VY] = (F32)sd[1].asReal(); +	return rv; +} + +// Quaternion +LLSD ll_sd_from_quaternion(const LLQuaternion& quat) +{ +	LLSD rv; +	rv.append((F64)quat.mQ[VX]); +	rv.append((F64)quat.mQ[VY]); +	rv.append((F64)quat.mQ[VZ]); +	rv.append((F64)quat.mQ[VW]); +	return rv; +} + +LLQuaternion ll_quaternion_from_sd(const LLSD& sd) +{ +	LLQuaternion quat; +	quat.mQ[VX] = (F32)sd[0].asReal(); +	quat.mQ[VY] = (F32)sd[1].asReal(); +	quat.mQ[VZ] = (F32)sd[2].asReal(); +	quat.mQ[VW] = (F32)sd[3].asReal(); +	return quat; +} + +// color4 +LLSD ll_sd_from_color4(const LLColor4& c) +{ +	LLSD rv; +	rv.append(c.mV[0]); +	rv.append(c.mV[1]); +	rv.append(c.mV[2]); +	rv.append(c.mV[3]); +	return rv; +} + +LLColor4 ll_color4_from_sd(const LLSD& sd) +{ +	LLColor4 c; +	c.mV[0] = (F32)sd[0].asReal(); +	c.mV[1] = (F32)sd[1].asReal(); +	c.mV[2] = (F32)sd[2].asReal(); +	c.mV[3] = (F32)sd[3].asReal(); +	return c; +} diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h index 56820148d5..e2a8274839 100644 --- a/indra/llmath/v3color.h +++ b/indra/llmath/v3color.h @@ -174,6 +174,10 @@ inline LLColor3::LLColor3(const F32 *vec)  	mV[VZ] = vec[VZ];  } +#if LL_WINDOWS +# pragma warning( disable : 4996 ) // strncpy teh sux0r +#endif +  inline LLColor3::LLColor3(char* color_string) // takes a string of format "RRGGBB" where RR is hex 00..FF   {  	if (strlen(color_string) <  6)		/* Flawfinder: ignore */  | 
