diff options
159 files changed, 2753 insertions, 2761 deletions
| diff --git a/.github/workflows/qatest.yaml b/.github/workflows/qatest.yaml new file mode 100644 index 0000000000..7f3a5242e9 --- /dev/null +++ b/.github/workflows/qatest.yaml @@ -0,0 +1,168 @@ +name: Run QA Test # Runs automated tests on a self-hosted QA machine
 +
 +on:
 +  workflow_run:
 +    workflows: ["Build"]
 +    types:
 +      - completed
 +
 +concurrency:
 +  group: qa-test-run
 +  cancel-in-progress: true  # Cancels any queued job when a new one starts
 +
 +jobs:
 +  debug-workflow:
 +    runs-on: ubuntu-latest
 +    steps:
 +      - name: Debug Workflow Variables
 +        run: |
 +          echo "Workflow Conclusion: ${{ github.event.workflow_run.conclusion }}"
 +          echo "Workflow Head Branch: ${{ github.event.workflow_run.head_branch }}"
 +          echo "Workflow Run ID: ${{ github.event.workflow_run.id }}"
 +          echo "Head Commit Message: ${{ github.event.workflow_run.head_commit.message }}"
 +          echo "GitHub Ref: ${{ github.ref }}"
 +          echo "GitHub Ref Name: ${{ github.ref_name }}"
 +          echo "GitHub Event Name: ${{ github.event_name }}"
 +          echo "GitHub Workflow Name: ${{ github.workflow }}"
 +
 +  install-viewer-and-run-tests:
 +    runs-on: [self-hosted, qa-machine]
 +    # Run test only on successful builds of Second_Life_X branches
 +    if: >
 +      github.event.workflow_run.conclusion == 'success' &&
 +      (
 +        startsWith(github.event.workflow_run.head_branch, 'Second_Life')
 +      )
 +
 +    steps:
 +      - name: Temporarily Allow PowerShell Scripts (Process Scope)
 +        run: |
 +          Set-ExecutionPolicy RemoteSigned -Scope Process -Force
 +
 +      - name: Verify viewer-sikulix-main Exists
 +        run: |
 +          if (-Not (Test-Path -Path 'C:\viewer-sikulix-main')) {
 +            Write-Host '❌ Error: viewer-sikulix not found on runner!'
 +            exit 1
 +          }
 +          Write-Host '✅ viewer-sikulix is already available.'
 +
 +      - name: Fetch & Download Windows Installer Artifact
 +        shell: pwsh
 +        run: |
 +          $BUILD_ID = "${{ github.event.workflow_run.id }}"
 +          $ARTIFACTS_URL = "https://api.github.com/repos/secondlife/viewer/actions/runs/$BUILD_ID/artifacts"
 +
 +          # Fetch the correct artifact URL
 +          $response = Invoke-RestMethod -Headers @{Authorization="token ${{ secrets.GITHUB_TOKEN }}" } -Uri $ARTIFACTS_URL
 +          $ARTIFACT_NAME = ($response.artifacts | Where-Object { $_.name -eq "Windows-installer" }).archive_download_url
 +
 +          if (-Not $ARTIFACT_NAME) {
 +            Write-Host "❌ Error: Windows-installer artifact not found!"
 +            exit 1
 +          }
 +
 +          Write-Host "✅ Artifact found: $ARTIFACT_NAME"
 +
 +          # Secure download path
 +          $DownloadPath = "$env:TEMP\secondlife-build-$BUILD_ID"
 +          New-Item -ItemType Directory -Path $DownloadPath -Force | Out-Null
 +          $InstallerPath = "$DownloadPath\installer.zip"
 +
 +          # Download the ZIP
 +          Invoke-WebRequest -Uri $ARTIFACT_NAME -Headers @{Authorization="token ${{ secrets.GITHUB_TOKEN }}"} -OutFile $InstallerPath
 +
 +          # Ensure download succeeded
 +          if (-Not (Test-Path $InstallerPath)) {
 +            Write-Host "❌ Error: Failed to download Windows-installer.zip"
 +            exit 1
 +          }
 +
 +      - name: Extract Installer & Locate Executable
 +        shell: pwsh
 +        run: |
 +          # Explicitly set BUILD_ID again (since it does not appear to persist across steps)
 +          $BUILD_ID = "${{ github.event.workflow_run.id }}"
 +          $ExtractPath = "$env:TEMP\secondlife-build-$BUILD_ID"
 +          $InstallerZip = "$ExtractPath\installer.zip"
 +
 +          # Print paths for debugging
 +          Write-Host "Extract Path: $ExtractPath"
 +          Write-Host "Installer ZIP Path: $InstallerZip"
 +
 +          # Verify ZIP exists before extracting
 +          if (-Not (Test-Path $InstallerZip)) {
 +              Write-Host "❌ Error: ZIP file not found at $InstallerZip!"
 +              exit 1
 +          }
 +
 +          Write-Host "✅ ZIP file exists and is valid. Extracting..."
 +
 +          Expand-Archive -Path $InstallerZip -DestinationPath $ExtractPath -Force
 +
 +          # Find installer executable
 +          $INSTALLER_PATH = (Get-ChildItem -Path $ExtractPath -Filter '*.exe' -Recurse | Select-Object -First 1).FullName
 +
 +          if (-Not $INSTALLER_PATH -or $INSTALLER_PATH -eq "") {
 +            Write-Host "❌ Error: No installer executable found in the extracted files!"
 +            Write-Host "📂 Extracted Files:"
 +            Get-ChildItem -Path $ExtractPath -Recurse | Format-Table -AutoSize
 +            exit 1
 +          }
 +
 +          Write-Host "✅ Installer found: $INSTALLER_PATH"
 +          echo "INSTALLER_PATH=$INSTALLER_PATH" | Out-File -FilePath $env:GITHUB_ENV -Append
 +
 +      - name: Install Second Life Using Task Scheduler (Bypass UAC)
 +        shell: pwsh
 +        run: |
 +          $action = New-ScheduledTaskAction -Execute "${{ env.INSTALLER_PATH }}" -Argument "/S"
 +          $principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
 +          $task = New-ScheduledTask -Action $action -Principal $principal
 +          Register-ScheduledTask -TaskName "SilentSLInstaller" -InputObject $task -Force
 +          Start-ScheduledTask -TaskName "SilentSLInstaller"
 +
 +      - name: Wait for Installation to Complete
 +        shell: pwsh
 +        run: |
 +          Write-Host "Waiting for the Second Life installer to finish..."
 +          do {
 +            Start-Sleep -Seconds 5
 +            $installerProcess = Get-Process | Where-Object { $_.Path -eq "${{ env.INSTALLER_PATH }}" }
 +          } while ($installerProcess)
 +
 +          Write-Host "✅ Installation completed!"
 +
 +      - name: Cleanup Task Scheduler Entry
 +        shell: pwsh
 +        run: |
 +          Unregister-ScheduledTask -TaskName "SilentSLInstaller" -Confirm:$false
 +          Write-Host "✅ Task Scheduler entry removed."
 +
 +      - name: Delete Installer ZIP
 +        shell: pwsh
 +        run: |
 +          # Explicitly set BUILD_ID again
 +          $BUILD_ID = "${{ github.event.workflow_run.id }}"
 +          $DeletePath = "$env:TEMP\secondlife-build-$BUILD_ID\installer.zip"
 +
 +          Write-Host "Checking if installer ZIP exists: $DeletePath"
 +
 +          # Ensure the ZIP file exists before trying to delete it
 +          if (Test-Path $DeletePath) {
 +              Remove-Item -Path $DeletePath -Force
 +              Write-Host "✅ Successfully deleted: $DeletePath"
 +          } else {
 +              Write-Host "⚠️ Warning: ZIP file does not exist, skipping deletion."
 +          }
 +
 +      - name: Run QA Test Script
 +        run: |
 +          Write-Host "Running QA Test script..."
 +          python C:\viewer-sikulix-main\runTests.py
 +
 +      # - name: Upload Test Results
 +      #   uses: actions/upload-artifact@v3
 +      #   with:
 +      #     name: test-results
 +      #     path: C:\viewer-sikulix-main\regressionTest\test_results.html
 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6bd8a2b74c..db2225c9fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,8 @@ developer-to-developer or support.  - [Official forums][] exist for many topics including content creation,     scripting, social topics and more.   - The [opensource-dev mailing list][] is useful for announcements and -  discussion between viewer maintainers.  +  discussion between viewer maintainers. +- Our [discord channel](https://discord.com/channels/677442248157167619/1357059883400167585) is available for real-time discussion.  ## Reporting bugs and requesting features diff --git a/indra/doxygen/CMakeLists.txt b/indra/doxygen/CMakeLists.txt index 616b5cd09c..354ae7b636 100644 --- a/indra/doxygen/CMakeLists.txt +++ b/indra/doxygen/CMakeLists.txt @@ -1,11 +1,5 @@  # -*- cmake -*- -# cmake_minimum_required should appear before any -# other commands to guarantee full compatibility -# with the version specified -## prior to 2.8, the add_custom_target commands used in setting the version did not work correctly -cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR) -  set(ROOT_PROJECT_NAME "SecondLife" CACHE STRING      "The root project/makefile/solution name. Defaults to SecondLife.")  project(${ROOT_PROJECT_NAME}) diff --git a/indra/llappearance/llpolymorph.cpp b/indra/llappearance/llpolymorph.cpp index 8df8a9726f..5ee6649164 100644 --- a/indra/llappearance/llpolymorph.cpp +++ b/indra/llappearance/llpolymorph.cpp @@ -550,12 +550,12 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )      mLastSex = avatar_sex; -    // Check for NaN condition (NaN is detected if a variable doesn't equal itself. -    if (mCurWeight != mCurWeight) +    // Check for NaN condition +    if (llisnan(mCurWeight))      { -        mCurWeight = 0.0; +        mCurWeight = 0.f;      } -    if (mLastWeight != mLastWeight) +    if (llisnan(mLastWeight))      {          mLastWeight = mCurWeight+.001f;      } diff --git a/indra/llcommon/indra_constants.h b/indra/llcommon/indra_constants.h index c6bdab007f..a0394da281 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!!  constexpr U32 BEACON_SHOW_MAP  = 0x0001; diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h index 2fbb26dc1a..232987da14 100644 --- a/indra/llcommon/lldefs.h +++ b/indra/llcommon/lldefs.h @@ -171,13 +171,13 @@ constexpr U32   MAXADDRSTR      = 17;       // 123.567.901.345 = 15 chars + \0 +  // 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 (d0 > maxrest)? d0 : maxrest; @@ -185,20 +185,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 (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)  {      A aminval{ static_cast<A>(minval) }, amaxval{ static_cast<A>(maxval) };      if ( a < aminval ) @@ -213,13 +213,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/llcommon/stdtypes.h b/indra/llcommon/stdtypes.h index 28e50b3d21..f1e4c2bc78 100644 --- a/indra/llcommon/stdtypes.h +++ b/indra/llcommon/stdtypes.h @@ -164,14 +164,14 @@ private:      FROM mValue;  public: -    narrow(FROM value): mValue(value) {} +    constexpr narrow(FROM value): mValue(value) {}      /*---------------------- Narrowing unsigned to signed ----------------------*/      template <typename TO,                typename std::enable_if<std::is_unsigned<FROM>::value &&                                        std::is_signed<TO>::value,                                        bool>::type = true> -    inline +    constexpr      operator TO() const      {          // The reason we skip the @@ -189,7 +189,7 @@ public:                typename std::enable_if<! (std::is_unsigned<FROM>::value &&                                           std::is_signed<TO>::value),                                        bool>::type = true> -    inline +    constexpr      operator TO() const      {          // two different assert()s so we can tell which condition failed diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 67d713db1f..759638b956 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -262,6 +262,8 @@ public:      void setMediaURLResetTimer(F32 time);      virtual void    setLocalID(S32 local_id); +    void setRegionID(const LLUUID& id) { mRegionID = id; } +    const LLUUID& getRegionID() const { return mRegionID; }      // blow away all the extra stuff lurking in parcels, including urls, access lists, etc      void clearParcel(); @@ -651,6 +653,7 @@ public:      S32                 mLocalID;      LLUUID              mBanListTransactionID;      LLUUID              mAccessListTransactionID; +    LLUUID              mRegionID;      std::map<LLUUID,LLAccessEntry>  mAccessList;      std::map<LLUUID,LLAccessEntry>  mBanList;      std::map<LLUUID,LLAccessEntry>  mTempBanList; diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index bf7cfbe071..0d1f2b3006 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -279,103 +279,118 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod  {      LLImageDataLock lock(&base); -    S32 data_size = base.getDataSize(); -    S32 max_bytes = (base.getMaxBytes() ? base.getMaxBytes() : data_size); +    try +    { -    // -    //  Initialization -    // -    mCodeStreamp.reset(); +        S32 data_size = base.getDataSize(); +        S32 max_bytes = (base.getMaxBytes() ? base.getMaxBytes() : data_size); -    // It's not clear to nat under what circumstances we would reuse a -    // pre-existing LLKDUMemSource instance. As of 2016-08-05, it consists of -    // two U32s and a pointer, so it's not as if it would be a huge overhead -    // to allocate a new one every time. -    // Also -- why is base.getData() tested specifically here? If that returns -    // NULL, shouldn't we bail out of the whole method? -    if (!mInputp && base.getData()) -    { -        // The compressed data has been loaded -        // Setup the source for the codestream -        mInputp.reset(new LLKDUMemSource(base.getData(), data_size)); -    } +        // +        //  Initialization +        // +        mCodeStreamp.reset(); -    if (mInputp) -    { -        // This is LLKDUMemSource::reset(), not boost::scoped_ptr::reset(). -        mInputp->reset(); -    } +        // It's not clear to nat under what circumstances we would reuse a +        // pre-existing LLKDUMemSource instance. As of 2016-08-05, it consists of +        // two U32s and a pointer, so it's not as if it would be a huge overhead +        // to allocate a new one every time. +        // Also -- why is base.getData() tested specifically here? If that returns +        // NULL, shouldn't we bail out of the whole method? +        if (!mInputp && base.getData()) +        { +            // The compressed data has been loaded +            // Setup the source for the codestream +            mInputp.reset(new LLKDUMemSource(base.getData(), data_size)); +        } -    mCodeStreamp->create(mInputp.get()); - -    // Set the maximum number of bytes to use from the codestream -    // *TODO: This seems to be wrong. The base class should have no idea of -    // how j2c compression works so no good way of computing what's the byte -    // range to be used. -    mCodeStreamp->set_max_bytes(max_bytes,true); - -    //  If you want to flip or rotate the image for some reason, change -    // the resolution, or identify a restricted region of interest, this is -    // the place to do it.  You may use "kdu_codestream::change_appearance" -    // and "kdu_codestream::apply_input_restrictions" for this purpose. -    //  If you wish to truncate the code-stream prior to decompression, you -    // may use "kdu_codestream::set_max_bytes". -    //  If you wish to retain all compressed data so that the material -    // can be decompressed multiple times, possibly with different appearance -    // parameters, you should call "kdu_codestream::set_persistent" here. -    //  There are a variety of other features which must be enabled at -    // this point if you want to take advantage of them.  See the -    // descriptions appearing with the "kdu_codestream" interface functions -    // in "kdu_compressed.h" for an itemized account of these capabilities. - -    switch (mode) -    { -    case MODE_FAST: -        mCodeStreamp->set_fast(); -        break; -    case MODE_RESILIENT: -        mCodeStreamp->set_resilient(); -        break; -    case MODE_FUSSY: -        mCodeStreamp->set_fussy(); -        break; -    default: -        llassert(0); -        mCodeStreamp->set_fast(); -    } +        if (mInputp) +        { +            // This is LLKDUMemSource::reset(), not boost::scoped_ptr::reset(). +            mInputp->reset(); +        } -    kdu_dims dims; -    mCodeStreamp->get_dims(0,dims); +        mCodeStreamp->create(mInputp.get()); + +        // Set the maximum number of bytes to use from the codestream +        // *TODO: This seems to be wrong. The base class should have no idea of +        // how j2c compression works so no good way of computing what's the byte +        // range to be used. +        mCodeStreamp->set_max_bytes(max_bytes, true); + +        //  If you want to flip or rotate the image for some reason, change +        // the resolution, or identify a restricted region of interest, this is +        // the place to do it.  You may use "kdu_codestream::change_appearance" +        // and "kdu_codestream::apply_input_restrictions" for this purpose. +        //  If you wish to truncate the code-stream prior to decompression, you +        // may use "kdu_codestream::set_max_bytes". +        //  If you wish to retain all compressed data so that the material +        // can be decompressed multiple times, possibly with different appearance +        // parameters, you should call "kdu_codestream::set_persistent" here. +        //  There are a variety of other features which must be enabled at +        // this point if you want to take advantage of them.  See the +        // descriptions appearing with the "kdu_codestream" interface functions +        // in "kdu_compressed.h" for an itemized account of these capabilities. + +        switch (mode) +        { +        case MODE_FAST: +            mCodeStreamp->set_fast(); +            break; +        case MODE_RESILIENT: +            mCodeStreamp->set_resilient(); +            break; +        case MODE_FUSSY: +            mCodeStreamp->set_fussy(); +            break; +        default: +            llassert(0); +            mCodeStreamp->set_fast(); +        } + +        kdu_dims dims; +        mCodeStreamp->get_dims(0, dims); -    S32 components = mCodeStreamp->get_num_components(); +        S32 components = mCodeStreamp->get_num_components(); -    // Check that components have consistent dimensions (for PPM file) -    for (int idx = 1; idx < components; ++idx) -    { -        kdu_dims other_dims; -        mCodeStreamp->get_dims(idx, other_dims); -        if (other_dims != dims) +        // Check that components have consistent dimensions (for PPM file) +        for (int idx = 1; idx < components; ++idx)          { -            // This method is only called from methods that catch KDUError. -            // We want to fail the image load, not crash the viewer. -            LLTHROW(KDUError(STRINGIZE("Component " << idx << " dimensions " -                                       << stringize(other_dims) -                                       << " do not match component 0 dimensions " -                                       << stringize(dims) << "!"))); +            kdu_dims other_dims; +            mCodeStreamp->get_dims(idx, other_dims); +            if (other_dims != dims) +            { +                // This method is only called from methods that catch KDUError. +                // We want to fail the image load, not crash the viewer. +                LLTHROW(KDUError(STRINGIZE("Component " << idx << " dimensions " +                    << stringize(other_dims) +                    << " do not match component 0 dimensions " +                    << stringize(dims) << "!"))); +            }          } -    } -    // Get the number of resolution levels in that image -    mLevels = mCodeStreamp->get_min_dwt_levels(); +        // Get the number of resolution levels in that image +        mLevels = mCodeStreamp->get_min_dwt_levels(); -    // Set the base dimensions -    base.setSize(dims.size.x, dims.size.y, components); -    base.setLevels(mLevels); +        // Set the base dimensions +        base.setSize(dims.size.x, dims.size.y, components); +        base.setLevels(mLevels); -    if (!keep_codestream) +        if (!keep_codestream) +        { +            mCodeStreamp.reset(); +            mInputp.reset(); +        } +    } +    catch (std::bad_alloc&)      { -        mCodeStreamp.reset(); -        mInputp.reset(); +        // we are in a thread, can't show an 'out of memory' here, +        // main thread will keep going +        throw; +    } +    catch (...) +    { +        LLTHROW(KDUError(STRINGIZE("Unknown J2C error : " + +            boost::current_exception_diagnostic_information() << "!")));      }  } diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h index b6e0e4a2be..6201761c46 100644 --- a/indra/llmath/llcamera.h +++ b/indra/llmath/llcamera.h @@ -33,23 +33,23 @@  #include "llplane.h"  #include "llvector4a.h" -const F32 DEFAULT_FIELD_OF_VIEW     = 60.f * DEG_TO_RAD; -const F32 DEFAULT_ASPECT_RATIO      = 640.f / 480.f; -const F32 DEFAULT_NEAR_PLANE        = 0.25f; -const F32 DEFAULT_FAR_PLANE         = 64.f; // far reaches across two horizontal, not diagonal, regions +constexpr F32 DEFAULT_FIELD_OF_VIEW = 60.f * DEG_TO_RAD; +constexpr F32 DEFAULT_ASPECT_RATIO  = 640.f / 480.f; +constexpr F32 DEFAULT_NEAR_PLANE    = 0.25f; +constexpr F32 DEFAULT_FAR_PLANE     = 64.f; // far reaches across two horizontal, not diagonal, regions -const F32 MAX_ASPECT_RATIO  = 50.0f; -const F32 MAX_NEAR_PLANE    = 1023.9f; // Clamp the near plane just before the skybox ends -const F32 MAX_FAR_PLANE     = 100000.0f; //1000000.0f; // Max allowed. Not good Z precision though. -const F32 MAX_FAR_CLIP      = 512.0f; +constexpr F32 MAX_ASPECT_RATIO  = 50.0f; +constexpr F32 MAX_NEAR_PLANE    = 1023.9f;   // Clamp the near plane just before the skybox ends +constexpr F32 MAX_FAR_PLANE     = 100000.0f; //1000000.0f; // Max allowed. Not good Z precision though. +constexpr F32 MAX_FAR_CLIP      = 512.0f; -const F32 MIN_ASPECT_RATIO  = 0.02f; -const F32 MIN_NEAR_PLANE    = 0.1f; -const F32 MIN_FAR_PLANE     = 0.2f; +constexpr F32 MIN_ASPECT_RATIO  = 0.02f; +constexpr F32 MIN_NEAR_PLANE    = 0.1f; +constexpr F32 MIN_FAR_PLANE     = 0.2f;  // Min/Max FOV values for square views. Call getMin/MaxView to get extremes based on current aspect ratio. -static const F32 MIN_FIELD_OF_VIEW = 5.0f * DEG_TO_RAD; -static const F32 MAX_FIELD_OF_VIEW = 175.f * DEG_TO_RAD; +constexpr F32 MIN_FIELD_OF_VIEW = 5.0f * DEG_TO_RAD; +constexpr F32 MAX_FIELD_OF_VIEW = 175.f * DEG_TO_RAD;  // An LLCamera is an LLCoorFrame with a view frustum.  // This means that it has several methods for moving it around diff --git a/indra/llmath/llcoordframe.cpp b/indra/llmath/llcoordframe.cpp index 4d6276b2cd..15c9f6ff3f 100644 --- a/indra/llmath/llcoordframe.cpp +++ b/indra/llmath/llcoordframe.cpp @@ -26,7 +26,6 @@  #include "linden_common.h" -//#include "vmath.h"  #include "v3math.h"  #include "m3math.h"  #include "v4math.h" diff --git a/indra/llmath/llcoordframe.h b/indra/llmath/llcoordframe.h index aaa701f792..458f6132c9 100644 --- a/indra/llmath/llcoordframe.h +++ b/indra/llmath/llcoordframe.h @@ -61,7 +61,7 @@ public:      //LLCoordFrame(const F32 *origin, const F32 *rotation); // Assumes "origin" is 1x3 and "rotation" is 1x9 array      //LLCoordFrame(const F32 *origin_and_rotation);         // Assumes "origin_and_rotation" is 1x12 array -    bool isFinite() { return mOrigin.isFinite() && mXAxis.isFinite() && mYAxis.isFinite() && mZAxis.isFinite(); } +    bool isFinite() const { return mOrigin.isFinite() && mXAxis.isFinite() && mYAxis.isFinite() && mZAxis.isFinite(); }      void reset();      void resetAxes(); diff --git a/indra/llmath/llline.h b/indra/llmath/llline.h index 33c1eb61a4..e98e173d1f 100644 --- a/indra/llmath/llline.h +++ b/indra/llmath/llline.h @@ -33,7 +33,7 @@  #include "stdtypes.h"  #include "v3math.h" -const F32 DEFAULT_INTERSECTION_ERROR = 0.000001f; +constexpr F32 DEFAULT_INTERSECTION_ERROR = 0.000001f;  class LLLine  { diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index fa315291a3..7f51de7820 100644 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -39,18 +39,8 @@  // llcommon depend on llmath.  #include "is_approx_equal_fraction.h" -// work around for Windows & older gcc non-standard function names. -#if LL_WINDOWS -#include <float.h> -#define llisnan(val)    _isnan(val) -#define llfinite(val)   _finite(val) -#elif (LL_LINUX && __GNUC__ <= 2) -#define llisnan(val)    isnan(val) -#define llfinite(val)   isfinite(val) -#else -#define llisnan(val)    std::isnan(val) -#define llfinite(val)   std::isfinite(val) -#endif +#define llisnan(val)  std::isnan(val) +#define llfinite(val) std::isfinite(val)  // Single Precision Floating Point Routines  // (There used to be more defined here, but they appeared to be redundant and @@ -89,7 +79,7 @@ constexpr F32   GIMBAL_THRESHOLD = 0.000436f; // sets the gimballock threshold 0  constexpr F32 FP_MAG_THRESHOLD = 0.0000001f;  // TODO: Replace with logic like is_approx_equal -inline bool is_approx_zero( F32 f ) { return (-F_APPROXIMATELY_ZERO < f) && (f < F_APPROXIMATELY_ZERO); } +constexpr bool is_approx_zero(F32 f) { return (-F_APPROXIMATELY_ZERO < f) && (f < F_APPROXIMATELY_ZERO); }  // These functions work by interpreting sign+exp+mantissa as an unsigned  // integer. @@ -148,33 +138,17 @@ inline F64 llabs(const F64 a)      return F64(std::fabs(a));  } -inline S32 lltrunc( F32 f ) +constexpr S32 lltrunc(F32 f)  { -#if LL_WINDOWS && !defined( __INTEL_COMPILER ) && (ADDRESS_SIZE == 32) -        // Avoids changing the floating point control word. -        // Add or subtract 0.5 - epsilon and then round -        const static U32 zpfp[] = { 0xBEFFFFFF, 0x3EFFFFFF }; -        S32 result; -        __asm { -            fld     f -            mov     eax,    f -            shr     eax,    29 -            and     eax,    4 -            fadd    dword ptr [zpfp + eax] -            fistp   result -        } -        return result; -#else -        return (S32)f; -#endif +    return narrow(f);  } -inline S32 lltrunc( F64 f ) +constexpr S32 lltrunc(F64 f)  { -    return (S32)f; +    return narrow(f);  } -inline S32 llfloor( F32 f ) +inline S32 llfloor(F32 f)  {  #if LL_WINDOWS && !defined( __INTEL_COMPILER ) && (ADDRESS_SIZE == 32)          // Avoids changing the floating point control word. @@ -284,7 +258,7 @@ constexpr F32 FAST_MAG_BETA = 0.397824734759f;  //constexpr F32 FAST_MAG_ALPHA = 0.948059448969f;  //constexpr F32 FAST_MAG_BETA = 0.392699081699f; -inline F32 fastMagnitude(F32 a, F32 b) +constexpr F32 fastMagnitude(F32 a, F32 b)  {      a = (a > 0) ? a : -a;      b = (b > 0) ? b : -b; @@ -342,7 +316,7 @@ inline F32 llfastpow(const F32 x, const F32 y)  } -inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs) +constexpr F32 snap_to_sig_figs(F32 foo, S32 sig_figs)  {      // compute the power of ten      F32 bar = 1.f; @@ -358,12 +332,9 @@ inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)      return new_foo;  } -inline F32 lerp(F32 a, F32 b, F32 u) -{ -    return a + ((b - a) * u); -} +using std::lerp; -inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v) +constexpr F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)  {      F32 a = x00 + (x01-x00)*u;      F32 b = x10 + (x11-x10)*u; @@ -371,17 +342,17 @@ inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)      return r;  } -inline F32 ramp(F32 x, F32 a, F32 b) +constexpr F32 ramp(F32 x, F32 a, F32 b)  {      return (a == b) ? 0.0f : ((a - x) / (a - b));  } -inline F32 rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2) +constexpr F32 rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)  {      return lerp(y1, y2, ramp(x, x1, x2));  } -inline F32 clamp_rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2) +constexpr F32 clamp_rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)  {      if (y1 < y2)      { @@ -394,7 +365,7 @@ inline F32 clamp_rescale(F32 x, F32 x1, F32 x2, F32 y1, F32 y2)  } -inline F32 cubic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 ) +constexpr F32 cubic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )  {      if (x <= x0)          return s0; @@ -407,14 +378,14 @@ inline F32 cubic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )      return  s0 + (s1 - s0) * (f * f) * (3.0f - 2.0f * f);  } -inline F32 cubic_step( F32 x ) +constexpr F32 cubic_step( F32 x )  {      x = llclampf(x);      return  (x * x) * (3.0f - 2.0f * x);  } -inline F32 quadratic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 ) +constexpr F32 quadratic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )  {      if (x <= x0)          return s0; @@ -428,7 +399,7 @@ inline F32 quadratic_step( F32 x, F32 x0, F32 x1, F32 s0, F32 s1 )      return  (s0 * (1.f - f_squared)) + ((s1 - s0) * f_squared);  } -inline F32 llsimple_angle(F32 angle) +constexpr F32 llsimple_angle(F32 angle)  {      while(angle <= -F_PI)          angle += F_TWO_PI; @@ -438,7 +409,7 @@ inline F32 llsimple_angle(F32 angle)  }  //SDK - Renamed this to get_lower_power_two, since this is what this actually does. -inline U32 get_lower_power_two(U32 val, U32 max_power_two) +constexpr U32 get_lower_power_two(U32 val, U32 max_power_two)  {      if(!max_power_two)      { @@ -460,7 +431,7 @@ inline U32 get_lower_power_two(U32 val, U32 max_power_two)  // number of digits, then add one.  We subtract 1 initially to handle  // the case where the number passed in is actually a power of two.  // WARNING: this only works with 32 bit ints. -inline U32 get_next_power_two(U32 val, U32 max_power_two) +constexpr U32 get_next_power_two(U32 val, U32 max_power_two)  {      if(!max_power_two)      { @@ -486,7 +457,7 @@ inline U32 get_next_power_two(U32 val, U32 max_power_two)  //get the gaussian value given the linear distance from axis x and guassian value o  inline F32 llgaussian(F32 x, F32 o)  { -    return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o)); +    return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2.f*o*o));  }  //helper function for removing outliers @@ -539,7 +510,8 @@ inline void ll_remove_outliers(std::vector<VEC_TYPE>& data, F32 k)  // Note: in our code, values labeled as sRGB are ALWAYS gamma corrected linear values, NOT linear values with monitor gamma applied  // Note: stored color values should always be gamma corrected linear (i.e. the values returned from an on-screen color swatch)  // Note: DO NOT cache the conversion.  This leads to error prone synchronization and is actually slower in the typical case due to cache misses -inline float linearTosRGB(const float val) { +inline float linearTosRGB(const float val) +{      if (val < 0.0031308f) {          return val * 12.92f;      } @@ -554,7 +526,8 @@ inline float linearTosRGB(const float val) {  // Note: Stored color values should generally be gamma corrected sRGB.  //       If you're serializing the return value of this function, you're probably doing it wrong.  // Note: DO NOT cache the conversion.  This leads to error prone synchronization and is actually slower in the typical case due to cache misses. -inline float sRGBtoLinear(const float val) { +inline float sRGBtoLinear(const float val) +{      if (val < 0.04045f) {          return val / 12.92f;      } diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp index aefb82b2f0..1ab3a73d79 100644 --- a/indra/llmath/llquaternion.cpp +++ b/indra/llmath/llquaternion.cpp @@ -30,7 +30,6 @@  #include "llquaternion.h" -//#include "vmath.h"  #include "v3math.h"  #include "v3dmath.h"  #include "v4math.h" diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 76e5e3aae9..1e7dfd18f2 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -1294,10 +1294,11 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en      c       = cos(ang)*lerp(radius_start, radius_end, t); -    pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s) +    pt->mPos.set(0 + lerp(0.f, params.getShear().mV[VX], s)                        + lerp(-skew ,skew, t) * 0.5f, -                    c + lerp(0,params.getShear().mV[1],s), +                    c + lerp(0.f, params.getShear().mV[VY], s),                      s); +      pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),          hole_y * lerp(taper_y_begin, taper_y_end, t),          0,1); @@ -1327,9 +1328,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en          c   = cos(ang)*lerp(radius_start, radius_end, t);          s   = sin(ang)*lerp(radius_start, radius_end, t); -        pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s) +        pt->mPos.set(0 + lerp(0.f, params.getShear().mV[VX], s)                            + lerp(-skew ,skew, t) * 0.5f, -                        c + lerp(0,params.getShear().mV[1],s), +                        c + lerp(0.f, params.getShear().mV[VY], s),                          s);          pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t), @@ -1354,9 +1355,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en      c   = cos(ang)*lerp(radius_start, radius_end, t);      s   = sin(ang)*lerp(radius_start, radius_end, t); -    pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s) +    pt->mPos.set(0 + lerp(0.f, params.getShear().mV[VX], s)                        + lerp(-skew ,skew, t) * 0.5f, -                    c + lerp(0,params.getShear().mV[1],s), +                    c + lerp(0.f, params.getShear().mV[VY], s),                      s);      pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),                     hole_y * lerp(taper_y_begin, taper_y_end, t), @@ -1494,8 +1495,8 @@ bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split,              for (S32 i=0;i<np;i++)              {                  F32 t = lerp(params.getBegin(),params.getEnd(),(F32)i * mStep); -                mPath[i].mPos.set(lerp(0,params.getShear().mV[0],t), -                                     lerp(0,params.getShear().mV[1],t), +                mPath[i].mPos.set(lerp(0.f, params.getShear().mV[VX], t), +                                     lerp(0.f ,params.getShear().mV[VY], t),                                       t - 0.5f);                  LLQuaternion quat;                  quat.setQuat(lerp(F_PI * params.getTwistBegin(),F_PI * params.getTwist(),t),0,0,1); @@ -1559,10 +1560,10 @@ bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split,          {              F32 t = (F32)i * mStep;              mPath[i].mPos.set(0, -                                lerp(0,   -sin(F_PI*params.getTwist()*t)*0.5f,t), -                                lerp(-0.5f, cos(F_PI*params.getTwist()*t)*0.5f,t)); -            mPath[i].mScale.set(lerp(1,params.getScale().mV[0],t), -                                lerp(1,params.getScale().mV[1],t), 0,1); +                                lerp(0.f,  -sin(F_PI*params.getTwist() * t) * 0.5f, t), +                                lerp(-0.5f, cos(F_PI*params.getTwist() * t) * 0.5f, t)); +            mPath[i].mScale.set(lerp(1.f, params.getScale().mV[VX], t), +                                lerp(1.f, params.getScale().mV[VY], t), 0.f, 1.f);              mPath[i].mTexT  = t;              LLQuaternion quat;              quat.setQuat(F_PI * params.getTwist() * t,1,0,0); diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 27c5fc5a49..3496928f7b 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -45,7 +45,6 @@ class LLVolumeOctree;  #include "lluuid.h"  #include "v4color.h" -//#include "vmath.h"  #include "v2math.h"  #include "v3math.h"  #include "v3dmath.h" diff --git a/indra/llmath/m3math.cpp b/indra/llmath/m3math.cpp index 472d340af5..3c2097f947 100644 --- a/indra/llmath/m3math.cpp +++ b/indra/llmath/m3math.cpp @@ -26,7 +26,6 @@  #include "linden_common.h" -//#include "vmath.h"  #include "v3math.h"  #include "v3dmath.h"  #include "v4math.h" diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp index c46ee587cb..a9853fe7e9 100644 --- a/indra/llmath/m4math.cpp +++ b/indra/llmath/m4math.cpp @@ -26,7 +26,6 @@  #include "linden_common.h" -//#include "vmath.h"  #include "v3math.h"  #include "v4math.h"  #include "m4math.h" diff --git a/indra/llmath/v2math.cpp b/indra/llmath/v2math.cpp index 4649e13376..59e6d947ca 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,14 +66,14 @@ 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;      an.normVec();      bn.normVec();      F32 dot = an * bn; -    if ( (1.0f - fabs(dot)) < epsilon) +    if ((1.0f - fabs(dot)) < epsilon)      {          return true;      } @@ -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[VX] = mV[VX]; +    ret[VY] = 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..18ad02a411 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,9 +299,9 @@ 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] ) +    if (F_APPROXIMATELY_ZERO > mV[VX]*mV[VX] + mV[VY]*mV[VY])      {          return true;      } @@ -312,9 +312,9 @@ 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] ) +    if (a.mV[VX] == b.mV[VX])      {          return a.mV[VY] < b.mV[VY];      } @@ -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/v3color.cpp b/indra/llmath/v3color.cpp index 4367b993f8..08b3795020 100644 --- a/indra/llmath/v3color.cpp +++ b/indra/llmath/v3color.cpp @@ -32,74 +32,79 @@  LLColor3 LLColor3::white(1.0f, 1.0f, 1.0f);  LLColor3 LLColor3::black(0.0f, 0.0f, 0.0f); -LLColor3 LLColor3::grey (0.5f, 0.5f, 0.5f); +LLColor3 LLColor3::grey(0.5f, 0.5f, 0.5f); -LLColor3::LLColor3(const LLColor4 &a) +LLColor3::LLColor3(const LLColor4& a)  { -    mV[0] = a.mV[0]; -    mV[1] = a.mV[1]; -    mV[2] = a.mV[2]; +    mV[VRED]   = a.mV[VRED]; +    mV[VGREEN] = a.mV[VGREEN]; +    mV[VBLUE]  = a.mV[VBLUE];  } -LLColor3::LLColor3(const LLVector4 &a) +LLColor3::LLColor3(const LLVector4& a)  { -    mV[0] = a.mV[0]; -    mV[1] = a.mV[1]; -    mV[2] = a.mV[2]; +    mV[VRED]   = a.mV[VRED]; +    mV[VGREEN] = a.mV[VGREEN]; +    mV[VBLUE]  = a.mV[VBLUE];  } -LLColor3::LLColor3(const LLSD &sd) +LLColor3::LLColor3(const LLSD& sd)  {      setValue(sd);  } -const LLColor3& LLColor3::operator=(const LLColor4 &a) +const LLColor3& LLColor3::operator=(const LLColor4& a)  { -    mV[0] = a.mV[0]; -    mV[1] = a.mV[1]; -    mV[2] = a.mV[2]; +    mV[VRED]   = a.mV[VRED]; +    mV[VGREEN] = a.mV[VGREEN]; +    mV[VBLUE]  = a.mV[VBLUE];      return (*this);  } -std::ostream& operator<<(std::ostream& s, const LLColor3 &a) +std::ostream& operator<<(std::ostream& s, const LLColor3& a)  {      s << "{ " << a.mV[VRED] << ", " << a.mV[VGREEN] << ", " << a.mV[VBLUE] << " }";      return s;  } -static F32 hueToRgb ( F32 val1In, F32 val2In, F32 valHUeIn ) +static F32 hueToRgb(F32 val1In, F32 val2In, F32 valHUeIn)  { -    if ( valHUeIn < 0.0f ) valHUeIn += 1.0f; -    if ( valHUeIn > 1.0f ) valHUeIn -= 1.0f; -    if ( ( 6.0f * valHUeIn ) < 1.0f ) return ( val1In + ( val2In - val1In ) * 6.0f * valHUeIn ); -    if ( ( 2.0f * valHUeIn ) < 1.0f ) return ( val2In ); -    if ( ( 3.0f * valHUeIn ) < 2.0f ) return ( val1In + ( val2In - val1In ) * ( ( 2.0f / 3.0f ) - valHUeIn ) * 6.0f ); -    return ( val1In ); +    if (valHUeIn < 0.0f) +        valHUeIn += 1.0f; +    if (valHUeIn > 1.0f) +        valHUeIn -= 1.0f; +    if ((6.0f * valHUeIn) < 1.0f) +        return (val1In + (val2In - val1In) * 6.0f * valHUeIn); +    if ((2.0f * valHUeIn) < 1.0f) +        return (val2In); +    if ((3.0f * valHUeIn) < 2.0f) +        return (val1In + (val2In - val1In) * ((2.0f / 3.0f) - valHUeIn) * 6.0f); +    return (val1In);  } -void LLColor3::setHSL ( F32 hValIn, F32 sValIn, F32 lValIn) +void LLColor3::setHSL(F32 hValIn, F32 sValIn, F32 lValIn)  { -    if ( sValIn < 0.00001f ) +    if (sValIn < 0.00001f)      { -        mV[VRED] = lValIn; +        mV[VRED]   = lValIn;          mV[VGREEN] = lValIn; -        mV[VBLUE] = lValIn; +        mV[VBLUE]  = lValIn;      }      else      {          F32 interVal1;          F32 interVal2; -        if ( lValIn < 0.5f ) -            interVal2 = lValIn * ( 1.0f + sValIn ); +        if (lValIn < 0.5f) +            interVal2 = lValIn * (1.0f + sValIn);          else -            interVal2 = ( lValIn + sValIn ) - ( sValIn * lValIn ); +            interVal2 = (lValIn + sValIn) - (sValIn * lValIn);          interVal1 = 2.0f * lValIn - interVal2; -        mV[VRED] = hueToRgb ( interVal1, interVal2, hValIn + ( 1.f / 3.f ) ); -        mV[VGREEN] = hueToRgb ( interVal1, interVal2, hValIn ); -        mV[VBLUE] = hueToRgb ( interVal1, interVal2, hValIn - ( 1.f / 3.f ) ); +        mV[VRED]   = hueToRgb(interVal1, interVal2, hValIn + (1.f / 3.f)); +        mV[VGREEN] = hueToRgb(interVal1, interVal2, hValIn); +        mV[VBLUE]  = hueToRgb(interVal1, interVal2, hValIn - (1.f / 3.f));      }  } @@ -109,45 +114,48 @@ void LLColor3::calcHSL(F32* hue, F32* saturation, F32* luminance) const      F32 var_G = mV[VGREEN];      F32 var_B = mV[VBLUE]; -    F32 var_Min = ( var_R < ( var_G < var_B ? var_G : var_B ) ? var_R : ( var_G < var_B ? var_G : var_B ) ); -    F32 var_Max = ( var_R > ( var_G > var_B ? var_G : var_B ) ? var_R : ( var_G > var_B ? var_G : var_B ) ); +    F32 var_Min = (var_R < (var_G < var_B ? var_G : var_B) ? var_R : (var_G < var_B ? var_G : var_B)); +    F32 var_Max = (var_R > (var_G > var_B ? var_G : var_B) ? var_R : (var_G > var_B ? var_G : var_B));      F32 del_Max = var_Max - var_Min; -    F32 L = ( var_Max + var_Min ) / 2.0f; +    F32 L = (var_Max + var_Min) / 2.0f;      F32 H = 0.0f;      F32 S = 0.0f; -    if ( del_Max == 0.0f ) +    if (del_Max == 0.0f)      { -       H = 0.0f; -       S = 0.0f; +        H = 0.0f; +        S = 0.0f;      }      else      { -        if ( L < 0.5 ) -            S = del_Max / ( var_Max + var_Min ); +        if (L < 0.5) +            S = del_Max / (var_Max + var_Min);          else -            S = del_Max / ( 2.0f - var_Max - var_Min ); +            S = del_Max / (2.0f - var_Max - var_Min); -        F32 del_R = ( ( ( var_Max - var_R ) / 6.0f ) + ( del_Max / 2.0f ) ) / del_Max; -        F32 del_G = ( ( ( var_Max - var_G ) / 6.0f ) + ( del_Max / 2.0f ) ) / del_Max; -        F32 del_B = ( ( ( var_Max - var_B ) / 6.0f ) + ( del_Max / 2.0f ) ) / del_Max; +        F32 del_R = (((var_Max - var_R) / 6.0f) + (del_Max / 2.0f)) / del_Max; +        F32 del_G = (((var_Max - var_G) / 6.0f) + (del_Max / 2.0f)) / del_Max; +        F32 del_B = (((var_Max - var_B) / 6.0f) + (del_Max / 2.0f)) / del_Max; -        if ( var_R >= var_Max ) +        if (var_R >= var_Max)              H = del_B - del_G; -        else -        if ( var_G >= var_Max ) -            H = ( 1.0f / 3.0f ) + del_R - del_B; -        else -        if ( var_B >= var_Max ) -            H = ( 2.0f / 3.0f ) + del_G - del_R; - -        if ( H < 0.0f ) H += 1.0f; -        if ( H > 1.0f ) H -= 1.0f; +        else if (var_G >= var_Max) +            H = (1.0f / 3.0f) + del_R - del_B; +        else if (var_B >= var_Max) +            H = (2.0f / 3.0f) + del_G - del_R; + +        if (H < 0.0f) +            H += 1.0f; +        if (H > 1.0f) +            H -= 1.0f;      } -    if (hue) *hue = H; -    if (saturation) *saturation = S; -    if (luminance) *luminance = L; +    if (hue) +        *hue = H; +    if (saturation) +        *saturation = S; +    if (luminance) +        *luminance = L;  } diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h index f7af469e66..48b36e7c8a 100644 --- a/indra/llmath/v3color.h +++ b/indra/llmath/v3color.h @@ -33,12 +33,12 @@ class LLVector4;  #include "llerror.h"  #include "llmath.h"  #include "llsd.h" -#include "v3math.h"  // needed for linearColor3v implemtation below +#include "v3math.h" // needed for linearColor3v implemtation below  #include <string.h>  //  LLColor3 = |r g b| -static const U32 LENGTHOFCOLOR3 = 3; +static constexpr U32 LENGTHOFCOLOR3 = 3;  class LLColor3  { @@ -50,44 +50,43 @@ public:      static LLColor3 grey;  public: -    LLColor3();                         // Initializes LLColor3 to (0, 0, 0) -    LLColor3(F32 r, F32 g, F32 b);      // Initializes LLColor3 to (r, g, b) -    LLColor3(const F32 *vec);           // Initializes LLColor3 to (vec[0]. vec[1], vec[2]) -    LLColor3(const char *color_string);       // html format color ie "#FFDDEE" -    explicit LLColor3(const LLColor4& color4);  // "explicit" to avoid automatic conversion -    explicit LLColor3(const LLVector4& vector4);  // "explicit" to avoid automatic conversion +    LLColor3();                                  // Initializes LLColor3 to (0, 0, 0) +    LLColor3(F32 r, F32 g, F32 b);               // Initializes LLColor3 to (r, g, b) +    LLColor3(const F32* vec);                    // Initializes LLColor3 to (vec[0]. vec[1], vec[2]) +    LLColor3(const char* color_string);          // html format color ie "#FFDDEE" +    explicit LLColor3(const LLColor4& color4);   // "explicit" to avoid automatic conversion +    explicit LLColor3(const LLVector4& vector4); // "explicit" to avoid automatic conversion      LLColor3(const LLSD& sd); -      LLSD getValue() const      {          LLSD ret; -        ret[0] = mV[0]; -        ret[1] = mV[1]; -        ret[2] = mV[2]; +        ret[VRED]   = mV[VRED]; +        ret[VGREEN] = mV[VGREEN]; +        ret[VBLUE]  = mV[VBLUE];          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[VRED]   = (F32)sd[VRED].asReal(); +        mV[VGREEN] = (F32)sd[VGREEN].asReal(); +        mV[VBLUE]  = (F32)sd[VBLUE].asReal();      }      void setHSL(F32 hue, F32 saturation, F32 luminance);      void calcHSL(F32* hue, F32* saturation, F32* luminance) const; -    const LLColor3& setToBlack();                   // Clears LLColor3 to (0, 0, 0) -    const LLColor3& setToWhite();                   // Zero LLColor3 to (0, 0, 0) +    const LLColor3& setToBlack(); // Clears LLColor3 to (0, 0, 0) +    const LLColor3& setToWhite(); // Zero LLColor3 to (0, 0, 0) -    const LLColor3& setVec(F32 x, F32 y, F32 z);    // deprecated -    const LLColor3& setVec(const LLColor3 &vec);    // deprecated -    const LLColor3& setVec(const F32 *vec);         // deprecated +    const LLColor3& setVec(F32 x, F32 y, F32 z); // deprecated +    const LLColor3& setVec(const LLColor3& vec); // deprecated +    const LLColor3& setVec(const F32* vec);      // deprecated -    const LLColor3& set(F32 x, F32 y, F32 z);   // Sets LLColor3 to (x, y, z) -    const LLColor3& set(const LLColor3 &vec);   // Sets LLColor3 to vec -    const LLColor3& set(const F32 *vec);        // Sets LLColor3 to vec +    const LLColor3& set(F32 x, F32 y, F32 z); // Sets LLColor3 to (x, y, z) +    const LLColor3& set(const LLColor3& vec); // Sets LLColor3 to vec +    const LLColor3& set(const F32* vec);      // Sets LLColor3 to vec      // set from a vector of unknown type and size      // may leave some data unmodified @@ -99,414 +98,390 @@ public:      template<typename T>      void write(std::vector<T>& v) const; -    F32     magVec() const;             // deprecated -    F32     magVecSquared() const;      // deprecated -    F32     normVec();                  // deprecated +    F32 magVec() const;        // deprecated +    F32 magVecSquared() const; // deprecated +    F32 normVec();             // deprecated -    F32     length() const;             // Returns magnitude of LLColor3 -    F32     lengthSquared() const;      // Returns magnitude squared of LLColor3 -    F32     normalize();                // Normalizes and returns the magnitude of LLColor3 +    F32 length() const;        // Returns magnitude of LLColor3 +    F32 lengthSquared() const; // Returns magnitude squared of LLColor3 +    F32 normalize();           // Normalizes and returns the magnitude of LLColor3 -    F32     brightness() const;         // Returns brightness of LLColor3 +    F32 brightness() const; // Returns brightness of LLColor3 -    const LLColor3& operator=(const LLColor4 &a); +    const LLColor3& operator=(const LLColor4& a); -    LL_FORCE_INLINE LLColor3 divide(const LLColor3 &col2) +    LL_FORCE_INLINE LLColor3 divide(const LLColor3& col2) const      { -        return LLColor3( -                mV[0] / col2.mV[0], -                mV[1] / col2.mV[1], -                mV[2] / col2.mV[2] ); +        return LLColor3(mV[VRED] / col2.mV[VRED], mV[VGREEN] / col2.mV[VGREEN], mV[VBLUE] / col2.mV[VBLUE]);      } -    LL_FORCE_INLINE LLColor3 color_norm() +    LL_FORCE_INLINE LLColor3 color_norm() const      {          F32 l = length(); -        return LLColor3( -                mV[0] / l, -                mV[1] / l, -                mV[2] / l ); +        return LLColor3(mV[VRED] / l, mV[VGREEN] / l, mV[VBLUE] / l);      } -    friend std::ostream&     operator<<(std::ostream& s, const LLColor3 &a);        // Print a -    friend LLColor3 operator+(const LLColor3 &a, const LLColor3 &b);    // Return vector a + b -    friend LLColor3 operator-(const LLColor3 &a, const LLColor3 &b);    // Return vector a minus b +    friend std::ostream& operator<<(std::ostream& s, const LLColor3& a);  // Print a +    friend LLColor3      operator+(const LLColor3& a, const LLColor3& b); // Return vector a + b +    friend LLColor3      operator-(const LLColor3& a, const LLColor3& b); // Return vector a minus b -    friend const LLColor3& operator+=(LLColor3 &a, const LLColor3 &b);  // Return vector a + b -    friend const LLColor3& operator-=(LLColor3 &a, const LLColor3 &b);  // Return vector a minus b -    friend const LLColor3& operator*=(LLColor3 &a, const LLColor3 &b); +    friend const LLColor3& operator+=(LLColor3& a, const LLColor3& b); // Return vector a + b +    friend const LLColor3& operator-=(LLColor3& a, const LLColor3& b); // Return vector a minus b +    friend const LLColor3& operator*=(LLColor3& a, const LLColor3& b); -    friend LLColor3 operator*(const LLColor3 &a, const LLColor3 &b);    // Return component wise a * b -    friend LLColor3 operator*(const LLColor3 &a, F32 k);                // Return a times scaler k -    friend LLColor3 operator*(F32 k, const LLColor3 &a);                // Return a times scaler k +    friend LLColor3 operator*(const LLColor3& a, const LLColor3& b); // Return component wise a * b +    friend LLColor3 operator*(const LLColor3& a, F32 k);             // Return a times scaler k +    friend LLColor3 operator*(F32 k, const LLColor3& a);             // Return a times scaler k -    friend bool operator==(const LLColor3 &a, const LLColor3 &b);       // Return a == b -    friend bool operator!=(const LLColor3 &a, const LLColor3 &b);       // Return a != b +    friend bool operator==(const LLColor3& a, const LLColor3& b); // Return a == b +    friend bool operator!=(const LLColor3& a, const LLColor3& b); // Return a != b -    friend const LLColor3& operator*=(LLColor3 &a, F32 k);              // Return a times scaler k +    friend const LLColor3& operator*=(LLColor3& a, F32 k); // Return a times scaler k -    friend LLColor3 operator-(const LLColor3 &a);                   // Return vector 1-rgb (inverse) +    friend LLColor3 operator-(const LLColor3& a); // Return vector 1-rgb (inverse)      inline void clamp(); -    inline void exp();  // Do an exponential on the color +    inline void exp(); // Do an exponential on the color  }; -LLColor3 lerp(const LLColor3 &a, const LLColor3 &b, F32 u); - +LLColor3 lerp(const LLColor3& a, const LLColor3& b, F32 u);  void LLColor3::clamp()  {      // Clamp the color... -    if (mV[0] < 0.f) +    if (mV[VRED] < 0.f)      { -        mV[0] = 0.f; +        mV[VRED] = 0.f;      } -    else if (mV[0] > 1.f) +    else if (mV[VRED] > 1.f)      { -        mV[0] = 1.f; +        mV[VRED] = 1.f;      } -    if (mV[1] < 0.f) +    if (mV[VGREEN] < 0.f)      { -        mV[1] = 0.f; +        mV[VGREEN] = 0.f;      } -    else if (mV[1] > 1.f) +    else if (mV[VGREEN] > 1.f)      { -        mV[1] = 1.f; +        mV[VGREEN] = 1.f;      } -    if (mV[2] < 0.f) +    if (mV[VBLUE] < 0.f)      { -        mV[2] = 0.f; +        mV[VBLUE] = 0.f;      } -    else if (mV[2] > 1.f) +    else if (mV[VBLUE] > 1.f)      { -        mV[2] = 1.f; +        mV[VBLUE] = 1.f;      }  }  // Non-member functions -F32     distVec(const LLColor3 &a, const LLColor3 &b);      // Returns distance between a and b -F32     distVec_squared(const LLColor3 &a, const LLColor3 &b);// Returns distance squared between a and b +F32 distVec(const LLColor3& a, const LLColor3& b);         // Returns distance between a and b +F32 distVec_squared(const LLColor3& a, const LLColor3& b); // Returns distance squared between a and b -inline LLColor3::LLColor3(void) +inline LLColor3::LLColor3()  { -    mV[0] = 0.f; -    mV[1] = 0.f; -    mV[2] = 0.f; +    mV[VRED]   = 0.f; +    mV[VGREEN] = 0.f; +    mV[VBLUE]  = 0.f;  }  inline LLColor3::LLColor3(F32 r, F32 g, F32 b)  { -    mV[VRED] = r; +    mV[VRED]   = r;      mV[VGREEN] = g; -    mV[VBLUE] = b; +    mV[VBLUE]  = b;  } - -inline LLColor3::LLColor3(const F32 *vec) +inline LLColor3::LLColor3(const F32* vec)  { -    mV[VRED] = vec[VRED]; +    mV[VRED]   = vec[VRED];      mV[VGREEN] = vec[VGREEN]; -    mV[VBLUE] = vec[VBLUE]; +    mV[VBLUE]  = vec[VBLUE];  }  inline LLColor3::LLColor3(const char* color_string) // takes a string of format "RRGGBB" where RR is hex 00..FF  { -    if (strlen(color_string) <  6)      /* Flawfinder: ignore */ +    if (strlen(color_string) < 6) /* Flawfinder: ignore */      { -        mV[0] = 0.f; -        mV[1] = 0.f; -        mV[2] = 0.f; +        mV[VRED]   = 0.f; +        mV[VGREEN] = 0.f; +        mV[VBLUE]  = 0.f;          return;      }      char tempstr[7]; -    strncpy(tempstr,color_string,6);        /* Flawfinder: ignore */ +    strncpy(tempstr, color_string, 6); /* Flawfinder: ignore */      tempstr[6] = '\0'; -    mV[VBLUE] = (F32)strtol(&tempstr[4],NULL,16)/255.f; +    mV[VBLUE]  = (F32)strtol(&tempstr[4], nullptr, 16) / 255.f;      tempstr[4] = '\0'; -    mV[VGREEN] = (F32)strtol(&tempstr[2],NULL,16)/255.f; +    mV[VGREEN] = (F32)strtol(&tempstr[2], nullptr, 16) / 255.f;      tempstr[2] = '\0'; -    mV[VRED] = (F32)strtol(&tempstr[0],NULL,16)/255.f; +    mV[VRED]   = (F32)strtol(&tempstr[0], nullptr, 16) / 255.f;  } -inline const LLColor3&  LLColor3::setToBlack(void) +inline const LLColor3& LLColor3::setToBlack()  { -    mV[0] = 0.f; -    mV[1] = 0.f; -    mV[2] = 0.f; +    mV[VRED]   = 0.f; +    mV[VGREEN] = 0.f; +    mV[VBLUE]  = 0.f;      return (*this);  } -inline const LLColor3&  LLColor3::setToWhite(void) +inline const LLColor3& LLColor3::setToWhite()  { -    mV[0] = 1.f; -    mV[1] = 1.f; -    mV[2] = 1.f; +    mV[VRED]   = 1.f; +    mV[VGREEN] = 1.f; +    mV[VBLUE]  = 1.f;      return (*this);  } -inline const LLColor3&  LLColor3::set(F32 r, F32 g, F32 b) +inline const LLColor3& LLColor3::set(F32 r, F32 g, F32 b)  { -    mV[0] = r; -    mV[1] = g; -    mV[2] = b; +    mV[VRED]   = r; +    mV[VGREEN] = g; +    mV[VBLUE]  = b;      return (*this);  } -inline const LLColor3&  LLColor3::set(const LLColor3 &vec) +inline const LLColor3& LLColor3::set(const LLColor3& vec)  { -    mV[0] = vec.mV[0]; -    mV[1] = vec.mV[1]; -    mV[2] = vec.mV[2]; +    mV[VRED]   = vec.mV[VRED]; +    mV[VGREEN] = vec.mV[VGREEN]; +    mV[VBLUE]  = vec.mV[VBLUE];      return (*this);  } -inline const LLColor3&  LLColor3::set(const F32 *vec) +inline const LLColor3& LLColor3::set(const F32* vec)  { -    mV[0] = vec[0]; -    mV[1] = vec[1]; -    mV[2] = vec[2]; +    mV[VRED]   = vec[VRED]; +    mV[VGREEN] = vec[VGREEN]; +    mV[VBLUE]  = vec[VBLUE];      return (*this);  }  // deprecated -inline const LLColor3&  LLColor3::setVec(F32 r, F32 g, F32 b) +inline const LLColor3& LLColor3::setVec(F32 r, F32 g, F32 b)  { -    mV[0] = r; -    mV[1] = g; -    mV[2] = b; +    mV[VRED]   = r; +    mV[VGREEN] = g; +    mV[VBLUE]  = b;      return (*this);  }  // deprecated -inline const LLColor3&  LLColor3::setVec(const LLColor3 &vec) +inline const LLColor3& LLColor3::setVec(const LLColor3& vec)  { -    mV[0] = vec.mV[0]; -    mV[1] = vec.mV[1]; -    mV[2] = vec.mV[2]; +    mV[VRED]   = vec.mV[VRED]; +    mV[VGREEN] = vec.mV[VGREEN]; +    mV[VBLUE]  = vec.mV[VBLUE];      return (*this);  }  // deprecated -inline const LLColor3&  LLColor3::setVec(const F32 *vec) +inline const LLColor3& LLColor3::setVec(const F32* vec)  { -    mV[0] = vec[0]; -    mV[1] = vec[1]; -    mV[2] = vec[2]; +    mV[VRED]   = vec[VRED]; +    mV[VGREEN] = vec[VGREEN]; +    mV[VBLUE]  = vec[VBLUE];      return (*this);  } -inline F32      LLColor3::brightness(void) const +inline F32 LLColor3::brightness() const  { -    return (mV[0] + mV[1] + mV[2]) / 3.0f; +    return (mV[VRED] + mV[VGREEN] + mV[VBLUE]) / 3.0f;  } -inline F32      LLColor3::length(void) const +inline F32 LLColor3::length() const  { -    return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); +    return sqrt(mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE]);  } -inline F32      LLColor3::lengthSquared(void) const +inline F32 LLColor3::lengthSquared() const  { -    return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]; +    return mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE];  } -inline F32      LLColor3::normalize(void) +inline F32 LLColor3::normalize()  { -    F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); +    F32 mag = sqrt(mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE]);      F32 oomag;      if (mag)      { -        oomag = 1.f/mag; -        mV[0] *= oomag; -        mV[1] *= oomag; -        mV[2] *= oomag; +        oomag = 1.f / mag; +        mV[VRED] *= oomag; +        mV[VGREEN] *= oomag; +        mV[VBLUE] *= oomag;      } -    return (mag); +    return mag;  }  // deprecated -inline F32      LLColor3::magVec(void) const +inline F32 LLColor3::magVec() const  { -    return (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); +    return sqrt(mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE]);  }  // deprecated -inline F32      LLColor3::magVecSquared(void) const +inline F32 LLColor3::magVecSquared() const  { -    return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]; +    return mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE];  }  // deprecated -inline F32      LLColor3::normVec(void) +inline F32 LLColor3::normVec()  { -    F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); +    F32 mag = sqrt(mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE]);      F32 oomag;      if (mag)      { -        oomag = 1.f/mag; -        mV[0] *= oomag; -        mV[1] *= oomag; -        mV[2] *= oomag; +        oomag = 1.f / mag; +        mV[VRED] *= oomag; +        mV[VGREEN] *= oomag; +        mV[VBLUE] *= oomag;      } -    return (mag); +    return mag;  }  inline void LLColor3::exp()  {  #if 0 -    mV[0] = ::exp(mV[0]); -    mV[1] = ::exp(mV[1]); -    mV[2] = ::exp(mV[2]); +    mV[VRED] = ::exp(mV[VRED]); +    mV[VGREEN] = ::exp(mV[VGREEN]); +    mV[VBLUE] = ::exp(mV[VBLUE]);  #else -    mV[0] = (F32)LL_FAST_EXP(mV[0]); -    mV[1] = (F32)LL_FAST_EXP(mV[1]); -    mV[2] = (F32)LL_FAST_EXP(mV[2]); +    mV[VRED]   = (F32)LL_FAST_EXP(mV[VRED]); +    mV[VGREEN] = (F32)LL_FAST_EXP(mV[VGREEN]); +    mV[VBLUE]  = (F32)LL_FAST_EXP(mV[VBLUE]);  #endif  } - -inline LLColor3 operator+(const LLColor3 &a, const LLColor3 &b) +inline LLColor3 operator+(const LLColor3& a, const LLColor3& b)  { -    return LLColor3( -        a.mV[0] + b.mV[0], -        a.mV[1] + b.mV[1], -        a.mV[2] + b.mV[2]); +    return LLColor3(a.mV[VRED] + b.mV[VRED], a.mV[VGREEN] + b.mV[VGREEN], a.mV[VBLUE] + b.mV[VBLUE]);  } -inline LLColor3 operator-(const LLColor3 &a, const LLColor3 &b) +inline LLColor3 operator-(const LLColor3& a, const LLColor3& b)  { -    return LLColor3( -        a.mV[0] - b.mV[0], -        a.mV[1] - b.mV[1], -        a.mV[2] - b.mV[2]); +    return LLColor3(a.mV[VRED] - b.mV[VRED], a.mV[VGREEN] - b.mV[VGREEN], a.mV[VBLUE] - b.mV[VBLUE]);  } -inline LLColor3  operator*(const LLColor3 &a, const LLColor3 &b) +inline LLColor3 operator*(const LLColor3& a, const LLColor3& b)  { -    return LLColor3( -        a.mV[0] * b.mV[0], -        a.mV[1] * b.mV[1], -        a.mV[2] * b.mV[2]); +    return LLColor3(a.mV[VRED] * b.mV[VRED], a.mV[VGREEN] * b.mV[VGREEN], a.mV[VBLUE] * b.mV[VBLUE]);  } -inline LLColor3 operator*(const LLColor3 &a, F32 k) +inline LLColor3 operator*(const LLColor3& a, F32 k)  { -    return LLColor3( a.mV[0] * k, a.mV[1] * k, a.mV[2] * k ); +    return LLColor3(a.mV[VRED] * k, a.mV[VGREEN] * k, a.mV[VBLUE] * k);  } -inline LLColor3 operator*(F32 k, const LLColor3 &a) +inline LLColor3 operator*(F32 k, const LLColor3& a)  { -    return LLColor3( a.mV[0] * k, a.mV[1] * k, a.mV[2] * k ); +    return LLColor3(a.mV[VRED] * k, a.mV[VGREEN] * k, a.mV[VBLUE] * k);  } -inline bool operator==(const LLColor3 &a, const LLColor3 &b) +inline bool operator==(const LLColor3& a, const LLColor3& b)  { -    return (  (a.mV[0] == b.mV[0]) -            &&(a.mV[1] == b.mV[1]) -            &&(a.mV[2] == b.mV[2])); +    return ((a.mV[VRED] == b.mV[VRED]) && (a.mV[VGREEN] == b.mV[VGREEN]) && (a.mV[VBLUE] == b.mV[VBLUE]));  } -inline bool operator!=(const LLColor3 &a, const LLColor3 &b) +inline bool operator!=(const LLColor3& a, const LLColor3& b)  { -    return (  (a.mV[0] != b.mV[0]) -            ||(a.mV[1] != b.mV[1]) -            ||(a.mV[2] != b.mV[2])); +    return ((a.mV[VRED] != b.mV[VRED]) || (a.mV[VGREEN] != b.mV[VGREEN]) || (a.mV[VBLUE] != b.mV[VBLUE]));  } -inline const LLColor3 &operator*=(LLColor3 &a, const LLColor3 &b) +inline const LLColor3& operator*=(LLColor3& a, const LLColor3& b)  { -    a.mV[0] *= b.mV[0]; -    a.mV[1] *= b.mV[1]; -    a.mV[2] *= b.mV[2]; +    a.mV[VRED] *= b.mV[VRED]; +    a.mV[VGREEN] *= b.mV[VGREEN]; +    a.mV[VBLUE] *= b.mV[VBLUE];      return a;  } -inline const LLColor3& operator+=(LLColor3 &a, const LLColor3 &b) +inline const LLColor3& operator+=(LLColor3& a, const LLColor3& b)  { -    a.mV[0] += b.mV[0]; -    a.mV[1] += b.mV[1]; -    a.mV[2] += b.mV[2]; +    a.mV[VRED] += b.mV[VRED]; +    a.mV[VGREEN] += b.mV[VGREEN]; +    a.mV[VBLUE] += b.mV[VBLUE];      return a;  } -inline const LLColor3& operator-=(LLColor3 &a, const LLColor3 &b) +inline const LLColor3& operator-=(LLColor3& a, const LLColor3& b)  { -    a.mV[0] -= b.mV[0]; -    a.mV[1] -= b.mV[1]; -    a.mV[2] -= b.mV[2]; +    a.mV[VRED] -= b.mV[VRED]; +    a.mV[VGREEN] -= b.mV[VGREEN]; +    a.mV[VBLUE] -= b.mV[VBLUE];      return a;  } -inline const LLColor3& operator*=(LLColor3 &a, F32 k) +inline const LLColor3& operator*=(LLColor3& a, F32 k)  { -    a.mV[0] *= k; -    a.mV[1] *= k; -    a.mV[2] *= k; +    a.mV[VRED] *= k; +    a.mV[VGREEN] *= k; +    a.mV[VBLUE] *= k;      return a;  } -inline LLColor3 operator-(const LLColor3 &a) +inline LLColor3 operator-(const LLColor3& a)  { -    return LLColor3( -        1.f - a.mV[0], -        1.f - a.mV[1], -        1.f - a.mV[2] ); +    return LLColor3(1.f - a.mV[VRED], 1.f - a.mV[VGREEN], 1.f - a.mV[VBLUE]);  }  // Non-member functions -inline F32      distVec(const LLColor3 &a, const LLColor3 &b) +inline F32 distVec(const LLColor3& a, const LLColor3& 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[VRED] - b.mV[VRED]; +    F32 y = a.mV[VGREEN] - b.mV[VGREEN]; +    F32 z = a.mV[VBLUE] - b.mV[VBLUE]; +    return sqrt(x * x + y * y + z * z);  } -inline F32      distVec_squared(const LLColor3 &a, const LLColor3 &b) +inline F32 distVec_squared(const LLColor3& a, const LLColor3& 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 x*x + y*y + z*z; +    F32 x = a.mV[VRED] - b.mV[VRED]; +    F32 y = a.mV[VGREEN] - b.mV[VGREEN]; +    F32 z = a.mV[VBLUE] - b.mV[VBLUE]; +    return x * x + y * y + z * z;  } -inline LLColor3 lerp(const LLColor3 &a, const LLColor3 &b, F32 u) +inline LLColor3 lerp(const LLColor3& a, const LLColor3& b, F32 u)  { -    return LLColor3( -        a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u, -        a.mV[VY] + (b.mV[VY] - a.mV[VY]) * u, -        a.mV[VZ] + (b.mV[VZ] - a.mV[VZ]) * u); +    return LLColor3(a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u, a.mV[VY] + (b.mV[VY] - a.mV[VY]) * u, a.mV[VZ] + (b.mV[VZ] - a.mV[VZ]) * u);  } -inline const LLColor3 srgbColor3(const LLColor3 &a) { +inline const LLColor3 srgbColor3(const LLColor3& a) +{      LLColor3 srgbColor; -    srgbColor.mV[0] = linearTosRGB(a.mV[0]); -    srgbColor.mV[1] = linearTosRGB(a.mV[1]); -    srgbColor.mV[2] = linearTosRGB(a.mV[2]); +    srgbColor.mV[VRED]   = linearTosRGB(a.mV[VRED]); +    srgbColor.mV[VGREEN] = linearTosRGB(a.mV[VGREEN]); +    srgbColor.mV[VBLUE]  = linearTosRGB(a.mV[VBLUE]);      return srgbColor;  } -inline const LLColor3 linearColor3p(const F32* v) { +inline const LLColor3 linearColor3p(const F32* v) +{      LLColor3 linearColor; -    linearColor.mV[0] = sRGBtoLinear(v[0]); -    linearColor.mV[1] = sRGBtoLinear(v[1]); -    linearColor.mV[2] = sRGBtoLinear(v[2]); +    linearColor.mV[VRED]   = sRGBtoLinear(v[VRED]); +    linearColor.mV[VGREEN] = sRGBtoLinear(v[VGREEN]); +    linearColor.mV[VBLUE]  = sRGBtoLinear(v[VBLUE]);      return linearColor;  }  template<class T> -inline const LLColor3 linearColor3(const T& a) { +inline const LLColor3 linearColor3(const T& a) +{      return linearColor3p(a.mV);  }  template<class T> -inline const LLVector3 linearColor3v(const T& a) { +inline const LLVector3 linearColor3v(const T& a) +{      return LLVector3(linearColor3p(a.mV).mV);  } diff --git a/indra/llmath/v3colorutil.h b/indra/llmath/v3colorutil.h index af8799e42a..4dc3100443 100644 --- a/indra/llmath/v3colorutil.h +++ b/indra/llmath/v3colorutil.h @@ -30,59 +30,46 @@  #include "v3color.h"  #include "v4color.h" -inline LLColor3 componentDiv(LLColor3 const &left, LLColor3 const & right) +inline LLColor3 componentDiv(const LLColor3& left, const LLColor3& right)  { -    return LLColor3(left.mV[0] / right.mV[0], -        left.mV[1] / right.mV[1], -        left.mV[2] / right.mV[2]); +    return LLColor3(left.mV[VRED] / right.mV[VRED], left.mV[VGREEN] / right.mV[VGREEN], left.mV[VBLUE] / right.mV[VBLUE]);  } - -inline LLColor3 componentMult(LLColor3 const &left, LLColor3 const & right) +inline LLColor3 componentMult(const LLColor3& left, const LLColor3& right)  { -    return LLColor3(left.mV[0] * right.mV[0], -        left.mV[1] * right.mV[1], -        left.mV[2] * right.mV[2]); +    return LLColor3(left.mV[VRED] * right.mV[VRED], left.mV[VGREEN] * right.mV[VGREEN], left.mV[VBLUE] * right.mV[VBLUE]);  } - -inline LLColor3 componentExp(LLColor3 const &v) +inline LLColor3 componentExp(const LLColor3& v)  { -    return LLColor3(exp(v.mV[0]), -        exp(v.mV[1]), -        exp(v.mV[2])); +    return LLColor3(exp(v.mV[VRED]), exp(v.mV[VGREEN]), exp(v.mV[VBLUE]));  } -inline LLColor3 componentPow(LLColor3 const &v, F32 exponent) +inline LLColor3 componentPow(const LLColor3& v, F32 exponent)  { -    return LLColor3(pow(v.mV[0], exponent), -        pow(v.mV[1], exponent), -        pow(v.mV[2], exponent)); +    return LLColor3(pow(v.mV[VRED], exponent), pow(v.mV[VGREEN], exponent), pow(v.mV[VBLUE], exponent));  } -inline LLColor3 componentSaturate(LLColor3 const &v) +inline LLColor3 componentSaturate(const LLColor3& v)  { -    return LLColor3(std::max(std::min(v.mV[0], 1.f), 0.f), -        std::max(std::min(v.mV[1], 1.f), 0.f), -        std::max(std::min(v.mV[2], 1.f), 0.f)); +    return LLColor3(std::max(std::min(v.mV[VRED], 1.f), 0.f), +                    std::max(std::min(v.mV[VGREEN], 1.f), 0.f), +                    std::max(std::min(v.mV[VBLUE], 1.f), 0.f));  } - -inline LLColor3 componentSqrt(LLColor3 const &v) +inline LLColor3 componentSqrt(const LLColor3& v)  { -    return LLColor3(sqrt(v.mV[0]), -        sqrt(v.mV[1]), -        sqrt(v.mV[2])); +    return LLColor3(sqrt(v.mV[VRED]), sqrt(v.mV[VGREEN]), sqrt(v.mV[VBLUE]));  } -inline void componentMultBy(LLColor3 & left, LLColor3 const & right) +inline void componentMultBy(LLColor3& left, const LLColor3& right)  { -    left.mV[0] *= right.mV[0]; -    left.mV[1] *= right.mV[1]; -    left.mV[2] *= right.mV[2]; +    left.mV[VRED] *= right.mV[VRED]; +    left.mV[VGREEN] *= right.mV[VGREEN]; +    left.mV[VBLUE] *= right.mV[VBLUE];  } -inline LLColor3 colorMix(LLColor3 const & left, LLColor3 const & right, F32 amount) +inline LLColor3 colorMix(const LLColor3& left, const LLColor3& right, F32 amount)  {      return (left + ((right - left) * amount));  } @@ -92,25 +79,24 @@ inline LLColor3 smear(F32 val)      return LLColor3(val, val, val);  } -inline F32 color_intens(const LLColor3 &col) +inline F32 color_intens(const LLColor3& col)  { -    return col.mV[0] + col.mV[1] + col.mV[2]; +    return col.mV[VRED] + col.mV[VGREEN] + col.mV[VBLUE];  } -inline F32 color_max(const LLColor3 &col) +inline F32 color_max(const LLColor3& col)  { -    return llmax(col.mV[0], col.mV[1], col.mV[2]); +    return llmax(col.mV[VRED], col.mV[VGREEN], col.mV[VBLUE]);  } -inline F32 color_max(const LLColor4 &col) +inline F32 color_max(const LLColor4& col)  { -    return llmax(col.mV[0], col.mV[1], col.mV[2]); +    return llmax(col.mV[VRED], col.mV[VGREEN], col.mV[VBLUE]);  } - -inline F32 color_min(const LLColor3 &col) +inline F32 color_min(const LLColor3& col)  { -    return llmin(col.mV[0], col.mV[1], col.mV[2]); +    return llmin(col.mV[VRED], col.mV[VGREEN], col.mV[VBLUE]);  }  #endif diff --git a/indra/llmath/v3dmath.cpp b/indra/llmath/v3dmath.cpp index bb55c812b5..b051303686 100644 --- a/indra/llmath/v3dmath.cpp +++ b/indra/llmath/v3dmath.cpp @@ -30,7 +30,6 @@  #include "v3dmath.h" -//#include "vmath.h"  #include "v4math.h"  #include "m4math.h"  #include "m3math.h" @@ -57,13 +56,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 +73,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,37 +88,37 @@ 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;  } -const LLVector3d&   LLVector3d::rotVec(const LLMatrix3 &mat) +const LLVector3d& LLVector3d::rotVec(const LLMatrix3& mat)  {      *this = *this * mat;      return *this;  } -const LLVector3d&   LLVector3d::rotVec(const LLQuaternion &q) +const LLVector3d& LLVector3d::rotVec(const LLQuaternion& q)  {      *this = *this * q;      return *this;  } -const LLVector3d&   LLVector3d::rotVec(F64 angle, const LLVector3d &vec) +const LLVector3d& LLVector3d::rotVec(F64 angle, const LLVector3d& vec)  { -    if ( !vec.isExactlyZero() && angle ) +    if (!vec.isExactlyZero() && angle)      {          *this = *this * LLMatrix3((F32)angle, vec);      }      return *this;  } -const LLVector3d&   LLVector3d::rotVec(F64 angle, F64 x, F64 y, F64 z) +const LLVector3d& LLVector3d::rotVec(F64 angle, F64 x, F64 y, F64 z)  {      LLVector3d vec(x, y, z); -    if ( !vec.isExactlyZero() && angle ) +    if (!vec.isExactlyZero() && angle)      {          *this = *this * LLMatrix3((F32)angle, vec);      } @@ -129,16 +128,16 @@ const LLVector3d&   LLVector3d::rotVec(F64 angle, F64 x, F64 y, F64 z)  bool LLVector3d::parseVector3d(const std::string& buf, LLVector3d* value)  { -    if( buf.empty() || value == nullptr) +    if (buf.empty() || value == nullptr)      {          return false;      }      LLVector3d v; -    S32 count = sscanf( buf.c_str(), "%lf %lf %lf", v.mdV + 0, v.mdV + 1, v.mdV + 2 ); -    if( 3 == count ) +    S32 count = sscanf(buf.c_str(), "%lf %lf %lf", v.mdV + VX, v.mdV + VY, v.mdV + VZ); +    if (3 == count)      { -        value->setVec( v ); +        value->setVec(v);          return true;      } diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h index ece8c54ea4..fcce2c30eb 100644 --- a/indra/llmath/v3dmath.h +++ b/indra/llmath/v3dmath.h @@ -32,128 +32,127 @@  class LLVector3d  { -    public: -        F64 mdV[3]; - -        const static LLVector3d zero; -        const static LLVector3d x_axis; -        const static LLVector3d y_axis; -        const static LLVector3d z_axis; -        const static LLVector3d x_axis_neg; -        const static LLVector3d y_axis_neg; -        const static LLVector3d z_axis_neg; - -        inline LLVector3d();                            // Initializes LLVector3d to (0, 0, 0) -        inline LLVector3d(const F64 x, const F64 y, const F64 z);           // Initializes LLVector3d to (x. y, z) -        inline explicit LLVector3d(const F64 *vec);             // Initializes LLVector3d to (vec[0]. vec[1], vec[2]) -        inline explicit LLVector3d(const LLVector3 &vec); -        explicit LLVector3d(const LLSD& sd) -        { -            setValue(sd); -        } - -        void setValue(const LLSD& sd) -        { -            mdV[0] = sd[0].asReal(); -            mdV[1] = sd[1].asReal(); -            mdV[2] = sd[2].asReal(); -        } - -        LLSD getValue() const -        { -            LLSD ret; -            ret[0] = mdV[0]; -            ret[1] = mdV[1]; -            ret[2] = mdV[2]; -            return ret; -        } - -        inline bool isFinite() const;                                   // checks to see if all values of LLVector3d are finite -        bool        clamp(const F64 min, const F64 max);        // Clamps all values to (min,max), returns true if data changed -        bool        abs();                      // sets all values to absolute value of original value (first octant), returns true if changed - -        inline const LLVector3d&    clear();        // Clears LLVector3d to (0, 0, 0, 1) -        inline const LLVector3d&    clearVec();     // deprecated -        inline const LLVector3d&    setZero();      // Zero LLVector3d to (0, 0, 0, 0) -        inline const LLVector3d&    zeroVec();      // deprecated -        inline const LLVector3d&    set(const F64 x, const F64 y, const F64 z); // Sets LLVector3d to (x, y, z, 1) -        inline const LLVector3d&    set(const LLVector3d &vec); // Sets LLVector3d to vec -        inline const LLVector3d&    set(const F64 *vec);        // Sets LLVector3d to vec -        inline const LLVector3d&    set(const LLVector3 &vec); -        inline const LLVector3d&    setVec(const F64 x, const F64 y, const F64 z);  // deprecated -        inline const LLVector3d&    setVec(const LLVector3d &vec);  // deprecated -        inline const LLVector3d&    setVec(const F64 *vec);         // deprecated -        inline const LLVector3d&    setVec(const LLVector3 &vec);   // deprecated - -        F64     magVec() const;             // deprecated -        F64     magVecSquared() const;      // deprecated -        inline F64      normVec();                  // deprecated - -        F64 length() const;         // Returns magnitude of LLVector3d -        F64 lengthSquared() const;  // Returns magnitude squared of LLVector3d -        inline F64 normalize();     // Normalizes and returns the magnitude of LLVector3d - -        const LLVector3d&   rotVec(const F64 angle, const LLVector3d &vec); // Rotates about vec by angle radians -        const LLVector3d&   rotVec(const F64 angle, const F64 x, const F64 y, const F64 z);     // Rotates about x,y,z by angle radians -        const LLVector3d&   rotVec(const LLMatrix3 &mat);               // Rotates by LLMatrix4 mat -        const LLVector3d&   rotVec(const LLQuaternion &q);              // Rotates by LLQuaternion q - -        bool isNull() const;            // Returns true if vector has a _very_small_ length -        bool isExactlyZero() const      { return !mdV[VX] && !mdV[VY] && !mdV[VZ]; } - -        const LLVector3d&   operator=(const LLVector4 &a); - -        F64 operator[](int idx) const { return mdV[idx]; } -        F64 &operator[](int idx) { return mdV[idx]; } - -        friend LLVector3d operator+(const LLVector3d& a, const LLVector3d& b);  // Return vector a + b -        friend LLVector3d operator-(const LLVector3d& a, const LLVector3d& b);  // Return vector a minus b -        friend F64 operator*(const LLVector3d& a, const LLVector3d& b);     // Return a dot b -        friend LLVector3d operator%(const LLVector3d& a, const LLVector3d& b);  // Return a cross b -        friend LLVector3d operator*(const LLVector3d& a, const F64 k);              // Return a times scaler k -        friend LLVector3d operator/(const LLVector3d& a, const F64 k);              // Return a divided by scaler k -        friend LLVector3d operator*(const F64 k, const LLVector3d& a);              // Return a times scaler k -        friend bool operator==(const LLVector3d& a, const LLVector3d& b);       // Return a == b -        friend bool operator!=(const LLVector3d& a, const LLVector3d& b);       // Return a != b - -        friend const LLVector3d& operator+=(LLVector3d& a, const LLVector3d& b);    // Return vector a + b -        friend const LLVector3d& operator-=(LLVector3d& a, const LLVector3d& b);    // Return vector a minus b -        friend const LLVector3d& operator%=(LLVector3d& a, const LLVector3d& b);    // Return a cross b -        friend const LLVector3d& operator*=(LLVector3d& a, const F64 k);                // Return a times scaler k -        friend const LLVector3d& operator/=(LLVector3d& a, const F64 k);                // Return a divided by scaler k - -        friend LLVector3d operator-(const LLVector3d& a);                   // Return vector -a - -        friend std::ostream&     operator<<(std::ostream& s, const LLVector3d& a);      // Stream a - -        static bool parseVector3d(const std::string& buf, LLVector3d* value); +public: +    F64 mdV[3]; + +    const static LLVector3d zero; +    const static LLVector3d x_axis; +    const static LLVector3d y_axis; +    const static LLVector3d z_axis; +    const static LLVector3d x_axis_neg; +    const static LLVector3d y_axis_neg; +    const static LLVector3d z_axis_neg; + +    inline LLVector3d();                            // Initializes LLVector3d to (0, 0, 0) +    inline LLVector3d(const F64 x, const F64 y, const F64 z);           // Initializes LLVector3d to (x. y, z) +    inline explicit LLVector3d(const F64 *vec);             // Initializes LLVector3d to (vec[0]. vec[1], vec[2]) +    inline explicit LLVector3d(const LLVector3 &vec); +    explicit LLVector3d(const LLSD& sd) +    { +        setValue(sd); +    } + +    void setValue(const LLSD& sd) +    { +        mdV[VX] = sd[0].asReal(); +        mdV[VY] = sd[1].asReal(); +        mdV[VZ] = sd[2].asReal(); +    } +    LLSD getValue() const +    { +        LLSD ret; +        ret[0] = mdV[VX]; +        ret[1] = mdV[VY]; +        ret[2] = mdV[VZ]; +        return ret; +    } + +    inline bool isFinite() const;                                   // checks to see if all values of LLVector3d are finite +    bool        clamp(const F64 min, const F64 max);        // Clamps all values to (min,max), returns true if data changed +    bool        abs();                      // sets all values to absolute value of original value (first octant), returns true if changed + +    inline const LLVector3d&    clear();        // Clears LLVector3d to (0, 0, 0, 1) +    inline const LLVector3d&    clearVec();     // deprecated +    inline const LLVector3d&    setZero();      // Zero LLVector3d to (0, 0, 0, 0) +    inline const LLVector3d&    zeroVec();      // deprecated +    inline const LLVector3d&    set(const F64 x, const F64 y, const F64 z); // Sets LLVector3d to (x, y, z, 1) +    inline const LLVector3d&    set(const LLVector3d &vec); // Sets LLVector3d to vec +    inline const LLVector3d&    set(const F64 *vec);        // Sets LLVector3d to vec +    inline const LLVector3d&    set(const LLVector3 &vec); +    inline const LLVector3d&    setVec(const F64 x, const F64 y, const F64 z);  // deprecated +    inline const LLVector3d&    setVec(const LLVector3d &vec);  // deprecated +    inline const LLVector3d&    setVec(const F64 *vec);         // deprecated +    inline const LLVector3d&    setVec(const LLVector3 &vec);   // deprecated + +    F64     magVec() const;             // deprecated +    F64     magVecSquared() const;      // deprecated +    inline F64      normVec();                  // deprecated + +    F64 length() const;         // Returns magnitude of LLVector3d +    F64 lengthSquared() const;  // Returns magnitude squared of LLVector3d +    inline F64 normalize();     // Normalizes and returns the magnitude of LLVector3d + +    const LLVector3d&   rotVec(const F64 angle, const LLVector3d &vec); // Rotates about vec by angle radians +    const LLVector3d&   rotVec(const F64 angle, const F64 x, const F64 y, const F64 z);     // Rotates about x,y,z by angle radians +    const LLVector3d&   rotVec(const LLMatrix3 &mat);               // Rotates by LLMatrix4 mat +    const LLVector3d&   rotVec(const LLQuaternion &q);              // Rotates by LLQuaternion q + +    bool isNull() const;            // Returns true if vector has a _very_small_ length +    bool isExactlyZero() const      { return !mdV[VX] && !mdV[VY] && !mdV[VZ]; } + +    const LLVector3d&   operator=(const LLVector4 &a); + +    F64 operator[](int idx) const { return mdV[idx]; } +    F64 &operator[](int idx) { return mdV[idx]; } + +    friend LLVector3d operator+(const LLVector3d& a, const LLVector3d& b);  // Return vector a + b +    friend LLVector3d operator-(const LLVector3d& a, const LLVector3d& b);  // Return vector a minus b +    friend F64 operator*(const LLVector3d& a, const LLVector3d& b);     // Return a dot b +    friend LLVector3d operator%(const LLVector3d& a, const LLVector3d& b);  // Return a cross b +    friend LLVector3d operator*(const LLVector3d& a, const F64 k);              // Return a times scaler k +    friend LLVector3d operator/(const LLVector3d& a, const F64 k);              // Return a divided by scaler k +    friend LLVector3d operator*(const F64 k, const LLVector3d& a);              // Return a times scaler k +    friend bool operator==(const LLVector3d& a, const LLVector3d& b);       // Return a == b +    friend bool operator!=(const LLVector3d& a, const LLVector3d& b);       // Return a != b + +    friend const LLVector3d& operator+=(LLVector3d& a, const LLVector3d& b);    // Return vector a + b +    friend const LLVector3d& operator-=(LLVector3d& a, const LLVector3d& b);    // Return vector a minus b +    friend const LLVector3d& operator%=(LLVector3d& a, const LLVector3d& b);    // Return a cross b +    friend const LLVector3d& operator*=(LLVector3d& a, const F64 k);                // Return a times scaler k +    friend const LLVector3d& operator/=(LLVector3d& a, const F64 k);                // Return a divided by scaler k + +    friend LLVector3d operator-(const LLVector3d& a);                   // Return vector -a + +    friend std::ostream&     operator<<(std::ostream& s, const LLVector3d& a);      // Stream a + +    static bool parseVector3d(const std::string& buf, LLVector3d* value);  };  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 +198,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 +238,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 +260,62 @@ 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 = (F32)sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); // This explicit cast to F32 limits the precision for numerical stability. +                                                                              // Without it, Unit test "v3dmath_h" fails at "1:angle_between" on macos.      F64 oomag;      if (mag > FP_MAG_THRESHOLD)      { -        oomag = 1.f/mag; -        mdV[0] *= oomag; -        mdV[1] *= oomag; -        mdV[2] *= oomag; +        oomag = 1.0/mag; +        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.0; +        mdV[VY] = 0.0; +        mdV[VZ] = 0.0;          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 = (F32)sqrt(mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ]); // Same as in normVec() above.      F64 oomag;      if (mag > FP_MAG_THRESHOLD)      { -        oomag = 1.f/mag; -        mdV[0] *= oomag; -        mdV[1] *= oomag; -        mdV[2] *= oomag; +        oomag = 1.0/mag; +        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.0; +        mdV[VY] = 0.0; +        mdV[VZ] = 0.0;          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..eac95ed023 100644 --- a/indra/llmath/v3math.cpp +++ b/indra/llmath/v3math.cpp @@ -28,7 +28,6 @@  #include "v3math.h" -//#include "vmath.h"  #include "v2math.h"  #include "v4math.h"  #include "m4math.h" @@ -58,13 +57,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 +84,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 +115,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,15 +155,15 @@ 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;  }  // Quatizations -void    LLVector3::quantize16(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz) +void LLVector3::quantize16(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz)  {      F32 x = mV[VX];      F32 y = mV[VY]; @@ -179,7 +178,7 @@ void    LLVector3::quantize16(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz)      mV[VZ] = z;  } -void    LLVector3::quantize8(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz) +void LLVector3::quantize8(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz)  {      mV[VX] = U8_to_F32(F32_to_U8(mV[VX], lowerxy, upperxy), lowerxy, upperxy);;      mV[VY] = U8_to_F32(F32_to_U8(mV[VY], lowerxy, upperxy), lowerxy, upperxy); @@ -187,20 +186,20 @@ void    LLVector3::quantize8(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz)  } -void    LLVector3::snap(S32 sig_digits) +void LLVector3::snap(S32 sig_digits)  {      mV[VX] = snap_to_sig_figs(mV[VX], sig_digits);      mV[VY] = snap_to_sig_figs(mV[VY], 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,26 +227,26 @@ 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 ) +    if (!vec.isExactlyZero() && angle)      {          *this = *this * LLQuaternion(angle, vec);      }      return *this;  } -const LLVector3&    LLVector3::rotVec(F32 angle, F32 x, F32 y, F32 z) +const LLVector3& LLVector3::rotVec(F32 angle, F32 x, F32 y, F32 z)  {      LLVector3 vec(x, y, z); -    if ( !vec.isExactlyZero() && angle ) +    if (!vec.isExactlyZero() && angle)      {          *this = *this * LLQuaternion(angle, vec);      }      return *this;  } -const LLVector3&    LLVector3::scaleVec(const LLVector3& vec) +const LLVector3& LLVector3::scaleVec(const LLVector3& vec)  {      mV[VX] *= vec.mV[VX];      mV[VY] *= vec.mV[VY]; @@ -256,42 +255,42 @@ const LLVector3&    LLVector3::scaleVec(const LLVector3& vec)      return *this;  } -LLVector3           LLVector3::scaledVec(const LLVector3& vec) const +LLVector3 LLVector3::scaledVec(const LLVector3& vec) const  {      LLVector3 ret = LLVector3(*this);      ret.scaleVec(vec);      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);  } @@ -299,17 +298,17 @@ LLVector3::LLVector3(const LLVector2 &vec)  {      mV[VX] = (F32)vec.mV[VX];      mV[VY] = (F32)vec.mV[VY]; -    mV[VZ] = 0; +    mV[VZ] = 0.f;  } -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]; @@ -319,7 +318,6 @@ LLVector3::LLVector3(const LLVector4 &vec)  LLVector3::LLVector3(const LLVector4a& vec)      : LLVector3(vec.getF32ptr())  { -  }  LLVector3::LLVector3(const LLSD& sd) @@ -330,20 +328,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[VX] = mV[VX]; +    ret[VY] = mV[VY]; +    ret[VZ] = 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[VX].asReal(); +    mV[VY] = (F32) sd[VY].asReal(); +    mV[VZ] = (F32) sd[VZ].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]; @@ -360,16 +358,16 @@ const LLVector3& operator*=(LLVector3 &a, const LLQuaternion &rot)  // static  bool LLVector3::parseVector3(const std::string& buf, LLVector3* value)  { -    if( buf.empty() || value == nullptr) +    if (buf.empty() || value == nullptr)      {          return false;      }      LLVector3 v; -    S32 count = sscanf( buf.c_str(), "%f %f %f", v.mV + 0, v.mV + 1, v.mV + 2 ); -    if( 3 == count ) +    S32 count = sscanf(buf.c_str(), "%f %f %f", v.mV + VX, v.mV + VY, v.mV + VZ); +    if (3 == count)      { -        value->setVec( v ); +        value->setVec(v);          return true;      } @@ -381,7 +379,7 @@ bool LLVector3::parseVector3(const std::string& buf, LLVector3* value)  LLVector3 point_to_box_offset(LLVector3& pos, const LLVector3* box)  {      LLVector3 offset; -    for (S32 k=0; k<3; k++) +    for (S32 k = 0; k < 3; k++)      {          offset[k] = 0;          if (pos[k] < box[0][k]) @@ -410,4 +408,3 @@ bool box_valid_and_non_zero(const LLVector3* box)      }      return false;  } - diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h index a3bfa68060..551c7df6c9 100644 --- a/indra/llmath/v3math.h +++ b/indra/llmath/v3math.h @@ -46,7 +46,7 @@ class LLQuaternion;  //  LLvector3 = |x y z w| -static const U32 LENGTHOFVECTOR3 = 3; +static constexpr U32 LENGTHOFVECTOR3 = 3;  class LLVector3  { @@ -181,11 +181,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) @@ -236,32 +236,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) @@ -271,18 +271,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[VX]; +    mV[VY] = vec[VY]; +    mV[VZ] = vec[VZ];  }  inline void LLVector3::set(const glm::vec4& vec) @@ -308,61 +308,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); @@ -370,145 +370,144 @@ 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)  { -    F32 t = 1.f / k; -    a.mV[0] *= t; -    a.mV[1] *= t; -    a.mV[2] *= t; +    a.mV[VX] /= k; +    a.mV[VY] /= k; +    a.mV[VZ] /= k;      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 LLVector3::operator glm::vec3() const @@ -522,30 +521,30 @@ inline LLVector3::operator glm::vec4() const      return glm::vec4(mV[VX], mV[VY], mV[VZ], 1.f);  } -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) @@ -570,18 +569,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, @@ -640,7 +639,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/v4color.cpp b/indra/llmath/v4color.cpp index ad13656bbd..1b687642ca 100644 --- a/indra/llmath/v4color.cpp +++ b/indra/llmath/v4color.cpp @@ -124,65 +124,64 @@ LLColor4 LLColor4::cyan6(0.2f, 0.6f, 0.6f, 1.0f);  // conversion  LLColor4::operator LLColor4U() const  { -    return LLColor4U( -        (U8)llclampb(ll_round(mV[VRED]*255.f)), -        (U8)llclampb(ll_round(mV[VGREEN]*255.f)), -        (U8)llclampb(ll_round(mV[VBLUE]*255.f)), -        (U8)llclampb(ll_round(mV[VALPHA]*255.f))); +    return LLColor4U((U8)llclampb(ll_round(mV[VRED] * 255.f)), +                     (U8)llclampb(ll_round(mV[VGREEN] * 255.f)), +                     (U8)llclampb(ll_round(mV[VBLUE] * 255.f)), +                     (U8)llclampb(ll_round(mV[VALPHA] * 255.f)));  } -LLColor4::LLColor4(const LLColor3 &vec, F32 a) +LLColor4::LLColor4(const LLColor3& vec, F32 a)  { -    mV[VRED] = vec.mV[VRED]; +    mV[VRED]   = vec.mV[VRED];      mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; +    mV[VBLUE]  = vec.mV[VBLUE];      mV[VALPHA] = a;  }  LLColor4::LLColor4(const LLColor4U& color4u)  { -    const F32 SCALE = 1.f/255.f; -    mV[VRED] = color4u.mV[VRED] * SCALE; -    mV[VGREEN] = color4u.mV[VGREEN] * SCALE; -    mV[VBLUE] = color4u.mV[VBLUE] * SCALE; -    mV[VALPHA] = color4u.mV[VALPHA] * SCALE; +    constexpr F32 SCALE = 1.f / 255.f; +    mV[VRED]            = color4u.mV[VRED] * SCALE; +    mV[VGREEN]          = color4u.mV[VGREEN] * SCALE; +    mV[VBLUE]           = color4u.mV[VBLUE] * SCALE; +    mV[VALPHA]          = color4u.mV[VALPHA] * SCALE;  }  LLColor4::LLColor4(const LLVector4& vector4)  { -    mV[VRED] = vector4.mV[VRED]; +    mV[VRED]   = vector4.mV[VRED];      mV[VGREEN] = vector4.mV[VGREEN]; -    mV[VBLUE] = vector4.mV[VBLUE]; +    mV[VBLUE]  = vector4.mV[VBLUE];      mV[VALPHA] = vector4.mV[VALPHA];  }  const LLColor4& LLColor4::set(const LLColor4U& color4u)  { -    const F32 SCALE = 1.f/255.f; -    mV[VRED] = color4u.mV[VRED] * SCALE; -    mV[VGREEN] = color4u.mV[VGREEN] * SCALE; -    mV[VBLUE] = color4u.mV[VBLUE] * SCALE; -    mV[VALPHA] = color4u.mV[VALPHA] * SCALE; +    constexpr F32 SCALE = 1.f / 255.f; +    mV[VRED]            = color4u.mV[VRED] * SCALE; +    mV[VGREEN]          = color4u.mV[VGREEN] * SCALE; +    mV[VBLUE]           = color4u.mV[VBLUE] * SCALE; +    mV[VALPHA]          = color4u.mV[VALPHA] * SCALE;      return (*this);  } -const LLColor4& LLColor4::set(const LLColor3 &vec) +const LLColor4& LLColor4::set(const LLColor3& vec)  { -    mV[VRED] = vec.mV[VRED]; +    mV[VRED]   = vec.mV[VRED];      mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; +    mV[VBLUE]  = vec.mV[VBLUE]; -//  no change to alpha! -//  mV[VALPHA] = 1.f; +    //  no change to alpha! +    //  mV[VALPHA] = 1.f;      return (*this);  } -const LLColor4& LLColor4::set(const LLColor3 &vec, F32 a) +const LLColor4& LLColor4::set(const LLColor3& vec, F32 a)  { -    mV[VRED] = vec.mV[VRED]; +    mV[VRED]   = vec.mV[VRED];      mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; +    mV[VBLUE]  = vec.mV[VBLUE];      mV[VALPHA] = a;      return (*this);  } @@ -190,33 +189,33 @@ const LLColor4& LLColor4::set(const LLColor3 &vec, F32 a)  // deprecated -- use set()  const LLColor4& LLColor4::setVec(const LLColor4U& color4u)  { -    const F32 SCALE = 1.f/255.f; -    mV[VRED] = color4u.mV[VRED] * SCALE; -    mV[VGREEN] = color4u.mV[VGREEN] * SCALE; -    mV[VBLUE] = color4u.mV[VBLUE] * SCALE; -    mV[VALPHA] = color4u.mV[VALPHA] * SCALE; +    constexpr F32 SCALE = 1.f / 255.f; +    mV[VRED]            = color4u.mV[VRED] * SCALE; +    mV[VGREEN]          = color4u.mV[VGREEN] * SCALE; +    mV[VBLUE]           = color4u.mV[VBLUE] * SCALE; +    mV[VALPHA]          = color4u.mV[VALPHA] * SCALE;      return (*this);  }  // deprecated -- use set() -const LLColor4& LLColor4::setVec(const LLColor3 &vec) +const LLColor4& LLColor4::setVec(const LLColor3& vec)  { -    mV[VRED] = vec.mV[VRED]; +    mV[VRED]   = vec.mV[VRED];      mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; +    mV[VBLUE]  = vec.mV[VBLUE]; -//  no change to alpha! -//  mV[VALPHA] = 1.f; +    //  no change to alpha! +    //  mV[VALPHA] = 1.f;      return (*this);  }  // deprecated -- use set() -const LLColor4& LLColor4::setVec(const LLColor3 &vec, F32 a) +const LLColor4& LLColor4::setVec(const LLColor3& vec, F32 a)  { -    mV[VRED] = vec.mV[VRED]; +    mV[VRED]   = vec.mV[VRED];      mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; +    mV[VBLUE]  = vec.mV[VBLUE];      mV[VALPHA] = a;      return (*this);  } @@ -228,110 +227,110 @@ void LLColor4::setValue(const LLSD& sd)      F32 val;      bool out_of_range = false;      val = sd[0].asReal(); -    mV[0] = llclamp(val, 0.f, 1.f); -    out_of_range = mV[0] != val; +    mV[VRED] = llclamp(val, 0.f, 1.f); +    out_of_range = mV[VRED] != val;      val = sd[1].asReal(); -    mV[1] = llclamp(val, 0.f, 1.f); -    out_of_range |= mV[1] != val; +    mV[VGREEN] = llclamp(val, 0.f, 1.f); +    out_of_range |= mV[VGREEN] != val;      val = sd[2].asReal(); -    mV[2] = llclamp(val, 0.f, 1.f); -    out_of_range |= mV[2] != val; +    mV[VBLUE] = llclamp(val, 0.f, 1.f); +    out_of_range |= mV[VBLUE] != val;      val = sd[3].asReal(); -    mV[3] = llclamp(val, 0.f, 1.f); -    out_of_range |= mV[3] != val; +    mV[VALPHA] = llclamp(val, 0.f, 1.f); +    out_of_range |= mV[VALPHA] != val;      if (out_of_range)      {          LL_WARNS() << "LLSD color value out of range!" << LL_ENDL;      }  #else -    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[VRED]   = (F32)sd[VRED].asReal(); +    mV[VGREEN] = (F32)sd[VGREEN].asReal(); +    mV[VBLUE]  = (F32)sd[VBLUE].asReal(); +    mV[VALPHA] = (F32)sd[VALPHA].asReal();  #endif  } -const LLColor4& LLColor4::operator=(const LLColor3 &a) +const LLColor4& LLColor4::operator=(const LLColor3& a)  { -    mV[VRED] = a.mV[VRED]; +    mV[VRED]   = a.mV[VRED];      mV[VGREEN] = a.mV[VGREEN]; -    mV[VBLUE] = a.mV[VBLUE]; +    mV[VBLUE]  = a.mV[VBLUE]; -// converting from an rgb sets a=1 (opaque) +    // converting from an rgb sets a=1 (opaque)      mV[VALPHA] = 1.f;      return (*this);  } - -std::ostream& operator<<(std::ostream& s, const LLColor4 &a) +std::ostream& operator<<(std::ostream& s, const LLColor4& a)  {      s << "{ " << a.mV[VRED] << ", " << a.mV[VGREEN] << ", " << a.mV[VBLUE] << ", " << a.mV[VALPHA] << " }";      return s;  } -bool operator==(const LLColor4 &a, const LLColor3 &b) +bool operator==(const LLColor4& a, const LLColor3& b)  { -    return (  (a.mV[VRED] == b.mV[VRED]) -            &&(a.mV[VGREEN] == b.mV[VGREEN]) -            &&(a.mV[VBLUE] == b.mV[VBLUE])); +    return ((a.mV[VRED] == b.mV[VRED]) && (a.mV[VGREEN] == b.mV[VGREEN]) && (a.mV[VBLUE] == b.mV[VBLUE]));  } -bool operator!=(const LLColor4 &a, const LLColor3 &b) +bool operator!=(const LLColor4& a, const LLColor3& b)  { -    return (  (a.mV[VRED] != b.mV[VRED]) -            ||(a.mV[VGREEN] != b.mV[VGREEN]) -            ||(a.mV[VBLUE] != b.mV[VBLUE])); +    return ((a.mV[VRED] != b.mV[VRED]) || (a.mV[VGREEN] != b.mV[VGREEN]) || (a.mV[VBLUE] != b.mV[VBLUE]));  } -LLColor3    vec4to3(const LLColor4 &vec) +LLColor3 vec4to3(const LLColor4& vec)  { -    LLColor3    temp(vec.mV[VRED], vec.mV[VGREEN], vec.mV[VBLUE]); +    LLColor3 temp(vec.mV[VRED], vec.mV[VGREEN], vec.mV[VBLUE]);      return temp;  } -LLColor4    vec3to4(const LLColor3 &vec) +LLColor4 vec3to4(const LLColor3& vec)  { -    LLColor3    temp(vec.mV[VRED], vec.mV[VGREEN], vec.mV[VBLUE]); +    LLColor3 temp(vec.mV[VRED], vec.mV[VGREEN], vec.mV[VBLUE]);      return temp;  } -static F32 hueToRgb ( F32 val1In, F32 val2In, F32 valHUeIn ) +static F32 hueToRgb(F32 val1In, F32 val2In, F32 valHUeIn)  { -    if ( valHUeIn < 0.0f ) valHUeIn += 1.0f; -    if ( valHUeIn > 1.0f ) valHUeIn -= 1.0f; -    if ( ( 6.0f * valHUeIn ) < 1.0f ) return ( val1In + ( val2In - val1In ) * 6.0f * valHUeIn ); -    if ( ( 2.0f * valHUeIn ) < 1.0f ) return ( val2In ); -    if ( ( 3.0f * valHUeIn ) < 2.0f ) return ( val1In + ( val2In - val1In ) * ( ( 2.0f / 3.0f ) - valHUeIn ) * 6.0f ); -    return ( val1In ); +    if (valHUeIn < 0.0f) +        valHUeIn += 1.0f; +    if (valHUeIn > 1.0f) +        valHUeIn -= 1.0f; +    if ((6.0f * valHUeIn) < 1.0f) +        return (val1In + (val2In - val1In) * 6.0f * valHUeIn); +    if ((2.0f * valHUeIn) < 1.0f) +        return (val2In); +    if ((3.0f * valHUeIn) < 2.0f) +        return (val1In + (val2In - val1In) * ((2.0f / 3.0f) - valHUeIn) * 6.0f); +    return (val1In);  } -void LLColor4::setHSL ( F32 hValIn, F32 sValIn, F32 lValIn) +void LLColor4::setHSL(F32 hValIn, F32 sValIn, F32 lValIn)  { -    if ( sValIn < 0.00001f ) +    if (sValIn < 0.00001f)      { -        mV[VRED] = lValIn; +        mV[VRED]   = lValIn;          mV[VGREEN] = lValIn; -        mV[VBLUE] = lValIn; +        mV[VBLUE]  = lValIn;      }      else      {          F32 interVal1;          F32 interVal2; -        if ( lValIn < 0.5f ) -            interVal2 = lValIn * ( 1.0f + sValIn ); +        if (lValIn < 0.5f) +            interVal2 = lValIn * (1.0f + sValIn);          else -            interVal2 = ( lValIn + sValIn ) - ( sValIn * lValIn ); +            interVal2 = (lValIn + sValIn) - (sValIn * lValIn);          interVal1 = 2.0f * lValIn - interVal2; -        mV[VRED] = hueToRgb ( interVal1, interVal2, hValIn + ( 1.f / 3.f ) ); -        mV[VGREEN] = hueToRgb ( interVal1, interVal2, hValIn ); -        mV[VBLUE] = hueToRgb ( interVal1, interVal2, hValIn - ( 1.f / 3.f ) ); +        mV[VRED]   = hueToRgb(interVal1, interVal2, hValIn + (1.f / 3.f)); +        mV[VGREEN] = hueToRgb(interVal1, interVal2, hValIn); +        mV[VBLUE]  = hueToRgb(interVal1, interVal2, hValIn - (1.f / 3.f));      }  } @@ -341,58 +340,61 @@ void LLColor4::calcHSL(F32* hue, F32* saturation, F32* luminance) const      F32 var_G = mV[VGREEN];      F32 var_B = mV[VBLUE]; -    F32 var_Min = ( var_R < ( var_G < var_B ? var_G : var_B ) ? var_R : ( var_G < var_B ? var_G : var_B ) ); -    F32 var_Max = ( var_R > ( var_G > var_B ? var_G : var_B ) ? var_R : ( var_G > var_B ? var_G : var_B ) ); +    F32 var_Min = (var_R < (var_G < var_B ? var_G : var_B) ? var_R : (var_G < var_B ? var_G : var_B)); +    F32 var_Max = (var_R > (var_G > var_B ? var_G : var_B) ? var_R : (var_G > var_B ? var_G : var_B));      F32 del_Max = var_Max - var_Min; -    F32 L = ( var_Max + var_Min ) / 2.0f; +    F32 L = (var_Max + var_Min) / 2.0f;      F32 H = 0.0f;      F32 S = 0.0f; -    if ( del_Max == 0.0f ) +    if (del_Max == 0.0f)      { -       H = 0.0f; -       S = 0.0f; +        H = 0.0f; +        S = 0.0f;      }      else      { -        if ( L < 0.5 ) -            S = del_Max / ( var_Max + var_Min ); +        if (L < 0.5f) +            S = del_Max / (var_Max + var_Min);          else -            S = del_Max / ( 2.0f - var_Max - var_Min ); +            S = del_Max / (2.0f - var_Max - var_Min); -        F32 del_R = ( ( ( var_Max - var_R ) / 6.0f ) + ( del_Max / 2.0f ) ) / del_Max; -        F32 del_G = ( ( ( var_Max - var_G ) / 6.0f ) + ( del_Max / 2.0f ) ) / del_Max; -        F32 del_B = ( ( ( var_Max - var_B ) / 6.0f ) + ( del_Max / 2.0f ) ) / del_Max; +        F32 del_R = (((var_Max - var_R) / 6.0f) + (del_Max / 2.0f)) / del_Max; +        F32 del_G = (((var_Max - var_G) / 6.0f) + (del_Max / 2.0f)) / del_Max; +        F32 del_B = (((var_Max - var_B) / 6.0f) + (del_Max / 2.0f)) / del_Max; -        if ( var_R >= var_Max ) +        if (var_R >= var_Max)              H = del_B - del_G; -        else -        if ( var_G >= var_Max ) -            H = ( 1.0f / 3.0f ) + del_R - del_B; -        else -        if ( var_B >= var_Max ) -            H = ( 2.0f / 3.0f ) + del_G - del_R; - -        if ( H < 0.0f ) H += 1.0f; -        if ( H > 1.0f ) H -= 1.0f; +        else if (var_G >= var_Max) +            H = (1.0f / 3.0f) + del_R - del_B; +        else if (var_B >= var_Max) +            H = (2.0f / 3.0f) + del_G - del_R; + +        if (H < 0.0f) +            H += 1.0f; +        if (H > 1.0f) +            H -= 1.0f;      } -    if (hue) *hue = H; -    if (saturation) *saturation = S; -    if (luminance) *luminance = L; +    if (hue) +        *hue = H; +    if (saturation) +        *saturation = S; +    if (luminance) +        *luminance = L;  }  // static  bool LLColor4::parseColor(const std::string& buf, LLColor4* color)  { -    if( buf.empty() || color == nullptr) +    if (buf.empty() || color == nullptr)      {          return false;      } -    boost_tokenizer tokens(buf, boost::char_separator<char>(", ")); +    boost_tokenizer           tokens(buf, boost::char_separator<char>(", "));      boost_tokenizer::iterator token_iter = tokens.begin();      if (token_iter == tokens.end())      { @@ -401,16 +403,16 @@ bool LLColor4::parseColor(const std::string& buf, LLColor4* color)      // Grab the first token into a string, since we don't know      // if this is a float or a color name. -    std::string color_name( (*token_iter) ); +    std::string color_name((*token_iter));      ++token_iter;      if (token_iter != tokens.end())      {          // There are more tokens to read.  This must be a vector.          LLColor4 v; -        LLStringUtil::convertToF32( color_name,  v.mV[VRED] ); -        LLStringUtil::convertToF32( *token_iter, v.mV[VGREEN] ); -        v.mV[VBLUE] = 0.0f; +        LLStringUtil::convertToF32(color_name, v.mV[VRED]); +        LLStringUtil::convertToF32(*token_iter, v.mV[VGREEN]); +        v.mV[VBLUE]  = 0.0f;          v.mV[VALPHA] = 1.0f;          ++token_iter; @@ -422,283 +424,284 @@ bool LLColor4::parseColor(const std::string& buf, LLColor4* color)          else          {              // There is a z-component. -            LLStringUtil::convertToF32( *token_iter, v.mV[VBLUE] ); +            LLStringUtil::convertToF32(*token_iter, v.mV[VBLUE]);              ++token_iter;              if (token_iter != tokens.end())              {                  // There is an alpha component. -                LLStringUtil::convertToF32( *token_iter, v.mV[VALPHA] ); +                LLStringUtil::convertToF32(*token_iter, v.mV[VALPHA]);              }          }          //  Make sure all values are between 0 and 1.          if (v.mV[VRED] > 1.f || v.mV[VGREEN] > 1.f || v.mV[VBLUE] > 1.f || v.mV[VALPHA] > 1.f)          { -            v = v * (1.f / 255.f); +            constexpr F32 SCALE{ 1.f / 255.f }; +            v *= SCALE;          } -        color->set( v ); +        color->set(v);      }      else // Single value.  Read as a named color.      {          // We have a color name -        if ( "red" == color_name ) +        if ("red" == color_name)          {              color->set(LLColor4::red);          } -        else if ( "red1" == color_name ) +        else if ("red1" == color_name)          {              color->set(LLColor4::red1);          } -        else if ( "red2" == color_name ) +        else if ("red2" == color_name)          {              color->set(LLColor4::red2);          } -        else if ( "red3" == color_name ) +        else if ("red3" == color_name)          {              color->set(LLColor4::red3);          } -        else if ( "red4" == color_name ) +        else if ("red4" == color_name)          {              color->set(LLColor4::red4);          } -        else if ( "red5" == color_name ) +        else if ("red5" == color_name)          {              color->set(LLColor4::red5);          } -        else if( "green" == color_name ) +        else if ("green" == color_name)          {              color->set(LLColor4::green);          } -        else if( "green1" == color_name ) +        else if ("green1" == color_name)          {              color->set(LLColor4::green1);          } -        else if( "green2" == color_name ) +        else if ("green2" == color_name)          {              color->set(LLColor4::green2);          } -        else if( "green3" == color_name ) +        else if ("green3" == color_name)          {              color->set(LLColor4::green3);          } -        else if( "green4" == color_name ) +        else if ("green4" == color_name)          {              color->set(LLColor4::green4);          } -        else if( "green5" == color_name ) +        else if ("green5" == color_name)          {              color->set(LLColor4::green5);          } -        else if( "green6" == color_name ) +        else if ("green6" == color_name)          {              color->set(LLColor4::green6);          } -        else if( "blue" == color_name ) +        else if ("blue" == color_name)          {              color->set(LLColor4::blue);          } -        else if( "blue1" == color_name ) +        else if ("blue1" == color_name)          {              color->set(LLColor4::blue1);          } -        else if( "blue2" == color_name ) +        else if ("blue2" == color_name)          {              color->set(LLColor4::blue2);          } -        else if( "blue3" == color_name ) +        else if ("blue3" == color_name)          {              color->set(LLColor4::blue3);          } -        else if( "blue4" == color_name ) +        else if ("blue4" == color_name)          {              color->set(LLColor4::blue4);          } -        else if( "blue5" == color_name ) +        else if ("blue5" == color_name)          {              color->set(LLColor4::blue5);          } -        else if( "blue6" == color_name ) +        else if ("blue6" == color_name)          {              color->set(LLColor4::blue6);          } -        else if( "black" == color_name ) +        else if ("black" == color_name)          {              color->set(LLColor4::black);          } -        else if( "white" == color_name ) +        else if ("white" == color_name)          {              color->set(LLColor4::white);          } -        else if( "yellow" == color_name ) +        else if ("yellow" == color_name)          {              color->set(LLColor4::yellow);          } -        else if( "yellow1" == color_name ) +        else if ("yellow1" == color_name)          {              color->set(LLColor4::yellow1);          } -        else if( "yellow2" == color_name ) +        else if ("yellow2" == color_name)          {              color->set(LLColor4::yellow2);          } -        else if( "yellow3" == color_name ) +        else if ("yellow3" == color_name)          {              color->set(LLColor4::yellow3);          } -        else if( "yellow4" == color_name ) +        else if ("yellow4" == color_name)          {              color->set(LLColor4::yellow4);          } -        else if( "yellow5" == color_name ) +        else if ("yellow5" == color_name)          {              color->set(LLColor4::yellow5);          } -        else if( "yellow6" == color_name ) +        else if ("yellow6" == color_name)          {              color->set(LLColor4::yellow6);          } -        else if( "magenta" == color_name ) +        else if ("magenta" == color_name)          {              color->set(LLColor4::magenta);          } -        else if( "magenta1" == color_name ) +        else if ("magenta1" == color_name)          {              color->set(LLColor4::magenta1);          } -        else if( "magenta2" == color_name ) +        else if ("magenta2" == color_name)          {              color->set(LLColor4::magenta2);          } -        else if( "magenta3" == color_name ) +        else if ("magenta3" == color_name)          {              color->set(LLColor4::magenta3);          } -        else if( "magenta4" == color_name ) +        else if ("magenta4" == color_name)          {              color->set(LLColor4::magenta4);          } -        else if( "purple" == color_name ) +        else if ("purple" == color_name)          {              color->set(LLColor4::purple);          } -        else if( "purple1" == color_name ) +        else if ("purple1" == color_name)          {              color->set(LLColor4::purple1);          } -        else if( "purple2" == color_name ) +        else if ("purple2" == color_name)          {              color->set(LLColor4::purple2);          } -        else if( "purple3" == color_name ) +        else if ("purple3" == color_name)          {              color->set(LLColor4::purple3);          } -        else if( "purple4" == color_name ) +        else if ("purple4" == color_name)          {              color->set(LLColor4::purple4);          } -        else if( "purple5" == color_name ) +        else if ("purple5" == color_name)          {              color->set(LLColor4::purple5);          } -        else if( "purple6" == color_name ) +        else if ("purple6" == color_name)          {              color->set(LLColor4::purple6);          } -        else if( "pink" == color_name ) +        else if ("pink" == color_name)          {              color->set(LLColor4::pink);          } -        else if( "pink1" == color_name ) +        else if ("pink1" == color_name)          {              color->set(LLColor4::pink1);          } -        else if( "pink2" == color_name ) +        else if ("pink2" == color_name)          {              color->set(LLColor4::pink2);          } -        else if( "cyan" == color_name ) +        else if ("cyan" == color_name)          {              color->set(LLColor4::cyan);          } -        else if( "cyan1" == color_name ) +        else if ("cyan1" == color_name)          {              color->set(LLColor4::cyan1);          } -        else if( "cyan2" == color_name ) +        else if ("cyan2" == color_name)          {              color->set(LLColor4::cyan2);          } -        else if( "cyan3" == color_name ) +        else if ("cyan3" == color_name)          {              color->set(LLColor4::cyan3);          } -        else if( "cyan4" == color_name ) +        else if ("cyan4" == color_name)          {              color->set(LLColor4::cyan4);          } -        else if( "cyan5" == color_name ) +        else if ("cyan5" == color_name)          {              color->set(LLColor4::cyan5);          } -        else if( "cyan6" == color_name ) +        else if ("cyan6" == color_name)          {              color->set(LLColor4::cyan6);          } -        else if( "smoke" == color_name ) +        else if ("smoke" == color_name)          {              color->set(LLColor4::smoke);          } -        else if( "grey" == color_name ) +        else if ("grey" == color_name)          {              color->set(LLColor4::grey);          } -        else if( "grey1" == color_name ) +        else if ("grey1" == color_name)          {              color->set(LLColor4::grey1);          } -        else if( "grey2" == color_name ) +        else if ("grey2" == color_name)          {              color->set(LLColor4::grey2);          } -        else if( "grey3" == color_name ) +        else if ("grey3" == color_name)          {              color->set(LLColor4::grey3);          } -        else if( "grey4" == color_name ) +        else if ("grey4" == color_name)          {              color->set(LLColor4::grey4);          } -        else if( "orange" == color_name ) +        else if ("orange" == color_name)          {              color->set(LLColor4::orange);          } -        else if( "orange1" == color_name ) +        else if ("orange1" == color_name)          {              color->set(LLColor4::orange1);          } -        else if( "orange2" == color_name ) +        else if ("orange2" == color_name)          {              color->set(LLColor4::orange2);          } -        else if( "orange3" == color_name ) +        else if ("orange3" == color_name)          {              color->set(LLColor4::orange3);          } -        else if( "orange4" == color_name ) +        else if ("orange4" == color_name)          {              color->set(LLColor4::orange4);          } -        else if( "orange5" == color_name ) +        else if ("orange5" == color_name)          {              color->set(LLColor4::orange5);          } -        else if( "orange6" == color_name ) +        else if ("orange6" == color_name)          {              color->set(LLColor4::orange6);          } -        else if ( "clear" == color_name ) +        else if ("clear" == color_name)          {              color->set(0.f, 0.f, 0.f, 0.f);          } @@ -714,21 +717,21 @@ bool LLColor4::parseColor(const std::string& buf, LLColor4* color)  // static  bool LLColor4::parseColor4(const std::string& buf, LLColor4* value)  { -    if( buf.empty() || value == nullptr) +    if (buf.empty() || value == nullptr)      {          return false;      }      LLColor4 v; -    S32 count = sscanf( buf.c_str(), "%f, %f, %f, %f", v.mV + 0, v.mV + 1, v.mV + 2, v.mV + 3 ); -    if (1 == count ) +    S32      count = sscanf(buf.c_str(), "%f, %f, %f, %f", v.mV + 0, v.mV + 1, v.mV + 2, v.mV + 3); +    if (1 == count)      {          // try this format -        count = sscanf( buf.c_str(), "%f %f %f %f", v.mV + 0, v.mV + 1, v.mV + 2, v.mV + 3 ); +        count = sscanf(buf.c_str(), "%f %f %f %f", v.mV + 0, v.mV + 1, v.mV + 2, v.mV + 3);      } -    if( 4 == count ) +    if (4 == count)      { -        value->setVec( v ); +        value->setVec(v);          return true;      } diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index cafdbd9d7c..2f1cb21113 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -28,7 +28,6 @@  #define LL_V4COLOR_H  #include "llerror.h" -//#include "vmath.h"  #include "llmath.h"  #include "llsd.h" @@ -38,213 +37,212 @@ class LLVector4;  //  LLColor4 = |x y z w| -static const U32 LENGTHOFCOLOR4 = 4; +static constexpr U32 LENGTHOFCOLOR4 = 4; -static const U32 MAX_LENGTH_OF_COLOR_NAME = 15; //Give plenty of room for additional colors... +static constexpr U32 MAX_LENGTH_OF_COLOR_NAME = 15; // Give plenty of room for additional colors...  class LLColor4  { -    public: -        F32 mV[LENGTHOFCOLOR4]; -        LLColor4();                     // Initializes LLColor4 to (0, 0, 0, 1) -        LLColor4(F32 r, F32 g, F32 b);      // Initializes LLColor4 to (r, g, b, 1) -        LLColor4(F32 r, F32 g, F32 b, F32 a);       // Initializes LLColor4 to (r. g, b, a) -        LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) -        explicit LLColor4(const LLSD& sd); -        explicit LLColor4(const F32 *vec);          // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1) -        explicit LLColor4(U32 clr);                         // Initializes LLColor4 to (r=clr>>24, etc)) -        explicit LLColor4(const LLColor4U& color4u);  // "explicit" to avoid automatic conversion -        explicit LLColor4(const LLVector4& vector4);  // "explicit" to avoid automatic conversion - -        LLSD getValue() const -        { -            LLSD ret; -            ret[0] = mV[0]; -            ret[1] = mV[1]; -            ret[2] = mV[2]; -            ret[3] = mV[3]; -            return ret; -        } - -        void setValue(const LLSD& sd); - -        void setHSL(F32 hue, F32 saturation, F32 luminance); -        void calcHSL(F32* hue, F32* saturation, F32* luminance) const; - -        const LLColor4& setToBlack();                       // zero LLColor4 to (0, 0, 0, 1) -        const LLColor4& setToWhite();                       // zero LLColor4 to (0, 0, 0, 1) - -        const LLColor4& setVec(F32 r, F32 g, F32 b, F32 a); // deprecated -- use set() -        const LLColor4& setVec(F32 r, F32 g, F32 b);        // deprecated -- use set() -        const LLColor4& setVec(const LLColor4 &vec);        // deprecated -- use set() -        const LLColor4& setVec(const LLColor3 &vec);        // deprecated -- use set() -        const LLColor4& setVec(const LLColor3 &vec, F32 a); // deprecated -- use set() -        const LLColor4& setVec(const F32 *vec);             // deprecated -- use set() -        const LLColor4& setVec(const LLColor4U& color4u);   // deprecated -- use set() - -        const LLColor4& set(F32 r, F32 g, F32 b, F32 a);    // Sets LLColor4 to (r, g, b, a) -        const LLColor4& set(F32 r, F32 g, F32 b);   // Sets LLColor4 to (r, g, b) (no change in a) -        const LLColor4& set(const LLColor4 &vec);   // Sets LLColor4 to vec -        const LLColor4& set(const LLColor3 &vec);   // Sets LLColor4 to LLColor3 vec (no change in alpha) -        const LLColor4& set(const LLColor3 &vec, F32 a);    // Sets LLColor4 to LLColor3 vec, with alpha specified -        const LLColor4& set(const F32 *vec);            // Sets LLColor4 to vec -        const LLColor4& set(const F64 *vec);            // Sets LLColor4 to (double)vec -        const LLColor4& set(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled. - -        // set from a vector of unknown type and size -        // may leave some data unmodified -        template<typename T> -        const LLColor4& set(const std::vector<T>& v); - -        // write to a vector of unknown type and size -        // maye leave some data unmodified -        template<typename T> -        void write(std::vector<T>& v) const; - -        const LLColor4&    setAlpha(F32 a); - -        F32         magVec() const;             // deprecated -- use length() -        F32         magVecSquared() const;      // deprecated -- use lengthSquared() -        F32         normVec();                  // deprecated -- use normalize() - -        F32         length() const;             // Returns magnitude of LLColor4 -        F32         lengthSquared() const;      // Returns magnitude squared of LLColor4 -        F32         normalize();                // deprecated -- use normalize() - -        bool        isOpaque() { return mV[VALPHA] == 1.f; } - -        F32 operator[](int idx) const { return mV[idx]; } -        F32 &operator[](int idx) { return mV[idx]; } - -        const LLColor4& operator=(const LLColor3 &a);   // Assigns vec3 to vec4 and returns vec4 - -        bool operator<(const LLColor4& rhs) const; -        friend std::ostream&     operator<<(std::ostream& s, const LLColor4 &a);        // Print a -        friend LLColor4 operator+(const LLColor4 &a, const LLColor4 &b);    // Return vector a + b -        friend LLColor4 operator-(const LLColor4 &a, const LLColor4 &b);    // Return vector a minus b -        friend LLColor4 operator*(const LLColor4 &a, const LLColor4 &b);    // Return component wise a * b -        friend LLColor4 operator*(const LLColor4 &a, F32 k);                // Return rgb times scaler k (no alpha change) -        friend LLColor4 operator/(const LLColor4 &a, F32 k);                // Return rgb divided by scalar k (no alpha change) -        friend LLColor4 operator*(F32 k, const LLColor4 &a);                // Return rgb times scaler k (no alpha change) -        friend LLColor4 operator%(const LLColor4 &a, F32 k);                // Return alpha times scaler k (no rgb change) -        friend LLColor4 operator%(F32 k, const LLColor4 &a);                // Return alpha times scaler k (no rgb change) - -        friend bool operator==(const LLColor4 &a, const LLColor4 &b);       // Return a == b -        friend bool operator!=(const LLColor4 &a, const LLColor4 &b);       // Return a != b - -        friend bool operator==(const LLColor4 &a, const LLColor3 &b);       // Return a == b -        friend bool operator!=(const LLColor4 &a, const LLColor3 &b);       // Return a != b - -        friend const LLColor4& operator+=(LLColor4 &a, const LLColor4 &b);  // Return vector a + b -        friend const LLColor4& operator-=(LLColor4 &a, const LLColor4 &b);  // Return vector a minus b -        friend const LLColor4& operator*=(LLColor4 &a, F32 k);              // Return rgb times scaler k (no alpha change) -        friend const LLColor4& operator%=(LLColor4 &a, F32 k);              // Return alpha times scaler k (no rgb change) - -        friend const LLColor4& operator*=(LLColor4 &a, const LLColor4 &b); // Doesn't multiply alpha! (for lighting) - -        // conversion -        operator LLColor4U() const; - -        // Basic color values. -        static LLColor4 red; -        static LLColor4 green; -        static LLColor4 blue; -        static LLColor4 black; -        static LLColor4 white; -        static LLColor4 yellow; -        static LLColor4 magenta; -        static LLColor4 cyan; -        static LLColor4 smoke; -        static LLColor4 grey; -        static LLColor4 orange; -        static LLColor4 purple; -        static LLColor4 pink; -        static LLColor4 transparent; - -        // Extra color values. -        static LLColor4 grey1; -        static LLColor4 grey2; -        static LLColor4 grey3; -        static LLColor4 grey4; - -        static LLColor4 red1; -        static LLColor4 red2; -        static LLColor4 red3; -        static LLColor4 red4; -        static LLColor4 red5; - -        static LLColor4 green1; -        static LLColor4 green2; -        static LLColor4 green3; -        static LLColor4 green4; -        static LLColor4 green5; -        static LLColor4 green6; - -        static LLColor4 blue1; -        static LLColor4 blue2; -        static LLColor4 blue3; -        static LLColor4 blue4; -        static LLColor4 blue5; -        static LLColor4 blue6; - -        static LLColor4 yellow1; -        static LLColor4 yellow2; -        static LLColor4 yellow3; -        static LLColor4 yellow4; -        static LLColor4 yellow5; -        static LLColor4 yellow6; -        static LLColor4 yellow7; -        static LLColor4 yellow8; -        static LLColor4 yellow9; - -        static LLColor4 orange1; -        static LLColor4 orange2; -        static LLColor4 orange3; -        static LLColor4 orange4; -        static LLColor4 orange5; -        static LLColor4 orange6; - -        static LLColor4 magenta1; -        static LLColor4 magenta2; -        static LLColor4 magenta3; -        static LLColor4 magenta4; - -        static LLColor4 purple1; -        static LLColor4 purple2; -        static LLColor4 purple3; -        static LLColor4 purple4; -        static LLColor4 purple5; -        static LLColor4 purple6; - -        static LLColor4 pink1; -        static LLColor4 pink2; - -        static LLColor4 cyan1; -        static LLColor4 cyan2; -        static LLColor4 cyan3; -        static LLColor4 cyan4; -        static LLColor4 cyan5; -        static LLColor4 cyan6; - -        static bool parseColor(const std::string& buf, LLColor4* color); -        static bool parseColor4(const std::string& buf, LLColor4* color); - -        inline void clamp(); -}; +public: +    F32 mV[LENGTHOFCOLOR4]; +    LLColor4();                                 // Initializes LLColor4 to (0, 0, 0, 1) +    LLColor4(F32 r, F32 g, F32 b);              // Initializes LLColor4 to (r, g, b, 1) +    LLColor4(F32 r, F32 g, F32 b, F32 a);       // Initializes LLColor4 to (r. g, b, a) +    LLColor4(const LLColor3& vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) +    explicit LLColor4(const LLSD& sd); +    explicit LLColor4(const F32* vec);           // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1) +    explicit LLColor4(U32 clr);                  // Initializes LLColor4 to (r=clr>>24, etc)) +    explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion +    explicit LLColor4(const LLVector4& vector4); // "explicit" to avoid automatic conversion + +    LLSD getValue() const +    { +        LLSD ret; +        ret[VRED]   = mV[VRED]; +        ret[VGREEN] = mV[VGREEN]; +        ret[VBLUE]  = mV[VBLUE]; +        ret[VALPHA] = mV[VALPHA]; +        return ret; +    } +    void setValue(const LLSD& sd); + +    void setHSL(F32 hue, F32 saturation, F32 luminance); +    void calcHSL(F32* hue, F32* saturation, F32* luminance) const; + +    const LLColor4& setToBlack(); // zero LLColor4 to (0, 0, 0, 1) +    const LLColor4& setToWhite(); // zero LLColor4 to (0, 0, 0, 1) + +    const LLColor4& setVec(F32 r, F32 g, F32 b, F32 a); // deprecated -- use set() +    const LLColor4& setVec(F32 r, F32 g, F32 b);        // deprecated -- use set() +    const LLColor4& setVec(const LLColor4& vec);        // deprecated -- use set() +    const LLColor4& setVec(const LLColor3& vec);        // deprecated -- use set() +    const LLColor4& setVec(const LLColor3& vec, F32 a); // deprecated -- use set() +    const LLColor4& setVec(const F32* vec);             // deprecated -- use set() +    const LLColor4& setVec(const LLColor4U& color4u);   // deprecated -- use set() + +    const LLColor4& set(F32 r, F32 g, F32 b, F32 a); // Sets LLColor4 to (r, g, b, a) +    const LLColor4& set(F32 r, F32 g, F32 b);        // Sets LLColor4 to (r, g, b) (no change in a) +    const LLColor4& set(const LLColor4& vec);        // Sets LLColor4 to vec +    const LLColor4& set(const LLColor3& vec);        // Sets LLColor4 to LLColor3 vec (no change in alpha) +    const LLColor4& set(const LLColor3& vec, F32 a); // Sets LLColor4 to LLColor3 vec, with alpha specified +    const LLColor4& set(const F32* vec);             // Sets LLColor4 to vec +    const LLColor4& set(const F64* vec);             // Sets LLColor4 to (double)vec +    const LLColor4& set(const LLColor4U& color4u);   // Sets LLColor4 to color4u, rescaled. + +    // set from a vector of unknown type and size +    // may leave some data unmodified +    template<typename T> +    const LLColor4& set(const std::vector<T>& v); + +    // write to a vector of unknown type and size +    // maye leave some data unmodified +    template<typename T> +    void write(std::vector<T>& v) const; + +    const LLColor4& setAlpha(F32 a); + +    F32 magVec() const;        // deprecated -- use length() +    F32 magVecSquared() const; // deprecated -- use lengthSquared() +    F32 normVec();             // deprecated -- use normalize() + +    F32 length() const;        // Returns magnitude of LLColor4 +    F32 lengthSquared() const; // Returns magnitude squared of LLColor4 +    F32 normalize();           // deprecated -- use normalize() + +    bool isOpaque() const { return mV[VALPHA] == 1.f; } + +    F32  operator[](int idx) const { return mV[idx]; } +    F32& operator[](int idx) { return mV[idx]; } + +    const LLColor4& operator=(const LLColor3& a); // Assigns vec3 to vec4 and returns vec4 + +    bool                 operator<(const LLColor4& rhs) const; +    friend std::ostream& operator<<(std::ostream& s, const LLColor4& a);  // Print a +    friend LLColor4      operator+(const LLColor4& a, const LLColor4& b); // Return vector a + b +    friend LLColor4      operator-(const LLColor4& a, const LLColor4& b); // Return vector a minus b +    friend LLColor4      operator*(const LLColor4& a, const LLColor4& b); // Return component wise a * b +    friend LLColor4      operator*(const LLColor4& a, F32 k);             // Return rgb times scaler k (no alpha change) +    friend LLColor4      operator/(const LLColor4& a, F32 k);             // Return rgb divided by scalar k (no alpha change) +    friend LLColor4      operator*(F32 k, const LLColor4& a);             // Return rgb times scaler k (no alpha change) +    friend LLColor4      operator%(const LLColor4& a, F32 k);             // Return alpha times scaler k (no rgb change) +    friend LLColor4      operator%(F32 k, const LLColor4& a);             // Return alpha times scaler k (no rgb change) + +    friend bool operator==(const LLColor4& a, const LLColor4& b); // Return a == b +    friend bool operator!=(const LLColor4& a, const LLColor4& b); // Return a != b + +    friend bool operator==(const LLColor4& a, const LLColor3& b); // Return a == b +    friend bool operator!=(const LLColor4& a, const LLColor3& b); // Return a != b + +    friend const LLColor4& operator+=(LLColor4& a, const LLColor4& b); // Return vector a + b +    friend const LLColor4& operator-=(LLColor4& a, const LLColor4& b); // Return vector a minus b +    friend const LLColor4& operator*=(LLColor4& a, F32 k);             // Return rgb times scaler k (no alpha change) +    friend const LLColor4& operator%=(LLColor4& a, F32 k);             // Return alpha times scaler k (no rgb change) + +    friend const LLColor4& operator*=(LLColor4& a, const LLColor4& b); // Doesn't multiply alpha! (for lighting) + +    // conversion +    operator LLColor4U() const; + +    // Basic color values. +    static LLColor4 red; +    static LLColor4 green; +    static LLColor4 blue; +    static LLColor4 black; +    static LLColor4 white; +    static LLColor4 yellow; +    static LLColor4 magenta; +    static LLColor4 cyan; +    static LLColor4 smoke; +    static LLColor4 grey; +    static LLColor4 orange; +    static LLColor4 purple; +    static LLColor4 pink; +    static LLColor4 transparent; + +    // Extra color values. +    static LLColor4 grey1; +    static LLColor4 grey2; +    static LLColor4 grey3; +    static LLColor4 grey4; + +    static LLColor4 red1; +    static LLColor4 red2; +    static LLColor4 red3; +    static LLColor4 red4; +    static LLColor4 red5; + +    static LLColor4 green1; +    static LLColor4 green2; +    static LLColor4 green3; +    static LLColor4 green4; +    static LLColor4 green5; +    static LLColor4 green6; + +    static LLColor4 blue1; +    static LLColor4 blue2; +    static LLColor4 blue3; +    static LLColor4 blue4; +    static LLColor4 blue5; +    static LLColor4 blue6; + +    static LLColor4 yellow1; +    static LLColor4 yellow2; +    static LLColor4 yellow3; +    static LLColor4 yellow4; +    static LLColor4 yellow5; +    static LLColor4 yellow6; +    static LLColor4 yellow7; +    static LLColor4 yellow8; +    static LLColor4 yellow9; + +    static LLColor4 orange1; +    static LLColor4 orange2; +    static LLColor4 orange3; +    static LLColor4 orange4; +    static LLColor4 orange5; +    static LLColor4 orange6; + +    static LLColor4 magenta1; +    static LLColor4 magenta2; +    static LLColor4 magenta3; +    static LLColor4 magenta4; + +    static LLColor4 purple1; +    static LLColor4 purple2; +    static LLColor4 purple3; +    static LLColor4 purple4; +    static LLColor4 purple5; +    static LLColor4 purple6; + +    static LLColor4 pink1; +    static LLColor4 pink2; + +    static LLColor4 cyan1; +    static LLColor4 cyan2; +    static LLColor4 cyan3; +    static LLColor4 cyan4; +    static LLColor4 cyan5; +    static LLColor4 cyan6; + +    static bool parseColor(const std::string& buf, LLColor4* color); +    static bool parseColor4(const std::string& buf, LLColor4* color); + +    inline void clamp(); +};  // Non-member functions -F32     distVec(const LLColor4 &a, const LLColor4 &b);          // Returns distance between a and b -F32     distVec_squared(const LLColor4 &a, const LLColor4 &b);  // Returns distance squared between a and b -LLColor3    vec4to3(const LLColor4 &vec); -LLColor4    vec3to4(const LLColor3 &vec); -LLColor4 lerp(const LLColor4 &a, const LLColor4 &b, F32 u); +F32      distVec(const LLColor4& a, const LLColor4& b);         // Returns distance between a and b +F32      distVec_squared(const LLColor4& a, const LLColor4& b); // Returns distance squared between a and b +LLColor3 vec4to3(const LLColor4& vec); +LLColor4 vec3to4(const LLColor3& vec); +LLColor4 lerp(const LLColor4& a, const LLColor4& b, F32 u); -inline LLColor4::LLColor4(void) +inline LLColor4::LLColor4()  { -    mV[VRED] = 0.f; +    mV[VRED]   = 0.f;      mV[VGREEN] = 0.f; -    mV[VBLUE] = 0.f; +    mV[VBLUE]  = 0.f;      mV[VALPHA] = 1.f;  } @@ -255,149 +253,146 @@ inline LLColor4::LLColor4(const LLSD& sd)  inline LLColor4::LLColor4(F32 r, F32 g, F32 b)  { -    mV[VRED] = r; +    mV[VRED]   = r;      mV[VGREEN] = g; -    mV[VBLUE] = b; +    mV[VBLUE]  = b;      mV[VALPHA] = 1.f;  }  inline LLColor4::LLColor4(F32 r, F32 g, F32 b, F32 a)  { -    mV[VRED] = r; +    mV[VRED]   = r;      mV[VGREEN] = g; -    mV[VBLUE] = b; +    mV[VBLUE]  = b;      mV[VALPHA] = a;  }  inline LLColor4::LLColor4(U32 clr)  { -    mV[VRED] = (clr&0xff) * (1.0f/255.0f); -    mV[VGREEN] = ((clr>>8)&0xff) * (1.0f/255.0f); -    mV[VBLUE] = ((clr>>16)&0xff) * (1.0f/255.0f); -    mV[VALPHA] = (clr>>24) * (1.0f/255.0f); +    mV[VRED]   = (clr & 0xff) * (1.0f / 255.0f); +    mV[VGREEN] = ((clr >> 8) & 0xff) * (1.0f / 255.0f); +    mV[VBLUE]  = ((clr >> 16) & 0xff) * (1.0f / 255.0f); +    mV[VALPHA] = (clr >> 24) * (1.0f / 255.0f);  } - -inline LLColor4::LLColor4(const F32 *vec) +inline LLColor4::LLColor4(const F32* vec)  { -    mV[VRED] = vec[VRED]; +    mV[VRED]   = vec[VRED];      mV[VGREEN] = vec[VGREEN]; -    mV[VBLUE] = vec[VBLUE]; +    mV[VBLUE]  = vec[VBLUE];      mV[VALPHA] = vec[VALPHA];  } -inline const LLColor4&  LLColor4::setToBlack(void) +inline const LLColor4& LLColor4::setToBlack(void)  { -    mV[VRED] = 0.f; +    mV[VRED]   = 0.f;      mV[VGREEN] = 0.f; -    mV[VBLUE] = 0.f; +    mV[VBLUE]  = 0.f;      mV[VALPHA] = 1.f;      return (*this);  } -inline const LLColor4&  LLColor4::setToWhite(void) +inline const LLColor4& LLColor4::setToWhite(void)  { -    mV[VRED] = 1.f; +    mV[VRED]   = 1.f;      mV[VGREEN] = 1.f; -    mV[VBLUE] = 1.f; +    mV[VBLUE]  = 1.f;      mV[VALPHA] = 1.f;      return (*this);  } -inline const LLColor4&  LLColor4::set(F32 x, F32 y, F32 z) +inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z)  { -    mV[VRED] = x; +    mV[VRED]   = x;      mV[VGREEN] = y; -    mV[VBLUE] = z; +    mV[VBLUE]  = z; -//  no change to alpha! -//  mV[VALPHA] = 1.f; +    //  no change to alpha! +    //  mV[VALPHA] = 1.f;      return (*this);  } -inline const LLColor4&  LLColor4::set(F32 x, F32 y, F32 z, F32 a) +inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z, F32 a)  { -    mV[VRED] = x; +    mV[VRED]   = x;      mV[VGREEN] = y; -    mV[VBLUE] = z; +    mV[VBLUE]  = z;      mV[VALPHA] = a;      return (*this);  } -inline const LLColor4&  LLColor4::set(const LLColor4 &vec) +inline const LLColor4& LLColor4::set(const LLColor4& vec)  { -    mV[VRED] = vec.mV[VRED]; +    mV[VRED]   = vec.mV[VRED];      mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; +    mV[VBLUE]  = vec.mV[VBLUE];      mV[VALPHA] = vec.mV[VALPHA];      return (*this);  } - -inline const LLColor4&  LLColor4::set(const F32 *vec) +inline const LLColor4& LLColor4::set(const F32* vec)  { -    mV[VRED] = vec[VRED]; +    mV[VRED]   = vec[VRED];      mV[VGREEN] = vec[VGREEN]; -    mV[VBLUE] = vec[VBLUE]; +    mV[VBLUE]  = vec[VBLUE];      mV[VALPHA] = vec[VALPHA];      return (*this);  } -inline const LLColor4&  LLColor4::set(const F64 *vec) +inline const LLColor4& LLColor4::set(const F64* vec)  { -    mV[VRED] = static_cast<F32>(vec[VRED]); +    mV[VRED]   = static_cast<F32>(vec[VRED]);      mV[VGREEN] = static_cast<F32>(vec[VGREEN]); -    mV[VBLUE] = static_cast<F32>(vec[VBLUE]); +    mV[VBLUE]  = static_cast<F32>(vec[VBLUE]);      mV[VALPHA] = static_cast<F32>(vec[VALPHA]);      return (*this);  }  // deprecated -inline const LLColor4&  LLColor4::setVec(F32 x, F32 y, F32 z) +inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z)  { -    mV[VRED] = x; +    mV[VRED]   = x;      mV[VGREEN] = y; -    mV[VBLUE] = z; +    mV[VBLUE]  = z; -//  no change to alpha! -//  mV[VALPHA] = 1.f; +    //  no change to alpha! +    //  mV[VALPHA] = 1.f;      return (*this);  }  // deprecated -inline const LLColor4&  LLColor4::setVec(F32 x, F32 y, F32 z, F32 a) +inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z, F32 a)  { -    mV[VRED] = x; +    mV[VRED]   = x;      mV[VGREEN] = y; -    mV[VBLUE] = z; +    mV[VBLUE]  = z;      mV[VALPHA] = a;      return (*this);  }  // deprecated -inline const LLColor4&  LLColor4::setVec(const LLColor4 &vec) +inline const LLColor4& LLColor4::setVec(const LLColor4& vec)  { -    mV[VRED] = vec.mV[VRED]; +    mV[VRED]   = vec.mV[VRED];      mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; +    mV[VBLUE]  = vec.mV[VBLUE];      mV[VALPHA] = vec.mV[VALPHA];      return (*this);  } -  // deprecated -inline const LLColor4&  LLColor4::setVec(const F32 *vec) +inline const LLColor4& LLColor4::setVec(const F32* vec)  { -    mV[VRED] = vec[VRED]; +    mV[VRED]   = vec[VRED];      mV[VGREEN] = vec[VGREEN]; -    mV[VBLUE] = vec[VBLUE]; +    mV[VBLUE]  = vec[VBLUE];      mV[VALPHA] = vec[VALPHA];      return (*this);  } -inline const LLColor4&  LLColor4::setAlpha(F32 a) +inline const LLColor4& LLColor4::setAlpha(F32 a)  {      mV[VALPHA] = a;      return (*this); @@ -405,155 +400,116 @@ inline const LLColor4&  LLColor4::setAlpha(F32 a)  // LLColor4 Magnitude and Normalization Functions -inline F32      LLColor4::length(void) const +inline F32 LLColor4::length() const  { -    return (F32) sqrt(mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]); +    return sqrt(mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE]);  } -inline F32      LLColor4::lengthSquared(void) const +inline F32 LLColor4::lengthSquared() const  { -    return mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]; +    return mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE];  } -inline F32      LLColor4::normalize(void) +inline F32 LLColor4::normalize()  { -    F32 mag = (F32) sqrt(mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]); +    F32 mag = sqrt(mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE]);      F32 oomag;      if (mag)      { -        oomag = 1.f/mag; +        oomag = 1.f / mag;          mV[VRED] *= oomag;          mV[VGREEN] *= oomag;          mV[VBLUE] *= oomag;      } -    return (mag); +    return mag;  }  // deprecated -inline F32      LLColor4::magVec(void) const +inline F32 LLColor4::magVec() const  { -    return (F32) sqrt(mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]); +    return sqrt(mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE]);  }  // deprecated -inline F32      LLColor4::magVecSquared(void) const +inline F32 LLColor4::magVecSquared() const  { -    return mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]; +    return mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE];  }  // deprecated -inline F32      LLColor4::normVec(void) +inline F32 LLColor4::normVec()  { -    F32 mag = (F32) sqrt(mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]); +    F32 mag = sqrt(mV[VRED] * mV[VRED] + mV[VGREEN] * mV[VGREEN] + mV[VBLUE] * mV[VBLUE]);      F32 oomag;      if (mag)      { -        oomag = 1.f/mag; +        oomag = 1.f / mag;          mV[VRED] *= oomag;          mV[VGREEN] *= oomag;          mV[VBLUE] *= oomag;      } -    return (mag); +    return mag;  }  // LLColor4 Operators - -inline LLColor4 operator+(const LLColor4 &a, const LLColor4 &b) +inline LLColor4 operator+(const LLColor4& a, const LLColor4& b)  { -    return LLColor4( -        a.mV[VRED] + b.mV[VRED], -        a.mV[VGREEN] + b.mV[VGREEN], -        a.mV[VBLUE] + b.mV[VBLUE], -        a.mV[VALPHA] + b.mV[VALPHA]); +    return LLColor4(a.mV[VRED] + b.mV[VRED], a.mV[VGREEN] + b.mV[VGREEN], a.mV[VBLUE] + b.mV[VBLUE], a.mV[VALPHA] + b.mV[VALPHA]);  } -inline LLColor4 operator-(const LLColor4 &a, const LLColor4 &b) +inline LLColor4 operator-(const LLColor4& a, const LLColor4& b)  { -    return LLColor4( -        a.mV[VRED] - b.mV[VRED], -        a.mV[VGREEN] - b.mV[VGREEN], -        a.mV[VBLUE] - b.mV[VBLUE], -        a.mV[VALPHA] - b.mV[VALPHA]); +    return LLColor4(a.mV[VRED] - b.mV[VRED], a.mV[VGREEN] - b.mV[VGREEN], a.mV[VBLUE] - b.mV[VBLUE], a.mV[VALPHA] - b.mV[VALPHA]);  } -inline LLColor4  operator*(const LLColor4 &a, const LLColor4 &b) +inline LLColor4 operator*(const LLColor4& a, const LLColor4& b)  { -    return LLColor4( -        a.mV[VRED] * b.mV[VRED], -        a.mV[VGREEN] * b.mV[VGREEN], -        a.mV[VBLUE] * b.mV[VBLUE], -        a.mV[VALPHA] * b.mV[VALPHA]); +    return LLColor4(a.mV[VRED] * b.mV[VRED], a.mV[VGREEN] * b.mV[VGREEN], a.mV[VBLUE] * b.mV[VBLUE], a.mV[VALPHA] * b.mV[VALPHA]);  } -inline LLColor4 operator*(const LLColor4 &a, F32 k) +inline LLColor4 operator*(const LLColor4& a, F32 k)  {      // only affects rgb (not a!) -    return LLColor4( -        a.mV[VRED] * k, -        a.mV[VGREEN] * k, -        a.mV[VBLUE] * k, -        a.mV[VALPHA]); +    return LLColor4(a.mV[VRED] * k, a.mV[VGREEN] * k, a.mV[VBLUE] * k, a.mV[VALPHA]);  } -inline LLColor4 operator/(const LLColor4 &a, F32 k) +inline LLColor4 operator/(const LLColor4& a, F32 k)  { -    return LLColor4( -        a.mV[VRED] / k, -        a.mV[VGREEN] / k, -        a.mV[VBLUE] / k, -        a.mV[VALPHA]); +    return LLColor4(a.mV[VRED] / k, a.mV[VGREEN] / k, a.mV[VBLUE] / k, a.mV[VALPHA]);  } -inline LLColor4 operator*(F32 k, const LLColor4 &a) +inline LLColor4 operator*(F32 k, const LLColor4& a)  {      // only affects rgb (not a!) -    return LLColor4( -        a.mV[VRED] * k, -        a.mV[VGREEN] * k, -        a.mV[VBLUE] * k, -        a.mV[VALPHA]); +    return LLColor4(a.mV[VRED] * k, a.mV[VGREEN] * k, a.mV[VBLUE] * k, a.mV[VALPHA]);  } -inline LLColor4 operator%(F32 k, const LLColor4 &a) +inline LLColor4 operator%(F32 k, const LLColor4& a)  {      // only affects alpha (not rgb!) -    return LLColor4( -        a.mV[VRED], -        a.mV[VGREEN], -        a.mV[VBLUE], -        a.mV[VALPHA] * k); +    return LLColor4(a.mV[VRED], a.mV[VGREEN], a.mV[VBLUE], a.mV[VALPHA] * k);  } -inline LLColor4 operator%(const LLColor4 &a, F32 k) +inline LLColor4 operator%(const LLColor4& a, F32 k)  {      // only affects alpha (not rgb!) -    return LLColor4( -        a.mV[VRED], -        a.mV[VGREEN], -        a.mV[VBLUE], -        a.mV[VALPHA] * k); +    return LLColor4(a.mV[VRED], a.mV[VGREEN], a.mV[VBLUE], a.mV[VALPHA] * k);  } -inline bool operator==(const LLColor4 &a, const LLColor4 &b) +inline bool operator==(const LLColor4& a, const LLColor4& b)  { -    return (  (a.mV[VRED] == b.mV[VRED]) -            &&(a.mV[VGREEN] == b.mV[VGREEN]) -            &&(a.mV[VBLUE] == b.mV[VBLUE]) -            &&(a.mV[VALPHA] == b.mV[VALPHA])); +    return ((a.mV[VRED] == b.mV[VRED]) && (a.mV[VGREEN] == b.mV[VGREEN]) && (a.mV[VBLUE] == b.mV[VBLUE]) && (a.mV[VALPHA] == b.mV[VALPHA]));  } -inline bool operator!=(const LLColor4 &a, const LLColor4 &b) +inline bool operator!=(const LLColor4& a, const LLColor4& b)  { -    return (  (a.mV[VRED] != b.mV[VRED]) -            ||(a.mV[VGREEN] != b.mV[VGREEN]) -            ||(a.mV[VBLUE] != b.mV[VBLUE]) -            ||(a.mV[VALPHA] != b.mV[VALPHA])); +    return ((a.mV[VRED] != b.mV[VRED]) || (a.mV[VGREEN] != b.mV[VGREEN]) || (a.mV[VBLUE] != b.mV[VBLUE]) || (a.mV[VALPHA] != b.mV[VALPHA]));  } -inline const LLColor4& operator+=(LLColor4 &a, const LLColor4 &b) +inline const LLColor4& operator+=(LLColor4& a, const LLColor4& b)  {      a.mV[VRED] += b.mV[VRED];      a.mV[VGREEN] += b.mV[VGREEN]; @@ -562,7 +518,7 @@ inline const LLColor4& operator+=(LLColor4 &a, const LLColor4 &b)      return a;  } -inline const LLColor4& operator-=(LLColor4 &a, const LLColor4 &b) +inline const LLColor4& operator-=(LLColor4& a, const LLColor4& b)  {      a.mV[VRED] -= b.mV[VRED];      a.mV[VGREEN] -= b.mV[VGREEN]; @@ -571,7 +527,7 @@ inline const LLColor4& operator-=(LLColor4 &a, const LLColor4 &b)      return a;  } -inline const LLColor4& operator*=(LLColor4 &a, F32 k) +inline const LLColor4& operator*=(LLColor4& a, F32 k)  {      // only affects rgb (not a!)      a.mV[VRED] *= k; @@ -580,121 +536,120 @@ inline const LLColor4& operator*=(LLColor4 &a, F32 k)      return a;  } -inline const LLColor4& operator *=(LLColor4 &a, const LLColor4 &b) +inline const LLColor4& operator*=(LLColor4& a, const LLColor4& b)  {      a.mV[VRED] *= b.mV[VRED];      a.mV[VGREEN] *= b.mV[VGREEN];      a.mV[VBLUE] *= b.mV[VBLUE]; -//  a.mV[VALPHA] *= b.mV[VALPHA]; +    //  a.mV[VALPHA] *= b.mV[VALPHA];      return a;  } -inline const LLColor4& operator%=(LLColor4 &a, F32 k) +inline const LLColor4& operator%=(LLColor4& a, F32 k)  {      // only affects alpha (not rgb!)      a.mV[VALPHA] *= k;      return a;  } -  // Non-member functions -inline F32      distVec(const LLColor4 &a, const LLColor4 &b) +inline F32 distVec(const LLColor4& a, const LLColor4& b)  {      LLColor4 vec = a - b; -    return (vec.length()); +    return vec.length();  } -inline F32      distVec_squared(const LLColor4 &a, const LLColor4 &b) +inline F32 distVec_squared(const LLColor4& a, const LLColor4& b)  {      LLColor4 vec = a - b; -    return (vec.lengthSquared()); +    return vec.lengthSquared();  } -inline LLColor4 lerp(const LLColor4 &a, const LLColor4 &b, F32 u) +inline LLColor4 lerp(const LLColor4& a, const LLColor4& b, F32 u)  { -    return LLColor4( -        a.mV[VRED] + (b.mV[VRED] - a.mV[VRED]) * u, -        a.mV[VGREEN] + (b.mV[VGREEN] - a.mV[VGREEN]) * u, -        a.mV[VBLUE] + (b.mV[VBLUE] - a.mV[VBLUE]) * u, -        a.mV[VALPHA] + (b.mV[VALPHA] - a.mV[VALPHA]) * u); +    return LLColor4(a.mV[VRED] + (b.mV[VRED] - a.mV[VRED]) * u, +                    a.mV[VGREEN] + (b.mV[VGREEN] - a.mV[VGREEN]) * u, +                    a.mV[VBLUE] + (b.mV[VBLUE] - a.mV[VBLUE]) * u, +                    a.mV[VALPHA] + (b.mV[VALPHA] - a.mV[VALPHA]) * u);  }  inline bool LLColor4::operator<(const LLColor4& rhs) const  { -    if (mV[0] != rhs.mV[0]) +    if (mV[VRED] != rhs.mV[VRED])      { -        return mV[0] < rhs.mV[0]; +        return mV[VRED] < rhs.mV[VRED];      } -    if (mV[1] != rhs.mV[1]) +    if (mV[VGREEN] != rhs.mV[VGREEN])      { -        return mV[1] < rhs.mV[1]; +        return mV[VGREEN] < rhs.mV[VGREEN];      } -    if (mV[2] != rhs.mV[2]) +    if (mV[VBLUE] != rhs.mV[VBLUE])      { -        return mV[2] < rhs.mV[2]; +        return mV[VBLUE] < rhs.mV[VBLUE];      } -    return mV[3] < rhs.mV[3]; +    return mV[VALPHA] < rhs.mV[VALPHA];  }  void LLColor4::clamp()  {      // Clamp the color... -    if (mV[0] < 0.f) +    if (mV[VRED] < 0.f)      { -        mV[0] = 0.f; +        mV[VRED] = 0.f;      } -    else if (mV[0] > 1.f) +    else if (mV[VRED] > 1.f)      { -        mV[0] = 1.f; +        mV[VRED] = 1.f;      } -    if (mV[1] < 0.f) +    if (mV[VGREEN] < 0.f)      { -        mV[1] = 0.f; +        mV[VGREEN] = 0.f;      } -    else if (mV[1] > 1.f) +    else if (mV[VGREEN] > 1.f)      { -        mV[1] = 1.f; +        mV[VGREEN] = 1.f;      } -    if (mV[2] < 0.f) +    if (mV[VBLUE] < 0.f)      { -        mV[2] = 0.f; +        mV[VBLUE] = 0.f;      } -    else if (mV[2] > 1.f) +    else if (mV[VBLUE] > 1.f)      { -        mV[2] = 1.f; +        mV[VBLUE] = 1.f;      } -    if (mV[3] < 0.f) +    if (mV[VALPHA] < 0.f)      { -        mV[3] = 0.f; +        mV[VALPHA] = 0.f;      } -    else if (mV[3] > 1.f) +    else if (mV[VALPHA] > 1.f)      { -        mV[3] = 1.f; +        mV[VALPHA] = 1.f;      }  }  // Return the given linear space color value in gamma corrected (sRGB) space -inline const LLColor4 srgbColor4(const LLColor4 &a) { +inline const LLColor4 srgbColor4(const LLColor4& a) +{      LLColor4 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[VRED]   = linearTosRGB(a.mV[VRED]); +    srgbColor.mV[VGREEN] = linearTosRGB(a.mV[VGREEN]); +    srgbColor.mV[VBLUE]  = linearTosRGB(a.mV[VBLUE]); +    srgbColor.mV[VALPHA] = a.mV[VALPHA];      return srgbColor;  }  // Return the given gamma corrected (sRGB) color in linear space -inline const LLColor4 linearColor4(const LLColor4 &a) +inline const LLColor4 linearColor4(const LLColor4& a)  {      LLColor4 linearColor; -    linearColor.mV[0] = sRGBtoLinear(a.mV[0]); -    linearColor.mV[1] = sRGBtoLinear(a.mV[1]); -    linearColor.mV[2] = sRGBtoLinear(a.mV[2]); -    linearColor.mV[3] = a.mV[3]; +    linearColor.mV[VRED]   = sRGBtoLinear(a.mV[VRED]); +    linearColor.mV[VGREEN] = sRGBtoLinear(a.mV[VGREEN]); +    linearColor.mV[VBLUE]  = sRGBtoLinear(a.mV[VBLUE]); +    linearColor.mV[VALPHA] = a.mV[VALPHA];      return linearColor;  } @@ -720,4 +675,3 @@ void LLColor4::write(std::vector<T>& v) const  }  #endif - diff --git a/indra/llmath/v4coloru.cpp b/indra/llmath/v4coloru.cpp index acf349245a..c495ffdb4c 100644 --- a/indra/llmath/v4coloru.cpp +++ b/indra/llmath/v4coloru.cpp @@ -26,10 +26,7 @@  #include "linden_common.h" -//#include "v3coloru.h"  #include "v4coloru.h" -#include "v4color.h" -//#include "vmath.h"  #include "llmath.h"  // LLColor4U @@ -39,49 +36,7 @@ LLColor4U LLColor4U::red  (255,   0,   0, 255);  LLColor4U LLColor4U::green(  0, 255,   0, 255);  LLColor4U LLColor4U::blue (  0,   0, 255, 255); -// conversion -/* inlined to fix gcc compile link error -LLColor4U::operator LLColor4() -{ -    return(LLColor4((F32)mV[VRED]/255.f,(F32)mV[VGREEN]/255.f,(F32)mV[VBLUE]/255.f,(F32)mV[VALPHA]/255.f)); -} -*/ - -// Constructors - - -/* -LLColor4U::LLColor4U(const LLColor3 &vec) -{ -    mV[VRED] = vec.mV[VRED]; -    mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; -    mV[VALPHA] = 255; -} -*/ - - -// Clear and Assignment Functions - - - -// LLColor4U Operators - -/* -LLColor4U LLColor4U::operator=(const LLColor3 &a) -{ -    mV[VRED] = a.mV[VRED]; -    mV[VGREEN] = a.mV[VGREEN]; -    mV[VBLUE] = a.mV[VBLUE]; - -// converting from an rgb sets a=1 (opaque) -    mV[VALPHA] = 255; -    return (*this); -} -*/ - - -std::ostream& operator<<(std::ostream& s, const LLColor4U &a) +std::ostream& operator<<(std::ostream& s, const LLColor4U& a)  {      s << "{ " << (S32)a.mV[VRED] << ", " << (S32)a.mV[VGREEN] << ", " << (S32)a.mV[VBLUE] << ", " << (S32)a.mV[VALPHA] << " }";      return s; @@ -90,31 +45,31 @@ std::ostream& operator<<(std::ostream& s, const LLColor4U &a)  // static  bool LLColor4U::parseColor4U(const std::string& buf, LLColor4U* value)  { -    if( buf.empty() || value == nullptr) +    if (buf.empty() || value == nullptr)      {          return false;      } -    U32 v[4]; -    S32 count = sscanf( buf.c_str(), "%u, %u, %u, %u", v + 0, v + 1, v + 2, v + 3 ); -    if (1 == count ) +    U32 v[4]{}; +    S32 count = sscanf(buf.c_str(), "%u, %u, %u, %u", v + 0, v + 1, v + 2, v + 3); +    if (1 == count)      {          // try this format -        count = sscanf( buf.c_str(), "%u %u %u %u", v + 0, v + 1, v + 2, v + 3 ); +        count = sscanf(buf.c_str(), "%u %u %u %u", v + 0, v + 1, v + 2, v + 3);      } -    if( 4 != count ) +    if (4 != count)      {          return false;      } -    for( S32 i = 0; i < 4; i++ ) +    for (S32 i = 0; i < 4; i++)      { -        if( v[i] > U8_MAX ) +        if (v[i] > U8_MAX)          {              return false;          }      } -    value->set( U8(v[0]), U8(v[1]), U8(v[2]), U8(v[3]) ); +    value->set(U8(v[VRED]), U8(v[VGREEN]), U8(v[VBLUE]), U8(v[VALPHA]));      return true;  } diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h index 29128a08a7..bfa998bc58 100644 --- a/indra/llmath/v4coloru.h +++ b/indra/llmath/v4coloru.h @@ -28,104 +28,93 @@  #define LL_V4COLORU_H  #include "llerror.h" -//#include "vmath.h"  #include "llmath.h" -//#include "v4color.h"  #include "v3color.h"  #include "v4color.h" -//class LLColor3U;  class LLColor4;  //  LLColor4U = | red green blue alpha | -static const U32 LENGTHOFCOLOR4U = 4; - +static constexpr U32 LENGTHOFCOLOR4U = 4;  class LLColor4U  {  public: -      U8 mV[LENGTHOFCOLOR4U]; -    LLColor4U();                        // Initializes LLColor4U to (0, 0, 0, 1) -    LLColor4U(U8 r, U8 g, U8 b);        // Initializes LLColor4U to (r, g, b, 1) -    LLColor4U(U8 r, U8 g, U8 b, U8 a);      // Initializes LLColor4U to (r. g, b, a) -    LLColor4U(const U8 *vec);           // Initializes LLColor4U to (vec[0]. vec[1], vec[2], 1) -    explicit LLColor4U(const LLSD& sd) -    { -        setValue(sd); -    } +    LLColor4U();                       // Initializes LLColor4U to (0, 0, 0, 1) +    LLColor4U(U8 r, U8 g, U8 b);       // Initializes LLColor4U to (r, g, b, 1) +    LLColor4U(U8 r, U8 g, U8 b, U8 a); // Initializes LLColor4U to (r. g, b, a) +    LLColor4U(const U8* vec);          // Initializes LLColor4U to (vec[0]. vec[1], vec[2], 1) +    explicit LLColor4U(const LLSD& sd) { setValue(sd); }      void setValue(const LLSD& sd)      { -        mV[0] = sd[0].asInteger(); -        mV[1] = sd[1].asInteger(); -        mV[2] = sd[2].asInteger(); -        mV[3] = sd[3].asInteger(); +        mV[VRED]   = sd[VRED].asInteger(); +        mV[VGREEN] = sd[VGREEN].asInteger(); +        mV[VBLUE]  = sd[VBLUE].asInteger(); +        mV[VALPHA] = sd[VALPHA].asInteger();      }      LLSD getValue() const      {          LLSD ret; -        ret[0] = mV[0]; -        ret[1] = mV[1]; -        ret[2] = mV[2]; -        ret[3] = mV[3]; +        ret[VRED]   = mV[VRED]; +        ret[VGREEN] = mV[VGREEN]; +        ret[VBLUE]  = mV[VBLUE]; +        ret[VALPHA] = mV[VALPHA];          return ret;      } -    const LLColor4U&    setToBlack();                       // zero LLColor4U to (0, 0, 0, 1) -    const LLColor4U&    setToWhite();                       // zero LLColor4U to (0, 0, 0, 1) +    const LLColor4U& setToBlack(); // zero LLColor4U to (0, 0, 0, 1) +    const LLColor4U& setToWhite(); // zero LLColor4U to (0, 0, 0, 1) -    const LLColor4U&    set(U8 r, U8 g, U8 b, U8 a);// Sets LLColor4U to (r, g, b, a) -    const LLColor4U&    set(U8 r, U8 g, U8 b);      // Sets LLColor4U to (r, g, b) (no change in a) -    const LLColor4U&    set(const LLColor4U &vec);  // Sets LLColor4U to vec -    const LLColor4U&    set(const U8 *vec);         // Sets LLColor4U to vec +    const LLColor4U& set(U8 r, U8 g, U8 b, U8 a); // Sets LLColor4U to (r, g, b, a) +    const LLColor4U& set(U8 r, U8 g, U8 b);       // Sets LLColor4U to (r, g, b) (no change in a) +    const LLColor4U& set(const LLColor4U& vec);   // Sets LLColor4U to vec +    const LLColor4U& set(const U8* vec);          // Sets LLColor4U to vec -    const LLColor4U&    setVec(U8 r, U8 g, U8 b, U8 a); // deprecated -- use set() -    const LLColor4U&    setVec(U8 r, U8 g, U8 b);       // deprecated -- use set() -    const LLColor4U&    setVec(const LLColor4U &vec);   // deprecated -- use set() -    const LLColor4U&    setVec(const U8 *vec);          // deprecated -- use set() +    const LLColor4U& setVec(U8 r, U8 g, U8 b, U8 a); // deprecated -- use set() +    const LLColor4U& setVec(U8 r, U8 g, U8 b);       // deprecated -- use set() +    const LLColor4U& setVec(const LLColor4U& vec);   // deprecated -- use set() +    const LLColor4U& setVec(const U8* vec);          // deprecated -- use set() -    const LLColor4U&    setAlpha(U8 a); +    const LLColor4U& setAlpha(U8 a); -    F32         magVec() const;             // deprecated -- use length() -    F32         magVecSquared() const;      // deprecated -- use lengthSquared() +    F32 magVec() const;        // deprecated -- use length() +    F32 magVecSquared() const; // deprecated -- use lengthSquared() -    F32         length() const;             // Returns magnitude squared of LLColor4U -    F32         lengthSquared() const;      // Returns magnitude squared of LLColor4U +    F32 length() const;        // Returns magnitude squared of LLColor4U +    F32 lengthSquared() const; // Returns magnitude squared of LLColor4U -    friend std::ostream&     operator<<(std::ostream& s, const LLColor4U &a);       // Print a -    friend LLColor4U operator+(const LLColor4U &a, const LLColor4U &b); // Return vector a + b -    friend LLColor4U operator-(const LLColor4U &a, const LLColor4U &b); // Return vector a minus b -    friend LLColor4U operator*(const LLColor4U &a, const LLColor4U &b); // Return a * b -    friend bool operator==(const LLColor4U &a, const LLColor4U &b);     // Return a == b -    friend bool operator!=(const LLColor4U &a, const LLColor4U &b);     // Return a != b +    friend std::ostream& operator<<(std::ostream& s, const LLColor4U& a);    // Print a +    friend LLColor4U     operator+(const LLColor4U& a, const LLColor4U& b);  // Return vector a + b +    friend LLColor4U     operator-(const LLColor4U& a, const LLColor4U& b);  // Return vector a minus b +    friend LLColor4U     operator*(const LLColor4U& a, const LLColor4U& b);  // Return a * b +    friend bool          operator==(const LLColor4U& a, const LLColor4U& b); // Return a == b +    friend bool          operator!=(const LLColor4U& a, const LLColor4U& b); // Return a != b -    friend const LLColor4U& operator+=(LLColor4U &a, const LLColor4U &b);   // Return vector a + b -    friend const LLColor4U& operator-=(LLColor4U &a, const LLColor4U &b);   // Return vector a minus b -    friend const LLColor4U& operator*=(LLColor4U &a, U8 k);             // Return rgb times scaler k (no alpha change) -    friend const LLColor4U& operator%=(LLColor4U &a, U8 k);             // Return alpha times scaler k (no rgb change) +    friend const LLColor4U& operator+=(LLColor4U& a, const LLColor4U& b); // Return vector a + b +    friend const LLColor4U& operator-=(LLColor4U& a, const LLColor4U& b); // Return vector a minus b +    friend const LLColor4U& operator*=(LLColor4U& a, U8 k);               // Return rgb times scaler k (no alpha change) +    friend const LLColor4U& operator%=(LLColor4U& a, U8 k);               // Return alpha times scaler k (no rgb change) -    LLColor4U addClampMax(const LLColor4U &color);                      // Add and clamp the max +    LLColor4U addClampMax(const LLColor4U& color); // Add and clamp the max -    LLColor4U multAll(const F32 k);                                     // Multiply ALL channels by scalar k +    LLColor4U multAll(const F32 k); // Multiply ALL channels by scalar k -    inline void setVecScaleClamp(const LLColor3 &color); -    inline void setVecScaleClamp(const LLColor4 &color); +    inline void setVecScaleClamp(const LLColor3& color); +    inline void setVecScaleClamp(const LLColor4& color);      static bool parseColor4U(const std::string& buf, LLColor4U* value);      // conversion -    operator LLColor4() const -    { -        return LLColor4(*this); -    } +    operator LLColor4() const { return LLColor4(*this); } -    U32 asRGBA() const; -    void fromRGBA( U32 aVal ); +    U32  asRGBA() const; +    void fromRGBA(U32 aVal);      static LLColor4U white;      static LLColor4U black; @@ -134,104 +123,95 @@ public:      static LLColor4U blue;  }; -  // Non-member functions -F32     distVec(const LLColor4U &a, const LLColor4U &b);            // Returns distance between a and b -F32     distVec_squared(const LLColor4U &a, const LLColor4U &b);    // Returns distance squared between a and b - +F32 distVec(const LLColor4U& a, const LLColor4U& b);         // Returns distance between a and b +F32 distVec_squared(const LLColor4U& a, const LLColor4U& b); // Returns distance squared between a and b  inline LLColor4U::LLColor4U()  { -    mV[VRED] = 0; +    mV[VRED]   = 0;      mV[VGREEN] = 0; -    mV[VBLUE] = 0; +    mV[VBLUE]  = 0;      mV[VALPHA] = 255;  }  inline LLColor4U::LLColor4U(U8 r, U8 g, U8 b)  { -    mV[VRED] = r; +    mV[VRED]   = r;      mV[VGREEN] = g; -    mV[VBLUE] = b; +    mV[VBLUE]  = b;      mV[VALPHA] = 255;  }  inline LLColor4U::LLColor4U(U8 r, U8 g, U8 b, U8 a)  { -    mV[VRED] = r; +    mV[VRED]   = r;      mV[VGREEN] = g; -    mV[VBLUE] = b; +    mV[VBLUE]  = b;      mV[VALPHA] = a;  } -inline LLColor4U::LLColor4U(const U8 *vec) +inline LLColor4U::LLColor4U(const U8* vec)  { -    mV[VRED] = vec[VRED]; +    mV[VRED]   = vec[VRED];      mV[VGREEN] = vec[VGREEN]; -    mV[VBLUE] = vec[VBLUE]; +    mV[VBLUE]  = vec[VBLUE];      mV[VALPHA] = vec[VALPHA];  } -/* -inline LLColor4U::operator LLColor4() -{ -    return(LLColor4((F32)mV[VRED]/255.f,(F32)mV[VGREEN]/255.f,(F32)mV[VBLUE]/255.f,(F32)mV[VALPHA]/255.f)); -} -*/ -  inline const LLColor4U& LLColor4U::setToBlack(void)  { -    mV[VRED] = 0; +    mV[VRED]   = 0;      mV[VGREEN] = 0; -    mV[VBLUE] = 0; +    mV[VBLUE]  = 0;      mV[VALPHA] = 255;      return (*this);  }  inline const LLColor4U& LLColor4U::setToWhite(void)  { -    mV[VRED] = 255; +    mV[VRED]   = 255;      mV[VGREEN] = 255; -    mV[VBLUE] = 255; +    mV[VBLUE]  = 255;      mV[VALPHA] = 255;      return (*this);  }  inline const LLColor4U& LLColor4U::set(const U8 x, const U8 y, const U8 z)  { -    mV[VRED] = x; +    mV[VRED]   = x;      mV[VGREEN] = y; -    mV[VBLUE] = z; +    mV[VBLUE]  = z; -//  no change to alpha! -//  mV[VALPHA] = 255; +    //  no change to alpha! +    //  mV[VALPHA] = 255;      return (*this);  }  inline const LLColor4U& LLColor4U::set(const U8 r, const U8 g, const U8 b, U8 a)  { -    mV[0] = r; -    mV[1] = g; -    mV[2] = b; -    mV[3] = a; +    mV[VRED]   = r; +    mV[VGREEN] = g; +    mV[VBLUE]  = b; +    mV[VALPHA] = a;      return (*this);  } -inline const LLColor4U& LLColor4U::set(const LLColor4U &vec) +inline const LLColor4U& LLColor4U::set(const LLColor4U& vec)  { -    mV[VRED] = vec.mV[VRED]; +    mV[VRED]   = vec.mV[VRED];      mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; +    mV[VBLUE]  = vec.mV[VBLUE];      mV[VALPHA] = vec.mV[VALPHA];      return (*this);  } -inline const LLColor4U& LLColor4U::set(const U8 *vec) +inline const LLColor4U& LLColor4U::set(const U8* vec)  { -    mV[VRED] = vec[VRED]; +    mV[VRED]   = vec[VRED];      mV[VGREEN] = vec[VGREEN]; -    mV[VBLUE] = vec[VBLUE]; +    mV[VBLUE]  = vec[VBLUE];      mV[VALPHA] = vec[VALPHA];      return (*this);  } @@ -239,12 +219,12 @@ inline const LLColor4U& LLColor4U::set(const U8 *vec)  // deprecated  inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z)  { -    mV[VRED] = x; +    mV[VRED]   = x;      mV[VGREEN] = y; -    mV[VBLUE] = z; +    mV[VBLUE]  = z; -//  no change to alpha! -//  mV[VALPHA] = 255; +    //  no change to alpha! +    //  mV[VALPHA] = 255;      return (*this);  } @@ -252,29 +232,29 @@ inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z)  // deprecated  inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 a)  { -    mV[0] = r; -    mV[1] = g; -    mV[2] = b; -    mV[3] = a; +    mV[VRED]   = r; +    mV[VGREEN] = g; +    mV[VBLUE]  = b; +    mV[VALPHA] = a;      return (*this);  }  // deprecated -inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec) +inline const LLColor4U& LLColor4U::setVec(const LLColor4U& vec)  { -    mV[VRED] = vec.mV[VRED]; +    mV[VRED]   = vec.mV[VRED];      mV[VGREEN] = vec.mV[VGREEN]; -    mV[VBLUE] = vec.mV[VBLUE]; +    mV[VBLUE]  = vec.mV[VBLUE];      mV[VALPHA] = vec.mV[VALPHA];      return (*this);  }  // deprecated -inline const LLColor4U& LLColor4U::setVec(const U8 *vec) +inline const LLColor4U& LLColor4U::setVec(const U8* vec)  { -    mV[VRED] = vec[VRED]; +    mV[VRED]   = vec[VRED];      mV[VGREEN] = vec[VGREEN]; -    mV[VBLUE] = vec[VBLUE]; +    mV[VBLUE]  = vec[VBLUE];      mV[VALPHA] = vec[VALPHA];      return (*this);  } @@ -287,131 +267,68 @@ inline const LLColor4U& LLColor4U::setAlpha(U8 a)  // LLColor4U Magnitude and Normalization Functions -inline F32      LLColor4U::length(void) const +inline F32 LLColor4U::length() const  { -    return (F32) sqrt( ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE] ); +    return sqrt(((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE]);  } -inline F32      LLColor4U::lengthSquared(void) const +inline F32 LLColor4U::lengthSquared() const  {      return ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE];  }  // deprecated -inline F32      LLColor4U::magVec(void) const +inline F32 LLColor4U::magVec() const  { -    return (F32) sqrt( ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE] ); +    return sqrt(((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE]);  }  // deprecated -inline F32      LLColor4U::magVecSquared(void) const +inline F32 LLColor4U::magVecSquared() const  {      return ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE];  } -inline LLColor4U operator+(const LLColor4U &a, const LLColor4U &b) +inline LLColor4U operator+(const LLColor4U& a, const LLColor4U& b)  { -    return LLColor4U( -        a.mV[VRED] + b.mV[VRED], -        a.mV[VGREEN] + b.mV[VGREEN], -        a.mV[VBLUE] + b.mV[VBLUE], -        a.mV[VALPHA] + b.mV[VALPHA]); +    return LLColor4U(a.mV[VRED] + b.mV[VRED], a.mV[VGREEN] + b.mV[VGREEN], a.mV[VBLUE] + b.mV[VBLUE], a.mV[VALPHA] + b.mV[VALPHA]);  } -inline LLColor4U operator-(const LLColor4U &a, const LLColor4U &b) +inline LLColor4U operator-(const LLColor4U& a, const LLColor4U& b)  { -    return LLColor4U( -        a.mV[VRED] - b.mV[VRED], -        a.mV[VGREEN] - b.mV[VGREEN], -        a.mV[VBLUE] - b.mV[VBLUE], -        a.mV[VALPHA] - b.mV[VALPHA]); +    return LLColor4U(a.mV[VRED] - b.mV[VRED], a.mV[VGREEN] - b.mV[VGREEN], a.mV[VBLUE] - b.mV[VBLUE], a.mV[VALPHA] - b.mV[VALPHA]);  } -inline LLColor4U  operator*(const LLColor4U &a, const LLColor4U &b) +inline LLColor4U operator*(const LLColor4U& a, const LLColor4U& b)  { -    return LLColor4U( -        a.mV[VRED] * b.mV[VRED], -        a.mV[VGREEN] * b.mV[VGREEN], -        a.mV[VBLUE] * b.mV[VBLUE], -        a.mV[VALPHA] * b.mV[VALPHA]); +    return LLColor4U(a.mV[VRED] * b.mV[VRED], a.mV[VGREEN] * b.mV[VGREEN], a.mV[VBLUE] * b.mV[VBLUE], a.mV[VALPHA] * b.mV[VALPHA]);  } -inline LLColor4U LLColor4U::addClampMax(const LLColor4U &color) +inline LLColor4U LLColor4U::addClampMax(const LLColor4U& color)  {      return LLColor4U(llmin((S32)mV[VRED] + color.mV[VRED], 255), -                    llmin((S32)mV[VGREEN] + color.mV[VGREEN], 255), -                    llmin((S32)mV[VBLUE] + color.mV[VBLUE], 255), -                    llmin((S32)mV[VALPHA] + color.mV[VALPHA], 255)); +                     llmin((S32)mV[VGREEN] + color.mV[VGREEN], 255), +                     llmin((S32)mV[VBLUE] + color.mV[VBLUE], 255), +                     llmin((S32)mV[VALPHA] + color.mV[VALPHA], 255));  }  inline LLColor4U LLColor4U::multAll(const F32 k)  {      // Round to nearest -    return LLColor4U( -        (U8)ll_round(mV[VRED] * k), -        (U8)ll_round(mV[VGREEN] * k), -        (U8)ll_round(mV[VBLUE] * k), -        (U8)ll_round(mV[VALPHA] * k)); -} -/* -inline LLColor4U operator*(const LLColor4U &a, U8 k) -{ -    // only affects rgb (not a!) -    return LLColor4U( -        a.mV[VRED] * k, -        a.mV[VGREEN] * k, -        a.mV[VBLUE] * k, -        a.mV[VALPHA]); +    return LLColor4U((U8)ll_round(mV[VRED] * k), (U8)ll_round(mV[VGREEN] * k), (U8)ll_round(mV[VBLUE] * k), (U8)ll_round(mV[VALPHA] * k));  } -inline LLColor4U operator*(U8 k, const LLColor4U &a) +inline bool operator==(const LLColor4U& a, const LLColor4U& b)  { -    // only affects rgb (not a!) -    return LLColor4U( -        a.mV[VRED] * k, -        a.mV[VGREEN] * k, -        a.mV[VBLUE] * k, -        a.mV[VALPHA]); +    return ((a.mV[VRED] == b.mV[VRED]) && (a.mV[VGREEN] == b.mV[VGREEN]) && (a.mV[VBLUE] == b.mV[VBLUE]) && (a.mV[VALPHA] == b.mV[VALPHA]));  } -inline LLColor4U operator%(U8 k, const LLColor4U &a) +inline bool operator!=(const LLColor4U& a, const LLColor4U& b)  { -    // only affects alpha (not rgb!) -    return LLColor4U( -        a.mV[VRED], -        a.mV[VGREEN], -        a.mV[VBLUE], -        a.mV[VALPHA] * k ); +    return ((a.mV[VRED] != b.mV[VRED]) || (a.mV[VGREEN] != b.mV[VGREEN]) || (a.mV[VBLUE] != b.mV[VBLUE]) || (a.mV[VALPHA] != b.mV[VALPHA]));  } -inline LLColor4U operator%(const LLColor4U &a, U8 k) -{ -    // only affects alpha (not rgb!) -    return LLColor4U( -        a.mV[VRED], -        a.mV[VGREEN], -        a.mV[VBLUE], -        a.mV[VALPHA] * k ); -} -*/ - -inline bool operator==(const LLColor4U &a, const LLColor4U &b) -{ -    return (  (a.mV[VRED] == b.mV[VRED]) -            &&(a.mV[VGREEN] == b.mV[VGREEN]) -            &&(a.mV[VBLUE] == b.mV[VBLUE]) -            &&(a.mV[VALPHA] == b.mV[VALPHA])); -} - -inline bool operator!=(const LLColor4U &a, const LLColor4U &b) -{ -    return (  (a.mV[VRED] != b.mV[VRED]) -            ||(a.mV[VGREEN] != b.mV[VGREEN]) -            ||(a.mV[VBLUE] != b.mV[VBLUE]) -            ||(a.mV[VALPHA] != b.mV[VALPHA])); -} - -inline const LLColor4U& operator+=(LLColor4U &a, const LLColor4U &b) +inline const LLColor4U& operator+=(LLColor4U& a, const LLColor4U& b)  {      a.mV[VRED] += b.mV[VRED];      a.mV[VGREEN] += b.mV[VGREEN]; @@ -420,7 +337,7 @@ inline const LLColor4U& operator+=(LLColor4U &a, const LLColor4U &b)      return a;  } -inline const LLColor4U& operator-=(LLColor4U &a, const LLColor4U &b) +inline const LLColor4U& operator-=(LLColor4U& a, const LLColor4U& b)  {      a.mV[VRED] -= b.mV[VRED];      a.mV[VGREEN] -= b.mV[VGREEN]; @@ -429,7 +346,7 @@ inline const LLColor4U& operator-=(LLColor4U &a, const LLColor4U &b)      return a;  } -inline const LLColor4U& operator*=(LLColor4U &a, U8 k) +inline const LLColor4U& operator*=(LLColor4U& a, U8 k)  {      // only affects rgb (not a!)      a.mV[VRED] *= k; @@ -438,20 +355,20 @@ inline const LLColor4U& operator*=(LLColor4U &a, U8 k)      return a;  } -inline const LLColor4U& operator%=(LLColor4U &a, U8 k) +inline const LLColor4U& operator%=(LLColor4U& a, U8 k)  {      // only affects alpha (not rgb!)      a.mV[VALPHA] *= k;      return a;  } -inline F32      distVec(const LLColor4U &a, const LLColor4U &b) +inline F32 distVec(const LLColor4U& a, const LLColor4U& b)  {      LLColor4U vec = a - b;      return (vec.length());  } -inline F32      distVec_squared(const LLColor4U &a, const LLColor4U &b) +inline F32 distVec_squared(const LLColor4U& a, const LLColor4U& b)  {      LLColor4U vec = a - b;      return (vec.lengthSquared()); @@ -460,13 +377,13 @@ inline F32      distVec_squared(const LLColor4U &a, const LLColor4U &b)  void LLColor4U::setVecScaleClamp(const LLColor4& color)  {      F32 color_scale_factor = 255.f; -    F32 max_color = llmax(color.mV[0], color.mV[1], color.mV[2]); +    F32 max_color          = llmax(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE]);      if (max_color > 1.f)      {          color_scale_factor /= max_color;      } -    const S32 MAX_COLOR = 255; -    S32 r = ll_round(color.mV[0] * color_scale_factor); +    constexpr S32 MAX_COLOR = 255; +    S32           r         = ll_round(color.mV[VRED] * color_scale_factor);      if (r > MAX_COLOR)      {          r = MAX_COLOR; @@ -475,9 +392,9 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)      {          r = 0;      } -    mV[0] = r; +    mV[VRED] = r; -    S32 g = ll_round(color.mV[1] * color_scale_factor); +    S32 g = ll_round(color.mV[VGREEN] * color_scale_factor);      if (g > MAX_COLOR)      {          g = MAX_COLOR; @@ -486,9 +403,9 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)      {          g = 0;      } -    mV[1] = g; +    mV[VGREEN] = g; -    S32 b = ll_round(color.mV[2] * color_scale_factor); +    S32 b = ll_round(color.mV[VBLUE] * color_scale_factor);      if (b > MAX_COLOR)      {          b = MAX_COLOR; @@ -497,10 +414,10 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)      {          b = 0;      } -    mV[2] = b; +    mV[VBLUE] = b;      // Alpha shouldn't be scaled, just clamped... -    S32 a = ll_round(color.mV[3] * MAX_COLOR); +    S32 a = ll_round(color.mV[VALPHA] * MAX_COLOR);      if (a > MAX_COLOR)      {          a = MAX_COLOR; @@ -509,44 +426,42 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color)      {          a = 0;      } -    mV[3] = a; +    mV[VALPHA] = a;  }  void LLColor4U::setVecScaleClamp(const LLColor3& color)  {      F32 color_scale_factor = 255.f; -    F32 max_color = llmax(color.mV[0], color.mV[1], color.mV[2]); +    F32 max_color          = llmax(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE]);      if (max_color > 1.f)      {          color_scale_factor /= max_color;      }      const S32 MAX_COLOR = 255; -    S32 r = ll_round(color.mV[0] * color_scale_factor); +    S32       r         = ll_round(color.mV[VRED] * color_scale_factor);      if (r > MAX_COLOR)      {          r = MAX_COLOR;      } -    else -    if (r < 0) +    else if (r < 0)      {          r = 0;      } -    mV[0] = r; +    mV[VRED] = r; -    S32 g = ll_round(color.mV[1] * color_scale_factor); +    S32 g = ll_round(color.mV[VGREEN] * color_scale_factor);      if (g > MAX_COLOR)      {          g = MAX_COLOR;      } -    else -    if (g < 0) +    else if (g < 0)      {          g = 0;      } -    mV[1] = g; +    mV[VGREEN] = g; -    S32 b = ll_round(color.mV[2] * color_scale_factor); +    S32 b = ll_round(color.mV[VBLUE] * color_scale_factor);      if (b > MAX_COLOR)      {          b = MAX_COLOR; @@ -555,31 +470,29 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color)      {          b = 0;      } -    mV[2] = b; +    mV[VBLUE] = b; -    mV[3] = 255; +    mV[VALPHA] = 255;  }  inline U32 LLColor4U::asRGBA() const  {      // Little endian: values are swapped in memory. The original code access the array like a U32, so we need to swap here -    return (mV[3] << 24) | (mV[2] << 16) | (mV[1] << 8) | mV[0]; +    return (mV[VALPHA] << 24) | (mV[VBLUE] << 16) | (mV[VGREEN] << 8) | mV[VRED];  } -inline void LLColor4U::fromRGBA( U32 aVal ) +inline void LLColor4U::fromRGBA(U32 aVal)  {      // Little endian: values are swapped in memory. The original code access the array like a U32, so we need to swap here -    mV[ 0 ] = aVal & 0xFF; +    mV[VRED] = aVal & 0xFF;      aVal >>= 8; -    mV[ 1 ] = aVal & 0xFF; +    mV[VGREEN] = aVal & 0xFF;      aVal >>= 8; -    mV[ 2 ] = aVal & 0xFF; +    mV[VBLUE] = aVal & 0xFF;      aVal >>= 8; -    mV[ 3 ] = aVal & 0xFF; +    mV[VALPHA] = aVal & 0xFF;  } -  #endif - diff --git a/indra/llmath/v4math.cpp b/indra/llmath/v4math.cpp index 0aa6eb09c3..cd475380d6 100644 --- a/indra/llmath/v4math.cpp +++ b/indra/llmath/v4math.cpp @@ -26,7 +26,6 @@  #include "linden_common.h" -//#include "vmath.h"  #include "v3math.h"  #include "v4math.h"  #include "m4math.h" @@ -36,13 +35,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 +63,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 +107,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 a4c9668fdd..37492e7f98 100644 --- a/indra/llmath/v4math.h +++ b/indra/llmath/v4math.h @@ -42,108 +42,108 @@ class LLQuaternion;  //  LLVector4 = |x y z w| -static const U32 LENGTHOFVECTOR4 = 4; +static constexpr U32 LENGTHOFVECTOR4 = 4;  class LLVector4  { -    public: -        F32 mV[LENGTHOFVECTOR4]; -        LLVector4();                        // Initializes LLVector4 to (0, 0, 0, 1) -        explicit LLVector4(const F32 *vec);         // Initializes LLVector4 to (vec[0]. vec[1], vec[2], vec[3]) -        explicit LLVector4(const F64 *vec);         // Initialized LLVector4 to ((F32) vec[0], (F32) vec[1], (F32) vec[3], (F32) vec[4]); -        explicit LLVector4(const LLVector2 &vec); -        explicit LLVector4(const LLVector2 &vec, F32 z, F32 w); -        explicit LLVector4(const LLVector3 &vec);           // Initializes LLVector4 to (vec, 1) -        explicit LLVector4(const LLVector3 &vec, F32 w);    // Initializes LLVector4 to (vec, w) -        explicit LLVector4(const LLSD &sd); -        LLVector4(F32 x, F32 y, F32 z);     // Initializes LLVector4 to (x. y, z, 1) -        LLVector4(F32 x, F32 y, F32 z, F32 w); - -        LLSD getValue() const -        { -            LLSD ret; -            ret[0] = mV[0]; -            ret[1] = mV[1]; -            ret[2] = mV[2]; -            ret[3] = mV[3]; -            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(); -        } - -        // GLM interop -        explicit LLVector4(const glm::vec3& vec); // Initializes LLVector4 to (vec, 1) -        explicit LLVector4(const glm::vec4& vec); // Initializes LLVector4 to vec -        explicit operator glm::vec3() const;      // Initializes glm::vec3 to (vec[0]. vec[1], vec[2]) -        explicit operator glm::vec4() const;      // Initializes glm::vec4 to (vec[0]. vec[1], vec[2], vec[3]) - -        inline bool isFinite() const;                                   // checks to see if all values of LLVector3 are finite - -        inline void clear();        // Clears LLVector4 to (0, 0, 0, 1) -        inline void clearVec();     // deprecated -        inline void zeroVec();      // deprecated - -        inline void set(F32 x, F32 y, F32 z);           // Sets LLVector4 to (x, y, z, 1) -        inline void set(F32 x, F32 y, F32 z, F32 w);    // Sets LLVector4 to (x, y, z, w) -        inline void set(const LLVector4 &vec);          // Sets LLVector4 to vec -        inline void set(const LLVector3 &vec, F32 w = 1.f); // Sets LLVector4 to LLVector3 vec -        inline void set(const F32 *vec);                // Sets LLVector4 to vec -        inline void set(const glm::vec4& vec); // Sets LLVector4 to vec -        inline void set(const glm::vec3& vec, F32 w = 1.f); // Sets LLVector4 to LLVector3 vec with w defaulted to 1 - -        inline void setVec(F32 x, F32 y, F32 z);        // deprecated -        inline void setVec(F32 x, F32 y, F32 z, F32 w); // deprecated -        inline void setVec(const LLVector4 &vec);       // deprecated -        inline void setVec(const LLVector3 &vec, F32 w = 1.f); // deprecated -        inline void setVec(const F32 *vec);             // deprecated - -        F32 length() const;             // Returns magnitude of LLVector4 -        F32 lengthSquared() const;      // Returns magnitude squared of LLVector4 -        F32 normalize();                // Normalizes and returns the magnitude of LLVector4 - -        F32         magVec() const;             // deprecated -        F32         magVecSquared() const;      // deprecated -        F32         normVec();                  // deprecated - -        // Sets all values to absolute value of their original values -        // Returns true if data changed -        bool abs(); - -        bool isExactlyClear() const     { return (mV[VW] == 1.0f) && !mV[VX] && !mV[VY] && !mV[VZ]; } -        bool isExactlyZero() const      { return !mV[VW] && !mV[VX] && !mV[VY] && !mV[VZ]; } - -        const LLVector4&    rotVec(const LLMatrix4 &mat);               // Rotates by MAT4 mat -        const LLVector4&    rotVec(const LLQuaternion &q);              // Rotates by QUAT q - -        const LLVector4&    scaleVec(const LLVector4& vec); // Scales component-wise by vec - -        F32 operator[](int idx) const { return mV[idx]; } -        F32 &operator[](int idx) { return mV[idx]; } - -        friend std::ostream&     operator<<(std::ostream& s, const LLVector4 &a);       // Print a -        friend LLVector4 operator+(const LLVector4 &a, const LLVector4 &b); // Return vector a + b -        friend LLVector4 operator-(const LLVector4 &a, const LLVector4 &b); // Return vector a minus b -        friend F32  operator*(const LLVector4 &a, const LLVector4 &b);      // Return a dot b -        friend LLVector4 operator%(const LLVector4 &a, const LLVector4 &b); // Return a cross b -        friend LLVector4 operator/(const LLVector4 &a, F32 k);              // Return a divided by scaler k -        friend LLVector4 operator*(const LLVector4 &a, F32 k);              // Return a times scaler k -        friend LLVector4 operator*(F32 k, const LLVector4 &a);              // Return a times scaler k -        friend bool operator==(const LLVector4 &a, const LLVector4 &b);     // Return a == b -        friend bool operator!=(const LLVector4 &a, const LLVector4 &b);     // Return a != b - -        friend const LLVector4& operator+=(LLVector4 &a, const LLVector4 &b);   // Return vector a + b -        friend const LLVector4& operator-=(LLVector4 &a, const LLVector4 &b);   // Return vector a minus b -        friend const LLVector4& operator%=(LLVector4 &a, const LLVector4 &b);   // Return a cross b -        friend const LLVector4& operator*=(LLVector4 &a, F32 k);                // Return a times scaler k -        friend const LLVector4& operator/=(LLVector4 &a, F32 k);                // Return a divided by scaler k - -        friend LLVector4 operator-(const LLVector4 &a);                 // Return vector -a +public: +    F32 mV[LENGTHOFVECTOR4]; +    LLVector4();                        // Initializes LLVector4 to (0, 0, 0, 1) +    explicit LLVector4(const F32 *vec);         // Initializes LLVector4 to (vec[0]. vec[1], vec[2], vec[3]) +    explicit LLVector4(const F64 *vec);         // Initialized LLVector4 to ((F32) vec[0], (F32) vec[1], (F32) vec[3], (F32) vec[4]); +    explicit LLVector4(const LLVector2 &vec); +    explicit LLVector4(const LLVector2 &vec, F32 z, F32 w); +    explicit LLVector4(const LLVector3 &vec);           // Initializes LLVector4 to (vec, 1) +    explicit LLVector4(const LLVector3 &vec, F32 w);    // Initializes LLVector4 to (vec, w) +    explicit LLVector4(const LLSD &sd); +    LLVector4(F32 x, F32 y, F32 z);     // Initializes LLVector4 to (x. y, z, 1) +    LLVector4(F32 x, F32 y, F32 z, F32 w); + +    LLSD getValue() const +    { +        LLSD ret; +        ret[VX] = mV[VX]; +        ret[VY] = mV[VY]; +        ret[VZ] = mV[VZ]; +        ret[VW] = mV[VW]; +        return ret; +    } + +    void setValue(const LLSD& sd) +    { +        mV[VX] = (F32)sd[VX].asReal(); +        mV[VY] = (F32)sd[VY].asReal(); +        mV[VZ] = (F32)sd[VZ].asReal(); +        mV[VW] = (F32)sd[VW].asReal(); +    } + +    // GLM interop +    explicit LLVector4(const glm::vec3& vec); // Initializes LLVector4 to (vec, 1) +    explicit LLVector4(const glm::vec4& vec); // Initializes LLVector4 to vec +    explicit operator glm::vec3() const;      // Initializes glm::vec3 to (vec[0]. vec[1], vec[2]) +    explicit operator glm::vec4() const;      // Initializes glm::vec4 to (vec[0]. vec[1], vec[2], vec[3]) + +    inline bool isFinite() const;                                   // checks to see if all values of LLVector3 are finite + +    inline void clear();        // Clears LLVector4 to (0, 0, 0, 1) +    inline void clearVec();     // deprecated +    inline void zeroVec();      // deprecated + +    inline void set(F32 x, F32 y, F32 z);           // Sets LLVector4 to (x, y, z, 1) +    inline void set(F32 x, F32 y, F32 z, F32 w);    // Sets LLVector4 to (x, y, z, w) +    inline void set(const LLVector4 &vec);          // Sets LLVector4 to vec +    inline void set(const LLVector3 &vec, F32 w = 1.f); // Sets LLVector4 to LLVector3 vec +    inline void set(const F32 *vec);                // Sets LLVector4 to vec +    inline void set(const glm::vec4& vec); // Sets LLVector4 to vec +    inline void set(const glm::vec3& vec, F32 w = 1.f); // Sets LLVector4 to LLVector3 vec with w defaulted to 1 + +    inline void setVec(F32 x, F32 y, F32 z);        // deprecated +    inline void setVec(F32 x, F32 y, F32 z, F32 w); // deprecated +    inline void setVec(const LLVector4 &vec);       // deprecated +    inline void setVec(const LLVector3 &vec, F32 w = 1.f); // deprecated +    inline void setVec(const F32 *vec);             // deprecated + +    F32 length() const;             // Returns magnitude of LLVector4 +    F32 lengthSquared() const;      // Returns magnitude squared of LLVector4 +    F32 normalize();                // Normalizes and returns the magnitude of LLVector4 + +    F32         magVec() const;             // deprecated +    F32         magVecSquared() const;      // deprecated +    F32         normVec();                  // deprecated + +    // Sets all values to absolute value of their original values +    // Returns true if data changed +    bool abs(); + +    bool isExactlyClear() const     { return (mV[VW] == 1.0f) && !mV[VX] && !mV[VY] && !mV[VZ]; } +    bool isExactlyZero() const      { return !mV[VW] && !mV[VX] && !mV[VY] && !mV[VZ]; } + +    const LLVector4&    rotVec(const LLMatrix4 &mat);               // Rotates by MAT4 mat +    const LLVector4&    rotVec(const LLQuaternion &q);              // Rotates by QUAT q + +    const LLVector4&    scaleVec(const LLVector4& vec); // Scales component-wise by vec + +    F32 operator[](int idx) const { return mV[idx]; } +    F32 &operator[](int idx) { return mV[idx]; } + +    friend std::ostream&     operator<<(std::ostream& s, const LLVector4 &a);       // Print a +    friend LLVector4 operator+(const LLVector4 &a, const LLVector4 &b); // Return vector a + b +    friend LLVector4 operator-(const LLVector4 &a, const LLVector4 &b); // Return vector a minus b +    friend F32  operator*(const LLVector4 &a, const LLVector4 &b);      // Return a dot b +    friend LLVector4 operator%(const LLVector4 &a, const LLVector4 &b); // Return a cross b +    friend LLVector4 operator/(const LLVector4 &a, F32 k);              // Return a divided by scaler k +    friend LLVector4 operator*(const LLVector4 &a, F32 k);              // Return a times scaler k +    friend LLVector4 operator*(F32 k, const LLVector4 &a);              // Return a times scaler k +    friend bool operator==(const LLVector4 &a, const LLVector4 &b);     // Return a == b +    friend bool operator!=(const LLVector4 &a, const LLVector4 &b);     // Return a != b + +    friend const LLVector4& operator+=(LLVector4 &a, const LLVector4 &b);   // Return vector a + b +    friend const LLVector4& operator-=(LLVector4 &a, const LLVector4 &b);   // Return vector a minus b +    friend const LLVector4& operator%=(LLVector4 &a, const LLVector4 &b);   // Return a cross b +    friend const LLVector4& operator*=(LLVector4 &a, F32 k);                // Return a times scaler k +    friend const LLVector4& operator/=(LLVector4 &a, F32 k);                // Return a divided by scaler k + +    friend LLVector4 operator-(const LLVector4 &a);                 // Return vector -a  };  // Non-member functions @@ -257,7 +257,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; @@ -266,7 +266,7 @@ inline void LLVector4::clear(void)  }  // deprecated -inline void LLVector4::clearVec(void) +inline void LLVector4::clearVec()  {      mV[VX] = 0.f;      mV[VY] = 0.f; @@ -275,7 +275,7 @@ inline void LLVector4::clearVec(void)  }  // deprecated -inline void LLVector4::zeroVec(void) +inline void LLVector4::zeroVec()  {      mV[VX] = 0.f;      mV[VY] = 0.f; @@ -299,7 +299,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]; @@ -307,7 +307,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]; @@ -315,7 +315,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]; @@ -358,7 +358,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]; @@ -367,7 +367,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]; @@ -376,7 +376,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]; @@ -386,75 +386,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]) @@ -462,7 +462,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]; @@ -470,7 +470,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]; @@ -478,14 +478,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; @@ -493,7 +493,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; @@ -502,7 +502,7 @@ 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] );  } @@ -517,19 +517,19 @@ inline LLVector4::operator glm::vec4() const      return glm::make_vec4(mV);  } -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, @@ -538,9 +538,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) @@ -552,18 +552,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) @@ -575,22 +575,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;  } diff --git a/indra/llmath/xform.h b/indra/llmath/xform.h index 7434301670..fa45fffeae 100644 --- a/indra/llmath/xform.h +++ b/indra/llmath/xform.h @@ -115,7 +115,7 @@ public:      void        clearChanged(U32 bits)                      { mChanged &= ~bits; }      void        setScaleChildOffset(bool scale)             { mScaleChildOffset = scale; } -    bool        getScaleChildOffset()                       { return mScaleChildOffset; } +    bool        getScaleChildOffset() const                 { return mScaleChildOffset; }      LLXform* getParent() const { return mParent; }      LLXform* getRoot() const; diff --git a/indra/llmessage/message_prehash.cpp b/indra/llmessage/message_prehash.cpp index c264a9f086..21dbf35783 100644 --- a/indra/llmessage/message_prehash.cpp +++ b/indra/llmessage/message_prehash.cpp @@ -1402,3 +1402,4 @@ char const* const _PREHASH_HoverHeight = LLMessageStringTable::getInstance()->ge  char const* const _PREHASH_Experience = LLMessageStringTable::getInstance()->getString("Experience");  char const* const _PREHASH_ExperienceID = LLMessageStringTable::getInstance()->getString("ExperienceID");  char const* const _PREHASH_LargeGenericMessage = LLMessageStringTable::getInstance()->getString("LargeGenericMessage"); +char const* const _PREHASH_MetaData = LLMessageStringTable::getInstance()->getString("MetaData"); diff --git a/indra/llmessage/message_prehash.h b/indra/llmessage/message_prehash.h index 1d30b69b67..8a2ad1587c 100644 --- a/indra/llmessage/message_prehash.h +++ b/indra/llmessage/message_prehash.h @@ -1403,5 +1403,6 @@ extern char const* const _PREHASH_HoverHeight;  extern char const* const _PREHASH_Experience;  extern char const* const _PREHASH_ExperienceID;  extern char const* const _PREHASH_LargeGenericMessage; +extern char const* const _PREHASH_MetaData;  #endif diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h index cf3569683e..3fdcf9f7f2 100644 --- a/indra/llui/llaccordionctrltab.h +++ b/indra/llui/llaccordionctrltab.h @@ -126,7 +126,7 @@ public:      void setSelected(bool is_selected); -    bool getCollapsible() { return mCollapsible; }; +    bool getCollapsible() const { return mCollapsible; };      void setCollapsible(bool collapsible) { mCollapsible = collapsible; };      void changeOpenClose(bool is_open); @@ -181,7 +181,7 @@ public:      void setHeaderVisible(bool value); -    bool getHeaderVisible() { return mHeaderVisible;} +    bool getHeaderVisible() const { return mHeaderVisible;}      S32 mExpandedHeight; // Height of expanded ctrl.                           // Used to restore height after expand. diff --git a/indra/llui/llchatentry.cpp b/indra/llui/llchatentry.cpp index da5afd0386..e8d942b8af 100644 --- a/indra/llui/llchatentry.cpp +++ b/indra/llui/llchatentry.cpp @@ -45,7 +45,8 @@ LLChatEntry::LLChatEntry(const Params& p)      mExpandLinesCount(p.expand_lines_count),      mPrevLinesCount(0),      mSingleLineMode(false), -    mPrevExpandedLineCount(S32_MAX) +    mPrevExpandedLineCount(S32_MAX), +    mCurrentInput("")  {      // Initialize current history line iterator      mCurrentHistoryLine = mLineHistory.begin(); @@ -189,6 +190,7 @@ bool LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)          {              needsReflow();          } +        mCurrentInput = "";          break;      case KEY_UP: @@ -196,6 +198,11 @@ bool LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)          {              if (!mLineHistory.empty() && mCurrentHistoryLine > mLineHistory.begin())              { +                if (mCurrentHistoryLine == mLineHistory.end()) +                { +                    mCurrentInput = getText(); +                } +                  setText(*(--mCurrentHistoryLine));                  endOfDoc();              } @@ -210,16 +217,15 @@ bool LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)      case KEY_DOWN:          if (mHasHistory && MASK_CONTROL == mask)          { -            if (!mLineHistory.empty() && mCurrentHistoryLine < (mLineHistory.end() - 1) ) +            if (!mLineHistory.empty() && mCurrentHistoryLine < (mLineHistory.end() - 1))              {                  setText(*(++mCurrentHistoryLine));                  endOfDoc();              } -            else if (!mLineHistory.empty() && mCurrentHistoryLine == (mLineHistory.end() - 1) ) +            else if (!mLineHistory.empty() && mCurrentHistoryLine == (mLineHistory.end() - 1))              {                  mCurrentHistoryLine++; -                std::string empty(""); -                setText(empty); +                setText(mCurrentInput);                  needsReflow();                  endOfDoc();              } diff --git a/indra/llui/llchatentry.h b/indra/llui/llchatentry.h index 5621ede1e7..9a0e8ee91e 100644 --- a/indra/llui/llchatentry.h +++ b/indra/llui/llchatentry.h @@ -101,6 +101,8 @@ private:      S32                                 mExpandLinesCount;      S32                                 mPrevLinesCount;      S32                                 mPrevExpandedLineCount; + +    std::string                         mCurrentInput;  };  #endif /* LLCHATENTRY_H_ */ diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h index 135f128692..4068741978 100644 --- a/indra/llui/llcheckboxctrl.h +++ b/indra/llui/llcheckboxctrl.h @@ -36,8 +36,8 @@  // Constants  // -const bool  RADIO_STYLE = true; -const bool  CHECK_STYLE = false; +constexpr bool RADIO_STYLE = true; +constexpr bool CHECK_STYLE = false;  //  // Classes @@ -94,7 +94,7 @@ public:      // LLUICtrl interface      virtual void        setValue(const LLSD& value );      virtual LLSD        getValue() const; -            bool        get() { return (bool)getValue().asBoolean(); } +            bool        get() const { return (bool)getValue().asBoolean(); }              void        set(bool value) { setValue(value); }      virtual void        setTentative(bool b); @@ -106,7 +106,7 @@ public:      virtual void        onCommit();      // LLCheckBoxCtrl interface -    virtual bool        toggle()                { return mButton->toggleState(); }      // returns new state +    virtual bool        toggle() { return mButton->toggleState(); }      // returns new state      void                setBtnFocus() { mButton->setFocus(true); } diff --git a/indra/llui/llcontainerview.h b/indra/llui/llcontainerview.h index c6dd401e85..2675d21c22 100644 --- a/indra/llui/llcontainerview.h +++ b/indra/llui/llcontainerview.h @@ -65,21 +65,21 @@ protected:  public:      ~LLContainerView(); -    /*virtual*/ bool postBuild(); -    /*virtual*/ bool addChild(LLView* view, S32 tab_group = 0); +    bool postBuild() override; +    bool addChild(LLView* view, S32 tab_group = 0) override; -    /*virtual*/ bool handleDoubleClick(S32 x, S32 y, MASK mask); -    /*virtual*/ bool handleMouseDown(S32 x, S32 y, MASK mask); -    /*virtual*/ bool handleMouseUp(S32 x, S32 y, MASK mask); +    bool handleDoubleClick(S32 x, S32 y, MASK mask) override; +    bool handleMouseDown(S32 x, S32 y, MASK mask) override; +    bool handleMouseUp(S32 x, S32 y, MASK mask) override; -    /*virtual*/ void draw(); -    /*virtual*/ void reshape(S32 width, S32 height, bool called_from_parent = true); -    /*virtual*/ LLRect getRequiredRect();   // Return the height of this object, given the set options. +    void draw() override; +    void reshape(S32 width, S32 height, bool called_from_parent = true) override; +    LLRect getRequiredRect() override;   // Return the height of this object, given the set options.      void setLabel(const std::string& label);      void showLabel(bool show) { mShowLabel = show; }      void setDisplayChildren(bool displayChildren); -    bool getDisplayChildren() { return mDisplayChildren; } +    bool getDisplayChildren() const { return mDisplayChildren; }      void setScrollContainer(LLScrollContainer* scroll) {mScrollContainer = scroll;}   private: diff --git a/indra/llui/lldockablefloater.h b/indra/llui/lldockablefloater.h index 3effc977db..9c516e23a4 100644 --- a/indra/llui/lldockablefloater.h +++ b/indra/llui/lldockablefloater.h @@ -112,8 +112,8 @@ public:      virtual bool overlapsScreenChannel() { return mOverlapsScreenChannel && getVisible() && isDocked(); }      virtual void setOverlapsScreenChannel(bool overlaps) { mOverlapsScreenChannel = overlaps; } -    bool getUniqueDocking() { return mUniqueDocking;    } -    bool getUseTongue() { return mUseTongue; } +    bool getUniqueDocking() const { return mUniqueDocking;    } +    bool getUseTongue() const { return mUseTongue; }      void setUseTongue(bool use_tongue) { mUseTongue = use_tongue;}  private: diff --git a/indra/llui/lldockcontrol.cpp b/indra/llui/lldockcontrol.cpp index 11dbad8c09..1a00c03856 100644 --- a/indra/llui/lldockcontrol.cpp +++ b/indra/llui/lldockcontrol.cpp @@ -156,7 +156,7 @@ void LLDockControl::repositionDockable()      }  } -bool LLDockControl::isDockVisible() +bool LLDockControl::isDockVisible() const  {      bool res = true; diff --git a/indra/llui/lldockcontrol.h b/indra/llui/lldockcontrol.h index 7e31330713..b6ac9c19dd 100644 --- a/indra/llui/lldockcontrol.h +++ b/indra/llui/lldockcontrol.h @@ -61,19 +61,19 @@ public:      void off();      void forceRecalculatePosition();      void setDock(LLView* dockWidget); -    LLView* getDock() +    LLView* getDock() const      {          return mDockWidgetHandle.get();      }      void repositionDockable();      void drawToungue(); -    bool isDockVisible(); +    bool isDockVisible() const;      // gets a rect that bounds possible positions for a dockable control (EXT-1111)      void getAllowedRect(LLRect& rect); -    S32 getTongueWidth() { return mDockTongue->getWidth(); } -    S32 getTongueHeight() { return mDockTongue->getHeight(); } +    S32 getTongueWidth() const { return mDockTongue->getWidth(); } +    S32 getTongueHeight() const { return mDockTongue->getHeight(); }  private:      virtual void moveDockable(); diff --git a/indra/llui/lldraghandle.h b/indra/llui/lldraghandle.h index a522e63243..73211d5292 100644 --- a/indra/llui/lldraghandle.h +++ b/indra/llui/lldraghandle.h @@ -66,7 +66,7 @@ public:      void            setMaxTitleWidth(S32 max_width) {mMaxTitleWidth = llmin(max_width, mMaxTitleWidth); }      S32             getMaxTitleWidth() const { return mMaxTitleWidth; }      void            setButtonsRect(const LLRect& rect){ mButtonsRect = rect; } -    LLRect          getButtonsRect() { return mButtonsRect; } +    LLRect          getButtonsRect() const { return mButtonsRect; }      void            setTitleVisible(bool visible);      virtual void    setTitle( const std::string& title ) = 0; diff --git a/indra/llui/llfiltereditor.h b/indra/llui/llfiltereditor.h index 686827d94c..685219c9f6 100644 --- a/indra/llui/llfiltereditor.h +++ b/indra/llui/llfiltereditor.h @@ -49,7 +49,7 @@ protected:      LLFilterEditor(const Params&);      friend class LLUICtrlFactory; -    /*virtual*/ void handleKeystroke(); +    void handleKeystroke() override;  };  #endif  // LL_FILTEREDITOR_H diff --git a/indra/llui/llflashtimer.cpp b/indra/llui/llflashtimer.cpp index c3db24c987..54f54653e2 100644 --- a/indra/llui/llflashtimer.cpp +++ b/indra/llui/llflashtimer.cpp @@ -85,12 +85,12 @@ void LLFlashTimer::stopFlashing()      mCurrentTickCount = 0;  } -bool LLFlashTimer::isFlashingInProgress() +bool LLFlashTimer::isFlashingInProgress() const  {      return mIsFlashingInProgress;  } -bool LLFlashTimer::isCurrentlyHighlighted() +bool LLFlashTimer::isCurrentlyHighlighted() const  {      return mIsCurrentlyHighlighted;  } diff --git a/indra/llui/llflashtimer.h b/indra/llui/llflashtimer.h index b55ce53fc0..4ef70faf2d 100644 --- a/indra/llui/llflashtimer.h +++ b/indra/llui/llflashtimer.h @@ -51,8 +51,8 @@ public:      void startFlashing();      void stopFlashing(); -    bool isFlashingInProgress(); -    bool isCurrentlyHighlighted(); +    bool isFlashingInProgress() const; +    bool isCurrentlyHighlighted() const;      /*       * Use this instead of deleting this object.       * The next call to tick() will return true and that will destroy this object. diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index 53f39766c6..b8c833f4fd 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -1337,7 +1337,7 @@ void LLFlatListViewEx::updateNoItemsMessage(const std::string& filter_string)      }  } -bool LLFlatListViewEx::getForceShowingUnmatchedItems() +bool LLFlatListViewEx::getForceShowingUnmatchedItems() const  {      return mForceShowingUnmatchedItems;  } diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h index 6d75e9f282..0ea3115f30 100644 --- a/indra/llui/llflatlistview.h +++ b/indra/llui/llflatlistview.h @@ -113,7 +113,7 @@ public:      };      // disable traversal when finding widget to hand focus off to -    /*virtual*/ bool canFocusChildren() const { return false; } +    /*virtual*/ bool canFocusChildren() const override { return false; }      /**       * Connects callback to signal called when Return key is pressed. @@ -121,15 +121,15 @@ public:      boost::signals2::connection setReturnCallback( const commit_signal_t::slot_type& cb ) { return mOnReturnSignal.connect(cb); }      /** Overridden LLPanel's reshape, height is ignored, the list sets its height to accommodate all items */ -    virtual void reshape(S32 width, S32 height, bool called_from_parent  = true); +    virtual void reshape(S32 width, S32 height, bool called_from_parent  = true) override;      /** Returns full rect of child panel */      const LLRect& getItemsRect() const; -    LLRect getRequiredRect() { return getItemsRect(); } +    LLRect getRequiredRect() override { return getItemsRect(); }      /** Returns distance between items */ -    const S32 getItemsPad() { return mItemPad; } +    const S32 getItemsPad() const { return mItemPad; }      /**       * Adds and item and LLSD value associated with it to the list at specified position @@ -264,13 +264,13 @@ public:      void setCommitOnSelectionChange(bool b)     { mCommitOnSelectionChange = b; }      /** Get number of selected items in the list */ -    U32 numSelected() const {return static_cast<U32>(mSelectedItemPairs.size()); } +    U32 numSelected() const { return static_cast<U32>(mSelectedItemPairs.size()); }      /** Get number of (visible) items in the list */      U32 size(const bool only_visible_items = true) const;      /** Removes all items from the list */ -    virtual void clear(); +    virtual void clear() override;      /**       * Removes all items that can be detached from the list but doesn't destroy @@ -294,10 +294,10 @@ public:      void scrollToShowFirstSelectedItem(); -    void selectFirstItem    (); -    void selectLastItem     (); +    void selectFirstItem(); +    void selectLastItem(); -    virtual S32 notify(const LLSD& info) ; +    virtual S32 notify(const LLSD& info) override;      virtual ~LLFlatListView(); @@ -346,8 +346,8 @@ protected:      virtual bool selectNextItemPair(bool is_up_direction, bool reset_selection); -    virtual bool canSelectAll() const; -    virtual void selectAll(); +    virtual bool canSelectAll() const override; +    virtual void selectAll() override;      virtual bool isSelected(item_pair_t* item_pair) const; @@ -364,15 +364,15 @@ protected:       */      void notifyParentItemsRectChanged(); -    virtual bool handleKeyHere(KEY key, MASK mask); +    virtual bool handleKeyHere(KEY key, MASK mask) override; -    virtual bool postBuild(); +    virtual bool postBuild() override; -    virtual void onFocusReceived(); +    virtual void onFocusReceived() override; -    virtual void onFocusLost(); +    virtual void onFocusLost() override; -    virtual void draw(); +    virtual void draw() override;      LLRect getLastSelectedItemRect(); @@ -478,7 +478,7 @@ public:      void setNoItemsMsg(const std::string& msg) { mNoItemsMsg = msg; }      void setNoFilteredItemsMsg(const std::string& msg) { mNoFilteredItemsMsg = msg; } -    bool getForceShowingUnmatchedItems(); +    bool getForceShowingUnmatchedItems() const;      void setForceShowingUnmatchedItems(bool show); @@ -486,7 +486,7 @@ public:       * Sets up new filter string and filters the list.       */      void setFilterSubString(const std::string& filter_str, bool notify_parent); -    std::string getFilterSubString() { return mFilterSubString; } +    std::string getFilterSubString() const { return mFilterSubString; }      /**       * Filters the list, rearranges and notifies parent about shape changes. diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 4b904f09e0..fd07b2ec5d 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2165,7 +2165,7 @@ void LLFloater::setCanDrag(bool can_drag)      }  } -bool LLFloater::getCanDrag() +bool LLFloater::getCanDrag() const  {      return mDragHandle->getEnabled();  } diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index eae2435117..9e1594bdd2 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -46,24 +46,24 @@ class LLMultiFloater;  class LLFloater; -const bool RESIZE_YES = true; -const bool RESIZE_NO = false; +constexpr bool RESIZE_YES = true; +constexpr bool RESIZE_NO = false; -const bool DRAG_ON_TOP = false; -const bool DRAG_ON_LEFT = true; +constexpr bool DRAG_ON_TOP = false; +constexpr bool DRAG_ON_LEFT = true; -const bool MINIMIZE_YES = true; -const bool MINIMIZE_NO = false; +constexpr bool MINIMIZE_YES = true; +constexpr bool MINIMIZE_NO = false; -const bool CLOSE_YES = true; -const bool CLOSE_NO = false; +constexpr bool CLOSE_YES = true; +constexpr bool CLOSE_NO = false; -const bool ADJUST_VERTICAL_YES = true; -const bool ADJUST_VERTICAL_NO = false; +constexpr bool ADJUST_VERTICAL_YES = true; +constexpr bool ADJUST_VERTICAL_NO = false; -const F32 CONTEXT_CONE_IN_ALPHA = 0.f; -const F32 CONTEXT_CONE_OUT_ALPHA = 1.f; -const F32 CONTEXT_CONE_FADE_TIME = .08f; +constexpr F32 CONTEXT_CONE_IN_ALPHA = 0.f; +constexpr F32 CONTEXT_CONE_OUT_ALPHA = 1.f; +constexpr F32 CONTEXT_CONE_FADE_TIME = .08f;  namespace LLFloaterEnums  { @@ -228,7 +228,7 @@ public:      /*virtual*/ void setIsChrome(bool is_chrome);      /*virtual*/ void setRect(const LLRect &rect);                  void setIsSingleInstance(bool is_single_instance); -                bool getIsSingleInstance() { return mSingleInstance; } +                bool getIsSingleInstance() const { return mSingleInstance; }      void            initFloater(const Params& p); @@ -274,17 +274,17 @@ public:      static bool     isShown(const LLFloater* floater);      static bool     isVisible(const LLFloater* floater);      static bool     isMinimized(const LLFloater* floater); -    bool            isFirstLook() { return mFirstLook; } // EXT-2653: This function is necessary to prevent overlapping for secondary showed toasts +    bool            isFirstLook() const { return mFirstLook; } // EXT-2653: This function is necessary to prevent overlapping for secondary showed toasts      virtual bool    isFrontmost(); -    bool            isDependent()                   { return !mDependeeHandle.isDead(); } +    bool            isDependent() const { return !mDependeeHandle.isDead(); }      void            setCanMinimize(bool can_minimize);      void            setCanClose(bool can_close);      void            setCanTearOff(bool can_tear_off);      virtual void    setCanResize(bool can_resize);      void            setCanDrag(bool can_drag); -    bool            getCanDrag(); +    bool            getCanDrag() const;      void            setHost(LLMultiFloater* host); -    bool            isResizable() const             { return mResizable; } +    bool            isResizable() const { return mResizable; }      void            setResizeLimits( S32 min_width, S32 min_height );      void            getResizeLimits( S32* min_width, S32* min_height ) { *min_width = mMinWidth; *min_height = mMinHeight; } @@ -347,7 +347,7 @@ public:      virtual void    setDocked(bool docked, bool pop_on_undock = true);      virtual void    setTornOff(bool torn_off) { mTornOff = torn_off; } -    bool isTornOff() {return mTornOff;} +    bool isTornOff() const { return mTornOff; }      void setOpenPositioning(LLFloaterEnums::EOpenPositioning pos) {mPositioning = pos;} @@ -425,7 +425,6 @@ protected:  private:      void            setForeground(bool b);  // called only by floaterview      void            cleanupHandles(); // remove handles to dead floaters -    void            createMinimizeButton();      void            buildButtons(const Params& p);      // Images and tooltips are named in the XML, but we want to look them diff --git a/indra/llui/llfloaterreglistener.h b/indra/llui/llfloaterreglistener.h index a36072892c..28f6e7c66b 100644 --- a/indra/llui/llfloaterreglistener.h +++ b/indra/llui/llfloaterreglistener.h @@ -30,7 +30,6 @@  #define LL_LLFLOATERREGLISTENER_H  #include "lleventapi.h" -#include <string>  class LLSD; diff --git a/indra/llui/llflyoutbutton.h b/indra/llui/llflyoutbutton.h index 7a49501318..73190fc984 100644 --- a/indra/llui/llflyoutbutton.h +++ b/indra/llui/llflyoutbutton.h @@ -54,7 +54,7 @@ protected:      LLFlyoutButton(const Params&);      friend class LLUICtrlFactory;  public: -    virtual void    draw(); +    void draw() override;      void setToggleState(bool state); diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index 1fa0ac137e..89fee5c9f1 100644 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -97,7 +97,7 @@ public:      LLFocusableElement*     getLastKeyboardFocus() const { return mLastKeyboardFocus; }      bool            childHasKeyboardFocus( const LLView* parent ) const;      void            removeKeyboardFocusWithoutCallback( const LLFocusableElement* focus ); -    bool            getKeystrokesOnly() { return mKeystrokesOnly; } +    bool            getKeystrokesOnly() const { return mKeystrokesOnly; }      void            setKeystrokesOnly(bool keystrokes_only) { mKeystrokesOnly = keystrokes_only; }      F32             getFocusFlashAmt() const; diff --git a/indra/llui/llfolderview.h b/indra/llui/llfolderview.h index 7ed10d9223..bdce9dec54 100644 --- a/indra/llui/llfolderview.h +++ b/indra/llui/llfolderview.h @@ -124,11 +124,11 @@ public:      void setSelectCallback(const signal_t::slot_type& cb) { mSelectSignal.connect(cb); }      void setReshapeCallback(const signal_t::slot_type& cb) { mReshapeSignal.connect(cb); } -    bool getAllowMultiSelect() { return mAllowMultiSelect; } -    bool getAllowDrag() { return mAllowDrag; } +    bool getAllowMultiSelect() const { return mAllowMultiSelect; } +    bool getAllowDrag() const { return mAllowDrag; }      void setSingleFolderMode(bool is_single_mode) { mSingleFolderMode = is_single_mode; } -    bool isSingleFolderMode() { return mSingleFolderMode; } +    bool isSingleFolderMode() const { return mSingleFolderMode; }      // Close all folders in the view      void closeAllFolders(); @@ -142,7 +142,7 @@ public:      virtual S32 getItemHeight() const;      void arrangeAll() { mArrangeGeneration++; } -    S32 getArrangeGeneration() { return mArrangeGeneration; } +    S32 getArrangeGeneration() const { return mArrangeGeneration; }      // applies filters to control visibility of items      virtual void filter( LLFolderViewFilter& filter); @@ -227,27 +227,27 @@ public:      void setShowSelectionContext(bool show) { mShowSelectionContext = show; }      bool getShowSelectionContext();      void setShowSingleSelection(bool show); -    bool getShowSingleSelection() { return mShowSingleSelection; } -    F32  getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); } -    bool getUseEllipses() { return mUseEllipses; } -    S32 getSelectedCount() { return (S32)mSelectedItems.size(); } +    bool getShowSingleSelection() const { return mShowSingleSelection; } +    F32  getSelectionFadeElapsedTime() const { return mMultiSelectionFadeTimer.getElapsedTimeF32(); } +    bool getUseEllipses() const { return mUseEllipses; } +    S32 getSelectedCount() const { return (S32)mSelectedItems.size(); } -    void    update();                       // needs to be called periodically (e.g. once per frame) +    void update(); // needs to be called periodically (e.g. once per frame) -    bool needsAutoSelect() { return mNeedsAutoSelect && !mAutoSelectOverride; } -    bool needsAutoRename() { return mNeedsAutoRename; } +    bool needsAutoSelect() const { return mNeedsAutoSelect && !mAutoSelectOverride; } +    bool needsAutoRename() const { return mNeedsAutoRename; }      void setNeedsAutoRename(bool val) { mNeedsAutoRename = val; }      void setPinningSelectedItem(bool val) { mPinningSelectedItem = val; }      void setAutoSelectOverride(bool val) { mAutoSelectOverride = val; } -    bool showItemLinkOverlays() { return mShowItemLinkOverlays; } +    bool showItemLinkOverlays() const { return mShowItemLinkOverlays; }      void setCallbackRegistrar(LLUICtrl::CommitCallbackRegistry::ScopedRegistrar* registrar) { mCallbackRegistrar = registrar; }      void setEnableRegistrar(LLUICtrl::EnableCallbackRegistry::ScopedRegistrar* registrar) { mEnableRegistrar = registrar; }      void setForceArrange(bool force) { mForceArrange = force; } -    LLPanel* getParentPanel() { return mParentPanel.get(); } +    LLPanel* getParentPanel() const { return mParentPanel.get(); }      // DEBUG only      void dumpSelectionInformation(); @@ -255,7 +255,7 @@ public:      void setShowEmptyMessage(bool show_msg) { mShowEmptyMessage = show_msg; } -    bool useLabelSuffix() { return mUseLabelSuffix; } +    bool useLabelSuffix() const { return mUseLabelSuffix; }      virtual void updateMenu();      void finishRenamingItem( void ); @@ -391,7 +391,7 @@ public:      virtual ~LLSelectFirstFilteredItem() {}      virtual void doFolder(LLFolderViewFolder* folder);      virtual void doItem(LLFolderViewItem* item); -    bool wasItemSelected() { return mItemSelected || mFolderSelected; } +    bool wasItemSelected() const { return mItemSelected || mFolderSelected; }  protected:      bool mItemSelected;      bool mFolderSelected; diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index cc8a7d934c..234d0dc7f9 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -282,7 +282,7 @@ public:      // Does not need filter update      virtual void refreshSuffix(); -    bool isSingleFolderMode() { return mSingleFolderMode; } +    bool isSingleFolderMode() const { return mSingleFolderMode; }      // LLView functionality      virtual bool handleRightMouseDown( S32 x, S32 y, MASK mask ); @@ -415,9 +415,6 @@ public:      // doesn't delete it.      virtual void extractItem( LLFolderViewItem* item, bool deparent_model = true); -    // This function is called by a child that needs to be resorted. -    void resort(LLFolderViewItem* item); -      void setAutoOpenCountdown(F32 countdown) { mAutoOpenCountdown = countdown; }      // folders can be opened. This will usually be called by internal diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 7bf43c22c1..2bea8fb4ed 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -170,7 +170,7 @@ std::string LLKeywords::getAttribute(std::string_view key)      return (it != mAttributes.end()) ? it->second : "";  } -LLUIColor LLKeywords::getColorGroup(std::string_view key_in) +LLUIColor LLKeywords::getColorGroup(std::string_view key_in) const  {      std::string color_group = "ScriptText";      if (key_in == "functions") diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 328561c92a..5892238593 100644 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -111,8 +111,8 @@ public:      ~LLKeywords();      void        clearLoaded() { mLoaded = false; } -    LLUIColor    getColorGroup(std::string_view key_in); -    bool        isLoaded() const    { return mLoaded; } +    LLUIColor    getColorGroup(std::string_view key_in) const; +    bool        isLoaded() const { return mLoaded; }      void        findSegments(std::vector<LLTextSegmentPtr> *seg_list,                               const LLWString& text, diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 1c59938f90..fe0591ce4b 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -36,8 +36,8 @@  #include "lliconctrl.h"  #include "boost/foreach.hpp" -static const F32 MIN_FRACTIONAL_SIZE = 0.00001f; -static const F32 MAX_FRACTIONAL_SIZE = 1.f; +static constexpr F32 MIN_FRACTIONAL_SIZE = 0.00001f; +static constexpr F32 MAX_FRACTIONAL_SIZE = 1.f;  static LLDefaultChildRegistry::Register<LLLayoutStack> register_layout_stack("layout_stack");  static LLLayoutStack::LayoutStackRegistry::Register<LLLayoutPanel> register_layout_panel("layout_panel"); diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 8459921c60..9e3536aaff 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -75,9 +75,6 @@ public:      /*virtual*/ bool addChild(LLView* child, S32 tab_group = 0);      /*virtual*/ void reshape(S32 width, S32 height, bool called_from_parent = true); - -    static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL); -      typedef enum e_animate      {          NO_ANIMATE, @@ -86,7 +83,7 @@ public:      void addPanel(LLLayoutPanel* panel, EAnimate animate = NO_ANIMATE);      void collapsePanel(LLPanel* panel, bool collapsed = true); -    S32 getNumPanels() { return static_cast<S32>(mPanels.size()); } +    S32 getNumPanels() const { return static_cast<S32>(mPanels.size()); }      void updateLayout(); @@ -190,7 +187,6 @@ public:      bool isCollapsed() const { return mCollapsed;}      void setOrientation(LLView::EOrientation orientation); -    void storeOriginalDim();      void setIgnoreReshape(bool ignore) { mIgnoreReshape = ignore; } diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 12fe800acb..7533f76f1d 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -306,8 +306,6 @@ public:      S32             calcCursorPos(S32 mouse_x);      bool            handleSpecialKey(KEY key, MASK mask);      bool            handleSelectionKey(KEY key, MASK mask); -    bool            handleControlKey(KEY key, MASK mask); -    S32             handleCommitKey(KEY key, MASK mask);      void            updateTextPadding();      // Draw the background image depending on enabled/focused state. @@ -444,7 +442,7 @@ private:              mText = ed->getText();          } -        void doRollback( LLLineEditor* ed ) +        void doRollback(LLLineEditor* ed) const          {              ed->mCursorPos = mCursorPos;              ed->mScrollHPos = mScrollHPos; @@ -455,7 +453,7 @@ private:              ed->mPrevText = mText;          } -        std::string getText()   { return mText; } +        std::string getText() const { return mText; }      private:          std::string mText; diff --git a/indra/llui/llmenubutton.h b/indra/llui/llmenubutton.h index a77ae7dae7..3f96b28246 100644 --- a/indra/llui/llmenubutton.h +++ b/indra/llui/llmenubutton.h @@ -65,8 +65,8 @@ public:      boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb ); -    /*virtual*/ bool handleMouseDown(S32 x, S32 y, MASK mask); -    /*virtual*/ bool handleKeyHere(KEY key, MASK mask ); +    bool handleMouseDown(S32 x, S32 y, MASK mask) override; +    bool handleKeyHere(KEY key, MASK mask) override;      void hideMenu(); diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 66f84393fe..ff9456acc6 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -439,8 +439,6 @@ protected:  public:      virtual ~LLMenuGL( void ); -    void parseChildXML(LLXMLNodePtr child, LLView* parent); -      // LLView Functionality      /*virtual*/ bool handleUnicodeCharHere( llwchar uni_char );      /*virtual*/ bool handleHover( S32 x, S32 y, MASK mask ); diff --git a/indra/llui/llmultifloater.cpp b/indra/llui/llmultifloater.cpp index a7f9b8b2d9..f53e22c349 100644 --- a/indra/llui/llmultifloater.cpp +++ b/indra/llui/llmultifloater.cpp @@ -390,7 +390,7 @@ LLFloater* LLMultiFloater::getActiveFloater()      return (LLFloater*)mTabContainer->getCurrentPanel();  } -S32 LLMultiFloater::getFloaterCount() +S32 LLMultiFloater::getFloaterCount() const  {      return mTabContainer->getTabCount();  } diff --git a/indra/llui/llmultifloater.h b/indra/llui/llmultifloater.h index eb0f917695..e0cd58aa3f 100644 --- a/indra/llui/llmultifloater.h +++ b/indra/llui/llmultifloater.h @@ -66,7 +66,7 @@ public:      virtual LLFloater*  getActiveFloater();      virtual bool        isFloaterFlashing(LLFloater* floaterp); -    virtual S32         getFloaterCount(); +    virtual S32         getFloaterCount() const;      virtual void setFloaterFlashing(LLFloater* floaterp, bool flashing);      virtual bool closeAllFloaters();    //Returns false if the floater could not be closed due to pending confirmation dialogs diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h index b2bfc8bc84..af255bcc8f 100644 --- a/indra/llui/llmultislider.h +++ b/indra/llui/llmultislider.h @@ -117,10 +117,10 @@ public:      /*virtual*/ void    onMouseLeave(S32 x, S32 y, MASK mask) override;      /*virtual*/ void    draw() override; -    S32             getMaxNumSliders() { return mMaxNumSliders; } -    S32             getCurNumSliders() { return static_cast<S32>(mValue.size()); } -    F32             getOverlapThreshold() { return mOverlapThreshold; } -    bool            canAddSliders() { return mValue.size() < mMaxNumSliders; } +    S32             getMaxNumSliders() const { return mMaxNumSliders; } +    S32             getCurNumSliders() const { return static_cast<S32>(mValue.size()); } +    F32             getOverlapThreshold() const { return mOverlapThreshold; } +    bool            canAddSliders() const { return mValue.size() < mMaxNumSliders; }  protected: diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h index dec6cb48b9..2c2bc5e4d9 100644 --- a/indra/llui/llmultisliderctrl.h +++ b/indra/llui/llmultisliderctrl.h @@ -124,10 +124,10 @@ public:      F32             getMinValue() const { return mMultiSlider->getMinValue(); }      F32             getMaxValue() const { return mMultiSlider->getMaxValue(); } -    S32             getMaxNumSliders() { return mMultiSlider->getMaxNumSliders(); } -    S32             getCurNumSliders() { return mMultiSlider->getCurNumSliders(); } -    F32             getOverlapThreshold() { return mMultiSlider->getOverlapThreshold(); } -    bool            canAddSliders() { return mMultiSlider->canAddSliders(); } +    S32             getMaxNumSliders() const { return mMultiSlider->getMaxNumSliders(); } +    S32             getCurNumSliders() const { return mMultiSlider->getCurNumSliders(); } +    F32             getOverlapThreshold() const { return mMultiSlider->getOverlapThreshold(); } +    bool            canAddSliders() const { return mMultiSlider->canAddSliders(); }      void            setLabel(const std::string& label)              { if (mLabelBox) mLabelBox->setText(label); }      void            setLabelColor(const LLUIColor& c)            { mTextEnabledColor = c; } @@ -147,7 +147,6 @@ public:      static void     onEditorCommit(LLUICtrl* ctrl, const LLSD& userdata);      static void     onEditorGainFocus(LLFocusableElement* caller, void *userdata); -    static void     onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);  private:      void            updateText(); diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 138f1969d5..3c8e1e85fa 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -247,7 +247,6 @@ public:      LLNotificationForm(const LLSD& sd);      LLNotificationForm(const std::string& name, const Params& p); -    void fromLLSD(const LLSD& sd);      LLSD asLLSD() const;      S32 getNumElements() { return static_cast<S32>(mFormData.size()); } @@ -266,8 +265,8 @@ public:      bool getIgnored();      void setIgnored(bool ignored); -    EIgnoreType getIgnoreType() { return mIgnore; } -    std::string getIgnoreMessage() { return mIgnoreMsg; } +    EIgnoreType getIgnoreType()const { return mIgnore; } +    std::string getIgnoreMessage() const { return mIgnoreMsg; }  private:      LLSD                                mFormData; @@ -971,8 +970,6 @@ private:      /*virtual*/ void initSingleton() override;      /*virtual*/ void cleanupSingleton() override; -    void loadPersistentNotifications(); -      bool expirationFilter(LLNotificationPtr pNotification);      bool expirationHandler(const LLSD& payload);      bool uniqueFilter(LLNotificationPtr pNotification); diff --git a/indra/llui/llprogressbar.h b/indra/llui/llprogressbar.h index 0d5d32cf21..7245bbf1cf 100644 --- a/indra/llui/llprogressbar.h +++ b/indra/llui/llprogressbar.h @@ -48,9 +48,9 @@ public:      LLProgressBar(const Params&);      virtual ~LLProgressBar(); -    void setValue(const LLSD& value); +    void setValue(const LLSD& value) override; -    /*virtual*/ void draw(); +    void draw() override;  private:      F32 mPercentDone; diff --git a/indra/llui/llresizebar.h b/indra/llui/llresizebar.h index 4b0f435834..68bf0fd95e 100644 --- a/indra/llui/llresizebar.h +++ b/indra/llui/llresizebar.h @@ -61,7 +61,7 @@ public:      void            setResizeLimits( S32 min_size, S32 max_size ) { mMinSize = min_size; mMaxSize = max_size; }      void            setEnableSnapping(bool enable) { mSnappingEnabled = enable; }      void            setAllowDoubleClickSnapping(bool allow) { mAllowDoubleClickSnapping = allow; } -    bool            canResize() { return getEnabled() && mMaxSize > mMinSize; } +    bool            canResize() const { return getEnabled() && mMaxSize > mMinSize; }      void            setResizeListener(boost::function<void(void*)> listener) {mResizeListener = listener;}      void            setImagePanel(LLPanel * panelp);      LLPanel *       getImagePanel() const; diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h index 9cc4123544..caec33405c 100644 --- a/indra/llui/llresizehandle.h +++ b/indra/llui/llresizehandle.h @@ -50,10 +50,10 @@ protected:      LLResizeHandle(const LLResizeHandle::Params&);      friend class LLUICtrlFactory;  public: -    virtual void    draw(); -    virtual bool    handleHover(S32 x, S32 y, MASK mask); -    virtual bool    handleMouseDown(S32 x, S32 y, MASK mask); -    virtual bool    handleMouseUp(S32 x, S32 y, MASK mask); +    void    draw() override; +    bool    handleHover(S32 x, S32 y, MASK mask) override; +    bool    handleMouseDown(S32 x, S32 y, MASK mask) override; +    bool    handleMouseUp(S32 x, S32 y, MASK mask) override;      void            setResizeLimits( S32 min_width, S32 min_height ) { mMinWidth = min_width; mMinHeight = min_height; } @@ -71,8 +71,8 @@ private:      const ECorner   mCorner;  }; -const S32 RESIZE_HANDLE_HEIGHT = 11; -const S32 RESIZE_HANDLE_WIDTH = 11; +constexpr S32 RESIZE_HANDLE_HEIGHT = 11; +constexpr S32 RESIZE_HANDLE_WIDTH = 11;  #endif  // LL_RESIZEHANDLE_H diff --git a/indra/llui/llrngwriter.h b/indra/llui/llrngwriter.h index 33ec049a1a..2c39472607 100644 --- a/indra/llui/llrngwriter.h +++ b/indra/llui/llrngwriter.h @@ -37,7 +37,7 @@ public:      void writeRNG(const std::string& name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace);      void addDefinition(const std::string& type_name, const LLInitParam::BaseBlock& block); -    /*virtual*/ std::string getCurrentElementName() { return LLStringUtil::null; } +    std::string getCurrentElementName() override { return LLStringUtil::null; }      LLRNGWriter(); diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h index e7ff5c8424..7dded3c0b7 100644 --- a/indra/llui/llscrolllistcell.h +++ b/indra/llui/llscrolllistcell.h @@ -105,7 +105,7 @@ public:      virtual const LLSD      getAltValue() const;      virtual void            setValue(const LLSD& value) { }      virtual void            setAltValue(const LLSD& value) { } -    virtual const std::string &getToolTip() const { return mToolTip; } +    virtual const std::string& getToolTip() const { return mToolTip; }      virtual void            setToolTip(const std::string &str) { mToolTip = str; }      virtual bool            getVisible() const { return true; }      virtual void            setWidth(S32 width) { mWidth = width; } diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index c24784338a..1f04100306 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -165,7 +165,6 @@ public:      void            deleteAllItems() { clearRows(); }      // Sets an array of column descriptors -    void            setColumnHeadings(const LLSD& headings);      void            sortByColumnIndex(U32 column, bool ascending);      // LLCtrlListInterface functions @@ -318,7 +317,7 @@ public:      void setAllowKeyboardMovement(bool b)       { mAllowKeyboardMovement = b; }      void            setMaxSelectable(U32 max_selected) { mMaxSelectable = max_selected; } -    S32             getMaxSelectable() { return mMaxSelectable; } +    S32             getMaxSelectable() const { return mMaxSelectable; }      virtual S32     getScrollPos() const; @@ -334,7 +333,7 @@ public:      // support right-click context menus for avatar/group lists      enum ContextMenuType { MENU_NONE, MENU_AVATAR, MENU_GROUP };      void setContextMenu(const ContextMenuType &menu) { mContextMenuType = menu; } -    ContextMenuType getContextMenuType() { return mContextMenuType; } +    ContextMenuType getContextMenuType() const { return mContextMenuType; }      // Overridden from LLView      /*virtual*/ void    draw(); @@ -362,7 +361,6 @@ public:      virtual void    fitContents(S32 max_width, S32 max_height);      virtual LLRect  getRequiredRect(); -    static  bool    rowPreceeds(LLScrollListItem *new_row, LLScrollListItem *test_row);      LLRect          getItemListRect() { return mItemListRect; } @@ -384,7 +382,6 @@ public:       * then display all items.       */      void setPageLines(S32 page_lines ); -    void setCollapseEmptyColumns(bool collapse);      LLScrollListItem*   hitItem(S32 x,S32 y);      virtual void        scrollToShowSelected(); @@ -401,7 +398,7 @@ public:      void            setNumDynamicColumns(S32 num) { mNumDynamicWidthColumns = num; }      void            updateStaticColumnWidth(LLScrollListColumn* col, S32 new_width); -    S32             getTotalStaticColumnWidth() { return mTotalStaticColumnWidth; } +    S32             getTotalStaticColumnWidth() const { return mTotalStaticColumnWidth; }      std::string     getSortColumnName();      bool            getSortAscending() { return mSortColumns.empty() ? true : mSortColumns.back().second; } diff --git a/indra/llui/llsliderctrl.h b/indra/llui/llsliderctrl.h index 311377a61f..23ce8fd955 100644 --- a/indra/llui/llsliderctrl.h +++ b/indra/llui/llsliderctrl.h @@ -132,7 +132,6 @@ public:      static void     onEditorCommit(LLUICtrl* ctrl, const LLSD& userdata);      static void     onEditorGainFocus(LLFocusableElement* caller, void *userdata); -    static void     onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);  protected:      virtual std::string _getSearchText() const diff --git a/indra/llui/llspinctrl.h b/indra/llui/llspinctrl.h index 58b38dc630..4ba8c97c63 100644 --- a/indra/llui/llspinctrl.h +++ b/indra/llui/llspinctrl.h @@ -94,7 +94,6 @@ public:      void            onEditorCommit(const LLSD& data);      static void     onEditorGainFocus(LLFocusableElement* caller, void *userdata);      static void     onEditorLostFocus(LLFocusableElement* caller, void *userdata); -    static void     onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);      void            onUpBtn(const LLSD& data);      void            onDownBtn(const LLSD& data); diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index c36a138566..bbbf0b3a19 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -67,7 +67,7 @@ public:      void setStat(const std::string& stat_name);      void setRange(F32 bar_min, F32 bar_max); -    void getRange(F32& bar_min, F32& bar_max) { bar_min = mTargetMinBar; bar_max = mTargetMaxBar; } +    void getRange(F32& bar_min, F32& bar_max) const { bar_min = mTargetMinBar; bar_max = mTargetMaxBar; }      /*virtual*/ LLRect getRequiredRect();   // Return the height of this object, given the set options. diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index d97051247e..0af717d447 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -36,7 +36,6 @@  #include "llglheaders.h"  #include "lltracerecording.h"  #include "lltracethreadrecorder.h" -//#include "llviewercontrol.h"  /////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index c254821870..6d9e3d1064 100644 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -99,9 +99,7 @@ public:      void setMin(const F32 min);      void setMax(const F32 max); -    virtual void draw(); - -    /*virtual*/ void setValue(const LLSD& value); +    void draw() override;  private:      LLTrace::StatType<LLTrace::CountAccumulator>*   mNewStatFloatp; @@ -133,9 +131,6 @@ private:      };      typedef std::vector<Threshold> threshold_vec_t;      threshold_vec_t mThresholds; -    //S32 mNumThresholds; -    //F32 mThresholds[4]; -    //LLColor4 mThresholdColors[4];  };  #endif  // LL_LLSTATGRAPH_H diff --git a/indra/llui/llstatview.h b/indra/llui/llstatview.h index b5187f886d..a396773057 100644 --- a/indra/llui/llstatview.h +++ b/indra/llui/llstatview.h @@ -29,7 +29,6 @@  #include "llstatbar.h"  #include "llcontainerview.h" -#include <vector>  class LLStatBar; diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 595ab0bd2b..5e0985c79c 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -1370,17 +1370,17 @@ LLPanel* LLTabContainer::getCurrentPanel()      return NULL;  } -S32 LLTabContainer::getCurrentPanelIndex() +S32 LLTabContainer::getCurrentPanelIndex() const  {      return mCurrentTabIdx;  } -S32 LLTabContainer::getTabCount() +S32 LLTabContainer::getTabCount() const  {      return static_cast<S32>(mTabList.size());  } -LLPanel* LLTabContainer::getPanelByIndex(S32 index) +LLPanel* LLTabContainer::getPanelByIndex(S32 index) const  {      if (index >= 0 && index < (S32)mTabList.size())      { @@ -1389,7 +1389,7 @@ LLPanel* LLTabContainer::getPanelByIndex(S32 index)      return NULL;  } -S32 LLTabContainer::getIndexForPanel(LLPanel* panel) +S32 LLTabContainer::getIndexForPanel(LLPanel* panel) const  {      for (S32 index = 0; index < (S32)mTabList.size(); index++)      { @@ -1401,7 +1401,7 @@ S32 LLTabContainer::getIndexForPanel(LLPanel* panel)      return -1;  } -S32 LLTabContainer::getPanelIndexByTitle(std::string_view title) +S32 LLTabContainer::getPanelIndexByTitle(std::string_view title) const  {      for (S32 index = 0 ; index < (S32)mTabList.size(); index++)      { diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index 40f272ffa8..4ac7e73d25 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -182,15 +182,15 @@ public:      void        removeTabPanel( LLPanel* child );      void        lockTabs(S32 num_tabs = 0);      void        unlockTabs(); -    S32         getNumLockedTabs() { return mLockedTabCount; } +    S32         getNumLockedTabs() const { return mLockedTabCount; }      void        enableTabButton(S32 which, bool enable);      void        deleteAllTabs();      LLPanel*    getCurrentPanel(); -    S32         getCurrentPanelIndex(); -    S32         getTabCount(); -    LLPanel*    getPanelByIndex(S32 index); -    S32         getIndexForPanel(LLPanel* panel); -    S32         getPanelIndexByTitle(std::string_view title); +    S32         getCurrentPanelIndex() const; +    S32         getTabCount() const; +    LLPanel*    getPanelByIndex(S32 index) const; +    S32         getIndexForPanel(LLPanel* panel) const; +    S32         getPanelIndexByTitle(std::string_view title) const;      LLPanel*    getPanelByName(std::string_view name);      S32         getTotalTabWidth() const;      void        setCurrentTabName(const std::string& name); diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 76d4e160af..e62b56963d 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -145,7 +145,6 @@ public:      /*virtual*/ void                setStyle(LLStyleConstSP style)  { mStyle = style; }      /*virtual*/ void                setToken( LLKeywordToken* token )   { mToken = token; }      /*virtual*/ LLKeywordToken*     getToken() const                    { return mToken; } -    /*virtual*/ bool                getToolTip( std::string& msg ) const;      /*virtual*/ void                setToolTip(const std::string& tooltip);      /*virtual*/ void                dump() const; @@ -450,7 +449,7 @@ public:      virtual void            setText(const LLStringExplicit &utf8str , const LLStyle::Params& input_params = LLStyle::Params()); // uses default style      /*virtual*/ const std::string& getText() const override;      void                    setMaxTextLength(S32 length) { mMaxTextByteLength = length; } -    S32                     getMaxTextLength() { return mMaxTextByteLength; } +    S32                     getMaxTextLength() const { return mMaxTextByteLength; }      // wide-char versions      void                    setWText(const LLWString& text); @@ -489,10 +488,10 @@ public:      LLRect                  getTextBoundingRect();      LLRect                  getVisibleDocumentRect() const; -    S32                     getVPad() { return mVPad; } -    S32                     getHPad() { return mHPad; } -    F32                     getLineSpacingMult() { return mLineSpacingMult; } -    S32                     getLineSpacingPixels() { return mLineSpacingPixels; } // only for multiline +    S32                     getVPad() const { return mVPad; } +    S32                     getHPad() const { return mHPad; } +    F32                     getLineSpacingMult() const { return mLineSpacingMult; } +    S32                     getLineSpacingPixels() const { return mLineSpacingPixels; } // only for multiline      S32                     getDocIndexFromLocalCoord( S32 local_x, S32 local_y, bool round, bool hit_past_end_of_line = true) const;      LLRect                  getLocalRectFromDocIndex(S32 pos) const; @@ -502,7 +501,7 @@ public:      bool                    getReadOnly() const { return mReadOnly; }      void                    setSkipLinkUnderline(bool skip_link_underline) { mSkipLinkUnderline = skip_link_underline; } -    bool                    getSkipLinkUnderline() { return mSkipLinkUnderline;  } +    bool                    getSkipLinkUnderline() const { return mSkipLinkUnderline;  }      void                    setParseURLs(bool parse_urls) { mParseHTML = parse_urls; } @@ -516,8 +515,8 @@ public:      void                    endOfLine();      void                    startOfDoc();      void                    endOfDoc(); -    void                    changePage( S32 delta ); -    void                    changeLine( S32 delta ); +    void                    changePage(S32 delta); +    void                    changeLine(S32 delta);      bool                    scrolledToStart();      bool                    scrolledToEnd(); @@ -675,7 +674,6 @@ protected:      void                            appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params = LLStyle::Params());      void                            appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only = false); -    S32 normalizeUri(std::string& uri);  protected:      // virtual diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h index 500dc8669f..507d8f3ee6 100644 --- a/indra/llui/lltextbox.h +++ b/indra/llui/lltextbox.h @@ -46,39 +46,39 @@ protected:      friend class LLUICtrlFactory;  public: -    virtual ~LLTextBox(); +    ~LLTextBox() override; -    /*virtual*/ bool handleMouseDown(S32 x, S32 y, MASK mask); -    /*virtual*/ bool handleMouseUp(S32 x, S32 y, MASK mask); -    /*virtual*/ bool handleHover(S32 x, S32 y, MASK mask); +    bool handleMouseDown(S32 x, S32 y, MASK mask) override; +    bool handleMouseUp(S32 x, S32 y, MASK mask) override; +    bool handleHover(S32 x, S32 y, MASK mask) override; -    /*virtual*/ void setEnabled(bool enabled); +    void setEnabled(bool enabled) override; -    /*virtual*/ void setText( const LLStringExplicit& text, const LLStyle::Params& input_params = LLStyle::Params() ); +    void setText(const LLStringExplicit& text, const LLStyle::Params& input_params = LLStyle::Params()) override; -    void            setRightAlign()                         { mHAlign = LLFontGL::RIGHT; } -    void            setHAlign( LLFontGL::HAlign align )     { mHAlign = align; } -    void            setClickedCallback( boost::function<void (void*)> cb, void* userdata = NULL ); +    void setRightAlign() { mHAlign = LLFontGL::RIGHT; } +    void setHAlign(LLFontGL::HAlign align) { mHAlign = align; } +    void setClickedCallback(boost::function<void(void*)> cb, void* userdata = NULL); -    void            reshapeToFitText(bool called_from_parent = false); +    void reshapeToFitText(bool called_from_parent = false); -    S32             getTextPixelWidth(); -    S32             getTextPixelHeight(); +    S32 getTextPixelWidth(); +    S32 getTextPixelHeight(); -    /*virtual*/ LLSD    getValue() const; -    /*virtual*/ bool    setTextArg( const std::string& key, const LLStringExplicit& text ); +    LLSD getValue() const override; +    bool setTextArg(const std::string& key, const LLStringExplicit& text) override; -    void            setShowCursorHand(bool show_cursor) { mShowCursorHand = show_cursor; } +    void setShowCursorHand(bool show_cursor) { mShowCursorHand = show_cursor; }  protected: -    void            onUrlLabelUpdated(const std::string &url, const std::string &label); +    void onUrlLabelUpdated(const std::string& url, const std::string& label);      LLUIString          mText;      callback_t          mClickedCallback;      bool                mShowCursorHand;  protected: -    virtual std::string _getSearchText() const +    virtual std::string _getSearchText() const override      {          return LLTextBase::_getSearchText() + mText.getString();      } diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index b2b14b01e2..353a7b93a0 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -200,7 +200,6 @@ public:      const LLUUID&   getSourceID() const                     { return mSourceID; }      const LLTextSegmentPtr  getPreviousSegment() const; -    const LLTextSegmentPtr  getLastSegment() const;      void            getSelectedSegments(segment_vec_t& segments) const;      void            setShowContextMenu(bool show) { mShowContextMenu = show; } @@ -217,8 +216,6 @@ protected:      void            showContextMenu(S32 x, S32 y);      void            drawPreeditMarker(); -    void            assignEmbedded(const std::string &s); -      void            removeCharOrTab();      void            indentSelectedLines( S32 spaces ); @@ -238,7 +235,6 @@ protected:      void            autoIndent(); -    void            findEmbeddedItemSegments(S32 start, S32 end);      void            getSegmentsInRange(segment_vec_t& segments, S32 start, S32 end, bool include_partial) const;      virtual llwchar pasteEmbeddedItem(llwchar ext_char) { return ext_char; } @@ -305,7 +301,7 @@ private:      // Methods      //      void            pasteHelper(bool is_primary); -    void            cleanStringForPaste(LLWString & clean_string); +    void            cleanStringForPaste(LLWString& clean_string);      void            pasteTextWithLinebreaks(LLWString & clean_string);      void            onKeyStroke(); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index c57c979525..5556406fbd 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -68,7 +68,7 @@ public:      void reshape(S32 width, S32 height, bool called_from_parent = true);      void setEnabled(bool enabled);      void setCommandId(const LLCommandId& id) { mId = id; } -    LLCommandId getCommandId() { return mId; } +    LLCommandId getCommandId() const { return mId; }      void setStartDragCallback(tool_startdrag_callback_t cb)   { mStartDragItemCallback  = cb; }      void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; } @@ -256,7 +256,7 @@ public:      // Methods used in loading and saving toolbar settings      void setButtonType(LLToolBarEnums::ButtonType button_type); -    LLToolBarEnums::ButtonType getButtonType() { return mButtonType; } +    LLToolBarEnums::ButtonType getButtonType() const { return mButtonType; }      command_id_list_t& getCommandsList() { return mButtonCommands; }      void clearCommandsList(); diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index 86525c2f7e..74f03618cf 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -390,22 +390,22 @@ void LLToolTip::draw()      }  } -bool LLToolTip::isFading() +bool LLToolTip::isFading() const  {      return mFadeTimer.getStarted();  } -F32 LLToolTip::getVisibleTime() +F32 LLToolTip::getVisibleTime() const  {      return mVisibleTimer.getStarted() ? mVisibleTimer.getElapsedTimeF32() : 0.f;  } -bool LLToolTip::hasClickCallback() +bool LLToolTip::hasClickCallback() const  {      return mHasClickCallback;  } -void LLToolTip::getToolTipMessage(std::string & message) +void LLToolTip::getToolTipMessage(std::string& message) const  {      if (mTextBox)      { diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h index 8515504e3b..760acddd6f 100644 --- a/indra/llui/lltooltip.h +++ b/indra/llui/lltooltip.h @@ -44,15 +44,15 @@ public:          Params();      };      LLToolTipView(const LLToolTipView::Params&); -    /*virtual*/ bool handleHover(S32 x, S32 y, MASK mask); -    /*virtual*/ bool handleMouseDown(S32 x, S32 y, MASK mask); -    /*virtual*/ bool handleMiddleMouseDown(S32 x, S32 y, MASK mask); -    /*virtual*/ bool handleRightMouseDown(S32 x, S32 y, MASK mask); -    /*virtual*/ bool handleScrollWheel( S32 x, S32 y, S32 clicks ); +    bool handleHover(S32 x, S32 y, MASK mask) override; +    bool handleMouseDown(S32 x, S32 y, MASK mask) override; +    bool handleMiddleMouseDown(S32 x, S32 y, MASK mask) override; +    bool handleRightMouseDown(S32 x, S32 y, MASK mask) override; +    bool handleScrollWheel( S32 x, S32 y, S32 clicks ) override;      void drawStickyRect(); -    /*virtual*/ void draw(); +    void draw() override;  };  class LLToolTip : public LLPanel @@ -98,20 +98,20 @@ public:          Params();      }; -    /*virtual*/ void draw(); -    /*virtual*/ bool handleHover(S32 x, S32 y, MASK mask); -    /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); -    /*virtual*/ void setVisible(bool visible); +    void draw() override; +    bool handleHover(S32 x, S32 y, MASK mask) override; +    void onMouseLeave(S32 x, S32 y, MASK mask) override; +    void setVisible(bool visible) override; -    bool isFading(); -    F32 getVisibleTime(); -    bool hasClickCallback(); +    bool isFading() const; +    F32 getVisibleTime() const; +    bool hasClickCallback() const;      LLToolTip(const Params& p);      virtual void initFromParams(const LLToolTip::Params& params); -    void getToolTipMessage(std::string & message); -    bool isTooltipPastable() { return mIsTooltipPastable; } +    void getToolTipMessage(std::string & message) const; +    bool isTooltipPastable() const { return mIsTooltipPastable; }  protected:      void updateTextBox(); diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 9890d3f7ef..b2dcb6dc88 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -154,7 +154,7 @@ public:              sanitizeRange();          } -        S32 clamp(S32 input) +        S32 clamp(S32 input) const          {              if (input < mMin) return mMin;              if (input > mMax) return mMax; @@ -168,8 +168,8 @@ public:              sanitizeRange();          } -        S32 getMin() { return mMin; } -        S32 getMax() { return mMax; } +        S32 getMin() const { return mMin; } +        S32 getMax() const { return mMax; }          bool operator==(const RangeS32& other) const          { @@ -223,7 +223,7 @@ public:              mValue = clamp(value);          } -        S32 get() +        S32 get() const          {              return mValue;          } @@ -253,7 +253,7 @@ public:      static std::string getLanguage(); // static for lldateutil_test compatibility      //helper functions (should probably move free standing rendering helper functions here) -    LLView* getRootView() { return mRootView; } +    LLView* getRootView() const { return mRootView; }      void setRootView(LLView* view) { mRootView = view; }      /**       * Walk the LLView tree to resolve a path @@ -296,7 +296,7 @@ public:      LLControlGroup& getControlControlGroup (std::string_view controlname);      F32 getMouseIdleTime() { return mMouseIdleTimer.getElapsedTimeF32(); }      void resetMouseIdleTimer() { mMouseIdleTimer.reset(); } -    LLWindow* getWindow() { return mWindow; } +    LLWindow* getWindow() const { return mWindow; }      void addPopup(LLView*);      void removePopup(LLView*); diff --git a/indra/llui/lluiconstants.h b/indra/llui/lluiconstants.h index 5fdfd37c6e..a317c66008 100644 --- a/indra/llui/lluiconstants.h +++ b/indra/llui/lluiconstants.h @@ -28,23 +28,23 @@  #define LL_LLUICONSTANTS_H  // spacing for small font lines of text, like LLTextBoxes -const S32 LINE = 16; +constexpr S32 LINE = 16;  // spacing for larger lines of text -const S32 LINE_BIG = 24; +constexpr S32 LINE_BIG = 24;  // default vertical padding -const S32 VPAD = 4; +constexpr S32 VPAD = 4;  // default horizontal padding -const S32 HPAD = 4; +constexpr S32 HPAD = 4;  // Account History, how far to look into past -const S32 SUMMARY_INTERVAL = 7;     // one week -const S32 SUMMARY_MAX = 8;          // -const S32 DETAILS_INTERVAL = 1;     // one day -const S32 DETAILS_MAX = 30;         // one month -const S32 TRANSACTIONS_INTERVAL = 1;// one day -const S32 TRANSACTIONS_MAX = 30;    // one month +constexpr S32 SUMMARY_INTERVAL = 7;     // one week +constexpr S32 SUMMARY_MAX = 8;          // +constexpr S32 DETAILS_INTERVAL = 1;     // one day +constexpr S32 DETAILS_MAX = 30;         // one month +constexpr S32 TRANSACTIONS_INTERVAL = 1;// one day +constexpr S32 TRANSACTIONS_MAX = 30;    // one month  #endif diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 8cd9950917..bcaf479b0f 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -39,9 +39,9 @@  #include "llviewmodel.h"        // *TODO move dependency to .cpp file  #include "llsearchablecontrol.h" -const bool TAKE_FOCUS_YES = true; -const bool TAKE_FOCUS_NO  = false; -const S32 DROP_SHADOW_FLOATER = 5; +constexpr bool TAKE_FOCUS_YES = true; +constexpr bool TAKE_FOCUS_NO  = false; +constexpr S32 DROP_SHADOW_FLOATER = 5;  class LLUICtrl      : public LLView, public boost::signals2::trackable diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 75e7e396bc..91221dc7f3 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -184,7 +184,7 @@ fail:      template<class T>      static T* getDefaultWidget(std::string_view name)      { -        typename T::Params widget_params; +        typename T::Params widget_params{};          widget_params.name = std::string(name);          return create<T>(widget_params);      } diff --git a/indra/llui/llundo.h b/indra/llui/llundo.h index dc40702be0..990745e530 100644 --- a/indra/llui/llundo.h +++ b/indra/llui/llundo.h @@ -42,7 +42,7 @@ public:          LLUndoAction(): mClusterID(0) {};          virtual ~LLUndoAction(){};      private: -        S32     mClusterID; +        S32 mClusterID;      };      LLUndoBuffer( LLUndoAction (*create_func()), S32 initial_count ); @@ -51,8 +51,8 @@ public:      LLUndoAction *getNextAction(bool setClusterBegin = true);      bool undoAction();      bool redoAction(); -    bool canUndo() { return (mNextAction != mFirstAction); } -    bool canRedo() { return (mNextAction != mLastAction); } +    bool canUndo() const { return (mNextAction != mFirstAction); } +    bool canRedo() const { return (mNextAction != mLastAction); }      void flushActions(); diff --git a/indra/llui/llurlaction.h b/indra/llui/llurlaction.h index 0f54b66299..ac9741a7ad 100644 --- a/indra/llui/llurlaction.h +++ b/indra/llui/llurlaction.h @@ -45,8 +45,6 @@  class LLUrlAction  {  public: -    LLUrlAction(); -      /// load a Url in the user's preferred web browser      static void openURL(std::string url); diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h index ba822fbda6..887796bb37 100644 --- a/indra/llui/llurlmatch.h +++ b/indra/llui/llurlmatch.h @@ -31,7 +31,6 @@  //#include "linden_common.h"  #include <string> -#include <vector>  #include "llstyle.h"  /// diff --git a/indra/llui/llurlregistry.h b/indra/llui/llurlregistry.h index 64cfec3960..c22af0dbc4 100644 --- a/indra/llui/llurlregistry.h +++ b/indra/llui/llurlregistry.h @@ -34,7 +34,6 @@  #include "llstring.h"  #include <string> -#include <vector>  class LLKeyBindingToStringHandler; diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 710ec3d05e..97212a9d2d 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -54,17 +54,17 @@  class LLSD; -const U32   FOLLOWS_NONE    = 0x00; -const U32   FOLLOWS_LEFT    = 0x01; -const U32   FOLLOWS_RIGHT   = 0x02; -const U32   FOLLOWS_TOP     = 0x10; -const U32   FOLLOWS_BOTTOM  = 0x20; -const U32   FOLLOWS_ALL     = 0x33; +constexpr U32   FOLLOWS_NONE    = 0x00; +constexpr U32   FOLLOWS_LEFT    = 0x01; +constexpr U32   FOLLOWS_RIGHT   = 0x02; +constexpr U32   FOLLOWS_TOP     = 0x10; +constexpr U32   FOLLOWS_BOTTOM  = 0x20; +constexpr U32   FOLLOWS_ALL     = 0x33; -const bool  MOUSE_OPAQUE = true; -const bool  NOT_MOUSE_OPAQUE = false; +constexpr bool  MOUSE_OPAQUE = true; +constexpr bool  NOT_MOUSE_OPAQUE = false; -const U32 GL_NAME_UI_RESERVED = 2; +constexpr U32 GL_NAME_UI_RESERVED = 2;  // maintains render state during traversal of UI tree @@ -241,7 +241,7 @@ public:      void        setUseBoundingRect( bool use_bounding_rect );      bool        getUseBoundingRect() const; -    ECursorType getHoverCursor() { return mHoverCursor; } +    ECursorType getHoverCursor() const { return mHoverCursor; }      static F32 getTooltipTimeout();      virtual const std::string getToolTip() const; @@ -265,7 +265,7 @@ public:      void setDefaultTabGroup(S32 d)              { mDefaultTabGroup = d; }      S32 getDefaultTabGroup() const              { return mDefaultTabGroup; } -    S32 getLastTabGroup()                       { return mLastTabGroup; } +    S32 getLastTabGroup() const                 { return mLastTabGroup; }      bool        isInVisibleChain() const;      bool        isInEnabledChain() const; diff --git a/indra/llui/llviewborder.h b/indra/llui/llviewborder.h index 1f118a0d20..a4bb748b77 100644 --- a/indra/llui/llviewborder.h +++ b/indra/llui/llviewborder.h @@ -92,7 +92,6 @@ public:  private:      void        drawOnePixelLines();      void        drawTwoPixelLines(); -    void        drawTextures();      EBevel      mBevel;      EStyle      mStyle; diff --git a/indra/llui/llviewereventrecorder.h b/indra/llui/llviewereventrecorder.h index 9e752e8090..5636c068d8 100644 --- a/indra/llui/llviewereventrecorder.h +++ b/indra/llui/llviewereventrecorder.h @@ -61,7 +61,7 @@ public:    std::string get_xui();    void update_xui(std::string xui); -  bool getLoggingStatus(){return logEvents;}; +  bool getLoggingStatus() const { return logEvents; }    void setEventLoggingOn();    void setEventLoggingOff(); diff --git a/indra/llui/llvirtualtrackball.h b/indra/llui/llvirtualtrackball.h index 61a78b2398..fbfda04585 100644 --- a/indra/llui/llvirtualtrackball.h +++ b/indra/llui/llvirtualtrackball.h @@ -78,20 +78,20 @@ public:      }; -    virtual ~LLVirtualTrackball(); -    /*virtual*/ bool postBuild(); +    ~LLVirtualTrackball() override; +    bool postBuild() override; -    virtual bool    handleHover(S32 x, S32 y, MASK mask); -    virtual bool    handleMouseUp(S32 x, S32 y, MASK mask); -    virtual bool    handleMouseDown(S32 x, S32 y, MASK mask); -    virtual bool    handleRightMouseDown(S32 x, S32 y, MASK mask); -    virtual bool    handleKeyHere(KEY key, MASK mask); +    bool    handleHover(S32 x, S32 y, MASK mask) override; +    bool    handleMouseUp(S32 x, S32 y, MASK mask) override; +    bool    handleMouseDown(S32 x, S32 y, MASK mask) override; +    bool    handleRightMouseDown(S32 x, S32 y, MASK mask) override; +    bool    handleKeyHere(KEY key, MASK mask) override; -    virtual void    draw(); +    void    draw() override; -    virtual void    setValue(const LLSD& value); -    void            setValue(F32 x, F32 y, F32 z, F32 w); -    virtual LLSD    getValue() const; +    void    setValue(const LLSD& value) override; +    void    setValue(F32 x, F32 y, F32 z, F32 w); +    LLSD    getValue() const override;      void            setRotation(const LLQuaternion &value);      LLQuaternion    getRotation() const; @@ -102,7 +102,6 @@ public:  protected:      friend class LLUICtrlFactory;      LLVirtualTrackball(const Params&); -    void onEditChange();  protected:      LLTextBox*          mNLabel; diff --git a/indra/llui/llwindowshade.h b/indra/llui/llwindowshade.h index da29188943..ee230cd2f6 100644 --- a/indra/llui/llwindowshade.h +++ b/indra/llui/llwindowshade.h @@ -49,7 +49,7 @@ public:      };      void show(LLNotificationPtr); -    /*virtual*/ void draw(); +    void draw() override;      void hide();      bool isShown() const; diff --git a/indra/llui/llxyvector.h b/indra/llui/llxyvector.h index bc41213c13..646771f387 100644 --- a/indra/llui/llxyvector.h +++ b/indra/llui/llxyvector.h @@ -65,18 +65,18 @@ public:      }; -    virtual ~LLXYVector(); -    /*virtual*/ bool postBuild(); +    ~LLXYVector() override; +    bool postBuild() override; -    virtual bool    handleHover(S32 x, S32 y, MASK mask); -    virtual bool    handleMouseUp(S32 x, S32 y, MASK mask); -    virtual bool    handleMouseDown(S32 x, S32 y, MASK mask); +    bool handleHover(S32 x, S32 y, MASK mask) override; +    bool handleMouseUp(S32 x, S32 y, MASK mask) override; +    bool handleMouseDown(S32 x, S32 y, MASK mask) override; -    virtual void    draw(); +    void draw() override; -    virtual void    setValue(const LLSD& value); -    void            setValue(F32 x, F32 y); -    virtual LLSD    getValue() const; +    void setValue(const LLSD& value) override; +    void setValue(F32 x, F32 y); +    LLSD getValue() const override;  protected:      friend class LLUICtrlFactory; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index c190295512..4fca74497f 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -4040,7 +4040,15 @@ void LLWindowWin32::fillCompositionLogfont(LOGFONT *logfont)          break;      } -    logfont->lfHeight = mPreeditor->getPreeditFontSize(); +    if (mPreeditor) +    { +        logfont->lfHeight = mPreeditor->getPreeditFontSize(); +    } +    else +    { +        // todo: extract from some font * LLUI::getScaleFactor() intead +        logfont->lfHeight = 10; +    }      logfont->lfWeight = FW_NORMAL;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/tonemapUtilF.glsl b/indra/newview/app_settings/shaders/class1/deferred/tonemapUtilF.glsl index a63b8d7c2b..774ccb6baf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/tonemapUtilF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/tonemapUtilF.glsl @@ -117,27 +117,34 @@ uniform float exposure;  uniform float tonemap_mix;  uniform int tonemap_type; +  vec3 toneMap(vec3 color)  {  #ifndef NO_POST -    float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r; - -    color *= exposure * exp_scale; +    vec3 linear_input_color = color; -    vec3 clamped_color = clamp(color.rgb, vec3(0.0), vec3(1.0)); +    float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r; +    float final_exposure = exposure * exp_scale; +    vec3 exposed_color = color * final_exposure; +    vec3 tonemapped_color = exposed_color;      switch(tonemap_type)      {      case 0: -        color = PBRNeutralToneMapping(color); +        tonemapped_color = PBRNeutralToneMapping(exposed_color);          break;      case 1: -        color = toneMapACES_Hill(color); +        tonemapped_color = toneMapACES_Hill(exposed_color);          break;      } -    // mix tonemapped and linear here to provide adjustment -    color = mix(clamped_color, color, tonemap_mix); +    vec3 exposed_linear_input = linear_input_color * final_exposure; +    color = mix(exposed_linear_input, tonemapped_color, tonemap_mix); + +    color = clamp(color, 0.0, 1.0); +#else +    color *= exposure * texture(exposureMap, vec2(0.5,0.5)).r; +    color = clamp(color, 0.0, 1.0);  #endif      return color; @@ -147,20 +154,24 @@ vec3 toneMap(vec3 color)  vec3 toneMapNoExposure(vec3 color)  {  #ifndef NO_POST -    vec3 clamped_color = clamp(color.rgb, vec3(0.0), vec3(1.0)); +    vec3 linear_input_color = color; +    vec3 tonemapped_color = color;      switch(tonemap_type)      {      case 0: -        color = PBRNeutralToneMapping(color); +        tonemapped_color = PBRNeutralToneMapping(color);          break;      case 1: -        color = toneMapACES_Hill(color); +        tonemapped_color = toneMapACES_Hill(color);          break;      } -    // mix tonemapped and linear here to provide adjustment -    color = mix(clamped_color, color, tonemap_mix); +    color = mix(linear_input_color, tonemapped_color, tonemap_mix); + +    color = clamp(color, 0.0, 1.0); +#else +     color = clamp(color, 0.0, 1.0);  #endif      return color; diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index c0009d24ee..1090dd8ffb 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 73 +version 74  // The version number above should be incremented IF AND ONLY IF some  // change has been made that is sufficiently important to justify  // resetting the graphics preferences of all users to the recommended diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 5940d1ec12..c3e2dd0c41 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 72 +version 73  // The version number above should be incremented IF AND ONLY IF some  // change has been made that is sufficiently important to justify  // resetting the graphics preferences of all users to the recommended diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 829b6380cd..76e308a966 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -504,7 +504,7 @@ void LLAvatarTracker::idleNotifyObservers()  void LLAvatarTracker::notifyObservers()  { -    if (mIsNotifyObservers) +    if (mIsNotifyObservers || (LLStartUp::getStartupState() <= STATE_INVENTORY_CALLBACKS))      {          // Don't allow multiple calls.          // new masks and ids will be processed later from idle. diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index c05a7fef44..c6fea1ba82 100644 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -101,10 +101,18 @@ namespace Details      void LLEventPollImpl::handleMessage(const LLSD& content)      {          LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; -        std::string msg_name = content["message"]; +        std::string msg_name = content["message"].asString();          LLSD message; -        message["sender"] = mSenderIp; -        message["body"] = content["body"]; +        try +        { +            message["sender"] = mSenderIp; +            message["body"] = content["body"]; +        } +        catch (std::bad_alloc&) +        { +            LLError::LLUserWarningMsg::showOutOfMemory(); +            LL_ERRS("LLCoros") << "Bad memory allocation on message: " << msg_name << LL_ENDL; +        }          LLMessageSystem::dispatch(msg_name, message);      } diff --git a/indra/newview/llfloaterenvironmentadjust.cpp b/indra/newview/llfloaterenvironmentadjust.cpp index aa548a3f42..4825cbf7fb 100644 --- a/indra/newview/llfloaterenvironmentadjust.cpp +++ b/indra/newview/llfloaterenvironmentadjust.cpp @@ -452,9 +452,29 @@ void LLFloaterEnvironmentAdjust::onMoonAzimElevChanged()  void LLFloaterEnvironmentAdjust::onCloudMapChanged()  {      if (!mLiveSky) +    {          return; -    mLiveSky->setCloudNoiseTextureId(getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP)->getValue().asUUID()); -    mLiveSky->update(); +    } + +    LLTextureCtrl* picker_ctrl = getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP); + +    LLUUID new_texture_id = picker_ctrl->getValue().asUUID(); + +    LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + +    LLSettingsSky::ptr_t sky_to_set = mLiveSky->buildClone(); +    if (!sky_to_set) +    { +        return; +    } + +    sky_to_set->setCloudNoiseTextureId(new_texture_id); + +    LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, sky_to_set); + +    LLEnvironment::instance().updateEnvironment(LLEnvironment::TRANSITION_INSTANT, true); + +    picker_ctrl->setValue(new_texture_id);  }  void LLFloaterEnvironmentAdjust::onWaterMapChanged() diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp index 4e8bcc4f7a..4c02511268 100644 --- a/indra/newview/llimprocessing.cpp +++ b/indra/newview/llimprocessing.cpp @@ -422,6 +422,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,      U8 *binary_bucket,      S32 binary_bucket_size,      LLHost &sender, +    LLSD metadata,      LLUUID aux_id)  {      LLChat chat; @@ -451,6 +452,28 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,      bool is_linden = chat.mSourceType != CHAT_SOURCE_OBJECT &&          LLMuteList::isLinden(name); +    /*** +    * The simulator may have flagged this sender as a bot, if the viewer would like to display +    * the chat text in a different color or font, the below code is how the viewer can +    * tell if the sender is a bot. +    *----------------------------------------------------- +    bool is_bot = false; +    if (metadata.has("sender")) +    {   // The server has identified this sender as a bot. +        is_bot = metadata["sender"]["bot"].asBoolean(); +    } +    *----------------------------------------------------- +    */ + +    std::string notice_name; +    LLSD notice_args; +    if (metadata.has("notice")) +    {   // The server has injected a notice into the IM conversation. +        // These will be things like bot notifications, etc. +        notice_name = metadata["notice"]["id"].asString(); +        notice_args = metadata["notice"]["data"]; +    } +      chat.mMuted = is_muted;      chat.mFromID = from_id;      chat.mFromName = name; @@ -544,7 +567,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,              }              else              { -                // standard message, not from system +                // standard message, server may have injected a notice into the conversation.                  std::string saved;                  if (offline == IM_OFFLINE)                  { @@ -579,8 +602,17 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,                              region_message = true;                          }                      } -                    gIMMgr->addMessage( -                        session_id, + +                    std::string real_name; + +                    if (!notice_name.empty()) +                    {   // The simulator has injected some sort of notice into the conversation. +                        // findString will only replace the contents of buffer if the notice_id is found. +                        LLTrans::findString(buffer, notice_name, notice_args); +                        real_name = SYSTEM_FROM; +                    } + +                    gIMMgr->addMessage(session_id,                          from_id,                          name,                          buffer, @@ -591,7 +623,9 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,                          region_id,                          position,                          region_message, -                        timestamp); +                        timestamp, +                        LLUUID::null, +                        real_name);                  }                  else                  { @@ -1619,6 +1653,12 @@ void LLIMProcessing::requestOfflineMessagesCoro(std::string url)              from_group = message_data["from_group"].asString() == "Y";          } +        LLSD metadata; +        if (message_data.has("metadata")) +        { +            metadata = message_data["metadata"]; +        } +          EInstantMessage dialog = static_cast<EInstantMessage>(message_data["dialog"].asInteger());          LLUUID session_id = message_data["transaction-id"].asUUID();          if (session_id.isNull() && dialog == IM_FROM_TASK) @@ -1646,6 +1686,7 @@ void LLIMProcessing::requestOfflineMessagesCoro(std::string url)                      local_bin_bucket.data(),                      S32(local_bin_bucket.size()),                      local_sender, +                    metadata,                      message_data["asset_id"].asUUID());              }); diff --git a/indra/newview/llimprocessing.h b/indra/newview/llimprocessing.h index 030d28b198..66ffc59ae0 100644 --- a/indra/newview/llimprocessing.h +++ b/indra/newview/llimprocessing.h @@ -48,6 +48,7 @@ public:          U8 *binary_bucket,          S32 binary_bucket_size,          LLHost &sender, +        LLSD metadata,          LLUUID aux_id = LLUUID::null);      // Either receives list of offline messages from 'ReadOfflineMsgs' capability diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 04e8a26008..474b7b66d7 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -3142,9 +3142,16 @@ void LLIMMgr::addMessage(      const LLUUID& region_id,      const LLVector3& position,      bool is_region_msg, -    U32 timestamp)      // May be zero +    U32 timestamp,  // May be zero +    LLUUID display_id, +    std::string_view display_name)  {      LLUUID other_participant_id = target_id; +    std::string message_display_name = (display_name.empty()) ? from : std::string(display_name); +    if (display_id.isNull() && (display_name.empty())) +    { +        display_id = other_participant_id; +    }      LLUUID new_session_id = session_id;      if (new_session_id.isNull()) @@ -3240,7 +3247,7 @@ void LLIMMgr::addMessage(              }              //Play sound for new conversations -            if (!skip_message & !gAgent.isDoNotDisturb() && (gSavedSettings.getBOOL("PlaySoundNewConversation"))) +            if (!skip_message && !gAgent.isDoNotDisturb() && (gSavedSettings.getBOOL("PlaySoundNewConversation")))              {                  make_ui_sound("UISndNewIncomingIMSession");              } @@ -3254,7 +3261,7 @@ void LLIMMgr::addMessage(      if (!LLMuteList::getInstance()->isMuted(other_participant_id, LLMute::flagTextChat) && !skip_message)      { -        LLIMModel::instance().addMessage(new_session_id, from, other_participant_id, msg, true, is_region_msg, timestamp); +        LLIMModel::instance().addMessage(new_session_id, message_display_name, display_id, msg, true, is_region_msg, timestamp);      }      // Open conversation floater if offline messages are present diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index 61776860e3..23f90ca795 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -368,7 +368,9 @@ public:                      const LLUUID& region_id = LLUUID::null,                      const LLVector3& position = LLVector3::zero,                      bool is_region_msg = false, -                    U32 timestamp = 0); +                    U32 timestamp = 0, +                    LLUUID display_id = LLUUID::null, +                    std::string_view display_name = "");      void addSystemMessage(const LLUUID& session_id, const std::string& message_name, const LLSD& args); diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index b7d9df6ea6..6e0b0d252e 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -3644,7 +3644,7 @@ void LLPanelFace::onCommitRepeatsPerMeter()      bool identical_scale_t = false;      LLSelectedTE::getObjectScaleS(obj_scale_s, identical_scale_s); -    LLSelectedTE::getObjectScaleS(obj_scale_t, identical_scale_t); +    LLSelectedTE::getObjectScaleT(obj_scale_t, identical_scale_t);      if (gSavedSettings.getBOOL("SyncMaterialSettings"))      { @@ -5151,6 +5151,7 @@ void LLPanelFace::LLSelectedTEMaterial::getMaxSpecularRepeats(F32& repeats, bool              LLMaterial* mat = object->getTE(face)->getMaterialParams().get();              U32 s_axis = VX;              U32 t_axis = VY; +            LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);              F32 repeats_s = 1.0f;              F32 repeats_t = 1.0f;              if (mat) @@ -5175,6 +5176,7 @@ void LLPanelFace::LLSelectedTEMaterial::getMaxNormalRepeats(F32& repeats, bool&              LLMaterial* mat = object->getTE(face)->getMaterialParams().get();              U32 s_axis = VX;              U32 t_axis = VY; +            LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);              F32 repeats_s = 1.0f;              F32 repeats_t = 1.0f;              if (mat) diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index b00b9d1ad1..b1c8b5f36a 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -777,7 +777,7 @@ void LLPanelPrimMediaControls::draw()      else if(mFadeTimer.getStarted())      {          F32 time = mFadeTimer.getElapsedTimeF32(); -        alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); +        alpha *= llmax(lerp(1.f, 0.f, time / mControlFadeTime), 0.0f);          if(time >= mControlFadeTime)          { diff --git a/indra/newview/llpanelprofileclassifieds.h b/indra/newview/llpanelprofileclassifieds.h index 9f0b27139a..1c58fa6cfa 100644 --- a/indra/newview/llpanelprofileclassifieds.h +++ b/indra/newview/llpanelprofileclassifieds.h @@ -157,17 +157,17 @@ public:      void setParcelId(const LLUUID& id) { mParcelId = id; } -    LLUUID getParcelId() { return mParcelId; } +    LLUUID getParcelId() const { return mParcelId; }      void setSimName(const std::string& sim_name) { mSimName = sim_name; } -    std::string getSimName() { return mSimName; } +    std::string getSimName() const { return mSimName; }      void setFromSearch(bool val) { mFromSearch = val; } -    bool fromSearch() { return mFromSearch; } +    bool fromSearch() const { return mFromSearch; } -    bool getInfoLoaded() { return mInfoLoaded; } +    bool getInfoLoaded() const { return mInfoLoaded; }      void setInfoLoaded(bool loaded) { mInfoLoaded = loaded; } @@ -175,9 +175,9 @@ public:      void resetDirty() override; -    bool isNew() { return mIsNew; } +    bool isNew() const { return mIsNew; } -    bool isNewWithErrors() { return mIsNewWithErrors; } +    bool isNewWithErrors() const { return mIsNewWithErrors; }      bool canClose(); @@ -191,10 +191,10 @@ public:      bool getAutoRenew(); -    S32 getPriceForListing() { return mPriceForListing; } +    S32 getPriceForListing() const { return mPriceForListing; }      void setEditMode(bool edit_mode); -    bool getEditMode() {return mEditMode;} +    bool getEditMode() const { return mEditMode; }      static void setClickThrough(          const LLUUID& classified_id, diff --git a/indra/newview/llpanelsnapshot.cpp b/indra/newview/llpanelsnapshot.cpp index 32c9f6f402..56c0294dbe 100644 --- a/indra/newview/llpanelsnapshot.cpp +++ b/indra/newview/llpanelsnapshot.cpp @@ -37,6 +37,7 @@  // newview  #include "llsidetraypanelcontainer.h" +#include "llsnapshotlivepreview.h"  #include "llviewercontrol.h" // gSavedSettings  #include "llagentbenefits.h" @@ -99,6 +100,17 @@ void LLPanelSnapshot::onOpen(const LLSD& key)      {          getParentByType<LLFloater>()->notify(LLSD().with("image-format-change", true));      } + +    // If resolution is set to "Current Window", force a snapshot update +    // each time a snapshot panel is opened to determine the correct +    // image size (and upload fee) depending on the snapshot type. +    if (mSnapshotFloater && getChild<LLUICtrl>(getImageSizeComboName())->getValue().asString() == "[i0,i0]") +    { +        if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView()) +        { +            preview->mForceUpdateSnapshot = true; +        } +    }  }  LLSnapshotModel::ESnapshotFormat LLPanelSnapshot::getImageFormat() const diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp index 96b17acc40..b81b891685 100644 --- a/indra/newview/llpanelsnapshotinventory.cpp +++ b/indra/newview/llpanelsnapshotinventory.cpp @@ -42,77 +42,35 @@  /**   * The panel provides UI for saving snapshot as an inventory texture.   */ -class LLPanelSnapshotInventoryBase -    : public LLPanelSnapshot -{ -    LOG_CLASS(LLPanelSnapshotInventoryBase); - -public: -    LLPanelSnapshotInventoryBase(); - -    /*virtual*/ bool postBuild(); -protected: -    void onSend(); -    /*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType(); -}; -  class LLPanelSnapshotInventory -    : public LLPanelSnapshotInventoryBase +    : public LLPanelSnapshot  {      LOG_CLASS(LLPanelSnapshotInventory);  public:      LLPanelSnapshotInventory(); -    /*virtual*/ bool postBuild(); -    /*virtual*/ void onOpen(const LLSD& key); +    bool postBuild() override; +    void onOpen(const LLSD& key) override;      void onResolutionCommit(LLUICtrl* ctrl);  private: -    /*virtual*/ std::string getWidthSpinnerName() const     { return "inventory_snapshot_width"; } -    /*virtual*/ std::string getHeightSpinnerName() const    { return "inventory_snapshot_height"; } -    /*virtual*/ std::string getAspectRatioCBName() const    { return "inventory_keep_aspect_check"; } -    /*virtual*/ std::string getImageSizeComboName() const   { return "texture_size_combo"; } -    /*virtual*/ std::string getImageSizePanelName() const   { return LLStringUtil::null; } -    /*virtual*/ void updateControls(const LLSD& info); - -}; - -class LLPanelOutfitSnapshotInventory -    : public LLPanelSnapshotInventoryBase -{ -    LOG_CLASS(LLPanelOutfitSnapshotInventory); - -public: -    LLPanelOutfitSnapshotInventory(); -        /*virtual*/ bool postBuild(); -        /*virtual*/ void onOpen(const LLSD& key); +    std::string getWidthSpinnerName() const override   { return "inventory_snapshot_width"; } +    std::string getHeightSpinnerName() const override  { return "inventory_snapshot_height"; } +    std::string getAspectRatioCBName() const override  { return "inventory_keep_aspect_check"; } +    std::string getImageSizeComboName() const override { return "texture_size_combo"; } +    std::string getImageSizePanelName() const override { return LLStringUtil::null; } +    LLSnapshotModel::ESnapshotType getSnapshotType() override; +    void updateControls(const LLSD& info) override; -private: -    /*virtual*/ std::string getWidthSpinnerName() const     { return ""; } -    /*virtual*/ std::string getHeightSpinnerName() const    { return ""; } -    /*virtual*/ std::string getAspectRatioCBName() const    { return ""; } -    /*virtual*/ std::string getImageSizeComboName() const   { return "texture_size_combo"; } -    /*virtual*/ std::string getImageSizePanelName() const   { return LLStringUtil::null; } -    /*virtual*/ void updateControls(const LLSD& info); - -    /*virtual*/ void cancel(); +    void onSend(); +    void updateUploadCost(); +    S32 calculateUploadCost();  };  static LLPanelInjector<LLPanelSnapshotInventory> panel_class1("llpanelsnapshotinventory"); -static LLPanelInjector<LLPanelOutfitSnapshotInventory> panel_class2("llpaneloutfitsnapshotinventory"); - -LLPanelSnapshotInventoryBase::LLPanelSnapshotInventoryBase() -{ -} - -bool LLPanelSnapshotInventoryBase::postBuild() -{ -    return LLPanelSnapshot::postBuild(); -} - -LLSnapshotModel::ESnapshotType LLPanelSnapshotInventoryBase::getSnapshotType() +LLSnapshotModel::ESnapshotType LLPanelSnapshotInventory::getSnapshotType()  {      return LLSnapshotModel::SNAPSHOT_TEXTURE;  } @@ -130,12 +88,14 @@ bool LLPanelSnapshotInventory::postBuild()      getChild<LLSpinCtrl>(getHeightSpinnerName())->setAllowEdit(false);      getChild<LLUICtrl>(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshotInventory::onResolutionCommit, this, _1)); -    return LLPanelSnapshotInventoryBase::postBuild(); +    return LLPanelSnapshot::postBuild();  }  // virtual  void LLPanelSnapshotInventory::onOpen(const LLSD& key)  { +    updateUploadCost(); +      LLPanelSnapshot::onOpen(key);  } @@ -144,6 +104,8 @@ void LLPanelSnapshotInventory::updateControls(const LLSD& info)  {      const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true;      getChild<LLUICtrl>("save_btn")->setEnabled(have_snapshot); + +    updateUploadCost();  }  void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl) @@ -153,21 +115,9 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl)      getChild<LLSpinCtrl>(getHeightSpinnerName())->setVisible(!current_window_selected);  } -void LLPanelSnapshotInventoryBase::onSend() +void LLPanelSnapshotInventory::onSend()  { -    S32 w = 0; -    S32 h = 0; - -    if( mSnapshotFloater ) -    { -        LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView(); -        if( preview ) -        { -            preview->getSize(w, h); -        } -    } - -    S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h); +    S32 expected_upload_cost = calculateUploadCost();      if (can_afford_transaction(expected_upload_cost))      {          if (mSnapshotFloater) @@ -188,36 +138,24 @@ void LLPanelSnapshotInventoryBase::onSend()      }  } -LLPanelOutfitSnapshotInventory::LLPanelOutfitSnapshotInventory() +void LLPanelSnapshotInventory::updateUploadCost()  { -    mCommitCallbackRegistrar.add("Inventory.SaveOutfitPhoto", boost::bind(&LLPanelOutfitSnapshotInventory::onSend, this)); -    mCommitCallbackRegistrar.add("Inventory.SaveOutfitCancel", boost::bind(&LLPanelOutfitSnapshotInventory::cancel, this)); +    getChild<LLUICtrl>("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", calculateUploadCost()));  } -// virtual -bool LLPanelOutfitSnapshotInventory::postBuild() +S32 LLPanelSnapshotInventory::calculateUploadCost()  { -    return LLPanelSnapshotInventoryBase::postBuild(); -} - -// virtual -void LLPanelOutfitSnapshotInventory::onOpen(const LLSD& key) -{ -    getChild<LLUICtrl>("hint_lbl")->setTextArg("[UPLOAD_COST]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost())); -    LLPanelSnapshot::onOpen(key); -} - -// virtual -void LLPanelOutfitSnapshotInventory::updateControls(const LLSD& info) -{ -    const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true; -    getChild<LLUICtrl>("save_btn")->setEnabled(have_snapshot); -} +    S32 w = 0; +    S32 h = 0; -void LLPanelOutfitSnapshotInventory::cancel() -{      if (mSnapshotFloater)      { -        mSnapshotFloater->closeFloater(); +        if (LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView()) +        { +            w = preview->getEncodedImageWidth(); +            h = preview->getEncodedImageHeight(); +        }      } + +    return LLAgentBenefitsMgr::current().getTextureUploadCost(w, h);  } diff --git a/indra/newview/llpanelsnapshotlocal.cpp b/indra/newview/llpanelsnapshotlocal.cpp index 366030c0fa..57759fbcaa 100644 --- a/indra/newview/llpanelsnapshotlocal.cpp +++ b/indra/newview/llpanelsnapshotlocal.cpp @@ -47,18 +47,18 @@ class LLPanelSnapshotLocal  public:      LLPanelSnapshotLocal(); -    /*virtual*/ bool postBuild(); -    /*virtual*/ void onOpen(const LLSD& key); +    bool postBuild() override; +    void onOpen(const LLSD& key) override;  private: -    /*virtual*/ std::string getWidthSpinnerName() const     { return "local_snapshot_width"; } -    /*virtual*/ std::string getHeightSpinnerName() const    { return "local_snapshot_height"; } -    /*virtual*/ std::string getAspectRatioCBName() const    { return "local_keep_aspect_check"; } -    /*virtual*/ std::string getImageSizeComboName() const   { return "local_size_combo"; } -    /*virtual*/ std::string getImageSizePanelName() const   { return "local_image_size_lp"; } -    /*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat() const; -    /*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType(); -    /*virtual*/ void updateControls(const LLSD& info); +    std::string getWidthSpinnerName() const  override  { return "local_snapshot_width"; } +    std::string getHeightSpinnerName() const override  { return "local_snapshot_height"; } +    std::string getAspectRatioCBName() const override  { return "local_keep_aspect_check"; } +    std::string getImageSizeComboName() const override { return "local_size_combo"; } +    std::string getImageSizePanelName() const override { return "local_image_size_lp"; } +    LLSnapshotModel::ESnapshotFormat getImageFormat() const override; +    LLSnapshotModel::ESnapshotType getSnapshotType() override; +    void updateControls(const LLSD& info) override;      S32 mLocalFormat; diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp index 962d3bba16..05cd9e7b3a 100644 --- a/indra/newview/llpanelsnapshotoptions.cpp +++ b/indra/newview/llpanelsnapshotoptions.cpp @@ -30,12 +30,8 @@  #include "llsidetraypanelcontainer.h"  #include "llfloatersnapshot.h" // FIXME: create a snapshot model -#include "llsnapshotlivepreview.h"  #include "llfloaterreg.h" -#include "llagentbenefits.h" - -  /**   * Provides several ways to save a snapshot.   */ @@ -46,12 +42,9 @@ class LLPanelSnapshotOptions  public:      LLPanelSnapshotOptions(); -    ~LLPanelSnapshotOptions(); -    /*virtual*/ bool postBuild(); -    /*virtual*/ void onOpen(const LLSD& key); +    bool postBuild() override;  private: -    void updateUploadCost();      void openPanel(const std::string& panel_name);      void onSaveToProfile();      void onSaveToEmail(); @@ -71,10 +64,6 @@ LLPanelSnapshotOptions::LLPanelSnapshotOptions()      mCommitCallbackRegistrar.add("Snapshot.SaveToComputer",     boost::bind(&LLPanelSnapshotOptions::onSaveToComputer,  this));  } -LLPanelSnapshotOptions::~LLPanelSnapshotOptions() -{ -} -  // virtual  bool LLPanelSnapshotOptions::postBuild()  { @@ -82,30 +71,6 @@ bool LLPanelSnapshotOptions::postBuild()      return LLPanel::postBuild();  } -// virtual -void LLPanelSnapshotOptions::onOpen(const LLSD& key) -{ -    updateUploadCost(); -} - -void LLPanelSnapshotOptions::updateUploadCost() -{ -    S32 w = 0; -    S32 h = 0; - -    if( mSnapshotFloater ) -    { -        LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView(); -        if( preview ) -        { -            preview->getSize(w, h); -        } -    } - -    S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h); -    getChild<LLUICtrl>("save_to_inventory_btn")->setLabelArg("[AMOUNT]", llformat("%d", upload_cost)); -} -  void LLPanelSnapshotOptions::openPanel(const std::string& panel_name)  {      LLSideTrayPanelContainer* parent = dynamic_cast<LLSideTrayPanelContainer*>(getParent()); diff --git a/indra/newview/llpanelsnapshotpostcard.cpp b/indra/newview/llpanelsnapshotpostcard.cpp index 23e8789e3f..f3dfdc9250 100644 --- a/indra/newview/llpanelsnapshotpostcard.cpp +++ b/indra/newview/llpanelsnapshotpostcard.cpp @@ -56,18 +56,18 @@ class LLPanelSnapshotPostcard  public:      LLPanelSnapshotPostcard(); -    /*virtual*/ bool postBuild(); -    /*virtual*/ void onOpen(const LLSD& key); +    bool postBuild() override; +    void onOpen(const LLSD& key) override;  private: -    /*virtual*/ std::string getWidthSpinnerName() const     { return "postcard_snapshot_width"; } -    /*virtual*/ std::string getHeightSpinnerName() const    { return "postcard_snapshot_height"; } -    /*virtual*/ std::string getAspectRatioCBName() const    { return "postcard_keep_aspect_check"; } -    /*virtual*/ std::string getImageSizeComboName() const   { return "postcard_size_combo"; } -    /*virtual*/ std::string getImageSizePanelName() const   { return "postcard_image_size_lp"; } -    /*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat() const { return LLSnapshotModel::SNAPSHOT_FORMAT_JPEG; } -    /*virtual*/ LLSnapshotModel::ESnapshotType getSnapshotType(); -    /*virtual*/ void updateControls(const LLSD& info); +    std::string getWidthSpinnerName() const override   { return "postcard_snapshot_width"; } +    std::string getHeightSpinnerName() const override  { return "postcard_snapshot_height"; } +    std::string getAspectRatioCBName() const override  { return "postcard_keep_aspect_check"; } +    std::string getImageSizeComboName() const override { return "postcard_size_combo"; } +    std::string getImageSizePanelName() const override { return "postcard_image_size_lp"; } +    LLSnapshotModel::ESnapshotFormat getImageFormat() const override { return LLSnapshotModel::SNAPSHOT_FORMAT_JPEG; } +    LLSnapshotModel::ESnapshotType getSnapshotType() override; +    void updateControls(const LLSD& info) override;      bool missingSubjMsgAlertCallback(const LLSD& notification, const LLSD& response);      static void sendPostcardFinished(LLSD result); diff --git a/indra/newview/llpanelsnapshotprofile.cpp b/indra/newview/llpanelsnapshotprofile.cpp index aa257dea9e..b533d7bbbc 100644 --- a/indra/newview/llpanelsnapshotprofile.cpp +++ b/indra/newview/llpanelsnapshotprofile.cpp @@ -49,17 +49,17 @@ class LLPanelSnapshotProfile  public:      LLPanelSnapshotProfile(); -    /*virtual*/ bool postBuild(); -    /*virtual*/ void onOpen(const LLSD& key); +    bool postBuild() override; +    void onOpen(const LLSD& key) override;  private: -    /*virtual*/ std::string getWidthSpinnerName() const     { return "profile_snapshot_width"; } -    /*virtual*/ std::string getHeightSpinnerName() const    { return "profile_snapshot_height"; } -    /*virtual*/ std::string getAspectRatioCBName() const    { return "profile_keep_aspect_check"; } -    /*virtual*/ std::string getImageSizeComboName() const   { return "profile_size_combo"; } -    /*virtual*/ std::string getImageSizePanelName() const   { return "profile_image_size_lp"; } -    /*virtual*/ LLSnapshotModel::ESnapshotFormat getImageFormat() const { return LLSnapshotModel::SNAPSHOT_FORMAT_PNG; } -    /*virtual*/ void updateControls(const LLSD& info); +    std::string getWidthSpinnerName() const override   { return "profile_snapshot_width"; } +    std::string getHeightSpinnerName() const override  { return "profile_snapshot_height"; } +    std::string getAspectRatioCBName() const override  { return "profile_keep_aspect_check"; } +    std::string getImageSizeComboName() const override { return "profile_size_combo"; } +    std::string getImageSizePanelName() const override { return "profile_image_size_lp"; } +    LLSnapshotModel::ESnapshotFormat getImageFormat() const override { return LLSnapshotModel::SNAPSHOT_FORMAT_PNG; } +    void updateControls(const LLSD& info) override;      void onSend();  }; diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp index 86291708b0..e5c84728fe 100644 --- a/indra/newview/llphysicsmotion.cpp +++ b/indra/newview/llphysicsmotion.cpp @@ -646,18 +646,17 @@ bool LLPhysicsMotion::onUpdate(F32 time)              velocity_new_local = 0;          } -        // Check for NaN values.  A NaN value is detected if the variables doesn't equal itself. -        // If NaN, then reset everything. -        if ((mPosition_local != mPosition_local) || -            (mVelocity_local != mVelocity_local) || -            (position_new_local != position_new_local)) +        // Check for NaN values. If NaN, then reset everything. +        if (llisnan(mPosition_local) || +            llisnan(mVelocity_local) || +            llisnan(position_new_local))          { -            position_new_local = 0; -            mVelocity_local = 0; -            mVelocityJoint_local = 0; -            mAccelerationJoint_local = 0; -            mPosition_local = 0; -            mPosition_world = LLVector3(0,0,0); +            position_new_local = 0.f; +            mVelocity_local = 0.f; +            mVelocityJoint_local = 0.f; +            mAccelerationJoint_local = 0.f; +            mPosition_local = 0.f; +            mPosition_world = LLVector3(0.f,0.f,0.f);          }          const F32 position_new_local_clamped = llclamp(position_new_local, diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 02a4c7fb26..c2aa4925bd 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -703,9 +703,10 @@ void LLScriptEdCore::sync()      }  } -bool LLScriptEdCore::hasChanged() +bool LLScriptEdCore::hasChanged() const  { -    if (!mEditor) return false; +    if (!mEditor) +        return false;      return ((!mEditor->isPristine() || mEnableSave) && mHasScriptData);  } diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 70ee1a4274..0bbe540207 100644 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -143,7 +143,7 @@ public:      void            setItemRemoved(bool script_removed){mScriptRemoved = script_removed;};      void            setAssetID( const LLUUID& asset_id){ mAssetID = asset_id; }; -    LLUUID          getAssetID() { return mAssetID; } +    LLUUID          getAssetID() const { return mAssetID; }      bool isFontSizeChecked(const LLSD &userdata);      void onChangeFontSize(const LLSD &size_name); @@ -155,7 +155,7 @@ public:      void        onBtnDynamicHelp();      void        onBtnUndoChanges(); -    bool        hasChanged(); +    bool        hasChanged() const;      void selectFirstError(); @@ -211,7 +211,6 @@ class LLScriptEdContainer : public LLPreview  public:      LLScriptEdContainer(const LLSD& key); -    LLScriptEdContainer(const LLSD& key, const bool live);      bool handleKeyHere(KEY key, MASK mask); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index b274ba5abb..bdcfec34f6 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -2137,6 +2137,21 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)      EInstantMessage dialog = (EInstantMessage)d;      LLHost sender = msg->getSender(); +    LLSD metadata; +    if (msg->getNumberOfBlocksFast(_PREHASH_MetaData) > 0) +    { +        S32 metadata_size = msg->getSizeFast(_PREHASH_MetaData, 0, _PREHASH_Data); +        std::string metadata_buffer; +        metadata_buffer.resize(metadata_size, 0); + +        msg->getBinaryDataFast(_PREHASH_MetaData, _PREHASH_Data, &metadata_buffer[0], metadata_size, 0, metadata_size ); +        std::stringstream metadata_stream(metadata_buffer); +        if (LLSDSerialize::fromBinary(metadata, metadata_stream, metadata_size) == LLSDParser::PARSE_FAILURE) +        { +            metadata.clear(); +        } +    } +      LLIMProcessing::processNewMessage(from_id,          from_group,          to_id, @@ -2151,7 +2166,8 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)          position,          binary_bucket,          binary_bucket_size, -        sender); +        sender, +        metadata);  }  void send_do_not_disturb_message (LLMessageSystem* msg, const LLUUID& from_id, const LLUUID& session_id) diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index 66a19d3601..432da2e990 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -1328,12 +1328,12 @@ const S32 LLViewerParcelMgr::getAgentParcelId() const      return INVALID_PARCEL_ID;  } -void LLViewerParcelMgr::sendParcelPropertiesUpdate(LLParcel* parcel, bool use_agent_region) +void LLViewerParcelMgr::sendParcelPropertiesUpdate(LLParcel* parcel)  {      if(!parcel)          return; -    LLViewerRegion *region = use_agent_region ? gAgent.getRegion() : LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); +    LLViewerRegion *region = LLWorld::getInstance()->getRegionFromID(parcel->getRegionID());      if (!region)          return; @@ -1677,10 +1677,16 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use      // Actually extract the data.      if (parcel)      { +        // store region_id in the parcel so we can find it again later +        LLViewerRegion* parcel_region = LLWorld::getInstance()->getRegion(msg->getSender()); +        if (parcel_region) +        { +            parcel->setRegionID(parcel_region->getRegionID()); +        } +          if (local_id == parcel_mgr.mAgentParcel->getLocalID())          {              // Parcels in different regions can have same ids. -            LLViewerRegion* parcel_region = LLWorld::getInstance()->getRegion(msg->getSender());              LLViewerRegion* agent_region = gAgent.getRegion();              if (parcel_region && agent_region && parcel_region->getRegionID() == agent_region->getRegionID())              { diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h index 95d693662e..1925cd23ed 100644 --- a/indra/newview/llviewerparcelmgr.h +++ b/indra/newview/llviewerparcelmgr.h @@ -219,7 +219,7 @@ public:      // containing the southwest corner of the selection.      // If want_reply_to_update, simulator will send back a ParcelProperties      // message. -    void    sendParcelPropertiesUpdate(LLParcel* parcel, bool use_agent_region = false); +    void    sendParcelPropertiesUpdate(LLParcel* parcel);      // Takes an Access List flag, like AL_ACCESS or AL_BAN      void    sendParcelAccessListUpdate(U32 which); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6c5fd855fd..493fcd5d45 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -121,7 +121,7 @@  #include "SMAAAreaTex.h"  #include "SMAASearchTex.h" - +#include "llerror.h"  #ifndef LL_WINDOWS  #define A_GCC 1  #pragma GCC diagnostic ignored "-Wunused-function" @@ -599,7 +599,6 @@ void LLPipeline::init()      connectRefreshCachedSettingsSafe("RenderMirrors");      connectRefreshCachedSettingsSafe("RenderHeroProbeUpdateRate");      connectRefreshCachedSettingsSafe("RenderHeroProbeConservativeUpdateMultiplier"); -    connectRefreshCachedSettingsSafe("RenderAutoHideSurfaceAreaLimit");      LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl("CollectFontVertexBuffers");      if (cntrl_ptr.notNull()) @@ -1286,8 +1285,11 @@ void LLPipeline::createGLBuffers()      }      allocateScreenBuffer(resX, resY); -    mRT->width = 0; -    mRT->height = 0; +    // Do not zero out mRT dimensions here. allocateScreenBuffer() above +    // already sets the correct dimensions. Zeroing them caused resizeShadowTexture() +    // to fail if called immediately after createGLBuffers (e.g., post graphics change). +    // mRT->width = 0; +    // mRT->height = 0;      if (!mNoiseMap) diff --git a/indra/newview/skins/default/xui/da/strings.xml b/indra/newview/skins/default/xui/da/strings.xml index e4f99d14e9..c4275d43f7 100644 --- a/indra/newview/skins/default/xui/da/strings.xml +++ b/indra/newview/skins/default/xui/da/strings.xml @@ -3723,6 +3723,10 @@ Hvis du bliver ved med at modtage denne besked, kontakt venligst [SUPPORT_SITE].  	<string name="conference-title-incoming">  		Konference med [AGENT_NAME]  	</string> +	<string name="bot_warning"> +Du chatter med en bot, [NAME]. Del ikke personlige oplysninger. +Læs mere på https://second.life/scripted-agents. +	</string>  	<string name="no_session_message">  		(IM session eksisterer ikke)  	</string> diff --git a/indra/newview/skins/default/xui/de/panel_snapshot_options.xml b/indra/newview/skins/default/xui/de/panel_snapshot_options.xml index dab20d63eb..2a51f10894 100644 --- a/indra/newview/skins/default/xui/de/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/de/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes"?>  <panel name="panel_snapshot_options">  	<button label="Auf Datenträger speichern" name="save_to_computer_btn"/> -	<button label="In Inventar speichern ([AMOUNT] L$)" name="save_to_inventory_btn"/> +	<button label="In Inventar speichern" name="save_to_inventory_btn"/>  	<button label="Im Profil-Feed teilen" name="save_to_profile_btn"/>  	<button label="Auf Facebook teilen" name="send_to_facebook_btn"/>  	<button label="Auf Twitter teilen" name="send_to_twitter_btn"/> diff --git a/indra/newview/skins/default/xui/de/strings.xml b/indra/newview/skins/default/xui/de/strings.xml index 3f5fccf57f..e9ed7f4949 100644 --- a/indra/newview/skins/default/xui/de/strings.xml +++ b/indra/newview/skins/default/xui/de/strings.xml @@ -1613,6 +1613,10 @@ Falls diese Meldung weiterhin angezeigt wird, wenden Sie sich bitte an [SUPPORT_  	<string name="conference-title-incoming">Konferenz mit [AGENT_NAME]</string>  	<string name="inventory_item_offered-im">Inventarobjekt „[ITEM_NAME]“ angeboten</string>  	<string name="inventory_folder_offered-im">Inventarordner „[ITEM_NAME]“ angeboten</string> +	<string name="bot_warning"> +	Sie chatten mit einem Bot, [NAME]. Geben Sie keine persönlichen Informationen weiter. +Erfahren Sie mehr unter https://second.life/scripted-agents. +	</string>  	<string name="share_alert">Objekte aus dem Inventar hier her ziehen</string>  	<string name="facebook_post_success">Sie haben auf Facebook gepostet.</string>  	<string name="flickr_post_success">Sie haben auf Flickr gepostet.</string> diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml index 7687f7cd96..23bbf45e88 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_clouds.xml @@ -139,7 +139,7 @@                      max_val_x="30"                      min_val_y="-30"                      max_val_y="30"  -                    logarithmic="1"/> +                    logarithmic="true"/>              <text                      name="cloud_image_label" diff --git a/indra/newview/skins/default/xui/en/panel_snapshot_inventory.xml b/indra/newview/skins/default/xui/en/panel_snapshot_inventory.xml index 68878baa0d..0cac1b410f 100644 --- a/indra/newview/skins/default/xui/en/panel_snapshot_inventory.xml +++ b/indra/newview/skins/default/xui/en/panel_snapshot_inventory.xml @@ -119,6 +119,8 @@       type="string"       word_wrap="true">          To save your image as a texture select one of the square formats. + +Upload cost: L$[UPLOAD_COST]      </text>      <button       follows="right|bottom" diff --git a/indra/newview/skins/default/xui/en/panel_snapshot_options.xml b/indra/newview/skins/default/xui/en/panel_snapshot_options.xml index 3a7731d235..2fb02af61c 100644 --- a/indra/newview/skins/default/xui/en/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/en/panel_snapshot_options.xml @@ -31,7 +31,7 @@     image_overlay_alignment="left"     image_top_pad="-1"     imgoverlay_label_space="10" -   label="Save to Inventory (L$[AMOUNT])" +   label="Save to Inventory"     layout="topleft"     left_delta="0"     name="save_to_inventory_btn" diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 7361ad5245..faa751bbf1 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3717,6 +3717,10 @@ Please reinstall viewer from  https://secondlife.com/support/downloads/ and cont    <string name="inventory_folder_offered-im">      Inventory folder '[ITEM_NAME]' offered    </string> +  <string name="bot_warning"> +  You are chatting with a bot, [NAME]. Do not share any personal information. +Learn more at https://second.life/scripted-agents. +  </string>    <string name="share_alert">      Drag items from inventory here    </string> diff --git a/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml b/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml index cdeff6ab05..f246ff764a 100644 --- a/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml +++ b/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml @@ -3,7 +3,6 @@      name="virtualtrackball"      width="150"      height="150" -    user_resize="false"           increment_angle_mouse="1.5f"      increment_angle_btn="1.0f"          image_sphere="VirtualTrackball_Sphere" diff --git a/indra/newview/skins/default/xui/en/widgets/xy_vector.xml b/indra/newview/skins/default/xui/en/widgets/xy_vector.xml index 23cde55f30..923895be5e 100644 --- a/indra/newview/skins/default/xui/en/widgets/xy_vector.xml +++ b/indra/newview/skins/default/xui/en/widgets/xy_vector.xml @@ -3,11 +3,9 @@      name="xyvector"      width="120"      height="140" -    decimal_digits="1"      label_width="16"      padding="4" -    edit_bar_height="18" -    user_resize="false"> +    edit_bar_height="18">      <xy_vector.border          visible="true"/> diff --git a/indra/newview/skins/default/xui/es/panel_snapshot_options.xml b/indra/newview/skins/default/xui/es/panel_snapshot_options.xml index 4eb9ecf28f..f3119c739e 100644 --- a/indra/newview/skins/default/xui/es/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/es/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes"?>  <panel name="panel_snapshot_options">  	<button label="Guardar en disco" name="save_to_computer_btn"/> -	<button label="Guardar en inventario (L$[AMOUNT])" name="save_to_inventory_btn"/> +	<button label="Guardar en inventario" name="save_to_inventory_btn"/>  	<button label="Compartir en los comentarios de Mi perfil" name="save_to_profile_btn"/>  	<button label="Compartir en Facebook" name="send_to_facebook_btn"/>  	<button label="Compartir en Twitter" name="send_to_twitter_btn"/> diff --git a/indra/newview/skins/default/xui/es/strings.xml b/indra/newview/skins/default/xui/es/strings.xml index ff1200e2b3..93b34e3cca 100644 --- a/indra/newview/skins/default/xui/es/strings.xml +++ b/indra/newview/skins/default/xui/es/strings.xml @@ -1584,6 +1584,10 @@ Si sigues recibiendo este mensaje, contacta con [SUPPORT_SITE].</string>  	<string name="conference-title-incoming">Conferencia con [AGENT_NAME]</string>  	<string name="inventory_item_offered-im">Ítem del inventario '[ITEM_NAME]' ofrecido</string>  	<string name="inventory_folder_offered-im">Carpeta del inventario '[ITEM_NAME]' ofrecida</string> +	<string name="bot_warning"> +Estás conversando con un bot, [NAME]. No compartas información personal. +Más información en https://second.life/scripted-agents. +	</string>  	<string name="share_alert">Arrastra los ítems desde el invenbtario hasta aquí</string>  	<string name="facebook_post_success">Has publicado en Facebook.</string>  	<string name="flickr_post_success">Has publicado en Flickr.</string> diff --git a/indra/newview/skins/default/xui/fr/panel_snapshot_options.xml b/indra/newview/skins/default/xui/fr/panel_snapshot_options.xml index bdedb9162f..52fa318f8e 100644 --- a/indra/newview/skins/default/xui/fr/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/fr/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes"?>  <panel name="panel_snapshot_options">  	<button label="Enreg. sur le disque" name="save_to_computer_btn"/> -	<button label="Enreg. dans l'inventaire ([AMOUNT] L$)" name="save_to_inventory_btn"/> +	<button label="Enreg. dans l'inventaire" name="save_to_inventory_btn"/>  	<button label="Partager sur le flux de profil" name="save_to_profile_btn"/>  	<button label="Partager sur Facebook" name="send_to_facebook_btn"/>  	<button label="Partager sur Twitter" name="send_to_twitter_btn"/> diff --git a/indra/newview/skins/default/xui/fr/strings.xml b/indra/newview/skins/default/xui/fr/strings.xml index 5307c8d561..c929226c43 100644 --- a/indra/newview/skins/default/xui/fr/strings.xml +++ b/indra/newview/skins/default/xui/fr/strings.xml @@ -1614,6 +1614,10 @@ Si ce message persiste, veuillez aller sur la page [SUPPORT_SITE].</string>  	<string name="conference-title-incoming">Conférence avec [AGENT_NAME]</string>  	<string name="inventory_item_offered-im">Objet de l’inventaire [ITEM_NAME] offert</string>  	<string name="inventory_folder_offered-im">Dossier de l’inventaire [ITEM_NAME] offert</string> +	<string name="bot_warning"> +Vous discutez avec un bot, [NAME]. Ne partagez pas d’informations personnelles. +En savoir plus sur https://second.life/scripted-agents. +	</string>  	<string name="share_alert">Faire glisser les objets de l'inventaire ici</string>  	<string name="facebook_post_success">Vous avez publié sur Facebook.</string>  	<string name="flickr_post_success">Vous avez publié sur Flickr.</string> diff --git a/indra/newview/skins/default/xui/it/panel_snapshot_options.xml b/indra/newview/skins/default/xui/it/panel_snapshot_options.xml index 50fb3d39fa..7fce171326 100644 --- a/indra/newview/skins/default/xui/it/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/it/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes"?>  <panel name="panel_snapshot_options">  	<button label="Salva sul disco" name="save_to_computer_btn"/> -	<button label="Salva nell'inventario (L$[AMOUNT])" name="save_to_inventory_btn"/> +	<button label="Salva nell'inventario" name="save_to_inventory_btn"/>  	<button label="Condividi sul feed del profilo" name="save_to_profile_btn"/>  	<button label="Condividi su Facebook" name="send_to_facebook_btn"/>  	<button label="Condividi su Twitter" name="send_to_twitter_btn"/> diff --git a/indra/newview/skins/default/xui/it/strings.xml b/indra/newview/skins/default/xui/it/strings.xml index bb22ff788e..d279f62d12 100644 --- a/indra/newview/skins/default/xui/it/strings.xml +++ b/indra/newview/skins/default/xui/it/strings.xml @@ -1586,6 +1586,10 @@ Se il messaggio persiste, contatta [SUPPORT_SITE].</string>  	<string name="conference-title-incoming">Chiamata in conferenza con [AGENT_NAME]</string>  	<string name="inventory_item_offered-im">Offerto oggetto di inventario "[ITEM_NAME]"</string>  	<string name="inventory_folder_offered-im">Offerta cartella di inventario "[ITEM_NAME]"</string> +	<string name="bot_warning"> +Stai parlando con un bot, [NAME]. Non condividere informazioni personali. +Scopri di più su https://second.life/scripted-agents. +	</string>  	<string name="facebook_post_success">Hai pubblicato su Facebook.</string>  	<string name="flickr_post_success">Hai pubblicato su Flickr.</string>  	<string name="twitter_post_success">Hai pubblicato su Twitter.</string> diff --git a/indra/newview/skins/default/xui/ja/panel_snapshot_inventory.xml b/indra/newview/skins/default/xui/ja/panel_snapshot_inventory.xml index 30542378cc..04ecba4264 100644 --- a/indra/newview/skins/default/xui/ja/panel_snapshot_inventory.xml +++ b/indra/newview/skins/default/xui/ja/panel_snapshot_inventory.xml @@ -16,7 +16,7 @@  	<spinner label="" name="inventory_snapshot_height"/>  	<check_box label="縦横比の固定" name="inventory_keep_aspect_check"/>  	<text name="hint_lbl"> -		画像をテクスチャとして保存する場合は、いずれかの正方形を選択してください。 +		画像をインベントリに保存するには L$[UPLOAD_COST] の費用がかかります。画像をテクスチャとして保存するには平方形式の 1 つを選択してください。  	</text>  	<button label="キャンセル" name="cancel_btn"/>  	<button label="保存" name="save_btn"/> diff --git a/indra/newview/skins/default/xui/ja/panel_snapshot_options.xml b/indra/newview/skins/default/xui/ja/panel_snapshot_options.xml index 7a1aa280ec..a979e31c9a 100644 --- a/indra/newview/skins/default/xui/ja/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/ja/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes"?>  <panel name="panel_snapshot_options">  	<button label="ディスクに保存" name="save_to_computer_btn"/> -	<button label="インベントリに保存(L$ [AMOUNT])" name="save_to_inventory_btn"/> +	<button label="インベントリに保存" name="save_to_inventory_btn"/>  	<button label="プロフィールフィードで共有する" name="save_to_profile_btn"/>  	<button label="メールで送信" name="save_to_email_btn"/>  	<text name="fee_hint_lbl"> diff --git a/indra/newview/skins/default/xui/ja/strings.xml b/indra/newview/skins/default/xui/ja/strings.xml index df19f3678f..7d1cf9d146 100644 --- a/indra/newview/skins/default/xui/ja/strings.xml +++ b/indra/newview/skins/default/xui/ja/strings.xml @@ -6149,6 +6149,10 @@ www.secondlife.com から最新バージョンをダウンロードしてくだ  	<string name="inventory_folder_offered-im">  		フォルダ「[ITEM_NAME]」がインベントリに送られてきました。  	</string> +	<string name="bot_warning"> +[NAME]とチャットしています。個人情報を共有しないでください。 +詳細は https://second.life/scripted-agents をご覧ください。 +	</string>  	<string name="share_alert">  		インベントリからここにアイテムをドラッグします。  	</string> diff --git a/indra/newview/skins/default/xui/pl/panel_snapshot_options.xml b/indra/newview/skins/default/xui/pl/panel_snapshot_options.xml index 016b9ca197..04c01940e1 100644 --- a/indra/newview/skins/default/xui/pl/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/pl/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes" ?>  <panel name="panel_snapshot_options">  	<button label="Zapisz na dysku twardym" name="save_to_computer_btn" /> -	<button label="Zapisz do Szafy ([AMOUNT]L$)" name="save_to_inventory_btn" /> +	<button label="Zapisz do Szafy" name="save_to_inventory_btn" />  	<button label="Wyślij na mój Kanał" name="save_to_profile_btn" />  	<button label="Załaduj na Facebook" name="send_to_facebook_btn" />  	<button label="Załaduj na Twitter" name="send_to_twitter_btn" /> diff --git a/indra/newview/skins/default/xui/pl/strings.xml b/indra/newview/skins/default/xui/pl/strings.xml index 8032443020..65b487e1b3 100644 --- a/indra/newview/skins/default/xui/pl/strings.xml +++ b/indra/newview/skins/default/xui/pl/strings.xml @@ -4412,6 +4412,10 @@ Jeżeli nadal otrzymujesz ten komunikat, skontaktuj się z [SUPPORT_SITE].  	<string name="inventory_folder_offered-im">  		Zaoferowano folder: '[ITEM_NAME]'  	</string> +	<string name="bot_warning"> +Rozmawiasz z botem [NAME]. Nie udostępniaj żadnych danych osobowych. +Dowiedz się więcej na https://second.life/scripted-agents. +	</string>  	<string name="share_alert">  		Przeciągaj tutaj rzeczy z Szafy  	</string> diff --git a/indra/newview/skins/default/xui/pt/panel_snapshot_options.xml b/indra/newview/skins/default/xui/pt/panel_snapshot_options.xml index 067e5dbd76..f71bc7cd12 100644 --- a/indra/newview/skins/default/xui/pt/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/pt/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes"?>  <panel name="panel_snapshot_options">  	<button label="Salvar no disco" name="save_to_computer_btn"/> -	<button label="Salvar em inventário (L$[AMOUNT])" name="save_to_inventory_btn"/> +	<button label="Salvar em inventário" name="save_to_inventory_btn"/>  	<button label="Compartilhar no feed do perfil" name="save_to_profile_btn"/>  	<button label="Compartilhar no Facebook" name="send_to_facebook_btn"/>  	<button label="Compartilhar no Twitter" name="send_to_twitter_btn"/> diff --git a/indra/newview/skins/default/xui/pt/strings.xml b/indra/newview/skins/default/xui/pt/strings.xml index 509b3d72a0..ccd0336ed1 100644 --- a/indra/newview/skins/default/xui/pt/strings.xml +++ b/indra/newview/skins/default/xui/pt/strings.xml @@ -1549,6 +1549,10 @@ If you continue to receive this message, contact the [SUPPORT_SITE].</string>  	<string name="conference-title-incoming">Conversa com [AGENT_NAME]</string>  	<string name="inventory_item_offered-im">Item do inventário '[ITEM_NAME]' oferecido</string>  	<string name="inventory_folder_offered-im">Pasta do inventário '[ITEM_NAME]' oferecida</string> +	<string name="bot_warning"> +Você está conversando com um bot, [NAME]. Não compartilhe informações pessoais. +Saiba mais em https://second.life/scripted-agents. +	</string>  	<string name="facebook_post_success">Você publicou no Facebook.</string>  	<string name="flickr_post_success">Você publicou no Flickr.</string>  	<string name="twitter_post_success">Você publicou no Twitter.</string> diff --git a/indra/newview/skins/default/xui/ru/panel_snapshot_options.xml b/indra/newview/skins/default/xui/ru/panel_snapshot_options.xml index 7ba03ee0c9..f7fda0b1dc 100644 --- a/indra/newview/skins/default/xui/ru/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/ru/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes"?>  <panel name="panel_snapshot_options">  	<button label="Сохранить на диске" name="save_to_computer_btn"/> -	<button label="Сохранить в инвентаре (L$[AMOUNT])" name="save_to_inventory_btn"/> +	<button label="Сохранить в инвентаре" name="save_to_inventory_btn"/>  	<button label="Поделиться в профиле" name="save_to_profile_btn"/>  	<button label="Поделиться в Facebook" name="send_to_facebook_btn"/>  	<button label="Поделиться в Twitter" name="send_to_twitter_btn"/> diff --git a/indra/newview/skins/default/xui/ru/strings.xml b/indra/newview/skins/default/xui/ru/strings.xml index 48eb7118aa..e542f7c4ef 100644 --- a/indra/newview/skins/default/xui/ru/strings.xml +++ b/indra/newview/skins/default/xui/ru/strings.xml @@ -4576,6 +4576,10 @@ support@secondlife.com.  	<string name="inventory_folder_offered-im">  		Предложена папка инвентаря «[ITEM_NAME]»  	</string> +	<string name="bot_warning"> +Вы общаетесь с ботом [NAME]. Не передавайте личные данные. +Подробнее на https://second.life/scripted-agents. +	</string>  	<string name="share_alert">  		Перетаскивайте вещи из инвентаря сюда  	</string> diff --git a/indra/newview/skins/default/xui/tr/panel_snapshot_options.xml b/indra/newview/skins/default/xui/tr/panel_snapshot_options.xml index 1b48bbeec2..a028710b98 100644 --- a/indra/newview/skins/default/xui/tr/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/tr/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes"?>  <panel name="panel_snapshot_options">  	<button label="Diske Kaydet" name="save_to_computer_btn"/> -	<button label="Envantere Kaydet (L$[AMOUNT])" name="save_to_inventory_btn"/> +	<button label="Envantere Kaydet" name="save_to_inventory_btn"/>  	<button label="Profil Akışında Paylaş" name="save_to_profile_btn"/>  	<button label="Facebook'ta Paylaş" name="send_to_facebook_btn"/>  	<button label="Twitter'da Paylaş" name="send_to_twitter_btn"/> diff --git a/indra/newview/skins/default/xui/tr/strings.xml b/indra/newview/skins/default/xui/tr/strings.xml index 92e5160e97..67df275895 100644 --- a/indra/newview/skins/default/xui/tr/strings.xml +++ b/indra/newview/skins/default/xui/tr/strings.xml @@ -4579,6 +4579,10 @@ Bu iletiyi almaya devam ederseniz, lütfen [SUPPORT_SITE] bölümüne başvurun.  	<string name="inventory_folder_offered-im">  		"[ITEM_NAME]" envanter klasörü sunuldu  	</string> +	<string name="bot_warning"> +Bir bot ile sohbet ediyorsunuz, [NAME]. Kişisel bilgilerinizi paylaşmayın. +Daha fazla bilgi için: https://second.life/scripted-agents. +	</string>  	<string name="share_alert">  		Envanterinizden buraya öğeler sürükleyin  	</string> diff --git a/indra/newview/skins/default/xui/zh/panel_snapshot_options.xml b/indra/newview/skins/default/xui/zh/panel_snapshot_options.xml index d7c65bb25e..d9536882ac 100644 --- a/indra/newview/skins/default/xui/zh/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/zh/panel_snapshot_options.xml @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="utf-8" standalone="yes"?>  <panel name="panel_snapshot_options">  	<button label="儲存到硬碟" name="save_to_computer_btn"/> -	<button label="儲存到收納區(L$[AMOUNT])" name="save_to_inventory_btn"/> +	<button label="儲存到收納區" name="save_to_inventory_btn"/>  	<button label="分享至檔案訊息發佈" name="save_to_profile_btn"/>  	<button label="分享到臉書" name="send_to_facebook_btn"/>  	<button label="分享到推特" name="send_to_twitter_btn"/> diff --git a/indra/newview/skins/default/xui/zh/strings.xml b/indra/newview/skins/default/xui/zh/strings.xml index 8fae007429..dee48b3d58 100644 --- a/indra/newview/skins/default/xui/zh/strings.xml +++ b/indra/newview/skins/default/xui/zh/strings.xml @@ -4572,6 +4572,10 @@ http://secondlife.com/support 求助解決問題。  	<string name="inventory_folder_offered-im">  		收納區資料夾'[ITEM_NAME]'已向人提供  	</string> +	<string name="bot_warning"> +您正在与人工智能机器人 [NAME] 聊天。请勿分享任何个人信息。 +了解更多:https://second.life/scripted-agents。 +	</string>  	<string name="share_alert">  		將收納區物品拖曳到這裡  	</string> | 
