From 0b16411d302c940ff98ae5529821d9b5a4dbfbd7 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 26 Jan 2012 14:07:37 -0500 Subject: assert fix for mempyNonAliased16 call --- indra/llprimitive/llmodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index cb32a510b8..28ed051c55 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1026,7 +1026,8 @@ void LLModel::setVolumeFaceData( if (tc.get()) { - LLVector4a::memcpyNonAliased16((F32*) face.mTexCoords, (F32*) tc.get(), num_verts*2*sizeof(F32)); + U32 tex_size = (num_verts*2*sizeof(F32)+0xF)&~0xF; + LLVector4a::memcpyNonAliased16((F32*) face.mTexCoords, (F32*) tc.get(), tex_size); } else { -- cgit v1.2.3 From a0bab1952bfe09be49164bad0ab7205735109395 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Fri, 27 Jan 2012 16:12:50 -0500 Subject: BUILDFIX header file capitalization Will clean this up to be more in line with our standards later --- indra/llprimitive/llmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index cb32a510b8..768d3a6ae8 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -28,7 +28,7 @@ #include "llmodel.h" #include "llmemory.h" -#include "llconvexdecomposition.h" +#include "LLConvexDecomposition.h" #include "llsdserialize.h" #include "llvector4a.h" #if LL_MSVC -- cgit v1.2.3 From 4d77d3cca1c932516781222e0c8c14d27f876466 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 28 Feb 2012 19:07:44 -0800 Subject: PATH-199: Cleaning up code related to object flags so that I can better use the flags to managed pathfinding flags such as permanent and character. --- indra/llprimitive/object_flags.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/object_flags.h b/indra/llprimitive/object_flags.h index 94c559d757..2f07665e6f 100644 --- a/indra/llprimitive/object_flags.h +++ b/indra/llprimitive/object_flags.h @@ -41,28 +41,19 @@ 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; -- cgit v1.2.3 From 07545e99fcb70c8bce34fc7a8c5a84c40f39174a Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 29 Feb 2012 13:09:28 -0500 Subject: SH-2689 FIX - a bit more logging and related cleanup. Somewhat arbitrarily calling this done, although tweaks will be ongoing --- indra/llprimitive/llprimitive.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 indra/llprimitive/llprimitive.cpp (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp old mode 100644 new mode 100755 -- cgit v1.2.3 From 894d79e4ecccda85e357f859c666031cc138e34b Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 29 Feb 2012 12:34:28 -0800 Subject: PATH-199: More cleanup of object flags and syncing with definitions from the server-side using left-shifted bits instead 0x explicits for better human readability. --- indra/llprimitive/object_flags.h | 146 ++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 71 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/object_flags.h b/indra/llprimitive/object_flags.h index 2f07665e6f..278ab12aa3 100644 --- a/indra/llprimitive/object_flags.h +++ b/indra/llprimitive/object_flags.h @@ -1,71 +1,75 @@ -/** - * @file object_flags.h - * @brief Flags for object creation and transmission - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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_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_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_CAMERA_DECOUPLED = 0x00100000; -const U32 FLAGS_ANIM_SOURCE = 0x00200000; -const U32 FLAGS_CAMERA_SOURCE = 0x00400000; - -const U32 FLAGS_OBJECT_OWNER_MODIFY = 0x10000000; - -const U32 FLAGS_TEMPORARY_ON_REZ = 0x20000000; - -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 - +/** + * @file object_flags.h + * @brief Flags for object creation and transmission + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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_OBJECT_FLAGS_H +#define LL_OBJECT_FLAGS_H + +// downstream flags from sim->viewer +const U32 FLAGS_USE_PHYSICS = (1U << 0); +const U32 FLAGS_CREATE_SELECTED = (1U << 1); +const U32 FLAGS_OBJECT_MODIFY = (1U << 2); +const U32 FLAGS_OBJECT_COPY = (1U << 3); +const U32 FLAGS_OBJECT_ANY_OWNER = (1U << 4); +const U32 FLAGS_OBJECT_YOU_OWNER = (1U << 5); +const U32 FLAGS_SCRIPTED = (1U << 6); +const U32 FLAGS_HANDLE_TOUCH = (1U << 7); +const U32 FLAGS_OBJECT_MOVE = (1U << 8); +const U32 FLAGS_TAKES_MONEY = (1U << 9); +const U32 FLAGS_PHANTOM = (1U << 10); +const U32 FLAGS_INVENTORY_EMPTY = (1U << 11); +//const U32 FLAGS_UNUSED_000 = (1U << 12); // was FLAGS_JOINT_HINGE +//const U32 FLAGS_UNUSED_001 = (1U << 13); // was FLAGS_JOINT_P2P +//const U32 FLAGS_UNUSED_002 = (1U << 14); // was FLAGS_JOINT_LP2P +const U32 FLAGS_INCLUDE_IN_SEARCH = (1U << 15); +const U32 FLAGS_ALLOW_INVENTORY_DROP = (1U << 16); +const U32 FLAGS_OBJECT_TRANSFER = (1U << 17); +const U32 FLAGS_OBJECT_GROUP_OWNED = (1U << 18); +//const U32 FLAGS_UNUSED_003 = (1U << 19); // was FLAGS_OBJECT_YOU_OFFICER +const U32 FLAGS_CAMERA_DECOUPLED = (1U << 20); +const U32 FLAGS_ANIM_SOURCE = (1U << 21); +const U32 FLAGS_CAMERA_SOURCE = (1U << 22); +//const U32 FLAGS_UNUSED_004 = (1U << 23); // was FLAGS_CAST_SHADOWS +//const U32 FLAGS_UNUSED_005 = (1U << 24); +//const U32 FLAGS_UNUSED_006 = (1U << 25); +//const U32 FLAGS_UNUSED_007 = (1U << 26); +//const U32 FLAGS_UNUSED_008 = (1U << 27); +const U32 FLAGS_OBJECT_OWNER_MODIFY = (1U << 28); +const U32 FLAGS_TEMPORARY_ON_REZ = (1U << 29); +//const U32 FLAGS_UNUSED_009 = (1U << 30); // was FLAGS_TEMPORARY +//const U32 FLAGS_UNUSED_010 = (1U << 31); // was FLAGS_ZLIB_COMPRESSED +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 -- cgit v1.2.3 From 3d237bd242c01895c8122b0a2fda3e305992fd1b Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 29 Feb 2012 14:41:47 -0800 Subject: PATH-199: Starting to introducing the pathfinding flags for the object. --- indra/llprimitive/object_flags.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/object_flags.h b/indra/llprimitive/object_flags.h index 278ab12aa3..f7f6841b53 100644 --- a/indra/llprimitive/object_flags.h +++ b/indra/llprimitive/object_flags.h @@ -40,26 +40,26 @@ const U32 FLAGS_OBJECT_MOVE = (1U << 8); const U32 FLAGS_TAKES_MONEY = (1U << 9); const U32 FLAGS_PHANTOM = (1U << 10); const U32 FLAGS_INVENTORY_EMPTY = (1U << 11); -//const U32 FLAGS_UNUSED_000 = (1U << 12); // was FLAGS_JOINT_HINGE -//const U32 FLAGS_UNUSED_001 = (1U << 13); // was FLAGS_JOINT_P2P -//const U32 FLAGS_UNUSED_002 = (1U << 14); // was FLAGS_JOINT_LP2P +const U32 FLAGS_OBJECT_PERMANENT = (1U << 12); +const U32 FLAGS_CHARACTER = (1U << 13); +//const U32 FLAGS_UNUSED_000 = (1U << 14); // was FLAGS_JOINT_LP2P const U32 FLAGS_INCLUDE_IN_SEARCH = (1U << 15); const U32 FLAGS_ALLOW_INVENTORY_DROP = (1U << 16); const U32 FLAGS_OBJECT_TRANSFER = (1U << 17); const U32 FLAGS_OBJECT_GROUP_OWNED = (1U << 18); -//const U32 FLAGS_UNUSED_003 = (1U << 19); // was FLAGS_OBJECT_YOU_OFFICER +//const U32 FLAGS_UNUSED_001 = (1U << 19); // was FLAGS_OBJECT_YOU_OFFICER const U32 FLAGS_CAMERA_DECOUPLED = (1U << 20); const U32 FLAGS_ANIM_SOURCE = (1U << 21); const U32 FLAGS_CAMERA_SOURCE = (1U << 22); -//const U32 FLAGS_UNUSED_004 = (1U << 23); // was FLAGS_CAST_SHADOWS -//const U32 FLAGS_UNUSED_005 = (1U << 24); -//const U32 FLAGS_UNUSED_006 = (1U << 25); -//const U32 FLAGS_UNUSED_007 = (1U << 26); -//const U32 FLAGS_UNUSED_008 = (1U << 27); +//const U32 FLAGS_UNUSED_002 = (1U << 23); // was FLAGS_CAST_SHADOWS +//const U32 FLAGS_UNUSED_003 = (1U << 24); +//const U32 FLAGS_UNUSED_004 = (1U << 25); +//const U32 FLAGS_UNUSED_005 = (1U << 26); +//const U32 FLAGS_UNUSED_006 = (1U << 27); const U32 FLAGS_OBJECT_OWNER_MODIFY = (1U << 28); const U32 FLAGS_TEMPORARY_ON_REZ = (1U << 29); -//const U32 FLAGS_UNUSED_009 = (1U << 30); // was FLAGS_TEMPORARY -//const U32 FLAGS_UNUSED_010 = (1U << 31); // was FLAGS_ZLIB_COMPRESSED +//const U32 FLAGS_UNUSED_007 = (1U << 30); // was FLAGS_TEMPORARY +//const U32 FLAGS_UNUSED_008 = (1U << 31); // was FLAGS_ZLIB_COMPRESSED const U32 FLAGS_LOCAL = FLAGS_ANIM_SOURCE | FLAGS_CAMERA_SOURCE; typedef enum e_havok_joint_type -- cgit v1.2.3 From 1cdef4903daea1622923550b1328b659a594b029 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 18 Apr 2012 16:03:33 -0700 Subject: Updating to the latest llphysicextensions pre-built package with the now lowercased version of the header file names. --- indra/llprimitive/llmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 768d3a6ae8..cb32a510b8 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -28,7 +28,7 @@ #include "llmodel.h" #include "llmemory.h" -#include "LLConvexDecomposition.h" +#include "llconvexdecomposition.h" #include "llsdserialize.h" #include "llvector4a.h" #if LL_MSVC -- cgit v1.2.3 From cbebd682f7b9b0cff120bc36d9db9bb170dc1b2a Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 25 Apr 2012 13:04:13 -0700 Subject: Removing windows line endings from .h and .cpp files. --- indra/llprimitive/object_flags.h | 150 +++++++++++++++++++-------------------- 1 file changed, 75 insertions(+), 75 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/object_flags.h b/indra/llprimitive/object_flags.h index f7f6841b53..b06a5ad4e3 100644 --- a/indra/llprimitive/object_flags.h +++ b/indra/llprimitive/object_flags.h @@ -1,75 +1,75 @@ -/** - * @file object_flags.h - * @brief Flags for object creation and transmission - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, 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_OBJECT_FLAGS_H -#define LL_OBJECT_FLAGS_H - -// downstream flags from sim->viewer -const U32 FLAGS_USE_PHYSICS = (1U << 0); -const U32 FLAGS_CREATE_SELECTED = (1U << 1); -const U32 FLAGS_OBJECT_MODIFY = (1U << 2); -const U32 FLAGS_OBJECT_COPY = (1U << 3); -const U32 FLAGS_OBJECT_ANY_OWNER = (1U << 4); -const U32 FLAGS_OBJECT_YOU_OWNER = (1U << 5); -const U32 FLAGS_SCRIPTED = (1U << 6); -const U32 FLAGS_HANDLE_TOUCH = (1U << 7); -const U32 FLAGS_OBJECT_MOVE = (1U << 8); -const U32 FLAGS_TAKES_MONEY = (1U << 9); -const U32 FLAGS_PHANTOM = (1U << 10); -const U32 FLAGS_INVENTORY_EMPTY = (1U << 11); -const U32 FLAGS_OBJECT_PERMANENT = (1U << 12); -const U32 FLAGS_CHARACTER = (1U << 13); -//const U32 FLAGS_UNUSED_000 = (1U << 14); // was FLAGS_JOINT_LP2P -const U32 FLAGS_INCLUDE_IN_SEARCH = (1U << 15); -const U32 FLAGS_ALLOW_INVENTORY_DROP = (1U << 16); -const U32 FLAGS_OBJECT_TRANSFER = (1U << 17); -const U32 FLAGS_OBJECT_GROUP_OWNED = (1U << 18); -//const U32 FLAGS_UNUSED_001 = (1U << 19); // was FLAGS_OBJECT_YOU_OFFICER -const U32 FLAGS_CAMERA_DECOUPLED = (1U << 20); -const U32 FLAGS_ANIM_SOURCE = (1U << 21); -const U32 FLAGS_CAMERA_SOURCE = (1U << 22); -//const U32 FLAGS_UNUSED_002 = (1U << 23); // was FLAGS_CAST_SHADOWS -//const U32 FLAGS_UNUSED_003 = (1U << 24); -//const U32 FLAGS_UNUSED_004 = (1U << 25); -//const U32 FLAGS_UNUSED_005 = (1U << 26); -//const U32 FLAGS_UNUSED_006 = (1U << 27); -const U32 FLAGS_OBJECT_OWNER_MODIFY = (1U << 28); -const U32 FLAGS_TEMPORARY_ON_REZ = (1U << 29); -//const U32 FLAGS_UNUSED_007 = (1U << 30); // was FLAGS_TEMPORARY -//const U32 FLAGS_UNUSED_008 = (1U << 31); // was FLAGS_ZLIB_COMPRESSED -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 +/** + * @file object_flags.h + * @brief Flags for object creation and transmission + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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_OBJECT_FLAGS_H +#define LL_OBJECT_FLAGS_H + +// downstream flags from sim->viewer +const U32 FLAGS_USE_PHYSICS = (1U << 0); +const U32 FLAGS_CREATE_SELECTED = (1U << 1); +const U32 FLAGS_OBJECT_MODIFY = (1U << 2); +const U32 FLAGS_OBJECT_COPY = (1U << 3); +const U32 FLAGS_OBJECT_ANY_OWNER = (1U << 4); +const U32 FLAGS_OBJECT_YOU_OWNER = (1U << 5); +const U32 FLAGS_SCRIPTED = (1U << 6); +const U32 FLAGS_HANDLE_TOUCH = (1U << 7); +const U32 FLAGS_OBJECT_MOVE = (1U << 8); +const U32 FLAGS_TAKES_MONEY = (1U << 9); +const U32 FLAGS_PHANTOM = (1U << 10); +const U32 FLAGS_INVENTORY_EMPTY = (1U << 11); +const U32 FLAGS_OBJECT_PERMANENT = (1U << 12); +const U32 FLAGS_CHARACTER = (1U << 13); +//const U32 FLAGS_UNUSED_000 = (1U << 14); // was FLAGS_JOINT_LP2P +const U32 FLAGS_INCLUDE_IN_SEARCH = (1U << 15); +const U32 FLAGS_ALLOW_INVENTORY_DROP = (1U << 16); +const U32 FLAGS_OBJECT_TRANSFER = (1U << 17); +const U32 FLAGS_OBJECT_GROUP_OWNED = (1U << 18); +//const U32 FLAGS_UNUSED_001 = (1U << 19); // was FLAGS_OBJECT_YOU_OFFICER +const U32 FLAGS_CAMERA_DECOUPLED = (1U << 20); +const U32 FLAGS_ANIM_SOURCE = (1U << 21); +const U32 FLAGS_CAMERA_SOURCE = (1U << 22); +//const U32 FLAGS_UNUSED_002 = (1U << 23); // was FLAGS_CAST_SHADOWS +//const U32 FLAGS_UNUSED_003 = (1U << 24); +//const U32 FLAGS_UNUSED_004 = (1U << 25); +//const U32 FLAGS_UNUSED_005 = (1U << 26); +//const U32 FLAGS_UNUSED_006 = (1U << 27); +const U32 FLAGS_OBJECT_OWNER_MODIFY = (1U << 28); +const U32 FLAGS_TEMPORARY_ON_REZ = (1U << 29); +//const U32 FLAGS_UNUSED_007 = (1U << 30); // was FLAGS_TEMPORARY +//const U32 FLAGS_UNUSED_008 = (1U << 31); // was FLAGS_ZLIB_COMPRESSED +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 -- cgit v1.2.3 From e4a0dda457039b1a04c74024d9fbcf02e071b13d Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 28 Jun 2012 14:24:04 -0400 Subject: SH-3228 WIP - always respond to processAppearance for self, convert baked textures to checkerboards --- indra/llprimitive/llprimitive.cpp | 17 +++++++++++++---- indra/llprimitive/llprimitive.h | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) mode change 100644 => 100755 indra/llprimitive/llprimitive.h (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 30532247ac..c766d8a43c 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -39,6 +39,7 @@ #include "lldatapacker.h" #include "llsdutil_math.h" #include "llprimtexturelist.h" +#include "imageids.h" /** * exported constants @@ -1227,12 +1228,12 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const return FALSE; } -S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name) +S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, bool fake_images) { - return(unpackTEMessage(mesgsys,block_name,-1)); + return(unpackTEMessage(mesgsys,block_name,-1,fake_images)); } -S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num) +S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images) { // use a negative block_num to indicate a single-block read (a non-variable block) S32 retval = 0; @@ -1307,7 +1308,15 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam LLColor4U coloru; for (U32 i = 0; i < face_count; i++) { - retval |= setTETexture(i, ((LLUUID*)image_data)[i]); + LLUUID& req_id = ((LLUUID*)image_data)[i]; + if (fake_images & (req_id != IMG_DEFAULT) && (req_id != IMG_DEFAULT_AVATAR) && (req_id != IMG_INVISIBLE)) + { + retval |= setTETexture(i, IMG_CHECKERBOARD_RGBA); + } + else + { + retval |= setTETexture(i, req_id); + } retval |= setTEScale(i, scale_s[i], scale_t[i]); retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF); retval |= setTERotation(i, ((F32)image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI); diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h old mode 100644 new mode 100755 index 998016f8f6..1e985221c0 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -360,8 +360,8 @@ public: 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 const* block_name); - S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num); // Variable num of blocks + S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, bool fake_images = false); + S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images = false); // Variable num of blocks BOOL unpackTEMessage(LLDataPacker &dp); #ifdef CHECK_FOR_FINITE -- cgit v1.2.3 From 4a5ad357930f0bede4d84b9810978e9d0c5d268b Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 20 Jul 2012 11:42:15 -0500 Subject: MAINT-570 Remove unused memory tracking system LLMemType --- indra/llprimitive/llprimitive.cpp | 4 ---- indra/llprimitive/llprimtexturelist.cpp | 2 -- 2 files changed, 6 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 30532247ac..9572378b46 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -27,7 +27,6 @@ #include "linden_common.h" #include "material_codes.h" -#include "llmemtype.h" #include "llerror.h" #include "message.h" #include "llprimitive.h" @@ -188,7 +187,6 @@ void LLPrimitive::clearTextureList() // static LLPrimitive *LLPrimitive::createPrimitive(LLPCode p_code) { - LLMemType m1(LLMemType::MTYPE_PRIMITIVE); LLPrimitive *retval = new LLPrimitive(); if (retval) @@ -206,7 +204,6 @@ LLPrimitive *LLPrimitive::createPrimitive(LLPCode p_code) //=============================================================== void LLPrimitive::init_primitive(LLPCode p_code) { - LLMemType m1(LLMemType::MTYPE_PRIMITIVE); clearTextureList(); mPrimitiveCode = p_code; } @@ -698,7 +695,6 @@ S32 face_index_from_id(LLFaceID face_ID, const std::vector& fac BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume) { - LLMemType m1(LLMemType::MTYPE_VOLUME); LLVolume *volumep; if (unique_volume) { diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 36e04df7b7..7ef87ed382 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -28,7 +28,6 @@ #include "llprimtexturelist.h" #include "lltextureentry.h" -#include "llmemtype.h" // static //int (TMyClass::*pt2Member)(float, char, char) = NULL; // C++ @@ -367,7 +366,6 @@ S32 LLPrimTextureList::size() const // sets the size of the mEntryList container void LLPrimTextureList::setSize(S32 new_size) { - LLMemType m1(LLMemType::MTYPE_PRIMITIVE); if (new_size < 0) { new_size = 0; -- cgit v1.2.3 From 702e6815ed70cb210dc2a014237e0c15a2a69045 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 5 Jul 2012 12:16:48 -0400 Subject: partial changes for building with the llphysicsextensions source package --- indra/llprimitive/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 7d0e313ff3..e4d9de7eb6 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -7,12 +7,14 @@ include(LLCommon) include(LLMath) include(LLMessage) include(LLXML) +include(LLPhysicsExtensions) include_directories( ${LLCOMMON_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS} + ${LLPHYSICSEXTENSIONS_INCLUDE_DIRS} ${LIBS_PREBUILT_DIR}/include/collada ${LIBS_PREBUILT_DIR}/include/collada/1.4 ) -- cgit v1.2.3 From 90fdf60d697f5c1e451a41eff0c6856e36cf1b64 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 12 Jul 2012 14:12:58 -0700 Subject: PATH-807: Adding an additional check for if the object is marked as volume-detect. Note that this will require Andrew's corresponding server-side change to take effect. However, the viewer change alone should have no neative effect prior to the server being updated. --- indra/llprimitive/object_flags.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/object_flags.h b/indra/llprimitive/object_flags.h index b06a5ad4e3..31dbd15ae0 100644 --- a/indra/llprimitive/object_flags.h +++ b/indra/llprimitive/object_flags.h @@ -40,26 +40,34 @@ const U32 FLAGS_OBJECT_MOVE = (1U << 8); const U32 FLAGS_TAKES_MONEY = (1U << 9); const U32 FLAGS_PHANTOM = (1U << 10); const U32 FLAGS_INVENTORY_EMPTY = (1U << 11); -const U32 FLAGS_OBJECT_PERMANENT = (1U << 12); + +const U32 FLAGS_AFFECTS_NAVMESH = (1U << 12); const U32 FLAGS_CHARACTER = (1U << 13); -//const U32 FLAGS_UNUSED_000 = (1U << 14); // was FLAGS_JOINT_LP2P +const U32 FLAGS_VOLUME_DETECT = (1U << 14); const U32 FLAGS_INCLUDE_IN_SEARCH = (1U << 15); + const U32 FLAGS_ALLOW_INVENTORY_DROP = (1U << 16); const U32 FLAGS_OBJECT_TRANSFER = (1U << 17); const U32 FLAGS_OBJECT_GROUP_OWNED = (1U << 18); -//const U32 FLAGS_UNUSED_001 = (1U << 19); // was FLAGS_OBJECT_YOU_OFFICER +//const U32 FLAGS_UNUSED_000 = (1U << 19); // was FLAGS_OBJECT_YOU_OFFICER + const U32 FLAGS_CAMERA_DECOUPLED = (1U << 20); const U32 FLAGS_ANIM_SOURCE = (1U << 21); const U32 FLAGS_CAMERA_SOURCE = (1U << 22); -//const U32 FLAGS_UNUSED_002 = (1U << 23); // was FLAGS_CAST_SHADOWS -//const U32 FLAGS_UNUSED_003 = (1U << 24); -//const U32 FLAGS_UNUSED_004 = (1U << 25); -//const U32 FLAGS_UNUSED_005 = (1U << 26); -//const U32 FLAGS_UNUSED_006 = (1U << 27); + +//const U32 FLAGS_UNUSED_001 = (1U << 23); // was FLAGS_CAST_SHADOWS + +//const U32 FLAGS_UNUSED_002 = (1U << 24); +//const U32 FLAGS_UNUSED_003 = (1U << 25); +//const U32 FLAGS_UNUSED_004 = (1U << 26); +//const U32 FLAGS_UNUSED_005 = (1U << 27); + const U32 FLAGS_OBJECT_OWNER_MODIFY = (1U << 28); + const U32 FLAGS_TEMPORARY_ON_REZ = (1U << 29); -//const U32 FLAGS_UNUSED_007 = (1U << 30); // was FLAGS_TEMPORARY -//const U32 FLAGS_UNUSED_008 = (1U << 31); // was FLAGS_ZLIB_COMPRESSED +//const U32 FLAGS_UNUSED_006 = (1U << 30); // was FLAGS_TEMPORARY +//const U32 FLAGS_UNUSED_007 = (1U << 31); // was FLAGS_ZLIB_COMPRESSED + const U32 FLAGS_LOCAL = FLAGS_ANIM_SOURCE | FLAGS_CAMERA_SOURCE; typedef enum e_havok_joint_type -- cgit v1.2.3 From 27c7b259b417d5843422e8bd4e8e480a186e44f4 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 12 Jul 2012 18:24:23 -0400 Subject: SH-3267 WIP --- indra/llprimitive/llprimitive.cpp | 107 +++++++++++++++++++++++++++++++++++++- indra/llprimitive/llprimitive.h | 31 ++++++++++- 2 files changed, 135 insertions(+), 3 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index c766d8a43c..0388e2c020 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1228,11 +1228,113 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const return FALSE; } -S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, bool fake_images) +S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images, + LLTEContents& tec) { - return(unpackTEMessage(mesgsys,block_name,-1,fake_images)); + tec.fake_images = fake_images; + + S32 retval = 0; + + if (block_num < 0) + { + tec.size = mesgsys->getSizeFast(block_name, _PREHASH_TextureEntry); + } + else + { + tec.size = mesgsys->getSizeFast(block_name, block_num, _PREHASH_TextureEntry); + } + + if (tec.size == 0) + { + return retval; + } + + if (block_num < 0) + { + mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, 0, LLTEContents::MAX_TE_BUFFER); + } + else + { + mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, block_num, LLTEContents::MAX_TE_BUFFER); + } + + tec.face_count = getNumTEs(); + + U8 *cur_ptr = tec.packed_buffer; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_data, 16, tec.face_count, MVT_LLUUID); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.colors, 4, tec.face_count, MVT_U8); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.scale_s, 4, tec.face_count, MVT_F32); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.scale_t, 4, tec.face_count, MVT_F32); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.offset_s, 2, tec.face_count, MVT_S16Array); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.offset_t, 2, tec.face_count, MVT_S16Array); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_rot, 2, tec.face_count, MVT_S16Array); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.bump, 1, tec.face_count, MVT_U8); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.media_flags, 1, tec.face_count, MVT_U8); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.glow, 1, tec.face_count, MVT_U8); + + retval = 1; + return retval; +} + +S32 LLPrimitive::unpackParsedTEMessage(LLTEContents& tec) +{ + S32 retval = 0; + + LLColor4 color; + LLColor4U coloru; + for (U32 i = 0; i < tec.face_count; i++) + { + LLUUID& req_id = ((LLUUID*)tec.image_data)[i]; + if (tec.fake_images & (req_id != IMG_DEFAULT) && (req_id != IMG_DEFAULT_AVATAR) && (req_id != IMG_INVISIBLE)) + { + retval |= setTETexture(i, IMG_CHECKERBOARD_RGBA); + } + else + { + retval |= setTETexture(i, req_id); + } + retval |= setTEScale(i, tec.scale_s[i], tec.scale_t[i]); + retval |= setTEOffset(i, (F32)tec.offset_s[i] / (F32)0x7FFF, (F32) tec.offset_t[i] / (F32) 0x7FFF); + retval |= setTERotation(i, ((F32)tec.image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI); + retval |= setTEBumpShinyFullbright(i, tec.bump[i]); + retval |= setTEMediaTexGen(i, tec.media_flags[i]); + retval |= setTEGlow(i, (F32)tec.glow[i] / (F32)0xFF); + coloru = LLColor4U(tec.colors + 4*i); + + // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) + // as all zeros. However, the subtraction and addition must be done in unsigned + // byte space, not in float space, otherwise off-by-one errors occur. JC + color.mV[VRED] = F32(255 - coloru.mV[VRED]) / 255.f; + color.mV[VGREEN] = F32(255 - coloru.mV[VGREEN]) / 255.f; + color.mV[VBLUE] = F32(255 - coloru.mV[VBLUE]) / 255.f; + color.mV[VALPHA] = F32(255 - coloru.mV[VALPHA]) / 255.f; + + retval |= setTEColor(i, color); + + } + + return retval; +} + +S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images) +{ + LLTEContents tec; + S32 retval = parseTEMessage(mesgsys, block_name, block_num, fake_images, tec); + if (!retval) + return retval; + return unpackParsedTEMessage(tec); } +#if 0 S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images) { // use a negative block_num to indicate a single-block read (a non-variable block) @@ -1339,6 +1441,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam return retval; } +#endif S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) { diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 1e985221c0..19ef3faf3f 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -289,6 +289,34 @@ public: }; +struct LLTEContents +{ + LLTEContents() + { + } + + static const U32 MAX_TES = 32; + + U8 image_data[MAX_TES*16]; + U8 colors[MAX_TES*4]; + F32 scale_s[MAX_TES]; + F32 scale_t[MAX_TES]; + S16 offset_s[MAX_TES]; + S16 offset_t[MAX_TES]; + S16 image_rot[MAX_TES]; + U8 bump[MAX_TES]; + U8 media_flags[MAX_TES]; + U8 glow[MAX_TES]; + + static const U32 MAX_TE_BUFFER = 4096; + U8 packed_buffer[MAX_TE_BUFFER]; + + U32 size; + U32 face_count; + + bool fake_images; +}; + class LLPrimitive : public LLXform { public: @@ -360,9 +388,10 @@ public: 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 const* block_name, bool fake_images = false); S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images = false); // Variable num of blocks BOOL unpackTEMessage(LLDataPacker &dp); + S32 parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images,LLTEContents& tec); + S32 unpackParsedTEMessage(LLTEContents& tec); #ifdef CHECK_FOR_FINITE inline void setPosition(const LLVector3& pos); -- cgit v1.2.3 From 409be9dcc4e372385f0fb0de274a4b17913bd124 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 13 Jul 2012 16:59:57 -0400 Subject: SH-3267 WIP - extract cof version from avatar appearance message, use to reject stale updates --- indra/llprimitive/llprimitive.cpp | 131 ++------------------------------------ indra/llprimitive/llprimitive.h | 18 +++--- 2 files changed, 15 insertions(+), 134 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 0388e2c020..97a382634a 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1228,11 +1228,8 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const return FALSE; } -S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images, - LLTEContents& tec) +S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec) { - tec.fake_images = fake_images; - S32 retval = 0; if (block_num < 0) @@ -1285,7 +1282,7 @@ S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name return retval; } -S32 LLPrimitive::unpackParsedTEMessage(LLTEContents& tec) +S32 LLPrimitive::applyParsedTEMessage(LLTEContents& tec) { S32 retval = 0; @@ -1294,14 +1291,7 @@ S32 LLPrimitive::unpackParsedTEMessage(LLTEContents& tec) for (U32 i = 0; i < tec.face_count; i++) { LLUUID& req_id = ((LLUUID*)tec.image_data)[i]; - if (tec.fake_images & (req_id != IMG_DEFAULT) && (req_id != IMG_DEFAULT_AVATAR) && (req_id != IMG_INVISIBLE)) - { - retval |= setTETexture(i, IMG_CHECKERBOARD_RGBA); - } - else - { - retval |= setTETexture(i, req_id); - } + retval |= setTETexture(i, req_id); retval |= setTEScale(i, tec.scale_s[i], tec.scale_t[i]); retval |= setTEOffset(i, (F32)tec.offset_s[i] / (F32)0x7FFF, (F32) tec.offset_t[i] / (F32) 0x7FFF); retval |= setTERotation(i, ((F32)tec.image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI); @@ -1325,123 +1315,14 @@ S32 LLPrimitive::unpackParsedTEMessage(LLTEContents& tec) return retval; } -S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images) +S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num) { LLTEContents tec; - S32 retval = parseTEMessage(mesgsys, block_name, block_num, fake_images, tec); + S32 retval = parseTEMessage(mesgsys, block_name, block_num, tec); if (!retval) return retval; - return unpackParsedTEMessage(tec); -} - -#if 0 -S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images) -{ - // use a negative block_num to indicate a single-block read (a non-variable block) - S32 retval = 0; - const U32 MAX_TES = 32; - - // Avoid construction of 32 UUIDs per call. JC - - U8 image_data[MAX_TES*16]; - U8 colors[MAX_TES*4]; - F32 scale_s[MAX_TES]; - F32 scale_t[MAX_TES]; - S16 offset_s[MAX_TES]; - S16 offset_t[MAX_TES]; - S16 image_rot[MAX_TES]; - U8 bump[MAX_TES]; - U8 media_flags[MAX_TES]; - U8 glow[MAX_TES]; - - const U32 MAX_TE_BUFFER = 4096; - U8 packed_buffer[MAX_TE_BUFFER]; - U8 *cur_ptr = packed_buffer; - - U32 size; - U32 face_count = 0; - - if (block_num < 0) - { - size = mesgsys->getSizeFast(block_name, _PREHASH_TextureEntry); - } - else - { - size = mesgsys->getSizeFast(block_name, block_num, _PREHASH_TextureEntry); - } - - if (size == 0) - { - return retval; - } - - if (block_num < 0) - { - mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, packed_buffer, 0, 0, MAX_TE_BUFFER); - } - else - { - mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, packed_buffer, 0, block_num, MAX_TE_BUFFER); - } - - face_count = getNumTEs(); - - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_data, 16, face_count, MVT_LLUUID); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)colors, 4, face_count, MVT_U8); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_s, 4, face_count, MVT_F32); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_t, 4, face_count, MVT_F32); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_s, 2, face_count, MVT_S16Array); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_t, 2, face_count, MVT_S16Array); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_rot, 2, face_count, MVT_S16Array); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)bump, 1, face_count, MVT_U8); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); - - LLColor4 color; - LLColor4U coloru; - for (U32 i = 0; i < face_count; i++) - { - LLUUID& req_id = ((LLUUID*)image_data)[i]; - if (fake_images & (req_id != IMG_DEFAULT) && (req_id != IMG_DEFAULT_AVATAR) && (req_id != IMG_INVISIBLE)) - { - retval |= setTETexture(i, IMG_CHECKERBOARD_RGBA); - } - else - { - retval |= setTETexture(i, req_id); - } - retval |= setTEScale(i, scale_s[i], scale_t[i]); - retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF); - retval |= setTERotation(i, ((F32)image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI); - retval |= setTEBumpShinyFullbright(i, bump[i]); - retval |= setTEMediaTexGen(i, media_flags[i]); - retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); - coloru = LLColor4U(colors + 4*i); - - // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) - // as all zeros. However, the subtraction and addition must be done in unsigned - // byte space, not in float space, otherwise off-by-one errors occur. JC - color.mV[VRED] = F32(255 - coloru.mV[VRED]) / 255.f; - color.mV[VGREEN] = F32(255 - coloru.mV[VGREEN]) / 255.f; - color.mV[VBLUE] = F32(255 - coloru.mV[VBLUE]) / 255.f; - color.mV[VALPHA] = F32(255 - coloru.mV[VALPHA]) / 255.f; - - retval |= setTEColor(i, color); - - } - - return retval; + return applyParsedTEMessage(tec); } -#endif S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) { diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 19ef3faf3f..d9333140a3 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -289,12 +289,14 @@ public: }; +// This code is not naming-standards compliant. Leaving it like this for +// now to make the connection to code in +// BOOL packTEMessage(LLDataPacker &dp) const; +// more obvious. This should be refactored to remove the duplication, at which +// point we can fix the names as well. +// - Vir struct LLTEContents { - LLTEContents() - { - } - static const U32 MAX_TES = 32; U8 image_data[MAX_TES*16]; @@ -313,8 +315,6 @@ struct LLTEContents U32 size; U32 face_count; - - bool fake_images; }; class LLPrimitive : public LLXform @@ -388,10 +388,10 @@ public: 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 const* block_name, const S32 block_num, bool fake_images = false); // Variable num of blocks + S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num); // Variable num of blocks BOOL unpackTEMessage(LLDataPacker &dp); - S32 parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, bool fake_images,LLTEContents& tec); - S32 unpackParsedTEMessage(LLTEContents& tec); + S32 parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec); + S32 applyParsedTEMessage(LLTEContents& tec); #ifdef CHECK_FOR_FINITE inline void setPosition(const LLVector3& pos); -- cgit v1.2.3 From 833d73d6747e6983e21ba7716a704c01c95d6a73 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 13 Jul 2012 17:46:43 -0600 Subject: fix for SH-3235: Bump maps are not loaded until objects change LOD --- indra/llprimitive/llprimitive.cpp | 31 +++++++++++++++++++++++++++++-- indra/llprimitive/llprimitive.h | 7 ++++++- 2 files changed, 35 insertions(+), 3 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 30532247ac..6dee192783 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -149,7 +149,8 @@ bool LLPrimitive::cleanupVolumeManager() LLPrimitive::LLPrimitive() : mTextureList(), mNumTEs(0), - mMiscFlags(0) + mMiscFlags(0), + mNumBumpmapTEs(0) { mPrimitiveCode = 0; @@ -237,7 +238,10 @@ void LLPrimitive::setAllTETextures(const LLUUID &tex_id) //=============================================================== void LLPrimitive::setTE(const U8 index, const LLTextureEntry& te) { - mTextureList.copyTexture(index, te); + if(mTextureList.copyTexture(index, te) != TEM_CHANGE_NONE && te.getBumpmap() > 0) + { + mNumBumpmapTEs++; + } } S32 LLPrimitive::setTETexture(const U8 index, const LLUUID &id) @@ -316,6 +320,7 @@ S32 LLPrimitive::setTERotation(const U8 index, const F32 r) //=============================================================== S32 LLPrimitive::setTEBumpShinyFullbright(const U8 index, const U8 bump) { + updateNumBumpmap(index, bump); return mTextureList.setBumpShinyFullbright(index, bump); } @@ -326,11 +331,13 @@ S32 LLPrimitive::setTEMediaTexGen(const U8 index, const U8 media) S32 LLPrimitive::setTEBumpmap(const U8 index, const U8 bump) { + updateNumBumpmap(index, bump); return mTextureList.setBumpMap(index, bump); } S32 LLPrimitive::setTEBumpShiny(const U8 index, const U8 bump_shiny) { + updateNumBumpmap(index, bump_shiny); return mTextureList.setBumpShiny(index, bump_shiny); } @@ -1445,6 +1452,26 @@ void LLPrimitive::takeTextureList(LLPrimTextureList& other_list) mTextureList.take(other_list); } +void LLPrimitive::updateNumBumpmap(const U8 index, const U8 bump) +{ + LLTextureEntry* te = getTE(index); + if(!te) + { + return; + } + + U8 old_bump = te->getBumpmap(); + if(old_bump > 0) + { + mNumBumpmapTEs--; + } + if((bump & TEM_BUMP_MASK) > 0) + { + mNumBumpmapTEs++; + } + + return; +} //============================================================================ // Moved from llselectmgr.cpp diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 998016f8f6..8dcaa8c740 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -421,7 +421,8 @@ public: inline BOOL isAvatar() const; inline BOOL isSittingAvatar() const; inline BOOL isSittingAvatarOnGround() const; - + inline bool hasBumpmap() const { return mNumBumpmapTEs > 0;} + void setFlags(U32 flags) { mMiscFlags = flags; } void addFlags(U32 flags) { mMiscFlags |= flags; } void removeFlags(U32 flags) { mMiscFlags &= ~flags; } @@ -435,6 +436,9 @@ public: inline static BOOL isPrimitive(const LLPCode pcode); inline static BOOL isApp(const LLPCode pcode); +private: + void updateNumBumpmap(const U8 index, const U8 bump); + protected: LLPCode mPrimitiveCode; // Primitive code LLVector3 mVelocity; // how fast are we moving? @@ -444,6 +448,7 @@ protected: LLPrimTextureList mTextureList; // list of texture GUIDs, scales, offsets U8 mMaterial; // Material code U8 mNumTEs; // # of faces on the primitve + U8 mNumBumpmapTEs; // number of bumpmap TEs. U32 mMiscFlags; // home for misc bools public: -- cgit v1.2.3 From 8ba2b388769e245ec1b49b7d6d4b0372d684ff86 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Thu, 13 Sep 2012 10:25:48 +0000 Subject: Fleshed out target_link_libraries dependencies between libraries. Appearance utility now reads avatar_lad.xml during stubbed out params processing. --- indra/llprimitive/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index e4d9de7eb6..cf01e10577 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -59,6 +59,15 @@ list(APPEND llprimitive_SOURCE_FILES ${llprimitive_HEADER_FILES}) add_library (llprimitive ${llprimitive_SOURCE_FILES}) +target_link_libraries(llprimitive + ${LLCOMMON_LIBRARIES} + ${LLMATH_LIBRARIES} + ${LLMESSAGE_LIBRARIES} + ${LLXML_LIBRARIES} + ${LLPHYSICSEXTENSIONS_LIBRARIES} + ) + + #add unit tests if (LL_TESTS) INCLUDE(LLAddBuildTest) -- cgit v1.2.3 From ae10e78d978360871556b1cee615cd79ef381184 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Fri, 14 Sep 2012 17:56:42 -0700 Subject: Added some initial basic decoding of the material value per face. --- indra/llprimitive/llprimitive.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 6dee192783..40e6bedd49 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1357,6 +1357,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; + unsigned char material_id[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1399,6 +1400,25 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_id, 16, face_count, MVT_LLUUID); + + for (U32 curFace = 0U; curFace < face_count; ++curFace) + { + std::string materialID(reinterpret_cast(&material_id[curFace * 16]), 16); + std::string materialIDString; + for (unsigned int i = 0U; i < 4U; ++i) + { + if (i != 0U) + { + materialIDString += "-"; + } + const U32 *value = reinterpret_cast(&materialID.c_str()[i * 4]); + materialIDString += llformat("%08x", *value); + } + + llinfos << "STINSON DEBUG: found material ID for face #" << curFace << " => " << materialIDString << llendl; + } for (i = 0; i < face_count; i++) { -- cgit v1.2.3 From dbe0a577ae09f500373c104e038a7d64dd9e3002 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Wed, 3 Oct 2012 18:31:33 -0700 Subject: Removing overly verbose debug outputs. --- indra/llprimitive/llprimitive.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 40e6bedd49..c6e229ae8e 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1403,6 +1403,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_id, 16, face_count, MVT_LLUUID); +#if 0 for (U32 curFace = 0U; curFace < face_count; ++curFace) { std::string materialID(reinterpret_cast(&material_id[curFace * 16]), 16); @@ -1419,6 +1420,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) llinfos << "STINSON DEBUG: found material ID for face #" << curFace << " => " << materialIDString << llendl; } +#endif for (i = 0; i < face_count; i++) { -- cgit v1.2.3 From 38a565f71a54aaa66300a0ab593e366731aac769 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 9 Oct 2012 12:30:38 -0700 Subject: Initial pass at getting a list of viewer objects with non-null material IDs. --- indra/llprimitive/CMakeLists.txt | 2 + indra/llprimitive/llmaterialid.cpp | 112 ++++++++++++++++++++++++++++++++ indra/llprimitive/llmaterialid.h | 62 ++++++++++++++++++ indra/llprimitive/llprimitive.cpp | 54 +++++++++------ indra/llprimitive/llprimitive.h | 2 + indra/llprimitive/llprimtexturelist.cpp | 10 +++ indra/llprimitive/llprimtexturelist.h | 2 + indra/llprimitive/lltextureentry.cpp | 17 +++++ indra/llprimitive/lltextureentry.h | 4 ++ 9 files changed, 244 insertions(+), 21 deletions(-) create mode 100644 indra/llprimitive/llmaterialid.cpp create mode 100644 indra/llprimitive/llmaterialid.h (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index e4d9de7eb6..82d0f892f2 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -20,6 +20,7 @@ include_directories( ) set(llprimitive_SOURCE_FILES + llmaterialid.cpp llmaterialtable.cpp llmediaentry.cpp llmodel.cpp @@ -37,6 +38,7 @@ set(llprimitive_HEADER_FILES CMakeLists.txt legacy_object_types.h + llmaterialid.h llmaterialtable.h llmediaentry.h llmodel.h diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp new file mode 100644 index 0000000000..4355a8ea3f --- /dev/null +++ b/indra/llprimitive/llmaterialid.cpp @@ -0,0 +1,112 @@ +/** +* @file llmaterialid.cpp +* @brief Implementation of llmaterialid +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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$ +*/ + +#include "linden_common.h" + +#include "llmaterialid.h" + +const LLMaterialID LLMaterialID::null; + +LLMaterialID::LLMaterialID() +{ + clear(); +} + +LLMaterialID::LLMaterialID(const LLSD& pMaterialID) +{ + llassert(pMaterialID.isBinary()); + parseFromBinary(pMaterialID.asBinary()); +} + +LLMaterialID::LLMaterialID(const LLSD::Binary& pMaterialID) +{ + parseFromBinary(pMaterialID); +} + +LLMaterialID::LLMaterialID(const LLMaterialID& pOtherMaterialID) +{ + copyFromOtherMaterialID(pOtherMaterialID); +} + +LLMaterialID::~LLMaterialID() +{ +} + +bool LLMaterialID::operator == (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) == 0); +} + +bool LLMaterialID::operator != (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) != 0); +} + +LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID) +{ + copyFromOtherMaterialID(pOtherMaterialID); + return (*this); +} + +bool LLMaterialID::isNull() const +{ + return (compareToOtherMaterialID(LLMaterialID::null) == 0); +} + +const U8* LLMaterialID::get() const +{ + return mID; +} + +void LLMaterialID::set(const void* pMemory) +{ + llassert(pMemory != NULL); + + // assumes that the required size of memory is available + memcpy(mID, pMemory, MATERIAL_ID_SIZE * sizeof(U8)); +} + +void LLMaterialID::clear() +{ + memset(mID, 0, MATERIAL_ID_SIZE * sizeof(U8)); +} + +void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) +{ + llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); + memcpy(mID, &pMaterialID[0], MATERIAL_ID_SIZE * sizeof(U8)); +} + +void LLMaterialID::copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID) +{ + memcpy(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8)); +} + +int LLMaterialID::compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const +{ + return memcmp(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8)); +} diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h new file mode 100644 index 0000000000..4551550db5 --- /dev/null +++ b/indra/llprimitive/llmaterialid.h @@ -0,0 +1,62 @@ +/** +* @file llmaterialid.h +* @brief Header file for llmaterialid +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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_LLMATERIALID_H +#define LL_LLMATERIALID_H + +#define MATERIAL_ID_SIZE 16 + +class LLMaterialID +{ +public: + LLMaterialID(); + LLMaterialID(const LLSD& pMaterialID); + LLMaterialID(const LLSD::Binary& pMaterialID); + LLMaterialID(const LLMaterialID& pOtherMaterialID); + ~LLMaterialID(); + + bool operator == (const LLMaterialID& pOtherMaterialID) const; + bool operator != (const LLMaterialID& pOtherMaterialID) const; + LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID); + + bool isNull() const; + + const U8* get() const; + void set(const void* pMemory); + void clear(); + + static const LLMaterialID null; + +private: + void parseFromBinary(const LLSD::Binary& pMaterialID); + void copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID); + int compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const; + + U8 mID[MATERIAL_ID_SIZE]; +} ; + +#endif // LL_LLMATERIALID_H + diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index c6e229ae8e..86aa371368 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -39,6 +39,7 @@ #include "lldatapacker.h" #include "llsdutil_math.h" #include "llprimtexturelist.h" +#include "llmaterialid.h" /** * exported constants @@ -366,6 +367,11 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } +S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID) +{ + return mTextureList.setMaterialID(index, pMaterialID); +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { @@ -1091,6 +1097,7 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; + U8 material_data[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1128,6 +1135,9 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const bump[face_index] = te->getBumpShinyFullbright(); media_flags[face_index] = te->getMediaTexGen(); glow[face_index] = (U8) llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF)); + + // Directly sending material_ids is not safe! + memcpy(&material_data[face_index*16],getTE(face_index)->getMaterialID().get(),16); /* Flawfinder: ignore */ } cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID); @@ -1149,6 +1159,8 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8); *cur_ptr++ = 0; cur_ptr += packTEField(cur_ptr, (U8 *)glow, 1 ,last_face_index, MVT_U8); + *cur_ptr++ = 0; + cur_ptr += packTEField(cur_ptr, (U8 *)material_data, 16, last_face_index, MVT_LLUUID); } mesgsys->addBinaryDataFast(_PREHASH_TextureEntry, packed_buffer, (S32)(cur_ptr - packed_buffer)); @@ -1170,6 +1182,7 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; + U8 material_data[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1207,6 +1220,9 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const bump[face_index] = te->getBumpShinyFullbright(); media_flags[face_index] = te->getMediaTexGen(); glow[face_index] = (U8) llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF)); + + // Directly sending material_ids is not safe! + memcpy(&material_data[face_index*16],getTE(face_index)->getMaterialID().get(),16); /* Flawfinder: ignore */ } cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID); @@ -1228,6 +1244,8 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8); *cur_ptr++ = 0; cur_ptr += packTEField(cur_ptr, (U8 *)glow, 1 ,last_face_index, MVT_U8); + *cur_ptr++ = 0; + cur_ptr += packTEField(cur_ptr, (U8 *)material_data, 16, last_face_index, MVT_LLUUID); } dp.packBinaryData(packed_buffer, (S32)(cur_ptr - packed_buffer), "TextureEntry"); @@ -1246,6 +1264,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam const U32 MAX_TES = 32; // Avoid construction of 32 UUIDs per call. JC + static LLMaterialID material_ids[MAX_TES]; U8 image_data[MAX_TES*16]; U8 colors[MAX_TES*4]; @@ -1257,6 +1276,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; + U8 material_data[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1309,6 +1329,13 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + + for (U32 i = 0; i < face_count; i++) + { + material_ids[i].set(&material_data[i * 16]); + } LLColor4 color; LLColor4U coloru; @@ -1321,6 +1348,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam retval |= setTEBumpShinyFullbright(i, bump[i]); retval |= setTEMediaTexGen(i, media_flags[i]); retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); + retval |= setTEMaterialID(i, material_ids[i]); coloru = LLColor4U(colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) @@ -1346,6 +1374,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) // Avoid construction of 32 UUIDs per call static LLUUID image_ids[MAX_TES]; + static LLMaterialID material_ids[MAX_TES]; U8 image_data[MAX_TES*16]; U8 colors[MAX_TES*4]; @@ -1357,7 +1386,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) U8 bump[MAX_TES]; U8 media_flags[MAX_TES]; U8 glow[MAX_TES]; - unsigned char material_id[MAX_TES*16]; + U8 material_data[MAX_TES*16]; const U32 MAX_TE_BUFFER = 4096; U8 packed_buffer[MAX_TE_BUFFER]; @@ -1401,30 +1430,12 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_id, 16, face_count, MVT_LLUUID); - -#if 0 - for (U32 curFace = 0U; curFace < face_count; ++curFace) - { - std::string materialID(reinterpret_cast(&material_id[curFace * 16]), 16); - std::string materialIDString; - for (unsigned int i = 0U; i < 4U; ++i) - { - if (i != 0U) - { - materialIDString += "-"; - } - const U32 *value = reinterpret_cast(&materialID.c_str()[i * 4]); - materialIDString += llformat("%08x", *value); - } - - llinfos << "STINSON DEBUG: found material ID for face #" << curFace << " => " << materialIDString << llendl; - } -#endif + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); for (i = 0; i < face_count; i++) { memcpy(image_ids[i].mData,&image_data[i*16],16); /* Flawfinder: ignore */ + material_ids[i].set(&material_data[i * 16]); } LLColor4 color; @@ -1438,6 +1449,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) retval |= setTEBumpShinyFullbright(i, bump[i]); retval |= setTEMediaTexGen(i, media_flags[i]); retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); + retval |= setTEMaterialID(i, material_ids[i]); coloru = LLColor4U(colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 8dcaa8c740..e1635740ef 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -42,6 +42,7 @@ class LLMessageSystem; class LLVolumeParams; class LLColor4; class LLColor3; +class LLMaterialID; class LLTextureEntry; class LLDataPacker; class LLVolumeMgr; @@ -353,6 +354,7 @@ public: 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 S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed void copyTEs(const LLPrimitive *primitive); diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 36e04df7b7..20438578b3 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -27,6 +27,7 @@ #include "linden_common.h" #include "llprimtexturelist.h" +#include "llmaterialid.h" #include "lltextureentry.h" #include "llmemtype.h" @@ -359,6 +360,15 @@ S32 LLPrimTextureList::setGlow(const U8 index, const F32 glow) return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMaterialID(const U8 index, const LLMaterialID& pMaterialID) +{ + if (index < mEntryList.size()) + { + return mEntryList[index]->setMaterialID(pMaterialID); + } + return TEM_CHANGE_NONE; +} + S32 LLPrimTextureList::size() const { return mEntryList.size(); diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h index 3cfa52f1d5..691df44c18 100644 --- a/indra/llprimitive/llprimtexturelist.h +++ b/indra/llprimitive/llprimtexturelist.h @@ -34,6 +34,7 @@ class LLTextureEntry; +class LLMaterialID; // this is a list of LLTextureEntry*'s because in practice the list's elements // are of some derived class: LLFooTextureEntry @@ -102,6 +103,7 @@ public: S32 setFullbright(const U8 index, const U8 t); S32 setMediaFlags(const U8 index, const U8 media_flags); S32 setGlow(const U8 index, const F32 glow); + S32 setMaterialID(const U8 index, const LLMaterialID& pMaterialID); S32 size() const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 34eff17519..b04fa809d2 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -29,6 +29,7 @@ #include "lluuid.h" #include "llmediaentry.h" #include "lltextureentry.h" +#include "llmaterialid.h" #include "llsdutil_math.h" #include "v4color.h" @@ -83,6 +84,8 @@ LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) mBump = rhs.mBump; mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; + mMaterialID = rhs.mMaterialID; + if (rhs.mMediaEntry != NULL) { // Make a copy mMediaEntry = new LLMediaEntry(*rhs.mMediaEntry); @@ -103,6 +106,7 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs) mBump = rhs.mBump; mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; + mMaterialID = rhs.mMaterialID; if (mMediaEntry != NULL) { delete mMediaEntry; } @@ -130,6 +134,7 @@ void LLTextureEntry::init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 of mBump = bump; mMediaFlags = 0x0; mGlow = 0; + mMaterialID.clear(); setColor(LLColor4(1.f, 1.f, 1.f, 1.f)); if (mMediaEntry != NULL) { @@ -159,6 +164,7 @@ bool LLTextureEntry::operator!=(const LLTextureEntry &rhs) const if (mBump != rhs.mBump) return (true); if (mMediaFlags != rhs.mMediaFlags) return (true); if (mGlow != rhs.mGlow) return (true); + if (mMaterialID != rhs.mMaterialID) return (true); return(false); } @@ -174,6 +180,7 @@ bool LLTextureEntry::operator==(const LLTextureEntry &rhs) const if (mBump != rhs.mBump) return (false); if (mMediaFlags != rhs.mMediaFlags) return false; if (mGlow != rhs.mGlow) return false; + if (mMaterialID != rhs.mMaterialID) return (false); return(true); } @@ -523,6 +530,16 @@ S32 LLTextureEntry::setGlow(F32 glow) return TEM_CHANGE_NONE; } +S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) +{ + if (mMaterialID != pMaterialID) + { + mMaterialID = pMaterialID; + return TEM_CHANGE_TEXTURE; + } + return TEM_CHANGE_NONE; +} + void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) { mMediaFlags |= MF_HAS_MEDIA; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 437b85e03f..b681ce8ca7 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -30,6 +30,7 @@ #include "lluuid.h" #include "v4color.h" #include "llsd.h" +#include "llmaterialid.h" // These bits are used while unpacking TEM messages to tell which aspects of // the texture entry changed. @@ -121,6 +122,7 @@ public: S32 setTexGen(U8 texGen); S32 setMediaTexGen(U8 media); S32 setGlow(F32 glow); + S32 setMaterialID(const LLMaterialID& pMaterialID); virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } @@ -139,6 +141,7 @@ public: U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; } U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } + const LLMaterialID& getMaterialID() const { return mMaterialID; }; // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() @@ -193,6 +196,7 @@ protected: U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + LLMaterialID mMaterialID; // Note the media data is not sent via the same message structure as the rest of the TE LLMediaEntry* mMediaEntry; // The media data for the face -- cgit v1.2.3 From c06c35609c6683731eaea283468f6b32af18fea2 Mon Sep 17 00:00:00 2001 From: Don Kjer Date: Thu, 11 Oct 2012 00:09:04 +0000 Subject: Updating linux build to gcc4.6 --- indra/llprimitive/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index cf01e10577..1768a06a27 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -14,10 +14,14 @@ include_directories( ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS} - ${LLPHYSICSEXTENSIONS_INCLUDE_DIRS} ${LIBS_PREBUILT_DIR}/include/collada ${LIBS_PREBUILT_DIR}/include/collada/1.4 ) +include_directories(SYSTEM + ${LLCOMMON_SYSTEM_INCLUDE_DIRS} + ${LLXML_SYSTEM_INCLUDE_DIRS} + ${LLPHYSICSEXTENSIONS_INCLUDE_DIRS} + ) set(llprimitive_SOURCE_FILES llmaterialtable.cpp -- cgit v1.2.3 From 4174e9be5ea6262d7ad27ab64805990fd13670ee Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Thu, 11 Oct 2012 11:51:16 -0700 Subject: Adding an additional conversion constructor. --- indra/llprimitive/llmaterialid.cpp | 5 +++++ indra/llprimitive/llmaterialid.h | 1 + 2 files changed, 6 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 4355a8ea3f..8122b70c2d 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -47,6 +47,11 @@ LLMaterialID::LLMaterialID(const LLSD::Binary& pMaterialID) parseFromBinary(pMaterialID); } +LLMaterialID::LLMaterialID(const void* pMemory) +{ + set(pMemory); +} + LLMaterialID::LLMaterialID(const LLMaterialID& pOtherMaterialID) { copyFromOtherMaterialID(pOtherMaterialID); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 4551550db5..71c6e72478 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -35,6 +35,7 @@ public: LLMaterialID(); LLMaterialID(const LLSD& pMaterialID); LLMaterialID(const LLSD::Binary& pMaterialID); + LLMaterialID(const void* pMemory); LLMaterialID(const LLMaterialID& pOtherMaterialID); ~LLMaterialID(); -- cgit v1.2.3 From e2ce144129e53ca7c6f5309cab833d48cdb30b11 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 27 Nov 2012 16:56:53 -0800 Subject: First pass at re-implementing the POST functionality to query values for selected visible objects. --- indra/llprimitive/llmaterialid.cpp | 11 +++++++++++ indra/llprimitive/llmaterialid.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 8122b70c2d..7df23e5ee0 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -100,6 +100,17 @@ void LLMaterialID::clear() memset(mID, 0, MATERIAL_ID_SIZE * sizeof(U8)); } +LLSD LLMaterialID::asLLSD() const +{ + LLSD::Binary materialIDBinary; + + materialIDBinary.resize(MATERIAL_ID_SIZE * sizeof(U8)); + memcpy(materialIDBinary.data(), mID, MATERIAL_ID_SIZE * sizeof(U8)); + + LLSD materialID = materialIDBinary; + return materialID; +} + void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) { llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 71c6e72478..1578172aec 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -49,6 +49,8 @@ public: void set(const void* pMemory); void clear(); + LLSD asLLSD() const; + static const LLMaterialID null; private: -- cgit v1.2.3 From 6618cff96c75bd0183b173c30ec818404038c2dd Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Thu, 29 Nov 2012 00:00:18 +0100 Subject: Encapsulate material definitions in LLMaterial and refactor LLFloaterDebugMaterials to use the new class --- indra/llprimitive/CMakeLists.txt | 2 + indra/llprimitive/llmaterial.cpp | 147 +++++++++++++++++++++++++++++++++++++++ indra/llprimitive/llmaterial.h | 94 +++++++++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 indra/llprimitive/llmaterial.cpp create mode 100644 indra/llprimitive/llmaterial.h (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 82d0f892f2..4eef1673f4 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -21,6 +21,7 @@ include_directories( set(llprimitive_SOURCE_FILES llmaterialid.cpp + llmaterial.cpp llmaterialtable.cpp llmediaentry.cpp llmodel.cpp @@ -38,6 +39,7 @@ set(llprimitive_HEADER_FILES CMakeLists.txt legacy_object_types.h + llmaterial.h llmaterialid.h llmaterialtable.h llmediaentry.h diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp new file mode 100644 index 0000000000..36d958ede5 --- /dev/null +++ b/indra/llprimitive/llmaterial.cpp @@ -0,0 +1,147 @@ +/** + * @file llmaterial.cpp + * @brief Material definition + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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$ + */ + +#include "linden_common.h" + +#include "llmaterial.h" + +/** + * Materials cap parameters + */ +#define MATERIALS_CAP_NORMAL_MAP_FIELD "NormMap" +#define MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD "NormOffsetX" +#define MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD "NormOffsetY" +#define MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD "NormRepeatX" +#define MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD "NormRepeatY" +#define MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD "NormRotation" + +#define MATERIALS_CAP_SPECULAR_MAP_FIELD "SpecMap" +#define MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD "SpecOffsetX" +#define MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD "SpecOffsetY" +#define MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD "SpecRepeatX" +#define MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD "SpecRepeatY" +#define MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD "SpecRotation" + +#define MATERIALS_CAP_SPECULAR_COLOR_FIELD "SpecColor" +#define MATERIALS_CAP_SPECULAR_EXP_FIELD "SpecExp" +#define MATERIALS_CAP_ENV_INTENSITY_FIELD "EnvIntensity" +#define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" +#define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" + +/** + * Materials constants + */ + +const LLColor4U MATERIALS_DEFAULT_SPECULAR_COLOR = LLColor4U(255, 255, 255, 255); +const U8 MATERIALS_DEFAULT_SPECULAR_EXP = 128; +const U8 MATERIALS_DEFAULT_ENV_INTENSITY = 128; +const U8 MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE = 0; +const U8 MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF = 128; + +const F32 MATERIALS_MULT_OFFSETREPEAT = 10000.f; +const F32 MATERIALS_MULT_ROTATION = 1000.f; + +/** + * Helper functions + */ + +template T getMaterialField(const LLSD& data, const std::string& field, const LLSD::Type field_type) +{ + if ( (data.has(field)) && (field_type == data[field].type()) ) + { + return (T)data[field]; + } + llerrs << "Missing or mistyped field '" << field << "' in material definition" << llendl; + return (T)LLSD(); +} + +/** + * LLMaterial class + */ + +LLMaterial::LLMaterial() + : mSpecularLightColor(MATERIALS_DEFAULT_SPECULAR_COLOR) + , mSpecularLightExponent(MATERIALS_DEFAULT_SPECULAR_EXP) + , mEnvironmentIntensity(MATERIALS_DEFAULT_ENV_INTENSITY) + , mDiffuseAlphaMode(MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE) + , mAlphaMaskCutoff(MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF) +{ +} + +LLMaterial::LLMaterial(const LLSD& material_data) +{ + fromLLSD(material_data); +} + +LLSD LLMaterial::asLLSD() const +{ + LLSD material_data; + + material_data[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalID; + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llround(mNormalOffsetX * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llround(mNormalOffsetY * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llround(mNormalRepeatX * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llround(mNormalRepeatY * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llround(mNormalRotation * MATERIALS_MULT_ROTATION); + + material_data[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularID; + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llround(mSpecularOffsetX * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llround(mSpecularOffsetY * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llround(mSpecularRepeatX * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llround(mSpecularRepeatY * MATERIALS_MULT_OFFSETREPEAT); + material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llround(mSpecularRotation * MATERIALS_MULT_ROTATION); + + material_data[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = mSpecularLightColor.getValue(); + material_data[MATERIALS_CAP_SPECULAR_EXP_FIELD] = mSpecularLightExponent; + material_data[MATERIALS_CAP_ENV_INTENSITY_FIELD] = mEnvironmentIntensity; + material_data[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = mDiffuseAlphaMode; + material_data[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = mAlphaMaskCutoff; + + return material_data; +} + +void LLMaterial::fromLLSD(const LLSD& material_data) +{ + mNormalID = getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_FIELD, LLSD::TypeUUID); + mNormalOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mNormalOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mNormalRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mNormalRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mNormalRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION; + + mSpecularID = getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_FIELD, LLSD::TypeUUID); + mSpecularOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mSpecularOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mSpecularRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mSpecularRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; + mSpecularRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION; + + mSpecularLightColor.setValue(getMaterialField(material_data, MATERIALS_CAP_SPECULAR_COLOR_FIELD, LLSD::TypeArray)); + mSpecularLightExponent = (U8)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_EXP_FIELD, LLSD::TypeInteger); + mEnvironmentIntensity = (U8)getMaterialField(material_data, MATERIALS_CAP_ENV_INTENSITY_FIELD, LLSD::TypeInteger); + mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); + mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); +} diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h new file mode 100644 index 0000000000..d50ab30195 --- /dev/null +++ b/indra/llprimitive/llmaterial.h @@ -0,0 +1,94 @@ +/** + * @file llmaterial.h + * @brief Material definition + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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_LLMATERIAL_H +#define LL_LLMATERIAL_H + +#include "llmaterialid.h" +#include "llsd.h" +#include "v4coloru.h" + +class LLMaterial +{ +public: + LLMaterial(); + LLMaterial(const LLSD& material_data); + + LLSD asLLSD() const; + void fromLLSD(const LLSD& material_data); + + const LLUUID& getNormalID() const { return mNormalID; } + void setNormalID(const LLUUID& normal_id) { mNormalID = normal_id; } + void getNormalOffset(F32& offset_x, F32& offset_y) const { offset_x = mNormalOffsetX; offset_y = mNormalOffsetY; } + void setNormalOffset(F32 offset_x, F32 offset_y) { mNormalOffsetX = offset_x; mNormalOffsetY = offset_y; } + void getNormalRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mNormalRepeatX; repeat_y = mNormalRepeatY; } + void setNormalRepeat(F32 repeat_x, F32 repeat_y) { mNormalRepeatX = repeat_x; mNormalRepeatY = repeat_y; } + F32 getNormalRotation() const { return mNormalRotation; } + void setNormalRotation(F32 rot) { mNormalRotation = rot; } + + const LLUUID& getSpecularID() const { return mSpecularID; } + void setSpecularID(const LLUUID& specular_id) { mSpecularID = specular_id; } + void getSpecularOffset(F32& offset_x, F32& offset_y) const { offset_x = mSpecularOffsetX; offset_y = mSpecularOffsetY; } + void setSpecularOffset(F32 offset_x, F32 offset_y) { mSpecularOffsetX = offset_x; mSpecularOffsetY = offset_y; } + void getSpecularRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mSpecularRepeatX; repeat_y = mSpecularRepeatY; } + void setSpecularRepeat(F32 repeat_x, F32 repeat_y) { mSpecularRepeatX = repeat_x; mSpecularRepeatY = repeat_y; } + F32 getSpecularRotation() const { return mSpecularRotation; } + void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } + + const LLColor4U& getSpecularLightColor() const { return mSpecularLightColor; } + void setSpecularLightColor(const LLColor4U& color) { mSpecularLightColor = color; } + U8 getSpecularLightExponent() const { return mSpecularLightExponent; } + void setSpecularLightExponent(U8 exponent) { mSpecularLightExponent = exponent; } + U8 getEnvironmentIntensity() const { return mEnvironmentIntensity; } + void setEnvironmentIntensity(U8 intensity) { mEnvironmentIntensity = intensity; } + U8 getDiffuseAlphaMode() const { return mDiffuseAlphaMode; } + void setDiffuseAlphaMode(U8 alpha_mode) { mDiffuseAlphaMode = alpha_mode; } + U8 getAlphaMaskCutoff() const { return mAlphaMaskCutoff; } + void setAlphaMaskCutoff(U8 cutoff) { mAlphaMaskCutoff = cutoff; } + +protected: + LLUUID mNormalID; + F32 mNormalOffsetX; + F32 mNormalOffsetY; + F32 mNormalRepeatX; + F32 mNormalRepeatY; + F32 mNormalRotation; + + LLUUID mSpecularID; + F32 mSpecularOffsetX; + F32 mSpecularOffsetY; + F32 mSpecularRepeatX; + F32 mSpecularRepeatY; + F32 mSpecularRotation; + + LLColor4U mSpecularLightColor; + U8 mSpecularLightExponent; + U8 mEnvironmentIntensity; + U8 mDiffuseAlphaMode; + U8 mAlphaMaskCutoff; +}; + +#endif // LL_LLMATERIAL_H -- cgit v1.2.3 From 2feac960904b0b94d05253e4c345f1853ed3bbbf Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 2 Dec 2012 01:04:56 +0100 Subject: Fixed two minor issues (mDiffuseAlphaMode and mAlphaMaskCutoff were reversed; specular rotation had wrong format specifier) --- indra/llprimitive/llmaterial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 36d958ede5..b07b4ce72d 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -142,6 +142,6 @@ void LLMaterial::fromLLSD(const LLSD& material_data) mSpecularLightColor.setValue(getMaterialField(material_data, MATERIALS_CAP_SPECULAR_COLOR_FIELD, LLSD::TypeArray)); mSpecularLightExponent = (U8)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_EXP_FIELD, LLSD::TypeInteger); mEnvironmentIntensity = (U8)getMaterialField(material_data, MATERIALS_CAP_ENV_INTENSITY_FIELD, LLSD::TypeInteger); - mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); - mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); + mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); + mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); } -- cgit v1.2.3 From a0392ec5ec5703bd54bc4e091820d1c1423bbad4 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 2 Dec 2012 21:29:43 +0100 Subject: Refactor LLFloaterDebugMaterials::convertToPrintableMaterialID() as LLMaterialID::asString() so it can be used everywhere --- indra/llprimitive/llmaterialid.cpp | 15 +++++++++++++++ indra/llprimitive/llmaterialid.h | 1 + 2 files changed, 16 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 7df23e5ee0..73a61f9c54 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -111,6 +111,21 @@ LLSD LLMaterialID::asLLSD() const return materialID; } +std::string LLMaterialID::asString() const +{ + std::string materialIDString; + for (unsigned int i = 0U; i < 4; ++i) + { + if (i != 0U) + { + materialIDString += "-"; + } + const U32 *value = reinterpret_cast(&mID[i * 4]); + materialIDString += llformat("%08x", *value); + } + return materialIDString; +} + void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) { llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 1578172aec..a474703f79 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -50,6 +50,7 @@ public: void clear(); LLSD asLLSD() const; + std::string asString() const; static const LLMaterialID null; -- cgit v1.2.3 From 1e26dbdcd27a1f29fe249cc7e074e5ede284bac8 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 3 Dec 2012 01:46:26 +0100 Subject: Started LLMaterialMgr to handle viewer<->region materials communication * refactored LLFloaterDebugMaterials::requestPutMaterials() to use LLMaterialMgr instead * replaced "Object editing" results list with information about the active selection instead --- indra/llprimitive/llmaterial.cpp | 18 ++++++++++++++---- indra/llprimitive/llmaterial.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index b07b4ce72d..da518b6916 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -82,6 +82,8 @@ template T getMaterialField(const LLSD& data, const std::string& fie * LLMaterial class */ +const LLMaterial LLMaterial::null; + LLMaterial::LLMaterial() : mSpecularLightColor(MATERIALS_DEFAULT_SPECULAR_COLOR) , mSpecularLightExponent(MATERIALS_DEFAULT_SPECULAR_EXP) @@ -117,8 +119,8 @@ LLSD LLMaterial::asLLSD() const material_data[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = mSpecularLightColor.getValue(); material_data[MATERIALS_CAP_SPECULAR_EXP_FIELD] = mSpecularLightExponent; material_data[MATERIALS_CAP_ENV_INTENSITY_FIELD] = mEnvironmentIntensity; - material_data[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = mDiffuseAlphaMode; - material_data[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = mAlphaMaskCutoff; + material_data[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = mDiffuseAlphaMode; + material_data[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = mAlphaMaskCutoff; return material_data; } @@ -142,6 +144,14 @@ void LLMaterial::fromLLSD(const LLSD& material_data) mSpecularLightColor.setValue(getMaterialField(material_data, MATERIALS_CAP_SPECULAR_COLOR_FIELD, LLSD::TypeArray)); mSpecularLightExponent = (U8)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_EXP_FIELD, LLSD::TypeInteger); mEnvironmentIntensity = (U8)getMaterialField(material_data, MATERIALS_CAP_ENV_INTENSITY_FIELD, LLSD::TypeInteger); - mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); - mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); + mDiffuseAlphaMode = (U8)getMaterialField(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); + mAlphaMaskCutoff = (U8)getMaterialField(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); +} + +bool LLMaterial::isNull() const +{ + // *TODO: find a better way of defining a 'null' material? + return + (mNormalID.isNull()) && (.0f == mNormalOffsetX) && (.0f == mNormalOffsetY) && (.0f == mNormalRepeatX) && (.0f == mNormalRepeatY) && + (mSpecularID.isNull()) && (.0f == mSpecularOffsetX) && (.0f == mSpecularOffsetY) && (.0f == mSpecularRepeatX) && (.0f == mSpecularRepeatY); } diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index d50ab30195..42e3dd04b9 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -69,6 +69,9 @@ public: U8 getAlphaMaskCutoff() const { return mAlphaMaskCutoff; } void setAlphaMaskCutoff(U8 cutoff) { mAlphaMaskCutoff = cutoff; } + bool isNull() const; + static const LLMaterial null; + protected: LLUUID mNormalID; F32 mNormalOffsetX; -- cgit v1.2.3 From 25bffc3d43ec7696c0a9fab43514affbfe006fb9 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 3 Dec 2012 15:20:11 +0100 Subject: Added LLMaterialMgr::get() to retrieve individual materials (with optional callback) --- indra/llprimitive/llmaterial.h | 4 ++++ indra/llprimitive/llmaterialid.cpp | 5 +++++ indra/llprimitive/llmaterialid.h | 1 + 3 files changed, 10 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 42e3dd04b9..da364e548c 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -27,6 +27,8 @@ #ifndef LL_LLMATERIAL_H #define LL_LLMATERIAL_H +#include + #include "llmaterialid.h" #include "llsd.h" #include "v4coloru.h" @@ -94,4 +96,6 @@ protected: U8 mAlphaMaskCutoff; }; +typedef boost::shared_ptr LLMaterialPtr; + #endif // LL_LLMATERIAL_H diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 73a61f9c54..bbbbf0ced3 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -77,6 +77,11 @@ LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID) return (*this); } +bool LLMaterialID::operator < (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) < 0); +} + bool LLMaterialID::isNull() const { return (compareToOtherMaterialID(LLMaterialID::null) == 0); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index a474703f79..ffefc9f11c 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -42,6 +42,7 @@ public: bool operator == (const LLMaterialID& pOtherMaterialID) const; bool operator != (const LLMaterialID& pOtherMaterialID) const; LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID); + bool operator < (const LLMaterialID& pOtherMaterialID) const; bool isNull() const; -- cgit v1.2.3 From e2b5e11820cf234d035bdb07f4b145c397fdf67b Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 4 Dec 2012 15:46:10 -0800 Subject: Implementing string conversion and comparison operator overrides for the LLMaterialID class. --- indra/llprimitive/llmaterialid.cpp | 40 ++++++++++++++++++++++++++++++++++++++ indra/llprimitive/llmaterialid.h | 9 +++++++++ 2 files changed, 49 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 7df23e5ee0..5c810ddf12 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -29,6 +29,10 @@ #include "llmaterialid.h" +#include + +#include "llformat.h" + const LLMaterialID LLMaterialID::null; LLMaterialID::LLMaterialID() @@ -71,6 +75,26 @@ bool LLMaterialID::operator != (const LLMaterialID& pOtherMaterialID) const return (compareToOtherMaterialID(pOtherMaterialID) != 0); } +bool LLMaterialID::operator < (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) < 0); +} + +bool LLMaterialID::operator <= (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) <= 0); +} + +bool LLMaterialID::operator > (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) > 0); +} + +bool LLMaterialID::operator >= (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) >= 0); +} + LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID) { copyFromOtherMaterialID(pOtherMaterialID); @@ -111,6 +135,22 @@ LLSD LLMaterialID::asLLSD() const return materialID; } +std::string LLMaterialID::asString() const +{ + std::string materialID(reinterpret_cast(get()), MATERIAL_ID_SIZE); + std::string materialIDString; + for (unsigned int i = 0U; i < static_cast(MATERIAL_ID_SIZE / sizeof(U32)); ++i) + { + if (i != 0U) + { + materialIDString += "-"; + } + const U32 *value = reinterpret_cast(&materialID.c_str()[i * sizeof(U32)]); + materialIDString += llformat("%08x", *value); + } + return materialIDString; +} + void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) { llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 1578172aec..9db4065302 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -29,6 +29,8 @@ #define MATERIAL_ID_SIZE 16 +#include + class LLMaterialID { public: @@ -41,6 +43,12 @@ public: bool operator == (const LLMaterialID& pOtherMaterialID) const; bool operator != (const LLMaterialID& pOtherMaterialID) const; + + bool operator < (const LLMaterialID& pOtherMaterialID) const; + bool operator <= (const LLMaterialID& pOtherMaterialID) const; + bool operator > (const LLMaterialID& pOtherMaterialID) const; + bool operator >= (const LLMaterialID& pOtherMaterialID) const; + LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID); bool isNull() const; @@ -50,6 +58,7 @@ public: void clear(); LLSD asLLSD() const; + std::string asString() const; static const LLMaterialID null; -- cgit v1.2.3 From a5b6142f6b53608769cfb3c33dbbbf3710b86d1b Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 4 Dec 2012 16:51:03 -0800 Subject: Updating the comparison function to not use ascii-character comparison. This will give better sorting when the operator overriden comparators are used. --- indra/llprimitive/llmaterialid.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 5c810ddf12..590f5cd91f 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -137,7 +137,6 @@ LLSD LLMaterialID::asLLSD() const std::string LLMaterialID::asString() const { - std::string materialID(reinterpret_cast(get()), MATERIAL_ID_SIZE); std::string materialIDString; for (unsigned int i = 0U; i < static_cast(MATERIAL_ID_SIZE / sizeof(U32)); ++i) { @@ -145,7 +144,7 @@ std::string LLMaterialID::asString() const { materialIDString += "-"; } - const U32 *value = reinterpret_cast(&materialID.c_str()[i * sizeof(U32)]); + const U32 *value = reinterpret_cast(&get()[i * sizeof(U32)]); materialIDString += llformat("%08x", *value); } return materialIDString; @@ -159,10 +158,19 @@ void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) void LLMaterialID::copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID) { - memcpy(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8)); + memcpy(mID, pOtherMaterialID.get(), MATERIAL_ID_SIZE * sizeof(U8)); } int LLMaterialID::compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const { - return memcmp(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8)); + int retVal = 0; + + for (unsigned int i = 0U; (retVal == 0) && (i < static_cast(MATERIAL_ID_SIZE / sizeof(U32))); ++i) + { + const U32 *thisValue = reinterpret_cast(&get()[i * sizeof(U32)]); + const U32 *otherValue = reinterpret_cast(&pOtherMaterialID.get()[i * sizeof(U32)]); + retVal = ((*thisValue < *otherValue) ? -1 : ((*thisValue > *otherValue) ? 1 : 0)); + } + + return retVal; } -- cgit v1.2.3 From a17f3e41ff960b7b486c5dd94860d484b4ceb177 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Fri, 7 Dec 2012 17:04:21 +0100 Subject: Use a single multiplier value for all material fields --- indra/llprimitive/llmaterial.cpp | 44 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index da518b6916..982136128e 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -60,9 +60,7 @@ const U8 MATERIALS_DEFAULT_SPECULAR_EXP = 128; const U8 MATERIALS_DEFAULT_ENV_INTENSITY = 128; const U8 MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE = 0; const U8 MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF = 128; - -const F32 MATERIALS_MULT_OFFSETREPEAT = 10000.f; -const F32 MATERIALS_MULT_ROTATION = 1000.f; +const F32 MATERIALS_MULTIPLIER = 10000.f; /** * Helper functions @@ -103,18 +101,18 @@ LLSD LLMaterial::asLLSD() const LLSD material_data; material_data[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalID; - material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llround(mNormalOffsetX * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llround(mNormalOffsetY * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llround(mNormalRepeatX * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llround(mNormalRepeatY * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llround(mNormalRotation * MATERIALS_MULT_ROTATION); + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llround(mNormalOffsetX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llround(mNormalOffsetY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llround(mNormalRepeatX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llround(mNormalRepeatY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llround(mNormalRotation * MATERIALS_MULTIPLIER); material_data[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularID; - material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llround(mSpecularOffsetX * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llround(mSpecularOffsetY * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llround(mSpecularRepeatX * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llround(mSpecularRepeatY * MATERIALS_MULT_OFFSETREPEAT); - material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llround(mSpecularRotation * MATERIALS_MULT_ROTATION); + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llround(mSpecularOffsetX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llround(mSpecularOffsetY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llround(mSpecularRepeatX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llround(mSpecularRepeatY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llround(mSpecularRotation * MATERIALS_MULTIPLIER); material_data[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = mSpecularLightColor.getValue(); material_data[MATERIALS_CAP_SPECULAR_EXP_FIELD] = mSpecularLightExponent; @@ -128,18 +126,18 @@ LLSD LLMaterial::asLLSD() const void LLMaterial::fromLLSD(const LLSD& material_data) { mNormalID = getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_FIELD, LLSD::TypeUUID); - mNormalOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mNormalOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mNormalRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mNormalRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mNormalRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION; + mNormalOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; mSpecularID = getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_FIELD, LLSD::TypeUUID); - mSpecularOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mSpecularOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mSpecularRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mSpecularRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT; - mSpecularRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION; + mSpecularOffsetX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularOffsetY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularRepeatX = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularRepeatY = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularRotation = (F32)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; mSpecularLightColor.setValue(getMaterialField(material_data, MATERIALS_CAP_SPECULAR_COLOR_FIELD, LLSD::TypeArray)); mSpecularLightExponent = (U8)getMaterialField(material_data, MATERIALS_CAP_SPECULAR_EXP_FIELD, LLSD::TypeInteger); -- cgit v1.2.3 From a073fa4009c6020970ce577b56bd76ea711cbe7f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 11 Dec 2012 16:27:58 -0600 Subject: MAINT-1028 Fix for crash when importing meshes produced by FBX converter --- indra/llprimitive/llmodel.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 28ed051c55..3f93f064ce 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -628,25 +628,41 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac if (v) { U32 v_idx = idx[j*stride+v_offset]*3; + v_idx = llclamp(v_idx, (U32) 0, v->getCount()); vert.getPosition().set(v->get(v_idx), v->get(v_idx+1), v->get(v_idx+2)); } - if (n) + //bounds check n and t lookups because some FBX to DAE converters + //use negative indices and empty arrays to indicate data does not exist + //for a particular channel + if (n && n->getCount() > 0) { U32 n_idx = idx[j*stride+n_offset]*3; + n_idx = llclamp(n_idx, (U32) 0, n->getCount()); vert.getNormal().set(n->get(n_idx), n->get(n_idx+1), n->get(n_idx+2)); } + else + { + vert.getNormal().clear(); + } + - if (t) + if (t && t->getCount() > 0) { U32 t_idx = idx[j*stride+t_offset]*2; + t_idx = llclamp(t_idx, (U32) 0, t->getCount()); vert.mTexCoord.setVec(t->get(t_idx), t->get(t_idx+1)); } + else + { + vert.mTexCoord.clear(); + } + verts.push_back(vert); } -- cgit v1.2.3 From 968567346a6af564da353a06305cfd8ff5c443d7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 11 Dec 2012 17:56:01 -0600 Subject: MAINT-1028 Fix for gcc --- indra/llprimitive/llmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 3f93f064ce..5ed05e2201 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -628,7 +628,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac if (v) { U32 v_idx = idx[j*stride+v_offset]*3; - v_idx = llclamp(v_idx, (U32) 0, v->getCount()); + v_idx = llclamp(v_idx, (U32) 0, (U32) v->getCount()); vert.getPosition().set(v->get(v_idx), v->get(v_idx+1), v->get(v_idx+2)); @@ -640,7 +640,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac if (n && n->getCount() > 0) { U32 n_idx = idx[j*stride+n_offset]*3; - n_idx = llclamp(n_idx, (U32) 0, n->getCount()); + n_idx = llclamp(n_idx, (U32) 0, (U32) n->getCount()); vert.getNormal().set(n->get(n_idx), n->get(n_idx+1), n->get(n_idx+2)); @@ -654,7 +654,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac if (t && t->getCount() > 0) { U32 t_idx = idx[j*stride+t_offset]*2; - t_idx = llclamp(t_idx, (U32) 0, t->getCount()); + t_idx = llclamp(t_idx, (U32) 0, (U32) t->getCount()); vert.mTexCoord.setVec(t->get(t_idx), t->get(t_idx+1)); } -- cgit v1.2.3 From ca790f7320c9fc6c43e8c6022c9e511a85fd1c9d Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 18 Dec 2012 21:52:41 +0100 Subject: Bypass GCC template stumble by specializing getMaterialField for LLUUID --- indra/llprimitive/llmaterial.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 982136128e..645fcf7b46 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -76,6 +76,17 @@ template T getMaterialField(const LLSD& data, const std::string& fie return (T)LLSD(); } +// GCC didn't like the generic form above for some reason +template<> LLUUID getMaterialField(const LLSD& data, const std::string& field, const LLSD::Type field_type) +{ + if ( (data.has(field)) && (field_type == data[field].type()) ) + { + return data[field].asUUID(); + } + llerrs << "Missing or mistyped field '" << field << "' in material definition" << llendl; + return LLUUID::null; +} + /** * LLMaterial class */ -- cgit v1.2.3 From eda11a25a465dd87b187f63da661f2ce02925deb Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 11 Jan 2013 06:37:21 -0500 Subject: Initial (largely complete) gamma correct rendering implementation. --- indra/llprimitive/lltextureentry.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index b681ce8ca7..ff1cc65bba 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -31,6 +31,7 @@ #include "v4color.h" #include "llsd.h" #include "llmaterialid.h" +#include "llmaterial.h" // These bits are used while unpacking TEM messages to tell which aspects of // the texture entry changed. @@ -197,6 +198,7 @@ protected: U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; LLMaterialID mMaterialID; + LLMaterialPtr mMaterial; // Note the media data is not sent via the same message structure as the rest of the TE LLMediaEntry* mMediaEntry; // The media data for the face -- cgit v1.2.3 From 5f03e197f4cfb43de93dc42b16b54beafccd376a Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 25 Jan 2013 17:54:38 -0500 Subject: Trying to set materials up for rendering! Yay! --- indra/llprimitive/llmaterial.h | 2 +- indra/llprimitive/llprimitive.cpp | 6 +++++- indra/llprimitive/llprimitive.h | 1 + indra/llprimitive/llprimtexturelist.cpp | 9 +++++++++ indra/llprimitive/llprimtexturelist.h | 2 ++ indra/llprimitive/lltextureentry.cpp | 10 ++++++++++ indra/llprimitive/lltextureentry.h | 2 ++ 7 files changed, 30 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index da364e548c..6f94cfda17 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -60,7 +60,7 @@ public: F32 getSpecularRotation() const { return mSpecularRotation; } void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } - const LLColor4U& getSpecularLightColor() const { return mSpecularLightColor; } + const LLColor4U getSpecularLightColor() const { return mSpecularLightColor; } void setSpecularLightColor(const LLColor4U& color) { mSpecularLightColor = color; } U8 getSpecularLightExponent() const { return mSpecularLightExponent; } void setSpecularLightExponent(U8 exponent) { mSpecularLightExponent = exponent; } diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 86aa371368..94df529b25 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -271,7 +271,6 @@ S32 LLPrimitive::setTEScale(const U8 index, const F32 s, const F32 t) return mTextureList.setScale(index, s, t); } - // BUG: slow - done this way because texture entries have some // voodoo related to texture coords S32 LLPrimitive::setTEScaleS(const U8 index, const F32 s) @@ -372,6 +371,10 @@ S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID return mTextureList.setMaterialID(index, pMaterialID); } +S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + return mTextureList.setMaterialParams(index, pMaterialParams); +} LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { @@ -1349,6 +1352,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam retval |= setTEMediaTexGen(i, media_flags[i]); retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); retval |= setTEMaterialID(i, material_ids[i]); + coloru = LLColor4U(colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index e1635740ef..6a9c5e9639 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -355,6 +355,7 @@ public: virtual S32 setTEMediaFlags(const U8 te, const U8 flags); virtual S32 setTEGlow(const U8 te, const F32 glow); virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); + virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed void copyTEs(const LLPrimitive *primitive); diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 20438578b3..c0923315cb 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -369,6 +369,15 @@ S32 LLPrimTextureList::setMaterialID(const U8 index, const LLMaterialID& pMateri return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + if (index < mEntryList.size()) + { + return mEntryList[index]->setMaterialParams(pMaterialParams); + } + return TEM_CHANGE_NONE; +} + S32 LLPrimTextureList::size() const { return mEntryList.size(); diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h index 691df44c18..d7fabbbb79 100644 --- a/indra/llprimitive/llprimtexturelist.h +++ b/indra/llprimitive/llprimtexturelist.h @@ -31,6 +31,7 @@ #include "lluuid.h" #include "v3color.h" #include "v4color.h" +#include "llmaterial.h" class LLTextureEntry; @@ -104,6 +105,7 @@ public: S32 setMediaFlags(const U8 index, const U8 media_flags); S32 setGlow(const U8 index, const F32 glow); S32 setMaterialID(const U8 index, const LLMaterialID& pMaterialID); + S32 setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); S32 size() const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index b04fa809d2..23b15b697c 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -540,6 +540,16 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) return TEM_CHANGE_NONE; } +S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) +{ + if (mMaterial != pMaterialParams) + { + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; + } + return TEM_CHANGE_NONE; +} + void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) { mMediaFlags |= MF_HAS_MEDIA; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index ff1cc65bba..c443ebcb30 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -124,6 +124,7 @@ public: S32 setMediaTexGen(U8 media); S32 setGlow(F32 glow); S32 setMaterialID(const LLMaterialID& pMaterialID); + S32 setMaterialParams(const LLMaterialPtr pMaterialParams); virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } @@ -143,6 +144,7 @@ public: U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } const LLMaterialID& getMaterialID() const { return mMaterialID; }; + const LLMaterialPtr getMaterialParams() const { return mMaterial; }; // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() -- cgit v1.2.3 From 90bf22ef24fbb8ff3497dd271abc7f7555a4f758 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 1 Feb 2013 10:20:44 -0500 Subject: add debug logging, ostream support for material ids, and some minor cleanup --- indra/llprimitive/llmaterialid.cpp | 7 +++++++ indra/llprimitive/llmaterialid.h | 2 ++ 2 files changed, 9 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 590f5cd91f..820f62c43c 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -150,6 +150,13 @@ std::string LLMaterialID::asString() const return materialIDString; } +std::ostream& operator<<(std::ostream& s, const LLMaterialID &material_id) +{ + s << material_id.asString(); + return s; +} + + void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) { llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 9db4065302..0a95204085 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -60,6 +60,8 @@ public: LLSD asLLSD() const; std::string asString() const; + friend std::ostream& operator<<(std::ostream& s, const LLMaterialID &material_id); + static const LLMaterialID null; private: -- cgit v1.2.3 From 72dfb2abce5d5635e7f81436d65c8689d161eb37 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 13 Feb 2013 17:28:05 -0500 Subject: SH-3812 WIP, SH-3852 WIP - some metrics cleanup, added rebake when needed and sb system is unavailable, to avoid stale appearance problems --- indra/llprimitive/llprimitive.cpp | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 indra/llprimitive/llprimitive.cpp (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp old mode 100644 new mode 100755 index 4e36723eec..faf98883d9 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1246,6 +1246,7 @@ S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name if (tec.size == 0) { + tec.face_count = 0; return retval; } -- cgit v1.2.3 From 354ccc1640dd223ccea20908183cc05a00ecaf6f Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 15 Feb 2013 13:44:21 -0500 Subject: additional safety check for bad appearance messages --- indra/llprimitive/llprimitive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index faf98883d9..cf6a3f97d2 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1259,7 +1259,7 @@ S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, block_num, LLTEContents::MAX_TE_BUFFER); } - tec.face_count = getNumTEs(); + tec.face_count = llmin((U32)getNumTEs(),LLTEContents::MAX_TES); U8 *cur_ptr = tec.packed_buffer; cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_data, 16, tec.face_count, MVT_LLUUID); -- cgit v1.2.3 From a6e8e60f5051ae27cb771e0404f1d5579ab85ebb Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 19 Feb 2013 21:21:41 +0100 Subject: Don't overrun the message buffer extracting materials ids when the region isn't sending them --- indra/llprimitive/llprimitive.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index d28cd89a1b..1a177f1c14 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1075,6 +1075,7 @@ S32 LLPrimitive::unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 dat } cur_ptr += data_size; } + llassert(cur_ptr <= buffer_end); return (S32)(cur_ptr - start_loc); } @@ -1328,8 +1329,15 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + if (cur_ptr < packed_buffer + size) + { + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + } + else + { + memset(material_data, 0, sizeof(material_data)); + } for (U32 i = 0; i < face_count; i++) { @@ -1429,8 +1437,15 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); cur_ptr++; cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); - cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + if (cur_ptr < packed_buffer + size) + { + cur_ptr++; + cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + } + else + { + memset(material_data, 0, sizeof(material_data)); + } for (i = 0; i < face_count; i++) { -- cgit v1.2.3 From 5711bda96abdb9da57ddc5d5fe9c26e72dc09b28 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 20 Feb 2013 12:03:29 -0500 Subject: clean up some debug logging, add comment on llassert --- indra/llprimitive/llprimitive.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 1a177f1c14..0578f0b192 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1052,7 +1052,7 @@ S32 LLPrimitive::unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 dat while ((cur_ptr < buffer_end) && (*cur_ptr != 0)) { -// llinfos << "TE exception" << llendl; + LL_DEBUGS("TEFieldDecode") << "TE exception" << LL_ENDL; i = 0; while (*cur_ptr & 0x80) { @@ -1067,15 +1067,16 @@ S32 LLPrimitive::unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 dat if (i & 0x01) { htonmemcpy(data_ptr+(j*data_size),cur_ptr,type,data_size); -// char foo[64]; -// sprintf(foo,"%x %x",*(data_ptr+(j*data_size)), *(data_ptr+(j*data_size)+1)); -// llinfos << "Assigning " << foo << " to face " << j << llendl; + LL_DEBUGS("TEFieldDecode") << "Assigning " ; + char foo[64]; + sprintf(foo,"%x %x",*(data_ptr+(j*data_size)), *(data_ptr+(j*data_size)+1)); + LL_CONT << foo << " to face " << j << LL_ENDL; } i = i >> 1; } cur_ptr += data_size; } - llassert(cur_ptr <= buffer_end); + llassert(cur_ptr <= buffer_end); // buffer underrun return (S32)(cur_ptr - start_loc); } -- cgit v1.2.3 From fbf8e51c6059791b12f60602b4dda0d72dc2d847 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 25 Feb 2013 00:16:14 +0100 Subject: Added LLMaterialMgr::remove() to remove material information from a face --- indra/llprimitive/llmaterial.cpp | 43 ++++++++++++++++++++++++++++------------ indra/llprimitive/llmaterial.h | 3 +++ 2 files changed, 33 insertions(+), 13 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 645fcf7b46..f6fd8e557a 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -55,11 +55,6 @@ * Materials constants */ -const LLColor4U MATERIALS_DEFAULT_SPECULAR_COLOR = LLColor4U(255, 255, 255, 255); -const U8 MATERIALS_DEFAULT_SPECULAR_EXP = 128; -const U8 MATERIALS_DEFAULT_ENV_INTENSITY = 128; -const U8 MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE = 0; -const U8 MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF = 128; const F32 MATERIALS_MULTIPLIER = 10000.f; /** @@ -94,11 +89,20 @@ template<> LLUUID getMaterialField(const LLSD& data, const std::string& field, c const LLMaterial LLMaterial::null; LLMaterial::LLMaterial() - : mSpecularLightColor(MATERIALS_DEFAULT_SPECULAR_COLOR) - , mSpecularLightExponent(MATERIALS_DEFAULT_SPECULAR_EXP) - , mEnvironmentIntensity(MATERIALS_DEFAULT_ENV_INTENSITY) - , mDiffuseAlphaMode(MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE) - , mAlphaMaskCutoff(MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF) + : mNormalOffsetX(.0f) + , mNormalOffsetY(.0f) + , mNormalRepeatX(.0f) + , mNormalRepeatY(.0f) + , mNormalRotation(.0f) + , mSpecularOffsetX(.0f) + , mSpecularOffsetY(.0f) + , mSpecularRepeatX(.0f) + , mSpecularRepeatY(.0f) + , mSpecularRotation(.0f) + , mSpecularLightExponent(0) + , mEnvironmentIntensity(0) + , mDiffuseAlphaMode(0) + , mAlphaMaskCutoff(0) { } @@ -159,8 +163,21 @@ void LLMaterial::fromLLSD(const LLSD& material_data) bool LLMaterial::isNull() const { - // *TODO: find a better way of defining a 'null' material? + return (*this == null); +} + +bool LLMaterial::operator == (const LLMaterial& rhs) const +{ return - (mNormalID.isNull()) && (.0f == mNormalOffsetX) && (.0f == mNormalOffsetY) && (.0f == mNormalRepeatX) && (.0f == mNormalRepeatY) && - (mSpecularID.isNull()) && (.0f == mSpecularOffsetX) && (.0f == mSpecularOffsetY) && (.0f == mSpecularRepeatX) && (.0f == mSpecularRepeatY); + (mNormalID == rhs.mNormalID) && (mNormalOffsetX == rhs.mNormalOffsetX) && (mNormalOffsetY == rhs.mNormalOffsetY) && + (mNormalRepeatX == rhs.mNormalRepeatX) && (mNormalRepeatY == rhs.mNormalRepeatY) && (mNormalRotation == rhs.mNormalRotation) && + (mSpecularID == rhs.mSpecularID) && (mSpecularOffsetX == rhs.mSpecularOffsetX) && (mSpecularOffsetY == rhs.mSpecularOffsetY) && + (mSpecularRepeatX == rhs.mSpecularRepeatX) && (mSpecularRepeatY == rhs.mSpecularRepeatY) && (mSpecularRotation == rhs.mSpecularRotation) && + (mSpecularLightColor == rhs.mSpecularLightColor) && (mSpecularLightExponent == rhs.mSpecularLightExponent) && + (mEnvironmentIntensity == rhs.mEnvironmentIntensity) && (mDiffuseAlphaMode == rhs.mDiffuseAlphaMode) && (mAlphaMaskCutoff == rhs.mAlphaMaskCutoff); +} + +bool LLMaterial::operator != (const LLMaterial& rhs) const +{ + return !(*this == rhs); } diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 6f94cfda17..5b56d11cd2 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -74,6 +74,9 @@ public: bool isNull() const; static const LLMaterial null; + bool operator == (const LLMaterial& rhs) const; + bool operator != (const LLMaterial& rhs) const; + protected: LLUUID mNormalID; F32 mNormalOffsetX; -- cgit v1.2.3 From 998c31ef9e0631eefe07e4e678032ee90c56c859 Mon Sep 17 00:00:00 2001 From: Nyx Linden Date: Tue, 26 Feb 2013 15:29:23 -0500 Subject: BUILDFIX fixing undefined reference in build --- indra/llprimitive/llprimitive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index cf6a3f97d2..c340fc2d35 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1259,7 +1259,7 @@ S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, block_num, LLTEContents::MAX_TE_BUFFER); } - tec.face_count = llmin((U32)getNumTEs(),LLTEContents::MAX_TES); + tec.face_count = llmin((U32)getNumTEs(),(U32)LLTEContents::MAX_TES); U8 *cur_ptr = tec.packed_buffer; cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_data, 16, tec.face_count, MVT_LLUUID); -- cgit v1.2.3 From 1816582b929737f92ee68a1422e3be4e7c02f542 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 6 Mar 2013 09:09:07 -0800 Subject: Fix crashes from using single alloc for pos/norm/tc in volume face data fighting with old free call in model loading code --- indra/llprimitive/llmodel.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 5ed05e2201..8f0120b064 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -194,6 +194,9 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa cv.setPosition(LLVector4a(v[idx[i+pos_offset]*3+0], v[idx[i+pos_offset]*3+1], v[idx[i+pos_offset]*3+2])); + + if (!cv.getPosition().isFinite3()) + return LLModel::BAD_ELEMENT; } if (tc_source) @@ -207,6 +210,8 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa cv.setNormal(LLVector4a(n[idx[i+norm_offset]*3+0], n[idx[i+norm_offset]*3+1], n[idx[i+norm_offset]*3+2])); + if (!cv.getNormal().isFinite3()) + return LLModel::BAD_ELEMENT; } BOOL found = FALSE; @@ -261,13 +266,13 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa LLVolumeFace& new_face = *face_list.rbegin(); if (!norm_source) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!tc_source) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } @@ -292,13 +297,13 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa LLVolumeFace& new_face = *face_list.rbegin(); if (!norm_source) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!tc_source) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } } @@ -480,13 +485,13 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac LLVolumeFace& new_face = *face_list.rbegin(); if (!norm_source) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!tc_source) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } @@ -514,13 +519,13 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac LLVolumeFace& new_face = *face_list.rbegin(); if (!norm_source) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!tc_source) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } } @@ -730,13 +735,13 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac LLVolumeFace& new_face = *face_list.rbegin(); if (!n) { - ll_aligned_free_16(new_face.mNormals); + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!t) { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } } @@ -1036,7 +1041,7 @@ void LLModel::setVolumeFaceData( } else { - ll_aligned_free_16(face.mNormals); + //ll_aligned_free_16(face.mNormals); face.mNormals = NULL; } @@ -1047,7 +1052,7 @@ void LLModel::setVolumeFaceData( } else { - ll_aligned_free_16(face.mTexCoords); + //ll_aligned_free_16(face.mTexCoords); face.mTexCoords = NULL; } @@ -1246,7 +1251,7 @@ void LLModel::generateNormals(F32 angle_cutoff) } else { - ll_aligned_free_16(new_face.mTexCoords); + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } -- cgit v1.2.3 From 2e8b2558b4b86b97dafec539792d14b66b2724d1 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 7 Mar 2013 14:13:14 -0800 Subject: For MAINT-2436 and MAINT-2388 contribs from STORM-1935 and STORM-1936 --- indra/llprimitive/llmodel.cpp | 114 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 8f0120b064..4ef4744981 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -186,32 +186,78 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa LLVolumeFace::VertexMapData::PointMap point_map; - for (U32 i = 0; i < idx.getCount(); i += idx_stride) + U32 index_count = idx.getCount(); + U32 vertex_count = pos_source ? v.getCount() : 0; + U32 tc_count = tc_source ? tc.getCount() : 0; + U32 norm_count = norm_source ? n.getCount() : 0; + + for (U32 i = 0; i < index_count; i += idx_stride) { LLVolumeFace::VertexData cv; if (pos_source) { + // guard against model data specifiying out of range indices or verts + // + if (((i + pos_offset) > index_count) + || ((idx[i+pos_offset]*3+2) > vertex_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.setPosition(LLVector4a(v[idx[i+pos_offset]*3+0], v[idx[i+pos_offset]*3+1], v[idx[i+pos_offset]*3+2])); if (!cv.getPosition().isFinite3()) + { return LLModel::BAD_ELEMENT; + } } if (tc_source) { + // guard against model data specifiying out of range indices or tcs + // + if (((i + tc_offset) > index_count) + || ((idx[i+pos_offset]*2+1) > tc_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.mTexCoord.setVec(tc[idx[i+tc_offset]*2+0], tc[idx[i+tc_offset]*2+1]); + + if (!cv.mTexCoord.isFinite()) + { + llwarns << "Found NaN while loading tex coords from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } if (norm_source) { + // guard against model data specifiying out of range indices or norms + // + if (((i + pos_offset) > index_count) + || ((idx[i+pos_offset]*3+2) > vertex_count)) + { + return LLModel::BAD_ELEMENT; + } + if (((i + norm_offset) > index_count) + || ((idx[i+norm_offset]*3+2) > norm_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.setNormal(LLVector4a(n[idx[i+norm_offset]*3+0], n[idx[i+norm_offset]*3+1], n[idx[i+norm_offset]*3+2])); + if (!cv.getNormal().isFinite3()) + { + llwarns << "Found NaN while loading normals from DAE-Model, invalid model." << llendl; return LLModel::BAD_ELEMENT; + } } BOOL found = FALSE; @@ -369,6 +415,11 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac LLVolumeFace::VertexMapData::PointMap point_map; + U32 index_count = idx.getCount(); + U32 vertex_count = pos_source ? v.getCount() : 0; + U32 tc_count = tc_source ? tc.getCount() : 0; + U32 norm_count = norm_source ? n.getCount() : 0; + U32 cur_idx = 0; for (U32 i = 0; i < vcount.getCount(); ++i) { //for each polygon @@ -381,22 +432,65 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac if (pos_source) { + // guard against model data specifiying out of range indices or verts + // + if (((i + pos_offset) > index_count) + || ((idx[i+pos_offset]*3+2) > vertex_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.getPosition().set(v[idx[cur_idx+pos_offset]*3+0], v[idx[cur_idx+pos_offset]*3+1], v[idx[cur_idx+pos_offset]*3+2]); + + if (!cv.getPosition().isFinite3()) + { + llwarns << "Found NaN while loading positions from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } + } if (tc_source) { + // guard against model data specifiying out of range indices or tcs + // + if (((i + pos_offset) > index_count) + || ((idx[cur_idx+tc_offset]*2+1) > tc_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.mTexCoord.setVec(tc[idx[cur_idx+tc_offset]*2+0], tc[idx[cur_idx+tc_offset]*2+1]); + + if (!cv.mTexCoord.isFinite()) + { + llwarns << "Found NaN while loading tex coords from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } if (norm_source) { + // guard against model data specifiying out of range indices or norms + // + if (((i + pos_offset) > index_count) + || ((idx[cur_idx+norm_offset]*3+2) > norm_count)) + { + return LLModel::BAD_ELEMENT; + } + cv.getNormal().set(n[idx[cur_idx+norm_offset]*3+0], n[idx[cur_idx+norm_offset]*3+1], n[idx[cur_idx+norm_offset]*3+2]); + + if (!cv.getNormal().isFinite3()) + { + llwarns << "Found NaN while loading normals from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } cur_idx += idx_stride; @@ -637,6 +731,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac vert.getPosition().set(v->get(v_idx), v->get(v_idx+1), v->get(v_idx+2)); + + if (!vert.getPosition().isFinite3()) + { + llwarns << "Found NaN while loading position data from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } //bounds check n and t lookups because some FBX to DAE converters @@ -649,6 +749,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac vert.getNormal().set(n->get(n_idx), n->get(n_idx+1), n->get(n_idx+2)); + + if (!vert.getNormal().isFinite3()) + { + llwarns << "Found NaN while loading normals from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } else { @@ -662,6 +768,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac t_idx = llclamp(t_idx, (U32) 0, (U32) t->getCount()); vert.mTexCoord.setVec(t->get(t_idx), t->get(t_idx+1)); + + if (!vert.mTexCoord.isFinite()) + { + llwarns << "Found NaN while loading tex coords from DAE-Model, invalid model." << llendl; + return LLModel::BAD_ELEMENT; + } } else { -- cgit v1.2.3 From 4b67d34c7e31e7dcc8185061e4a0b02c5da6560a Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 7 Mar 2013 15:45:29 -0800 Subject: Remove redundant data validation copy-pasted into normals loop --- indra/llprimitive/llmodel.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 4ef4744981..ef6eb75a6b 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -238,11 +238,6 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa { // guard against model data specifiying out of range indices or norms // - if (((i + pos_offset) > index_count) - || ((idx[i+pos_offset]*3+2) > vertex_count)) - { - return LLModel::BAD_ELEMENT; - } if (((i + norm_offset) > index_count) || ((idx[i+norm_offset]*3+2) > norm_count)) { -- cgit v1.2.3 From 6300f4f768de13823a754831797cb34022f87b60 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 27 Mar 2013 21:59:14 -0500 Subject: NORSPEC-61 Hook up material parameters to shaders. --- indra/llprimitive/llmaterial.cpp | 33 +++++++++++++++++++++++++++++++++ indra/llprimitive/llmaterial.h | 16 ++++++++++++++++ 2 files changed, 49 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index f6fd8e557a..7d1ce4ab86 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -181,3 +181,36 @@ bool LLMaterial::operator != (const LLMaterial& rhs) const { return !(*this == rhs); } + + +U32 LLMaterial::getShaderMask() +{ //NEVER incorporate this value into the message system -- this function will vary depending on viewer implementation + U32 ret = 0; + + //two least significant bits are "diffuse alpha mode" + ret = getDiffuseAlphaMode(); + + llassert(ret < SHADER_COUNT); + + //next bit is whether or not specular map is present + const U32 SPEC_BIT = 0x4; + + if (getSpecularID().notNull()) + { + ret |= SPEC_BIT; + } + + llassert(ret < SHADER_COUNT); + + //next bit is whether or not normal map is present + const U32 NORM_BIT = 0x8; + if (getNormalID().notNull()) + { + ret |= NORM_BIT; + } + + llassert(ret < SHADER_COUNT); + + return ret; +} + diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 5b56d11cd2..fd35045e45 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -36,6 +36,20 @@ class LLMaterial { public: + + typedef enum + { + DIFFUSE_ALPHA_MODE_NONE = 0, + DIFFUSE_ALPHA_MODE_BLEND = 1, + DIFFUSE_ALPHA_MODE_MASK = 2, + DIFFUSE_ALPHA_MODE_EMISSIVE = 3 + } eDiffuseAlphaMode; + + typedef enum + { + SHADER_COUNT = 16 + } eShaderCount; + LLMaterial(); LLMaterial(const LLSD& material_data); @@ -77,6 +91,8 @@ public: bool operator == (const LLMaterial& rhs) const; bool operator != (const LLMaterial& rhs) const; + U32 getShaderMask(); + protected: LLUUID mNormalID; F32 mNormalOffsetX; -- cgit v1.2.3 From bf6182daa8b4d7cea79310547f71d7a3155e17b0 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 29 Mar 2013 07:50:08 -0700 Subject: Update Mac and Windows breakpad builds to latest --- indra/llprimitive/CMakeLists.txt | 0 indra/llprimitive/legacy_object_types.h | 0 indra/llprimitive/llmaterialtable.cpp | 0 indra/llprimitive/llmaterialtable.h | 0 indra/llprimitive/llmediaentry.cpp | 0 indra/llprimitive/llmediaentry.h | 0 indra/llprimitive/llmodel.cpp | 0 indra/llprimitive/llmodel.h | 0 indra/llprimitive/llprimitive.cpp | 0 indra/llprimitive/llprimitive.h | 0 indra/llprimitive/llprimlinkinfo.h | 0 indra/llprimitive/llprimtexturelist.cpp | 0 indra/llprimitive/llprimtexturelist.h | 0 indra/llprimitive/lltextureanim.cpp | 0 indra/llprimitive/lltextureanim.h | 0 indra/llprimitive/lltextureentry.cpp | 0 indra/llprimitive/lltextureentry.h | 0 indra/llprimitive/lltree_common.h | 0 indra/llprimitive/lltreeparams.cpp | 0 indra/llprimitive/lltreeparams.h | 0 indra/llprimitive/llvolumemessage.cpp | 0 indra/llprimitive/llvolumemessage.h | 0 indra/llprimitive/llvolumexml.cpp | 0 indra/llprimitive/llvolumexml.h | 0 indra/llprimitive/material_codes.cpp | 0 indra/llprimitive/material_codes.h | 0 indra/llprimitive/object_flags.h | 0 indra/llprimitive/tests/llmediaentry_test.cpp | 0 indra/llprimitive/tests/llmessagesystem_stub.cpp | 0 indra/llprimitive/tests/llprimitive_test.cpp | 0 30 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 indra/llprimitive/CMakeLists.txt mode change 100644 => 100755 indra/llprimitive/legacy_object_types.h mode change 100644 => 100755 indra/llprimitive/llmaterialtable.cpp mode change 100644 => 100755 indra/llprimitive/llmaterialtable.h mode change 100644 => 100755 indra/llprimitive/llmediaentry.cpp mode change 100644 => 100755 indra/llprimitive/llmediaentry.h mode change 100644 => 100755 indra/llprimitive/llmodel.cpp mode change 100644 => 100755 indra/llprimitive/llmodel.h mode change 100644 => 100755 indra/llprimitive/llprimitive.cpp mode change 100644 => 100755 indra/llprimitive/llprimitive.h mode change 100644 => 100755 indra/llprimitive/llprimlinkinfo.h mode change 100644 => 100755 indra/llprimitive/llprimtexturelist.cpp mode change 100644 => 100755 indra/llprimitive/llprimtexturelist.h mode change 100644 => 100755 indra/llprimitive/lltextureanim.cpp mode change 100644 => 100755 indra/llprimitive/lltextureanim.h mode change 100644 => 100755 indra/llprimitive/lltextureentry.cpp mode change 100644 => 100755 indra/llprimitive/lltextureentry.h mode change 100644 => 100755 indra/llprimitive/lltree_common.h mode change 100644 => 100755 indra/llprimitive/lltreeparams.cpp mode change 100644 => 100755 indra/llprimitive/lltreeparams.h mode change 100644 => 100755 indra/llprimitive/llvolumemessage.cpp mode change 100644 => 100755 indra/llprimitive/llvolumemessage.h mode change 100644 => 100755 indra/llprimitive/llvolumexml.cpp mode change 100644 => 100755 indra/llprimitive/llvolumexml.h mode change 100644 => 100755 indra/llprimitive/material_codes.cpp mode change 100644 => 100755 indra/llprimitive/material_codes.h mode change 100644 => 100755 indra/llprimitive/object_flags.h mode change 100644 => 100755 indra/llprimitive/tests/llmediaentry_test.cpp mode change 100644 => 100755 indra/llprimitive/tests/llmessagesystem_stub.cpp mode change 100644 => 100755 indra/llprimitive/tests/llprimitive_test.cpp (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/indra/llprimitive/legacy_object_types.h b/indra/llprimitive/legacy_object_types.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmaterialtable.cpp b/indra/llprimitive/llmaterialtable.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmaterialtable.h b/indra/llprimitive/llmaterialtable.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmediaentry.cpp b/indra/llprimitive/llmediaentry.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmediaentry.h b/indra/llprimitive/llmediaentry.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimlinkinfo.h b/indra/llprimitive/llprimlinkinfo.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltextureanim.cpp b/indra/llprimitive/lltextureanim.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltextureanim.h b/indra/llprimitive/lltextureanim.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltree_common.h b/indra/llprimitive/lltree_common.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltreeparams.cpp b/indra/llprimitive/lltreeparams.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/lltreeparams.h b/indra/llprimitive/lltreeparams.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llvolumemessage.cpp b/indra/llprimitive/llvolumemessage.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llvolumemessage.h b/indra/llprimitive/llvolumemessage.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llvolumexml.cpp b/indra/llprimitive/llvolumexml.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/llvolumexml.h b/indra/llprimitive/llvolumexml.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/material_codes.cpp b/indra/llprimitive/material_codes.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/material_codes.h b/indra/llprimitive/material_codes.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/object_flags.h b/indra/llprimitive/object_flags.h old mode 100644 new mode 100755 diff --git a/indra/llprimitive/tests/llmediaentry_test.cpp b/indra/llprimitive/tests/llmediaentry_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/tests/llmessagesystem_stub.cpp b/indra/llprimitive/tests/llmessagesystem_stub.cpp old mode 100644 new mode 100755 diff --git a/indra/llprimitive/tests/llprimitive_test.cpp b/indra/llprimitive/tests/llprimitive_test.cpp old mode 100644 new mode 100755 -- cgit v1.2.3 From f189ba4a3d927fe0ecfb83b36b60a47c88525fdd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 3 Apr 2013 16:56:59 -0500 Subject: NORSPEC-71 Lots more UI hookups Written with and Reviewed By Graham --- indra/llprimitive/llmaterial.h | 6 ++++-- indra/llprimitive/lltextureentry.cpp | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index fd35045e45..dc3484309c 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -32,8 +32,10 @@ #include "llmaterialid.h" #include "llsd.h" #include "v4coloru.h" +#include "llpointer.h" +#include "llrefcount.h" -class LLMaterial +class LLMaterial : public LLRefCount { public: @@ -115,6 +117,6 @@ protected: U8 mAlphaMaskCutoff; }; -typedef boost::shared_ptr LLMaterialPtr; +typedef LLPointer LLMaterialPtr; #endif // LL_LLMATERIAL_H diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 23b15b697c..691216e035 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -535,6 +535,10 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) if (mMaterialID != pMaterialID) { mMaterialID = pMaterialID; + if (mMaterialID.isNull()) + { + setMaterialParams(NULL); + } return TEM_CHANGE_TEXTURE; } return TEM_CHANGE_NONE; -- cgit v1.2.3 From 9e3155c368fba6cb877c55ad4e0c90258a6e9ba9 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 8 Apr 2013 11:40:10 -0700 Subject: NORSPEC-82 NORSPEC-85 More UI shenanigans --- indra/llprimitive/llmaterial.cpp | 6 +++++- indra/llprimitive/llmaterial.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 7d1ce4ab86..1e92847b38 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -51,6 +51,8 @@ #define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" #define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" +const LLColor4U LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR = LLColor4U::white; + /** * Materials constants */ @@ -99,7 +101,8 @@ LLMaterial::LLMaterial() , mSpecularRepeatX(.0f) , mSpecularRepeatY(.0f) , mSpecularRotation(.0f) - , mSpecularLightExponent(0) + , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR) + , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT) , mEnvironmentIntensity(0) , mDiffuseAlphaMode(0) , mAlphaMaskCutoff(0) @@ -214,3 +217,4 @@ U32 LLMaterial::getShaderMask() return ret; } + diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index dc3484309c..bedfc8f8c2 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -52,6 +52,9 @@ public: SHADER_COUNT = 16 } eShaderCount; + static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); + static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; + LLMaterial(); LLMaterial(const LLSD& material_data); @@ -120,3 +123,4 @@ protected: typedef LLPointer LLMaterialPtr; #endif // LL_LLMATERIAL_H + -- cgit v1.2.3 From bd3716b7758ab27f929da1608260eafd4212c5d8 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 8 Apr 2013 11:40:10 -0700 Subject: NORSPEC-82 NORSPEC-85 More UI shenanigans --- indra/llprimitive/llmaterial.cpp | 6 +++++- indra/llprimitive/llmaterial.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 7d1ce4ab86..1e92847b38 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -51,6 +51,8 @@ #define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" #define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" +const LLColor4U LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR = LLColor4U::white; + /** * Materials constants */ @@ -99,7 +101,8 @@ LLMaterial::LLMaterial() , mSpecularRepeatX(.0f) , mSpecularRepeatY(.0f) , mSpecularRotation(.0f) - , mSpecularLightExponent(0) + , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR) + , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT) , mEnvironmentIntensity(0) , mDiffuseAlphaMode(0) , mAlphaMaskCutoff(0) @@ -214,3 +217,4 @@ U32 LLMaterial::getShaderMask() return ret; } + diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index dc3484309c..bedfc8f8c2 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -52,6 +52,9 @@ public: SHADER_COUNT = 16 } eShaderCount; + static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); + static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; + LLMaterial(); LLMaterial(const LLSD& material_data); @@ -120,3 +123,4 @@ protected: typedef LLPointer LLMaterialPtr; #endif // LL_LLMATERIAL_H + -- cgit v1.2.3 From fafa21315f043ab51e3373e825c85646685778a6 Mon Sep 17 00:00:00 2001 From: g Date: Fri, 12 Apr 2013 15:21:35 -0700 Subject: Fix issue with alphaNonIndexedNoColorF shader and static init fail on default spec color (real source of NORSPEC-94, I think) --- indra/llprimitive/llmaterial.cpp | 6 +++--- indra/llprimitive/llmaterial.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 1e92847b38..bd98aa040a 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -51,7 +51,7 @@ #define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" #define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" -const LLColor4U LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR = LLColor4U::white; +const LLColor4U LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR(255,255,255,255); /** * Materials constants @@ -103,8 +103,8 @@ LLMaterial::LLMaterial() , mSpecularRotation(.0f) , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR) , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT) - , mEnvironmentIntensity(0) - , mDiffuseAlphaMode(0) + , mEnvironmentIntensity(LLMaterial::DEFAULT_ENV_INTENSITY) + , mDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) , mAlphaMaskCutoff(0) { } diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index bedfc8f8c2..c2e49985a4 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -54,6 +54,7 @@ public: static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; + static const U8 DEFAULT_ENV_INTENSITY = ((U8)(0.05f * 255)); LLMaterial(); LLMaterial(const LLSD& material_data); -- cgit v1.2.3 From 0b4d76ce7856b060d4682955548ff047326c0aee Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 16 Apr 2013 08:27:30 -0700 Subject: NORSPEC-123 et al...roll back NSPEC 91 fix to avoid knock-on and set correct default env intensity --- indra/llprimitive/llmaterial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index c2e49985a4..df5a45cabd 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -54,7 +54,7 @@ public: static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; - static const U8 DEFAULT_ENV_INTENSITY = ((U8)(0.05f * 255)); + static const U8 DEFAULT_ENV_INTENSITY = 0; LLMaterial(); LLMaterial(const LLSD& material_data); -- cgit v1.2.3 From 67af268b785e8a47d7db10aa3a566c269b0f16e3 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 17 Apr 2013 01:51:39 -0500 Subject: NORSPEC-90 Alpha pool hookups for materials. --- indra/llprimitive/llmaterial.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index c2e49985a4..3145891393 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -49,8 +49,11 @@ public: typedef enum { - SHADER_COUNT = 16 + SHADER_COUNT = 16, + ALPHA_SHADER_COUNT = 4 } eShaderCount; + + static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; -- cgit v1.2.3 From 806d09b1143894ad66cea2c228f467e8c39a8adf Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 30 Apr 2013 19:50:05 -0700 Subject: Merge 3.5.1 into Materials --- indra/llprimitive/CMakeLists.txt | 15 ++++- indra/llprimitive/llprimitive.cpp | 138 +++++++++++++++++++------------------- indra/llprimitive/llprimitive.h | 31 +++++++++ 3 files changed, 113 insertions(+), 71 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 4eef1673f4..0dd13916bf 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -14,10 +14,14 @@ include_directories( ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS} - ${LLPHYSICSEXTENSIONS_INCLUDE_DIRS} ${LIBS_PREBUILT_DIR}/include/collada ${LIBS_PREBUILT_DIR}/include/collada/1.4 ) +include_directories(SYSTEM + ${LLCOMMON_SYSTEM_INCLUDE_DIRS} + ${LLXML_SYSTEM_INCLUDE_DIRS} + ${LLPHYSICSEXTENSIONS_INCLUDE_DIRS} + ) set(llprimitive_SOURCE_FILES llmaterialid.cpp @@ -63,6 +67,15 @@ list(APPEND llprimitive_SOURCE_FILES ${llprimitive_HEADER_FILES}) add_library (llprimitive ${llprimitive_SOURCE_FILES}) +target_link_libraries(llprimitive + ${LLCOMMON_LIBRARIES} + ${LLMATH_LIBRARIES} + ${LLMESSAGE_LIBRARIES} + ${LLXML_LIBRARIES} + ${LLPHYSICSEXTENSIONS_LIBRARIES} + ) + + #add unit tests if (LL_TESTS) INCLUDE(LLAddBuildTest) diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 0578f0b192..4a3fd03242 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -38,6 +38,7 @@ #include "lldatapacker.h" #include "llsdutil_math.h" #include "llprimtexturelist.h" +#include "imageids.h" #include "llmaterialid.h" /** @@ -268,6 +269,7 @@ S32 LLPrimitive::setTEScale(const U8 index, const F32 s, const F32 t) return mTextureList.setScale(index, s, t); } + // BUG: slow - done this way because texture entries have some // voodoo related to texture coords S32 LLPrimitive::setTEScaleS(const U8 index, const F32 s) @@ -313,6 +315,15 @@ S32 LLPrimitive::setTERotation(const U8 index, const F32 r) return mTextureList.setRotation(index, r); } +S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID) +{ + return mTextureList.setMaterialID(index, pMaterialID); +} + +S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) +{ + return mTextureList.setMaterialParams(index, pMaterialParams); +} //=============================================================== S32 LLPrimitive::setTEBumpShinyFullbright(const U8 index, const U8 bump) @@ -363,16 +374,6 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } -S32 LLPrimitive::setTEMaterialID(const U8 index, const LLMaterialID& pMaterialID) -{ - return mTextureList.setMaterialID(index, pMaterialID); -} - -S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) -{ - return mTextureList.setMaterialParams(index, pMaterialParams); -} - LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? @@ -1253,112 +1254,100 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const return FALSE; } -S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name) +S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec) { - return(unpackTEMessage(mesgsys,block_name,-1)); -} - -S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num) -{ - // use a negative block_num to indicate a single-block read (a non-variable block) S32 retval = 0; - const U32 MAX_TES = 32; - - // Avoid construction of 32 UUIDs per call. JC - static LLMaterialID material_ids[MAX_TES]; - - U8 image_data[MAX_TES*16]; - U8 colors[MAX_TES*4]; - F32 scale_s[MAX_TES]; - F32 scale_t[MAX_TES]; - S16 offset_s[MAX_TES]; - S16 offset_t[MAX_TES]; - S16 image_rot[MAX_TES]; - U8 bump[MAX_TES]; - U8 media_flags[MAX_TES]; - U8 glow[MAX_TES]; - U8 material_data[MAX_TES*16]; - - const U32 MAX_TE_BUFFER = 4096; - U8 packed_buffer[MAX_TE_BUFFER]; - U8 *cur_ptr = packed_buffer; - U32 size; - U32 face_count = 0; + // temp buffer for material ID processing + // data will end up in tec.material_id[] + U8 material_data[LLTEContents::MAX_TES*16]; if (block_num < 0) { - size = mesgsys->getSizeFast(block_name, _PREHASH_TextureEntry); + tec.size = mesgsys->getSizeFast(block_name, _PREHASH_TextureEntry); } else { - size = mesgsys->getSizeFast(block_name, block_num, _PREHASH_TextureEntry); + tec.size = mesgsys->getSizeFast(block_name, block_num, _PREHASH_TextureEntry); } - if (size == 0) + if (tec.size == 0) { + tec.face_count = 0; return retval; } if (block_num < 0) { - mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, packed_buffer, 0, 0, MAX_TE_BUFFER); + mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, 0, LLTEContents::MAX_TE_BUFFER); } else { - mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, packed_buffer, 0, block_num, MAX_TE_BUFFER); + mesgsys->getBinaryDataFast(block_name, _PREHASH_TextureEntry, tec.packed_buffer, 0, block_num, LLTEContents::MAX_TE_BUFFER); } - face_count = getNumTEs(); + tec.face_count = llmin((U32)getNumTEs(),(U32)LLTEContents::MAX_TES); - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_data, 16, face_count, MVT_LLUUID); + U8 *cur_ptr = tec.packed_buffer; + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_data, 16, tec.face_count, MVT_LLUUID); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)colors, 4, face_count, MVT_U8); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.colors, 4, tec.face_count, MVT_U8); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_s, 4, face_count, MVT_F32); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.scale_s, 4, tec.face_count, MVT_F32); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_t, 4, face_count, MVT_F32); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.scale_t, 4, tec.face_count, MVT_F32); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_s, 2, face_count, MVT_S16Array); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.offset_s, 2, tec.face_count, MVT_S16Array); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_t, 2, face_count, MVT_S16Array); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.offset_t, 2, tec.face_count, MVT_S16Array); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)image_rot, 2, face_count, MVT_S16Array); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.image_rot, 2, tec.face_count, MVT_S16Array); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)bump, 1, face_count, MVT_U8); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.bump, 1, tec.face_count, MVT_U8); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.media_flags, 1, tec.face_count, MVT_U8); cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8); - if (cur_ptr < packed_buffer + size) + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)tec.glow, 1, tec.face_count, MVT_U8); + + if (cur_ptr < tec.packed_buffer + tec.size) { cur_ptr++; - cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)material_data, 16, face_count, MVT_LLUUID); + cur_ptr += unpackTEField(cur_ptr, tec.packed_buffer+tec.size, (U8 *)material_data, 16, tec.face_count, MVT_LLUUID); } else { memset(material_data, 0, sizeof(material_data)); } - for (U32 i = 0; i < face_count; i++) + for (U32 i = 0; i < tec.face_count; i++) { - material_ids[i].set(&material_data[i * 16]); + tec.material_ids[i].set(&material_data[i * 16]); } + retval = 1; + return retval; +} + +S32 LLPrimitive::applyParsedTEMessage(LLTEContents& tec) +{ + S32 retval = 0; + LLColor4 color; LLColor4U coloru; - for (U32 i = 0; i < face_count; i++) - { - retval |= setTETexture(i, ((LLUUID*)image_data)[i]); - retval |= setTEScale(i, scale_s[i], scale_t[i]); - retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF); - retval |= setTERotation(i, ((F32)image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI); - retval |= setTEBumpShinyFullbright(i, bump[i]); - retval |= setTEMediaTexGen(i, media_flags[i]); - retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF); - retval |= setTEMaterialID(i, material_ids[i]); + for (U32 i = 0; i < tec.face_count; i++) + { + LLUUID& req_id = ((LLUUID*)tec.image_data)[i]; + retval |= setTETexture(i, req_id); + retval |= setTEScale(i, tec.scale_s[i], tec.scale_t[i]); + retval |= setTEOffset(i, (F32)tec.offset_s[i] / (F32)0x7FFF, (F32) tec.offset_t[i] / (F32) 0x7FFF); + retval |= setTERotation(i, ((F32)tec.image_rot[i] / TEXTURE_ROTATION_PACK_FACTOR) * F_TWO_PI); + retval |= setTEBumpShinyFullbright(i, tec.bump[i]); + retval |= setTEMediaTexGen(i, tec.media_flags[i]); + retval |= setTEGlow(i, (F32)tec.glow[i] / (F32)0xFF); - coloru = LLColor4U(colors + 4*i); + retval |= setTEMaterialID(i, tec.material_ids[i]); + + coloru = LLColor4U(tec.colors + 4*i); // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) // as all zeros. However, the subtraction and addition must be done in unsigned @@ -1375,6 +1364,15 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_nam return retval; } +S32 LLPrimitive::unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num) +{ + LLTEContents tec; + S32 retval = parseTEMessage(mesgsys, block_name, block_num, tec); + if (!retval) + return retval; + return applyParsedTEMessage(tec); +} + S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp) { // use a negative block_num to indicate a single-block read (a non-variable block) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 6a9c5e9639..6f3657cd9b 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -290,6 +290,35 @@ public: }; +// This code is not naming-standards compliant. Leaving it like this for +// now to make the connection to code in +// BOOL packTEMessage(LLDataPacker &dp) const; +// more obvious. This should be refactored to remove the duplication, at which +// point we can fix the names as well. +// - Vir +struct LLTEContents +{ + static const U32 MAX_TES = 32; + + U8 image_data[MAX_TES*16]; + U8 colors[MAX_TES*4]; + F32 scale_s[MAX_TES]; + F32 scale_t[MAX_TES]; + S16 offset_s[MAX_TES]; + S16 offset_t[MAX_TES]; + S16 image_rot[MAX_TES]; + U8 bump[MAX_TES]; + U8 media_flags[MAX_TES]; + U8 glow[MAX_TES]; + LLMaterialID material_ids[MAX_TES]; + + static const U32 MAX_TE_BUFFER = 4096; + U8 packed_buffer[MAX_TE_BUFFER]; + + U32 size; + U32 face_count; +}; + class LLPrimitive : public LLXform { public: @@ -366,6 +395,8 @@ public: S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name); S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num); // Variable num of blocks BOOL unpackTEMessage(LLDataPacker &dp); + S32 parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec); + S32 applyParsedTEMessage(LLTEContents& tec); #ifdef CHECK_FOR_FINITE inline void setPosition(const LLVector3& pos); -- cgit v1.2.3 From 18e3985120d53acdf07d43dce79312b78629e57a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 6 May 2013 15:44:44 -0500 Subject: NORSPEC-162 Fix for objects with materials set ignoring "tranparency %" value. --- indra/llprimitive/llmaterial.cpp | 11 +++++++++-- indra/llprimitive/llmaterial.h | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index bd98aa040a..ce443dea1d 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -186,12 +186,19 @@ bool LLMaterial::operator != (const LLMaterial& rhs) const } -U32 LLMaterial::getShaderMask() +U32 LLMaterial::getShaderMask(U32 alpha_mode) { //NEVER incorporate this value into the message system -- this function will vary depending on viewer implementation U32 ret = 0; //two least significant bits are "diffuse alpha mode" - ret = getDiffuseAlphaMode(); + if (alpha_mode != DIFFUSE_ALPHA_MODE_DEFAULT) + { + ret = alpha_mode; + } + else + { + ret = getDiffuseAlphaMode(); + } llassert(ret < SHADER_COUNT); diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index b294288c64..b265732adc 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -44,7 +44,8 @@ public: DIFFUSE_ALPHA_MODE_NONE = 0, DIFFUSE_ALPHA_MODE_BLEND = 1, DIFFUSE_ALPHA_MODE_MASK = 2, - DIFFUSE_ALPHA_MODE_EMISSIVE = 3 + DIFFUSE_ALPHA_MODE_EMISSIVE = 3, + DIFFUSE_ALPHA_MODE_DEFAULT = 4, } eDiffuseAlphaMode; typedef enum @@ -100,7 +101,7 @@ public: bool operator == (const LLMaterial& rhs) const; bool operator != (const LLMaterial& rhs) const; - U32 getShaderMask(); + U32 getShaderMask(U32 alpha_mode = DIFFUSE_ALPHA_MODE_DEFAULT); protected: LLUUID mNormalID; -- cgit v1.2.3 From dbfcd6c9c5709b74365c2538ba312685b09d22bf Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 May 2013 17:20:33 -0500 Subject: Optimization -- don't draw glow in alpha pool unless needed --- indra/llprimitive/llmodel.cpp | 37 +++++++++++++++++++++++++++++++++++++ indra/llprimitive/llmodel.h | 4 +++- 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index ef6eb75a6b..e236f98fe6 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1122,6 +1122,43 @@ void LLModel::getNormalizedScaleTranslation(LLVector3& scale_out, LLVector3& tra translation_out = mNormalizedTranslation; } +LLVector3 LLModel::getTransformedCenter(const LLMatrix4& mat) +{ + LLVector3 ret; + + if (!mVolumeFaces.empty()) + { + LLMatrix4a m; + m.loadu(mat); + + LLVector4a minv,maxv; + + LLVector4a t; + m.affineTransform(mVolumeFaces[0].mPositions[0], t); + minv = maxv = t; + + for (S32 i = 0; i < mVolumeFaces.size(); ++i) + { + LLVolumeFace& face = mVolumeFaces[i]; + + for (U32 j = 0; j < face.mNumVertices; ++j) + { + m.affineTransform(face.mPositions[j],t); + update_min_max(minv, maxv, t); + } + } + + minv.add(maxv); + minv.mul(0.5f); + + ret.set(minv.getF32ptr()); + } + + return ret; +} + + + void LLModel::setNumVolumeFaces(S32 count) { mVolumeFaces.resize(count); diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index 1cf528fd9f..aaafc55258 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -173,13 +173,15 @@ public: void optimizeVolumeFaces(); void offsetMesh( const LLVector3& pivotPoint ); void getNormalizedScaleTranslation(LLVector3& scale_out, LLVector3& translation_out); - + LLVector3 getTransformedCenter(const LLMatrix4& mat); + //reorder face list based on mMaterialList in this and reference so //order matches that of reference (material ordering touchup) bool matchMaterialOrder(LLModel* ref, int& refFaceCnt, int& modelFaceCnt ); bool isMaterialListSubset( LLModel* ref ); bool needToAddFaces( LLModel* ref, int& refFaceCnt, int& modelFaceCnt ); + std::vector mMaterialList; //data used for skin weights -- cgit v1.2.3 From 5aa3f3c808976c3b709bd8141d4338e910c49691 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Thu, 9 May 2013 15:41:07 -0700 Subject: NORSPEC-164 fix TE copy ctor and operator= to include material pointer in addition to ID --- indra/llprimitive/lltextureentry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 691216e035..53816266eb 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -85,7 +85,7 @@ LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; mMaterialID = rhs.mMaterialID; - + mMaterial = rhs.mMaterial; if (rhs.mMediaEntry != NULL) { // Make a copy mMediaEntry = new LLMediaEntry(*rhs.mMediaEntry); @@ -107,6 +107,7 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs) mMediaFlags = rhs.mMediaFlags; mGlow = rhs.mGlow; mMaterialID = rhs.mMaterialID; + mMaterial = rhs.mMaterial; if (mMediaEntry != NULL) { delete mMediaEntry; } -- cgit v1.2.3 From 269b8b7de53f368791fbffde8a6f8d47d9cbbcdc Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Fri, 10 May 2013 10:50:50 +0200 Subject: NORSPEC-102 Rapid materials updates are not smooth to viewer which is editing the object --- indra/llprimitive/llprimitive.cpp | 18 ++++++++++++++++++ indra/llprimitive/llprimitive.h | 2 ++ indra/llprimitive/lltextureentry.cpp | 20 +++++++++++++++++++- indra/llprimitive/lltextureentry.h | 6 ++++++ 4 files changed, 45 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 0578f0b192..3f57dbe26d 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -373,6 +373,24 @@ S32 LLPrimitive::setTEMaterialParams(const U8 index, const LLMaterialPtr pMateri return mTextureList.setMaterialParams(index, pMaterialParams); } +void LLPrimitive::setAllTESelected(bool sel) +{ + for (int i = 0, cnt = getNumTEs(); i < cnt; i++) + { + setTESelected(i, sel); + } +} + +void LLPrimitive::setTESelected(const U8 te, bool sel) +{ + LLTextureEntry* tep = getTE(te); + if ( (tep) && (tep->setSelected(sel)) && (!sel) && (tep->hasPendingMaterialUpdate()) ) + { + LLMaterialID material_id = tep->getMaterialID(); + setTEMaterialID(te, material_id); + } +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 6a9c5e9639..dc21af2649 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -332,6 +332,7 @@ public: LLTextureEntry* getTE(const U8 te_num) const; virtual void setNumTEs(const U8 num_tes); + virtual void setAllTESelected(bool sel); 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); @@ -357,6 +358,7 @@ public: virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed + virtual void setTESelected(const U8 te, bool sel); void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 691216e035..6e5d27bb94 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -61,18 +61,24 @@ LLTextureEntry* LLTextureEntry::newTextureEntry() //=============================================================== LLTextureEntry::LLTextureEntry() : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(LLUUID::null,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { mID = rhs.mID; mScaleS = rhs.mScaleS; @@ -532,8 +538,16 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if (mMaterialID != pMaterialID) + if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) { + if (mSelected) + { + mMaterialUpdatePending = true; + mMaterialID = pMaterialID; + return TEM_CHANGE_NONE; + } + + mMaterialUpdatePending = false; mMaterialID = pMaterialID; if (mMaterialID.isNull()) { @@ -548,6 +562,10 @@ S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { if (mMaterial != pMaterialParams) { + if (mSelected) + { + mMaterialUpdatePending = true; + } mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index c443ebcb30..f867f45819 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -99,6 +99,10 @@ public: virtual LLTextureEntry* newCopy() const; void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); + + bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; } + bool isSelected() const { return mSelected; } + bool setSelected(bool sel) { bool prev_sel = mSelected; mSelected = sel; return prev_sel; } // These return a TEM_ flag from above to indicate if something changed. S32 setID (const LLUUID &tex_id); @@ -194,11 +198,13 @@ public: static const char* TEXTURE_MEDIA_DATA_KEY; protected: + bool mSelected; LLUUID mID; // Texture GUID LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; -- cgit v1.2.3 From e413f4b335a2f4f5a1ca151c8ab67324a72ebaee Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 10 May 2013 15:13:07 -0700 Subject: Fixup merge diffs --- indra/llprimitive/llprimitive.cpp | 1 - indra/llprimitive/llprimitive.h | 1 - 2 files changed, 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 426666ff00..e5905c3a3b 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1257,7 +1257,6 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const S32 LLPrimitive::parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec) { S32 retval = 0; - // temp buffer for material ID processing // data will end up in tec.material_id[] U8 material_data[LLTEContents::MAX_TES*16]; diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 6f3657cd9b..b1f8090416 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -392,7 +392,6 @@ public: 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 const* block_name); S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num); // Variable num of blocks BOOL unpackTEMessage(LLDataPacker &dp); S32 parseTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num, LLTEContents& tec); -- cgit v1.2.3 From f356d7eb9fd730f5f6f5a29fb0706e20876ad3bd Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sat, 11 May 2013 19:58:56 -0700 Subject: Fix many issues with selection misapplication and rendering not matching applied materials --- indra/llprimitive/llprimitive.cpp | 18 ++++++++++++++++++ indra/llprimitive/llprimitive.h | 2 ++ indra/llprimitive/lltextureentry.cpp | 25 +++++++++++++------------ indra/llprimitive/lltextureentry.h | 6 ++++++ 4 files changed, 39 insertions(+), 12 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index e5905c3a3b..2fa77177f5 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -374,6 +374,24 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } +void LLPrimitive::setAllTESelected(bool sel) +{ + for (int i = 0, cnt = getNumTEs(); i < cnt; i++) + { + setTESelected(i, sel); + } +} + +void LLPrimitive::setTESelected(const U8 te, bool sel) +{ + LLTextureEntry* tep = getTE(te); + if ( (tep) && (tep->setSelected(sel)) && (!sel) && (tep->hasPendingMaterialUpdate()) ) + { + LLMaterialID material_id = tep->getMaterialID(); + setTEMaterialID(te, material_id); + } +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index b1f8090416..47a21beaaf 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -361,6 +361,7 @@ public: LLTextureEntry* getTE(const U8 te_num) const; virtual void setNumTEs(const U8 num_tes); + virtual void setAllTESelected(bool sel); 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); @@ -386,6 +387,7 @@ public: virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed + virtual void setTESelected(const U8 te, bool sel); void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 53816266eb..1d581da897 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -67,12 +67,16 @@ LLTextureEntry::LLTextureEntry() LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { mID = rhs.mID; mScaleS = rhs.mScaleS; @@ -536,23 +540,20 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) if (mMaterialID != pMaterialID) { mMaterialID = pMaterialID; - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + } - return TEM_CHANGE_NONE; + if (mMaterialID.isNull()) + { + setMaterialParams(NULL); + } + return TEM_CHANGE_TEXTURE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mMaterial != pMaterialParams) - { - mMaterial = pMaterialParams; - return TEM_CHANGE_TEXTURE; - } - return TEM_CHANGE_NONE; + + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; } void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index c443ebcb30..5cc76cfe82 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -100,6 +100,10 @@ public: void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); + bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; } + bool isSelected() const { return mSelected; } + bool setSelected(bool sel) { bool prev_sel = mSelected; mSelected = sel; return prev_sel; } + // These return a TEM_ flag from above to indicate if something changed. S32 setID (const LLUUID &tex_id); S32 setColor(const LLColor4 &color); @@ -194,11 +198,13 @@ public: static const char* TEXTURE_MEDIA_DATA_KEY; protected: + bool mSelected; LLUUID mID; // Texture GUID LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; -- cgit v1.2.3 From 5ac9d9cb05f22099bea8c9312f5e0b234430022a Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 12 May 2013 16:10:31 +0200 Subject: LLMaterialMgr::get() doesn't handle a callback request for LLMaterialID::null --- indra/llprimitive/lltextureentry.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 8365c9d7b6..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -550,12 +550,9 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) mMaterialUpdatePending = false; mMaterialID = pMaterialID; + return TEM_CHANGE_TEXTURE; } - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + return TEM_CHANGE_NONE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) -- cgit v1.2.3 From d9e8ee7cfd323872145c23e4032989f9b7770f55 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 13 May 2013 13:02:53 -0700 Subject: NORSPEC-178 NORSPEC-179 NORSPEC-180 made enable/disable handling more consistent and increased max range on repeats per meter --- indra/llprimitive/lltextureentry.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 597f078490..ca57f1edbd 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,28 +539,21 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) + if (mMaterialID != pMaterialID) { - if (mSelected) + mMaterialID = pMaterialID; + + } + if (mMaterialID.isNull()) { - mMaterialUpdatePending = true; - mMaterialID = pMaterialID; - return TEM_CHANGE_NONE; + setMaterialParams(NULL); } - - mMaterialUpdatePending = false; - mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } - return TEM_CHANGE_NONE; -} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mSelected) - { - mMaterialUpdatePending = true; - } + mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } -- cgit v1.2.3 From ad09e2111cd980117ae937b79155ef6c24e4567c Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 14 May 2013 21:14:46 +0200 Subject: NORSPEC-102 & Co Reloaded --- indra/llprimitive/lltextureentry.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index ca57f1edbd..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,21 +539,28 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if (mMaterialID != pMaterialID) + if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) { - mMaterialID = pMaterialID; - - } - if (mMaterialID.isNull()) + if (mSelected) { - setMaterialParams(NULL); + mMaterialUpdatePending = true; + mMaterialID = pMaterialID; + return TEM_CHANGE_NONE; } + + mMaterialUpdatePending = false; + mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } + return TEM_CHANGE_NONE; +} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - + if (mSelected) + { + mMaterialUpdatePending = true; + } mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } -- cgit v1.2.3 From 7e4e59470f36ae7a0e01b8d2613af4c8fb6b0101 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 7 Jun 2013 08:58:15 -0700 Subject: NORSPEC-233 WIP for individual material param edits across hetero object selections --- indra/llprimitive/llmaterial.h | 28 ++++++++++++++++++++++++++-- indra/llprimitive/lltextureentry.h | 8 +++++++- 2 files changed, 33 insertions(+), 3 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index b265732adc..9f52a3f6c1 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -69,19 +69,43 @@ public: const LLUUID& getNormalID() const { return mNormalID; } void setNormalID(const LLUUID& normal_id) { mNormalID = normal_id; } void getNormalOffset(F32& offset_x, F32& offset_y) const { offset_x = mNormalOffsetX; offset_y = mNormalOffsetY; } + F32 getNormalOffsetX() const { return mNormalOffsetX; } + F32 getNormalOffsetY() const { return mNormalOffsetY; } + void setNormalOffset(F32 offset_x, F32 offset_y) { mNormalOffsetX = offset_x; mNormalOffsetY = offset_y; } + void setNormalOffsetX(F32 offset_x) { mNormalOffsetX = offset_x; } + void setNormalOffsetY(F32 offset_y) { mNormalOffsetY = offset_y; } + void getNormalRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mNormalRepeatX; repeat_y = mNormalRepeatY; } + F32 getNormalRepeatX() const { return mNormalRepeatX; } + F32 getNormalRepeatY() const { return mNormalRepeatY; } + void setNormalRepeat(F32 repeat_x, F32 repeat_y) { mNormalRepeatX = repeat_x; mNormalRepeatY = repeat_y; } - F32 getNormalRotation() const { return mNormalRotation; } + void setNormalRepeatX(F32 repeat_x) { mNormalRepeatX = repeat_x; } + void setNormalRepeatY(F32 repeat_y) { mNormalRepeatY = repeat_y; } + + F32 getNormalRotation() const { return mNormalRotation; } void setNormalRotation(F32 rot) { mNormalRotation = rot; } const LLUUID& getSpecularID() const { return mSpecularID; } void setSpecularID(const LLUUID& specular_id) { mSpecularID = specular_id; } void getSpecularOffset(F32& offset_x, F32& offset_y) const { offset_x = mSpecularOffsetX; offset_y = mSpecularOffsetY; } + F32 getSpecularOffsetX() const { return mSpecularOffsetX; } + F32 getSpecularOffsetY() const { return mSpecularOffsetY; } + void setSpecularOffset(F32 offset_x, F32 offset_y) { mSpecularOffsetX = offset_x; mSpecularOffsetY = offset_y; } + void setSpecularOffsetX(F32 offset_x) { mSpecularOffsetX = offset_x; } + void setSpecularOffsetY(F32 offset_y) { mSpecularOffsetY = offset_y; } + void getSpecularRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mSpecularRepeatX; repeat_y = mSpecularRepeatY; } + F32 getSpecularRepeatX() const { return mSpecularRepeatX; } + F32 getSpecularRepeatY() const { return mSpecularRepeatY; } + void setSpecularRepeat(F32 repeat_x, F32 repeat_y) { mSpecularRepeatX = repeat_x; mSpecularRepeatY = repeat_y; } - F32 getSpecularRotation() const { return mSpecularRotation; } + void setSpecularRepeatX(F32 repeat_x) { mSpecularRepeatX = repeat_x; } + void setSpecularRepeatY(F32 repeat_y) { mSpecularRepeatY = repeat_y; } + + F32 getSpecularRotation() const { return mSpecularRotation; } void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } const LLColor4U getSpecularLightColor() const { return mSpecularLightColor; } diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 5cc76cfe82..59364cb913 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -133,7 +133,13 @@ public: virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; } + void getScaleS(F32 *s) const { *s = mScaleS; } + void getScaleT(F32 *t) const { *t = mScaleT; } + void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; } + F32 getOffsetS() const { return mOffsetS; } + F32 getOffsetT() const { return mOffsetT; } + F32 getRotation() const { return mRotation; } void getRotation(F32 *theta) const { *theta = mRotation; } @@ -144,7 +150,7 @@ public: U8 getBumpShinyFullbright() const { return mBump; } U8 getMediaFlags() const { return mMediaFlags & TEM_MEDIA_MASK; } - U8 getTexGen() const { return mMediaFlags & TEM_TEX_GEN_MASK; } + LLTextureEntry::e_texgen getTexGen() const { return LLTextureEntry::e_texgen(mMediaFlags & TEM_TEX_GEN_MASK); } U8 getMediaTexGen() const { return mMediaFlags; } F32 getGlow() const { return mGlow; } const LLMaterialID& getMaterialID() const { return mMaterialID; }; -- cgit v1.2.3 From c78cd1aae63a7c7c0bf6a9c21380818aa9cd47b7 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 7 Jun 2013 14:37:39 -0700 Subject: NORSPEC-233 WIP fix completely bogus substitution of offsets for scales and make scale accessors get with the program --- indra/llprimitive/lltextureentry.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 59364cb913..19edcaa27d 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -133,8 +133,8 @@ public: virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } void getScale(F32 *s, F32 *t) const { *s = mScaleS; *t = mScaleT; } - void getScaleS(F32 *s) const { *s = mScaleS; } - void getScaleT(F32 *t) const { *t = mScaleT; } + F32 getScaleS() const { return mScaleS; } + F32 getScaleT() const { return mScaleT; } void getOffset(F32 *s, F32 *t) const { *s = mOffsetS; *t = mOffsetT; } F32 getOffsetS() const { return mOffsetS; } -- cgit v1.2.3 From eba7eb2d062c43cd83cb6972e4e05dc54d409582 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sat, 8 Jun 2013 06:28:48 -0700 Subject: NORSPEC-233 fix default value and material apply logic errors --- indra/llprimitive/llmaterial.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index ce443dea1d..cf4c645cfd 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -91,16 +91,16 @@ template<> LLUUID getMaterialField(const LLSD& data, const std::string& field, c const LLMaterial LLMaterial::null; LLMaterial::LLMaterial() - : mNormalOffsetX(.0f) - , mNormalOffsetY(.0f) - , mNormalRepeatX(.0f) - , mNormalRepeatY(.0f) - , mNormalRotation(.0f) - , mSpecularOffsetX(.0f) - , mSpecularOffsetY(.0f) - , mSpecularRepeatX(.0f) - , mSpecularRepeatY(.0f) - , mSpecularRotation(.0f) + : mNormalOffsetX(0.0f) + , mNormalOffsetY(0.0f) + , mNormalRepeatX(1.0f) + , mNormalRepeatY(1.0f) + , mNormalRotation(0.0f) + , mSpecularOffsetX(0.0f) + , mSpecularOffsetY(0.0f) + , mSpecularRepeatX(1.0f) + , mSpecularRepeatY(1.0f) + , mSpecularRotation(0.0f) , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR) , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT) , mEnvironmentIntensity(LLMaterial::DEFAULT_ENV_INTENSITY) -- cgit v1.2.3 From f782e0192009b249edcb30ca2a5418ec7c1ddfa4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sat, 15 Jun 2013 05:18:50 -0700 Subject: NORSPEC-267 fix UI feedback for materials edits not appearing for observers when obj was selected by them --- indra/llprimitive/lltextureentry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 597f078490..0db75a0e82 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -545,7 +545,7 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { mMaterialUpdatePending = true; mMaterialID = pMaterialID; - return TEM_CHANGE_NONE; + return TEM_CHANGE_TEXTURE; } mMaterialUpdatePending = false; -- cgit v1.2.3 From d38bcb66217376745b0687f9002c8dd8267b5019 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 16 Sep 2013 09:40:58 -0700 Subject: MAINT-2388 replace stomped fix to not crash when handed bogus model data --- indra/llprimitive/llmodel.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index e236f98fe6..4d93627116 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -238,6 +238,11 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa { // guard against model data specifiying out of range indices or norms // + if (((i + pos_offset) > index_count) + || ((idx[i+pos_offset]*3+2) > vertex_count)) + { + return LLModel::BAD_ELEMENT; + } if (((i + norm_offset) > index_count) || ((idx[i+norm_offset]*3+2) > norm_count)) { -- cgit v1.2.3 From 0e3ad3e94b7a265c5ba035660c40557d73303dae Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 16 Sep 2013 12:11:58 -0700 Subject: MAINT-3153 fix potential mis-indexing in DAE loading checks --- indra/llprimitive/llmodel.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 4d93627116..37f0bfcbb8 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -218,8 +218,9 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa { // guard against model data specifiying out of range indices or tcs // + if (((i + tc_offset) > index_count) - || ((idx[i+pos_offset]*2+1) > tc_count)) + || ((idx[i+tc_offset]*2+1) > tc_count)) { return LLModel::BAD_ELEMENT; } @@ -238,11 +239,6 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa { // guard against model data specifiying out of range indices or norms // - if (((i + pos_offset) > index_count) - || ((idx[i+pos_offset]*3+2) > vertex_count)) - { - return LLModel::BAD_ELEMENT; - } if (((i + norm_offset) > index_count) || ((idx[i+norm_offset]*3+2) > norm_count)) { @@ -456,7 +452,7 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac { // guard against model data specifiying out of range indices or tcs // - if (((i + pos_offset) > index_count) + if (((cur_idx + tc_offset) > index_count) || ((idx[cur_idx+tc_offset]*2+1) > tc_count)) { return LLModel::BAD_ELEMENT; @@ -476,7 +472,7 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac { // guard against model data specifiying out of range indices or norms // - if (((i + pos_offset) > index_count) + if (((cur_idx + norm_offset) > index_count) || ((idx[cur_idx+norm_offset]*3+2) > norm_count)) { return LLModel::BAD_ELEMENT; -- cgit v1.2.3 From 29216ac5e725254c48711737f5c22d2ad3e5e4a2 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 23 Sep 2013 13:43:01 -0700 Subject: MAINT-3179 fix bad indexing of position info generating false alarms on range checks, issue with free of data now allocated contig with positions instead, and added copious amounts of llwarns to error return sites so 'invalid element' will be a reason to read the log and not a tease. --- indra/llprimitive/llmodel.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 37f0bfcbb8..34e0483a83 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -166,6 +166,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if ( !get_dom_sources(inputs, pos_offset, tc_offset, norm_offset, idx_stride, pos_source, tc_source, norm_source) || !pos_source ) { + llwarns << "Could not find dom sources for basic geo data; invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -201,6 +202,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if (((i + pos_offset) > index_count) || ((idx[i+pos_offset]*3+2) > vertex_count)) { + llwarns << "Out of range index data; invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -210,6 +212,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if (!cv.getPosition().isFinite3()) { + llwarns << "Nan positional data, invalid model." << llendl; return LLModel::BAD_ELEMENT; } } @@ -222,6 +225,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if (((i + tc_offset) > index_count) || ((idx[i+tc_offset]*2+1) > tc_count)) { + llwarns << "Out of range TC indices." << llendl; return LLModel::BAD_ELEMENT; } @@ -242,6 +246,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if (((i + norm_offset) > index_count) || ((idx[i+norm_offset]*3+2) > norm_count)) { + llwarns << "Found out of range norm indices, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -380,6 +385,7 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac if (!get_dom_sources(inputs, pos_offset, tc_offset, norm_offset, idx_stride, pos_source, tc_source, norm_source)) { + llwarns << "Could not get DOM sources for basic geo data, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -430,9 +436,10 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac { // guard against model data specifiying out of range indices or verts // - if (((i + pos_offset) > index_count) - || ((idx[i+pos_offset]*3+2) > vertex_count)) + if (((cur_idx + pos_offset) > index_count) + || ((idx[cur_idx+pos_offset]*3+2) > vertex_count)) { + llwarns << "Out of range position indices, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -455,6 +462,7 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac if (((cur_idx + tc_offset) > index_count) || ((idx[cur_idx+tc_offset]*2+1) > tc_count)) { + llwarns << "Out of range TC indices, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -475,6 +483,7 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac if (((cur_idx + norm_offset) > index_count) || ((idx[cur_idx+norm_offset]*3+2) > norm_count)) { + llwarns << "Out of range norm indices, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -653,6 +662,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac domVertices* vertices = (domVertices*) elem.cast(); if (!vertices) { + llwarns << "Could not find vertex source, invalid model." << llendl; return LLModel::BAD_ELEMENT; } domInputLocal_Array& v_inp = vertices->getInput_array(); @@ -666,6 +676,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac domSource* src = (domSource*) elem.cast(); if (!src) { + llwarns << "Could not find DOM source, invalid model." << llendl; return LLModel::BAD_ELEMENT; } v = &(src->getFloat_array()->getValue()); @@ -681,6 +692,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac domSource* src = (domSource*) elem.cast(); if (!src) { + llwarns << "Could not find DOM source, invalid model." << llendl; return LLModel::BAD_ELEMENT; } n = &(src->getFloat_array()->getValue()); @@ -693,6 +705,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac domSource* src = (domSource*) elem.cast(); if (!src) { + llwarns << "Could not find DOM source, invalid model." << llendl; return LLModel::BAD_ELEMENT; } t = &(src->getFloat_array()->getValue()); -- cgit v1.2.3