summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsariel Hiller <Ansariel@users.noreply.github.com>2024-10-02 19:53:17 +0200
committerGitHub <noreply@github.com>2024-10-02 20:53:17 +0300
commit13b91ad30633cb50275b1ca4a25522da23107e34 (patch)
tree313d1f20a077d1095aa6d40f9f7c4b5c1393ce3a
parent1d045d7d11118835bb9d5421f71a1b3b9a61cb38 (diff)
Add a lot of more constexpr; use constants for accessing vector indices in vector math classes (#2766)
-rw-r--r--indra/llcommon/indra_constants.h408
-rw-r--r--indra/llcommon/llapp.h9
-rw-r--r--indra/llcommon/lldefs.h16
-rw-r--r--indra/llmath/v2math.cpp35
-rw-r--r--indra/llmath/v2math.h140
-rw-r--r--indra/llmath/v3dmath.cpp24
-rw-r--r--indra/llmath/v3dmath.h196
-rw-r--r--indra/llmath/v3math.cpp106
-rw-r--r--indra/llmath/v3math.h268
-rw-r--r--indra/llmath/v4math.cpp18
-rw-r--r--indra/llmath/v4math.h119
11 files changed, 666 insertions, 673 deletions
diff --git a/indra/llcommon/indra_constants.h b/indra/llcommon/indra_constants.h
index d2de88ff0a..566ea2ea14 100644
--- a/indra/llcommon/indra_constants.h
+++ b/indra/llcommon/indra_constants.h
@@ -31,15 +31,15 @@
class LLUUID;
-static const F32 REGION_WIDTH_METERS = 256.f;
-static const S32 REGION_WIDTH_UNITS = 256;
-static const U32 REGION_WIDTH_U32 = 256;
+static constexpr F32 REGION_WIDTH_METERS = 256.f;
+static constexpr S32 REGION_WIDTH_UNITS = 256;
+static constexpr U32 REGION_WIDTH_U32 = 256;
-const F32 REGION_HEIGHT_METERS = 4096.f;
+constexpr F32 REGION_HEIGHT_METERS = 4096.f;
-const F32 DEFAULT_AGENT_DEPTH = 0.45f;
-const F32 DEFAULT_AGENT_WIDTH = 0.60f;
-const F32 DEFAULT_AGENT_HEIGHT = 1.9f;
+constexpr F32 DEFAULT_AGENT_DEPTH = 0.45f;
+constexpr F32 DEFAULT_AGENT_WIDTH = 0.60f;
+constexpr F32 DEFAULT_AGENT_HEIGHT = 1.9f;
enum ETerrainBrushType
{
@@ -67,112 +67,112 @@ enum EMouseClickType{
// keys
// Bit masks for various keyboard modifier keys.
-const MASK MASK_NONE = 0x0000;
-const MASK MASK_CONTROL = 0x0001; // Mapped to cmd on Macs
-const MASK MASK_ALT = 0x0002;
-const MASK MASK_SHIFT = 0x0004;
-const MASK MASK_NORMALKEYS = 0x0007; // A real mask - only get the bits for normal modifier keys
-const MASK MASK_MAC_CONTROL = 0x0008; // Un-mapped Ctrl key on Macs, not used on Windows
-const MASK MASK_MODIFIERS = MASK_CONTROL|MASK_ALT|MASK_SHIFT|MASK_MAC_CONTROL;
+constexpr MASK MASK_NONE = 0x0000;
+constexpr MASK MASK_CONTROL = 0x0001; // Mapped to cmd on Macs
+constexpr MASK MASK_ALT = 0x0002;
+constexpr MASK MASK_SHIFT = 0x0004;
+constexpr MASK MASK_NORMALKEYS = 0x0007; // A real mask - only get the bits for normal modifier keys
+constexpr MASK MASK_MAC_CONTROL = 0x0008; // Un-mapped Ctrl key on Macs, not used on Windows
+constexpr MASK MASK_MODIFIERS = MASK_CONTROL|MASK_ALT|MASK_SHIFT|MASK_MAC_CONTROL;
// Special keys go into >128
-const KEY KEY_SPECIAL = 0x80; // special keys start here
-const KEY KEY_RETURN = 0x81;
-const KEY KEY_LEFT = 0x82;
-const KEY KEY_RIGHT = 0x83;
-const KEY KEY_UP = 0x84;
-const KEY KEY_DOWN = 0x85;
-const KEY KEY_ESCAPE = 0x86;
-const KEY KEY_BACKSPACE =0x87;
-const KEY KEY_DELETE = 0x88;
-const KEY KEY_SHIFT = 0x89;
-const KEY KEY_CONTROL = 0x8A;
-const KEY KEY_ALT = 0x8B;
-const KEY KEY_HOME = 0x8C;
-const KEY KEY_END = 0x8D;
-const KEY KEY_PAGE_UP = 0x8E;
-const KEY KEY_PAGE_DOWN = 0x8F;
-const KEY KEY_HYPHEN = 0x90;
-const KEY KEY_EQUALS = 0x91;
-const KEY KEY_INSERT = 0x92;
-const KEY KEY_CAPSLOCK = 0x93;
-const KEY KEY_TAB = 0x94;
-const KEY KEY_ADD = 0x95;
-const KEY KEY_SUBTRACT =0x96;
-const KEY KEY_MULTIPLY =0x97;
-const KEY KEY_DIVIDE = 0x98;
-const KEY KEY_F1 = 0xA1;
-const KEY KEY_F2 = 0xA2;
-const KEY KEY_F3 = 0xA3;
-const KEY KEY_F4 = 0xA4;
-const KEY KEY_F5 = 0xA5;
-const KEY KEY_F6 = 0xA6;
-const KEY KEY_F7 = 0xA7;
-const KEY KEY_F8 = 0xA8;
-const KEY KEY_F9 = 0xA9;
-const KEY KEY_F10 = 0xAA;
-const KEY KEY_F11 = 0xAB;
-const KEY KEY_F12 = 0xAC;
-
-const KEY KEY_PAD_UP = 0xC0;
-const KEY KEY_PAD_DOWN = 0xC1;
-const KEY KEY_PAD_LEFT = 0xC2;
-const KEY KEY_PAD_RIGHT = 0xC3;
-const KEY KEY_PAD_HOME = 0xC4;
-const KEY KEY_PAD_END = 0xC5;
-const KEY KEY_PAD_PGUP = 0xC6;
-const KEY KEY_PAD_PGDN = 0xC7;
-const KEY KEY_PAD_CENTER = 0xC8; // the 5 in the middle
-const KEY KEY_PAD_INS = 0xC9;
-const KEY KEY_PAD_DEL = 0xCA;
-const KEY KEY_PAD_RETURN = 0xCB;
-const KEY KEY_PAD_ADD = 0xCC; // not used
-const KEY KEY_PAD_SUBTRACT = 0xCD; // not used
-const KEY KEY_PAD_MULTIPLY = 0xCE; // not used
-const KEY KEY_PAD_DIVIDE = 0xCF; // not used
-
-const KEY KEY_BUTTON0 = 0xD0;
-const KEY KEY_BUTTON1 = 0xD1;
-const KEY KEY_BUTTON2 = 0xD2;
-const KEY KEY_BUTTON3 = 0xD3;
-const KEY KEY_BUTTON4 = 0xD4;
-const KEY KEY_BUTTON5 = 0xD5;
-const KEY KEY_BUTTON6 = 0xD6;
-const KEY KEY_BUTTON7 = 0xD7;
-const KEY KEY_BUTTON8 = 0xD8;
-const KEY KEY_BUTTON9 = 0xD9;
-const KEY KEY_BUTTON10 = 0xDA;
-const KEY KEY_BUTTON11 = 0xDB;
-const KEY KEY_BUTTON12 = 0xDC;
-const KEY KEY_BUTTON13 = 0xDD;
-const KEY KEY_BUTTON14 = 0xDE;
-const KEY KEY_BUTTON15 = 0xDF;
-
-const KEY KEY_NONE = 0xFF; // not sent from keyboard. For internal use only.
-
-const S32 KEY_COUNT = 256;
-
-
-const F32 DEFAULT_WATER_HEIGHT = 20.0f;
+constexpr KEY KEY_SPECIAL = 0x80; // special keys start here
+constexpr KEY KEY_RETURN = 0x81;
+constexpr KEY KEY_LEFT = 0x82;
+constexpr KEY KEY_RIGHT = 0x83;
+constexpr KEY KEY_UP = 0x84;
+constexpr KEY KEY_DOWN = 0x85;
+constexpr KEY KEY_ESCAPE = 0x86;
+constexpr KEY KEY_BACKSPACE =0x87;
+constexpr KEY KEY_DELETE = 0x88;
+constexpr KEY KEY_SHIFT = 0x89;
+constexpr KEY KEY_CONTROL = 0x8A;
+constexpr KEY KEY_ALT = 0x8B;
+constexpr KEY KEY_HOME = 0x8C;
+constexpr KEY KEY_END = 0x8D;
+constexpr KEY KEY_PAGE_UP = 0x8E;
+constexpr KEY KEY_PAGE_DOWN = 0x8F;
+constexpr KEY KEY_HYPHEN = 0x90;
+constexpr KEY KEY_EQUALS = 0x91;
+constexpr KEY KEY_INSERT = 0x92;
+constexpr KEY KEY_CAPSLOCK = 0x93;
+constexpr KEY KEY_TAB = 0x94;
+constexpr KEY KEY_ADD = 0x95;
+constexpr KEY KEY_SUBTRACT =0x96;
+constexpr KEY KEY_MULTIPLY =0x97;
+constexpr KEY KEY_DIVIDE = 0x98;
+constexpr KEY KEY_F1 = 0xA1;
+constexpr KEY KEY_F2 = 0xA2;
+constexpr KEY KEY_F3 = 0xA3;
+constexpr KEY KEY_F4 = 0xA4;
+constexpr KEY KEY_F5 = 0xA5;
+constexpr KEY KEY_F6 = 0xA6;
+constexpr KEY KEY_F7 = 0xA7;
+constexpr KEY KEY_F8 = 0xA8;
+constexpr KEY KEY_F9 = 0xA9;
+constexpr KEY KEY_F10 = 0xAA;
+constexpr KEY KEY_F11 = 0xAB;
+constexpr KEY KEY_F12 = 0xAC;
+
+constexpr KEY KEY_PAD_UP = 0xC0;
+constexpr KEY KEY_PAD_DOWN = 0xC1;
+constexpr KEY KEY_PAD_LEFT = 0xC2;
+constexpr KEY KEY_PAD_RIGHT = 0xC3;
+constexpr KEY KEY_PAD_HOME = 0xC4;
+constexpr KEY KEY_PAD_END = 0xC5;
+constexpr KEY KEY_PAD_PGUP = 0xC6;
+constexpr KEY KEY_PAD_PGDN = 0xC7;
+constexpr KEY KEY_PAD_CENTER = 0xC8; // the 5 in the middle
+constexpr KEY KEY_PAD_INS = 0xC9;
+constexpr KEY KEY_PAD_DEL = 0xCA;
+constexpr KEY KEY_PAD_RETURN = 0xCB;
+constexpr KEY KEY_PAD_ADD = 0xCC; // not used
+constexpr KEY KEY_PAD_SUBTRACT = 0xCD; // not used
+constexpr KEY KEY_PAD_MULTIPLY = 0xCE; // not used
+constexpr KEY KEY_PAD_DIVIDE = 0xCF; // not used
+
+constexpr KEY KEY_BUTTON0 = 0xD0;
+constexpr KEY KEY_BUTTON1 = 0xD1;
+constexpr KEY KEY_BUTTON2 = 0xD2;
+constexpr KEY KEY_BUTTON3 = 0xD3;
+constexpr KEY KEY_BUTTON4 = 0xD4;
+constexpr KEY KEY_BUTTON5 = 0xD5;
+constexpr KEY KEY_BUTTON6 = 0xD6;
+constexpr KEY KEY_BUTTON7 = 0xD7;
+constexpr KEY KEY_BUTTON8 = 0xD8;
+constexpr KEY KEY_BUTTON9 = 0xD9;
+constexpr KEY KEY_BUTTON10 = 0xDA;
+constexpr KEY KEY_BUTTON11 = 0xDB;
+constexpr KEY KEY_BUTTON12 = 0xDC;
+constexpr KEY KEY_BUTTON13 = 0xDD;
+constexpr KEY KEY_BUTTON14 = 0xDE;
+constexpr KEY KEY_BUTTON15 = 0xDF;
+
+constexpr KEY KEY_NONE = 0xFF; // not sent from keyboard. For internal use only.
+
+constexpr S32 KEY_COUNT = 256;
+
+
+constexpr F32 DEFAULT_WATER_HEIGHT = 20.0f;
// Maturity ratings for simulators
-const U8 SIM_ACCESS_MIN = 0; // Treated as 'unknown', usually ends up being SIM_ACCESS_PG
-const U8 SIM_ACCESS_PG = 13;
-const U8 SIM_ACCESS_MATURE = 21;
-const U8 SIM_ACCESS_ADULT = 42; // Seriously Adult Only
-const U8 SIM_ACCESS_DOWN = 254;
-const U8 SIM_ACCESS_MAX = SIM_ACCESS_ADULT;
+constexpr U8 SIM_ACCESS_MIN = 0; // Treated as 'unknown', usually ends up being SIM_ACCESS_PG
+constexpr U8 SIM_ACCESS_PG = 13;
+constexpr U8 SIM_ACCESS_MATURE = 21;
+constexpr U8 SIM_ACCESS_ADULT = 42; // Seriously Adult Only
+constexpr U8 SIM_ACCESS_DOWN = 254;
+constexpr U8 SIM_ACCESS_MAX = SIM_ACCESS_ADULT;
// attachment constants
-const U8 ATTACHMENT_ADD = 0x80;
+constexpr U8 ATTACHMENT_ADD = 0x80;
// god levels
-const U8 GOD_MAINTENANCE = 250;
-const U8 GOD_FULL = 200;
-const U8 GOD_LIAISON = 150;
-const U8 GOD_CUSTOMER_SERVICE = 100;
-const U8 GOD_LIKE = 1;
-const U8 GOD_NOT = 0;
+constexpr U8 GOD_MAINTENANCE = 250;
+constexpr U8 GOD_FULL = 200;
+constexpr U8 GOD_LIAISON = 150;
+constexpr U8 GOD_CUSTOMER_SERVICE = 100;
+constexpr U8 GOD_LIKE = 1;
+constexpr U8 GOD_NOT = 0;
// "agent id" for things that should be done to ALL agents
LL_COMMON_API extern const LLUUID LL_UUID_ALL_AGENTS;
@@ -239,120 +239,120 @@ LL_COMMON_API extern const LLUUID BLANK_OBJECT_NORMAL;
LL_COMMON_API extern const LLUUID BLANK_MATERIAL_ASSET_ID;
// radius within which a chat message is fully audible
-const F32 CHAT_NORMAL_RADIUS = 20.f;
+constexpr F32 CHAT_NORMAL_RADIUS = 20.f;
// media commands
-const U32 PARCEL_MEDIA_COMMAND_STOP = 0;
-const U32 PARCEL_MEDIA_COMMAND_PAUSE = 1;
-const U32 PARCEL_MEDIA_COMMAND_PLAY = 2;
-const U32 PARCEL_MEDIA_COMMAND_LOOP = 3;
-const U32 PARCEL_MEDIA_COMMAND_TEXTURE = 4;
-const U32 PARCEL_MEDIA_COMMAND_URL = 5;
-const U32 PARCEL_MEDIA_COMMAND_TIME = 6;
-const U32 PARCEL_MEDIA_COMMAND_AGENT = 7;
-const U32 PARCEL_MEDIA_COMMAND_UNLOAD = 8;
-const U32 PARCEL_MEDIA_COMMAND_AUTO_ALIGN = 9;
-const U32 PARCEL_MEDIA_COMMAND_TYPE = 10;
-const U32 PARCEL_MEDIA_COMMAND_SIZE = 11;
-const U32 PARCEL_MEDIA_COMMAND_DESC = 12;
-const U32 PARCEL_MEDIA_COMMAND_LOOP_SET = 13;
+constexpr U32 PARCEL_MEDIA_COMMAND_STOP = 0;
+constexpr U32 PARCEL_MEDIA_COMMAND_PAUSE = 1;
+constexpr U32 PARCEL_MEDIA_COMMAND_PLAY = 2;
+constexpr U32 PARCEL_MEDIA_COMMAND_LOOP = 3;
+constexpr U32 PARCEL_MEDIA_COMMAND_TEXTURE = 4;
+constexpr U32 PARCEL_MEDIA_COMMAND_URL = 5;
+constexpr U32 PARCEL_MEDIA_COMMAND_TIME = 6;
+constexpr U32 PARCEL_MEDIA_COMMAND_AGENT = 7;
+constexpr U32 PARCEL_MEDIA_COMMAND_UNLOAD = 8;
+constexpr U32 PARCEL_MEDIA_COMMAND_AUTO_ALIGN = 9;
+constexpr U32 PARCEL_MEDIA_COMMAND_TYPE = 10;
+constexpr U32 PARCEL_MEDIA_COMMAND_SIZE = 11;
+constexpr U32 PARCEL_MEDIA_COMMAND_DESC = 12;
+constexpr U32 PARCEL_MEDIA_COMMAND_LOOP_SET = 13;
const S32 CHAT_CHANNEL_DEBUG = S32_MAX;
// agent constants
-const U32 CONTROL_AT_POS_INDEX = 0;
-const U32 CONTROL_AT_NEG_INDEX = 1;
-const U32 CONTROL_LEFT_POS_INDEX = 2;
-const U32 CONTROL_LEFT_NEG_INDEX = 3;
-const U32 CONTROL_UP_POS_INDEX = 4;
-const U32 CONTROL_UP_NEG_INDEX = 5;
-const U32 CONTROL_PITCH_POS_INDEX = 6;
-const U32 CONTROL_PITCH_NEG_INDEX = 7;
-const U32 CONTROL_YAW_POS_INDEX = 8;
-const U32 CONTROL_YAW_NEG_INDEX = 9;
-const U32 CONTROL_FAST_AT_INDEX = 10;
-const U32 CONTROL_FAST_LEFT_INDEX = 11;
-const U32 CONTROL_FAST_UP_INDEX = 12;
-const U32 CONTROL_FLY_INDEX = 13;
-const U32 CONTROL_STOP_INDEX = 14;
-const U32 CONTROL_FINISH_ANIM_INDEX = 15;
-const U32 CONTROL_STAND_UP_INDEX = 16;
-const U32 CONTROL_SIT_ON_GROUND_INDEX = 17;
-const U32 CONTROL_MOUSELOOK_INDEX = 18;
-const U32 CONTROL_NUDGE_AT_POS_INDEX = 19;
-const U32 CONTROL_NUDGE_AT_NEG_INDEX = 20;
-const U32 CONTROL_NUDGE_LEFT_POS_INDEX = 21;
-const U32 CONTROL_NUDGE_LEFT_NEG_INDEX = 22;
-const U32 CONTROL_NUDGE_UP_POS_INDEX = 23;
-const U32 CONTROL_NUDGE_UP_NEG_INDEX = 24;
-const U32 CONTROL_TURN_LEFT_INDEX = 25;
-const U32 CONTROL_TURN_RIGHT_INDEX = 26;
-const U32 CONTROL_AWAY_INDEX = 27;
-const U32 CONTROL_LBUTTON_DOWN_INDEX = 28;
-const U32 CONTROL_LBUTTON_UP_INDEX = 29;
-const U32 CONTROL_ML_LBUTTON_DOWN_INDEX = 30;
-const U32 CONTROL_ML_LBUTTON_UP_INDEX = 31;
-const U32 TOTAL_CONTROLS = 32;
-
-const U32 AGENT_CONTROL_AT_POS = 0x1 << CONTROL_AT_POS_INDEX; // 0x00000001
-const U32 AGENT_CONTROL_AT_NEG = 0x1 << CONTROL_AT_NEG_INDEX; // 0x00000002
-const U32 AGENT_CONTROL_LEFT_POS = 0x1 << CONTROL_LEFT_POS_INDEX; // 0x00000004
-const U32 AGENT_CONTROL_LEFT_NEG = 0x1 << CONTROL_LEFT_NEG_INDEX; // 0x00000008
-const U32 AGENT_CONTROL_UP_POS = 0x1 << CONTROL_UP_POS_INDEX; // 0x00000010
-const U32 AGENT_CONTROL_UP_NEG = 0x1 << CONTROL_UP_NEG_INDEX; // 0x00000020
-const U32 AGENT_CONTROL_PITCH_POS = 0x1 << CONTROL_PITCH_POS_INDEX; // 0x00000040
-const U32 AGENT_CONTROL_PITCH_NEG = 0x1 << CONTROL_PITCH_NEG_INDEX; // 0x00000080
-const U32 AGENT_CONTROL_YAW_POS = 0x1 << CONTROL_YAW_POS_INDEX; // 0x00000100
-const U32 AGENT_CONTROL_YAW_NEG = 0x1 << CONTROL_YAW_NEG_INDEX; // 0x00000200
-
-const U32 AGENT_CONTROL_FAST_AT = 0x1 << CONTROL_FAST_AT_INDEX; // 0x00000400
-const U32 AGENT_CONTROL_FAST_LEFT = 0x1 << CONTROL_FAST_LEFT_INDEX; // 0x00000800
-const U32 AGENT_CONTROL_FAST_UP = 0x1 << CONTROL_FAST_UP_INDEX; // 0x00001000
-
-const U32 AGENT_CONTROL_FLY = 0x1 << CONTROL_FLY_INDEX; // 0x00002000
-const U32 AGENT_CONTROL_STOP = 0x1 << CONTROL_STOP_INDEX; // 0x00004000
-const U32 AGENT_CONTROL_FINISH_ANIM = 0x1 << CONTROL_FINISH_ANIM_INDEX; // 0x00008000
-const U32 AGENT_CONTROL_STAND_UP = 0x1 << CONTROL_STAND_UP_INDEX; // 0x00010000
-const U32 AGENT_CONTROL_SIT_ON_GROUND = 0x1 << CONTROL_SIT_ON_GROUND_INDEX; // 0x00020000
-const U32 AGENT_CONTROL_MOUSELOOK = 0x1 << CONTROL_MOUSELOOK_INDEX; // 0x00040000
-
-const U32 AGENT_CONTROL_NUDGE_AT_POS = 0x1 << CONTROL_NUDGE_AT_POS_INDEX; // 0x00080000
-const U32 AGENT_CONTROL_NUDGE_AT_NEG = 0x1 << CONTROL_NUDGE_AT_NEG_INDEX; // 0x00100000
-const U32 AGENT_CONTROL_NUDGE_LEFT_POS = 0x1 << CONTROL_NUDGE_LEFT_POS_INDEX; // 0x00200000
-const U32 AGENT_CONTROL_NUDGE_LEFT_NEG = 0x1 << CONTROL_NUDGE_LEFT_NEG_INDEX; // 0x00400000
-const U32 AGENT_CONTROL_NUDGE_UP_POS = 0x1 << CONTROL_NUDGE_UP_POS_INDEX; // 0x00800000
-const U32 AGENT_CONTROL_NUDGE_UP_NEG = 0x1 << CONTROL_NUDGE_UP_NEG_INDEX; // 0x01000000
-const U32 AGENT_CONTROL_TURN_LEFT = 0x1 << CONTROL_TURN_LEFT_INDEX; // 0x02000000
-const U32 AGENT_CONTROL_TURN_RIGHT = 0x1 << CONTROL_TURN_RIGHT_INDEX; // 0x04000000
-
-const U32 AGENT_CONTROL_AWAY = 0x1 << CONTROL_AWAY_INDEX; // 0x08000000
-
-const U32 AGENT_CONTROL_LBUTTON_DOWN = 0x1 << CONTROL_LBUTTON_DOWN_INDEX; // 0x10000000
-const U32 AGENT_CONTROL_LBUTTON_UP = 0x1 << CONTROL_LBUTTON_UP_INDEX; // 0x20000000
-const U32 AGENT_CONTROL_ML_LBUTTON_DOWN = 0x1 << CONTROL_ML_LBUTTON_DOWN_INDEX; // 0x40000000
-const U32 AGENT_CONTROL_ML_LBUTTON_UP = ((U32)0x1) << CONTROL_ML_LBUTTON_UP_INDEX; // 0x80000000
+constexpr U32 CONTROL_AT_POS_INDEX = 0;
+constexpr U32 CONTROL_AT_NEG_INDEX = 1;
+constexpr U32 CONTROL_LEFT_POS_INDEX = 2;
+constexpr U32 CONTROL_LEFT_NEG_INDEX = 3;
+constexpr U32 CONTROL_UP_POS_INDEX = 4;
+constexpr U32 CONTROL_UP_NEG_INDEX = 5;
+constexpr U32 CONTROL_PITCH_POS_INDEX = 6;
+constexpr U32 CONTROL_PITCH_NEG_INDEX = 7;
+constexpr U32 CONTROL_YAW_POS_INDEX = 8;
+constexpr U32 CONTROL_YAW_NEG_INDEX = 9;
+constexpr U32 CONTROL_FAST_AT_INDEX = 10;
+constexpr U32 CONTROL_FAST_LEFT_INDEX = 11;
+constexpr U32 CONTROL_FAST_UP_INDEX = 12;
+constexpr U32 CONTROL_FLY_INDEX = 13;
+constexpr U32 CONTROL_STOP_INDEX = 14;
+constexpr U32 CONTROL_FINISH_ANIM_INDEX = 15;
+constexpr U32 CONTROL_STAND_UP_INDEX = 16;
+constexpr U32 CONTROL_SIT_ON_GROUND_INDEX = 17;
+constexpr U32 CONTROL_MOUSELOOK_INDEX = 18;
+constexpr U32 CONTROL_NUDGE_AT_POS_INDEX = 19;
+constexpr U32 CONTROL_NUDGE_AT_NEG_INDEX = 20;
+constexpr U32 CONTROL_NUDGE_LEFT_POS_INDEX = 21;
+constexpr U32 CONTROL_NUDGE_LEFT_NEG_INDEX = 22;
+constexpr U32 CONTROL_NUDGE_UP_POS_INDEX = 23;
+constexpr U32 CONTROL_NUDGE_UP_NEG_INDEX = 24;
+constexpr U32 CONTROL_TURN_LEFT_INDEX = 25;
+constexpr U32 CONTROL_TURN_RIGHT_INDEX = 26;
+constexpr U32 CONTROL_AWAY_INDEX = 27;
+constexpr U32 CONTROL_LBUTTON_DOWN_INDEX = 28;
+constexpr U32 CONTROL_LBUTTON_UP_INDEX = 29;
+constexpr U32 CONTROL_ML_LBUTTON_DOWN_INDEX = 30;
+constexpr U32 CONTROL_ML_LBUTTON_UP_INDEX = 31;
+constexpr U32 TOTAL_CONTROLS = 32;
+
+constexpr U32 AGENT_CONTROL_AT_POS = 0x1 << CONTROL_AT_POS_INDEX; // 0x00000001
+constexpr U32 AGENT_CONTROL_AT_NEG = 0x1 << CONTROL_AT_NEG_INDEX; // 0x00000002
+constexpr U32 AGENT_CONTROL_LEFT_POS = 0x1 << CONTROL_LEFT_POS_INDEX; // 0x00000004
+constexpr U32 AGENT_CONTROL_LEFT_NEG = 0x1 << CONTROL_LEFT_NEG_INDEX; // 0x00000008
+constexpr U32 AGENT_CONTROL_UP_POS = 0x1 << CONTROL_UP_POS_INDEX; // 0x00000010
+constexpr U32 AGENT_CONTROL_UP_NEG = 0x1 << CONTROL_UP_NEG_INDEX; // 0x00000020
+constexpr U32 AGENT_CONTROL_PITCH_POS = 0x1 << CONTROL_PITCH_POS_INDEX; // 0x00000040
+constexpr U32 AGENT_CONTROL_PITCH_NEG = 0x1 << CONTROL_PITCH_NEG_INDEX; // 0x00000080
+constexpr U32 AGENT_CONTROL_YAW_POS = 0x1 << CONTROL_YAW_POS_INDEX; // 0x00000100
+constexpr U32 AGENT_CONTROL_YAW_NEG = 0x1 << CONTROL_YAW_NEG_INDEX; // 0x00000200
+
+constexpr U32 AGENT_CONTROL_FAST_AT = 0x1 << CONTROL_FAST_AT_INDEX; // 0x00000400
+constexpr U32 AGENT_CONTROL_FAST_LEFT = 0x1 << CONTROL_FAST_LEFT_INDEX; // 0x00000800
+constexpr U32 AGENT_CONTROL_FAST_UP = 0x1 << CONTROL_FAST_UP_INDEX; // 0x00001000
+
+constexpr U32 AGENT_CONTROL_FLY = 0x1 << CONTROL_FLY_INDEX; // 0x00002000
+constexpr U32 AGENT_CONTROL_STOP = 0x1 << CONTROL_STOP_INDEX; // 0x00004000
+constexpr U32 AGENT_CONTROL_FINISH_ANIM = 0x1 << CONTROL_FINISH_ANIM_INDEX; // 0x00008000
+constexpr U32 AGENT_CONTROL_STAND_UP = 0x1 << CONTROL_STAND_UP_INDEX; // 0x00010000
+constexpr U32 AGENT_CONTROL_SIT_ON_GROUND = 0x1 << CONTROL_SIT_ON_GROUND_INDEX; // 0x00020000
+constexpr U32 AGENT_CONTROL_MOUSELOOK = 0x1 << CONTROL_MOUSELOOK_INDEX; // 0x00040000
+
+constexpr U32 AGENT_CONTROL_NUDGE_AT_POS = 0x1 << CONTROL_NUDGE_AT_POS_INDEX; // 0x00080000
+constexpr U32 AGENT_CONTROL_NUDGE_AT_NEG = 0x1 << CONTROL_NUDGE_AT_NEG_INDEX; // 0x00100000
+constexpr U32 AGENT_CONTROL_NUDGE_LEFT_POS = 0x1 << CONTROL_NUDGE_LEFT_POS_INDEX; // 0x00200000
+constexpr U32 AGENT_CONTROL_NUDGE_LEFT_NEG = 0x1 << CONTROL_NUDGE_LEFT_NEG_INDEX; // 0x00400000
+constexpr U32 AGENT_CONTROL_NUDGE_UP_POS = 0x1 << CONTROL_NUDGE_UP_POS_INDEX; // 0x00800000
+constexpr U32 AGENT_CONTROL_NUDGE_UP_NEG = 0x1 << CONTROL_NUDGE_UP_NEG_INDEX; // 0x01000000
+constexpr U32 AGENT_CONTROL_TURN_LEFT = 0x1 << CONTROL_TURN_LEFT_INDEX; // 0x02000000
+constexpr U32 AGENT_CONTROL_TURN_RIGHT = 0x1 << CONTROL_TURN_RIGHT_INDEX; // 0x04000000
+
+constexpr U32 AGENT_CONTROL_AWAY = 0x1 << CONTROL_AWAY_INDEX; // 0x08000000
+
+constexpr U32 AGENT_CONTROL_LBUTTON_DOWN = 0x1 << CONTROL_LBUTTON_DOWN_INDEX; // 0x10000000
+constexpr U32 AGENT_CONTROL_LBUTTON_UP = 0x1 << CONTROL_LBUTTON_UP_INDEX; // 0x20000000
+constexpr U32 AGENT_CONTROL_ML_LBUTTON_DOWN = 0x1 << CONTROL_ML_LBUTTON_DOWN_INDEX; // 0x40000000
+constexpr U32 AGENT_CONTROL_ML_LBUTTON_UP = ((U32)0x1) << CONTROL_ML_LBUTTON_UP_INDEX; // 0x80000000
// move these up so that we can hide them in "State" for object updates
// (for now)
-const U32 AGENT_ATTACH_OFFSET = 4;
-const U32 AGENT_ATTACH_MASK = 0xf << AGENT_ATTACH_OFFSET;
+constexpr U32 AGENT_ATTACH_OFFSET = 4;
+constexpr U32 AGENT_ATTACH_MASK = 0xf << AGENT_ATTACH_OFFSET;
// RN: this method swaps the upper and lower nibbles to maintain backward
// compatibility with old objects that only used the upper nibble
#define ATTACHMENT_ID_FROM_STATE(state) ((S32)((((U8)state & AGENT_ATTACH_MASK) >> 4) | (((U8)state & ~AGENT_ATTACH_MASK) << 4)))
// DO NOT CHANGE THE SEQUENCE OF THIS LIST!!
-const U8 CLICK_ACTION_NONE = 0;
-const U8 CLICK_ACTION_TOUCH = 0;
-const U8 CLICK_ACTION_SIT = 1;
-const U8 CLICK_ACTION_BUY = 2;
-const U8 CLICK_ACTION_PAY = 3;
-const U8 CLICK_ACTION_OPEN = 4;
-const U8 CLICK_ACTION_PLAY = 5;
-const U8 CLICK_ACTION_OPEN_MEDIA = 6;
-const U8 CLICK_ACTION_ZOOM = 7;
-const U8 CLICK_ACTION_DISABLED = 8;
-const U8 CLICK_ACTION_IGNORE = 9;
+constexpr U8 CLICK_ACTION_NONE = 0;
+constexpr U8 CLICK_ACTION_TOUCH = 0;
+constexpr U8 CLICK_ACTION_SIT = 1;
+constexpr U8 CLICK_ACTION_BUY = 2;
+constexpr U8 CLICK_ACTION_PAY = 3;
+constexpr U8 CLICK_ACTION_OPEN = 4;
+constexpr U8 CLICK_ACTION_PLAY = 5;
+constexpr U8 CLICK_ACTION_OPEN_MEDIA = 6;
+constexpr U8 CLICK_ACTION_ZOOM = 7;
+constexpr U8 CLICK_ACTION_DISABLED = 8;
+constexpr U8 CLICK_ACTION_IGNORE = 9;
// DO NOT CHANGE THE SEQUENCE OF THIS LIST!!
diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h
index 3d18864b80..950f88e791 100644
--- a/indra/llcommon/llapp.h
+++ b/indra/llcommon/llapp.h
@@ -216,13 +216,6 @@ public:
// soon as the application status changes away from APP_STATUS_RUNNING
// (isRunning()).
//
- // sleep() returns true if it sleeps undisturbed for the entire specified
- // duration. The idea is that you can code 'while sleep(duration) ...',
- // which will break the loop once shutdown begins.
- //
- // Since any time-based LLUnit should be implicitly convertible to
- // F32Milliseconds, accept that specific type as a proxy.
- static bool sleep(F32Milliseconds duration);
// Allow any duration defined in terms of <chrono>.
// One can imagine a wonderfully general bidirectional conversion system
// between any type derived from LLUnits::LLUnit<T, LLUnits::Seconds> and
@@ -262,7 +255,7 @@ public:
void setDebugFileNames(const std::string &path);
// Return the Google Breakpad minidump filename after a crash.
- char *getMiniDumpFilename() { return mMinidumpPath; }
+ char* getMiniDumpFilename() { return mMinidumpPath; }
std::string* getStaticDebugFile() { return &mStaticDebugFileName; }
std::string* getDynamicDebugFile() { return &mDynamicDebugFileName; }
diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h
index d4b063f88c..96b48c1532 100644
--- a/indra/llcommon/lldefs.h
+++ b/indra/llcommon/lldefs.h
@@ -176,7 +176,7 @@ constexpr U32 MAXADDRSTR = 17; // 123.567.901.345 = 15 chars + \0 +
// the negative value to a huge positive value, producing the wrong answer!
// llless() specifically addresses that case.
template <typename T0, typename T1>
-inline bool llless(T0 d0, T1 d1)
+constexpr bool llless(T0 d0, T1 d1)
{
if constexpr (std::is_signed_v<T0> && ! std::is_signed_v<T1>)
{
@@ -204,13 +204,13 @@ inline bool llless(T0 d0, T1 d1)
// recursion tail
template <typename T>
-inline auto llmax(T data)
+constexpr auto llmax(T data)
{
return data;
}
template <typename T0, typename T1, typename... Ts>
-inline auto llmax(T0 d0, T1 d1, Ts... rest)
+constexpr auto llmax(T0 d0, T1 d1, Ts... rest)
{
auto maxrest = llmax(d1, rest...);
return llless(maxrest, d0)? d0 : maxrest;
@@ -218,20 +218,20 @@ inline auto llmax(T0 d0, T1 d1, Ts... rest)
// recursion tail
template <typename T>
-inline auto llmin(T data)
+constexpr auto llmin(T data)
{
return data;
}
template <typename T0, typename T1, typename... Ts>
-inline auto llmin(T0 d0, T1 d1, Ts... rest)
+constexpr auto llmin(T0 d0, T1 d1, Ts... rest)
{
auto minrest = llmin(d1, rest...);
return llless(d0, minrest) ? d0 : minrest;
}
template <typename A, typename MIN, typename MAX>
-inline A llclamp(A a, MIN minval, MAX maxval)
+constexpr A llclamp(A a, MIN minval, MAX maxval)
{
// The only troublesome case is if A is unsigned and either minval or
// maxval is both signed and negative. Casting a negative number to
@@ -262,13 +262,13 @@ inline A llclamp(A a, MIN minval, MAX maxval)
}
template <class LLDATATYPE>
-inline LLDATATYPE llclampf(LLDATATYPE a)
+constexpr LLDATATYPE llclampf(LLDATATYPE a)
{
return llmin(llmax(a, LLDATATYPE(0)), LLDATATYPE(1));
}
template <class LLDATATYPE>
-inline LLDATATYPE llclampb(LLDATATYPE a)
+constexpr LLDATATYPE llclampb(LLDATATYPE a)
{
return llmin(llmax(a, LLDATATYPE(0)), LLDATATYPE(255));
}
diff --git a/indra/llmath/v2math.cpp b/indra/llmath/v2math.cpp
index 4649e13376..198fedcb03 100644
--- a/indra/llmath/v2math.cpp
+++ b/indra/llmath/v2math.cpp
@@ -26,7 +26,6 @@
#include "linden_common.h"
-//#include "vmath.h"
#include "v2math.h"
#include "v3math.h"
#include "v4math.h"
@@ -47,8 +46,8 @@ bool LLVector2::abs()
{
bool ret{ false };
- if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = true; }
- if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = true; }
+ if (mV[VX] < 0.f) { mV[VX] = -mV[VX]; ret = true; }
+ if (mV[VY] < 0.f) { mV[VY] = -mV[VY]; ret = true; }
return ret;
}
@@ -67,7 +66,7 @@ F32 angle_between(const LLVector2& a, const LLVector2& b)
return angle;
}
-bool are_parallel(const LLVector2 &a, const LLVector2 &b, float epsilon)
+bool are_parallel(const LLVector2& a, const LLVector2& b, F32 epsilon)
{
LLVector2 an = a;
LLVector2 bn = b;
@@ -82,28 +81,28 @@ bool are_parallel(const LLVector2 &a, const LLVector2 &b, float epsilon)
}
-F32 dist_vec(const LLVector2 &a, const LLVector2 &b)
+F32 dist_vec(const LLVector2& a, const LLVector2& b)
{
- F32 x = a.mV[0] - b.mV[0];
- F32 y = a.mV[1] - b.mV[1];
+ F32 x = a.mV[VX] - b.mV[VX];
+ F32 y = a.mV[VY] - b.mV[VY];
return (F32) sqrt( x*x + y*y );
}
-F32 dist_vec_squared(const LLVector2 &a, const LLVector2 &b)
+F32 dist_vec_squared(const LLVector2& a, const LLVector2& b)
{
- F32 x = a.mV[0] - b.mV[0];
- F32 y = a.mV[1] - b.mV[1];
+ F32 x = a.mV[VX] - b.mV[VX];
+ F32 y = a.mV[VY] - b.mV[VY];
return x*x + y*y;
}
-F32 dist_vec_squared2D(const LLVector2 &a, const LLVector2 &b)
+F32 dist_vec_squared2D(const LLVector2& a, const LLVector2& b)
{
- F32 x = a.mV[0] - b.mV[0];
- F32 y = a.mV[1] - b.mV[1];
+ F32 x = a.mV[VX] - b.mV[VX];
+ F32 y = a.mV[VY] - b.mV[VY];
return x*x + y*y;
}
-LLVector2 lerp(const LLVector2 &a, const LLVector2 &b, F32 u)
+LLVector2 lerp(const LLVector2& a, const LLVector2& b, F32 u)
{
return LLVector2(
a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u,
@@ -113,14 +112,14 @@ LLVector2 lerp(const LLVector2 &a, const LLVector2 &b, F32 u)
LLSD LLVector2::getValue() const
{
LLSD ret;
- ret[0] = mV[0];
- ret[1] = mV[1];
+ ret[0] = mV[VX];
+ ret[1] = mV[VY];
return ret;
}
void LLVector2::setValue(const LLSD& sd)
{
- mV[0] = (F32) sd[0].asReal();
- mV[1] = (F32) sd[1].asReal();
+ mV[VX] = (F32) sd[0].asReal();
+ mV[VY] = (F32) sd[1].asReal();
}
diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h
index a61c946304..a0ba3ec505 100644
--- a/indra/llmath/v2math.h
+++ b/indra/llmath/v2math.h
@@ -36,7 +36,7 @@ class LLQuaternion;
// Llvector2 = |x y z w|
-static const U32 LENGTHOFVECTOR2 = 2;
+static constexpr U32 LENGTHOFVECTOR2 = 2;
class LLVector2
{
@@ -82,7 +82,7 @@ class LLVector2
const LLVector2& scaleVec(const LLVector2& vec); // scales per component by vec
- bool isNull(); // Returns true if vector has a _very_small_ length
+ bool isNull() const; // Returns true if vector has a _very_small_ length
bool isExactlyZero() const { return !mV[VX] && !mV[VY]; }
F32 operator[](int idx) const { return mV[idx]; }
@@ -113,16 +113,16 @@ class LLVector2
// Non-member functions
-F32 angle_between(const LLVector2 &a, const LLVector2 &b); // Returns angle (radians) between a and b
-bool are_parallel(const LLVector2 &a, const LLVector2 &b, F32 epsilon=F_APPROXIMATELY_ZERO); // Returns true if a and b are very close to parallel
-F32 dist_vec(const LLVector2 &a, const LLVector2 &b); // Returns distance between a and b
-F32 dist_vec_squared(const LLVector2 &a, const LLVector2 &b);// Returns distance squared between a and b
-F32 dist_vec_squared2D(const LLVector2 &a, const LLVector2 &b);// Returns distance squared between a and b ignoring Z component
-LLVector2 lerp(const LLVector2 &a, const LLVector2 &b, F32 u); // Returns a vector that is a linear interpolation between a and b
+F32 angle_between(const LLVector2& a, const LLVector2& b); // Returns angle (radians) between a and b
+bool are_parallel(const LLVector2& a, const LLVector2& b, F32 epsilon = F_APPROXIMATELY_ZERO); // Returns true if a and b are very close to parallel
+F32 dist_vec(const LLVector2& a, const LLVector2& b); // Returns distance between a and b
+F32 dist_vec_squared(const LLVector2& a, const LLVector2& b);// Returns distance squared between a and b
+F32 dist_vec_squared2D(const LLVector2& a, const LLVector2& b);// Returns distance squared between a and b ignoring Z component
+LLVector2 lerp(const LLVector2& a, const LLVector2& b, F32 u); // Returns a vector that is a linear interpolation between a and b
// Constructors
-inline LLVector2::LLVector2(void)
+inline LLVector2::LLVector2()
{
mV[VX] = 0.f;
mV[VY] = 0.f;
@@ -153,27 +153,27 @@ inline LLVector2::LLVector2(const LLSD &sd)
// Clear and Assignment Functions
-inline void LLVector2::clear(void)
+inline void LLVector2::clear()
{
mV[VX] = 0.f;
mV[VY] = 0.f;
}
-inline void LLVector2::setZero(void)
+inline void LLVector2::setZero()
{
mV[VX] = 0.f;
mV[VY] = 0.f;
}
// deprecated
-inline void LLVector2::clearVec(void)
+inline void LLVector2::clearVec()
{
mV[VX] = 0.f;
mV[VY] = 0.f;
}
// deprecated
-inline void LLVector2::zeroVec(void)
+inline void LLVector2::zeroVec()
{
mV[VX] = 0.f;
mV[VY] = 0.f;
@@ -222,31 +222,31 @@ inline void LLVector2::setVec(const F32 *vec)
// LLVector2 Magnitude and Normalization Functions
-inline F32 LLVector2::length(void) const
+inline F32 LLVector2::length() const
{
- return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]);
+ return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY]);
}
-inline F32 LLVector2::lengthSquared(void) const
+inline F32 LLVector2::lengthSquared() const
{
- return mV[0]*mV[0] + mV[1]*mV[1];
+ return mV[VX]*mV[VX] + mV[VY]*mV[VY];
}
-inline F32 LLVector2::normalize(void)
+inline F32 LLVector2::normalize()
{
- F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]);
+ F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY]);
F32 oomag;
if (mag > FP_MAG_THRESHOLD)
{
oomag = 1.f/mag;
- mV[0] *= oomag;
- mV[1] *= oomag;
+ mV[VX] *= oomag;
+ mV[VY] *= oomag;
}
else
{
- mV[0] = 0.f;
- mV[1] = 0.f;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
mag = 0;
}
return (mag);
@@ -259,33 +259,33 @@ inline bool LLVector2::isFinite() const
}
// deprecated
-inline F32 LLVector2::magVec(void) const
+inline F32 LLVector2::magVec() const
{
- return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]);
+ return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY]);
}
// deprecated
-inline F32 LLVector2::magVecSquared(void) const
+inline F32 LLVector2::magVecSquared() const
{
- return mV[0]*mV[0] + mV[1]*mV[1];
+ return mV[VX]*mV[VX] + mV[VY]*mV[VY];
}
// deprecated
-inline F32 LLVector2::normVec(void)
+inline F32 LLVector2::normVec()
{
- F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]);
+ F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY]);
F32 oomag;
if (mag > FP_MAG_THRESHOLD)
{
oomag = 1.f/mag;
- mV[0] *= oomag;
- mV[1] *= oomag;
+ mV[VX] *= oomag;
+ mV[VY] *= oomag;
}
else
{
- mV[0] = 0.f;
- mV[1] = 0.f;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
mag = 0;
}
return (mag);
@@ -299,7 +299,7 @@ inline const LLVector2& LLVector2::scaleVec(const LLVector2& vec)
return *this;
}
-inline bool LLVector2::isNull()
+inline bool LLVector2::isNull() const
{
if ( F_APPROXIMATELY_ZERO > mV[VX]*mV[VX] + mV[VY]*mV[VY] )
{
@@ -312,7 +312,7 @@ inline bool LLVector2::isNull()
// LLVector2 Operators
// For sorting. By convention, x is "more significant" than y.
-inline bool operator<(const LLVector2 &a, const LLVector2 &b)
+inline bool operator<(const LLVector2& a, const LLVector2& b)
{
if( a.mV[VX] == b.mV[VX] )
{
@@ -325,95 +325,95 @@ inline bool operator<(const LLVector2 &a, const LLVector2 &b)
}
-inline LLVector2 operator+(const LLVector2 &a, const LLVector2 &b)
+inline LLVector2 operator+(const LLVector2& a, const LLVector2& b)
{
LLVector2 c(a);
return c += b;
}
-inline LLVector2 operator-(const LLVector2 &a, const LLVector2 &b)
+inline LLVector2 operator-(const LLVector2& a, const LLVector2& b)
{
LLVector2 c(a);
return c -= b;
}
-inline F32 operator*(const LLVector2 &a, const LLVector2 &b)
+inline F32 operator*(const LLVector2& a, const LLVector2& b)
{
- return (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1]);
+ return (a.mV[VX]*b.mV[VX] + a.mV[VY]*b.mV[VY]);
}
-inline LLVector2 operator%(const LLVector2 &a, const LLVector2 &b)
+inline LLVector2 operator%(const LLVector2& a, const LLVector2& b)
{
- return LLVector2(a.mV[0]*b.mV[1] - b.mV[0]*a.mV[1], a.mV[1]*b.mV[0] - b.mV[1]*a.mV[0]);
+ return LLVector2(a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY], a.mV[VY]*b.mV[VX] - b.mV[VY]*a.mV[VX]);
}
-inline LLVector2 operator/(const LLVector2 &a, F32 k)
+inline LLVector2 operator/(const LLVector2& a, F32 k)
{
F32 t = 1.f / k;
- return LLVector2( a.mV[0] * t, a.mV[1] * t );
+ return LLVector2( a.mV[VX] * t, a.mV[VY] * t );
}
-inline LLVector2 operator*(const LLVector2 &a, F32 k)
+inline LLVector2 operator*(const LLVector2& a, F32 k)
{
- return LLVector2( a.mV[0] * k, a.mV[1] * k );
+ return LLVector2( a.mV[VX] * k, a.mV[VY] * k );
}
-inline LLVector2 operator*(F32 k, const LLVector2 &a)
+inline LLVector2 operator*(F32 k, const LLVector2& a)
{
- return LLVector2( a.mV[0] * k, a.mV[1] * k );
+ return LLVector2( a.mV[VX] * k, a.mV[VY] * k );
}
-inline bool operator==(const LLVector2 &a, const LLVector2 &b)
+inline bool operator==(const LLVector2& a, const LLVector2& b)
{
- return ( (a.mV[0] == b.mV[0])
- &&(a.mV[1] == b.mV[1]));
+ return ( (a.mV[VX] == b.mV[VX])
+ &&(a.mV[VY] == b.mV[VY]));
}
-inline bool operator!=(const LLVector2 &a, const LLVector2 &b)
+inline bool operator!=(const LLVector2& a, const LLVector2& b)
{
- return ( (a.mV[0] != b.mV[0])
- ||(a.mV[1] != b.mV[1]));
+ return ( (a.mV[VX] != b.mV[VX])
+ ||(a.mV[VY] != b.mV[VY]));
}
-inline const LLVector2& operator+=(LLVector2 &a, const LLVector2 &b)
+inline const LLVector2& operator+=(LLVector2& a, const LLVector2& b)
{
- a.mV[0] += b.mV[0];
- a.mV[1] += b.mV[1];
+ a.mV[VX] += b.mV[VX];
+ a.mV[VY] += b.mV[VY];
return a;
}
-inline const LLVector2& operator-=(LLVector2 &a, const LLVector2 &b)
+inline const LLVector2& operator-=(LLVector2& a, const LLVector2& b)
{
- a.mV[0] -= b.mV[0];
- a.mV[1] -= b.mV[1];
+ a.mV[VX] -= b.mV[VX];
+ a.mV[VY] -= b.mV[VY];
return a;
}
-inline const LLVector2& operator%=(LLVector2 &a, const LLVector2 &b)
+inline const LLVector2& operator%=(LLVector2& a, const LLVector2& b)
{
- LLVector2 ret(a.mV[0]*b.mV[1] - b.mV[0]*a.mV[1], a.mV[1]*b.mV[0] - b.mV[1]*a.mV[0]);
+ LLVector2 ret(a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY], a.mV[VY]*b.mV[VX] - b.mV[VY]*a.mV[VX]);
a = ret;
return a;
}
-inline const LLVector2& operator*=(LLVector2 &a, F32 k)
+inline const LLVector2& operator*=(LLVector2& a, F32 k)
{
- a.mV[0] *= k;
- a.mV[1] *= k;
+ a.mV[VX] *= k;
+ a.mV[VY] *= k;
return a;
}
-inline const LLVector2& operator/=(LLVector2 &a, F32 k)
+inline const LLVector2& operator/=(LLVector2& a, F32 k)
{
F32 t = 1.f / k;
- a.mV[0] *= t;
- a.mV[1] *= t;
+ a.mV[VX] *= t;
+ a.mV[VY] *= t;
return a;
}
-inline LLVector2 operator-(const LLVector2 &a)
+inline LLVector2 operator-(const LLVector2& a)
{
- return LLVector2( -a.mV[0], -a.mV[1] );
+ return LLVector2( -a.mV[VX], -a.mV[VY] );
}
inline void update_min_max(LLVector2& min, LLVector2& max, const LLVector2& pos)
@@ -431,7 +431,7 @@ inline void update_min_max(LLVector2& min, LLVector2& max, const LLVector2& pos)
}
}
-inline std::ostream& operator<<(std::ostream& s, const LLVector2 &a)
+inline std::ostream& operator<<(std::ostream& s, const LLVector2& a)
{
s << "{ " << a.mV[VX] << ", " << a.mV[VY] << " }";
return s;
diff --git a/indra/llmath/v3dmath.cpp b/indra/llmath/v3dmath.cpp
index bb55c812b5..bd6d838186 100644
--- a/indra/llmath/v3dmath.cpp
+++ b/indra/llmath/v3dmath.cpp
@@ -57,13 +57,13 @@ bool LLVector3d::clamp(F64 min, F64 max)
{
bool ret{ false };
- if (mdV[0] < min) { mdV[0] = min; ret = true; }
- if (mdV[1] < min) { mdV[1] = min; ret = true; }
- if (mdV[2] < min) { mdV[2] = min; ret = true; }
+ if (mdV[VX] < min) { mdV[VX] = min; ret = true; }
+ if (mdV[VY] < min) { mdV[VY] = min; ret = true; }
+ if (mdV[VZ] < min) { mdV[VZ] = min; ret = true; }
- if (mdV[0] > max) { mdV[0] = max; ret = true; }
- if (mdV[1] > max) { mdV[1] = max; ret = true; }
- if (mdV[2] > max) { mdV[2] = max; ret = true; }
+ if (mdV[VX] > max) { mdV[VX] = max; ret = true; }
+ if (mdV[VY] > max) { mdV[VY] = max; ret = true; }
+ if (mdV[VZ] > max) { mdV[VZ] = max; ret = true; }
return ret;
}
@@ -74,9 +74,9 @@ bool LLVector3d::abs()
{
bool ret{ false };
- if (mdV[0] < 0.0) { mdV[0] = -mdV[0]; ret = true; }
- if (mdV[1] < 0.0) { mdV[1] = -mdV[1]; ret = true; }
- if (mdV[2] < 0.0) { mdV[2] = -mdV[2]; ret = true; }
+ if (mdV[VX] < 0.0) { mdV[VX] = -mdV[VX]; ret = true; }
+ if (mdV[VY] < 0.0) { mdV[VY] = -mdV[VY]; ret = true; }
+ if (mdV[VZ] < 0.0) { mdV[VZ] = -mdV[VZ]; ret = true; }
return ret;
}
@@ -89,9 +89,9 @@ std::ostream& operator<<(std::ostream& s, const LLVector3d &a)
const LLVector3d& LLVector3d::operator=(const LLVector4 &a)
{
- mdV[0] = a.mV[0];
- mdV[1] = a.mV[1];
- mdV[2] = a.mV[2];
+ mdV[VX] = a.mV[VX];
+ mdV[VY] = a.mV[VY];
+ mdV[VZ] = a.mV[VZ];
return *this;
}
diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h
index ece8c54ea4..7c94ebdf9b 100644
--- a/indra/llmath/v3dmath.h
+++ b/indra/llmath/v3dmath.h
@@ -54,17 +54,17 @@ class LLVector3d
void setValue(const LLSD& sd)
{
- mdV[0] = sd[0].asReal();
- mdV[1] = sd[1].asReal();
- mdV[2] = sd[2].asReal();
+ mdV[VX] = sd[0].asReal();
+ mdV[VY] = sd[1].asReal();
+ mdV[VZ] = sd[2].asReal();
}
LLSD getValue() const
{
LLSD ret;
- ret[0] = mdV[0];
- ret[1] = mdV[1];
- ret[2] = mdV[2];
+ ret[0] = mdV[VX];
+ ret[1] = mdV[VY];
+ ret[2] = mdV[VZ];
return ret;
}
@@ -134,26 +134,26 @@ typedef LLVector3d LLGlobalVec;
inline const LLVector3d &LLVector3d::set(const LLVector3 &vec)
{
- mdV[0] = vec.mV[0];
- mdV[1] = vec.mV[1];
- mdV[2] = vec.mV[2];
+ mdV[VX] = vec.mV[VX];
+ mdV[VY] = vec.mV[VY];
+ mdV[VZ] = vec.mV[VZ];
return *this;
}
inline const LLVector3d &LLVector3d::setVec(const LLVector3 &vec)
{
- mdV[0] = vec.mV[0];
- mdV[1] = vec.mV[1];
- mdV[2] = vec.mV[2];
+ mdV[VX] = vec.mV[VX];
+ mdV[VY] = vec.mV[VY];
+ mdV[VZ] = vec.mV[VZ];
return *this;
}
inline LLVector3d::LLVector3d(void)
{
- mdV[0] = 0.f;
- mdV[1] = 0.f;
- mdV[2] = 0.f;
+ mdV[VX] = 0.f;
+ mdV[VY] = 0.f;
+ mdV[VZ] = 0.f;
}
inline LLVector3d::LLVector3d(const F64 x, const F64 y, const F64 z)
@@ -199,33 +199,33 @@ inline bool LLVector3d::isFinite() const
inline const LLVector3d& LLVector3d::clear(void)
{
- mdV[0] = 0.f;
- mdV[1] = 0.f;
- mdV[2]= 0.f;
+ mdV[VX] = 0.f;
+ mdV[VY] = 0.f;
+ mdV[VZ] = 0.f;
return (*this);
}
inline const LLVector3d& LLVector3d::clearVec(void)
{
- mdV[0] = 0.f;
- mdV[1] = 0.f;
- mdV[2]= 0.f;
+ mdV[VX] = 0.f;
+ mdV[VY] = 0.f;
+ mdV[VZ] = 0.f;
return (*this);
}
inline const LLVector3d& LLVector3d::setZero(void)
{
- mdV[0] = 0.f;
- mdV[1] = 0.f;
- mdV[2] = 0.f;
+ mdV[VX] = 0.f;
+ mdV[VY] = 0.f;
+ mdV[VZ] = 0.f;
return (*this);
}
inline const LLVector3d& LLVector3d::zeroVec(void)
{
- mdV[0] = 0.f;
- mdV[1] = 0.f;
- mdV[2] = 0.f;
+ mdV[VX] = 0.f;
+ mdV[VY] = 0.f;
+ mdV[VZ] = 0.f;
return (*this);
}
@@ -239,17 +239,17 @@ inline const LLVector3d& LLVector3d::set(const F64 x, const F64 y, const F64
inline const LLVector3d& LLVector3d::set(const LLVector3d &vec)
{
- mdV[0] = vec.mdV[0];
- mdV[1] = vec.mdV[1];
- mdV[2] = vec.mdV[2];
+ mdV[VX] = vec.mdV[VX];
+ mdV[VY] = vec.mdV[VY];
+ mdV[VZ] = vec.mdV[VZ];
return (*this);
}
inline const LLVector3d& LLVector3d::set(const F64 *vec)
{
- mdV[0] = vec[0];
- mdV[1] = vec[1];
- mdV[2] = vec[2];
+ mdV[VX] = vec[0];
+ mdV[VY] = vec[1];
+ mdV[VZ] = vec[2];
return (*this);
}
@@ -261,61 +261,61 @@ inline const LLVector3d& LLVector3d::setVec(const F64 x, const F64 y, const F
return (*this);
}
-inline const LLVector3d& LLVector3d::setVec(const LLVector3d &vec)
+inline const LLVector3d& LLVector3d::setVec(const LLVector3d& vec)
{
- mdV[0] = vec.mdV[0];
- mdV[1] = vec.mdV[1];
- mdV[2] = vec.mdV[2];
+ mdV[VX] = vec.mdV[VX];
+ mdV[VY] = vec.mdV[VY];
+ mdV[VZ] = vec.mdV[VZ];
return (*this);
}
-inline const LLVector3d& LLVector3d::setVec(const F64 *vec)
+inline const LLVector3d& LLVector3d::setVec(const F64* vec)
{
- mdV[0] = vec[0];
- mdV[1] = vec[1];
- mdV[2] = vec[2];
+ mdV[VX] = vec[VX];
+ mdV[VY] = vec[VY];
+ mdV[VZ] = vec[VZ];
return (*this);
}
-inline F64 LLVector3d::normVec(void)
+inline F64 LLVector3d::normVec()
{
- F64 mag = (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+ F64 mag = sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]);
F64 oomag;
if (mag > FP_MAG_THRESHOLD)
{
oomag = 1.f/mag;
- mdV[0] *= oomag;
- mdV[1] *= oomag;
- mdV[2] *= oomag;
+ mdV[VX] *= oomag;
+ mdV[VY] *= oomag;
+ mdV[VZ] *= oomag;
}
else
{
- mdV[0] = 0.f;
- mdV[1] = 0.f;
- mdV[2] = 0.f;
+ mdV[VX] = 0.f;
+ mdV[VY] = 0.f;
+ mdV[VZ] = 0.f;
mag = 0;
}
return (mag);
}
-inline F64 LLVector3d::normalize(void)
+inline F64 LLVector3d::normalize()
{
- F64 mag = (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+ F64 mag = sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]);
F64 oomag;
if (mag > FP_MAG_THRESHOLD)
{
oomag = 1.f/mag;
- mdV[0] *= oomag;
- mdV[1] *= oomag;
- mdV[2] *= oomag;
+ mdV[VX] *= oomag;
+ mdV[VY] *= oomag;
+ mdV[VZ] *= oomag;
}
else
{
- mdV[0] = 0.f;
- mdV[1] = 0.f;
- mdV[2] = 0.f;
+ mdV[VX] = 0.f;
+ mdV[VY] = 0.f;
+ mdV[VZ] = 0.f;
mag = 0;
}
return (mag);
@@ -323,24 +323,24 @@ inline F64 LLVector3d::normalize(void)
// LLVector3d Magnitude and Normalization Functions
-inline F64 LLVector3d::magVec(void) const
+inline F64 LLVector3d::magVec() const
{
- return (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+ return sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]);
}
-inline F64 LLVector3d::magVecSquared(void) const
+inline F64 LLVector3d::magVecSquared() const
{
- return mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2];
+ return mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ];
}
-inline F64 LLVector3d::length(void) const
+inline F64 LLVector3d::length() const
{
- return (F32) sqrt(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+ return sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]);
}
-inline F64 LLVector3d::lengthSquared(void) const
+inline F64 LLVector3d::lengthSquared() const
{
- return mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2];
+ return mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ];
}
inline LLVector3d operator+(const LLVector3d& a, const LLVector3d& b)
@@ -357,109 +357,109 @@ inline LLVector3d operator-(const LLVector3d& a, const LLVector3d& b)
inline F64 operator*(const LLVector3d& a, const LLVector3d& b)
{
- return (a.mdV[0]*b.mdV[0] + a.mdV[1]*b.mdV[1] + a.mdV[2]*b.mdV[2]);
+ return (a.mdV[VX]*b.mdV[VX] + a.mdV[VY]*b.mdV[VY] + a.mdV[VZ]*b.mdV[VZ]);
}
inline LLVector3d operator%(const LLVector3d& a, const LLVector3d& b)
{
- return LLVector3d( a.mdV[1]*b.mdV[2] - b.mdV[1]*a.mdV[2], a.mdV[2]*b.mdV[0] - b.mdV[2]*a.mdV[0], a.mdV[0]*b.mdV[1] - b.mdV[0]*a.mdV[1] );
+ return LLVector3d( a.mdV[VY]*b.mdV[VZ] - b.mdV[VY]*a.mdV[VZ], a.mdV[VZ]*b.mdV[VX] - b.mdV[VZ]*a.mdV[VX], a.mdV[VX]*b.mdV[VY] - b.mdV[VX]*a.mdV[VY] );
}
inline LLVector3d operator/(const LLVector3d& a, const F64 k)
{
F64 t = 1.f / k;
- return LLVector3d( a.mdV[0] * t, a.mdV[1] * t, a.mdV[2] * t );
+ return LLVector3d( a.mdV[VX] * t, a.mdV[VY] * t, a.mdV[VZ] * t );
}
inline LLVector3d operator*(const LLVector3d& a, const F64 k)
{
- return LLVector3d( a.mdV[0] * k, a.mdV[1] * k, a.mdV[2] * k );
+ return LLVector3d( a.mdV[VX] * k, a.mdV[VY] * k, a.mdV[VZ] * k );
}
inline LLVector3d operator*(F64 k, const LLVector3d& a)
{
- return LLVector3d( a.mdV[0] * k, a.mdV[1] * k, a.mdV[2] * k );
+ return LLVector3d( a.mdV[VX] * k, a.mdV[VY] * k, a.mdV[VZ] * k );
}
inline bool operator==(const LLVector3d& a, const LLVector3d& b)
{
- return ( (a.mdV[0] == b.mdV[0])
- &&(a.mdV[1] == b.mdV[1])
- &&(a.mdV[2] == b.mdV[2]));
+ return ( (a.mdV[VX] == b.mdV[VX])
+ &&(a.mdV[VY] == b.mdV[VY])
+ &&(a.mdV[VZ] == b.mdV[VZ]));
}
inline bool operator!=(const LLVector3d& a, const LLVector3d& b)
{
- return ( (a.mdV[0] != b.mdV[0])
- ||(a.mdV[1] != b.mdV[1])
- ||(a.mdV[2] != b.mdV[2]));
+ return ( (a.mdV[VX] != b.mdV[VX])
+ ||(a.mdV[VY] != b.mdV[VY])
+ ||(a.mdV[VZ] != b.mdV[VZ]));
}
inline const LLVector3d& operator+=(LLVector3d& a, const LLVector3d& b)
{
- a.mdV[0] += b.mdV[0];
- a.mdV[1] += b.mdV[1];
- a.mdV[2] += b.mdV[2];
+ a.mdV[VX] += b.mdV[VX];
+ a.mdV[VY] += b.mdV[VY];
+ a.mdV[VZ] += b.mdV[VZ];
return a;
}
inline const LLVector3d& operator-=(LLVector3d& a, const LLVector3d& b)
{
- a.mdV[0] -= b.mdV[0];
- a.mdV[1] -= b.mdV[1];
- a.mdV[2] -= b.mdV[2];
+ a.mdV[VX] -= b.mdV[VX];
+ a.mdV[VY] -= b.mdV[VY];
+ a.mdV[VZ] -= b.mdV[VZ];
return a;
}
inline const LLVector3d& operator%=(LLVector3d& a, const LLVector3d& b)
{
- LLVector3d ret( a.mdV[1]*b.mdV[2] - b.mdV[1]*a.mdV[2], a.mdV[2]*b.mdV[0] - b.mdV[2]*a.mdV[0], a.mdV[0]*b.mdV[1] - b.mdV[0]*a.mdV[1]);
+ LLVector3d ret( a.mdV[VY]*b.mdV[VZ] - b.mdV[VY]*a.mdV[VZ], a.mdV[VZ]*b.mdV[VX] - b.mdV[VZ]*a.mdV[VX], a.mdV[VX]*b.mdV[VY] - b.mdV[VX]*a.mdV[VY]);
a = ret;
return a;
}
inline const LLVector3d& operator*=(LLVector3d& a, const F64 k)
{
- a.mdV[0] *= k;
- a.mdV[1] *= k;
- a.mdV[2] *= k;
+ a.mdV[VX] *= k;
+ a.mdV[VY] *= k;
+ a.mdV[VZ] *= k;
return a;
}
inline const LLVector3d& operator/=(LLVector3d& a, const F64 k)
{
F64 t = 1.f / k;
- a.mdV[0] *= t;
- a.mdV[1] *= t;
- a.mdV[2] *= t;
+ a.mdV[VX] *= t;
+ a.mdV[VY] *= t;
+ a.mdV[VZ] *= t;
return a;
}
inline LLVector3d operator-(const LLVector3d& a)
{
- return LLVector3d( -a.mdV[0], -a.mdV[1], -a.mdV[2] );
+ return LLVector3d( -a.mdV[VX], -a.mdV[VY], -a.mdV[VZ] );
}
inline F64 dist_vec(const LLVector3d& a, const LLVector3d& b)
{
- F64 x = a.mdV[0] - b.mdV[0];
- F64 y = a.mdV[1] - b.mdV[1];
- F64 z = a.mdV[2] - b.mdV[2];
+ F64 x = a.mdV[VX] - b.mdV[VX];
+ F64 y = a.mdV[VY] - b.mdV[VY];
+ F64 z = a.mdV[VZ] - b.mdV[VZ];
return (F32) sqrt( x*x + y*y + z*z );
}
inline F64 dist_vec_squared(const LLVector3d& a, const LLVector3d& b)
{
- F64 x = a.mdV[0] - b.mdV[0];
- F64 y = a.mdV[1] - b.mdV[1];
- F64 z = a.mdV[2] - b.mdV[2];
+ F64 x = a.mdV[VX] - b.mdV[VX];
+ F64 y = a.mdV[VY] - b.mdV[VY];
+ F64 z = a.mdV[VZ] - b.mdV[VZ];
return x*x + y*y + z*z;
}
inline F64 dist_vec_squared2D(const LLVector3d& a, const LLVector3d& b)
{
- F64 x = a.mdV[0] - b.mdV[0];
- F64 y = a.mdV[1] - b.mdV[1];
+ F64 x = a.mdV[VX] - b.mdV[VX];
+ F64 y = a.mdV[VY] - b.mdV[VY];
return x*x + y*y;
}
diff --git a/indra/llmath/v3math.cpp b/indra/llmath/v3math.cpp
index 73ad2a4ed6..941a122528 100644
--- a/indra/llmath/v3math.cpp
+++ b/indra/llmath/v3math.cpp
@@ -58,13 +58,13 @@ bool LLVector3::clamp(F32 min, F32 max)
{
bool ret{ false };
- if (mV[0] < min) { mV[0] = min; ret = true; }
- if (mV[1] < min) { mV[1] = min; ret = true; }
- if (mV[2] < min) { mV[2] = min; ret = true; }
+ if (mV[VX] < min) { mV[VX] = min; ret = true; }
+ if (mV[VY] < min) { mV[VY] = min; ret = true; }
+ if (mV[VZ] < min) { mV[VZ] = min; ret = true; }
- if (mV[0] > max) { mV[0] = max; ret = true; }
- if (mV[1] > max) { mV[1] = max; ret = true; }
- if (mV[2] > max) { mV[2] = max; ret = true; }
+ if (mV[VX] > max) { mV[VX] = max; ret = true; }
+ if (mV[VY] > max) { mV[VY] = max; ret = true; }
+ if (mV[VZ] > max) { mV[VZ] = max; ret = true; }
return ret;
}
@@ -85,9 +85,9 @@ bool LLVector3::clampLength( F32 length_limit )
{
length_limit = 0.f;
}
- mV[0] *= length_limit;
- mV[1] *= length_limit;
- mV[2] *= length_limit;
+ mV[VX] *= length_limit;
+ mV[VY] *= length_limit;
+ mV[VZ] *= length_limit;
changed = true;
}
}
@@ -116,35 +116,35 @@ bool LLVector3::clampLength( F32 length_limit )
{
// yes it can be salvaged -->
// bring the components down before we normalize
- mV[0] /= max_abs_component;
- mV[1] /= max_abs_component;
- mV[2] /= max_abs_component;
+ mV[VX] /= max_abs_component;
+ mV[VY] /= max_abs_component;
+ mV[VZ] /= max_abs_component;
normalize();
if (length_limit < 0.f)
{
length_limit = 0.f;
}
- mV[0] *= length_limit;
- mV[1] *= length_limit;
- mV[2] *= length_limit;
+ mV[VX] *= length_limit;
+ mV[VY] *= length_limit;
+ mV[VZ] *= length_limit;
}
}
return changed;
}
-bool LLVector3::clamp(const LLVector3 &min_vec, const LLVector3 &max_vec)
+bool LLVector3::clamp(const LLVector3& min_vec, const LLVector3& max_vec)
{
bool ret{ false };
- if (mV[0] < min_vec[0]) { mV[0] = min_vec[0]; ret = true; }
- if (mV[1] < min_vec[1]) { mV[1] = min_vec[1]; ret = true; }
- if (mV[2] < min_vec[2]) { mV[2] = min_vec[2]; ret = true; }
+ if (mV[VX] < min_vec[0]) { mV[VX] = min_vec[0]; ret = true; }
+ if (mV[VY] < min_vec[1]) { mV[VY] = min_vec[1]; ret = true; }
+ if (mV[VZ] < min_vec[2]) { mV[VZ] = min_vec[2]; ret = true; }
- if (mV[0] > max_vec[0]) { mV[0] = max_vec[0]; ret = true; }
- if (mV[1] > max_vec[1]) { mV[1] = max_vec[1]; ret = true; }
- if (mV[2] > max_vec[2]) { mV[2] = max_vec[2]; ret = true; }
+ if (mV[VX] > max_vec[0]) { mV[VX] = max_vec[0]; ret = true; }
+ if (mV[VY] > max_vec[1]) { mV[VY] = max_vec[1]; ret = true; }
+ if (mV[VZ] > max_vec[2]) { mV[VZ] = max_vec[2]; ret = true; }
return ret;
}
@@ -156,9 +156,9 @@ bool LLVector3::abs()
{
bool ret{ false };
- if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = true; }
- if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = true; }
- if (mV[2] < 0.f) { mV[2] = -mV[2]; ret = true; }
+ if (mV[VX] < 0.f) { mV[VX] = -mV[VX]; ret = true; }
+ if (mV[VY] < 0.f) { mV[VY] = -mV[VY]; ret = true; }
+ if (mV[VZ] < 0.f) { mV[VZ] = -mV[VZ]; ret = true; }
return ret;
}
@@ -194,13 +194,13 @@ void LLVector3::snap(S32 sig_digits)
mV[VZ] = snap_to_sig_figs(mV[VZ], sig_digits);
}
-const LLVector3& LLVector3::rotVec(const LLMatrix3 &mat)
+const LLVector3& LLVector3::rotVec(const LLMatrix3& mat)
{
*this = *this * mat;
return *this;
}
-const LLVector3& LLVector3::rotVec(const LLQuaternion &q)
+const LLVector3& LLVector3::rotVec(const LLQuaternion& q)
{
*this = *this * q;
return *this;
@@ -228,7 +228,7 @@ const LLVector3& LLVector3::transVec(const LLMatrix4& mat)
}
-const LLVector3& LLVector3::rotVec(F32 angle, const LLVector3 &vec)
+const LLVector3& LLVector3::rotVec(F32 angle, const LLVector3& vec)
{
if ( !vec.isExactlyZero() && angle )
{
@@ -263,35 +263,35 @@ LLVector3 LLVector3::scaledVec(const LLVector3& vec) const
return ret;
}
-const LLVector3& LLVector3::set(const LLVector3d &vec)
+const LLVector3& LLVector3::set(const LLVector3d& vec)
{
- mV[0] = (F32)vec.mdV[0];
- mV[1] = (F32)vec.mdV[1];
- mV[2] = (F32)vec.mdV[2];
+ mV[VX] = (F32)vec.mdV[VX];
+ mV[VY] = (F32)vec.mdV[VY];
+ mV[VZ] = (F32)vec.mdV[VZ];
return (*this);
}
-const LLVector3& LLVector3::set(const LLVector4 &vec)
+const LLVector3& LLVector3::set(const LLVector4& vec)
{
- mV[0] = vec.mV[0];
- mV[1] = vec.mV[1];
- mV[2] = vec.mV[2];
+ mV[VX] = vec.mV[VX];
+ mV[VY] = vec.mV[VY];
+ mV[VZ] = vec.mV[VZ];
return (*this);
}
-const LLVector3& LLVector3::setVec(const LLVector3d &vec)
+const LLVector3& LLVector3::setVec(const LLVector3d& vec)
{
- mV[0] = (F32)vec.mdV[0];
- mV[1] = (F32)vec.mdV[1];
- mV[2] = (F32)vec.mdV[2];
+ mV[VX] = (F32)vec.mdV[0];
+ mV[VY] = (F32)vec.mdV[1];
+ mV[VZ] = (F32)vec.mdV[2];
return (*this);
}
-const LLVector3& LLVector3::setVec(const LLVector4 &vec)
+const LLVector3& LLVector3::setVec(const LLVector4& vec)
{
- mV[0] = vec.mV[0];
- mV[1] = vec.mV[1];
- mV[2] = vec.mV[2];
+ mV[VX] = vec.mV[VX];
+ mV[VY] = vec.mV[VY];
+ mV[VZ] = vec.mV[VZ];
return (*this);
}
@@ -302,14 +302,14 @@ LLVector3::LLVector3(const LLVector2 &vec)
mV[VZ] = 0;
}
-LLVector3::LLVector3(const LLVector3d &vec)
+LLVector3::LLVector3(const LLVector3d& vec)
{
mV[VX] = (F32)vec.mdV[VX];
mV[VY] = (F32)vec.mdV[VY];
mV[VZ] = (F32)vec.mdV[VZ];
}
-LLVector3::LLVector3(const LLVector4 &vec)
+LLVector3::LLVector3(const LLVector4& vec)
{
mV[VX] = (F32)vec.mV[VX];
mV[VY] = (F32)vec.mV[VY];
@@ -330,20 +330,20 @@ LLVector3::LLVector3(const LLSD& sd)
LLSD LLVector3::getValue() const
{
LLSD ret;
- ret[0] = mV[0];
- ret[1] = mV[1];
- ret[2] = mV[2];
+ ret[0] = mV[VX];
+ ret[1] = mV[VY];
+ ret[2] = mV[VZ];
return ret;
}
void LLVector3::setValue(const LLSD& sd)
{
- mV[0] = (F32) sd[0].asReal();
- mV[1] = (F32) sd[1].asReal();
- mV[2] = (F32) sd[2].asReal();
+ mV[VX] = (F32) sd[0].asReal();
+ mV[VY] = (F32) sd[1].asReal();
+ mV[VZ] = (F32) sd[2].asReal();
}
-const LLVector3& operator*=(LLVector3 &a, const LLQuaternion &rot)
+const LLVector3& operator*=(LLVector3& a, const LLQuaternion& rot)
{
const F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
const F32 rx = rot.mQ[VW] * a.mV[VX] + rot.mQ[VY] * a.mV[VZ] - rot.mQ[VZ] * a.mV[VY];
diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h
index 4fc7585a46..53491533c2 100644
--- a/indra/llmath/v3math.h
+++ b/indra/llmath/v3math.h
@@ -41,7 +41,7 @@ class LLQuaternion;
// LLvector3 = |x y z w|
-static const U32 LENGTHOFVECTOR3 = 3;
+static constexpr U32 LENGTHOFVECTOR3 = 3;
class LLVector3
{
@@ -169,11 +169,11 @@ LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u); // Returns a vect
LLVector3 point_to_box_offset(LLVector3& pos, const LLVector3* box); // Displacement from query point to nearest point on bounding box.
bool box_valid_and_non_zero(const LLVector3* box);
-inline LLVector3::LLVector3(void)
+inline LLVector3::LLVector3()
{
- mV[0] = 0.f;
- mV[1] = 0.f;
- mV[2] = 0.f;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
+ mV[VZ] = 0.f;
}
inline LLVector3::LLVector3(const F32 x, const F32 y, const F32 z)
@@ -210,32 +210,32 @@ inline bool LLVector3::isFinite() const
// Clear and Assignment Functions
-inline void LLVector3::clear(void)
+inline void LLVector3::clear()
{
- mV[0] = 0.f;
- mV[1] = 0.f;
- mV[2] = 0.f;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
+ mV[VZ] = 0.f;
}
-inline void LLVector3::setZero(void)
+inline void LLVector3::setZero()
{
- mV[0] = 0.f;
- mV[1] = 0.f;
- mV[2] = 0.f;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
+ mV[VZ] = 0.f;
}
-inline void LLVector3::clearVec(void)
+inline void LLVector3::clearVec()
{
- mV[0] = 0.f;
- mV[1] = 0.f;
- mV[2] = 0.f;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
+ mV[VZ] = 0.f;
}
-inline void LLVector3::zeroVec(void)
+inline void LLVector3::zeroVec()
{
- mV[0] = 0.f;
- mV[1] = 0.f;
- mV[2] = 0.f;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
+ mV[VZ] = 0.f;
}
inline void LLVector3::set(F32 x, F32 y, F32 z)
@@ -245,18 +245,18 @@ inline void LLVector3::set(F32 x, F32 y, F32 z)
mV[VZ] = z;
}
-inline void LLVector3::set(const LLVector3 &vec)
+inline void LLVector3::set(const LLVector3& vec)
{
- mV[0] = vec.mV[0];
- mV[1] = vec.mV[1];
- mV[2] = vec.mV[2];
+ mV[VX] = vec.mV[VX];
+ mV[VY] = vec.mV[VY];
+ mV[VZ] = vec.mV[VZ];
}
-inline void LLVector3::set(const F32 *vec)
+inline void LLVector3::set(const F32* vec)
{
- mV[0] = vec[0];
- mV[1] = vec[1];
- mV[2] = vec[2];
+ mV[VX] = vec[0];
+ mV[VY] = vec[1];
+ mV[VZ] = vec[2];
}
// deprecated
@@ -268,61 +268,61 @@ inline void LLVector3::setVec(F32 x, F32 y, F32 z)
}
// deprecated
-inline void LLVector3::setVec(const LLVector3 &vec)
+inline void LLVector3::setVec(const LLVector3& vec)
{
- mV[0] = vec.mV[0];
- mV[1] = vec.mV[1];
- mV[2] = vec.mV[2];
+ mV[VX] = vec.mV[VX];
+ mV[VY] = vec.mV[VY];
+ mV[VZ] = vec.mV[VZ];
}
// deprecated
-inline void LLVector3::setVec(const F32 *vec)
+inline void LLVector3::setVec(const F32* vec)
{
- mV[0] = vec[0];
- mV[1] = vec[1];
- mV[2] = vec[2];
+ mV[VX] = vec[0];
+ mV[VY] = vec[1];
+ mV[VZ] = vec[2];
}
-inline F32 LLVector3::normalize(void)
+inline F32 LLVector3::normalize()
{
- F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+ F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
F32 oomag;
if (mag > FP_MAG_THRESHOLD)
{
oomag = 1.f/mag;
- mV[0] *= oomag;
- mV[1] *= oomag;
- mV[2] *= oomag;
+ mV[VX] *= oomag;
+ mV[VY] *= oomag;
+ mV[VZ] *= oomag;
}
else
{
- mV[0] = 0.f;
- mV[1] = 0.f;
- mV[2] = 0.f;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
+ mV[VZ] = 0.f;
mag = 0;
}
return (mag);
}
// deprecated
-inline F32 LLVector3::normVec(void)
+inline F32 LLVector3::normVec()
{
- F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+ F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
F32 oomag;
if (mag > FP_MAG_THRESHOLD)
{
oomag = 1.f/mag;
- mV[0] *= oomag;
- mV[1] *= oomag;
- mV[2] *= oomag;
+ mV[VX] *= oomag;
+ mV[VY] *= oomag;
+ mV[VZ] *= oomag;
}
else
{
- mV[0] = 0.f;
- mV[1] = 0.f;
- mV[2] = 0.f;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
+ mV[VZ] = 0.f;
mag = 0;
}
return (mag);
@@ -330,178 +330,178 @@ inline F32 LLVector3::normVec(void)
// LLVector3 Magnitude and Normalization Functions
-inline F32 LLVector3::length(void) const
+inline F32 LLVector3::length() const
{
- return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+ return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
}
-inline F32 LLVector3::lengthSquared(void) const
+inline F32 LLVector3::lengthSquared() const
{
- return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2];
+ return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ];
}
-inline F32 LLVector3::magVec(void) const
+inline F32 LLVector3::magVec() const
{
- return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
+ return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
}
-inline F32 LLVector3::magVecSquared(void) const
+inline F32 LLVector3::magVecSquared() const
{
- return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2];
+ return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ];
}
inline bool LLVector3::inRange( F32 min, F32 max ) const
{
- return mV[0] >= min && mV[0] <= max &&
- mV[1] >= min && mV[1] <= max &&
- mV[2] >= min && mV[2] <= max;
+ return mV[VX] >= min && mV[VX] <= max &&
+ mV[VY] >= min && mV[VY] <= max &&
+ mV[VZ] >= min && mV[VZ] <= max;
}
-inline LLVector3 operator+(const LLVector3 &a, const LLVector3 &b)
+inline LLVector3 operator+(const LLVector3& a, const LLVector3& b)
{
LLVector3 c(a);
return c += b;
}
-inline LLVector3 operator-(const LLVector3 &a, const LLVector3 &b)
+inline LLVector3 operator-(const LLVector3& a, const LLVector3& b)
{
LLVector3 c(a);
return c -= b;
}
-inline F32 operator*(const LLVector3 &a, const LLVector3 &b)
+inline F32 operator*(const LLVector3& a, const LLVector3& b)
{
- return (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1] + a.mV[2]*b.mV[2]);
+ return (a.mV[VX]*b.mV[VX] + a.mV[VY]*b.mV[VY] + a.mV[VZ]*b.mV[VZ]);
}
-inline LLVector3 operator%(const LLVector3 &a, const LLVector3 &b)
+inline LLVector3 operator%(const LLVector3& a, const LLVector3& b)
{
- return LLVector3( a.mV[1]*b.mV[2] - b.mV[1]*a.mV[2], a.mV[2]*b.mV[0] - b.mV[2]*a.mV[0], a.mV[0]*b.mV[1] - b.mV[0]*a.mV[1] );
+ return LLVector3( a.mV[VY]*b.mV[VZ] - b.mV[VY]*a.mV[VZ], a.mV[VZ]*b.mV[VX] - b.mV[VZ]*a.mV[VX], a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY] );
}
-inline LLVector3 operator/(const LLVector3 &a, F32 k)
+inline LLVector3 operator/(const LLVector3& a, F32 k)
{
F32 t = 1.f / k;
- return LLVector3( a.mV[0] * t, a.mV[1] * t, a.mV[2] * t );
+ return LLVector3( a.mV[VX] * t, a.mV[VY] * t, a.mV[VZ] * t );
}
-inline LLVector3 operator*(const LLVector3 &a, F32 k)
+inline LLVector3 operator*(const LLVector3& a, F32 k)
{
- return LLVector3( a.mV[0] * k, a.mV[1] * k, a.mV[2] * k );
+ return LLVector3( a.mV[VX] * k, a.mV[VY] * k, a.mV[VZ] * k );
}
-inline LLVector3 operator*(F32 k, const LLVector3 &a)
+inline LLVector3 operator*(F32 k, const LLVector3& a)
{
- return LLVector3( a.mV[0] * k, a.mV[1] * k, a.mV[2] * k );
+ return LLVector3( a.mV[VX] * k, a.mV[VY] * k, a.mV[VZ] * k );
}
-inline bool operator==(const LLVector3 &a, const LLVector3 &b)
+inline bool operator==(const LLVector3& a, const LLVector3& b)
{
- return ( (a.mV[0] == b.mV[0])
- &&(a.mV[1] == b.mV[1])
- &&(a.mV[2] == b.mV[2]));
+ return ( (a.mV[VX] == b.mV[VX])
+ &&(a.mV[VY] == b.mV[VY])
+ &&(a.mV[VZ] == b.mV[VZ]));
}
-inline bool operator!=(const LLVector3 &a, const LLVector3 &b)
+inline bool operator!=(const LLVector3& a, const LLVector3& b)
{
- return ( (a.mV[0] != b.mV[0])
- ||(a.mV[1] != b.mV[1])
- ||(a.mV[2] != b.mV[2]));
+ return ( (a.mV[VX] != b.mV[VX])
+ ||(a.mV[VY] != b.mV[VY])
+ ||(a.mV[VZ] != b.mV[VZ]));
}
-inline bool operator<(const LLVector3 &a, const LLVector3 &b)
+inline bool operator<(const LLVector3& a, const LLVector3& b)
{
- return (a.mV[0] < b.mV[0]
- || (a.mV[0] == b.mV[0]
- && (a.mV[1] < b.mV[1]
- || ((a.mV[1] == b.mV[1])
- && a.mV[2] < b.mV[2]))));
+ return (a.mV[VX] < b.mV[VX]
+ || (a.mV[VX] == b.mV[VX]
+ && (a.mV[VY] < b.mV[VY]
+ || ((a.mV[VY] == b.mV[VY])
+ && a.mV[VZ] < b.mV[VZ]))));
}
-inline const LLVector3& operator+=(LLVector3 &a, const LLVector3 &b)
+inline const LLVector3& operator+=(LLVector3& a, const LLVector3& b)
{
- a.mV[0] += b.mV[0];
- a.mV[1] += b.mV[1];
- a.mV[2] += b.mV[2];
+ a.mV[VX] += b.mV[VX];
+ a.mV[VY] += b.mV[VY];
+ a.mV[VZ] += b.mV[VZ];
return a;
}
-inline const LLVector3& operator-=(LLVector3 &a, const LLVector3 &b)
+inline const LLVector3& operator-=(LLVector3& a, const LLVector3& b)
{
- a.mV[0] -= b.mV[0];
- a.mV[1] -= b.mV[1];
- a.mV[2] -= b.mV[2];
+ a.mV[VX] -= b.mV[VX];
+ a.mV[VY] -= b.mV[VY];
+ a.mV[VZ] -= b.mV[VZ];
return a;
}
-inline const LLVector3& operator%=(LLVector3 &a, const LLVector3 &b)
+inline const LLVector3& operator%=(LLVector3& a, const LLVector3& b)
{
- LLVector3 ret( a.mV[1]*b.mV[2] - b.mV[1]*a.mV[2], a.mV[2]*b.mV[0] - b.mV[2]*a.mV[0], a.mV[0]*b.mV[1] - b.mV[0]*a.mV[1]);
+ LLVector3 ret( a.mV[VY]*b.mV[VZ] - b.mV[VY]*a.mV[VZ], a.mV[VZ]*b.mV[VX] - b.mV[VZ]*a.mV[VX], a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY]);
a = ret;
return a;
}
-inline const LLVector3& operator*=(LLVector3 &a, F32 k)
+inline const LLVector3& operator*=(LLVector3& a, F32 k)
{
- a.mV[0] *= k;
- a.mV[1] *= k;
- a.mV[2] *= k;
+ a.mV[VX] *= k;
+ a.mV[VY] *= k;
+ a.mV[VZ] *= k;
return a;
}
-inline const LLVector3& operator*=(LLVector3 &a, const LLVector3 &b)
+inline const LLVector3& operator*=(LLVector3& a, const LLVector3& b)
{
- a.mV[0] *= b.mV[0];
- a.mV[1] *= b.mV[1];
- a.mV[2] *= b.mV[2];
+ a.mV[VX] *= b.mV[VX];
+ a.mV[VY] *= b.mV[VY];
+ a.mV[VZ] *= b.mV[VZ];
return a;
}
-inline const LLVector3& operator/=(LLVector3 &a, F32 k)
+inline const LLVector3& operator/=(LLVector3& a, F32 k)
{
- a.mV[0] /= k;
- a.mV[1] /= k;
- a.mV[2] /= k;
+ a.mV[VX] /= k;
+ a.mV[VY] /= k;
+ a.mV[VZ] /= k;
return a;
}
inline const LLVector3& operator/=(LLVector3& a, const LLVector3& b)
{
- a.mV[0] /= b.mV[0];
- a.mV[1] /= b.mV[1];
- a.mV[2] /= b.mV[2];
+ a.mV[VX] /= b.mV[VX];
+ a.mV[VY] /= b.mV[VY];
+ a.mV[VZ] /= b.mV[VZ];
return a;
}
-inline LLVector3 operator-(const LLVector3 &a)
+inline LLVector3 operator-(const LLVector3& a)
{
- return LLVector3( -a.mV[0], -a.mV[1], -a.mV[2] );
+ return LLVector3( -a.mV[VX], -a.mV[VY], -a.mV[VZ] );
}
-inline F32 dist_vec(const LLVector3 &a, const LLVector3 &b)
+inline F32 dist_vec(const LLVector3& a, const LLVector3& b)
{
- F32 x = a.mV[0] - b.mV[0];
- F32 y = a.mV[1] - b.mV[1];
- F32 z = a.mV[2] - b.mV[2];
- return (F32) sqrt( x*x + y*y + z*z );
+ F32 x = a.mV[VX] - b.mV[VX];
+ F32 y = a.mV[VY] - b.mV[VY];
+ F32 z = a.mV[VZ] - b.mV[VZ];
+ return sqrt( x*x + y*y + z*z );
}
-inline F32 dist_vec_squared(const LLVector3 &a, const LLVector3 &b)
+inline F32 dist_vec_squared(const LLVector3& a, const LLVector3& b)
{
- F32 x = a.mV[0] - b.mV[0];
- F32 y = a.mV[1] - b.mV[1];
- F32 z = a.mV[2] - b.mV[2];
+ F32 x = a.mV[VX] - b.mV[VX];
+ F32 y = a.mV[VY] - b.mV[VY];
+ F32 z = a.mV[VZ] - b.mV[VZ];
return x*x + y*y + z*z;
}
-inline F32 dist_vec_squared2D(const LLVector3 &a, const LLVector3 &b)
+inline F32 dist_vec_squared2D(const LLVector3& a, const LLVector3& b)
{
- F32 x = a.mV[0] - b.mV[0];
- F32 y = a.mV[1] - b.mV[1];
+ F32 x = a.mV[VX] - b.mV[VX];
+ F32 y = a.mV[VY] - b.mV[VY];
return x*x + y*y;
}
-inline LLVector3 projected_vec(const LLVector3 &a, const LLVector3 &b)
+inline LLVector3 projected_vec(const LLVector3& a, const LLVector3& b)
{
F32 bb = b * b;
if (bb > FP_MAG_THRESHOLD * FP_MAG_THRESHOLD)
@@ -526,18 +526,18 @@ inline LLVector3 inverse_projected_vec(const LLVector3& a, const LLVector3& b)
return normalized_a * (b_length / dot_product);
}
-inline LLVector3 parallel_component(const LLVector3 &a, const LLVector3 &b)
+inline LLVector3 parallel_component(const LLVector3& a, const LLVector3& b)
{
return projected_vec(a, b);
}
-inline LLVector3 orthogonal_component(const LLVector3 &a, const LLVector3 &b)
+inline LLVector3 orthogonal_component(const LLVector3& a, const LLVector3& b)
{
return a - projected_vec(a, b);
}
-inline LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u)
+inline LLVector3 lerp(const LLVector3& a, const LLVector3& b, F32 u)
{
return LLVector3(
a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u,
@@ -596,7 +596,7 @@ inline F32 angle_between(const LLVector3& a, const LLVector3& b)
return atan2f(sqrtf(c * c), ab); // return the angle
}
-inline bool are_parallel(const LLVector3 &a, const LLVector3 &b, F32 epsilon)
+inline bool are_parallel(const LLVector3& a, const LLVector3& b, F32 epsilon)
{
LLVector3 an = a;
LLVector3 bn = b;
diff --git a/indra/llmath/v4math.cpp b/indra/llmath/v4math.cpp
index 0aa6eb09c3..e87bfc0013 100644
--- a/indra/llmath/v4math.cpp
+++ b/indra/llmath/v4math.cpp
@@ -36,13 +36,13 @@
// LLVector4
// Axis-Angle rotations
-const LLVector4& LLVector4::rotVec(const LLMatrix4 &mat)
+const LLVector4& LLVector4::rotVec(const LLMatrix4& mat)
{
*this = *this * mat;
return *this;
}
-const LLVector4& LLVector4::rotVec(const LLQuaternion &q)
+const LLVector4& LLVector4::rotVec(const LLQuaternion& q)
{
*this = *this * q;
return *this;
@@ -64,16 +64,16 @@ bool LLVector4::abs()
{
bool ret{ false };
- if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = true; }
- if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = true; }
- if (mV[2] < 0.f) { mV[2] = -mV[2]; ret = true; }
- if (mV[3] < 0.f) { mV[3] = -mV[3]; ret = true; }
+ if (mV[VX] < 0.f) { mV[VX] = -mV[VX]; ret = true; }
+ if (mV[VY] < 0.f) { mV[VY] = -mV[VY]; ret = true; }
+ if (mV[VZ] < 0.f) { mV[VZ] = -mV[VZ]; ret = true; }
+ if (mV[VW] < 0.f) { mV[VW] = -mV[VW]; ret = true; }
return ret;
}
-std::ostream& operator<<(std::ostream& s, const LLVector4 &a)
+std::ostream& operator<<(std::ostream& s, const LLVector4& a)
{
s << "{ " << a.mV[VX] << ", " << a.mV[VY] << ", " << a.mV[VZ] << ", " << a.mV[VW] << " }";
return s;
@@ -108,12 +108,12 @@ bool are_parallel(const LLVector4 &a, const LLVector4 &b, F32 epsilon)
}
-LLVector3 vec4to3(const LLVector4 &vec)
+LLVector3 vec4to3(const LLVector4& vec)
{
return LLVector3( vec.mV[VX], vec.mV[VY], vec.mV[VZ] );
}
-LLVector4 vec3to4(const LLVector3 &vec)
+LLVector4 vec3to4(const LLVector3& vec)
{
return LLVector4(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
}
diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h
index a5b6f506d7..e2092d1277 100644
--- a/indra/llmath/v4math.h
+++ b/indra/llmath/v4math.h
@@ -38,7 +38,7 @@ class LLQuaternion;
// LLVector4 = |x y z w|
-static const U32 LENGTHOFVECTOR4 = 4;
+static constexpr U32 LENGTHOFVECTOR4 = 4;
class LLVector4
{
@@ -58,19 +58,19 @@ class LLVector4
LLSD getValue() const
{
LLSD ret;
- ret[0] = mV[0];
- ret[1] = mV[1];
- ret[2] = mV[2];
- ret[3] = mV[3];
+ ret[0] = mV[VX];
+ ret[1] = mV[VY];
+ ret[2] = mV[VZ];
+ ret[3] = mV[VW];
return ret;
}
void setValue(const LLSD& sd)
{
- mV[0] = (F32)sd[0].asReal();
- mV[1] = (F32)sd[1].asReal();
- mV[2] = (F32)sd[2].asReal();
- mV[3] = (F32)sd[3].asReal();
+ mV[VX] = (F32)sd[0].asReal();
+ mV[VY] = (F32)sd[1].asReal();
+ mV[VZ] = (F32)sd[2].asReal();
+ mV[VW] = (F32)sd[3].asReal();
}
@@ -231,7 +231,7 @@ inline bool LLVector4::isFinite() const
// Clear and Assignment Functions
-inline void LLVector4::clear(void)
+inline void LLVector4::clear()
{
mV[VX] = 0.f;
mV[VY] = 0.f;
@@ -240,7 +240,7 @@ inline void LLVector4::clear(void)
}
// deprecated
-inline void LLVector4::clearVec(void)
+inline void LLVector4::clearVec()
{
mV[VX] = 0.f;
mV[VY] = 0.f;
@@ -249,7 +249,7 @@ inline void LLVector4::clearVec(void)
}
// deprecated
-inline void LLVector4::zeroVec(void)
+inline void LLVector4::zeroVec()
{
mV[VX] = 0.f;
mV[VY] = 0.f;
@@ -273,7 +273,7 @@ inline void LLVector4::set(F32 x, F32 y, F32 z, F32 w)
mV[VW] = w;
}
-inline void LLVector4::set(const LLVector4 &vec)
+inline void LLVector4::set(const LLVector4& vec)
{
mV[VX] = vec.mV[VX];
mV[VY] = vec.mV[VY];
@@ -281,7 +281,7 @@ inline void LLVector4::set(const LLVector4 &vec)
mV[VW] = vec.mV[VW];
}
-inline void LLVector4::set(const LLVector3 &vec, F32 w)
+inline void LLVector4::set(const LLVector3& vec, F32 w)
{
mV[VX] = vec.mV[VX];
mV[VY] = vec.mV[VY];
@@ -289,7 +289,7 @@ inline void LLVector4::set(const LLVector3 &vec, F32 w)
mV[VW] = w;
}
-inline void LLVector4::set(const F32 *vec)
+inline void LLVector4::set(const F32* vec)
{
mV[VX] = vec[VX];
mV[VY] = vec[VY];
@@ -317,7 +317,7 @@ inline void LLVector4::setVec(F32 x, F32 y, F32 z, F32 w)
}
// deprecated
-inline void LLVector4::setVec(const LLVector4 &vec)
+inline void LLVector4::setVec(const LLVector4& vec)
{
mV[VX] = vec.mV[VX];
mV[VY] = vec.mV[VY];
@@ -326,7 +326,7 @@ inline void LLVector4::setVec(const LLVector4 &vec)
}
// deprecated
-inline void LLVector4::setVec(const LLVector3 &vec, F32 w)
+inline void LLVector4::setVec(const LLVector3& vec, F32 w)
{
mV[VX] = vec.mV[VX];
mV[VY] = vec.mV[VY];
@@ -335,7 +335,7 @@ inline void LLVector4::setVec(const LLVector3 &vec, F32 w)
}
// deprecated
-inline void LLVector4::setVec(const F32 *vec)
+inline void LLVector4::setVec(const F32* vec)
{
mV[VX] = vec[VX];
mV[VY] = vec[VY];
@@ -345,75 +345,75 @@ inline void LLVector4::setVec(const F32 *vec)
// LLVector4 Magnitude and Normalization Functions
-inline F32 LLVector4::length(void) const
+inline F32 LLVector4::length() const
{
- return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+ return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
}
-inline F32 LLVector4::lengthSquared(void) const
+inline F32 LLVector4::lengthSquared() const
{
return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ];
}
-inline F32 LLVector4::magVec(void) const
+inline F32 LLVector4::magVec() const
{
- return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+ return sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
}
-inline F32 LLVector4::magVecSquared(void) const
+inline F32 LLVector4::magVecSquared() const
{
return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ];
}
// LLVector4 Operators
-inline LLVector4 operator+(const LLVector4 &a, const LLVector4 &b)
+inline LLVector4 operator+(const LLVector4& a, const LLVector4& b)
{
LLVector4 c(a);
return c += b;
}
-inline LLVector4 operator-(const LLVector4 &a, const LLVector4 &b)
+inline LLVector4 operator-(const LLVector4& a, const LLVector4& b)
{
LLVector4 c(a);
return c -= b;
}
-inline F32 operator*(const LLVector4 &a, const LLVector4 &b)
+inline F32 operator*(const LLVector4& a, const LLVector4& b)
{
return (a.mV[VX]*b.mV[VX] + a.mV[VY]*b.mV[VY] + a.mV[VZ]*b.mV[VZ]);
}
-inline LLVector4 operator%(const LLVector4 &a, const LLVector4 &b)
+inline LLVector4 operator%(const LLVector4& a, const LLVector4& b)
{
return LLVector4(a.mV[VY]*b.mV[VZ] - b.mV[VY]*a.mV[VZ], a.mV[VZ]*b.mV[VX] - b.mV[VZ]*a.mV[VX], a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY]);
}
-inline LLVector4 operator/(const LLVector4 &a, F32 k)
+inline LLVector4 operator/(const LLVector4& a, F32 k)
{
F32 t = 1.f / k;
return LLVector4( a.mV[VX] * t, a.mV[VY] * t, a.mV[VZ] * t );
}
-inline LLVector4 operator*(const LLVector4 &a, F32 k)
+inline LLVector4 operator*(const LLVector4& a, F32 k)
{
return LLVector4( a.mV[VX] * k, a.mV[VY] * k, a.mV[VZ] * k );
}
-inline LLVector4 operator*(F32 k, const LLVector4 &a)
+inline LLVector4 operator*(F32 k, const LLVector4& a)
{
return LLVector4( a.mV[VX] * k, a.mV[VY] * k, a.mV[VZ] * k );
}
-inline bool operator==(const LLVector4 &a, const LLVector4 &b)
+inline bool operator==(const LLVector4& a, const LLVector4& b)
{
return ( (a.mV[VX] == b.mV[VX])
&&(a.mV[VY] == b.mV[VY])
&&(a.mV[VZ] == b.mV[VZ]));
}
-inline bool operator!=(const LLVector4 &a, const LLVector4 &b)
+inline bool operator!=(const LLVector4& a, const LLVector4& b)
{
return ( (a.mV[VX] != b.mV[VX])
||(a.mV[VY] != b.mV[VY])
@@ -421,7 +421,7 @@ inline bool operator!=(const LLVector4 &a, const LLVector4 &b)
||(a.mV[VW] != b.mV[VW]) );
}
-inline const LLVector4& operator+=(LLVector4 &a, const LLVector4 &b)
+inline const LLVector4& operator+=(LLVector4& a, const LLVector4& b)
{
a.mV[VX] += b.mV[VX];
a.mV[VY] += b.mV[VY];
@@ -429,7 +429,7 @@ inline const LLVector4& operator+=(LLVector4 &a, const LLVector4 &b)
return a;
}
-inline const LLVector4& operator-=(LLVector4 &a, const LLVector4 &b)
+inline const LLVector4& operator-=(LLVector4& a, const LLVector4& b)
{
a.mV[VX] -= b.mV[VX];
a.mV[VY] -= b.mV[VY];
@@ -437,14 +437,14 @@ inline const LLVector4& operator-=(LLVector4 &a, const LLVector4 &b)
return a;
}
-inline const LLVector4& operator%=(LLVector4 &a, const LLVector4 &b)
+inline const LLVector4& operator%=(LLVector4& a, const LLVector4& b)
{
LLVector4 ret(a.mV[VY]*b.mV[VZ] - b.mV[VY]*a.mV[VZ], a.mV[VZ]*b.mV[VX] - b.mV[VZ]*a.mV[VX], a.mV[VX]*b.mV[VY] - b.mV[VX]*a.mV[VY]);
a = ret;
return a;
}
-inline const LLVector4& operator*=(LLVector4 &a, F32 k)
+inline const LLVector4& operator*=(LLVector4& a, F32 k)
{
a.mV[VX] *= k;
a.mV[VY] *= k;
@@ -452,7 +452,7 @@ inline const LLVector4& operator*=(LLVector4 &a, F32 k)
return a;
}
-inline const LLVector4& operator/=(LLVector4 &a, F32 k)
+inline const LLVector4& operator/=(LLVector4& a, F32 k)
{
F32 t = 1.f / k;
a.mV[VX] *= t;
@@ -461,24 +461,24 @@ inline const LLVector4& operator/=(LLVector4 &a, F32 k)
return a;
}
-inline LLVector4 operator-(const LLVector4 &a)
+inline LLVector4 operator-(const LLVector4& a)
{
return LLVector4( -a.mV[VX], -a.mV[VY], -a.mV[VZ] );
}
-inline F32 dist_vec(const LLVector4 &a, const LLVector4 &b)
+inline F32 dist_vec(const LLVector4& a, const LLVector4& b)
{
LLVector4 vec = a - b;
return (vec.length());
}
-inline F32 dist_vec_squared(const LLVector4 &a, const LLVector4 &b)
+inline F32 dist_vec_squared(const LLVector4& a, const LLVector4& b)
{
LLVector4 vec = a - b;
return (vec.lengthSquared());
}
-inline LLVector4 lerp(const LLVector4 &a, const LLVector4 &b, F32 u)
+inline LLVector4 lerp(const LLVector4& a, const LLVector4& b, F32 u)
{
return LLVector4(
a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u,
@@ -487,9 +487,9 @@ inline LLVector4 lerp(const LLVector4 &a, const LLVector4 &b, F32 u)
a.mV[VW] + (b.mV[VW] - a.mV[VW]) * u);
}
-inline F32 LLVector4::normalize(void)
+inline F32 LLVector4::normalize()
{
- F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+ F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
F32 oomag;
if (mag > FP_MAG_THRESHOLD)
@@ -501,18 +501,18 @@ inline F32 LLVector4::normalize(void)
}
else
{
- mV[0] = 0.f;
- mV[1] = 0.f;
- mV[2] = 0.f;
- mag = 0;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
+ mV[VZ] = 0.f;
+ mag = 0.f;
}
return (mag);
}
// deprecated
-inline F32 LLVector4::normVec(void)
+inline F32 LLVector4::normVec()
{
- F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
+ F32 mag = sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]);
F32 oomag;
if (mag > FP_MAG_THRESHOLD)
@@ -524,22 +524,23 @@ inline F32 LLVector4::normVec(void)
}
else
{
- mV[0] = 0.f;
- mV[1] = 0.f;
- mV[2] = 0.f;
- mag = 0;
+ mV[VX] = 0.f;
+ mV[VY] = 0.f;
+ mV[VZ] = 0.f;
+ mag = 0.f;
}
return (mag);
}
// Because apparently some parts of the viewer use this for color info.
-inline const LLVector4 srgbVector4(const LLVector4 &a) {
+inline const LLVector4 srgbVector4(const LLVector4& a)
+{
LLVector4 srgbColor;
- srgbColor.mV[0] = linearTosRGB(a.mV[0]);
- srgbColor.mV[1] = linearTosRGB(a.mV[1]);
- srgbColor.mV[2] = linearTosRGB(a.mV[2]);
- srgbColor.mV[3] = a.mV[3];
+ srgbColor.mV[VX] = linearTosRGB(a.mV[VX]);
+ srgbColor.mV[VY] = linearTosRGB(a.mV[VY]);
+ srgbColor.mV[VZ] = linearTosRGB(a.mV[VZ]);
+ srgbColor.mV[VW] = a.mV[VW];
return srgbColor;
}