[
  {
    "path": ".github/ISSUE_TEMPLATE/bug-report-blender-add-on.md",
    "content": "---\nname: Bug Report Blender Add-On\nabout: Help improve the Hubs Blender add-on with quality bug-reports\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Description**\nA clear and concise description of what the bug is.\n\n**To Reproduce**\nSteps to reproduce the behavior:\n*Please include detailed steps so others can reproduce*\n\n\n**Expected behavior**\nA clear and concise description of what you expected to happen.\n\n**Screenshots**\nIf applicable, add screenshots to help explain your problem.\n\n**Hardware** <!-- Please complete the following information -->\n - Add-on Release Version:\n - Blender Version: \n\n**Additional context**\n*Scene Links, models, any other helpful context*\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "content": "---\nname: Feature request\nabout: Suggest an idea for this project\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Is your feature request related to a problem? Please describe.**\nA clear and concise description of what the problem is. Ex. I'm always frustrated when [...]\n\n**Describe the solution you'd like**\nA clear and concise description of what you want to happen.\n\n**Describe alternatives you've considered**\nA clear and concise description of any alternative solutions or features you've considered.\n\n**Additional context**\nAdd any other context or screenshots about the feature request here.\n"
  },
  {
    "path": ".github/workflows/publish.yml",
    "content": "name: Publish\n\non:\n  push:\n    branches:\n      - master\n    paths-ignore: [\"README.md\", \"LICENSE\", \".gitignore\", \".idea\", \".vscode\", \".github/ISSUE_TEMPLATE\"]\n  pull_request:\n  workflow_dispatch:\n\npermissions: {}\n\njobs:\n  lint:\n    runs-on: ubuntu-latest\n    timeout-minutes: 20\n    steps:\n      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2\n        with:\n          persist-credentials: false\n      - name: Python Linter\n        uses: weibullguy/python-lint-plus@c1913ebcf442cb2901a919858b0146fef4f007fa # v1.12.0\n        with:\n          python-root-list: \"addons\"\n          use-black: false\n          use-yapf: false\n          use-isort: false\n          use-docformatter: false\n          use-pycodestyle: true\n          use-autopep8: false\n          use-pydocstyle: false\n          use-mypy: false\n          use-pylint: false\n          use-flake8: false\n          use-mccabe: false\n          use-radon: false\n          use-rstcheck: false\n          use-check-manifest: false\n          use-pyroma: false\n          extra-black-options: \"\"\n          extra-yapf-options: \"\"\n          extra-isort-options: \"\"\n          extra-docformatter-options: \"\"\n          # This should work with **/models but it doesn't\n          extra-pycodestyle-options: \"--exclude=models --ignore=E501,W504\"\n          extra-pydocstyle-options: \"\"\n          extra-mypy-options: \"\"\n          extra-pylint-options: \"\"\n          extra-flake8-options: \"\"\n          extra-mccabe-options: \"\"\n          extra-radon-options: \"\"\n          extra-rstcheck-options: \"\"\n          extra-manifest-options: \"\"\n          extra-pyroma-options: \"\"\n\n  test:\n    needs: lint\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        version: [\"3.6.23\", \"4.0.2\", \"4.1.1\", \"4.2.19\", \"4.3.2\", \"4.4.3\", \"4.5.8\", \"5.0.1\", \"5.1.1\" ]\n    timeout-minutes: 20\n    steps:\n      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2\n        with:\n          persist-credentials: false\n      # Finds latest Blender build, and outputs the hosted build's download URL.\n      - name: Find latest Blender build\n        id: blender_version\n        run: |\n          echo ${{ matrix.version }}\n          major=$(echo ${{ matrix.version }} | cut -d. -f1)\n          minor=$(echo ${{ matrix.version }} | cut -d. -f2)\n          patch=$(echo ${{ matrix.version }} | cut -d. -f3)\n          echo \"Looking for Blender $BLENDER_MAJOR.$BLENDER_MINOR.${BLENDER_PATCH}\"\n          BLENDER_URL=\"https://download.blender.org/release/Blender$major.$minor/blender-$major.$minor.$patch-linux-x64.tar.xz\"\n          echo \"blender-url=$BLENDER_URL\" >> $GITHUB_OUTPUT\n      # Loads a cached build of Blender if available. If not available, this step\n      # enqueues the /opt/blender directory to be cached after tests pass.\n      - id: blender_cache\n        uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5\n        env:\n          cache-name: cache-blender\n        with:\n          path: /opt/blender\n          key: ${{ steps.blender_version.outputs.blender-url }}\n      # Downloads a build from blender.org, if a cached version was not available.\n      - name: Download Blender\n        if: ${{ !steps.blender_cache.outputs.cache-hit }}\n        run: |\n          mkdir /opt/blender\n          echo \"Downloading: ${STEPS_BLENDER_VERSION_OUTPUTS_BLENDER_URL}\"\n          curl -SL \"${STEPS_BLENDER_VERSION_OUTPUTS_BLENDER_URL}\" | \\\n            tar -Jx -C /opt/blender --strip-components=1\n        env:\n          STEPS_BLENDER_VERSION_OUTPUTS_BLENDER_URL: ${{ steps.blender_version.outputs.blender-url }}\n      - name: Set up workspace\n        run: |\n          sudo ln -s /opt/blender/blender /usr/local/bin/blender\n          blender --version\n          major=$(echo ${{ matrix.version }} | cut -d. -f1)\n          minor=$(echo ${{ matrix.version }} | cut -d. -f2)\n          ADDON_DIR=/opt/blender/$major.$minor/scripts/addons\n          rm -rf $ADDON_DIR/io_hubs_addon\n          cp -r addons/io_hubs_addon $ADDON_DIR\n          cd tests\n          yarn install\n          mkdir -p out\n      - name: Run tests\n        run: |\n          cd tests\n          OUT_PREFIX=$GITHUB_WORKSPACE/tests/out yarn test-bail --reporter-options reportDir=out/mochawesome\n      - name: Upload test artifacts\n        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1\n        with:\n          name: test-output-${{ matrix.version }}\n          path: tests/out/mochawesome\n          if-no-files-found: error\n\n  publish:\n    needs: test\n    runs-on: ubuntu-latest\n    timeout-minutes: 20\n    steps:\n      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2\n        with:\n          persist-credentials: false\n      - name: Update build number\n        run: |\n          sed -i'' 's/\"dev_build\"/${{ github.run_number }}/g' $GITHUB_WORKSPACE/addons/io_hubs_addon/__init__.py\n      - name: Get version\n        id: get_version\n        run: |\n          VERSION=$(grep '\"version\"' $GITHUB_WORKSPACE/addons/io_hubs_addon/__init__.py | sed -E 's/.*\\(([0-9]+), ([0-9]+), ([0-9]+), ([0-9]+)\\).*/\\1.\\2.\\3.\\4/')\n          echo \"version=$VERSION\" >> $GITHUB_OUTPUT\n      - name: Upload addon artifacts\n        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1\n        with:\n          name: io_hubs_addon_${{ steps.get_version.outputs.version }}\n          path: addons\n          if-no-files-found: error\n          include-hidden-files: true\n"
  },
  {
    "path": ".github/workflows/roadmap-auto-commenter.yml",
    "content": "# When modifying this file, make sure to pass on the update to all repositories.  A tool like https://github.com/gruntwork-io/git-xargs may be useful for this.\n\n# WARNING: This workflow is sometimes triggered by pull_request_target and so will always run automatically on pull requests made by anyone.  Do not do any sort of processing of user input, such as checking out code.\n\nname: Roadmap Auto Commenter\non:\n  issues:\n    types:\n      - opened\n  pull_request_target:\n    types:\n      - opened\n\njobs:\n  call_reusable_roadmap_auto_commenter:\n    permissions:\n      issues: write\n      pull-requests: write\n    uses: Hubs-Foundation/.github/.github/workflows/reusable-roadmap-auto-commenter.yml@main\n"
  },
  {
    "path": ".gitignore",
    "content": "fake_bpy_modules*\n__pycache__\n.DS_Store\nio_scene_gltf2\n\n# Tests\nnode_modules/\nmochawesome-report\ntests_out/\ngenerated_cubemaps/\n\n# CMake\nCMakeFiles\ncmake_install.cmake\nCMakeCache.txt\nMakefile\nlib\n\n# Selenium\n__hubs_selenium_profile\n\n# Dependencies\naddons/io_hubs_addon/.__deps__"
  },
  {
    "path": ".vscode/launch.json",
    "content": "{\n  // Use IntelliSense to learn about possible attributes.\n  // Hover to view descriptions of existing attributes.\n  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      \"name\": \"Launch Tests\",\n      \"request\": \"launch\",\n      \"runtimeArgs\": [\n        \"run-script\",\n        \"test\"\n      ],\n      \"runtimeExecutable\": \"npm\",\n      \"skipFiles\": [\n        \"<node_internals>/**\"\n      ],\n      \"type\": \"pwa-node\",\n      \"cwd\": \"${workspaceFolder}/tests\"\n    },\n    {\n      \"name\": \"Python: Remote Attach\",\n      \"type\": \"python\",\n      \"request\": \"attach\",\n      \"connect\": {\n        \"host\": \"localhost\",\n        \"port\": 5678\n      },\n      \"pathMappings\": [\n        {\n          \"localRoot\": \"${workspaceFolder}\",\n          \"remoteRoot\": \"${workspaceFolder}\"\n        }\n      ],\n      \"justMyCode\": true\n    }\n  ]\n}"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\n  \"python.autoComplete.extraPaths\": [\n    \"./fake_bpy_modules_3.3-20221006\"\n  ],\n  \"python.formatting.provider\": \"autopep8\",\n  \"python.formatting.autopep8Args\": [\n    \"--exclude=models\", \"--max-line-length\", \"120\", \"--experimental\"\n  ],\n  \"python.analysis.extraPaths\": [\n    \"./fake_bpy_modules_3.3-20221006\"\n  ],\n  \"editor.defaultFormatter\": \"ms-python.autopep8\",\n  \"editor.formatOnSave\": true,\n  \"editor.formatOnSaveMode\": \"file\",\n  \"autopep8.args\": [\n    \"--exclude=models\", \"--max-line-length\", \"120\", \"--experimental\"\n  ],\n}"
  },
  {
    "path": "LICENSE",
    "content": "Mozilla Public License Version 2.0\n==================================\n\n1. Definitions\n--------------\n\n1.1. \"Contributor\"\n    means each individual or legal entity that creates, contributes to\n    the creation of, or owns Covered Software.\n\n1.2. \"Contributor Version\"\n    means the combination of the Contributions of others (if any) used\n    by a Contributor and that particular Contributor's Contribution.\n\n1.3. \"Contribution\"\n    means Covered Software of a particular Contributor.\n\n1.4. \"Covered Software\"\n    means Source Code Form to which the initial Contributor has attached\n    the notice in Exhibit A, the Executable Form of such Source Code\n    Form, and Modifications of such Source Code Form, in each case\n    including portions thereof.\n\n1.5. \"Incompatible With Secondary Licenses\"\n    means\n\n    (a) that the initial Contributor has attached the notice described\n        in Exhibit B to the Covered Software; or\n\n    (b) that the Covered Software was made available under the terms of\n        version 1.1 or earlier of the License, but not also under the\n        terms of a Secondary License.\n\n1.6. \"Executable Form\"\n    means any form of the work other than Source Code Form.\n\n1.7. \"Larger Work\"\n    means a work that combines Covered Software with other material, in \n    a separate file or files, that is not Covered Software.\n\n1.8. \"License\"\n    means this document.\n\n1.9. \"Licensable\"\n    means having the right to grant, to the maximum extent possible,\n    whether at the time of the initial grant or subsequently, any and\n    all of the rights conveyed by this License.\n\n1.10. \"Modifications\"\n    means any of the following:\n\n    (a) any file in Source Code Form that results from an addition to,\n        deletion from, or modification of the contents of Covered\n        Software; or\n\n    (b) any new file in Source Code Form that contains any Covered\n        Software.\n\n1.11. \"Patent Claims\" of a Contributor\n    means any patent claim(s), including without limitation, method,\n    process, and apparatus claims, in any patent Licensable by such\n    Contributor that would be infringed, but for the grant of the\n    License, by the making, using, selling, offering for sale, having\n    made, import, or transfer of either its Contributions or its\n    Contributor Version.\n\n1.12. \"Secondary License\"\n    means either the GNU General Public License, Version 2.0, the GNU\n    Lesser General Public License, Version 2.1, the GNU Affero General\n    Public License, Version 3.0, or any later versions of those\n    licenses.\n\n1.13. \"Source Code Form\"\n    means the form of the work preferred for making modifications.\n\n1.14. \"You\" (or \"Your\")\n    means an individual or a legal entity exercising rights under this\n    License. For legal entities, \"You\" includes any entity that\n    controls, is controlled by, or is under common control with You. For\n    purposes of this definition, \"control\" means (a) the power, direct\n    or indirect, to cause the direction or management of such entity,\n    whether by contract or otherwise, or (b) ownership of more than\n    fifty percent (50%) of the outstanding shares or beneficial\n    ownership of such entity.\n\n2. License Grants and Conditions\n--------------------------------\n\n2.1. Grants\n\nEach Contributor hereby grants You a world-wide, royalty-free,\nnon-exclusive license:\n\n(a) under intellectual property rights (other than patent or trademark)\n    Licensable by such Contributor to use, reproduce, make available,\n    modify, display, perform, distribute, and otherwise exploit its\n    Contributions, either on an unmodified basis, with Modifications, or\n    as part of a Larger Work; and\n\n(b) under Patent Claims of such Contributor to make, use, sell, offer\n    for sale, have made, import, and otherwise transfer either its\n    Contributions or its Contributor Version.\n\n2.2. Effective Date\n\nThe licenses granted in Section 2.1 with respect to any Contribution\nbecome effective for each Contribution on the date the Contributor first\ndistributes such Contribution.\n\n2.3. Limitations on Grant Scope\n\nThe licenses granted in this Section 2 are the only rights granted under\nthis License. No additional rights or licenses will be implied from the\ndistribution or licensing of Covered Software under this License.\nNotwithstanding Section 2.1(b) above, no patent license is granted by a\nContributor:\n\n(a) for any code that a Contributor has removed from Covered Software;\n    or\n\n(b) for infringements caused by: (i) Your and any other third party's\n    modifications of Covered Software, or (ii) the combination of its\n    Contributions with other software (except as part of its Contributor\n    Version); or\n\n(c) under Patent Claims infringed by Covered Software in the absence of\n    its Contributions.\n\nThis License does not grant any rights in the trademarks, service marks,\nor logos of any Contributor (except as may be necessary to comply with\nthe notice requirements in Section 3.4).\n\n2.4. Subsequent Licenses\n\nNo Contributor makes additional grants as a result of Your choice to\ndistribute the Covered Software under a subsequent version of this\nLicense (see Section 10.2) or under the terms of a Secondary License (if\npermitted under the terms of Section 3.3).\n\n2.5. Representation\n\nEach Contributor represents that the Contributor believes its\nContributions are its original creation(s) or it has sufficient rights\nto grant the rights to its Contributions conveyed by this License.\n\n2.6. Fair Use\n\nThis License is not intended to limit any rights You have under\napplicable copyright doctrines of fair use, fair dealing, or other\nequivalents.\n\n2.7. Conditions\n\nSections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted\nin Section 2.1.\n\n3. Responsibilities\n-------------------\n\n3.1. Distribution of Source Form\n\nAll distribution of Covered Software in Source Code Form, including any\nModifications that You create or to which You contribute, must be under\nthe terms of this License. You must inform recipients that the Source\nCode Form of the Covered Software is governed by the terms of this\nLicense, and how they can obtain a copy of this License. You may not\nattempt to alter or restrict the recipients' rights in the Source Code\nForm.\n\n3.2. Distribution of Executable Form\n\nIf You distribute Covered Software in Executable Form then:\n\n(a) such Covered Software must also be made available in Source Code\n    Form, as described in Section 3.1, and You must inform recipients of\n    the Executable Form how they can obtain a copy of such Source Code\n    Form by reasonable means in a timely manner, at a charge no more\n    than the cost of distribution to the recipient; and\n\n(b) You may distribute such Executable Form under the terms of this\n    License, or sublicense it under different terms, provided that the\n    license for the Executable Form does not attempt to limit or alter\n    the recipients' rights in the Source Code Form under this License.\n\n3.3. Distribution of a Larger Work\n\nYou may create and distribute a Larger Work under terms of Your choice,\nprovided that You also comply with the requirements of this License for\nthe Covered Software. If the Larger Work is a combination of Covered\nSoftware with a work governed by one or more Secondary Licenses, and the\nCovered Software is not Incompatible With Secondary Licenses, this\nLicense permits You to additionally distribute such Covered Software\nunder the terms of such Secondary License(s), so that the recipient of\nthe Larger Work may, at their option, further distribute the Covered\nSoftware under the terms of either this License or such Secondary\nLicense(s).\n\n3.4. Notices\n\nYou may not remove or alter the substance of any license notices\n(including copyright notices, patent notices, disclaimers of warranty,\nor limitations of liability) contained within the Source Code Form of\nthe Covered Software, except that You may alter any license notices to\nthe extent required to remedy known factual inaccuracies.\n\n3.5. Application of Additional Terms\n\nYou may choose to offer, and to charge a fee for, warranty, support,\nindemnity or liability obligations to one or more recipients of Covered\nSoftware. However, You may do so only on Your own behalf, and not on\nbehalf of any Contributor. You must make it absolutely clear that any\nsuch warranty, support, indemnity, or liability obligation is offered by\nYou alone, and You hereby agree to indemnify every Contributor for any\nliability incurred by such Contributor as a result of warranty, support,\nindemnity or liability terms You offer. You may include additional\ndisclaimers of warranty and limitations of liability specific to any\njurisdiction.\n\n4. Inability to Comply Due to Statute or Regulation\n---------------------------------------------------\n\nIf it is impossible for You to comply with any of the terms of this\nLicense with respect to some or all of the Covered Software due to\nstatute, judicial order, or regulation then You must: (a) comply with\nthe terms of this License to the maximum extent possible; and (b)\ndescribe the limitations and the code they affect. Such description must\nbe placed in a text file included with all distributions of the Covered\nSoftware under this License. Except to the extent prohibited by statute\nor regulation, such description must be sufficiently detailed for a\nrecipient of ordinary skill to be able to understand it.\n\n5. Termination\n--------------\n\n5.1. The rights granted under this License will terminate automatically\nif You fail to comply with any of its terms. However, if You become\ncompliant, then the rights granted under this License from a particular\nContributor are reinstated (a) provisionally, unless and until such\nContributor explicitly and finally terminates Your grants, and (b) on an\nongoing basis, if such Contributor fails to notify You of the\nnon-compliance by some reasonable means prior to 60 days after You have\ncome back into compliance. Moreover, Your grants from a particular\nContributor are reinstated on an ongoing basis if such Contributor\nnotifies You of the non-compliance by some reasonable means, this is the\nfirst time You have received notice of non-compliance with this License\nfrom such Contributor, and You become compliant prior to 30 days after\nYour receipt of the notice.\n\n5.2. If You initiate litigation against any entity by asserting a patent\ninfringement claim (excluding declaratory judgment actions,\ncounter-claims, and cross-claims) alleging that a Contributor Version\ndirectly or indirectly infringes any patent, then the rights granted to\nYou by any and all Contributors for the Covered Software under Section\n2.1 of this License shall terminate.\n\n5.3. In the event of termination under Sections 5.1 or 5.2 above, all\nend user license agreements (excluding distributors and resellers) which\nhave been validly granted by You or Your distributors under this License\nprior to termination shall survive termination.\n\n************************************************************************\n*                                                                      *\n*  6. Disclaimer of Warranty                                           *\n*  -------------------------                                           *\n*                                                                      *\n*  Covered Software is provided under this License on an \"as is\"       *\n*  basis, without warranty of any kind, either expressed, implied, or  *\n*  statutory, including, without limitation, warranties that the       *\n*  Covered Software is free of defects, merchantable, fit for a        *\n*  particular purpose or non-infringing. The entire risk as to the     *\n*  quality and performance of the Covered Software is with You.        *\n*  Should any Covered Software prove defective in any respect, You     *\n*  (not any Contributor) assume the cost of any necessary servicing,   *\n*  repair, or correction. This disclaimer of warranty constitutes an   *\n*  essential part of this License. No use of any Covered Software is   *\n*  authorized under this License except under this disclaimer.         *\n*                                                                      *\n************************************************************************\n\n************************************************************************\n*                                                                      *\n*  7. Limitation of Liability                                          *\n*  --------------------------                                          *\n*                                                                      *\n*  Under no circumstances and under no legal theory, whether tort      *\n*  (including negligence), contract, or otherwise, shall any           *\n*  Contributor, or anyone who distributes Covered Software as          *\n*  permitted above, be liable to You for any direct, indirect,         *\n*  special, incidental, or consequential damages of any character      *\n*  including, without limitation, damages for lost profits, loss of    *\n*  goodwill, work stoppage, computer failure or malfunction, or any    *\n*  and all other commercial damages or losses, even if such party      *\n*  shall have been informed of the possibility of such damages. This   *\n*  limitation of liability shall not apply to liability for death or   *\n*  personal injury resulting from such party's negligence to the       *\n*  extent applicable law prohibits such limitation. Some               *\n*  jurisdictions do not allow the exclusion or limitation of           *\n*  incidental or consequential damages, so this exclusion and          *\n*  limitation may not apply to You.                                    *\n*                                                                      *\n************************************************************************\n\n8. Litigation\n-------------\n\nAny litigation relating to this License may be brought only in the\ncourts of a jurisdiction where the defendant maintains its principal\nplace of business and such litigation shall be governed by laws of that\njurisdiction, without reference to its conflict-of-law provisions.\nNothing in this Section shall prevent a party's ability to bring\ncross-claims or counter-claims.\n\n9. Miscellaneous\n----------------\n\nThis License represents the complete agreement concerning the subject\nmatter hereof. If any provision of this License is held to be\nunenforceable, such provision shall be reformed only to the extent\nnecessary to make it enforceable. Any law or regulation which provides\nthat the language of a contract shall be construed against the drafter\nshall not be used to construe this License against a Contributor.\n\n10. Versions of the License\n---------------------------\n\n10.1. New Versions\n\nMozilla Foundation is the license steward. Except as provided in Section\n10.3, no one other than the license steward has the right to modify or\npublish new versions of this License. Each version will be given a\ndistinguishing version number.\n\n10.2. Effect of New Versions\n\nYou may distribute the Covered Software under the terms of the version\nof the License under which You originally received the Covered Software,\nor under the terms of any subsequent version published by the license\nsteward.\n\n10.3. Modified Versions\n\nIf you create software not governed by this License, and you want to\ncreate a new license for such software, you may create and use a\nmodified version of this License if you rename the license and remove\nany references to the name of the license steward (except to note that\nsuch modified license differs from this License).\n\n10.4. Distributing Source Code Form that is Incompatible With Secondary\nLicenses\n\nIf You choose to distribute Source Code Form that is Incompatible With\nSecondary Licenses under the terms of this version of the License, the\nnotice described in Exhibit B of this License must be attached.\n\nExhibit A - Source Code Form License Notice\n-------------------------------------------\n\n  This Source Code Form is subject to the terms of the Mozilla Public\n  License, v. 2.0. If a copy of the MPL was not distributed with this\n  file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\nIf it is not possible or desirable to put the notice in a particular\nfile, then You may include the notice in a location (such as a LICENSE\nfile in a relevant directory) where a recipient would be likely to look\nfor such a notice.\n\nYou may add additional accurate notices of copyright ownership.\n\nExhibit B - \"Incompatible With Secondary Licenses\" Notice\n---------------------------------------------------------\n\n  This Source Code Form is \"Incompatible With Secondary Licenses\", as\n  defined by the Mozilla Public License, v. 2.0.\n"
  },
  {
    "path": "Pipfile",
    "content": "[[source]]\nname = \"pypi\"\nurl = \"https://pypi.org/simple\"\nverify_ssl = true\n\n[dev-packages]\nfake-bpy-module-2-82 = \"*\"\n\n[packages]\n\n[requires]\npython_version = \"3.8\"\n"
  },
  {
    "path": "README.md",
    "content": "# Hubs Blender Exporter and Importer\n\nThis addon extends the glTF 2.0 exporter to support the `MOZ_hubs_components` and `MOZ_lightmap` extensions allowing you to add behavior to glTF assets for Hubs.\n\n[![Test](https://github.com/Hubs-Foundation/hubs-blender-exporter/actions/workflows/test.yml/badge.svg)](https://github.com/Hubs-Foundation/hubs-blender-exporter/actions/workflows/test.yml)\n[![Publish](https://github.com/Hubs-Foundation/hubs-blender-exporter/actions/workflows/publish.yml/badge.svg)](https://github.com/Hubs-Foundation/hubs-blender-exporter/actions/workflows/publish.yml)\n\n# To Install\n\nFind the latest [release](https://github.com/Hubs-Foundation/hubs-blender-exporter/releases) and download the add-on zip file.\n\n<img alt=\"select add-on zip file\" src=\"https://user-images.githubusercontent.com/837184/204576860-316b32de-8654-48a7-b9a7-3c0de1c1b652.png\" width=685px height=330px />\n\nIn Blender: `Edit > Preferences > Add-ons`\nClick install and select the zip file of the latest release.\n\n<img width=\"780\" alt=\"in blender prefs install addon\" src=\"https://user-images.githubusercontent.com/4493657/102955927-dcc56900-448b-11eb-8bfa-07e68b31cffd.png\">\n\nEnsure the Hubs add-on is checked and enabled.\n\n<img width=\"494\" alt=\"hubs blender add-on installed\" src=\"https://user-images.githubusercontent.com/4493657/102956859-c9b39880-448d-11eb-9f02-2f529f14c139.png\">\n\n# Adding Components\n\nTo add components, go to the \"Hubs\" section of the properties panel for the thing you want to add a component to. Currently adding components is supported on Scenes, Objects, Bones, and Materials.\n\n<img src=\"https://user-images.githubusercontent.com/130735/84547528-97440a00-acb8-11ea-9f07-24c919796a3c.png\" width=\"300px\"/>\n\nClick \"Add Component\" and select the component you wish to add from the list. Only components appropriate for the object type you are currently editing and have not already been added will be shown.\n\n# Using Lightmaps\n\nTo use a lightmap, create a `MOZ_lightmap` node from the `Add > Hubs` menu and hook up a image texture to the `Lightmap` input. Use a `UV Map` node to control what UV set should be used for the lightmap, as you would any other texture in Blender.\n\n![lightmap node](https://user-images.githubusercontent.com/130735/83931408-65c7bd80-a751-11ea-86b9-a2ae889ec5df.png)\n\nNote that for use in Hubs, you currently **MUST** use the second UV set, as ThreeJS is currently hardcoded to use that for lightmaps. This will likely be fixed in the future so the add-on does not enforce this.\n\n![setting bake UV](https://user-images.githubusercontent.com/130735/83697782-b9e96b00-a5b4-11ea-986b-6690c69d8a3f.png)\n\n# Exporting\n\nThis addon works in conjunction with the official glTF add-on, so exporting is done through it. Select \"File > Export > glTF 2.0\" and then ensure \"Hubs Components\" is enabled under \"Extensions\".\n\n![gltf export window](https://user-images.githubusercontent.com/130735/84547591-be9ad700-acb8-11ea-8c58-7b1104f0a3a7.png)\n\n# Import into Hubs\n\nThe easiest way to use your scene file is through the Spoke project creation page and selecting _Import From Blender_:\n\n<img width=\"710\" alt=\"Screenshot 2021-10-31 at 14 05 21\" src=\"https://user-images.githubusercontent.com/303516/139588457-8d9d7835-6101-4cfc-886b-ad3e86c37846.png\">\n\nThis will bring up the Publish Scene From Blender dialog where you can upload your GLB file and a thumbnail picture for your scene:\n\n<img width=\"826\" alt=\"Screenshot 2021-10-31 at 14 31 44\" src=\"https://user-images.githubusercontent.com/303516/139588871-ca440552-a270-4feb-9208-65b65ee02b4a.png\">\n\nIt is also possible to use the GLB file to replace the scene for an existing Hubs room directly by going to Room Settings > Change Scene > Custom Scene and entering the URL of the GLB file. This assumes the file has been already uploaded to an online storage provider.\n\n# Scene debugger\n\nThe Hubs Blender add-on includes a scene debugger, enabling you to see the Blender scene updates in Hubs with just one click. For additional information, please visit:  https://github.com/Hubs-Foundation/hubs-blender-exporter/wiki/Hubs-scene-debugger/\n\n# Development\n\n## Code Completion\nTo enable code completion for the Blender Python API you can install the [Fake Blender Python API module collection](https://github.com/nutti/fake-bpy-module/). You can download the modules using the `setup.sh` script from the repository root or using [pip](https://github.com/nutti/fake-bpy-module/#install-via-pip-package).\n## Code style\n\nThis repository follows the [PEP8](https://peps.python.org/pep-0008/) style convention for python files. If you use VSCode this repository already includes a setting to autoformat every python file when saved. If you don't use VSCode you can probably add a similar setting in your favorite editor. We are happy to add settings for other editors so feel free to open a PR if you want your editor's settings included.\n\nWe also include a `format.py` python script that will format the whole codebase when run. You can run it before pushing the PR to make sure that all the new code follows PEP8.\n\nBoth the python script and the VSCode settings rely on the [autopep8](https://pypi.org/project/autopep8/) command line tool for formatting so make sure that it's installed in your system.\n\n## Addon development\n\nIt might be useful while developing to be able to load the addon directly from the checkout folder without needing to install it. You can do it in two ways:\n\n- ### Overriding the Blender user scripts directory\n  You can override the Blender user scripts directory from the console to point to the addon repo directory.\n\n**MacOS**\n\n`BLENDER_USER_SCRIPTS=full_path_to_/hubs-blender-exporter /Applications/Blender.app/Contents/MacOS/Blender`\n\n**Linux**\n\n`BLENDER_USER_SCRIPTS=full_path_to_/hubs-blender-exporter blender`\n\n- ### Symlinking your addon to the Blender user scripts directory\n  You can create a symbolic link pointing to `full_path_to_/hubs-blender-exporter/addons/io_hubs_addon` in your current Python scripts directory in Blender. This way you will also load any other addons that you have in that directory.\n\n**MacOS and Linux**\n\n`ln -s full_path_to/hubs-blender-exporter/addons/io_hubs_addon full_path_to/blender_user_scripts_dir`\n\nYou can set or see the current Blender user scripts in the Preferences -> File Paths -> Scripts\n\n## Component export hooks\n\nWhen adding or modifying Hubs components, the exporter lifecycle uses a few different hooks with different responsibilities (these are defined in hubs_component.py and optionally overridden in specific components):\n\n- `pre_export`\n  - Runs before export starts.\n  - Best used for export setup or preprocessing that must happen before gathering data.\n  - Avoid using this for component data validation that is tied to exported output.\n\n- `gather`\n  - Runs when component data is exported.\n  - Best place for component-specific export logic and export-time validation related to exported data.\n\n- `post_export`\n  - Runs after export finishes.\n  - Best used for cleanup or restoring temporary state.\n\nFor user-facing validation or reporting, prefer the existing Hubs report viewer / export reporting flow rather than console-only warnings when appropriate.\n\n# Debugging\n\nYou can debug the addon code with PyCharm or VSCode:\n\n- [Debug with PyCharm](https://code.blender.org/2015/10/debugging-python-code-with-pycharm) **NOTE:** If you are using Blender 2.80+, you need the [updated debugger script](https://github.com/ux3d/random-blender-addons/blob/master/remote_debugger.py)\n- [Debug with VSCode](DEBUGGING.md)\n\n# Continuous Integration Tests\n\nTo run the tests locally, your system should have a blender executable in the path that launches the desired version of Blender.\n\nThe latest version of [Yarn](https://yarnpkg.com/en/) should also be installed.\n\nThen, in the tests folder of this repository, run yarn install, followed by yarn run test.\n"
  },
  {
    "path": "addons/io_hubs_addon/.pylintrc",
    "content": "[MASTER]\n\n# A comma-separated list of package or module names from where C extensions may\n# be loaded. Extensions are loading into the active Python interpreter and may\n# run arbitrary code.\nextension-pkg-whitelist=\n\n# Add files or directories to the blacklist. They should be base names, not\n# paths.\nignore=CVS\n\n# Add files or directories matching the regex patterns to the blacklist. The\n# regex matches against base names, not paths.\nignore-patterns=\n\n# Python code to execute, usually for sys.path manipulation such as\n# pygtk.require().\n#init-hook=\n\n# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the\n# number of processors available to use.\njobs=1\n\n# Control the amount of potential inferred values when inferring a single\n# object. This can help the performance when dealing with large functions or\n# complex, nested conditions.\nlimit-inference-results=100\n\n# List of plugins (as comma separated values of python modules names) to load,\n# usually to register additional checkers.\nload-plugins=\n\n# Pickle collected data for later comparisons.\npersistent=yes\n\n# Specify a configuration file.\n#rcfile=\n\n# When enabled, pylint would attempt to guess common misconfiguration and emit\n# user-friendly hints instead of false-positive error messages.\nsuggestion-mode=yes\n\n# Allow loading of arbitrary C extensions. Extensions are imported into the\n# active Python interpreter and may run arbitrary code.\nunsafe-load-any-extension=no\n\n\n[MESSAGES CONTROL]\n\n# Only show warnings with the listed confidence levels. Leave empty to show\n# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.\nconfidence=\n\n# Disable the message, report, category or checker with the given id(s). You\n# can either give multiple identifiers separated by comma (,) or put this\n# option multiple times (only on the command line, not in the configuration\n# file where it should appear only once). You can also use \"--disable=all\" to\n# disable everything first and then reenable specific checks. For example, if\n# you want to run only the similarities checker, you can use \"--disable=all\n# --enable=similarities\". If you want to run only the classes checker, but have\n# no Warning level messages displayed, use \"--disable=all --enable=classes\n# --disable=W\".\ndisable=print-statement,\n        parameter-unpacking,\n        unpacking-in-except,\n        old-raise-syntax,\n        backtick,\n        long-suffix,\n        old-ne-operator,\n        old-octal-literal,\n        import-star-module-level,\n        non-ascii-bytes-literal,\n        raw-checker-failed,\n        bad-inline-option,\n        locally-disabled,\n        file-ignored,\n        suppressed-message,\n        useless-suppression,\n        deprecated-pragma,\n        use-symbolic-message-instead,\n        apply-builtin,\n        basestring-builtin,\n        buffer-builtin,\n        cmp-builtin,\n        coerce-builtin,\n        execfile-builtin,\n        file-builtin,\n        long-builtin,\n        raw_input-builtin,\n        reduce-builtin,\n        standarderror-builtin,\n        unicode-builtin,\n        xrange-builtin,\n        coerce-method,\n        delslice-method,\n        getslice-method,\n        setslice-method,\n        no-absolute-import,\n        old-division,\n        dict-iter-method,\n        dict-view-method,\n        next-method-called,\n        metaclass-assignment,\n        indexing-exception,\n        raising-string,\n        reload-builtin,\n        oct-method,\n        hex-method,\n        nonzero-method,\n        cmp-method,\n        input-builtin,\n        round-builtin,\n        intern-builtin,\n        unichr-builtin,\n        map-builtin-not-iterating,\n        zip-builtin-not-iterating,\n        range-builtin-not-iterating,\n        filter-builtin-not-iterating,\n        using-cmp-argument,\n        eq-without-hash,\n        div-method,\n        idiv-method,\n        rdiv-method,\n        exception-message-attribute,\n        invalid-str-codec,\n        sys-max-int,\n        bad-python3-import,\n        deprecated-string-function,\n        deprecated-str-translate-call,\n        deprecated-itertools-function,\n        deprecated-types-field,\n        next-method-defined,\n        dict-items-not-iterating,\n        dict-keys-not-iterating,\n        dict-values-not-iterating,\n        deprecated-operator-function,\n        deprecated-urllib-function,\n        xreadlines-attribute,\n        deprecated-sys-function,\n        exception-escape,\n        comprehension-escape,\n        invalid-name,\n        missing-docstring,\n        assignment-from-no-return,\n        import-error,\n        protected-access\n\n# Enable the message, report, category or checker with the given id(s). You can\n# either give multiple identifier separated by comma (,) or put this option\n# multiple time (only on the command line, not in the configuration file where\n# it should appear only once). See also the \"--disable\" option for examples.\nenable=c-extension-no-member\n\n\n[REPORTS]\n\n# Python expression which should return a note less than 10 (10 is the highest\n# note). You have access to the variables errors warning, statement which\n# respectively contain the number of errors / warnings messages and the total\n# number of statements analyzed. This is used by the global evaluation report\n# (RP0004).\nevaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)\n\n# Template used to display messages. This is a python new-style format string\n# used to format the message information. See doc for all details.\n#msg-template=\n\n# Set the output format. Available formats are text, parseable, colorized, json\n# and msvs (visual studio). You can also give a reporter class, e.g.\n# mypackage.mymodule.MyReporterClass.\noutput-format=text\n\n# Tells whether to display a full report or only the messages.\nreports=no\n\n# Activate the evaluation score.\nscore=yes\n\n\n[REFACTORING]\n\n# Maximum number of nested blocks for function / method body\nmax-nested-blocks=5\n\n# Complete name of functions that never returns. When checking for\n# inconsistent-return-statements if a never returning function is called then\n# it will be considered as an explicit return statement and no message will be\n# printed.\nnever-returning-functions=sys.exit\n\n\n[LOGGING]\n\n# Format style used to check logging format string. `old` means using %\n# formatting, while `new` is for `{}` formatting.\nlogging-format-style=old\n\n# Logging modules to check that the string format arguments are in logging\n# function parameter format.\nlogging-modules=logging\n\n\n[SPELLING]\n\n# Limits count of emitted suggestions for spelling mistakes.\nmax-spelling-suggestions=4\n\n# Spelling dictionary name. Available dictionaries: none. To make it working\n# install python-enchant package..\nspelling-dict=\n\n# List of comma separated words that should not be checked.\nspelling-ignore-words=\n\n# A path to a file that contains private dictionary; one word per line.\nspelling-private-dict-file=\n\n# Tells whether to store unknown words to indicated private dictionary in\n# --spelling-private-dict-file option instead of raising a message.\nspelling-store-unknown-words=no\n\n\n[MISCELLANEOUS]\n\n# List of note tags to take in consideration, separated by a comma.\nnotes=FIXME,\n      XXX,\n      TODO\n\n\n[TYPECHECK]\n\n# List of decorators that produce context managers, such as\n# contextlib.contextmanager. Add to this list to register other decorators that\n# produce valid context managers.\ncontextmanager-decorators=contextlib.contextmanager\n\n# List of members which are set dynamically and missed by pylint inference\n# system, and so shouldn't trigger E1101 when accessed. Python regular\n# expressions are accepted.\ngenerated-members=\n\n# Tells whether missing members accessed in mixin class should be ignored. A\n# mixin class is detected if its name ends with \"mixin\" (case insensitive).\nignore-mixin-members=yes\n\n# Tells whether to warn about missing members when the owner of the attribute\n# is inferred to be None.\nignore-none=yes\n\n# This flag controls whether pylint should warn about no-member and similar\n# checks whenever an opaque object is returned when inferring. The inference\n# can return multiple potential results while evaluating a Python object, but\n# some branches might not be evaluated, which results in partial inference. In\n# that case, it might be useful to still emit no-member and other checks for\n# the rest of the inferred objects.\nignore-on-opaque-inference=yes\n\n# List of class names for which member attributes should not be checked (useful\n# for classes with dynamically set attributes). This supports the use of\n# qualified names.\nignored-classes=optparse.Values,thread._local,_thread._local\n\n# List of module names for which member attributes should not be checked\n# (useful for modules/projects where namespaces are manipulated during runtime\n# and thus existing member attributes cannot be deduced by static analysis. It\n# supports qualified module names, as well as Unix pattern matching.\nignored-modules=\n\n# Show a hint with possible names when a member name was not found. The aspect\n# of finding the hint is based on edit distance.\nmissing-member-hint=yes\n\n# The minimum edit distance a name should have in order to be considered a\n# similar match for a missing member name.\nmissing-member-hint-distance=1\n\n# The total number of similar names that should be taken in consideration when\n# showing a hint for a missing member.\nmissing-member-max-choices=1\n\n\n[VARIABLES]\n\n# List of additional names supposed to be defined in builtins. Remember that\n# you should avoid defining new builtins when possible.\nadditional-builtins=\n\n# Tells whether unused global variables should be treated as a violation.\nallow-global-unused-variables=yes\n\n# List of strings which can identify a callback function by name. A callback\n# name must start or end with one of those strings.\ncallbacks=cb_,\n          _cb\n\n# A regular expression matching the name of dummy variables (i.e. expected to\n# not be used).\ndummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_\n\n# Argument names that match this expression will be ignored. Default to name\n# with leading underscore.\nignored-argument-names=_.*|^ignored_|^unused_\n\n# Tells whether we should check for unused import in __init__ files.\ninit-import=no\n\n# List of qualified module names which can have objects that can redefine\n# builtins.\nredefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io\n\n\n[FORMAT]\n\n# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.\nexpected-line-ending-format=\n\n# Regexp for a line that is allowed to be longer than the limit.\nignore-long-lines=^\\s*(# )?<?https?://\\S+>?$\n\n# Number of spaces of indent required inside a hanging or continued line.\nindent-after-paren=4\n\n# String used as indentation unit. This is usually \"    \" (4 spaces) or \"\\t\" (1\n# tab).\nindent-string='    '\n\n# Maximum number of characters on a single line.\nmax-line-length=100\n\n# Maximum number of lines in a module.\nmax-module-lines=1000\n\n# List of optional constructs for which whitespace checking is disabled. `dict-\n# separator` is used to allow tabulation in dicts, etc.: {1  : 1,\\n222: 2}.\n# `trailing-comma` allows a space between comma and closing bracket: (a, ).\n# `empty-line` allows space-only lines.\nno-space-check=trailing-comma,\n               dict-separator\n\n# Allow the body of a class to be on the same line as the declaration if body\n# contains single statement.\nsingle-line-class-stmt=no\n\n# Allow the body of an if to be on the same line as the test if there is no\n# else.\nsingle-line-if-stmt=no\n\n\n[SIMILARITIES]\n\n# Ignore comments when computing similarities.\nignore-comments=yes\n\n# Ignore docstrings when computing similarities.\nignore-docstrings=yes\n\n# Ignore imports when computing similarities.\nignore-imports=no\n\n# Minimum lines number of a similarity.\nmin-similarity-lines=4\n\n\n[BASIC]\n\n# Naming style matching correct argument names.\nargument-naming-style=snake_case\n\n# Regular expression matching correct argument names. Overrides argument-\n# naming-style.\n#argument-rgx=\n\n# Naming style matching correct attribute names.\nattr-naming-style=snake_case\n\n# Regular expression matching correct attribute names. Overrides attr-naming-\n# style.\n#attr-rgx=\n\n# Bad variable names which should always be refused, separated by a comma.\nbad-names=foo,\n          bar,\n          baz,\n          toto,\n          tutu,\n          tata\n\n# Naming style matching correct class attribute names.\nclass-attribute-naming-style=any\n\n# Regular expression matching correct class attribute names. Overrides class-\n# attribute-naming-style.\n#class-attribute-rgx=\n\n# Naming style matching correct class names.\nclass-naming-style=PascalCase\n\n# Regular expression matching correct class names. Overrides class-naming-\n# style.\n#class-rgx=\n\n# Naming style matching correct constant names.\nconst-naming-style=UPPER_CASE\n\n# Regular expression matching correct constant names. Overrides const-naming-\n# style.\n#const-rgx=\n\n# Minimum line length for functions/classes that require docstrings, shorter\n# ones are exempt.\ndocstring-min-length=-1\n\n# Naming style matching correct function names.\nfunction-naming-style=snake_case\n\n# Regular expression matching correct function names. Overrides function-\n# naming-style.\n#function-rgx=\n\n# Good variable names which should always be accepted, separated by a comma.\ngood-names=i,\n           j,\n           k,\n           ex,\n           Run,\n           _\n\n# Include a hint for the correct naming format with invalid-name.\ninclude-naming-hint=no\n\n# Naming style matching correct inline iteration names.\ninlinevar-naming-style=any\n\n# Regular expression matching correct inline iteration names. Overrides\n# inlinevar-naming-style.\n#inlinevar-rgx=\n\n# Naming style matching correct method names.\nmethod-naming-style=snake_case\n\n# Regular expression matching correct method names. Overrides method-naming-\n# style.\n#method-rgx=\n\n# Naming style matching correct module names.\nmodule-naming-style=snake_case\n\n# Regular expression matching correct module names. Overrides module-naming-\n# style.\n#module-rgx=\n\n# Colon-delimited sets of names that determine each other's naming style when\n# the name regexes allow several styles.\nname-group=\n\n# Regular expression which should only match function or class names that do\n# not require a docstring.\nno-docstring-rgx=^_\n\n# List of decorators that produce properties, such as abc.abstractproperty. Add\n# to this list to register other decorators that produce valid properties.\n# These decorators are taken in consideration only for invalid-name.\nproperty-classes=abc.abstractproperty\n\n# Naming style matching correct variable names.\nvariable-naming-style=snake_case\n\n# Regular expression matching correct variable names. Overrides variable-\n# naming-style.\n#variable-rgx=\n\n\n[STRING]\n\n# This flag controls whether the implicit-str-concat-in-sequence should\n# generate a warning on implicit string concatenation in sequences defined over\n# several lines.\ncheck-str-concat-over-line-jumps=no\n\n\n[IMPORTS]\n\n# Allow wildcard imports from modules that define __all__.\nallow-wildcard-with-all=no\n\n# Analyse import fallback blocks. This can be used to support both Python 2 and\n# 3 compatible code, which means that the block might have code that exists\n# only in one or another interpreter, leading to false positives when analysed.\nanalyse-fallback-blocks=no\n\n# Deprecated modules which should not be used, separated by a comma.\ndeprecated-modules=optparse,tkinter.tix\n\n# Create a graph of external dependencies in the given file (report RP0402 must\n# not be disabled).\next-import-graph=\n\n# Create a graph of every (i.e. internal and external) dependencies in the\n# given file (report RP0402 must not be disabled).\nimport-graph=\n\n# Create a graph of internal dependencies in the given file (report RP0402 must\n# not be disabled).\nint-import-graph=\n\n# Force import order to recognize a module as part of the standard\n# compatibility libraries.\nknown-standard-library=\n\n# Force import order to recognize a module as part of a third party library.\nknown-third-party=enchant\n\n\n[CLASSES]\n\n# List of method names used to declare (i.e. assign) instance attributes.\ndefining-attr-methods=__init__,\n                      __new__,\n                      setUp\n\n# List of member names, which should be excluded from the protected access\n# warning.\nexclude-protected=_asdict,\n                  _fields,\n                  _replace,\n                  _source,\n                  _make\n\n# List of valid names for the first argument in a class method.\nvalid-classmethod-first-arg=cls\n\n# List of valid names for the first argument in a metaclass class method.\nvalid-metaclass-classmethod-first-arg=cls\n\n\n[DESIGN]\n\n# Maximum number of arguments for function / method.\nmax-args=5\n\n# Maximum number of attributes for a class (see R0902).\nmax-attributes=7\n\n# Maximum number of boolean expressions in an if statement.\nmax-bool-expr=5\n\n# Maximum number of branch for function / method body.\nmax-branches=12\n\n# Maximum number of locals for function / method body.\nmax-locals=15\n\n# Maximum number of parents for a class (see R0901).\nmax-parents=7\n\n# Maximum number of public methods for a class (see R0904).\nmax-public-methods=20\n\n# Maximum number of return / yield for function / method body.\nmax-returns=6\n\n# Maximum number of statements in function / method body.\nmax-statements=50\n\n# Minimum number of public methods for a class (see R0903).\nmin-public-methods=2\n\n\n[EXCEPTIONS]\n\n# Exceptions that will emit a warning when being caught. Defaults to\n# \"BaseException, Exception\".\novergeneral-exceptions=BaseException,\n                       Exception\n"
  },
  {
    "path": "addons/io_hubs_addon/__init__.py",
    "content": "from .utils import create_prefs_dir\nimport sys\nimport bpy\nfrom .io import gltf_exporter, gltf_importer, panels\nfrom . import (nodes, components)\nfrom . import preferences\nfrom . import third_party\nfrom . import debugger\nfrom . import icons\nbl_info = {\n    \"name\": \"Hubs Blender Addon\",\n    \"author\": \"The Hubs Community\",\n    \"description\": \"Tools for developing glTF assets for Hubs\",\n    \"blender\": (3, 1, 2),\n    \"version\": (1, 8, 0, \"dev_build\"),\n    \"location\": \"\",\n    \"wiki_url\": \"https://github.com/Hubs-Foundation/hubs-blender-exporter\",\n    \"tracker_url\": \"https://github.com/Hubs-Foundation/hubs-blender-exporter/issues\",\n    \"support\": \"COMMUNITY\",\n    \"warning\": \"\",\n    \"category\": \"Generic\"\n}\n\n\ncreate_prefs_dir()\n\n\n# Blender 4.2+ glTF Extension Import/Export Settings Panel\ndef draw(context, layout):\n    layout_header, layout_body = layout.panel('HBA_PT_Import_Export_Panel', default_closed=True)\n    sfile = context.space_data\n    operator = sfile.active_operator\n\n    # Panel Header\n    if operator.bl_idname == \"EXPORT_SCENE_OT_gltf\":\n        props = bpy.context.scene.HubsComponentsExtensionProperties\n    elif operator.bl_idname == \"IMPORT_SCENE_OT_gltf\":\n        props = bpy.context.scene.HubsComponentsExtensionImportProperties\n\n    layout_header.use_property_split = False\n    layout_header.prop(props, 'enabled', text=\"\")\n    layout_header.label(text=\"Hubs Components\")\n\n    # Panel Body\n    if layout_body:\n        if operator.bl_idname == \"EXPORT_SCENE_OT_gltf\":\n            gltf_exporter.HubsGLTFExportPanel.draw_body(context, layout_body)\n        elif operator.bl_idname == \"IMPORT_SCENE_OT_gltf\":\n            gltf_importer.HubsGLTFImportPanel.draw_body(context, layout_body)\n\n\ndef register():\n    icons.register()\n    preferences.register()\n    nodes.register()\n    components.register()\n    gltf_importer.register()\n    gltf_exporter.register()\n    panels.register_panels()\n    third_party.register()\n    debugger.register()\n\n    # Migrate components if the add-on is enabled in the middle of a session.\n    if bpy.context.preferences.is_dirty:\n        def registration_migration():\n            # Passing True as the first argument of the operator forces an undo step to be created.\n            bpy.ops.wm.migrate_hubs_components(\n                'EXEC_DEFAULT', True, is_registration=True)\n        bpy.app.timers.register(registration_migration)\n\n\ndef unregister():\n    third_party.unregister()\n    panels.unregister_panels()\n    gltf_exporter.unregister()\n    gltf_importer.unregister()\n    components.unregister()\n    nodes.unregister()\n    preferences.unregister()\n    debugger.unregister()\n    icons.unregister()\n\n\n# called by gltf-blender-io after it has loaded\n\n\nglTF2ExportUserExtension = gltf_exporter.glTF2ExportUserExtension\nglTF2_pre_export_callback = gltf_exporter.glTF2_pre_export_callback\nglTF2_post_export_callback = gltf_exporter.glTF2_post_export_callback\nif bpy.app.version > (3, 0, 0):\n    glTF2ImportUserExtension = gltf_importer.glTF2ImportUserExtension\n\n\ndef register_panel():\n    return panels.register_panels()\n"
  },
  {
    "path": "addons/io_hubs_addon/api.py",
    "content": "import requests\n\n\ndef create_room(endpoint, token=None, scene_name=None, scene_id=None):\n    payload = {}\n    if scene_id:\n        payload = {\n            \"hub\": {\n                \"name\": scene_name,\n                \"scene_id\": scene_id\n            }\n        }\n\n    headers = {}\n    if token:\n        headers = {\n            \"content-type\": \"application/json\",\n            \"authorization\": f'Bearer {token}'\n        }\n\n    import json\n    body = json.dumps(payload)\n\n    url = f'{endpoint}/api/v1/hubs'\n    resp = requests.post(url, body, headers=headers)\n\n    return resp.json()\n\n\ndef upload_media(endpoint, file):\n    resp = requests.post(f'{endpoint}/api/v1/media', files={'media': (\n        'glb', file, 'application/octet-stream')}, verify=False)\n    json = resp.json()\n\n    if \"error\" in json:\n        raise Exception(f'Unknown error')\n\n    return {\n        \"file_id\": json.get(\"file_id\"),\n        \"access_token\": json.get(\"meta\").get(\"access_token\")\n    }\n\n\ndef publish_scene(endpoint, token, scene_data, scene_id=None):\n    headers = {\n        \"content-type\": \"application/json\",\n        \"authorization\": f'Bearer {token}'\n    }\n\n    import json\n    body = json.dumps({\"scene\": scene_data})\n\n    url = f'{endpoint}/api/v1/scenes{\"/\" + scene_id if scene_id else \"\"}'\n    if scene_id:\n        resp = requests.put(url, body, headers=headers)\n    else:\n        resp = requests.post(url, body, headers=headers)\n\n    jsonFile = resp.json()\n    if \"error\" in jsonFile:\n        error = jsonFile.get(\"error\")\n        if error == \"invalid_token\":\n            raise Exception(\"Authentication error\")\n        else:\n            raise Exception(f'Unknown error: {error}')\n\n    return jsonFile\n\n\ndef get_projects(endpoint, token):\n    headers = {\n        \"content-type\": \"application/json\",\n        \"authorization\": f'Bearer {token}'\n    }\n\n    resp = requests.get(\n        f'{endpoint}/api/v1/scenes/projectless', headers=headers)\n\n    jsonFile = resp.json()\n    if \"error\" in jsonFile:\n        error = jsonFile.get(\"error\")\n        if error == \"invalid_token\":\n            raise Exception(\"Authentication error\")\n        else:\n            raise Exception(f'Unknown error: {error}')\n\n    if \"scenes\" not in jsonFile:\n        raise Exception(f'Projects request error')\n    scenes = jsonFile.get(\"scenes\")\n    return scenes\n"
  },
  {
    "path": "addons/io_hubs_addon/components/__init__.py",
    "content": "from . import (handlers, gizmos, components_registry, ui, operators, utils)\n\n\ndef register():\n    utils.register()\n    handlers.register()\n    gizmos.register()\n    components_registry.register()\n    operators.register()\n    ui.register()\n\n\ndef unregister():\n    ui.unregister()\n    operators.unregister()\n    components_registry.unregister()\n    gizmos.unregister()\n    handlers.unregister()\n    utils.unregister()\n"
  },
  {
    "path": "addons/io_hubs_addon/components/components_registry.py",
    "content": "from .types import NodeType\nimport bpy\nfrom bpy.props import BoolProperty, StringProperty, CollectionProperty, PointerProperty\nfrom bpy.types import PropertyGroup\n\nimport importlib\nimport inspect\nimport os\nfrom os.path import join, isfile, isdir, dirname, realpath\n\nfrom .hubs_component import HubsComponent\n\n\nclass HubsComponentName(PropertyGroup):\n    # For backwards compatibility reasons this attribute is called \"name\" but it actually points to the component id\n    name: StringProperty(name=\"name\")\n    expanded: BoolProperty(name=\"expanded\", default=True)\n    isDependency: BoolProperty(name=\"dependency\", default=False)\n\n\nclass HubsComponentList(PropertyGroup):\n    items: CollectionProperty(type=HubsComponentName)\n\n\ndef get_components_in_dir(dir):\n    components = []\n    for f in os.listdir(dir):\n        f_path = join(dir, f)\n        if isfile(f_path) and f.endswith(\".py\"):\n            components.append(f[:-3])\n        elif isdir(f_path) and f != \"__pycache__\":\n            comps = [f + '.' + name for name in get_components_in_dir(f_path)]\n            components = components + comps\n    return sorted(components)\n\n\ndef get_user_component_names():\n    component_names = []\n    from ..preferences import get_addon_pref\n    addon_prefs = get_addon_pref(bpy.context)\n    for entry in addon_prefs.user_components_paths:\n        if entry.path and os.path.isdir(entry.path):\n            component_names.append(get_components_in_dir(entry.path))\n    return component_names\n\n\ndef get_user_component_paths():\n    component_paths = []\n    from ..preferences import get_addon_pref\n    addon_prefs = get_addon_pref(bpy.context)\n    for entry in addon_prefs.user_components_paths:\n        if entry.path and os.path.isdir(entry.path):\n            components = get_components_in_dir(entry.path)\n            for component in components:\n                component_paths.append(os.path.join(entry.path, component + \".py\"))\n    return component_paths\n\n\ndef get_user_component_definitions():\n    modules = []\n    component_paths = get_user_component_paths()\n    for component_path in component_paths:\n        try:\n            spec = importlib.util.spec_from_file_location(component_path, component_path)\n            mod = importlib.util.module_from_spec(spec)\n            spec.loader.exec_module(mod)\n            modules.append(mod)\n\n        except Exception as e:\n            print(f'Failed import of component {component_path}', e)\n    return modules\n\n\ndef get_component_definitions():\n    components_dir = join(dirname(realpath(__file__)), \"definitions\")\n    component_module_names = get_components_in_dir(components_dir)\n    return [\n        importlib.import_module(\".definitions.\" + name, package=__package__)\n        for name in component_module_names\n    ]\n\n\ndef get_component_module_name(component_class):\n    relative_module_name = component_class.__module__.replace(f\"{__package__}.definitions.\", \"\")\n    return \".\".join(relative_module_name.split(\".\")[:-1])\n\n\ndef register_component(component_class):\n    component_module_name = get_component_module_name(component_class)\n    if component_module_name:\n        print(f\"Registering component: {component_module_name} - {component_class.get_name()}\")\n    else:\n        print(f\"Registering component: {component_class.get_name()}\")\n    bpy.utils.register_class(component_class)\n\n    component_id = component_class.get_id()\n    if component_class.get_node_type() == NodeType.SCENE:\n        setattr(\n            bpy.types.Scene,\n            component_id,\n            PointerProperty(type=component_class)\n        )\n    elif component_class.get_node_type() == NodeType.NODE:\n        setattr(\n            bpy.types.Object,\n            component_id,\n            PointerProperty(type=component_class)\n        )\n        setattr(\n            bpy.types.Bone,\n            component_id,\n            PointerProperty(type=component_class)\n        )\n        setattr(\n            bpy.types.EditBone,\n            component_id,\n            PointerProperty(type=component_class)\n        )\n    elif component_class.get_node_type() == NodeType.MATERIAL:\n        setattr(\n            bpy.types.Material,\n            component_id,\n            PointerProperty(type=component_class)\n        )\n\n    from ..io.gltf_exporter import glTF2ExportUserExtension\n    glTF2ExportUserExtension.add_excluded_property(component_class.get_id())\n\n\ndef unregister_component(component_class):\n    component_id = component_class.get_id()\n    if component_class.get_node_type() == NodeType.SCENE:\n        delattr(bpy.types.Scene, component_id)\n    elif component_class.get_node_type() == NodeType.NODE:\n        delattr(bpy.types.Object, component_id)\n        delattr(bpy.types.Bone, component_id)\n        delattr(bpy.types.EditBone, component_id)\n    elif component_class.get_node_type() == NodeType.MATERIAL:\n        delattr(bpy.types.Material, component_id)\n\n    bpy.utils.unregister_class(component_class)\n\n    from ..io.gltf_exporter import glTF2ExportUserExtension\n    glTF2ExportUserExtension.remove_excluded_property(component_class.get_id())\n\n    component_module_name = get_component_module_name(component_class)\n    if component_module_name:\n        print(f\"Component unregistered: {component_module_name} - {component_class.get_name()}\")\n    else:\n        print(f\"Component unregistered: {component_class.get_name()}\")\n\n\ndef load_user_components():\n    global __components_registry\n    for module in get_user_component_definitions():\n        for _, member in inspect.getmembers(module):\n            if inspect.isclass(member) and issubclass(member, HubsComponent) and module.__name__ == member.__module__:\n                try:\n                    if hasattr(module, 'register_module'):\n                        module.register_module()\n                    register_component(member)\n                    __components_registry[member.get_name()] = member\n                except Exception:\n                    import traceback\n                    traceback.print_exc()\n\n\ndef unload_user_components():\n    global __components_registry\n    for _, component_class in __components_registry.items():\n        for module_name in get_user_component_names():\n            if module_name == component_class.get_name():\n                unregister_component(component_class)\n    for module in get_user_component_definitions():\n        if hasattr(module, 'unregister_module'):\n            module.unregister_module()\n\n\ndef load_components_registry():\n    \"\"\"Recurse in the components directory to build the components registry\"\"\"\n    global __components_registry\n    __components_registry = {}\n    for module in get_component_definitions():\n        for _, member in inspect.getmembers(module):\n            if inspect.isclass(member) and issubclass(member, HubsComponent) and module.__name__ == member.__module__:\n                if hasattr(module, 'register_module'):\n                    module.register_module()\n                register_component(member)\n                __components_registry[member.get_name()] = member\n\n    # When running Blender in factory startup mode and specifying an addon, that addon's register function is called.\n    # As preferences are not available until the addon is enabled, the user component load fails when accessing them.\n    # This happens when running tests and this guard avoids crashing in that scenario.\n    from ..utils import is_addon_enabled\n    if is_addon_enabled():\n        load_user_components()\n\n\ndef unload_components_registry():\n    \"\"\"Recurse in the components directory to unload the registered components\"\"\"\n    global __components_registry\n    for _, component_class in __components_registry.items():\n        unregister_component(component_class)\n    for module in get_component_definitions():\n        if hasattr(module, 'unregister_module'):\n            module.unregister_module()\n\n\n__components_registry = {}\n\n\ndef get_components_registry():\n    global __components_registry\n    return __components_registry\n\n\ndef get_component_by_name(component_name):\n    global __components_registry\n    return next(\n        (component_class for _, component_class in __components_registry.items()\n         if component_class.get_name() == component_name),\n        None)\n\n\ndef register():\n    load_components_registry()\n\n    bpy.utils.register_class(HubsComponentName)\n    bpy.utils.register_class(HubsComponentList)\n\n    bpy.types.Object.hubs_component_list = PointerProperty(\n        type=HubsComponentList)\n    bpy.types.Scene.hubs_component_list = PointerProperty(\n        type=HubsComponentList)\n    bpy.types.Material.hubs_component_list = PointerProperty(\n        type=HubsComponentList)\n    bpy.types.Bone.hubs_component_list = PointerProperty(\n        type=HubsComponentList)\n    bpy.types.EditBone.hubs_component_list = PointerProperty(\n        type=HubsComponentList)\n\n    from ..io.gltf_exporter import glTF2ExportUserExtension\n    glTF2ExportUserExtension.add_excluded_property(\"hubs_component_list\")\n\n\ndef unregister():\n    del bpy.types.Object.hubs_component_list\n    del bpy.types.Scene.hubs_component_list\n    del bpy.types.Material.hubs_component_list\n    del bpy.types.Bone.hubs_component_list\n    del bpy.types.EditBone.hubs_component_list\n\n    bpy.utils.unregister_class(HubsComponentName)\n    bpy.utils.unregister_class(HubsComponentList)\n\n    from ..io.gltf_exporter import glTF2ExportUserExtension\n    glTF2ExportUserExtension.remove_excluded_property(\"hubs_component_list\")\n\n    unload_components_registry()\n\n    global __components_registry\n    del __components_registry\n"
  },
  {
    "path": "addons/io_hubs_addon/components/consts.py",
    "content": "from math import pi\n\nDISTANCE_MODELS = [(\"inverse\", \"Inverse drop off (inverse)\",\n                    \"Volume will decrease inversely with distance\"),\n                   (\"linear\", \"Linear drop off (linear)\",\n                   \"Volume will decrease linearly with distance\"),\n                   (\"exponential\", \"Exponential drop off (exponential)\",\n                   \"Volume will decrease expoentially with distance\")]\n\n\nMAX_ANGLE = 2 * pi\n\nPROJECTION_MODE = [(\"flat\", \"2D image (flat)\", \"Image will be shown on a 2D surface\"),\n                   (\"360-equirectangular\",\n                    \"Spherical (360-equirectangular)\", \"Image will be shown on a sphere\")]\n\nTRANSPARENCY_MODE = [(\"opaque\", \"No transparency (opaque)\", \"Alpha channel will be ignored\"),\n                     (\"blend\", \"Gradual transparency (blend)\",\n                      \"Alpha channel will be applied\"),\n                     (\"mask\", \"Binary transparency (mask)\",\n                      \"Alpha channel will be used as a threshold between opaque and transparent pixels\")]\n\nINTERPOLATION_MODES = [\n    (\"linear\", \"linear\", \"\"),\n    (\"quadraticIn\", \"quadraticIn\", \"\"),\n    (\"quadraticOut\", \"quadraticOut\", \"\"),\n    (\"quadraticInOut\", \"quadraticInOut\", \"\"),\n    (\"cubicIn\", \"cubicIn\", \"\"),\n    (\"cubicOut\", \"cubicOut\", \"\"),\n    (\"cubicInOut\", \"cubicInOut\", \"\"),\n    (\"quarticIn\", \"quarticIn\", \"\"),\n    (\"quarticOut\", \"quarticOut\", \"\"),\n    (\"quarticInOut\", \"quarticInOut\", \"\"),\n    (\"quinticIn\", \"quinticIn\", \"\"),\n    (\"quinticOut\", \"quinticOut\", \"\"),\n    (\"quinticInOut\", \"quinticInOut\", \"\"),\n    (\"sinusoidalIn\", \"sinusoidalIn\", \"\"),\n    (\"sinusoidalOut\", \"sinusoidalOut\", \"\"),\n    (\"sinusoidalInOut\", \"sinusoidalInOut\", \"\"),\n    (\"exponentialIn\", \"exponentialIn\", \"\"),\n    (\"exponentialOut\", \"exponentialOut\", \"\"),\n    (\"exponentialInOut\", \"exponentialIn\", \"\"),\n    (\"circularIn\", \"circularIn\", \"\"),\n    (\"circularOut\", \"circularOut\", \"\"),\n    (\"circularInOut\", \"circularInOut\", \"\"),\n    (\"elasticIn\", \"elasticIn\", \"\"),\n    (\"elasticOut\", \"elasticOut\", \"\"),\n    (\"elasticInOut\", \"elasticInOut\", \"\"),\n    (\"backIn\", \"backIn\", \"\"),\n    (\"backOut\", \"backOut\", \"\"),\n    (\"backInOut\", \"backInOut\", \"\"),\n    (\"bounceIn\", \"bounceIn\", \"\"),\n    (\"bounceOut\", \"bounceOut\", \"\"),\n    (\"bounceInOut\", \"bounceInOut\", \"\")\n]\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/ambient_light.py",
    "content": "from bpy.props import FloatVectorProperty, FloatProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass AmbientLight(HubsComponent):\n    _definition = {\n        'name': 'ambient-light',\n        'display_name': 'Ambient Light',\n        'category': Category.LIGHTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'LIGHT_HEMI',\n        'version': (1, 0, 0)\n    }\n\n    color: FloatVectorProperty(name=\"Color\",\n                               description=\"Color\",\n                               subtype='COLOR_GAMMA',\n                               default=(1.0, 1.0, 1.0, 1.0),\n                               size=4,\n                               min=0,\n                               max=1)\n\n    intensity: FloatProperty(name=\"Intensity\",\n                             description=\"Intensity\",\n                             default=1.0)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/ammo_shape.py",
    "content": "from bpy.props import FloatProperty, EnumProperty, FloatVectorProperty, BoolProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ..utils import get_host_or_parents_scaled\n\n\nclass AmmoShape(HubsComponent):\n    _definition = {\n        'name': 'ammo-shape',\n        'display_name': 'Ammo Shape',\n        'category': Category.OBJECT,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'SCENE_DATA',\n        'version': (1, 0, 0)\n    }\n\n    type: EnumProperty(\n        name=\"Type\", description=\"Type\",\n        items=[(\"box\", \"Box Collider\", \"A box-shaped primitive collision shape\"),\n               (\"sphere\", \"Sphere Collider\", \"A primitive collision shape which represents a sphere\"),\n               (\"hull\", \"Convex Hull\",\n                \"A convex hull wrapped around the object's vertices. A good analogy for a convex hull is an elastic membrane or balloon under pressure which is placed around a given set of vertices. When released the membrane will assume the shape of the convex hull\"),\n               (\"mesh\", \"Mesh Collider\",\n                \"A shape made of the actual vertices of the object. This can be expensive for large meshes\")],\n        default=\"hull\")\n\n    #  TODO Add conditional UI to show only the required properties per type\n    fit: EnumProperty(\n        name=\"Shape Fitting Mode\",\n        description=\"Shape fitting mode\",\n        items=[(\"all\", \"Automatic fit all\", \"Automatically match the shape to fit the object's vertices\"),\n               (\"manual\", \"Manual fit\", \"Use the manually specified dimensions to define the shape, ignoring the object's vertices\")],\n        default=\"all\")\n\n    halfExtents: FloatVectorProperty(\n        name=\"Half Extents\",\n        description=\"Half dimensions of the collider. (Only used when fit is set to \\\"manual\\\" and type is set to \\\"box\\\")\",\n        unit='LENGTH',\n        subtype=\"XYZ\",\n        default=(0.5, 0.5, 0.5))\n\n    minHalfExtent: FloatProperty(\n        name=\"Min Half Extent\",\n        description=\"The minimum size to use when automatically generating half extents. (Only used when fit is set to \\\"all\\\" and type is set to \\\"box\\\")\",\n        unit=\"LENGTH\",\n        default=0.0)\n\n    maxHalfExtent: FloatProperty(\n        name=\"Max Half Extent\",\n        description=\"The maximum size to use when automatically generating half extents. (Only used when fit is set to \\\"all\\\" and type is set to \\\"box\\\")\",\n        unit=\"LENGTH\",\n        default=1000.0)\n\n    sphereRadius: FloatProperty(\n        name=\"Sphere Radius\",\n        description=\"Radius of the sphere collider. (Only used when fit is set to \\\"manual\\\" and type is set to \\\"sphere\\\")\",\n        unit=\"LENGTH\", default=0.5)\n\n    offset: FloatVectorProperty(\n        name=\"Offset\", description=\"An offset to apply to the collider relative to the object's origin\",\n        unit='LENGTH',\n        subtype=\"XYZ\",\n        default=(0.0, 0.0, 0.0))\n\n    includeInvisible: BoolProperty(\n        name=\"Include Invisible\",\n        description=\"Include invisible objects when generating a collider. (Only used if \\\"fit\\\" is set to \\\"all\\\")\",\n        default=False)\n\n    def draw(self, context, layout, panel):\n        super().draw(context, layout, panel)\n\n        if get_host_or_parents_scaled(context.object):\n            col = layout.column()\n            col.alert = True\n            col.label(\n                text=\"The ammo-shape object, and its parents' scale need to be [1,1,1]\", icon='ERROR')\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/audio.py",
    "content": "from ..models import audio\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world\nfrom bpy.props import BoolProperty, StringProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom .networked import migrate_networked\n\n\nclass Audio(HubsComponent):\n    _definition = {\n        'name': 'audio',\n        'display_name': 'Audio',\n        'category': Category.MEDIA,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'deps': ['networked', 'audio-params'],\n        'icon': 'OUTLINER_OB_SPEAKER',\n        'version': (1, 0, 0)\n    }\n\n    src: StringProperty(\n        name=\"Audio URL\", description=\"Audio URL\", default='https://example.org/AudioFile.mp3')\n\n    autoPlay: BoolProperty(name=\"Auto Play\",\n                           description=\"Auto Play\",\n                           default=True)\n\n    controls: BoolProperty(\n        name=\"Show controls\",\n        description=\"When enabled, shows play/pause, skip forward/back, and volume controls when hovering your cursor over it in Hubs\",\n        default=True)\n\n    loop: BoolProperty(name=\"Loop\",\n                       description=\"Loop\",\n                       default=True)\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            migrate_networked(host)\n\n        return migration_occurred\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", audio.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = (0.8, 0.8, 0.8)\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/audio_params.py",
    "content": "import bpy\nfrom bpy.props import BoolProperty, FloatProperty, EnumProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import PanelType, NodeType, MigrationType\nfrom ..utils import is_linked, get_host_reference_message\nfrom ..consts import DISTANCE_MODELS, MAX_ANGLE\nfrom ...io.utils import assign_property\nfrom math import degrees, radians\n\nAUDIO_TYPES = [(\"pannernode\", \"Positional audio (pannernode)\",\n                \"Volume will change depending on the listener's position relative to the source\"),\n               (\"stereo\", \"Background audio (stereo)\",\n                \"Volume will be independent of the listener's position\")]\n\n\nclass AudioParams(HubsComponent):\n    _definition = {\n        'name': 'audio-params',\n        'display_name': 'Audio Params',\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'version': (1, 0, 1)\n    }\n\n    overrideAudioSettings: BoolProperty(\n        name=\"Override Audio Settings\",\n        description=\"Override Audio Settings\",\n        default=False)\n\n    audioType: EnumProperty(\n        name=\"Audio Type\",\n        description=\"Audio Type\",\n        items=AUDIO_TYPES,\n        default=\"pannernode\")\n\n    distanceModel: EnumProperty(\n        name=\"Distance Model\",\n        description=\"Distance Model\",\n        items=DISTANCE_MODELS,\n        default=\"inverse\")\n\n    gain: FloatProperty(\n        name=\"Gain\",\n        description=\"How much to amplify the source audio by\",\n        default=1.0,\n        min=0.0)\n\n    refDistance: FloatProperty(\n        name=\"Ref Distance\",\n        description=\"A double value representing the reference distance for reducing volume as the audio source moves further from the listener. For distances greater than this the volume will be reduced based on rolloffFactor and distanceModel\",\n        subtype=\"DISTANCE\",\n        unit=\"LENGTH\",\n        default=1.0,\n        min=0.0)\n\n    rolloffFactor: FloatProperty(\n        name=\"Rolloff Factor\",\n        description=\"A double value describing how quickly the volume is reduced as the source moves away from the listener. This value is used by all distance models\",\n        default=1.0,\n        min=0.0)\n\n    maxDistance: FloatProperty(\n        name=\"Max Distance\",\n        description=\"A double value representing the maximum distance between the audio source and the listener, after which the volume is not reduced any further. This value is used only by the linear distance model\",\n        subtype=\"DISTANCE\",\n        unit=\"LENGTH\",\n        default=10000.0,\n        min=0.0)\n\n    coneInnerAngle: FloatProperty(\n        name=\"Cone Inner Angle\",\n        description=\"A double value describing the angle, in degrees, of a cone inside of which there will be no volume reduction\",\n        subtype=\"ANGLE\",\n        default=MAX_ANGLE,\n        min=0.0,\n        max=MAX_ANGLE,\n        precision=2)\n\n    coneOuterAngle: FloatProperty(\n        name=\"Cone Outer Angle\",\n        description=\"A double value describing the angle, in degrees, of a cone outside of which the volume will be reduced by a constant value, defined by the coneOuterGain attribute\",\n        subtype=\"ANGLE\",\n        default=0.0,\n        min=0.0,\n        max=MAX_ANGLE,\n        precision=2)\n\n    coneOuterGain: FloatProperty(\n        name=\"Cone Outer Gain\",\n        description=\"A double value describing the amount of volume reduction outside the cone defined by the coneOuterAngle attribute\",\n        default=0.0,\n        min=0.0,\n        max=1.0)\n\n    def gather(self, export_settings, object):\n        if (self.overrideAudioSettings):\n            return {\n                'audioType': self.audioType,\n                'distanceModel': self.distanceModel,\n                'gain': self.gain,\n                'refDistance': self.refDistance,\n                'rolloffFactor': self.rolloffFactor,\n                'maxDistance': self.maxDistance,\n                'coneInnerAngle': round(degrees(self.coneInnerAngle), 2),\n                'coneOuterAngle': round(degrees(self.coneOuterAngle), 2),\n                'coneOuterGain': self.coneOuterGain\n            }\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            self.coneInnerAngle = radians(\n                self.coneInnerAngle)\n            self.coneOuterAngle = radians(\n                self.coneOuterAngle)\n\n            if migration_type != MigrationType.GLOBAL or is_linked(ob) or type(ob) is bpy.types.Armature:\n                host_reference = get_host_reference_message(panel_type, host, ob=ob)\n                migration_report.append(\n                    f\"Warning: The Media Cone angles may not have migrated correctly for the Audio Params component on the {panel_type.value} {host_reference}\")\n\n        if instance_version <= (1, 0, 0):\n            if self.get(\"overrideAudioSettings\") is None:\n                migration_occurred = True\n                self.overrideAudioSettings = True\n\n        return migration_occurred\n\n    def draw(self, context, layout, panel):\n        layout.prop(data=self, property=\"overrideAudioSettings\")\n        if not self.overrideAudioSettings:\n            return\n\n        layout.prop(data=self, property=\"audioType\")\n        layout.prop(data=self, property=\"gain\")\n\n        if self.audioType == \"pannernode\":\n            layout.prop(data=self, property=\"distanceModel\")\n            layout.prop(data=self, property=\"rolloffFactor\")\n            layout.prop(data=self, property=\"refDistance\")\n            layout.prop(data=self, property=\"maxDistance\")\n            layout.prop(data=self, property=\"coneInnerAngle\")\n            layout.prop(data=self, property=\"coneOuterAngle\")\n            layout.prop(data=self, property=\"coneOuterGain\")\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        component = blender_host.hubs_component_audio_params\n        component.overrideAudioSettings = True\n        for property_name, property_value in component_value.items():\n            if property_name in ['coneInnerAngle', 'coneOuterAngle']:\n                property_value = radians(property_value)\n            assign_property(gltf.vnodes, component,\n                            property_name, property_value)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/audio_settings.py",
    "content": "import bpy\nfrom bpy.props import FloatProperty, EnumProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType, MigrationType\nfrom ..utils import is_linked\nfrom ..consts import DISTANCE_MODELS, MAX_ANGLE\nfrom ...io.utils import import_component, assign_property\nfrom math import degrees, radians\n\n\nclass AudioSettings(HubsComponent):\n    _definition = {\n        'name': 'audio-settings',\n        'display_name': 'Audio Settings',\n        'category': Category.SCENE,\n        'node_type': NodeType.SCENE,\n        'panel_type': [PanelType.SCENE],\n        'icon': 'SPEAKER',\n        'version': (1, 0, 0)\n    }\n\n    avatarDistanceModel: EnumProperty(\n        name=\"Avatar Distance Model\",\n        description=\"Avatar Distance Model\",\n        items=DISTANCE_MODELS,\n        default=\"inverse\")\n\n    avatarRolloffFactor: FloatProperty(\n        name=\"Avatar Rolloff Factor\",\n        default=2.0,\n        min=0.0)\n\n    avatarRefDistance: FloatProperty(\n        name=\"Avatar Ref Distance\",\n        description=\"Avatar Ref Distance\",\n        subtype=\"DISTANCE\",\n        default=1.0,\n        min=0.0)\n\n    avatarMaxDistance: FloatProperty(\n        name=\"Avatar Max Distance\",\n        description=\"Avatar Max Distance\",\n        subtype=\"DISTANCE\",\n        default=10000.0,\n        min=0.0)\n\n    mediaVolume: FloatProperty(\n        name=\"Media Volume\",\n        description=\"Media Volume\",\n        default=0.5,\n        min=0.0)\n\n    mediaDistanceModel: EnumProperty(\n        name=\"Media Distance Model\",\n        description=\"Media Distance Model\",\n        items=DISTANCE_MODELS,\n        default=\"inverse\")\n\n    mediaRolloffFactor: FloatProperty(\n        name=\"Media Rolloff Factor\",\n        description=\"Media Rolloff Factor\",\n        default=2.0,\n        min=0.0)\n\n    mediaRefDistance: FloatProperty(\n        name=\"Media Ref Distance\",\n        description=\"Media Rolloff Factor\",\n        subtype=\"DISTANCE\",\n        default=2.0,\n        min=0.0)\n\n    mediaMaxDistance: FloatProperty(\n        name=\"Media Max Distance\",\n        description=\"Media Max Distance\",\n        subtype=\"DISTANCE\",\n        default=10000.0,\n        min=0.0)\n\n    mediaConeInnerAngle: FloatProperty(\n        name=\"Media Cone Inner Angle\",\n        description=\"Media Cone Inner Angle\",\n        subtype=\"ANGLE\",\n        default=MAX_ANGLE,\n        min=0.0,\n        max=MAX_ANGLE)\n\n    mediaConeOuterAngle: FloatProperty(\n        name=\"Media Cone Outer Angle\",\n        description=\"Media Cone Outer Angle\",\n        subtype=\"ANGLE\",\n        default=0.0,\n        min=0.0,\n        max=MAX_ANGLE)\n\n    mediaConeOuterGain: FloatProperty(\n        name=\"Media Cone Outer Gain\",\n        description=\"Media Cone Outer Gain\",\n        default=0.0,\n        min=0.0,\n        max=1.0)\n\n    def gather(self, export_settings, object):\n        return {\n            'avatarDistanceModel': self.avatarDistanceModel,\n            'avatarRolloffFactor': self.avatarRolloffFactor,\n            'avatarRefDistance': self.avatarRefDistance,\n            'avatarMaxDistance': self.avatarMaxDistance,\n            'mediaVolume': self.mediaVolume,\n            'mediaDistanceModel': self.mediaDistanceModel,\n            'mediaRolloffFactor': self.mediaRolloffFactor,\n            'mediaRefDistance': self.mediaRefDistance,\n            'mediaMaxDistance': self.mediaMaxDistance,\n            'mediaConeInnerAngle': round(degrees(self.mediaConeInnerAngle), 2),\n            'mediaConeOuterAngle': round(degrees(self.mediaConeOuterAngle), 2),\n            'mediaConeOuterGain': self.mediaConeOuterGain,\n        }\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            self.mediaConeInnerAngle = radians(\n                self.mediaConeInnerAngle)\n            self.mediaConeOuterAngle = radians(\n                self.mediaConeOuterAngle)\n\n            if migration_type != MigrationType.GLOBAL or is_linked(host):\n                migration_report.append(\n                    f\"Warning: The Media Cone angles may not have migrated correctly for the Audio Settings component on scene \\\"{host.name_full}\\\"\")\n\n        return migration_occurred\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        component = import_component(component_name, blender_host)\n        for property_name, property_value in component_value.items():\n            if property_name in ['mediaConeInnerAngle', 'mediaConeOuterAngle']:\n                property_value = radians(property_value)\n            assign_property(gltf.vnodes, component,\n                            property_name, property_value)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/audio_source.py",
    "content": "from bpy.props import BoolProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass AudioSource(HubsComponent):\n    _definition = {\n        'name': 'zone-audio-source',\n        'display_name': 'Audio Source',\n        'category': Category.MEDIA,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'MOD_WAVE',\n        'version': (1, 0, 0)\n    }\n\n    onlyMods: BoolProperty(\n        name=\"Only Mods\", description=\"Only room moderators are able to transmit audio from this source\", default=True)\n\n    muteSelf: BoolProperty(\n        name=\"Mute Self\", description=\"Do not transmit your own audio to audio targets\", default=True)\n\n    debug: BoolProperty(\n        name=\"Debug\", description=\"Play white noise when no audio source is in the zone\", default=False)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/audio_target.py",
    "content": "from email.policy import default\nfrom bpy.props import FloatProperty, BoolProperty, PointerProperty, EnumProperty, StringProperty\nfrom ..hubs_component import HubsComponent\nfrom ..utils import has_component, is_linked\nfrom ..types import Category, PanelType, NodeType\nfrom ..ui import add_link_indicator\nfrom bpy.types import Object\nfrom ...utils import delayed_gather\nfrom ...io.utils import import_component, assign_property\nfrom .audio_source import AudioSource\n\n\nBLANK_ID = \"374e54CMHFCipSk\"\n\n\ndef filter_on_component(self, ob):\n    dep_name = AudioSource.get_name()\n    if hasattr(ob, 'type') and ob.type == 'ARMATURE':\n        if ob.mode == 'EDIT':\n            ob.update_from_editmode()\n\n        for bone in ob.data.bones:\n            if has_component(bone, dep_name):\n                return True\n    return has_component(ob, dep_name)\n\n\nbones = []\n\n\ndef get_bones(self, context):\n    global bones\n    bones = []\n    count = 0\n    dep_name = AudioSource.get_name()\n    bones.append((BLANK_ID, \"Select a bone\", \"None\", \"BLANK\", count))\n    count += 1\n\n    if self.srcNode and self.srcNode.mode == 'EDIT':\n        self.srcNode.update_from_editmode()\n\n    found = False\n    if self.srcNode and self.srcNode.type == 'ARMATURE':\n        for bone in self.srcNode.data.bones:\n            if has_component(bone, dep_name):\n                bones.append((bone.name, bone.name, \"\", 'BONE_DATA', count))\n                count += 1\n                if bone.name == self.bone_id:\n                    found = True\n\n    if self.bone_id != BLANK_ID and not found:\n        bones.append(\n            (self.bone_id, self.bone_id, \"\", \"ERROR\", count))\n        count += 1\n\n    return bones\n\n\ndef get_bone(self):\n    global bones\n    list_ids = list(map(lambda x: x[0], bones))\n    if self.bone_id in list_ids:\n        return list_ids.index(self.bone_id)\n    return 0\n\n\ndef set_bone(self, value):\n    global bones\n    list_indexes = list(map(lambda x: x[4], bones))\n    if value in list_indexes:\n        self.bone_id = bones[value][0]\n    else:\n        self.bone_id = BLANK_ID\n\n\nclass AudioTarget(HubsComponent):\n    _definition = {\n        'name': 'audio-target',\n        'display_name': 'Audio Target',\n        'category': Category.MEDIA,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'deps': ['audio-params'],\n        'icon': 'SPEAKER',\n        'version': (1, 0, 0)\n    }\n\n    srcNode: PointerProperty(\n        name=\"Source\",\n        description=\"The object with an audio-source component to pull audio from\",\n        type=Object,\n        poll=filter_on_component,\n        update=lambda self, context: setattr(self, 'bone', BLANK_ID)\n    )\n\n    bone: EnumProperty(\n        name=\"Bone\",\n        description=\"The bone with an audio-source component to pull audio from.  If a bone is selected, this will override the object source, otherwise if no bone is selected, the source will be pulled from the object\",\n        items=get_bones,\n        get=get_bone,\n        set=set_bone\n    )\n\n    bone_id: StringProperty(\n        name=\"bone_id\",\n        default=BLANK_ID,\n        options={'HIDDEN'})\n\n    minDelay: FloatProperty(\n        name=\"Min Delay\",\n        description=\"Minimum random delay applied to the source audio\",\n        default=0.01,\n        min=0.0)\n\n    maxDelay: FloatProperty(\n        name=\"Max Delay\",\n        description=\"Maximum random delay applied to the source audio\",\n        default=0.03,\n        min=0.0)\n\n    debug: BoolProperty(\n        name=\"Debug\",\n        description=\"Show debug visuals\",\n        default=False)\n\n    @classmethod\n    def init(cls, obj):\n        obj.hubs_component_audio_params.overrideAudioSettings = True\n\n    def draw(self, context, layout, panel):\n        dep_name = AudioSource.get_name()\n\n        has_obj_component = False\n        has_bone_component = False\n        row = layout.row(align=True)\n        sub_row = row.row(align=True)\n        sub_row.prop(data=self, property=\"srcNode\")\n        if is_linked(context.active_object):\n            # Manually disable the PointerProperty, needed for Blender 3.2+.\n            sub_row.enabled = False\n        if is_linked(self.srcNode):\n            sub_row = row.row(align=True)\n            sub_row.enabled = False\n            add_link_indicator(sub_row, self.srcNode)\n\n        if hasattr(self.srcNode, 'type'):\n            has_obj_component = has_component(self.srcNode, dep_name)\n            if self.srcNode.type == 'ARMATURE':\n                layout.prop(data=self, property=\"bone\")\n                if self.bone_id != BLANK_ID and self.bone in self.srcNode.data.bones:\n                    has_bone_component = has_component(\n                        self.srcNode.data.bones[self.bone], dep_name)\n\n        if self.srcNode and self.bone_id == BLANK_ID and not has_obj_component:\n            col = layout.column()\n            col.alert = True\n            col.label(\n                text=f'The selected source doesn\\'t have an {AudioSource.get_display_name()} component', icon='ERROR')\n        elif self.srcNode and self.bone_id != BLANK_ID and not has_bone_component:\n            col = layout.column()\n            col.alert = True\n            col.label(\n                text=f'The selected bone doesn\\'t have an {AudioSource.get_display_name()} component', icon='ERROR')\n\n        layout.prop(data=self, property=\"minDelay\")\n        layout.prop(data=self, property=\"maxDelay\")\n        layout.prop(data=self, property=\"debug\")\n\n    @delayed_gather\n    def gather(self, export_settings, object):\n        from ...io.utils import gather_joint_property, gather_node_property\n        return {\n            'srcNode': gather_joint_property(export_settings, self.srcNode, self, 'bone') if self.bone_id != BLANK_ID else gather_node_property(\n                export_settings, object, self, 'srcNode'),\n            'maxDelay': self.maxDelay,\n            'minDelay': self.minDelay,\n            'debug': self.debug\n        }\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        component = import_component(component_name, blender_host)\n        for property_name, property_value in component_value.items():\n            if property_name == \"srcNode\" and type(property_value) is int:\n                # This srcNode property was generated from an older version of the exporter which stored the index directly as an integer.\n                property_value = {\"__mhc_link_type\": \"node\", \"index\": property_value}\n            assign_property(gltf.vnodes, component,\n                            property_name, property_value)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/audio_zone.py",
    "content": "from bpy.props import BoolProperty\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world\nfrom ..models import box\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom .networked import migrate_networked\n\n\nclass AudioZone(HubsComponent):\n    _definition = {\n        'name': 'audio-zone',\n        'display_name': 'Audio Zone',\n        'category': Category.MEDIA,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'deps': ['networked', 'audio-params'],\n        'icon': 'MATCUBE',\n        'version': (1, 0, 0)\n    }\n\n    inOut: BoolProperty(\n        name=\"In Out\",\n        description=\"The zone audio parameters affect the sources inside the zone when the listener is outside\",\n        default=True)\n\n    outIn: BoolProperty(\n        name=\"Out In\",\n        description=\"The zone audio parameters affect the sources outside the zone when the listener is inside\",\n        default=True)\n\n    dynamic: BoolProperty(\n        name=\"Dynamic\",\n        description=\"Whether or not this audio-zone will be movable\",\n        default=False)\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", box.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.line_width = 3\n        gizmo.color = (0.0, 0.8, 0.0)\n        gizmo.alpha = 1.0\n        gizmo.hide_select = True\n        gizmo.scale_basis = 1.0\n        gizmo.color_highlight = (0.0, 0.8, 0.0)\n        gizmo.alpha_highlight = 0.5\n\n        return gizmo\n\n    @classmethod\n    def init(cls, obj):\n        obj.hubs_component_audio_params.overrideAudioSettings = True\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            migrate_networked(host)\n\n        return migration_occurred\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/billboard.py",
    "content": "from bpy.props import BoolProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, NodeType, PanelType\n\n\nclass Billboard(HubsComponent):\n    _definition = {\n        'name': 'billboard',\n        'display_name': 'Billboard',\n        'category': Category.OBJECT,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'IMAGE_PLANE',\n        'version': (1, 0, 0)\n    }\n\n    onlyY: BoolProperty(\n        name=\"Vertical Axis Only\",\n        description=\"Locks the Vertical Axis to enable only side to side movement in world space and removes any other rotational transforms\",\n        default=False)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/directional_light.py",
    "content": "from ..models import directional_light\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world, update_gizmos\nfrom bpy.props import FloatVectorProperty, FloatProperty, BoolProperty, IntVectorProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, NodeType, PanelType\n\n\nclass DirectionalLight(HubsComponent):\n    _definition = {\n        'name': 'directional-light',\n        'display_name': 'Directional Light',\n        'category': Category.LIGHTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'LIGHT_SUN',\n        'version': (1, 0, 0)\n    }\n\n    color: FloatVectorProperty(name=\"Color\",\n                               description=\"Color\",\n                               subtype='COLOR_GAMMA',\n                               default=(1.0, 1.0, 1.0, 1.0),\n                               size=4,\n                               min=0,\n                               max=1,\n                               update=lambda self, context: update_gizmos())\n\n    intensity: FloatProperty(name=\"Intensity\",\n                             description=\"Intensity\",\n                             default=1.0)\n\n    castShadow: BoolProperty(name=\"Cast Shadow\", default=True)\n\n    shadowMapResolution: IntVectorProperty(name=\"Shadow Map Resolution\",\n                                           description=\"Shadow Map Resolution\",\n                                           size=2,\n                                           default=[512, 512])\n\n    shadowBias: FloatProperty(name=\"Shadow Bias\",\n                              description=\"Shadow Bias\",\n                              default=0.0)\n\n    shadowRadius: FloatProperty(name=\"Shadow Radius\",\n                                description=\"Shadow Radius\",\n                                default=1.0)\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", directional_light.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = getattr(ob, cls.get_id()).color[:3]\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/environment_settings.py",
    "content": "from bpy.props import FloatProperty, EnumProperty, FloatVectorProperty, PointerProperty, BoolProperty\nfrom bpy.types import Image\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ..utils import is_linked\nfrom ..ui import add_link_indicator\nfrom ...io.utils import import_component, assign_property\nimport bpy\n\n\nTOME_MAPPING = [(\"NoToneMapping\", \"None\", \"No tone mapping\"),\n                (\"LinearToneMapping\", \"Linear\", \"Linear tone mapping\"),\n                (\"ReinhardToneMapping\", \"ThreeJS 'Reinhard'\",\n                 \"ThreeJS 'Reinhard' tone mapping\"),\n                (\"CineonToneMapping\", \"ThreeJS 'Cineon'\",\n                 \"ThreeJS 'Cineon' tone mapping\"),\n                (\"ACESFilmicToneMapping\", \"ThreeJS 'ACES Filmic'\",\n                 \"ThreeJS 'ACES Filmic' tone mapping\"),\n                (\"LUTToneMapping\", \"Blender 'Filmic'\", \"Match Blender's Filmic tone mapping\")]\n\n\nclass EnvironmentSettings(HubsComponent):\n    _definition = {\n        'name': 'environment-settings',\n        'display_name': 'Environment Settings',\n        'category': Category.SCENE,\n        'node_type': NodeType.SCENE,\n        'panel_type': [PanelType.SCENE],\n        'icon': 'WORLD',\n        'version': (1, 0, 0)\n    }\n\n    toneMapping: EnumProperty(\n        name=\"Tone Mapping\",\n        description=\"Tone Mapping\",\n        items=TOME_MAPPING,\n        default=\"LUTToneMapping\")\n\n    toneMappingExposure: FloatProperty(\n        name=\"Exposure\", description=\"Exposure level of tone mapping\", default=1.0, min=0.0)\n\n    backgroundColor: FloatVectorProperty(name=\"Background Color\",\n                                         description=\"Background Color\",\n                                         subtype='COLOR_GAMMA',\n                                         default=(1.0, 1.0, 1.0, 1.0),\n                                         size=4,\n                                         min=0,\n                                         max=1)\n    backgroundTexture: PointerProperty(\n        name=\"Background Image\",\n        description=\"An equirectangular image to use as the scene background\",\n        type=Image\n    )\n\n    envMapTexture: PointerProperty(\n        name=\"EnvMap\",\n        description=\"An equirectangular image to use as the default environment map for all objects\",\n        type=Image\n    )\n\n    enableHDRPipeline: BoolProperty(\n        name=\"Enable HDR Pipeline\",\n        description=\"Enable the new (experimental) HDR render pipeline with post processing effects and modified lighting + tonemapping model. NOTE: This checkbox is an opt-in to breaking changes. New versions of the Hubs client may break scenes with this option checked without warning and may reqquire re-export with a later Blender exporter.\",\n        default=False\n    )\n\n    enableBloom: BoolProperty(\n        name=\"Bloom\",\n        description=\"Add a Bloom effect to bright objects.\",\n        default=False\n    )\n    bloomThreshold: FloatProperty(\n        name=\"Threshold\",\n        description=\"Values brighter than this in the final render (before tone mapping) will have bloom applied to them. The threshold is applied starting at 1, so a value of 0 will cover all 'HDR' values. You can specify a number below 0 to have bloom effect SDR values (not recommended)\",\n        default=1.0, min=0.0, soft_min=1.0)\n    bloomIntensity: FloatProperty(\n        name=\"Intensity\", description=\"Scales the intensity of the bloom effect\", default=1.0, min=0.0)\n    bloomRadius: FloatProperty(\n        name=\"Radius\", description=\"Spread distance of the bloom effect\", default=0.6, min=0.0, soft_max=1.0)\n    bloomSmoothing: FloatProperty(name=\"Smoothing\",\n                                  description=\"Makes transition between under/over-threshold more gradual.\",\n                                  default=0.025, min=0.0, soft_max=1.0)\n\n    def draw(self, context, layout, panel):\n        layout.prop(data=self, property=\"enableHDRPipeline\")\n\n        layout.prop(data=self, property=\"backgroundColor\")\n\n        row = layout.row(align=True)\n        sub_row = row.row(align=True)\n        sub_row.prop(data=self, property=\"backgroundTexture\")\n        if is_linked(context.scene):\n            # Manually disable the PointerProperty, needed for Blender 3.2+.\n            sub_row.enabled = False\n        if is_linked(self.backgroundTexture):\n            sub_row = row.row(align=True)\n            sub_row.enabled = False\n            add_link_indicator(sub_row, self.backgroundTexture)\n\n        row.context_pointer_set(\"target\", self)\n        row.context_pointer_set(\"host\", context.scene)\n        op = row.operator(\"image.hubs_open_image\", text='', icon='FILE_FOLDER')\n        op.target_property = \"backgroundTexture\"\n\n        row = layout.row(align=True)\n        sub_row = row.row(align=True)\n        sub_row.prop(data=self, property=\"envMapTexture\")\n\n        if is_linked(context.scene):\n            # Manually disable the PointerProperty, needed for Blender 3.2+.\n            sub_row.enabled = False\n        if is_linked(self.envMapTexture):\n            sub_row = row.row(align=True)\n            sub_row.enabled = False\n            add_link_indicator(sub_row, self.envMapTexture)\n\n        row.context_pointer_set(\"target\", self)\n        row.context_pointer_set(\"host\", context.scene)\n        op = row.operator(\"image.hubs_open_image\", text='', icon='FILE_FOLDER')\n        op.target_property = \"envMapTexture\"\n\n        layout.prop(data=self, property=\"toneMapping\")\n        layout.prop(data=self, property=\"toneMappingExposure\")\n\n        if self.enableHDRPipeline:\n            layout = layout.box()\n            top_row = layout.row()\n            top_row.prop(data=self, property=\"enableBloom\")\n            if self.enableBloom:\n                layout.prop(data=self, property=\"bloomThreshold\")\n                layout.prop(data=self, property=\"bloomIntensity\")\n                layout.prop(data=self, property=\"bloomRadius\")\n                layout.prop(data=self, property=\"bloomSmoothing\")\n\n    def gather(self, export_settings, object):\n        from ...io.utils import gather_texture_property, gather_color_property\n        output = {\n            'toneMapping': self.toneMapping,\n            'toneMappingExposure': self.toneMappingExposure,\n            'backgroundColor': gather_color_property(export_settings, object, self, 'backgroundColor', 'COLOR_GAMMA'),\n            'backgroundTexture': gather_texture_property(\n                export_settings,\n                object,\n                self,\n                'backgroundTexture'),\n            'envMapTexture': gather_texture_property(\n                export_settings,\n                object,\n                self,\n                'envMapTexture')\n\n        }\n\n        if self.enableHDRPipeline:\n            output[\"enableHDRPipeline\"] = True\n            if self.enableBloom:\n                output[\"enableBloom\"] = True\n                output[\"bloom\"] = {\n                    \"threshold\": self.bloomThreshold,\n                    \"intensity\": self.bloomIntensity,\n                    \"radius\": self.bloomRadius,\n                    \"smoothing\": self.bloomSmoothing,\n                }\n\n        return output\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        component = import_component(component_name, blender_host)\n        for property_name, property_value in component_value.items():\n            if property_name == \"bloom\":\n                for subproperty_name, subproperty_value in property_value.items():\n                    assign_property(gltf.vnodes, component,\n                                    f\"bloom{subproperty_name.capitalize()}\",\n                                    subproperty_value)\n            else:\n                assign_property(gltf.vnodes, component,\n                                property_name, property_value)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/fog.py",
    "content": "from bpy.props import FloatProperty, EnumProperty, FloatVectorProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass Fog(HubsComponent):\n    _definition = {\n        'name': 'fog',\n        'display_name': 'Fog',\n        'category': Category.SCENE,\n        'node_type': NodeType.SCENE,\n        'panel_type': [PanelType.SCENE],\n        'icon': 'MOD_OCEAN',\n        'version': (1, 0, 0)\n    }\n\n    def draw(self, context, layout, panel):\n        '''Draw method to be called by the panel.'''\n        layout.prop(data=self, property=\"type\")\n        layout.prop(data=self, property=\"color\")\n        if self.type == \"linear\":\n            layout.prop(data=self, property=\"near\")\n            layout.prop(data=self, property=\"far\")\n        else:\n            layout.prop(data=self, property=\"density\")\n\n    type: EnumProperty(\n        name=\"type\",\n        description=\"Fog Type\",\n        items=[(\"linear\", \"Linear fog\", \"Fog effect will increase linearly with distance\"),\n               (\"exponential\", \"Exponential fog\",\n                \"Fog effect will increase exponentially with distance\")],\n        default=\"linear\")\n\n    color: FloatVectorProperty(name=\"Color\",\n                               subtype='COLOR_GAMMA',\n                               default=(1.0, 1.0, 1.0, 1.0),\n                               size=4,\n                               min=0,\n                               max=1)\n\n    near: FloatProperty(\n        name=\"Near\", description=\"Fog Near Distance (linear only)\", default=1.0)\n\n    far: FloatProperty(\n        name=\"Far\", description=\"Fog Far Distance (linear only)\", default=100.0)\n\n    density: FloatProperty(\n        name=\"Density\", description=\"Fog Density (exponential only)\", default=0.00025)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/frustrum.py",
    "content": "from bpy.props import BoolProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass Frustrum(HubsComponent):\n    _definition = {\n        'name': 'frustrum',\n        'display_name': 'Frustum',\n        'category': Category.OBJECT,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT],\n        'icon': 'IMAGE_PLANE',\n        'version': (1, 0, 0)\n    }\n\n    culled: BoolProperty(\n        name=\"Culled\",\n        description=\"Ignore entities outside of the camera frustum. Frustum culling can cause problems with some animations\",\n        default=True)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/hemisphere_light.py",
    "content": "from bpy.props import FloatVectorProperty, FloatProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass HemisphereLight(HubsComponent):\n    _definition = {\n        'name': 'hemisphere-light',\n        'display_name': 'Hemisphere Light',\n        'category': Category.LIGHTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'LIGHT_AREA',\n        'version': (1, 0, 0)\n    }\n\n    skyColor: FloatVectorProperty(name=\"Sky Color\",\n                                  description=\"Sky Color\",\n                                  subtype='COLOR_GAMMA',\n                                  default=(1.0, 1.0, 1.0, 1.0),\n                                  size=4,\n                                  min=0,\n                                  max=1)\n\n    groundColor: FloatVectorProperty(name=\"Ground Color\",\n                                     description=\"Ground Color\",\n                                     subtype='COLOR_GAMMA',\n                                     default=(1.0, 1.0, 1.0, 1.0),\n                                     size=4,\n                                     min=0,\n                                     max=1)\n\n    intensity: FloatProperty(name=\"Intensity\",\n                             description=\"Intensity\",\n                             default=1.0)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/image.py",
    "content": "from ..models import image\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world\nfrom bpy.props import EnumProperty, FloatProperty, StringProperty, BoolProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ..consts import PROJECTION_MODE, TRANSPARENCY_MODE\nfrom .networked import migrate_networked\n\n\nclass Image(HubsComponent):\n    _definition = {\n        'name': 'image',\n        'display_name': 'Image',\n        'category': Category.MEDIA,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'FILE_IMAGE',\n        'deps': ['networked'],\n        'version': (1, 0, 0)\n    }\n\n    src: StringProperty(\n        name=\"Image URL\", description=\"The web address of the image\", default=\"https://example.org/ImageFile.webp\")\n\n    controls: BoolProperty(\n        name=\"Controls\",\n        description=\"When enabled, shows an \\\"open link\\\" button when hovering your cursor over it in Hubs that allows you to open the image in a new tab\",\n        default=True)\n\n    alphaMode: EnumProperty(\n        name=\"Transparency Mode\",\n        description=\"Transparency Mode\",\n        items=TRANSPARENCY_MODE,\n        default=\"opaque\")\n\n    alphaCutoff: FloatProperty(\n        name=\"Alpha Cutoff\",\n        description=\"Pixels with alpha values lower than this will be transparent on Binary transparency mode\",\n        default=0.5,\n        min=0.0,\n        max=1.0)\n\n    projection: EnumProperty(\n        name=\"Projection\",\n        description=\"Projection\",\n        items=PROJECTION_MODE,\n        default=\"flat\")\n\n    def draw(self, context, layout, panel_type):\n        layout.prop(self, \"src\")\n        layout.prop(self, \"controls\")\n        layout.prop(self, \"alphaMode\")\n        if self.alphaMode == \"mask\":\n            layout.prop(self, \"alphaCutoff\")\n        layout.prop(self, \"projection\")\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            migrate_networked(host)\n\n        return migration_occurred\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", image.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = (0.8, 0.8, 0.8)\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/link.py",
    "content": "from ..models import link\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world\nfrom bpy.props import StringProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom .networked import migrate_networked\n\n\nclass Link(HubsComponent):\n    _definition = {\n        'name': 'link',\n        'display_name': 'Link',\n        'category': Category.ELEMENTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'LINKED',\n        'deps': ['networked'],\n        'version': (1, 0, 0)\n    }\n\n    href: StringProperty(name=\"Link URL\", description=\"Link URL\",\n                         default=\"https://example.org\")\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            migrate_networked(host)\n\n        return migration_occurred\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", link.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = (0.8, 0.8, 0.8)\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/loop_animation.py",
    "content": "import bpy\nfrom bpy.app.handlers import persistent\nfrom bpy.props import StringProperty, CollectionProperty, IntProperty, EnumProperty, FloatProperty\nfrom bpy.types import PropertyGroup, Menu, Operator\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ...io.utils import import_component, assign_property\nfrom ..utils import redraw_component_ui, get_host_reference_message\nfrom ...utils import delayed_gather\n\nmsgbus_owners = []\n\n\nclass TrackPropertyType(PropertyGroup):\n    name: StringProperty(\n        name=\"Display Name\",\n        description=\"Display Name\",\n    )\n    track_name: StringProperty(  # Will only contain data if the track references an NLA track\n        name=\"Track Name\",\n        description=\"Track Name\",\n    )\n    strip_name: StringProperty(  # Will only contain data if the track references an NLA track and the NLA track name is generic\n        name=\"Strip Name\",\n        description=\"Strip Name\",\n    )\n    action_name: StringProperty(  # Will only contain data if the NLA track name is generic or the track references an action\n        name=\"Action Name\",\n        description=\"Action Name\",\n    )\n    track_type: EnumProperty(\n        name=\"Track Type\",\n        description=\"Track Type\",\n        items=[\n            (\"object\", \"Object\", \"Object\"),\n            (\"shape_key\", \"Shape Key\", \"Shape Key\")\n        ],\n        default=\"object\"\n    )\n\n\nclass Errors():\n    _errors = {}\n\n    @classmethod\n    def log(cls, track, error_type, error_message, severity='Error'):\n        has_error = cls._errors.get(track.track_type + track.name, '')\n        if not has_error:\n            cls._errors[track.track_type + track.name] = {\n                'type': error_type, 'message': error_message, 'severity': severity}\n\n    @classmethod\n    def get(cls, track):\n        return cls._errors.get(track.track_type + track.name, '')\n\n    @classmethod\n    def clear(cls):\n        cls._errors.clear()\n\n    @classmethod\n    def are_present(cls):\n        return bool(cls._errors)\n\n    @classmethod\n    def display_error(cls, layout, error):\n        message_lines = error['message'].split('\\n')\n        padding = layout.row(align=False)\n        padding.scale_y = 0.18\n        padding.label()\n        for i, line in enumerate(message_lines):\n            error_row = layout.row(align=False)\n            error_row.scale_y = 0.7\n\n            if i == 0:\n                error_row.label(\n                    text=f\"{error['severity']}: {line}\", icon='ERROR')\n            else:\n                error_row.label(text=line, icon='BLANK1')\n\n        padding = layout.row(align=False)\n        padding.scale_y = 0.2\n        padding.label()\n\n\ndef register_msgbus():\n    global msgbus_owners\n\n    if msgbus_owners:\n        return\n\n    for animtype in [bpy.types.NlaTrack, bpy.types.NlaStrip, bpy.types.Action]:\n        owner = object()\n        msgbus_owners.append(owner)\n        bpy.msgbus.subscribe_rna(\n            key=(animtype, \"name\"),\n            owner=owner,\n            args=(bpy.context,),\n            notify=redraw_component_ui,\n        )\n\n\ndef unregister_msgbus():\n    global msgbus_owners\n\n    for owner in msgbus_owners:\n        bpy.msgbus.clear_by_owner(owner)\n    msgbus_owners.clear()\n\n\n@persistent\ndef load_post(dummy):\n    unregister_msgbus()\n    register_msgbus()\n\n\n@persistent\ndef undo_redo_post(dummy):\n    unregister_msgbus()\n    register_msgbus()\n\n\ndef is_default_name(track_name):\n    return bool(track_name.startswith(\"NlaTrack\") or track_name.startswith(\"[Action Stash]\"))\n\n\ndef get_display_name(track_name, strip_name):\n    return track_name if not is_default_name(track_name) else f\"{track_name} ({strip_name})\"\n\n\ndef get_strip_name(nla_track):\n    try:\n        return nla_track.strips[0].name\n    except IndexError:\n        return ''\n\n\ndef get_action_name(nla_track):\n    try:\n        return nla_track.strips[0].action.name\n    except (IndexError, AttributeError):\n        return ''\n\n\ndef get_menu_id(nla_track, track_type, display_name):\n    return display_name if not is_default_name(nla_track.name) else track_type + display_name\n\n\ndef is_unique_action(animation_data, target_nla_track):\n    try:\n        target_action = target_nla_track.strips[0].action\n    except (IndexError):\n        return True\n\n    for nla_track in animation_data.nla_tracks:\n        if nla_track == target_nla_track:\n            continue\n\n        try:\n            action = nla_track.strips[0].action\n        except (IndexError):\n            continue\n\n        if action == target_action:\n            return False\n\n    return True\n\n\ndef has_track(tracks_list, nla_track, invalid_track=None):\n    strip_name = get_strip_name(nla_track)\n    action_name = get_action_name(nla_track)\n    exists = False\n    for track in tracks_list:\n        if is_default_name(nla_track.name):\n            if track.track_name == nla_track.name and track.strip_name == strip_name and track.action_name == action_name:\n                exists = True\n                break\n\n        else:\n            if track.track_name == nla_track.name and track != invalid_track:\n                exists = True\n                break\n\n    return exists\n\n\ndef has_action(tracks_list, action, invalid_action=None):\n    exists = False\n    for track in tracks_list:\n        if track.name == action.name and track != invalid_action:\n            exists = True\n            break\n\n    return exists\n\n\ndef action_has_nla_track(ob, action):\n    nla_tracks_with_action = []\n    for nla_track in ob.animation_data.nla_tracks:\n        track_action_name = get_action_name(nla_track)\n        if track_action_name == action.name:\n            nla_tracks_with_action.append(nla_track.name)\n    if hasattr(ob.data, 'shape_keys') and ob.data.shape_keys and ob.data.shape_keys.animation_data:\n        for nla_track in ob.data.shape_keys.animation_data.nla_tracks:\n            track_action_name = get_action_name(nla_track)\n            if track_action_name == action.name:\n                nla_tracks_with_action.append(nla_track.name)\n    return any(nla_tracks_with_action)\n\n\ndef is_matching_track(nla_track_type, nla_track, track):\n    if nla_track_type != track.track_type:\n        return False\n\n    if is_default_name(nla_track.name):\n        if nla_track.name == track.track_name:\n            if get_strip_name(nla_track) == track.strip_name:\n                if get_action_name(nla_track) == track.action_name:\n                    return True\n\n                Errors.log(track, 'INVALID_ACTION',\n                           \"The action has changed for this strip/track.\\nChoose the track again to update.\")\n\n    else:\n        if nla_track.name == track.track_name:\n            return True\n\n    return False\n\n\ndef is_useable_nla_track(animation_data, nla_track, track):\n    # Error checking is handled from top level to bottom level, if something isn't present an error is logged and we return early.  This way we always know that the expected constructs are present, e.g. we verify X is valid, then all checks for properties of X are conducted afterwards and we know they won't crash.\n    track_name = nla_track.name\n    action_name = get_action_name(nla_track)\n\n    if track_name == '':\n        Errors.log(track, 'FORBIDDEN_NAME', \"Track names can't be nothing.\")\n        return False\n\n    forbidden_chars = [\",\", \" \"]\n    if not is_default_name(track_name):\n        if any([c for c in forbidden_chars if c in track_name]):\n            Errors.log(track, 'FORBIDDEN_NAME',\n                       \"Custom track names can't contain commas or spaces.\")\n            return False\n\n    else:\n        if any([c for c in forbidden_chars if c in action_name]):\n            Errors.log(track, 'FORBIDDEN_NAME',\n                       \"Action names can't contain commas or spaces.\")\n            return False\n\n    if not nla_track.strips:\n        Errors.log(track, 'NO_NLA_TRACK_STRIPS', \"No strips are present in the NLA track.\")\n        return False\n\n    if len(nla_track.strips) > 1:\n        Errors.log(track, 'MULTIPLE_NLA_TRACK_STRIPS',\n                   \"Only one strip is allowed in the NLA track.\")\n        return False\n\n    if nla_track.strips[0].mute:\n        Errors.log(track, 'MUTED_NLA_TRACK_STRIP',\n                   \"The NLA track strip is muted and won't export.\")\n        return False\n\n    if not action_name:\n        Errors.log(track, 'NO_ACTION',\n                   \"The NLA track strip doesn't have an action.\")\n        return False\n\n    action = nla_track.strips[0].action\n    nla_track_fcurves = None\n    if bpy.app.version >= (4, 4, 0):\n        if not action.slots:\n            Errors.log(track, 'NO_ACTION_SLOTS', \"No slots are present in the action.\")\n            return False\n\n        if not nla_track.strips[0].action_slot:\n            Errors.log(track, 'NO_ACTION_SLOT_IN_STRIP', \"No action slot has been selected for the NLA track strip.\")\n            return False\n\n        if not action.layers:\n            # Action layers aren't exposed in anything but the Python API as of Blender 5.0\n            Errors.log(track, 'NO_ACTION_LAYERS',\n                       \"The action doesn't have any layers.\\nDid you forget to add any keyframes to the action?\")\n            return False\n\n        if not action.layers[0].strips:\n            # Action strips aren't exposed in anything but the Python API as of Blender 5.0\n            Errors.log(track, 'NO_ACTION_STRIPS', \"No strips are present in the action layer.\")\n            return False\n\n        channelbag = action.layers[0].strips[0].channelbag(nla_track.strips[0].action_slot)\n        if channelbag:\n            nla_track_fcurves = channelbag.fcurves\n    else:\n        nla_track_fcurves = action.fcurves\n\n    if not nla_track_fcurves:\n        if bpy.app.version >= (4, 4, 0):\n            Errors.log(\n                track, 'NO_FCURVES',\n                \"The NLA track strip's action doesn't have any animation in\\nthe active slot and won't be exported.\")\n        else:\n            Errors.log(track, 'NO_FCURVES',\n                       \"The NLA track strip's action doesn't have any animation and\\nwon't be exported.\")\n        return False\n\n    if not is_unique_action(animation_data, nla_track):\n        Errors.log(\n            track, 'NON_UNIQUE_ACTION',\n            \"The NLA track strip contains an action that is present within\\nmultiple NLA tracks on this object and may not export correctly.\",\n            severity=\"Warning\")\n        return False\n\n    return True\n\n\ndef is_usable_action(ob, track):\n    action_name = track.name\n    action = ob.animation_data.action\n    action_fcurves = None\n\n    if action_name == '':\n        Errors.log(track, 'FORBIDDEN_NAME', \"Action names can't be nothing.\")\n        return False\n\n    forbidden_chars = [\",\", \" \"]\n    if any([c for c in forbidden_chars if c in action_name]):\n        Errors.log(track, 'FORBIDDEN_NAME', \"Custom action names can't contain commas or spaces.\")\n        return False\n\n    if bpy.app.version >= (4, 4, 0):\n        if not action.slots:\n            Errors.log(track, 'NO_ACTION_SLOTS', \"No slots are present in the action.\")\n            return False\n\n        if not action.layers:\n            # Action layers aren't exposed in anything but the Python API as of Blender 5.0\n            Errors.log(track, 'NO_ACTION_LAYERS',\n                       \"The action doesn't have any layers.\\nDid you forget to add any keyframes to the action?\")\n            return False\n\n        if not action.layers[0].strips:\n            # Action strips aren't exposed in anything but the Python API as of Blender 5.0\n            Errors.log(track, 'NO_ACTION_STRIPS', \"No strips are present in the action layer.\")\n            return False\n\n        try:\n            active_slot = [slot for slot in action.slots if ob in slot.users()][0]\n            channelbag = action.layers[0].strips[0].channelbag(active_slot)\n            if channelbag:\n                action_fcurves = channelbag.fcurves\n        except IndexError:\n            Errors.log(track, 'NO_ACTIVE_ACTION_SLOT', \"No active slot is present in the action.\")\n            return False\n    else:\n        action_fcurves = action.fcurves\n\n    if not action_fcurves:\n        if bpy.app.version >= (4, 4, 0):\n            Errors.log(track, 'NO_FCURVES',\n                       \"The action doesn't have any animation in\\nthe active slot and won't be exported.\")\n        else:\n            Errors.log(track, 'NO_FCURVES',\n                       \"The action doesn't have any animation and\\nwon't be exported.\")\n        return False\n\n    return True\n\n\ndef is_valid_regular_action(ob, track):\n    if ob.animation_data and ob.animation_data.action and is_usable_action(ob, track):\n        action = ob.animation_data.action\n        return not action_has_nla_track(ob, action) and track.name == action.name\n    return False\n\n\ndef is_valid_regular_nla_track(ob, track):\n    if ob.animation_data:\n        for nla_track in ob.animation_data.nla_tracks:\n            if is_matching_track(\"object\", nla_track, track):\n                return is_useable_nla_track(ob.animation_data, nla_track, track)\n    return False\n\n\ndef is_valid_regular_track(ob, track):\n    if is_valid_regular_nla_track(ob, track):\n        return True\n\n    elif is_valid_regular_action(ob, track):\n        return True\n\n    Errors.log(track, 'NOT_FOUND', \"Track not found.  Did you mean:\")\n\n    return False\n\n\ndef is_valid_shape_key_action(ob, track):\n    if hasattr(ob.data, 'shape_keys') and ob.data.shape_keys and ob.data.shape_keys.animation_data.action:\n        if is_usable_action(track):\n            action = ob.data.shape_keys.animation_data.action\n            return not action_has_nla_track(ob, action) and track.name == action.name\n    return False\n\n\ndef is_valid_shape_key_nla_track(ob, track):\n    if hasattr(ob.data, 'shape_keys') and ob.data.shape_keys and ob.data.shape_keys.animation_data:\n        for nla_track in ob.data.shape_keys.animation_data.nla_tracks:\n            if is_matching_track(\"shape_key\", nla_track, track):\n                return is_useable_nla_track(ob.data.shape_keys.animation_data, nla_track, track)\n    return False\n\n\ndef is_valid_shape_key_track(ob, track):\n    if is_valid_shape_key_nla_track(ob, track):\n        return True\n\n    elif is_valid_shape_key_action(ob, track):\n        return True\n\n    Errors.log(track, 'NOT_FOUND', \"Track not found.  Did you mean:\")\n\n    return False\n\n\ndef get_animation_name(ob, track, export_settings):\n    if is_valid_regular_action(ob, track) or is_valid_shape_key_action(ob, track):\n        return track.name\n    elif is_valid_regular_nla_track(ob, track) or is_valid_shape_key_nla_track(ob, track):\n        if bpy.app.version >= (4, 4, 0) and export_settings['gltf_animation_mode'] == 'ACTIONS':\n            nla_track = ob.animation_data.nla_tracks.get(track.track_name)\n            return nla_track.strips[0].action.name\n        else:\n            return track.track_name if not is_default_name(\n                track.track_name) else track.action_name\n    else:\n        return track.name\n\n\ndef import_tracks(tracks, ob, component):\n    for track_name in tracks:\n        try:\n            nla_track = ob.animation_data.nla_tracks[track_name]\n            track_type = \"object\"\n        except (AttributeError, KeyError):\n            try:\n                nla_track = ob.data.shape_keys.animation_data.nla_tracks[track_name]\n                track_type = \"shape_key\"\n            except (AttributeError, KeyError):\n                track = component.tracks_list.add()\n                track.name = track_name\n                continue\n\n        if not has_track(component.tracks_list, nla_track):\n            track = component.tracks_list.add()\n            strip_name = get_strip_name(nla_track)\n            action_name = get_action_name(nla_track)\n            track.name = get_display_name(\n                nla_track.name, strip_name)\n            track.track_name = nla_track.name\n            track.strip_name = strip_name if is_default_name(\n                nla_track.name) else ''\n            track.action_name = action_name if is_default_name(\n                nla_track.name) else ''\n            track.track_type = track_type\n\n\nclass TracksList(bpy.types.UIList):\n    bl_idname = \"HUBS_UL_TRACKS_list\"\n\n    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):\n        key_block = item\n        ob = context.object\n        if self.layout_type in {'DEFAULT', 'COMPACT'}:\n            split = layout.split(factor=0.90, align=False)\n            if item.track_type == \"object\" and is_valid_regular_track(ob, item):\n                split.prop(key_block, \"name\", text=\"\",\n                           emboss=False, icon='OBJECT_DATA')\n                split.enabled = False\n            elif item.track_type == \"shape_key\" and is_valid_shape_key_track(ob, item):\n                split.prop(key_block, \"name\", text=\"\",\n                           emboss=False, icon='SHAPEKEY_DATA')\n                split.enabled = False\n            else:\n                spacer = '  '  # needed so the menu arrow doesn't intersect with the name\n                row = split.row(align=False)\n                row.emboss = 'NONE'\n                row.alignment = 'LEFT'\n                row.context_pointer_set('hubs_component', data)\n                row.context_pointer_set('track', item)\n                row.menu(UpdateTrackContextMenu.bl_idname,\n                         text=item.name + spacer, icon='ERROR')\n            row = split.row(align=True)\n            row.emboss = 'UI_EMBOSS_NONE_OR_STATUS' if bpy.app.version < (\n                3, 0, 0) else 'NONE_OR_STATUS'\n        elif self.layout_type == 'GRID':\n            layout.alignment = 'CENTER'\n            layout.label(text=\"\", icon_value=icon)\n\n\nclass UpdateTrack(Operator):\n    bl_idname = \"hubs_loop_animation.update_track\"\n    bl_label = \"Update the track with a new NLA Track\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    name: StringProperty(\n        name=\"Display Name\", description=\"Display Name\", default=\"\")\n\n    track_name: StringProperty(\n        name=\"Track Name\", description=\"Track Name\", default=\"\")\n\n    strip_name: StringProperty(\n        name=\"Strip Name\", description=\"Strip Name\", default=\"\")\n\n    action_name: StringProperty(\n        name=\"Action Name\", description=\"Action Name\", default=\"\")\n\n    track_type: StringProperty(\n        name=\"Track Type\", description=\"Track Type\", default=\"\")\n\n    def execute(self, context):\n        track = context.track\n        track.name = self.name\n        track.track_name = self.track_name\n        track.strip_name = self.strip_name\n        track.action_name = self.action_name\n        track.track_type = self.track_type\n\n        redraw_component_ui(context)\n        return {'FINISHED'}\n\n\nclass AddTrackOperator(Operator):\n    bl_idname = \"hubs_loop_animation.add_track\"\n    bl_label = \"Add Track\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    name: StringProperty(\n        name=\"Display Name\", description=\"Display Name\", default=\"\")\n\n    track_name: StringProperty(\n        name=\"Track Name\", description=\"Track Name\", default=\"\")\n\n    strip_name: StringProperty(\n        name=\"Strip Name\", description=\"Strip Name\", default=\"\")\n\n    action_name: StringProperty(\n        name=\"Action Name\", description=\"Action Name\", default=\"\")\n\n    track_type: StringProperty(\n        name=\"Track Type\", description=\"Track Type\", default=\"\")\n\n    panel_type: StringProperty(name=\"panel_type\")\n\n    def execute(self, context):\n        panel_type = PanelType(self.panel_type)\n        ob = context.object\n        host = ob if panel_type == PanelType.OBJECT else context.active_bone\n\n        track = host.hubs_component_loop_animation.tracks_list.add()\n        track.name = self.name\n        track.track_name = self.track_name\n        track.strip_name = self.strip_name\n        track.action_name = self.action_name\n        track.track_type = self.track_type\n\n        num_tracks = len(host.hubs_component_loop_animation.tracks_list)\n        host.hubs_component_loop_animation.active_track_key = num_tracks - 1\n\n        redraw_component_ui(context)\n\n        return {'FINISHED'}\n\n    def invoke(self, context, event):\n        return self.execute(context)\n\n\nclass RemoveTrackOperator(Operator):\n    bl_idname = \"hubs_loop_animation.remove_track\"\n    bl_label = \"Remove Track\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context):\n        if hasattr(context, \"panel\"):\n            panel_type = PanelType(context.panel.bl_context)\n            ob = context.object\n            host = ob if panel_type == PanelType.OBJECT else context.active_bone\n\n            return host.hubs_component_loop_animation.active_track_key != -1\n\n        return True\n\n    def execute(self, context):\n        panel_type = PanelType(context.panel.bl_context)\n        ob = context.object\n        host = ob if panel_type == PanelType.OBJECT else context.active_bone\n\n        active_track_key = host.hubs_component_loop_animation.active_track_key\n        host.hubs_component_loop_animation.tracks_list.remove(\n            active_track_key)\n\n        if host.hubs_component_loop_animation.active_track_key != 0:\n            host.hubs_component_loop_animation.active_track_key -= 1\n\n        if len(host.hubs_component_loop_animation.tracks_list) == 0:\n            host.hubs_component_loop_animation.active_track_key = -1\n\n        redraw_component_ui(context)\n\n        return {'FINISHED'}\n\n\nclass UpdateTrackContextMenu(Menu):\n    bl_idname = \"HUBS_MT_TRACKS_update_track_context_menu\"\n    bl_label = \"Update Track\"\n\n    def draw(self, context):\n        track = context.track\n        hubs_component = context.hubs_component\n        layout = self.layout\n        no_tracks = True\n        menu_tracks = []\n        ob = context.object\n\n        error = Errors.get(track)\n        if error:\n            Errors.display_error(layout, error)\n            if error['type'] not in ['NOT_FOUND', 'INVALID_ACTION']:\n                return\n\n            layout.separator()\n\n        if ob.animation_data:\n            for _, nla_track in enumerate(ob.animation_data.nla_tracks):\n                strip_name = get_strip_name(nla_track)\n                action_name = get_action_name(nla_track)\n                display_name = get_display_name(nla_track.name, strip_name)\n                track_type = \"object\"\n                menu_id = get_menu_id(nla_track, track_type, display_name)\n\n                if menu_id not in menu_tracks and not has_track(\n                        hubs_component.tracks_list, nla_track, invalid_track=track):\n                    row = layout.row(align=False)\n                    row.context_pointer_set('track', track)\n\n                    update_track = row.operator(UpdateTrack.bl_idname,\n                                                icon='OBJECT_DATA', text=display_name)\n                    update_track.name = display_name\n                    update_track.track_name = nla_track.name\n                    update_track.strip_name = strip_name if is_default_name(\n                        nla_track.name) else ''\n                    update_track.action_name = action_name if is_default_name(\n                        nla_track.name) else ''\n                    update_track.track_type = track_type\n\n                    no_tracks = False\n                    menu_tracks.append(menu_id)\n\n            if ob.animation_data.action:\n                action = ob.animation_data.action\n                action_name = action.name\n                track_type = \"object\"\n                menu_id = action_name\n\n                if menu_id not in menu_tracks and not action_has_nla_track(ob, action) and not has_action(\n                        hubs_component.tracks_list, action, invalid_action=action):\n                    row = layout.row(align=False)\n                    row.context_pointer_set('track', track)\n                    update_track = row.operator(UpdateTrack.bl_idname,\n                                                icon='OBJECT_DATA', text=action_name)\n                    update_track.name = action_name\n                    update_track.action_name = action_name\n                    update_track.track_type = track_type\n\n                    no_tracks = False\n                    menu_tracks.append(menu_id)\n\n        if hasattr(ob.data, 'shape_keys') and ob.data.shape_keys and ob.data.shape_keys.animation_data:\n            for _, nla_track in enumerate(ob.data.shape_keys.animation_data.nla_tracks):\n                strip_name = get_strip_name(nla_track)\n                action_name = get_action_name(nla_track)\n                display_name = get_display_name(nla_track.name, strip_name)\n                track_type = \"shape_key\"\n                menu_id = get_menu_id(nla_track, track_type, display_name)\n\n                if menu_id not in menu_tracks and not has_track(\n                        hubs_component.tracks_list, nla_track, invalid_track=track):\n                    row = layout.row(align=False)\n                    row.context_pointer_set('track', track)\n\n                    update_track = row.operator(UpdateTrack.bl_idname,\n                                                icon='SHAPEKEY_DATA', text=display_name)\n                    update_track.name = display_name\n                    update_track.track_name = nla_track.name\n                    update_track.strip_name = strip_name if is_default_name(\n                        nla_track.name) else ''\n                    update_track.action_name = action_name if is_default_name(\n                        nla_track.name) else ''\n                    update_track.track_type = track_type\n\n                    no_tracks = False\n                    menu_tracks.append(menu_id)\n\n            if ob.data.shape_keys.animation_data.action:\n                action = ob.data.shape_keys.animation_data.action\n                action_name = action.name\n                track_type = \"shape_key\"\n                menu_id = action_name\n\n                if menu_id not in menu_tracks and not action_has_nla_track(ob, action) and not has_action(\n                        hubs_component.tracks_list, action, invalid_action=action):\n                    row = layout.row(align=False)\n                    row.context_pointer_set('track', track)\n                    update_track = row.operator(UpdateTrack.bl_idname,\n                                                icon='SHAPEKEY_DATA', text=action_name)\n                    update_track.name = action_name\n                    update_track.action_name = action_name\n                    update_track.track_type = track_type\n\n                    no_tracks = False\n                    menu_tracks.append(menu_id)\n\n        if no_tracks:\n            layout.label(text=\"No tracks found\")\n\n\nclass TracksContextMenu(Menu):\n    bl_idname = \"HUBS_MT_TRACKS_context_menu\"\n    bl_label = \"Add Track\"\n\n    def draw(self, context):\n        panel_type = PanelType(context.panel.bl_context)\n        layout = self.layout\n        no_tracks = True\n        menu_tracks = []\n        ob = context.object\n        host = ob if panel_type == PanelType.OBJECT else context.active_bone\n        component_tracks_list = host.hubs_component_loop_animation.tracks_list\n\n        if ob.animation_data:\n            for _, nla_track in enumerate(ob.animation_data.nla_tracks):\n                strip_name = get_strip_name(nla_track)\n                action_name = get_action_name(nla_track)\n                display_name = get_display_name(nla_track.name, strip_name)\n                track_type = \"object\"\n                menu_id = get_menu_id(nla_track, track_type, display_name)\n\n                if menu_id not in menu_tracks and not has_track(component_tracks_list, nla_track):\n                    add_track = layout.operator(AddTrackOperator.bl_idname,\n                                                icon='OBJECT_DATA', text=display_name)\n                    add_track.name = display_name\n                    add_track.track_name = nla_track.name\n                    add_track.strip_name = strip_name if is_default_name(\n                        nla_track.name) else ''\n                    add_track.action_name = action_name if is_default_name(\n                        nla_track.name) else ''\n                    add_track.track_type = track_type\n                    add_track.panel_type = panel_type.value\n\n                    no_tracks = False\n                    menu_tracks.append(menu_id)\n\n            if ob.animation_data.action:\n                action = ob.animation_data.action\n                action_name = action.name\n                menu_id = action_name\n                track_type = \"object\"\n\n                if menu_id not in menu_tracks and not action_has_nla_track(\n                        ob, action) and not has_action(\n                        component_tracks_list, action):\n                    add_track = layout.operator(AddTrackOperator.bl_idname,\n                                                icon='OBJECT_DATA', text=action_name)\n                    add_track.name = action_name\n                    add_track.action_name = action_name\n                    add_track.track_type = track_type\n                    add_track.panel_type = panel_type.value\n\n                    no_tracks = False\n                    menu_tracks.append(menu_id)\n\n        if hasattr(ob.data, 'shape_keys') and ob.data.shape_keys and ob.data.shape_keys.animation_data:\n            for _, nla_track in enumerate(ob.data.shape_keys.animation_data.nla_tracks):\n                strip_name = get_strip_name(nla_track)\n                action_name = get_action_name(nla_track)\n                display_name = get_display_name(nla_track.name, strip_name)\n                track_type = \"shape_key\"\n                menu_id = get_menu_id(nla_track, track_type, display_name)\n\n                if menu_id not in menu_tracks and not has_track(component_tracks_list, nla_track):\n                    add_track = layout.operator(AddTrackOperator.bl_idname,\n                                                icon='SHAPEKEY_DATA', text=display_name)\n                    add_track.name = display_name\n                    add_track.track_name = nla_track.name\n                    add_track.strip_name = strip_name if is_default_name(\n                        nla_track.name) else ''\n                    add_track.action_name = action_name if is_default_name(\n                        nla_track.name) else ''\n                    add_track.track_type = track_type\n                    add_track.panel_type = panel_type.value\n\n                    no_tracks = False\n                    menu_tracks.append(menu_id)\n\n            if ob.data.shape_keys.animation_data.action:\n                action = ob.data.shape_keys.animation_data.action\n                action_name = action.name\n                menu_id = action_name\n                track_type = \"shape_key\"\n\n                if menu_id not in menu_tracks and not action_has_nla_track(\n                        ob, action) and not has_action(\n                        component_tracks_list, action):\n                    add_track = layout.operator(AddTrackOperator.bl_idname,\n                                                icon='SHAPEKEY_DATA', text=action_name)\n                    add_track.name = action_name\n                    add_track.action_name = action_name\n                    add_track.track_type = track_type\n                    add_track.panel_type = panel_type.value\n\n                    no_tracks = False\n                    menu_tracks.append(menu_id)\n\n        if no_tracks:\n            layout.label(text=\"No tracks found\")\n\n\nclass LoopAnimation(HubsComponent):\n    _definition = {\n        'name': 'loop-animation',\n        'display_name': 'Loop Animation',\n        'category': Category.ANIMATION,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'LOOP_BACK',\n        'version': (1, 1, 0)\n    }\n\n    tracks_list: CollectionProperty(\n        type=TrackPropertyType)\n\n    clip: StringProperty(\n        name=\"Animation Clip\",\n        description=\"Animation clip to use\",\n        default=\"\"\n    )\n\n    active_track_key: IntProperty(\n        name=\"Active track index\",\n        description=\"Active track index\",\n        default=-1\n    )\n\n    startOffset: IntProperty(\n        name=\"Start Offset\",\n        description=\"Time in frames to skip on the first loop of the animation\",\n        default=0\n    )\n\n    timeScale: FloatProperty(\n        name=\"Time Scale\",\n        description=\"Scale animation playback speed by this factor. Normal playback rate being 1. Negative values will play the animation backwards\",\n        default=1.0\n    )\n\n    def draw(self, context, layout, panel):\n        Errors.clear()\n\n        layout.prop(data=self, property=\"startOffset\")\n        layout.prop(data=self, property=\"timeScale\")\n\n        layout.label(text='Animations to play:')\n\n        row = layout.row()\n        row.template_list(TracksList.bl_idname, \"\", self,\n                          \"tracks_list\", self, \"active_track_key\", rows=3)\n\n        col = row.column(align=True)\n\n        col.context_pointer_set('panel', panel)\n        col.menu(TracksContextMenu.bl_idname, icon='ADD', text=\"\")\n        col.operator(RemoveTrackOperator.bl_idname,\n                     icon='REMOVE', text=\"\")\n\n        if Errors.are_present():\n            error_row = layout.row()\n            error_row.alert = True\n            error_row.label(text=\"Errors detected, click on the flagged tracks for more information.\",\n                            icon='ERROR')\n\n        layout.separator()\n\n    def gather(self, export_settings, object):\n        final_track_names = []\n        for track in object.hubs_component_loop_animation.tracks_list.values():\n            final_track_names.append(get_animation_name(object, track, export_settings))\n\n        fps = bpy.context.scene.render.fps / bpy.context.scene.render.fps_base\n\n        return {\n            'clip': \",\".join(\n                final_track_names),\n            'startOffset': self.startOffset / fps,\n            'timeScale': self.timeScale\n        }\n\n    @staticmethod\n    def register():\n        bpy.utils.register_class(TracksList)\n        bpy.utils.register_class(UpdateTrackContextMenu)\n        bpy.utils.register_class(TracksContextMenu)\n        bpy.utils.register_class(UpdateTrack)\n        bpy.utils.register_class(AddTrackOperator)\n        bpy.utils.register_class(RemoveTrackOperator)\n\n        if load_post not in bpy.app.handlers.load_post:\n            bpy.app.handlers.load_post.append(load_post)\n        if undo_redo_post not in bpy.app.handlers.undo_post:\n            bpy.app.handlers.undo_post.append(undo_redo_post)\n        if undo_redo_post not in bpy.app.handlers.redo_post:\n            bpy.app.handlers.redo_post.append(undo_redo_post)\n\n        register_msgbus()\n\n    @staticmethod\n    def unregister():\n        bpy.utils.unregister_class(TracksList)\n        bpy.utils.unregister_class(UpdateTrackContextMenu)\n        bpy.utils.unregister_class(TracksContextMenu)\n        bpy.utils.unregister_class(UpdateTrack)\n        bpy.utils.unregister_class(AddTrackOperator)\n        bpy.utils.unregister_class(RemoveTrackOperator)\n\n        if load_post in bpy.app.handlers.load_post:\n            bpy.app.handlers.load_post.remove(load_post)\n        if undo_redo_post in bpy.app.handlers.undo_post:\n            bpy.app.handlers.undo_post.remove(undo_redo_post)\n        if undo_redo_post in bpy.app.handlers.redo_post:\n            bpy.app.handlers.redo_post.remove(undo_redo_post)\n\n        unregister_msgbus()\n\n    @classmethod\n    @delayed_gather\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        blender_component = import_component(\n            component_name, blender_host)\n\n        for property_name, property_value in component_value.items():\n            if property_name == 'clip' and property_value != \"\":\n                tracks = property_value.split(\",\")\n                import_tracks(tracks, blender_ob, blender_component)\n            else:\n                if property_name == 'startOffset':\n                    fps = bpy.context.scene.render.fps / bpy.context.scene.render.fps_base\n                    property_value = round(property_value * fps)\n\n                assign_property(gltf.vnodes, blender_component,\n                                property_name, property_value)\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            migration_warning = False\n            tracks = self.clip.split(\",\")\n            for track_name in tracks:\n                nla_track = None\n                action = None\n\n                # check regular\n                try:\n                    nla_track = ob.animation_data.nla_tracks[track_name]\n                    track_type = \"object\"\n                except (AttributeError, KeyError):\n                    try:\n                        action = ob.animation_data.action\n                        if not action_has_nla_track(ob, action) and track_name == action.name:\n                            track_type = \"object\"\n                        else:\n                            raise KeyError\n                    except (AttributeError, KeyError):\n                        action = None\n\n                if not (nla_track or action):\n                    # check shapekey\n                    try:\n                        nla_track = ob.data.shape_keys.animation_data.nla_tracks[track_name]\n                        track_type = \"shape_key\"\n                    except (AttributeError, KeyError):\n                        try:\n                            action = ob.data.shape_keys.animation_data.action\n                            if not action_has_nla_track(ob, action) and track_name == action.name:\n                                track_type = \"shape_key\"\n                            else:\n                                raise KeyError\n                        except (AttributeError, KeyError):\n                            action = None\n\n                if not (nla_track or action):\n                    # nothing found\n                    track = self.tracks_list.add()\n                    track.name = track_name\n                    migration_warning = True\n                    continue\n\n                if nla_track:\n                    if not has_track(self.tracks_list, nla_track):\n                        track = self.tracks_list.add()\n                        strip_name = get_strip_name(nla_track)\n                        action_name = get_action_name(nla_track)\n                        track.name = get_display_name(nla_track.name, strip_name)\n                        track.track_name = nla_track.name\n                        track.strip_name = strip_name if is_default_name(nla_track.name) else ''\n                        track.action_name = action_name if is_default_name(nla_track.name) else ''\n                        track.track_type = track_type\n\n                elif action:\n                    if not has_action(self.tracks_list, action):\n                        track = self.tracks_list.add()\n                        track.name = action.name\n                        track.track_name = ''\n                        track.strip_name = ''\n                        track.action_name = action.name\n                        track.track_type = track_type\n\n            if migration_warning:\n                host_reference = get_host_reference_message(panel_type, host, ob=ob)\n                migration_report.append(\n                    f\"Warning: The Loop Animation component on the {panel_type.value} {host_reference} may not have migrated correctly\")\n\n        return migration_occurred\n\n\ndef register_module():\n    bpy.utils.register_class(TrackPropertyType)\n\n\ndef unregister_module():\n    bpy.utils.unregister_class(TrackPropertyType)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/media_frame.py",
    "content": "import bpy\nfrom bpy.props import EnumProperty, FloatVectorProperty, BoolProperty\nfrom bpy.types import (Gizmo, Bone, EditBone)\nfrom ..gizmos import bone_matrix_world\nfrom ..models import box\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType, MigrationType\nfrom ..utils import get_host_or_parents_scaled, is_linked, get_host_reference_message\nfrom .networked import migrate_networked\nfrom mathutils import Matrix, Vector\nfrom ...io.utils import import_component, assign_property\n\n\ndef is_bone(ob):\n    return type(ob) is EditBone or type(ob) is Bone\n\n\nclass MediaFrameGizmo(Gizmo):\n    \"\"\"MediaFrame gizmo\"\"\"\n    bl_idname = \"GIZMO_GT_hba_mediaframe_gizmo\"\n    bl_target_properties = (\n        {\"id\": \"bounds\", \"type\": 'FLOAT', \"array_length\": 3},\n    )\n\n    __slots__ = (\n        \"hubs_gizmo_shape\",\n        \"custom_shape\",\n    )\n\n    def _update_offset_matrix(self):\n        loc, rot, _ = self.matrix_basis.decompose()\n        scale = self.target_get_value(\"bounds\")\n        mat_out = Matrix.Translation(\n            loc) @ rot.normalized().to_matrix().to_4x4() @ Matrix.Diagonal(scale).to_4x4()\n        self.matrix_basis = mat_out\n\n    def draw(self, context):\n        self._update_offset_matrix()\n        self.draw_custom_shape(self.custom_shape)\n\n    def draw_select(self, context, select_id):\n        self._update_offset_matrix()\n        self.draw_custom_shape(self.custom_shape, select_id=select_id)\n\n    def setup(self):\n        if hasattr(self, \"hubs_gizmo_shape\"):\n            self.custom_shape = self.new_custom_shape(\n                'TRIS', self.hubs_gizmo_shape)\n\n\nclass MediaFrame(HubsComponent):\n    _definition = {\n        'name': 'media-frame',\n        'display_name': 'Media Frame',\n        'category': Category.ELEMENTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'OBJECT_DATA',\n        'deps': ['networked'],\n        'version': (1, 0, 0)\n    }\n\n    mediaType: EnumProperty(\n        name=\"Media Type\",\n        description=\"Limit what type of media this frame will capture\",\n        items=[(\"all\", \"All Media\", \"Allow any type of media\"),\n               (\"all-2d\", \"Only 2D Media\", \"Allow only Images, Videos, and PDFs\"),\n               (\"model\", \"Only 3D Models\", \"Allow only 3D models\"),\n               (\"image\", \"Only Images\", \"Allow only images\"),\n               (\"video\", \"Only Videos\", \"Allow only videos\"),\n               (\"pdf\", \"Only PDFs\", \"Allow only PDFs\")],\n        default=\"all-2d\")\n\n    bounds: FloatVectorProperty(\n        name=\"Bounds\",\n        description=\"Bounding box to fit objects into when they are snapped into the media frame\",\n        unit='LENGTH',\n        subtype=\"XYZ\",\n        default=(1.0, 1.0, 1.0))\n\n    alignX: EnumProperty(\n        name=\"Align X\",\n        description=\"Media alignment along the X axis\",\n        items=[(\"min\", \"Min\", \"Align minimum X bounds of media and frame\"),\n               (\"center\", \"Center\", \"Align X centers of media and frame\"),\n               (\"max\", \"Max\", \"Align maximum X bounds of media and frame\")],\n        default=\"center\")\n\n    alignY: EnumProperty(\n        name=\"Align Y\",\n        description=\"Media alignment along the Y axis\",\n        items=[(\"min\", \"Min\", \"Align minimum Y bounds of media and frame\"),\n               (\"center\", \"Center\", \"Align Y centers of media and frame\"),\n               (\"max\", \"Max\", \"Align maximum Y bounds of media and frame\")],\n        default=\"center\")\n\n    alignZ: EnumProperty(\n        name=\"Align Z\",\n        description=\"Media alignment along the Z axis\",\n        items=[(\"min\", \"Min\", \"Align minimum Z bounds of media and frame\"),\n               (\"center\", \"Center\", \"Align Z centers of media and frame\"),\n               (\"max\", \"Max\", \"Align maximum Z bounds of media and frame\")],\n        default=\"center\")\n\n    scaleToBounds: BoolProperty(\n        name=\"Scale To Bounds\",\n        description=\"Scale the media to fit within the bounds of the media frame\",\n        default=True\n    )\n\n    snapToCenter: BoolProperty(\n        name=\"Snap To Center\",\n        description=\"Snap the media to the center of the media frame when capturing. If set to false the object will just remain in the place it was dropped but still be considered \\\"captured\\\" by the media frame\",\n        default=True\n    )\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        gizmo.target_set_prop(\n            \"bounds\", target.hubs_component_media_frame, \"bounds\")\n\n        scale = gizmo.target_get_value(\"bounds\")\n        if bone:\n            mat = bone_matrix_world(ob, bone, scale)\n        else:\n            loc, rot, _ = ob.matrix_world.decompose()\n            mat = Matrix.Translation(\n                loc) @ rot.normalized().to_matrix().to_4x4() @ Matrix.Diagonal(scale).to_4x4()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(MediaFrameGizmo.bl_idname)\n        setattr(gizmo, \"hubs_gizmo_shape\", box.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = (0.0, 0.0, 0.8)\n        gizmo.alpha = 1.0\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.0, 0.0, 0.8)\n        gizmo.alpha_highlight = 0.5\n\n        gizmo.target_set_prop(\n            \"bounds\", ob.hubs_component_media_frame, \"bounds\")\n\n        return gizmo\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            migrate_networked(host)\n            bounds = self.bounds.copy()\n            bounds = Vector((bounds.x, bounds.z, bounds.y))\n            self.bounds = bounds\n\n            if migration_type != MigrationType.GLOBAL or is_linked(ob) or type(ob) is bpy.types.Armature:\n                host_reference = get_host_reference_message(panel_type, host, ob=ob)\n                migration_report.append(\n                    f\"Warning: The Media Frame component's Y and Z bounds on the {panel_type.value} {host_reference} may not have migrated correctly\")\n\n        return migration_occurred\n\n    @staticmethod\n    def register():\n        bpy.utils.register_class(MediaFrameGizmo)\n\n    @staticmethod\n    def unregister():\n        bpy.utils.unregister_class(MediaFrameGizmo)\n\n    def gather(self, export_settings, object):\n        bounds = {\n            'x': self.bounds.x,\n            'y': self.bounds.y,\n            'z': self.bounds.z\n        }\n        if export_settings['gltf_yup']:\n            bounds['y'] = self.bounds.z\n            bounds['z'] = self.bounds.y\n        align = {\n            'x': self.alignX,\n            'y': self.alignY,\n            'z': self.alignZ\n        }\n        if export_settings['gltf_yup']:\n            align['y'] = self.alignZ\n            align['z'] = \"min\" if self.alignY == \"max\" else \"max\" if self.alignY == \"min\" else self.alignY\n        return {\n            'bounds': bounds,\n            'mediaType': self.mediaType,\n            'align': align,\n            'scaleToBounds': self.scaleToBounds,\n            'snapToCenter': self.snapToCenter\n        }\n\n    def draw(self, context, layout, panel):\n        super().draw(context, layout, panel)\n\n        if get_host_or_parents_scaled(context.object):\n            col = layout.column()\n            col.alert = True\n            col.label(\n                text=\"The media-frame object, and its parents' scale need to be [1,1,1]\", icon='ERROR')\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        blender_component = import_component(\n            component_name, blender_host)\n\n        gltf_yup = gltf.import_settings.get('gltf_yup', True)\n\n        for property_name, property_value in component_value.items():\n            if property_name == 'bounds' and gltf_yup:\n                property_value['y'], property_value['z'] = property_value['z'], property_value['y']\n\n                assign_property(gltf.vnodes, blender_component,\n                                property_name, property_value)\n\n            elif property_name == 'align':\n                align = {\n                    'x': property_value['x'],\n                    'y': property_value['y'],\n                    'z': property_value['z']\n                }\n                if gltf_yup:\n                    align['y'] = \"min\" if property_value['z'] == \"max\" else \"max\" if property_value['z'] == \"min\" else property_value['z']\n                    align['z'] = property_value['y']\n\n                blender_component.alignX = align['x']\n                blender_component.alignY = align['y']\n                blender_component.alignZ = align['z']\n\n            else:\n                assign_property(gltf.vnodes, blender_component,\n                                property_name, property_value)\n\n        if get_host_or_parents_scaled(blender_host):\n            import_report.append(\n                f\"The media-frame {blender_host.name} or one of its parents' scales isn't [1,1,1].  If this file is being imported from Spoke, then you may need to multiply the bounds parameter by the parents' scale before resetting the scale to [1,1,1].\")\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/mirror.py",
    "content": "from bpy.props import FloatVectorProperty\nfrom ..hubs_component import HubsComponent\nfrom ..gizmos import update_gizmos\nfrom ..types import Category, PanelType, NodeType\nfrom mathutils import Matrix, Quaternion\nfrom math import radians\n\n\nclass Mirror(HubsComponent):\n    _definition = {\n        'name': 'mirror',\n        'display_name': 'Mirror',\n        'category': Category.SCENE,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'MOD_MIRROR',\n        'version': (1, 0, 0)\n    }\n\n    color: FloatVectorProperty(name=\"Color\",\n                               description=\"Color\",\n                               subtype='COLOR_GAMMA',\n                               default=(0.498039, 0.498039, 0.498039),\n                               size=3,\n                               min=0,\n                               max=1,\n                               update=lambda self, context: update_gizmos())\n\n    def draw(self, context, layout, panel_type):\n        super().draw(context, layout, panel_type)\n\n        cmp = getattr(context.object, self.get_id())\n        if cmp.color[:] == (0.0, 0.0, 0.0):\n            layout.label(\n                text=\"You won't see much if the mirror is black\", icon='ERROR')\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new('GIZMO_GT_primitive_3d')\n        gizmo.draw_style = ('PLANE')\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_offset_scale = True\n        gizmo.line_width = 3\n        gizmo.color = getattr(ob, cls.get_id()).color[:3]\n        gizmo.alpha = 0.5\n        gizmo.hide_select = True\n        gizmo.scale_basis = 0.5\n        gizmo.use_draw_modal = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            loc, rot, scale = bone.matrix.to_4x4().decompose()\n            # Account for bones using Y up\n            rot_offset = Matrix.Rotation(radians(-90), 4, 'X').to_4x4()\n            rot = rot.normalized().to_matrix().to_4x4() @ rot_offset\n            # Account for the armature object's position\n            loc = ob.matrix_world @ Matrix.Translation(loc)\n            # Apply the custom rotation\n            rot_offset = Matrix.Rotation(radians(90), 4, 'X').to_4x4()\n            rot = rot @ rot_offset\n            # Shrink the gizmo to a 1x1m square (Blender defaults to 2x2m)\n            scale = scale / 2\n            # Convert the scale to a matrix\n            scale = Matrix.Diagonal(scale).to_4x4()\n            # Assemble the new matrix\n            mat_out = loc @ rot @ scale\n\n        else:\n            loc, rot, scale = ob.matrix_world.decompose()\n            # Apply the custom rotation\n            offset = Quaternion((1.0, 0.0, 0.0), radians(90.0))\n            new_rot = rot @ offset\n            # Shrink the gizmo to a 1x1m square (Blender defaults to 2x2m)\n            scale = scale / 2\n            # Assemble the new matrix\n            mat_out = Matrix.Translation(\n                loc) @ new_rot.normalized().to_matrix().to_4x4() @ Matrix.Diagonal(scale).to_4x4()\n\n        gizmo.matrix_basis = mat_out\n        gizmo.hide = not ob.visible_get()\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/model.py",
    "content": "from bpy.props import StringProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom .networked import migrate_networked\n\n\nclass Model(HubsComponent):\n    _definition = {\n        'name': 'model',\n        'display_name': 'Model',\n        'category': Category.MEDIA,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'SCENE_DATA',\n        'deps': ['networked'],\n        'version': (1, 0, 0)\n    }\n\n    src: StringProperty(name=\"Model URL\", description=\"Model URL\",\n                        default=\"https://example.org/ModelFile.glb\")\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            migrate_networked(host)\n\n        return migration_occurred\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/morph_audio_feedback.py",
    "content": "import bpy\nfrom bpy.props import FloatProperty, StringProperty, EnumProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\nshape_keys = []\n\nBLANK_ID = \"cKsdi5pSEUGvSg8\"\n\n\ndef get_object_shape_keys(cmp, ob):\n    global shape_keys\n    shape_keys = []\n    count = 0\n\n    shape_keys.append(\n        (BLANK_ID, \"Select a shape key\", \"None\", \"BLANK\", count))\n    count += 1\n\n    found = False\n    if ob.data.shape_keys:\n        for item in ob.data.shape_keys.key_blocks:\n            if item == item.relative_key:\n                pass\n            else:\n                shape_keys.append(\n                    (item.name, item.name, \"\", 'SHAPEKEY_DATA', count))\n                count += 1\n                if item.name == cmp.name:\n                    found = True\n\n    if cmp.name != BLANK_ID and not found:\n        shape_keys.append(\n            (cmp.name, cmp.name, \"\", \"ERROR\", count))\n        count += 1\n\n    return shape_keys\n\n\ndef get_shape_keys(self, context):\n    return get_object_shape_keys(self, context.object)\n\n\ndef get_shape_key(self):\n    global shape_keys\n    list_ids = list(map(lambda x: x[0], shape_keys))\n    if self.name in list_ids:\n        return list_ids.index(self.name)\n    return 0\n\n\ndef set_shape_key(self, value):\n    global shape_keys\n    list_indexes = list(map(lambda x: x[4], shape_keys))\n    if value in list_indexes:\n        self.name = shape_keys[value][0]\n    else:\n        self.name = BLANK_ID\n\n\nclass MorphAudioFeedback(HubsComponent):\n    _definition = {\n        'name': 'morph-audio-feedback',\n        'display_name': 'Morph Audio Feedback',\n        'category': Category.AVATAR,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT],\n        'icon': 'MOD_SMOOTH',\n        'version': (1, 0, 0)\n    }\n\n    name: StringProperty(\n        name=\"Name\",\n        description=\"Name\",\n        default=BLANK_ID\n    )\n\n    shape_key: EnumProperty(\n        name=\"Shape Key\",\n        description=\"Shape key to morph\",\n        items=get_shape_keys,\n        get=get_shape_key,\n        set=set_shape_key\n    )\n\n    minValue: FloatProperty(name=\"Min Value\",\n                            description=\"Min Value\",\n                            default=0.0,)\n\n    maxValue: FloatProperty(name=\"Max Value\",\n                            description=\"Max Value\",\n                            default=1.0)\n\n    @classmethod\n    def poll(cls, panel_type, host, ob=None):\n        return host.type == 'MESH'\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            shape_keys = get_object_shape_keys(self, host)\n            list_ids = list(map(lambda x: x[0], shape_keys))\n            if self.name not in list_ids:\n                self.name = self.name\n\n        return migration_occurred\n\n    def draw(self, context, layout, panel):\n        layout.prop(data=self, property=\"shape_key\")\n        shape_keys = context.object.data.shape_keys\n        if self.shape_key != BLANK_ID and shape_keys and self.shape_key not in shape_keys.key_blocks:\n            col = layout.column()\n            col.alert = True\n            col.label(text=\"No matching shape key found\",\n                      icon='ERROR')\n        layout.prop(data=self, property=\"minValue\")\n        layout.prop(data=self, property=\"maxValue\")\n\n    def gather(self, export_settings, object):\n        return {\n            'name': self.name if self.name != BLANK_ID else \"\",\n            'minValue': self.minValue,\n            'maxValue': self.maxValue\n        }\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/nav_mesh.py",
    "content": "from ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ..utils import has_component, add_component\n\n\nclass NavMesh(HubsComponent):\n    _definition = {\n        'name': 'nav-mesh',\n        'display_name': 'Navigation Mesh',\n        'category': Category.SCENE,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT],\n        'icon': 'GRID',\n        'version': (1, 0, 1),\n        'deps': ['visible']\n    }\n\n    @classmethod\n    def poll(cls, panel_type, host, ob=None):\n        return host.type == 'MESH'\n\n    def draw(self, context, layout, panel):\n        ob = context.object\n\n        total = 0\n        if ob.type == 'MESH' and ob.data and ob.data.materials:\n            for material in ob.data.materials:\n                if material:\n                    total += 1\n\n        if total > 1:\n            col = layout.column()\n            col.alert = True\n            col.label(text='The Nav mesh should only have one material',\n                      icon='ERROR')\n\n    @classmethod\n    def init(cls, obj):\n        obj.hubs_component_visible.visible = False\n        obj.hubs_component_list.items.get('visible').isDependency = True\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 1):\n            if not has_component(host, 'visible'):\n                add_component(host, 'visible')\n                host.hubs_component_visible.visible = False\n\n            host.hubs_component_list.items.get('visible').isDependency = True\n            migration_occurred = True\n\n        return migration_occurred\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/networked.py",
    "content": "from ..hubs_component import HubsComponent\nfrom bpy.props import StringProperty\nfrom ..types import PanelType, NodeType\nimport uuid\nfrom ..utils import add_component\nimport bpy\n\n\nclass Networked(HubsComponent):\n    _definition = {\n        'name': 'networked',\n        'display_name': 'Networked',\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'version': (1, 0, 0)\n    }\n\n    def gather(self, export_settings, object):\n        return {\n            'id': str(uuid.uuid4()).upper()\n        }\n\n\ndef migrate_networked(host):\n    if Networked.get_name() not in host.hubs_component_list.items:\n        add_component(host, Networked.get_name())\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/particle_emitter.py",
    "content": "from bpy.props import FloatProperty, EnumProperty, FloatVectorProperty, StringProperty, IntProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, NodeType, PanelType, MigrationType\nfrom ..consts import INTERPOLATION_MODES\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world, update_gizmos\nfrom ..models import particle_emitter\nfrom ..utils import is_linked, get_host_reference_message\nimport bpy\nfrom mathutils import Vector\nfrom ...io.utils import import_component, assign_property\n\n\nclass ParticleEmitter(HubsComponent):\n    _definition = {\n        'name': 'particle-emitter',\n        'display_name': 'Particle Emitter',\n        'category': Category.ELEMENTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'PARTICLES',\n        'version': (1, 1, 0)\n    }\n\n    particleCount: IntProperty(\n        name=\"Particle Count\", description=\"Particle Count\", subtype=\"UNSIGNED\", default=100)\n\n    src: StringProperty(\n        name=\"Image Source\", description=\"The web address (URL) of the image to use for each particle\",\n        default=\"https://assets.example.org/spoke/assets/images/dot-75db99b125fe4e9afbe58696320bea73.png\")\n\n    ageRandomness: FloatProperty(\n        name=\"Age Randomness\", description=\"Age Randomness\", default=10.0)\n\n    lifetime: FloatProperty(\n        name=\"Lifetime\", description=\"Lifetime\", unit=\"TIME\", subtype=\"TIME\", default=5.0)\n\n    lifetimeRandomness: FloatProperty(\n        name=\"Lifetime Randomness\", description=\"Lifetime Randomness\", default=5.0)\n\n    sizeCurve: EnumProperty(\n        name=\"Size Curve\",\n        description=\"Size Curve\",\n        items=INTERPOLATION_MODES,\n        default=\"linear\")\n\n    startSize: FloatProperty(\n        name=\"Start Size\", description=\"Start Size\", default=0.25)\n\n    endSize: FloatProperty(\n        name=\"End Size\", description=\"End Size\", default=0.25)\n\n    sizeRandomness: FloatProperty(\n        name=\"Size Randomness\", description=\"Size Randomness\", default=0.0)\n\n    colorCurve: EnumProperty(\n        name=\"Color Curve\",\n        description=\"Color Curve\",\n        items=INTERPOLATION_MODES,\n        default=\"linear\")\n\n    startColor: FloatVectorProperty(name=\"Start Color\",\n                                    description=\"Start Color\",\n                                    subtype='COLOR_GAMMA',\n                                    default=(1.0, 1.0, 1.0, 1.0),\n                                    size=4,\n                                    min=0,\n                                    max=1,\n                                    update=lambda self, context: update_gizmos())\n\n    startOpacity: FloatProperty(\n        name=\"Start Opacity\", description=\"Start Opacity\", default=1.0)\n\n    middleColor: FloatVectorProperty(name=\"Middle Color\",\n                                     description=\"Middle Color\",\n                                     subtype='COLOR_GAMMA',\n                                     default=(1.0, 1.0, 1.0, 1.0),\n                                     size=4,\n                                     min=0,\n                                     max=1)\n\n    middleOpacity: FloatProperty(\n        name=\"Middle Opacity\", description=\"Middle Opacity\", default=1.0)\n\n    endColor: FloatVectorProperty(name=\"End Color\",\n                                  description=\"End Color\",\n                                  subtype='COLOR_GAMMA',\n                                  default=(1.0, 1.0, 1.0, 1.0),\n                                  size=4,\n                                  min=0,\n                                  max=1)\n\n    endOpacity: FloatProperty(\n        name=\"End Opacity\", description=\"end Opacity\", default=1.0)\n\n    velocityCurve: EnumProperty(\n        name=\"Velocity Curve\",\n        description=\"Velocity Curve\",\n        items=INTERPOLATION_MODES,\n        default=\"linear\")\n\n    startVelocity: FloatVectorProperty(\n        name=\"Start Velocity\", description=\"Start Velocity\", unit=\"LENGTH\", subtype=\"XYZ\", default=(0.0, 0.0, 0.5))\n\n    endVelocity: FloatVectorProperty(\n        name=\"End Velocity\", description=\"End Velocity\", unit=\"LENGTH\", subtype=\"XYZ\", default=(0.0, 0.0, 0.5))\n\n    angularVelocity: FloatProperty(\n        name=\"Angular Velocity\", description=\"Angular Velocity\", unit=\"VELOCITY\", default=0.0)\n\n    def draw(self, context, layout, panel):\n        alert_src = getattr(self, \"src\") == self.bl_rna.properties['src'].default\n        for key in self.get_properties():\n            if not self.bl_rna.properties[key].is_hidden:\n                row = layout.row()\n                if key == \"src\" and alert_src:\n                    row.alert = True\n                row.prop(data=self, property=key)\n                if key == \"src\" and alert_src:\n                    warning_row = layout.row()\n                    warning_row.alert = True\n                    warning_row.label(\n                        text=\"Warning: the default URL won't work unless you replace 'example.org' with the domain of your Hubs instance.\",\n                        icon='ERROR')\n\n    def gather(self, export_settings, object):\n        props = super().gather(export_settings, object)\n        props['startVelocity'] = {\n            'x': self.startVelocity[0],\n            'y': self.startVelocity[2] if export_settings['gltf_yup'] else self.startVelocity[1],\n            'z': self.startVelocity[1] if export_settings['gltf_yup'] else self.startVelocity[2],\n        }\n        props['endVelocity'] = {\n            'x': self.endVelocity[0],\n            'y': self.endVelocity[2] if export_settings['gltf_yup'] else self.endVelocity[1],\n            'z': self.endVelocity[1] if export_settings['gltf_yup'] else self.endVelocity[2],\n        }\n        return props\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 1, 0):\n            migration_occurred = True\n            startVelocity = self.startVelocity.copy()\n            startVelocity = Vector((startVelocity.x, startVelocity.z, startVelocity.y))\n            self.startVelocity = startVelocity\n\n            endVelocity = self.endVelocity.copy()\n            endVelocity = Vector((endVelocity.x, endVelocity.z, endVelocity.y))\n            self.endVelocity = endVelocity\n\n        return migration_occurred\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", particle_emitter.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = getattr(ob, cls.get_id()).startColor[:3]\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        blender_component = import_component(\n            component_name, blender_host)\n\n        gltf_yup = gltf.import_settings.get('gltf_yup', True)\n\n        for property_name, property_value in component_value.items():\n            if property_name in ['startVelocity', 'endVelocity'] and gltf_yup:\n                property_value['y'], property_value['z'] = property_value['z'], property_value['y']\n\n            assign_property(gltf.vnodes, blender_component,\n                            property_name, property_value)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/pdf.py",
    "content": "from bpy.props import StringProperty, BoolProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom mathutils import Matrix\nfrom math import radians\n\n\nclass PDF(HubsComponent):\n    _definition = {\n        'name': 'pdf',\n        'display_name': 'PDF',\n        'category': Category.MEDIA,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'deps': ['networked'],\n        'icon': 'FILE_IMAGE',\n        'version': (1, 0, 0)\n    }\n    src: StringProperty(\n        name=\"PDF URL\", description=\"The web address of the PDF\", default='https://example.org/PdfFile.pdf')\n    controls: BoolProperty(\n        name=\"Controls\",\n        description=\"When enabled, shows pagination buttons when hovering your cursor over it in Hubs that allow you to switch pages\",\n        default=True)\n\n    @classmethod\n    def gather_name(cls):\n        return 'image'\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new('GIZMO_GT_primitive_3d')\n        gizmo.draw_style = ('PLANE')\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_offset_scale = True\n        gizmo.line_width = 3\n        gizmo.color = (0.8, 0.8, 0.8)\n        gizmo.alpha = 0.5\n        gizmo.hide_select = True\n        gizmo.scale_basis = 0.5\n        gizmo.use_draw_modal = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n        return gizmo\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            loc, rot, scale = bone.matrix.to_4x4().decompose()\n            # Account for the armature object's position\n            loc = ob.matrix_world @ Matrix.Translation(loc)\n            # Convert to A4 aspect ratio\n            scale[1] = 1.414\n            # Shrink the gizmo to fit within a 1x1m square\n            scale = scale * 0.3538\n            # Convert the scale to a matrix\n            scale = Matrix.Diagonal(scale).to_4x4()\n            # Convert the rotation to a matrix\n            rot = rot.normalized().to_matrix().to_4x4()\n            # Assemble the new matrix\n            mat_out = loc @ rot @ scale\n        else:\n            loc, rot, scale = ob.matrix_world.decompose()\n            # Apply the custom rotation\n            rot_offset = Matrix.Rotation(radians(90), 4, 'X').to_4x4()\n            new_rot = rot.normalized().to_matrix().to_4x4() @ rot_offset\n            # Convert to A4 aspect ratio\n            scale[1] = 1.414\n            # Shrink the gizmo to fit within a 1x1m square\n            scale = scale * 0.3538\n            # Assemble the new matrix\n            mat_out = Matrix.Translation(\n                loc) @ new_rot @ Matrix.Diagonal(scale).to_4x4()\n        gizmo.matrix_basis = mat_out\n        gizmo.hide = not ob.visible_get()\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/personal_space_invader.py",
    "content": "from bpy.props import BoolProperty, FloatProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass PersonalSpaceInvader(HubsComponent):\n    _definition = {\n        'name': 'personal-space-invader',\n        'display_name': 'Personal Space Invader',\n        'category': Category.AVATAR,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'MATSHADERBALL',\n        'version': (1, 0, 0)\n    }\n\n    radius: FloatProperty(name=\"Radius\",\n                          description=\"Radius\",\n                          default=0.1)\n\n    useMaterial: BoolProperty(name=\"Use Material\",\n                              description=\"Use Material\",\n                              default=False)\n\n    invadingOpacity: FloatProperty(name=\"Invading Opacity\",\n                                   description=\"Invading Opacity\",\n                                   default=0.3)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/point_light.py",
    "content": "from ..models import point_light\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world, update_gizmos\nfrom bpy.props import FloatVectorProperty, FloatProperty, BoolProperty, IntVectorProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass PointLight(HubsComponent):\n    _definition = {\n        'name': 'point-light',\n        'display_name': 'Point Light',\n        'category': Category.LIGHTS,\n        'node_type': NodeType. NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'LIGHT_POINT',\n        'version': (1, 0, 0)\n    }\n\n    color: FloatVectorProperty(name=\"Color\",\n                               description=\"Color\",\n                               subtype='COLOR_GAMMA',\n                               default=(1.0, 1.0, 1.0, 1.0),\n                               size=4,\n                               min=0,\n                               max=1,\n                               update=lambda self, context: update_gizmos())\n\n    intensity: FloatProperty(name=\"Intensity\",\n                             description=\"Intensity\",\n                             default=1.0)\n\n    range: FloatProperty(name=\"Range\",\n                         description=\"Range\",\n                         default=0.0)\n\n    decay: FloatProperty(name=\"Decay\",\n                         description=\"Decay\",\n                         default=2.0)\n\n    castShadow: BoolProperty(\n        name=\"Cast Shadow\", description=\"Cast Shadow\", default=True)\n\n    shadowMapResolution: IntVectorProperty(name=\"Shadow Map Resolution\",\n                                           description=\"Shadow Map Resolution\",\n                                           size=2,\n                                           default=[512, 512])\n\n    shadowBias: FloatProperty(name=\"Shadow Bias\",\n                              description=\"Shadow Bias\",\n                              default=0.0)\n\n    shadowRadius: FloatProperty(name=\"Shadow Radius\",\n                                description=\"Shadow Radius\",\n                                default=1.0)\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", point_light.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = getattr(ob, cls.get_id()).color[:3]\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/reflection_probe.py",
    "content": "from ..operators import OpenImage\nimport bpy\nfrom bpy.props import PointerProperty, EnumProperty, StringProperty, BoolProperty, CollectionProperty\nfrom bpy.types import Image, PropertyGroup, Operator\n\nfrom ...components.utils import is_gpu_available, redraw_component_ui, is_linked, update_image_editors\n\nfrom ..components_registry import get_components_registry\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ..ui import add_link_indicator\nfrom ...utils import rgetattr, rsetattr\nfrom ...io.utils import import_component, assign_property\nimport math\nimport os\n\n\nDEFAULT_RESOLUTION_ITEMS = [\n    ('128x64', '128x64',\n     '128 x 64', '', 0),\n    ('256x128', '256x128',\n     '256 x 128', '', 1),\n    ('512x256', '512x256',\n     '512 x 256', '', 2),\n    ('1024x512', '1024x512',\n     '1024 x 512', '', 3),\n    ('2048x1024', '2048x1024',\n     '2048 x 1024', '', 4),\n]\n\nRESOLUTION_ITEMS = DEFAULT_RESOLUTION_ITEMS[:]\n\nprobe_baking = False\nbake_mode = None\n\n\ndef get_resolutions(self, context):\n    global RESOLUTION_ITEMS\n    env_map = context.scene.hubs_component_environment_settings.envMapTexture\n    if env_map:\n        x = env_map.size[0]\n        y = env_map.size[1]\n        RESOLUTION_ITEMS = [(f'{x}x{y}', f'{x}x{y}', f'{x} x {y}', '', 0)]\n    else:\n        RESOLUTION_ITEMS = DEFAULT_RESOLUTION_ITEMS\n\n    return RESOLUTION_ITEMS\n\n\ndef get_resolution(self):\n    env_map = bpy.context.scene.hubs_component_environment_settings.envMapTexture\n    list_ids = [x[0] for x in RESOLUTION_ITEMS]\n    return 0 if env_map else list_ids.index(self.resolution_id)\n\n\ndef set_resolution(self, value):\n    env_map = bpy.context.scene.hubs_component_environment_settings.envMapTexture\n    if not env_map:\n        self.resolution_id = RESOLUTION_ITEMS[value][0]\n\n\ndef get_probes(all_objects=False, include_locked=False, include_linked=False):\n    probes = []\n    objects = bpy.data.objects if all_objects else bpy.context.view_layer.objects\n    for ob in objects:\n        component_list = ob.hubs_component_list\n\n        registered_hubs_components = get_components_registry()\n\n        if component_list.items:\n            for component_item in component_list.items:\n                component_name = component_item.name\n                if component_name in registered_hubs_components:\n                    if component_name == 'reflection-probe':\n                        probe_component = ob.hubs_component_reflection_probe\n                        if is_linked(ob) and not include_linked:\n                            continue\n                        if probe_component.locked and not include_locked:\n                            continue\n                        probes.append(ob)\n\n    return probes\n\n\ndef get_probe_image_path(probe):\n    return f\"{bpy.app.tempdir}/{probe.name}.hdr\"\n\n\ndef import_menu_draw(self, context):\n    self.layout.operator(\"image.hubs_import_reflection_probe_envmaps\",\n                         text=\"Import Reflection Probe EnvMaps\")\n\n\ndef export_menu_draw(self, context):\n    self.layout.operator(\"image.hubs_export_reflection_probe_envmaps\",\n                         text=\"Export Reflection Probe EnvMaps\")\n\n\nclass ReflectionProbeSceneProps(PropertyGroup):\n    resolution: EnumProperty(name='Resolution',\n                             description='Reflection Probe Selected Environment Map Resolution',\n                             items=get_resolutions,\n                             get=get_resolution,\n                             set=set_resolution)\n\n    render_resolution: StringProperty(name='Last Bake Resolution',\n                                      description='Reflection Probe Last Bake Environment Map Resolution',\n                                      options={'HIDDEN'},\n                                      default='256x128')\n\n    resolution_id: StringProperty(name='Current Resolution Id',\n                                  default='256x128', options={'HIDDEN'})\n\n    use_compositor: BoolProperty(\n        name=\"Use Compositor\",\n        description=\"Controls whether the baked images will be processed by the compositor after baking\", default=False)\n\n\nclass BakeProbeOperator(Operator):\n    bl_idname = \"render.hubs_render_reflection_probe\"\n    bl_label = \"Render Hubs Reflection Probe\"\n\n    _timer = None\n    done = False\n    rendering = False\n    cancelled = False\n    probes = []\n    probe_index = 0\n    probe_is_setup = False\n\n    bake_mode: EnumProperty(\n        name=\"bake_mode\",\n        items=[('ACTIVE', 'Bake Active', 'Bake Active'),\n               ('SELECTED', 'Bake Selected', 'Bake Selected'),\n               ('ALL', 'Bake All', 'Bake All')],\n        default='ACTIVE')\n\n    disabled_message = \"Can't bake linked reflection probes.  Please make it local first\"\n\n    @classmethod\n    def description(cls, context, properties):\n        if properties.bake_mode == 'ACTIVE':\n            description_text = \"Generate a 360 equirectangular HDR environment map of the current area in the scene\"\n            if bpy.app.version < (3, 0, 0) and is_linked(context.active_object):\n                description_text += f\"\\nDisabled: {cls.disabled_message}\"\n        elif properties.bake_mode == 'SELECTED':\n            description_text = \"Bake the selected unlocked/local reflection probes\"\n        else:\n            description_text = \"Bake all the unlocked/local reflection probes in the current view layer\"\n\n        return description_text\n\n    @classmethod\n    def poll(cls, context):\n        if hasattr(context, 'bake_active_probe') and is_linked(context.active_object):\n            if bpy.app.version >= (3, 0, 0):\n                cls.poll_message_set(f\"{cls.disabled_message}.\")\n            return False\n\n        return not probe_baking and hasattr(bpy.context.scene, \"cycles\")\n\n    def render_post(self, scene, depsgraph):\n        print(\"Finished render\")\n\n        self.rendering = False\n        self.probe_is_setup = False\n\n        if self.probe_index == 0:\n            self.done = True\n        else:\n            self.probe_index -= 1\n\n    def render_cancelled(self, scene, depsgraph):\n        print(\"Render canceled\")\n        self.cancelled = True\n\n    def execute(self, context):\n        modes = {\n            'ACTIVE': lambda: [context.active_object],\n            'SELECTED': lambda: [ob for ob in get_probes() if ob in context.selected_objects],\n            'ALL': lambda: get_probes(),\n        }\n        self.probes = modes[self.bake_mode]()\n\n        if self.bake_mode == 'SELECTED' and len(self.probes) == 0:\n            def draw(self, context):\n                self.layout.label(\n                    text=\"No probes selected to bake or the selected probes are locked/linked. Please select some unlocked/local probes first.\")\n            bpy.context.window_manager.popup_menu(\n                draw, title=\"No unlocked/local probes selected\", icon='ERROR')\n            return {'CANCELLED'}\n        if self.bake_mode == 'ALL' and len(self.probes) == 0:\n            def draw(self, context):\n                self.layout.label(\n                    text=\"No unlocked/local probes to bake. Please unlock/make local the desired probes first.\")\n            bpy.context.window_manager.popup_menu(\n                draw, title=\"No unlocked/local probes\", icon='ERROR')\n            return {'CANCELLED'}\n        if self.bake_mode == 'ACTIVE' and is_linked(self.probes[0]):\n            # This isn't likely to ever happen, but just in case....\n            def draw(self, context):\n                self.layout.label(\n                    text=\"The active probe is linked. Please make it local first.\")\n            bpy.context.window_manager.popup_menu(\n                draw, title=\"Active probe linked\", icon='ERROR')\n            return {'CANCELLED'}\n        if self.bake_mode == 'ACTIVE' and self.probes[0].hubs_component_reflection_probe.locked:\n            # This isn't likely to ever happen, but just in case....\n            def draw(self, context):\n                self.layout.label(\n                    text=\"The active probe is locked. Please unlock it first.\")\n            bpy.context.window_manager.popup_menu(\n                draw, title=\"Active probe locked\", icon='ERROR')\n            return {'CANCELLED'}\n\n        bpy.app.handlers.render_post.append(self.render_post)\n        bpy.app.handlers.render_cancel.append(self.render_cancelled)\n\n        self._timer = context.window_manager.event_timer_add(\n            0.5, window=context.window)\n        context.window_manager.modal_handler_add(self)\n\n        global probe_baking, bake_mode\n        bake_mode = self.bake_mode\n\n        self.camera_data = bpy.data.cameras.new(name='Temp EnvMap Camera')\n        self.camera_object = bpy.data.objects.new(\n            'Temp EnvMap Camera', self.camera_data)\n        bpy.context.scene.collection.objects.link(self.camera_object)\n\n        self.saved_props = {}\n        self.preferences_is_dirty_state = bpy.context.preferences.is_dirty\n        self.cancelled = False\n        self.done = False\n        self.rendering = False\n        self.probe_is_setup = False\n        self.probe_index = len(self.probes) - 1\n\n        probe_baking = True\n\n        return {\"RUNNING_MODAL\"}\n\n    def modal(self, context, event):\n        global probe_baking\n\n        # print(\"ev: %s\" % event.type)\n        if event.type == 'TIMER':\n            if self.cancelled or self.done:\n                probe_baking = False\n                bpy.app.handlers.render_post.remove(self.render_post)\n                bpy.app.handlers.render_cancel.remove(self.render_cancelled)\n                context.window_manager.event_timer_remove(self._timer)\n\n                bpy.context.scene.collection.objects.unlink(self.camera_object)\n                bpy.data.cameras.remove(self.camera_data)\n\n                self.restore_render_props()\n                self.rendering = False\n                self.probe_is_setup = False\n\n                if self.cancelled:\n                    for probe in self.probes:\n                        img_path = get_probe_image_path(probe)\n                        if os.path.exists(img_path):\n                            os.remove(img_path)\n                    self.report(\n                        {'WARNING'}, 'Reflection probe baking cancelled')\n                    return {\"CANCELLED\"}\n\n                for probe in self.probes:\n                    probe_component = probe.hubs_component_reflection_probe\n                    old_img = probe_component.envMapTexture\n                    image_name = f\"generated_cubemap-{probe.name}\"\n                    # Store the old image's name in case of name juggling.\n                    old_img_name = old_img.name if old_img else \"\"\n\n                    conflicting_img = None\n                    for img in bpy.data.images:\n                        if img.name == image_name and not is_linked(img):\n                            conflicting_img = img\n                            break\n\n                    if conflicting_img and conflicting_img != old_img:\n                        # Rename the conflicting image to help avoid problems caused by Blender's name juggling and allow name juggled images to be more easily found.\n                        conflicting_img.name = f\"{conflicting_img.name}-old\"\n\n                    img_path = get_probe_image_path(probe)\n                    img = bpy.data.images.load(filepath=img_path)\n                    img.name = image_name\n                    if old_img:\n                        if image_name == old_img_name and not is_linked(old_img):\n                            old_img.user_remap(img)\n                            bpy.data.images.remove(old_img)\n                        else:\n                            update_image_editors(old_img, img)\n\n                    probe_component.envMapTexture = img\n\n                    # Pack image and update filepaths so that it displays/unpacks nicely for the user.\n                    # Note: updating the filepaths prints an error to the terminal, but otherwise seems to work fine.\n                    img.pack()\n                    new_filepath = f\"//{image_name}.hdr\"\n                    img.packed_files[0].filepath = new_filepath\n                    img.filepath_raw = new_filepath\n                    img.filepath = new_filepath\n                    if os.path.exists(img_path):\n                        os.remove(img_path)\n\n                props = context.scene.hubs_scene_reflection_probe_properties\n                props.render_resolution = props.resolution\n\n                self.report({'INFO'}, 'Reflection probe baking finished')\n                return {\"FINISHED\"}\n\n            elif not self.rendering:\n                try:\n                    if not self.probe_is_setup:\n                        self.setup_probe_render(context)\n\n                    # Rendering can sometimes fail if the old render is still being cleaned up.  Keep trying until it works.\n                    # For more details see https://developer.blender.org/T52258\n                    if bpy.ops.render.render(\"INVOKE_DEFAULT\", write_still=True) != {'CANCELLED'}:\n                        self.rendering = True\n\n                except Exception as e:\n                    print(e)\n                    self.cancelled = True\n                    self.report(\n                        {'ERROR'}, 'Reflection probe baking error %s' % e)\n\n        return {\"PASS_THROUGH\"}\n\n    def restore_render_props(self):\n        for prop in self.saved_props:\n            rsetattr(bpy.context, prop, self.saved_props[prop])\n        bpy.context.preferences.is_dirty = self.preferences_is_dirty_state\n        self.preferences_is_dirty_state = None\n\n    def setup_probe_render(self, context):\n        probe = self.probes[self.probe_index]\n        cycles_settings = self.camera_data.cycles if bpy.app.version < (4, 0, 0) else self.camera_data\n\n        self.camera_data.type = \"PANO\"\n        cycles_settings.panorama_type = \"EQUIRECTANGULAR\"\n\n        cycles_settings.longitude_min = -math.pi\n        cycles_settings.longitude_max = math.pi\n        cycles_settings.latitude_min = -math.pi / 2\n        cycles_settings.latitude_max = math.pi / 2\n\n        self.camera_data.clip_start = probe.data.clip_start\n        self.camera_data.clip_end = probe.data.clip_end\n\n        self.camera_object.matrix_world = probe.matrix_world.copy()\n        self.camera_object.rotation_euler.x += math.pi / 2\n        self.camera_object.rotation_euler.z += -math.pi / 2\n\n        resolution = context.scene.hubs_scene_reflection_probe_properties.resolution\n        (x, y) = [int(i) for i in resolution.split('x')]\n        output_path = get_probe_image_path(probe)\n        use_compositor = context.scene.hubs_scene_reflection_probe_properties.use_compositor\n\n        overrides = [\n            (\"preferences.view.render_display_type\", \"NONE\"),\n            (\"scene.camera\", self.camera_object),\n            (\"scene.render.engine\", \"CYCLES\"),\n            (\"scene.cycles.device\", \"GPU\" if is_gpu_available(context) else \"CPU\"),\n            (\"scene.render.resolution_x\", x),\n            (\"scene.render.resolution_y\", y),\n            (\"scene.render.resolution_percentage\", 100),\n            (\"scene.render.image_settings.file_format\", \"HDR\"),\n            (\"scene.render.filepath\", output_path),\n            (\"scene.render.use_compositing\", use_compositor),\n            (\"scene.use_nodes\", use_compositor)\n        ]\n\n        for (prop, value) in overrides:\n            if prop not in self.saved_props:\n                self.saved_props[prop] = rgetattr(bpy.context, prop)\n            rsetattr(bpy.context, prop, value)\n\n        self.report({'INFO'}, 'Baking probe %s' % probe.name)\n        self.probe_is_setup = True\n\n\nclass OpenReflectionProbeEnvMap(OpenImage):\n    bl_idname = \"image.hubs_open_reflection_probe_envmap\"\n    bl_label = \"Open EnvMap\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context):\n        if is_linked(context.active_object):\n            if bpy.app.version >= (3, 0, 0):\n                cls.poll_message_set(f\"{cls.disabled_message}.\")\n            return False\n\n        probe_component = context.active_object.hubs_component_reflection_probe\n        if probe_component.locked:\n            return False\n\n        return True\n\n\nclass ImportReflectionProbeEnvMaps(Operator):\n    bl_idname = \"image.hubs_import_reflection_probe_envmaps\"\n    bl_label = \"Import EnvMaps\"\n    bl_description = \"Batch open environment maps and assign them to their corresponding reflection probes\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    filepath: StringProperty(subtype=\"FILE_PATH\")\n    files: CollectionProperty(type=PropertyGroup)\n    filter_folder: BoolProperty(default=True, options={\"HIDDEN\"})\n    filter_image: BoolProperty(default=True, options={\"HIDDEN\"})\n\n    relative_path: BoolProperty(\n        name=\"Relative Path\", description=\"Select the file relative to the blend file\", default=True)\n    overwrite_images: BoolProperty(\n        name=\"Overwrite Probe Images\",\n        description=\"Overwrite/Remove the current images of the reflection probes being imported to\", default=False)\n\n    def draw(self, context):\n        layout = self.layout\n        layout.prop(self, \"relative_path\")\n        layout.prop(self, \"overwrite_images\")\n        layout.separator()\n        info_col = layout.column()\n        info_col.scale_y = 0.7\n        info_col.label(text=\"Load the selected images\", icon='INFO')\n        info_col.label(text=\"into the matching probes.\", icon='BLANK1')\n        info_col.label(text=\"Images must start with the\", icon='BLANK1')\n        info_col.label(text=\"respective probe's name\", icon='BLANK1')\n        info_col.label(text=\"formatted like this:\", icon='BLANK1')\n        info_col.label(text=\"\\\"<Probe Name> - EnvMap\\\"\", icon='BLANK1')\n\n    def execute(self, context):\n        dirname = os.path.dirname(self.filepath)\n\n        if not self.files[0].name:\n            self.report(\n                {'INFO'}, \"Import EnvMaps cancelled.  No images selected.\")\n            return {'CANCELLED'}\n\n        num_imported = 0\n        num_failed = 0\n        probes = get_probes(all_objects=True)\n        for f in self.files:\n            imported_file = False\n            for probe in probes:\n                if f.name.startswith(f\"{probe.name} - EnvMap\"):\n                    probe_component = probe.hubs_component_reflection_probe\n                    old_img = probe_component.envMapTexture\n\n                    img = bpy.data.images.load(\n                        filepath=os.path.join(dirname, f.name))\n                    probe_component.envMapTexture = img\n\n                    if old_img:\n                        if self.overwrite_images:\n                            if old_img.name == f.name:\n                                img.name = f.name\n\n                            old_img.user_remap(img)\n\n                            if not is_linked(old_img):\n                                bpy.data.images.remove(old_img)\n\n                        else:\n                            update_image_editors(old_img, img)\n\n                    imported_file = True\n                    num_imported += 1\n                    self.report(\n                        {'INFO'}, f\"Imported {f.name} to probe {probe.name}\")\n\n            if not imported_file:\n                num_failed += 1\n                self.report(\n                    {'WARNING'},\n                    f\"Warning: Couldn't import {f.name}.  The corresponding probe either doesn't exist or is locked/linked.\")\n\n        if num_failed:\n            final_report_message = f\"Warning: {num_failed} environment maps failed to import. {num_imported} environment maps imported to probes\"\n        else:\n            final_report_message = f\"{num_imported} environment maps imported to probes\"\n        self.report({'INFO'}, final_report_message)\n\n        redraw_component_ui(context)\n        return {'FINISHED'}\n\n    def invoke(self, context, event):\n        self.filepath = \"\"\n        context.window_manager.fileselect_add(self)\n        return {'RUNNING_MODAL'}\n\n\nclass ExportReflectionProbeEnvMaps(Operator):\n    bl_idname = \"image.hubs_export_reflection_probe_envmaps\"\n    bl_label = \"Export EnvMaps\"\n    bl_description = \"Batch save out the current environment maps from reflection probes\"\n\n    directory: StringProperty(subtype=\"DIR_PATH\")\n    filter_folder: BoolProperty(default=True, options={\"HIDDEN\"})\n    filter_image: BoolProperty(default=True, options={\"HIDDEN\"})\n\n    batch_type: EnumProperty(\n        name=\"Batch Type\",\n        description=\"Choose which probes to export\",\n        items=(\n            ('ALL', \"All Probes\",\n             \"Export the environment maps from all probes in the current view layer\"),\n            ('SELECTED', \"Selected Probes\",\n             \"Export the environment maps from the selected probes\"),\n        ),\n        default='ALL',\n    )\n\n    include_locked: BoolProperty(\n        name=\"Include Locked\", description=\"Include environment maps from locked probes\", default=False)\n\n    naming_scheme: StringProperty(\n        name=\"Output Naming Scheme\",\n        description=\"How exported files will be named\",\n        default=\"<Probe Name> - EnvMap.hdr\"\n    )\n\n    def draw(self, context):\n        layout = self.layout\n        layout.label(text=\"Export EnvMaps for:\")\n        layout.prop(self, \"batch_type\", expand=True)\n        layout.prop(self, \"include_locked\")\n        layout.separator()\n        row = layout.row()\n        row.prop(self, \"naming_scheme\", text=\"To\")\n        row.enabled = False\n\n    def execute(self, context):\n        if self.batch_type == 'SELECTED':\n            probes = [ob for ob in get_probes(\n                include_locked=self.include_locked) if ob in context.selected_objects]\n        else:\n            probes = get_probes(include_locked=self.include_locked)\n\n        if not probes:\n            self.report(\n                {'WARNING'}, \"Export EnvMaps cancelled.  No local probes matching the criteria were found.\")\n            return {'CANCELLED'}\n\n        num_exported = 0\n        for probe in probes:\n            envMapTexture = probe.hubs_component_reflection_probe.envMapTexture\n            if envMapTexture:\n                export_path = f\"{self.directory}/{probe.name} - EnvMap.hdr\"\n                orig_filepath_raw = envMapTexture.filepath_raw\n                envMapTexture.filepath_raw = export_path\n                envMapTexture.save()\n                envMapTexture.filepath_raw = orig_filepath_raw\n                self.report(\n                    {'INFO'}, f\"Exported environment map for probe {probe.name}\")\n                num_exported += 1\n            else:\n                self.report(\n                    {'WARNING'}, f\"Reflection probe {probe.name} doesn't have an environment map to export\")\n        self.report(\n            {'INFO'}, f\"Exported {num_exported} environment maps to {self.directory}\")\n        return {'FINISHED'}\n\n    def invoke(self, context, event):\n        context.window_manager.fileselect_add(self)\n        return {'RUNNING_MODAL'}\n\n\nclass SelectMismatchedReflectionProbes(Operator):\n    bl_idname = \"wm.hubs_select_mismatched_reflection_probes\"\n    bl_label = \"Select Mismatched Reflection Probes\"\n    bl_description = \"Select reflection probes in the current view layer with environment maps that don't match the global resolution\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    select_all: BoolProperty(default=False)\n    mismatched_probe_indexes: StringProperty()\n\n    def execute(self, context):\n        if self.select_all:\n            bpy.ops.object.select_all(action='DESELECT')\n            probes = get_probes(include_locked=True, include_linked=True)\n            for index in map(int, self.mismatched_probe_indexes.split(',')):\n                probe = probes[index]\n                probe.select_set(True)\n            context.view_layer.objects.active = None\n            return {'FINISHED'}\n\n        probe = context.probe\n\n        # Check if the probe can be selected.\n        probe.select_set(True)\n        if not probe.select_get():\n            self.report({'INFO'}, f\"Couldn't select probe {probe.name_full}\")\n            return {'CANCELLED'}\n\n        bpy.ops.object.select_all(action='DESELECT')\n        probe.select_set(True)\n        context.view_layer.objects.active = probe\n        return {'FINISHED'}\n\n    def invoke(self, context, event):\n        probes = get_probes(include_locked=True, include_linked=True)\n\n        def draw(self, context):\n            layout = self.layout\n            layout.label(text=\"Select Mismatched Probes\")\n            layout.separator()\n\n            props = context.scene.hubs_scene_reflection_probe_properties\n            mismatched_probe_indexes = []\n            mismatched_probes = []\n            for i, probe in enumerate(probes):\n                envmap = probe.hubs_component_reflection_probe.envMapTexture\n                if envmap:\n                    envmap_resolution = f\"{envmap.size[0]}x{envmap.size[1]}\"\n                    if envmap_resolution != props.resolution:\n                        mismatched_probe_indexes.append(i)\n                        mismatched_probes.append(probe)\n\n            is_selected = (context.selected_objects == mismatched_probes and not context.active_object)\n            icon = 'RADIOBUT_ON' if is_selected else 'RADIOBUT_OFF'\n            op = layout.operator(\n                SelectMismatchedReflectionProbes.bl_idname, text=\"Select All\", icon=icon)\n            op.select_all = True\n            op.mismatched_probe_indexes = ','.join(\n                map(str, mismatched_probe_indexes))\n\n            layout.separator()\n\n            for probe in mismatched_probes:\n                is_selected = (probe == context.active_object and probe in context.selected_objects and len(\n                    context.selected_objects) == 1)\n                icon = 'RADIOBUT_ON' if is_selected else 'RADIOBUT_OFF'\n                row = layout.row()\n                row.context_pointer_set(\"probe\", probe)\n                op = row.operator(\n                    SelectMismatchedReflectionProbes.bl_idname, text=probe.name_full, icon=icon)\n                op.select_all = False\n                op.mismatched_probe_indexes = ''\n\n        bpy.context.window_manager.popup_menu(draw)\n        return {'FINISHED'}\n\n\nclass ReflectionProbe(HubsComponent):\n    _definition = {\n        'name': 'reflection-probe',\n        'display_name': 'Reflection Probe',\n        'category': Category.SCENE,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT],\n        'icon': 'MATERIAL',\n        'version': (1, 0, 0)\n    }\n\n    envMapTexture: PointerProperty(\n        name=\"EnvMap\",\n        description=\"An equirectangular image to use as the environment map for this probe\",\n        type=Image\n    )\n\n    locked: BoolProperty(\n        name=\"Probe Lock\",\n        description=\"Toggle whether new environment maps can be assigned/baked to this reflection probe\", default=False)\n\n    def draw(self, context, layout, panel):\n        row = layout.row()\n        row.alignment = 'LEFT'\n        icon = 'LOCKED' if self.locked else 'UNLOCKED'\n        row.prop(self, \"locked\", text='', icon=icon, toggle=True)\n\n        if not context.scene.hubs_component_environment_settings.envMapTexture:\n            row = layout.row()\n            row.alert = True\n            row.label(\n                text=\"No scene environment map found.  Please add an environment map to the environment settings scene component for reflection probes to work in Hubs.\",\n                icon='ERROR')\n\n        if any(context.active_object.matrix_world.to_euler()):\n            row = layout.row()\n            row.alert = True\n            row.label(text=\"Rotation detected!  The reflection probe must have no rotation applied to it.\",\n                      icon='ERROR')\n\n        row = layout.row()\n        row.label(\n            text=\"Resolution settings, as well as the option to bake all reflection probes at once, can be accessed from the scene settings.\",\n            icon='INFO')\n\n        row = layout.row(align=True)\n        sub_row = row.row(align=True)\n        sub_row.prop(self, \"envMapTexture\")\n        if is_linked(context.active_object):\n            # Manually disable the PointerProperty, needed for Blender 3.2+.\n            sub_row.enabled = False\n\n        if is_linked(self.envMapTexture):\n            sub_row = row.row(align=True)\n            sub_row.enabled = False\n            add_link_indicator(sub_row, self.envMapTexture)\n        row.context_pointer_set(\"target\", self)\n        row.context_pointer_set(\"host\", context.active_object)\n        op = row.operator(\"image.hubs_open_reflection_probe_envmap\", text='', icon='FILE_FOLDER')\n        op.target_property = \"envMapTexture\"\n\n        if self.locked:\n            row.enabled = False\n\n        envmap = self.envMapTexture\n        if envmap:\n            envmap_resolution = f\"{envmap.size[0]}x{envmap.size[1]}\"\n            props = context.scene.hubs_scene_reflection_probe_properties\n            if not envmap.has_data:\n                row = layout.row()\n                row.alert = True\n                row.label(text=\"Can't load image.\",\n                          icon='ERROR')\n            elif envmap_resolution != props.resolution:\n                row = layout.row()\n                row.alert = True\n                row.label(text=f\"{envmap_resolution} EnvMap doesn't match the scene probe resolution.\",\n                          icon='ERROR')\n\n        global bake_mode\n        row = layout.row()\n        row.context_pointer_set(\"bake_active_probe\", None)\n        bake_msg = \"Baking...\" if probe_baking and bake_mode == 'ACTIVE' else \"Bake\"\n        bake_op = row.operator(\n            \"render.hubs_render_reflection_probe\",\n            text=bake_msg\n        )\n        bake_op.bake_mode = 'ACTIVE'\n\n        if self.locked:\n            row.enabled = False\n\n        if not hasattr(bpy.context.scene, \"cycles\"):\n            row = layout.row()\n            row.alert = True\n            row.label(text=\"Baking requires Cycles addon to be enabled.\",\n                      icon='ERROR')\n\n    def gather(self, export_settings, object):\n        from ...io.utils import gather_texture\n        return {\n            \"size\": object.data.influence_distance,\n            \"envMapTexture\": {\n                \"__mhc_link_type\": \"texture\",\n                \"index\": gather_texture(self.envMapTexture, export_settings)\n            }\n        }\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        # Reflection Probes import as empties, so add a Light Probe object to host the component and parent it to the empty.\n        probe_type = 'CUBE' if bpy.app.version < (4, 1, 0) else 'SPHERE'\n        reflecion_probe_name = blender_host.name\n        blender_host.name = f\"{blender_host.name}_node\"\n        lightprobe_data = bpy.data.lightprobes.new(reflecion_probe_name, probe_type)\n        lightprobe_data.influence_type = 'BOX'\n        lightprobe_object = bpy.data.objects.new(reflecion_probe_name, lightprobe_data)\n        lightprobe_object.location = blender_host.location\n        lightprobe_object.rotation_mode = 'QUATERNION'\n        lightprobe_object.rotation_quaternion = blender_host.rotation_quaternion\n        lightprobe_object.scale = blender_host.scale\n        lightprobe_object.parent = blender_host\n        for collection in blender_host.users_collection:\n            collection.objects.link(lightprobe_object)\n        bpy.context.view_layer.update()\n        lightprobe_object.matrix_parent_inverse = blender_host.matrix_world.inverted()\n\n        # Import the component\n        component = import_component(component_name, lightprobe_object)\n        lightprobe_data.influence_distance = component_value[\"size\"]\n        assign_property(gltf.vnodes, component,\n                        \"envMapTexture\", component_value[\"envMapTexture\"])\n\n    @classmethod\n    def draw_global(cls, context, layout, panel):\n        panel_type = PanelType(panel.bl_context)\n        probes = get_probes(include_locked=True, include_linked=True)\n        if len(probes) > 0 and panel_type == PanelType.SCENE:\n            row = layout.row()\n            col = row.box().column()\n            row = col.row()\n            row.label(text=\"Reflection Probes Resolution:\")\n\n            if not context.scene.hubs_component_environment_settings.envMapTexture:\n                row = col.row()\n                row.alert = True\n                row.label(\n                    text=\"No scene environment map found.  Please add an environment map to the environment settings scene component for reflection probes to work in Hubs.\",\n                    icon='ERROR')\n\n            row = col.row()\n            row.prop(context.scene.hubs_scene_reflection_probe_properties,\n                     \"resolution\", text=\"\")\n\n            props = context.scene.hubs_scene_reflection_probe_properties\n            mismatched_probes = 0\n            for probe in probes:\n                envmap = probe.hubs_component_reflection_probe.envMapTexture\n                if envmap:\n                    envmap_resolution = f\"{envmap.size[0]}x{envmap.size[1]}\"\n                    if envmap_resolution != props.resolution:\n                        mismatched_probes += 1\n\n            if mismatched_probes:\n                if props.resolution != props.render_resolution:\n                    row = col.row()\n                    row.alert = True\n                    row.label(text=\"Reflection probe resolution has changed. Bake again to apply the new resolution.\",\n                              icon='ERROR')\n                row = col.row()\n                row.alert = True\n                row.label(text=f\"{mismatched_probes} probes don't match the current resolution.\",\n                          icon='ERROR')\n                row.operator(\"wm.hubs_select_mismatched_reflection_probes\",\n                             text=\"\", icon='RESTRICT_SELECT_OFF')\n\n            row = col.row()\n            row.prop(\n                context.scene.hubs_scene_reflection_probe_properties, \"use_compositor\")\n\n            global bake_mode\n\n            row = col.row()\n            bake_msg = \"Baking...\" if probe_baking and bake_mode == 'ALL' else \"Bake All\"\n            bake_op = row.operator(\n                \"render.hubs_render_reflection_probe\",\n                text=bake_msg\n            )\n            bake_op.bake_mode = 'ALL'\n            bake_msg = \"Baking...\" if probe_baking and bake_mode == 'SELECTED' else \"Bake Selected\"\n            bake_op = row.operator(\n                \"render.hubs_render_reflection_probe\",\n                text=bake_msg\n            )\n            bake_op.bake_mode = 'SELECTED'\n\n            if not hasattr(bpy.context.scene, \"cycles\"):\n                row = col.row()\n                row.alert = True\n                row.label(text=\"Baking requires Cycles addon to be enabled.\",\n                          icon='ERROR')\n\n    @classmethod\n    def poll(cls, panel_type, host, ob=None):\n        return host.type == 'LIGHT_PROBE'\n\n    @staticmethod\n    def register():\n        bpy.utils.register_class(BakeProbeOperator)\n        bpy.utils.register_class(ReflectionProbeSceneProps)\n        bpy.utils.register_class(OpenReflectionProbeEnvMap)\n        bpy.utils.register_class(ImportReflectionProbeEnvMaps)\n        bpy.utils.register_class(ExportReflectionProbeEnvMaps)\n        bpy.utils.register_class(SelectMismatchedReflectionProbes)\n        bpy.types.Scene.hubs_scene_reflection_probe_properties = PointerProperty(\n            type=ReflectionProbeSceneProps)\n        bpy.types.TOPBAR_MT_file_import.append(import_menu_draw)\n        bpy.types.TOPBAR_MT_file_export.append(export_menu_draw)\n        from ...io.gltf_exporter import glTF2ExportUserExtension\n        glTF2ExportUserExtension.add_excluded_property(\"hubs_scene_reflection_probe_properties\")\n\n    @staticmethod\n    def unregister():\n        bpy.utils.unregister_class(BakeProbeOperator)\n        bpy.utils.unregister_class(ReflectionProbeSceneProps)\n        bpy.utils.unregister_class(OpenReflectionProbeEnvMap)\n        bpy.utils.unregister_class(ImportReflectionProbeEnvMaps)\n        bpy.utils.unregister_class(ExportReflectionProbeEnvMaps)\n        bpy.utils.unregister_class(SelectMismatchedReflectionProbes)\n        del bpy.types.Scene.hubs_scene_reflection_probe_properties\n        bpy.types.TOPBAR_MT_file_import.remove(import_menu_draw)\n        bpy.types.TOPBAR_MT_file_export.remove(export_menu_draw)\n        from ...io.gltf_exporter import glTF2ExportUserExtension\n        glTF2ExportUserExtension.remove_excluded_property(\"hubs_scene_reflection_probe_properties\")\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/scale_audio_feedback.py",
    "content": "from bpy.props import FloatProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass ScaleAudioFeedback(HubsComponent):\n    _definition = {\n        'name': 'scale-audio-feedback',\n        'display_name': 'Scale Audio Feedback',\n        'category': Category.AVATAR,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'GRAPH',\n        'version': (1, 0, 0)\n    }\n\n    minScale: FloatProperty(name=\"Min Scale\",\n                            description=\"Min Scale\",\n                            default=1.0)\n\n    maxScale: FloatProperty(name=\"Max Scale\",\n                            description=\"Max Scale\",\n                            default=1.5)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/scene_preview_camera.py",
    "content": "from ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ..gizmos import CustomModelGizmo\nfrom ..models import scene_preview_camera\nfrom mathutils import Matrix\nfrom math import radians\nfrom bpy.types import Operator\nfrom bpy.props import FloatProperty\nimport bpy\nfrom ...utils import rgetattr, rsetattr\n\n\ndef render_post(scene, depsgraph):\n    bpy.context.scene.collection.objects.unlink(camera_object)\n    bpy.data.cameras.remove(camera_data)\n\n    for prop in saved_props:\n        rsetattr(bpy.context, prop, saved_props[prop])\n\n    bpy.app.handlers.render_cancel.remove(render_post)\n    bpy.app.handlers.render_complete.remove(render_post)\n\n\nclass RenderOperator(Operator):\n    bl_idname = \"render.hubs_render\"\n    bl_label = \"Hubs Render\"\n    bl_options = {\"REGISTER\"}\n\n    fov: FloatProperty(name=\"FOV\", min=0, max=radians(180), default=radians(80), subtype=\"ANGLE\", unit=\"ROTATION\")\n\n    def execute(self, context):\n        bpy.app.handlers.render_complete.append(render_post)\n        bpy.app.handlers.render_cancel.append(render_post)\n\n        global camera_data\n        camera_data = bpy.data.cameras.new(name=\"Temp Hubs Camera Data\")\n        camera_data.type = \"PERSP\"\n        camera_data.clip_start = 0.1\n        camera_data.clip_end = 2000\n        camera_data.lens_unit = \"FOV\"\n        camera_data.angle = self.fov\n\n        global camera_object\n        camera_object = bpy.data.objects.new(\"Temp hubs Camera Object\", camera_data)\n        context.scene.collection.objects.link(camera_object)\n        camera_object.matrix_world = context.active_object.matrix_world.copy()\n        rot_offset = Matrix.Rotation(radians(90), 4, 'X')\n        camera_object.matrix_world = camera_object.matrix_world @ rot_offset\n\n        overrides = [\n            (\"preferences.view.render_display_type\", \"NONE\"),\n            (\"scene.camera\", camera_object),\n            (\"scene.render.resolution_x\", 1920),\n            (\"scene.render.resolution_y\", 1080),\n            (\"scene.render.resolution_percentage\", 100),\n            (\"scene.render.image_settings.file_format\", \"PNG\"),\n            (\"scene.render.filepath\", f\"{context.scene.render.filepath}/scene-preview-camera.png\"),\n        ]\n\n        global saved_props\n        saved_props = {}\n        for (prop, value) in overrides:\n            if prop not in saved_props:\n                saved_props[prop] = rgetattr(bpy.context, prop)\n            rsetattr(bpy.context, prop, value)\n\n        bpy.ops.render.render(\"INVOKE_DEFAULT\", write_still=True)\n\n        return {'FINISHED'}\n\n\nclass ScenePreviewCamera(HubsComponent):\n    _definition = {\n        'name': 'scene-preview-camera',\n        'display_name': 'Scene Preview Camera',\n        'category': Category.SCENE,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT],\n        'icon': 'CAMERA_DATA',\n        'version': (1, 0, 0)\n    }\n\n    fov: FloatProperty(name=\"FOV\", min=0, max=radians(180), default=radians(80), subtype=\"ANGLE\", unit=\"ROTATION\")\n\n    def pre_export(self, export_settings, host, ob=None):\n        global backup_name\n        backup_name = host.name\n        host.name = 'scene-preview-camera'\n\n    def post_export(self, export_settings, host, ob=None):\n        global backup_name\n        host.name = backup_name\n        backup_name = \"\"\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        mat = ob.matrix_world.copy()\n\n        rot_offset = Matrix.Rotation(radians(180), 4, 'Z')\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat @ rot_offset\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", scene_preview_camera.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n\n    def draw(self, context, layout, panel):\n        row = layout.row()\n        row.prop(data=self, property=\"fov\")\n        row = layout.row()\n        op = row.operator(\"render.hubs_render\", text=\"Render Preview Camera\")\n        op.fov = self.fov\n\n    @staticmethod\n    def register():\n        bpy.utils.register_class(RenderOperator)\n\n    @staticmethod\n    def unregister():\n        bpy.utils.unregister_class(RenderOperator)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/shadow.py",
    "content": "from bpy.props import BoolProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, NodeType, PanelType\n\n\nclass Shadow(HubsComponent):\n    _definition = {\n        'name': 'shadow',\n        'display_name': 'Shadow',\n        'category': Category.OBJECT,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT],\n        'icon': 'MOD_MASK',\n        'version': (1, 0, 0)\n    }\n\n    cast: BoolProperty(\n        name=\"Cast Shadow\", description=\"Cast shadow\", default=True)\n\n    receive: BoolProperty(\n        name=\"Receive Shadow\", description=\"Receive shadow\", default=True)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/simple_water.py",
    "content": "from bpy.props import FloatVectorProperty, FloatProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, NodeType, PanelType\n\n\nclass SimpleWater(HubsComponent):\n    _definition = {\n        'name': 'simple-water',\n        'display_name': 'Simple Water',\n        'category': Category.ELEMENTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'MOD_FLUIDSIM',\n        'version': (1, 0, 0)\n    }\n\n    color: FloatVectorProperty(name=\"Color\",\n                               description=\"Color\",\n                               subtype='COLOR_GAMMA',\n                               default=(1.0, 1.0, 1.0, 1.0),\n                               size=4,\n                               min=0,\n                               max=1)\n\n    opacity: FloatProperty(name=\"Opacity\",\n                           description=\"Opacity\",\n                           default=1.0)\n\n    tideHeight: FloatProperty(name=\"Tide Height\",\n                              description=\"Tide Height\",\n                              default=0.01)\n\n    tideScale: FloatVectorProperty(name=\"Tide Scale\",\n                                   description=\"Tide Scale\",\n                                   size=2,\n                                   unit=\"LENGTH\",\n                                   subtype=\"XYZ\",\n                                   default=[1.0, 1.0])\n\n    tideSpeed: FloatVectorProperty(name=\"Tide Speed\",\n                                   description=\"Tide Speed\",\n                                   size=2,\n                                   unit=\"VELOCITY\",\n                                   subtype=\"XYZ\",\n                                   default=[0.5, 0.5])\n\n    waveHeight: FloatProperty(name=\"Wave Height\",\n                                   default=1.0)\n\n    waveScale: FloatVectorProperty(name=\"Wave Scale\",\n                                   description=\"Wave Scale\",\n                                   size=2,\n                                   unit=\"LENGTH\",\n                                   subtype=\"XYZ\",\n                                   default=[1.0, 20.0])\n\n    waveSpeed: FloatVectorProperty(name=\"Wave Speed\",\n                                   description=\"Wave Speed\",\n                                   size=2,\n                                   unit=\"VELOCITY\",\n                                   subtype=\"XYZ\",\n                                   default=[0.05, 6.0])\n\n    ripplesSpeed: FloatProperty(name=\"Ripples Speed\",\n                                default=0.25)\n\n    ripplesScale: FloatProperty(name=\"Ripples Scale\",\n                                default=1.0)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/skybox.py",
    "content": "from bpy.props import FloatProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass Skybox(HubsComponent):\n    _definition = {\n        'name': 'skybox',\n        'display_name': 'Skybox',\n        'category': Category.SCENE,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'MAT_SPHERE_SKY',\n        'version': (1, 0, 0)\n    }\n\n    azimuth: FloatProperty(name=\"Time of Day\",\n                           description=\"Time of Day\",\n                           default=0.15)\n\n    inclination: FloatProperty(name=\"Latitude\",\n                               description=\"Latitude\",\n                               default=0.0)\n\n    luminance: FloatProperty(name=\"Luminance\",\n                             description=\"Luminance\",\n                             default=1.0)\n\n    mieCoefficient: FloatProperty(name=\"Scattering Amount\",\n                                  description=\"Scattering Amount\",\n                                  default=0.005)\n\n    mieDirectionalG: FloatProperty(name=\"Scattering Distance\",\n                                   description=\"Scattering Distance\",\n                                   default=0.8)\n\n    turbidity: FloatProperty(name=\"Horizon Start\",\n                                  description=\"Horizon Start\",\n                                  default=10.0)\n\n    rayleigh: FloatProperty(name=\"Horizon End\",\n                            description=\"Horizon End\",\n                            default=2.0)\n\n    distance: FloatProperty(name=\"Distance\",\n                            description=\"Distance\",\n                            default=8000.0)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/spawner.py",
    "content": "import bpy\nfrom bpy.props import StringProperty, BoolProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ...io.utils import import_component, assign_property\n\n\nclass Spawner(HubsComponent):\n    _definition = {\n        'name': 'spawner',\n        'display_name': 'Spawner',\n        'category': Category.ELEMENTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'MOD_PARTICLE_INSTANCE',\n        'version': (1, 0, 0)\n    }\n\n    src: StringProperty(\n        name=\"Model Source\", description=\"The web address (URL) of the glTF to be spawned\",\n        default=\"https://example.org/ModelFile.glb\")\n\n    applyGravity: BoolProperty(\n        name=\"Apply Gravity\", description=\"Apply gravity to spawned object\", default=False)\n\n    def gather(self, export_settings, object):\n        return {\n            'src': self.src,\n            'mediaOptions': {\n                'applyGravity': self.applyGravity\n            }\n        }\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            try:\n                self.applyGravity = self[\n                    'mediaOptions']['applyGravity']\n            except Exception:  # applyGravity was never saved, so it must have been left on the default value: False.\n                self.applyGravity = False\n\n        return migration_occurred\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        blender_component = import_component(\n            component_name, blender_host)\n\n        for property_name, property_value in component_value.items():\n            if property_name == 'mediaOptions':\n                setattr(blender_component, \"applyGravity\",\n                        property_value[\"applyGravity\"])\n            else:\n                assign_property(gltf.vnodes, blender_component,\n                                property_name, property_value)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/spoke/background.py",
    "content": "from ....io.utils import import_component, set_color_from_hex\nfrom ...hubs_component import HubsComponent\nfrom ...types import NodeType\n\n\nclass Background(HubsComponent):\n    _definition = {\n        'name': 'background',\n        'display_name': 'Background',\n        'node_type': NodeType.SCENE\n    }\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        blender_component = import_component(\n            'environment-settings', blender_host)\n        blender_component.toneMapping = \"LinearToneMapping\"\n        set_color_from_hex(blender_component, \"backgroundColor\", component_value['color'])\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/spoke/box_collider.py",
    "content": "from ...types import NodeType\nfrom ...hubs_component import HubsComponent\nfrom ....io.utils import assign_property, import_component\nimport bpy\n\n\nclass BoxCollider(HubsComponent):\n    _definition = {\n        'name': 'box-collider'\n    }\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        blender_component = import_component('ammo-shape', blender_host)\n        assign_property(gltf.vnodes, blender_component,\n                        \"type\", 'box')\n        assign_property(gltf.vnodes, blender_component,\n                        \"fit\", 'manual')\n\n        # These settings don't get applied when set as normal here, so use a timer to set them later.\n        def set_half_extents_and_offsets():\n            loc, _, scale = blender_host.matrix_world.decompose()\n            blender_component.halfExtents[0] = scale[0] / 2\n            blender_component.halfExtents[1] = scale[2] / 2\n            blender_component.halfExtents[2] = scale[1] / 2\n            blender_component.offset[0] = loc[0]\n            blender_component.offset[1] = loc[2]\n            blender_component.offset[2] = -loc[1]\n        bpy.app.timers.register(set_half_extents_and_offsets)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/spoke/spawn_point.py",
    "content": "from ...types import NodeType\nfrom ...hubs_component import HubsComponent\nfrom ...utils import add_component\nfrom ....io.utils import assign_property, import_component\n\n\nclass SpawnPoint(HubsComponent):\n    _definition = {\n        'name': 'spawn-point'\n    }\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        blender_component = import_component('waypoint', blender_host)\n        assign_property(gltf.vnodes, blender_component,\n                        \"canBeSpawnPoint\", True)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/spot_light.py",
    "content": "from ..models import spot_light\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world, update_gizmos\nfrom bpy.props import FloatVectorProperty, FloatProperty, BoolProperty, IntVectorProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom math import pi\n\n\nclass SpotLight(HubsComponent):\n    _definition = {\n        'name': 'spot-light',\n        'display_name': 'Spot Light',\n        'category': Category.LIGHTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'LIGHT_SPOT',\n        'version': (1, 0, 0)\n    }\n\n    color: FloatVectorProperty(name=\"Color\",\n                               description=\"Color\",\n                               subtype='COLOR_GAMMA',\n                               default=(1.0, 1.0, 1.0, 1.0),\n                               size=4,\n                               min=0,\n                               max=1,\n                               update=lambda self, context: update_gizmos())\n\n    intensity: FloatProperty(name=\"Intensity\",\n                             description=\"Intensity\",\n                             default=1.0)\n\n    range: FloatProperty(name=\"Range\",\n                         description=\"Range\",\n                         default=0.0)\n\n    decay: FloatProperty(name=\"Decay\",\n                         description=\"Decay\",\n                         default=1.0)\n\n    innerConeAngle: FloatProperty(\n        name=\"Cone Inner Angle\",\n        description=\"A double value describing the angle, in degrees, of a cone inside of which there will be no volume reduction\",\n        subtype=\"ANGLE\",\n        default=0.0,\n        min=0.0,\n        max=pi / 2)\n\n    outerConeAngle: FloatProperty(\n        name=\"Cone Outer Angle\",\n        description=\"A double value describing the angle, in degrees, of a cone outside of which the volume will be reduced by a constant value, defined by the coneOuterGain attribute\",\n        subtype=\"ANGLE\",\n        default=pi / 4,\n        min=0.0,\n        max=pi / 2)\n\n    decay: FloatProperty(name=\"Decay\",\n                         description=\"Decay\",\n                         default=2.0)\n\n    castShadow: BoolProperty(\n        name=\"Cast Shadow\", description=\"Cast Shadow\", default=True)\n\n    shadowMapResolution: IntVectorProperty(name=\"Shadow Map Resolution\",\n                                           description=\"Shadow Map Resolution\",\n                                           size=2,\n                                           default=[512, 512])\n\n    shadowBias: FloatProperty(name=\"Shadow Bias\",\n                              description=\"Shadow Bias\",\n                              default=0.0)\n\n    shadowRadius: FloatProperty(name=\"Shadow Radius\",\n                                description=\"Shadow Radius\",\n                                default=1.0)\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", spot_light.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = getattr(ob, cls.get_id()).color[:3]\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/text.py",
    "content": "from bpy.props import FloatProperty, EnumProperty, FloatVectorProperty, StringProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ...io.utils import gather_property, assign_property, import_component\n\nSPOKE_PROPS_TO_FIX = ['outlineBlur', 'outlineOffsetX',\n                      'outlineOffsetY', 'outlineWidth', 'strokeWidth']\n\n\nclass Text(HubsComponent):\n    _definition = {\n        'name': 'text',\n        'display_name': 'Text',\n        'category': Category.ELEMENTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'FONT_DATA',\n        'version': (1, 1, 0)\n    }\n\n    value: StringProperty(\n        name=\"Text\",\n        description=\"The string of text to be rendered. Newlines and repeating whitespace characters are honored\",\n        default=\"Hello world!\")\n\n    fontSize: FloatProperty(\n        name=\"Font Size\",\n        description=\"Font size, in local meters\",\n        unit='LENGTH',\n        default=0.075)\n\n    textAlign: EnumProperty(\n        name=\"Alignment\",\n        description=\"The horizontal alignment of each line of text within the overall text bounding box\",\n        items=[(\"left\", \"Left\", \"Text will be aligned to the left\"),\n               (\"right\", \"Right\", \"Text will be aligned to the right\"),\n               (\"center\", \"Center\", \"Text will be centered\"),\n               (\"justify\", \"Justify\", \"Text will be justified\")],\n        default=\"left\")\n\n    anchorX: EnumProperty(\n        name=\"Anchor X\",\n        description=\"Defines the horizontal position in the text block that should line up with the local origin\",\n        items=[(\"left\", \"Left\", \"Left side of the text will be at the pivot point of this object\"),\n               (\"center\", \"Center\",\n                \"Center of the text will be at the pivot point of this object\"),\n               (\"right\", \"Right\", \"Right side of the text will be at the pivot point of this object\")],\n        default=\"center\")\n\n    anchorY: EnumProperty(\n        name=\"Anchor Y\",\n        description=\"Defines the vertical position in the text block that should line up with the local origin\",\n        items=[(\"top\", \"Top\", \"Top of the text will be at the pivot point of this object\"),\n               (\"top-baseline\", \"Top Baseline\",\n                \"Top baseline of the text will be at the pivot point of this object\"),\n               (\"middle\", \"Middle\",\n                \"Middle of the text will be at the pivot point of this object\"),\n               (\"bottom-baseline\", \"Bottom Baseline\",\n                \"Bottom baseline of the text will be at the pivot point of this object\"),\n               (\"bottom\", \"Bottom\", \"Bottom of the text will be at the pivot point of this object\")],\n        default=\"middle\")\n\n    color: FloatVectorProperty(name=\"Color\",\n                               description=\"Color\",\n                               subtype='COLOR_GAMMA',\n                               default=(1.0, 1.0, 1.0, 1.0),\n                               size=4,\n                               min=0,\n                               max=1)\n\n    letterSpacing: FloatProperty(\n        name=\"Letter Space\",\n        description=\"Sets a uniform adjustment to spacing between letters after kerning is applied, in local meters. Positive numbers increase spacing and negative numbers decrease it\",\n        unit='LENGTH',\n        default=0.0)\n\n    clipRectMin: FloatVectorProperty(\n        name=\"Clip Rect Min\",\n        description=\"This defines the X and Y coordinate of the bottom left corner of a rectangle outside of which you won't be able to see that part of the text anymore. Setting all the Clip Rect values to zero disables\",\n        subtype='XYZ', size=2, default=(0.0, 0.0))\n\n    clipRectMax: FloatVectorProperty(\n        name=\"Clip Rect Max\",\n        description=\"This defines the X and Y coordinate of the top right corner of a rectangle outside of which you won't be able to see that part of the text anymore. Setting all the Clip Rect values to zero disables\",\n        subtype='XYZ', size=2, default=(0.0, 0.0))\n\n    lineHeight: FloatProperty(\n        name=\"Line Height\",\n        description=\"Sets the height of each line of text. If 0, a reasonable height based on the chosen font's ascender/descender metrics will be used, otherwise it is interpreted as a multiple of the fontSize\",\n        default=0.0)\n\n    outlineWidth: StringProperty(\n        name=\"Outline Width\",\n        description=\"The width of an outline/halo to be drawn around each text glyph using the outlineColor and outlineOpacity. This can help improve readability when the text is displayed against a background of low or varying contrast.\\n\\n The width can be specified as either an absolute number in local units, or as a percentage string e.g. \\\"10%\\\" which is interpreted as a percentage of the fontSize\",\n        default=\"0\")\n\n    outlineColor: FloatVectorProperty(\n        name=\"Outline Color\",\n        description=\"The color to use for the text outline when outlineWidth, outlineBlur, and/or outlineOffsetX/Y are set\",\n        subtype='COLOR_GAMMA', default=(0.0, 0.0, 0.0, 1.0),\n        size=4, min=0, max=1)\n\n    outlineBlur: StringProperty(name=\"Outline Blur\",\n                                description=\"Specifies a blur radius applied to the outer edge of the text's outlineWidth. If the outlineWidth is zero, the blur will be applied at the glyph edge, like CSS's text-shadow blur radius. A blur plus a nonzero outlineWidth can give a solid outline with a fuzzy outer edge.\\n\\nThe blur radius can be specified as either an absolute number in local meters, or as a percentage string e.g. \\\"12%\\\" which is treated as a percentage of the fontSize\",\n                                default=\"0\")\n\n    outlineOffsetX: StringProperty(\n        name=\"Outline X Offset\",\n        description=\"This defines a horizontal offset of the text outline. Using an offset with outlineWidth: 0 creates a drop-shadow effect like CSS's text-shadow; also see outlineBlur.\\n\\n The offsets can be specified as either an absolute number in local units, or as a percentage string e.g. \\\"12%\\\" which is treated as a percentage of the fontSize\",\n        default=\"0\")\n\n    outlineOffsetY: StringProperty(\n        name=\"Outline Y Offset\",\n        description=\"This defines a vertical offset of the text outline. Using an offset with outlineWidth: 0 creates a drop-shadow effect like CSS's text-shadow; also see outlineBlur.\\n\\n The offsets can be specified as either an absolute number in local units, or as a percentage string e.g. \\\"12%\\\" which is treated as a percentage of the fontSize\",\n        default=\"0\")\n\n    outlineOpacity: FloatProperty(\n        name=\"Outline Opacity\",\n        description=\"Sets the opacity of a configured text outline, in the range 0 to 1\",\n        min=0.0,\n        max=1.0,\n        default=1.0)\n\n    fillOpacity: FloatProperty(\n        name=\"Fill Opacity\",\n        description=\"Controls the opacity of just the glyph's fill area, separate from any configured strokeOpacity, outlineOpacity, and the material's opacity. A fillOpacity of 0 will make the fill invisible, leaving just the stroke and/or outline\",\n        min=0.0,\n        max=1.0,\n        default=1.0)\n\n    strokeWidth: StringProperty(\n        name=\"Stroke Width\",\n        description=\"Sets the width of a stroke drawn inside the edge of each text glyph, using the strokeColor and strokeOpacity.\\n\\n The width can be specified as either an absolute number in local units, or as a percentage string e.g. \\\"10%\\\" which is interpreted as a percentage of the fontSize\",\n        default=\"0\")\n\n    strokeColor: FloatVectorProperty(name=\"Stroke Color\",\n                                     description=\"The color of the text stroke, when strokeWidth is nonzero\",\n                                     subtype='COLOR_GAMMA',\n                                     default=(0.0, 0.0, 0.0, 1.0),\n                                     size=4,\n                                     min=0,\n                                     max=1)\n\n    strokeOpacity: FloatProperty(name=\"Stroke Opacity\",\n                                 description=\"The opacity of the text stroke, when strokeWidth is nonzero\",\n                                 min=0.0,\n                                 max=1.0,\n                                 default=1.0)\n\n    textIndent: FloatProperty(\n        name=\"Text Indent\",\n        description=\"An indentation applied to the first character of each hard newline. Behaves like CSS text-indent\",\n        default=0.0)\n\n    whiteSpace: EnumProperty(\n        name=\"Wrapping\",\n        description=\"Defines whether text should wrap when a line reaches the maxWidth\",\n        items=[(\"normal\", \"Normal\", \"Allow wrapping according to the 'wrapping mode'\"),\n               (\"nowrap\", \"No Wrapping\", \"Prevent wrapping\")],\n        default=\"normal\")\n\n    overflowWrap: EnumProperty(\n        name=\"Wrapping Mode\",\n        description=\"Defines how text wraps if the whiteSpace property is 'normal'\",\n        items=[(\"normal\", \"Normal\", \"Break only at whitespace characters\"),\n               (\"break-word\", \"Break Word\", \"Allow breaking within words\")],\n        default=\"normal\")\n\n    opacity: FloatProperty(\n        name=\"Opacity\",\n        description=\"The opacity of the entire text object\",\n        min=0.0,\n        max=1.0,\n        default=1.0)\n\n    side: EnumProperty(\n        name=\"Display Side\",\n        description=\"Defines how text wraps if the whiteSpace property is 'normal'\",\n        items=[(\"front\", \"Show on front\", \"Text will be shown on the front (-Y)\"),\n               (\"back\", \"Show on back\", \"Text will be shown on the back (+Y)\"),\n               (\"double\", \"Show on both\", \"Text will be shown on both sides\")],\n        default=\"front\")\n\n    maxWidth: FloatProperty(\n        name=\"Max Width\",\n        description=\"The maximum width of the text block, above which text may start wrapping according to the whiteSpace and overflowWrap properties\",\n        unit='LENGTH',\n        default=1.0)\n\n    curveRadius: FloatProperty(\n        name=\"Curve Radius\",\n        description=\"Defines a cylindrical radius along which the text's plane will be curved. Positive numbers put the cylinder's centerline (oriented vertically) that distance in front of the text, for a concave curvature, while negative numbers put it behind the text for a convex curvature. The centerline will be aligned with the text's local origin; you can use anchorX to offset it\",\n        unit='LENGTH',\n        default=0.0)\n\n    direction: EnumProperty(\n        name=\"Direction\",\n        description=\"Sets the base direction for the tex\",\n        items=[(\"auto\", \"Auto\", \"Use the default text direction defined by the system and font\"),\n               (\"ltr\", \"Left to Right\", \"Order text left to right\"),\n               (\"rtl\", \"Right to Left\", \"Order text right to left\")],\n        default=\"auto\")\n\n    def gather(self, export_settings, object):\n        component_json = {}\n        clipRect = None\n\n        for key in self.get_properties():\n            if key in [\"clipRectMin\", \"clipRectMax\"]:\n                if clipRect is None and list(self.clipRectMin) + list(self.clipRectMax) != [0, 0, 0, 0]:\n                    clipRect = [\n                        self.clipRectMin.x,\n                        self.clipRectMin.y,\n                        self.clipRectMax.x,\n                        self.clipRectMax.y\n                    ]\n\n                component_json[\"clipRect\"] = clipRect\n                continue\n\n            component_json[key] = gather_property(\n                export_settings, object, self, key)\n\n        return component_json\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        blender_component = import_component(component_name, blender_host)\n\n        for property_name, property_value in component_value.items():\n            if property_name == \"clipRect\":\n                if property_value:\n                    blender_component.clipRectMin = (property_value[0], property_value[1])\n                    blender_component.clipRectMax = (property_value[2], property_value[3])\n                continue\n\n            if property_name in SPOKE_PROPS_TO_FIX:\n                if type(property_value) is int or type(property_value) is float:\n                    property_value = str(property_value)\n\n            assign_property(gltf.vnodes, blender_component,\n                            property_name, property_value)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/uv_scroll.py",
    "content": "from bpy.props import FloatVectorProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass UVScroll(HubsComponent):\n    _definition = {\n        'name': 'uv-scroll',\n        'display_name': 'UV Scroll',\n        'category': Category.ANIMATION,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT],\n        'icon': 'TEXTURE_DATA',\n        'version': (1, 0, 0)\n    }\n\n    speed: FloatVectorProperty(name=\"Speed\",\n                               description=\"Speed\",\n                               size=2,\n                               subtype=\"XYZ\",\n                               default=[0, 0])\n\n    increment: FloatVectorProperty(name=\"Increment\",\n                                   description=\"Increment\",\n                                   size=2,\n                                   subtype=\"XYZ\",\n                                   default=[0, 0])\n\n    @classmethod\n    def poll(cls, panel_type, host, ob=None):\n        return hasattr(ob.data, 'materials')\n\n    def draw(self, context, layout, panel):\n        has_texture = False\n        for material in context.object.data.materials:\n            if material:\n                for node in material.node_tree.nodes:\n                    if node.type == 'TEX_IMAGE' and node.image is not None:\n                        has_texture = True\n\n        super().draw(context, layout, panel)\n        if not has_texture:\n            layout.alert = True\n            layout.label(text='This component requires an image texture',\n                         icon='ERROR')\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/video.py",
    "content": "from ..models import video\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world\nfrom bpy.props import BoolProperty, EnumProperty, StringProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ..consts import PROJECTION_MODE\nfrom .networked import migrate_networked\n\n\nclass Video(HubsComponent):\n    _definition = {\n        'name': 'video',\n        'display_name': 'Video',\n        'category': Category.MEDIA,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'deps': ['networked', 'audio-params'],\n        'icon': 'FILE_MOVIE',\n        'version': (1, 0, 0)\n    }\n\n    src: StringProperty(\n        name=\"Video URL\", description=\"The web address of the video\", default='https://example.org/VideoFile.webm')\n\n    projection: EnumProperty(\n        name=\"Projection\",\n        description=\"Projection\",\n        items=PROJECTION_MODE,\n        default=\"flat\")\n\n    autoPlay: BoolProperty(name=\"Auto Play\",\n                           description=\"Auto Play\",\n                           default=True)\n\n    controls: BoolProperty(\n        name=\"Show controls\",\n        description=\"When enabled, shows play/pause, skip forward/back, and, if the video contains audio, volume controls when hovering your cursor over it in Hubs\",\n        default=True)\n\n    loop: BoolProperty(name=\"Loop\",\n                       description=\"Loop\",\n                       default=True)\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            migrate_networked(host)\n\n        return migration_occurred\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", video.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = (0.8, 0.8, 0.8)\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/video_texture_source.py",
    "content": "from ..utils import children_recursive, get_host_reference_message\nfrom bpy.props import IntVectorProperty, IntProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass VideoTextureSource(HubsComponent):\n    _definition = {\n        'name': 'video-texture-source',\n        'display_name': 'Video Texture Source',\n        'category': Category.MEDIA,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'VIEW_CAMERA',\n        'version': (1, 0, 0)\n    }\n\n    resolution: IntVectorProperty(name=\"Resolution\",\n                                  description=\"Resolution\",\n                                  size=2,\n                                  default=[1280, 720])\n\n    fps: IntProperty(\n        name=\"FPS\", description=\"FPS\", default=15)\n\n    @classmethod\n    def poll(cls, panel_type, host, ob=None):\n        if panel_type == PanelType.OBJECT:\n            return hasattr(\n                host, 'type') and (\n                host.type == 'CAMERA' or\n                [x for x in children_recursive(host) if x.type == \"CAMERA\" and not x.parent_bone])\n        elif panel_type == PanelType.BONE:\n            return [x for x in children_recursive(ob) if x.type == \"CAMERA\" and x.parent_bone == host.name]\n        return False\n\n    @classmethod\n    def get_unsupported_host_message(cls, panel_type, host, ob=None):\n        host_reference = get_host_reference_message(panel_type, host, ob=ob)\n        if panel_type == PanelType.BONE:\n            object_message = \"\"\n        else:\n            object_message = \" aren't cameras themselves and\"\n\n        host_type = panel_type.value\n        message = f\"Warning: Unsupported component on {host_type} {host_reference}, {host_type}s that{object_message} don't have a camera somewhere in their child hierarchy don't support {cls.get_display_name()} components\"\n\n        return message\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/video_texture_target.py",
    "content": "from bpy.props import BoolProperty, PointerProperty, EnumProperty, StringProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\nfrom ..utils import has_component, is_linked\nfrom ..ui import add_link_indicator\nfrom bpy.types import Object\nfrom ...utils import delayed_gather\nfrom .video_texture_source import VideoTextureSource\n\nBLANK_ID = \"pXph8WBzMu9fung\"\n\n\ndef filter_on_component(self, ob):\n    dep_name = VideoTextureSource.get_name()\n    if hasattr(ob, 'type') and ob.type == 'ARMATURE':\n        if ob.mode == 'EDIT':\n            ob.update_from_editmode()\n\n        for bone in ob.data.bones:\n            if has_component(bone, dep_name):\n                return True\n    return has_component(ob, dep_name)\n\n\nbones = []\n\n\ndef get_bones(self, context):\n    global bones\n    bones = []\n    count = 0\n    dep_name = VideoTextureSource.get_name()\n    bones.append((BLANK_ID, \"Select a bone\", \"None\", \"BLANK\", count))\n    count += 1\n\n    if self.srcNode and self.srcNode.mode == 'EDIT':\n        self.srcNode.update_from_editmode()\n\n    found = False\n    if self.srcNode and self.srcNode.type == 'ARMATURE':\n        for bone in self.srcNode.data.bones:\n            if has_component(bone, dep_name):\n                bones.append((bone.name, bone.name, \"\", 'BONE_DATA', count))\n                count += 1\n                if bone.name == self.bone_id:\n                    found = True\n\n    if self.bone_id != BLANK_ID and not found:\n        bones.append(\n            (self.bone_id, self.bone_id, \"\", \"ERROR\", count))\n        count += 1\n\n    return bones\n\n\ndef get_bone(self):\n    global bones\n    list_ids = list(map(lambda x: x[0], bones))\n    if self.bone_id in list_ids:\n        return list_ids.index(self.bone_id)\n    return 0\n\n\ndef set_bone(self, value):\n    global bones\n    list_indexes = list(map(lambda x: x[4], bones))\n    if value in list_indexes:\n        self.bone_id = bones[value][0]\n    else:\n        self.bone_id = BLANK_ID\n\n\nclass VideoTextureTarget(HubsComponent):\n    _definition = {\n        'name': 'video-texture-target',\n        'display_name': 'Video Texture Target',\n        'category': Category.MEDIA,\n        'node_type': NodeType.MATERIAL,\n        'panel_type': [PanelType.MATERIAL],\n        'icon': 'IMAGE_DATA',\n        'version': (1, 0, 0)\n    }\n\n    targetBaseColorMap: BoolProperty(\n        name=\"Override Base Color Map\",\n        description=\"Causes the video texture to be displayed in place of the base color map\", default=True)\n\n    targetEmissiveMap: BoolProperty(\n        name=\"Override Emissive Color Map\",\n        description=\"Causes the video texture to be displayed in place of the emissive map\", default=False)\n\n    srcNode: PointerProperty(\n        name=\"Source\",\n        description=\"The object with a video-texture-source component to pull video from\",\n        type=Object,\n        poll=filter_on_component,\n        update=lambda self, context: setattr(self, 'bone', BLANK_ID))\n\n    bone: EnumProperty(\n        name=\"Bone\",\n        description=\"The bone with a video-texture-source component to pull video from.  If a bone is selected, this will override the object source, otherwise if no bone is selected, the source will be pulled from the object\",\n        items=get_bones,\n        get=get_bone,\n        set=set_bone\n    )\n\n    bone_id: StringProperty(\n        name=\"bone_id\",\n        default=BLANK_ID,\n        options={'HIDDEN'})\n\n    def draw(self, context, layout, panel):\n        dep_name = VideoTextureSource.get_name()\n\n        has_obj_component = False\n        has_bone_component = False\n        row = layout.row(align=True)\n        sub_row = row.row(align=True)\n        sub_row.prop(data=self, property=\"srcNode\")\n        if is_linked(self.id_data):\n            # Manually disable the PointerProperty, needed for Blender 3.2+.\n            sub_row.enabled = False\n        if is_linked(self.srcNode):\n            sub_row = row.row(align=True)\n            sub_row.enabled = False\n            add_link_indicator(sub_row, self.srcNode)\n        if hasattr(self.srcNode, 'type'):\n            has_obj_component = has_component(self.srcNode, dep_name)\n            if self.srcNode.type == 'ARMATURE':\n                layout.prop(data=self, property=\"bone\")\n                if self.bone_id != BLANK_ID and self.bone in self.srcNode.data.bones:\n                    has_bone_component = has_component(\n                        self.srcNode.data.bones[self.bone], dep_name)\n\n        if self.srcNode and self.bone_id == BLANK_ID and not has_obj_component:\n            col = layout.column()\n            col.alert = True\n            col.label(\n                text=f'The selected source doesn\\'t have a {VideoTextureSource.get_display_name()} component',\n                icon='ERROR')\n        elif self.srcNode and self.bone_id != BLANK_ID and not has_bone_component:\n            col = layout.column()\n            col.alert = True\n            col.label(\n                text=f'The selected bone doesn\\'t have a {VideoTextureSource.get_display_name()} component',\n                icon='ERROR')\n\n        layout.prop(data=self, property=\"targetBaseColorMap\")\n        layout.prop(data=self, property=\"targetEmissiveMap\")\n\n        has_material = len(context.object.material_slots) > 0\n        if not has_material:\n            col = layout.column()\n            col.alert = True\n            col.label(text='This component requires a material',\n                      icon='ERROR')\n\n    @delayed_gather\n    def gather(self, export_settings, object):\n        from ...io.utils import gather_joint_property, gather_node_property\n        return {\n            'targetBaseColorMap': self.targetBaseColorMap,\n            'targetEmissiveMap': self.targetEmissiveMap,\n            'srcNode': gather_joint_property(export_settings, self.srcNode, self, 'bone') if self.bone_id != BLANK_ID else gather_node_property(\n                export_settings, object, self, 'srcNode'),\n        }\n\n    @classmethod\n    @delayed_gather\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        super().gather_import(gltf, blender_host, component_name, component_value, import_report, blender_ob=blender_ob)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/visible.py",
    "content": "import bpy\nfrom bpy.props import BoolProperty\nfrom ..hubs_component import HubsComponent\nfrom ..types import Category, PanelType, NodeType\n\n\nclass Visible(HubsComponent):\n    _definition = {\n        'name': 'visible',\n        'display_name': 'Visible',\n        'category': Category.OBJECT,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'icon': 'HIDE_OFF',\n        'version': (1, 0, 0)\n    }\n\n    visible: BoolProperty(name=\"Visible\", default=True)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/definitions/waypoint.py",
    "content": "from ..models import spawn_point\nfrom ..gizmos import CustomModelGizmo, bone_matrix_world\nfrom ..types import Category, PanelType, NodeType\nfrom ..hubs_component import HubsComponent\nfrom bpy.props import BoolProperty\nfrom .networked import migrate_networked\n\n\nclass Waypoint(HubsComponent):\n    _definition = {\n        'name': 'waypoint',\n        'display_name': 'Waypoint',\n        'category': Category.ELEMENTS,\n        'node_type': NodeType.NODE,\n        'panel_type': [PanelType.OBJECT, PanelType.BONE],\n        'gizmo': 'waypoint',\n        'icon': 'spawn-point.png',\n        'deps': ['networked'],\n        'version': (1, 0, 0)\n    }\n\n    canBeSpawnPoint: BoolProperty(\n        name=\"Use As Spawn Point\",\n        description=\"Avatars may be teleported to this waypoint when entering the scene\",\n        default=False)\n\n    canBeOccupied: BoolProperty(\n        name=\"Can Be Occupied\",\n        description=\"After each use, this waypoint will be disabled until the previous user moves away from it\",\n        default=False)\n\n    canBeClicked: BoolProperty(\n        name=\"Clickable\",\n        description=\"This waypoint will be visible in pause mode and clicking on it will teleport you to it\",\n        default=False)\n\n    willDisableMotion: BoolProperty(\n        name=\"Disable Motion\",\n        description=\"Avatars will not be able to move while occupying this waypoint\",\n        default=False)\n\n    willDisableTeleporting: BoolProperty(\n        name=\"Disable Teleporting\",\n        description=\"Avatars will not be able to teleport while occupying this waypoint\",\n        default=False)\n\n    willMaintainInitialOrientation: BoolProperty(\n        name=\"Maintain Initial Orientation\",\n        description=\"Instead of rotating to face the same direction as the waypoint, avatars will maintain the orientation they started with before they teleported\",\n        default=False)\n\n    snapToNavMesh: BoolProperty(\n        name=\"Snap To NavMesh\",\n        description=\"Avatars will move as close as they can to this waypoint but will not leave the ground\",\n        default=False)\n\n    @classmethod\n    def update_gizmo(cls, ob, bone, target, gizmo):\n        if bone:\n            mat = bone_matrix_world(ob, bone)\n        else:\n            mat = ob.matrix_world.copy()\n\n        gizmo.hide = not ob.visible_get()\n        gizmo.matrix_basis = mat\n\n    @classmethod\n    def create_gizmo(cls, ob, gizmo_group):\n        gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)\n        gizmo.object = ob\n        setattr(gizmo, \"hubs_gizmo_shape\", spawn_point.SHAPE)\n        gizmo.setup()\n        gizmo.use_draw_scale = False\n        gizmo.use_draw_modal = False\n        gizmo.color = (0.8, 0.8, 0.8)\n        gizmo.alpha = 0.5\n        gizmo.scale_basis = 1.0\n        gizmo.hide_select = True\n        gizmo.color_highlight = (0.8, 0.8, 0.8)\n        gizmo.alpha_highlight = 1.0\n\n        return gizmo\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        migration_occurred = False\n        if instance_version < (1, 0, 0):\n            migration_occurred = True\n            migrate_networked(host)\n\n        return migration_occurred\n"
  },
  {
    "path": "addons/io_hubs_addon/components/gizmos.py",
    "content": "import bpy\nfrom bpy.types import (Gizmo, GizmoGroup)\nfrom bpy.props import (IntProperty)\nfrom .components_registry import get_component_by_name\nfrom bpy.app.handlers import persistent\nfrom math import radians\nfrom mathutils import Matrix\n\n\ndef gizmo_update(obj, gizmo):\n    gizmo.matrix_basis = obj.matrix_world.normalized()\n\n\ndef bone_matrix_world(ob, bone, scaleOverride=None):\n    loc, rot, scale = bone.matrix.to_4x4().decompose()\n    # Account for bones using Y up\n    rot_offset = Matrix.Rotation(radians(-90), 4, 'X').to_4x4()\n    if scaleOverride:\n        scale = scaleOverride\n    else:\n        scale = scale.xzy\n    final_loc = ob.matrix_world @ Matrix.Translation(loc)\n    final_rot = rot.normalized().to_matrix().to_4x4() @ rot_offset\n    final_scale = Matrix.Diagonal(scale).to_4x4()\n    return final_loc @ final_rot @ final_scale\n\n\nclass CustomModelGizmo(Gizmo):\n    \"\"\"Generic gizmo to render all Hubs custom gizmos\"\"\"\n    bl_idname = \"GIZMO_GT_hba_gizmo\"\n\n    __slots__ = (\n        \"object\",\n        \"hubs_gizmo_shape\",\n        \"custom_shape\",\n    )\n\n    def draw(self, context):\n        self.draw_custom_shape(self.custom_shape)\n\n    def draw_select(self, context, select_id):\n        self.draw_custom_shape(self.custom_shape, select_id=select_id)\n\n    def setup(self):\n        if hasattr(self, \"hubs_gizmo_shape\"):\n            self.custom_shape = self.new_custom_shape(\n                'TRIS', self.hubs_gizmo_shape)\n\n    def invoke(self, context, event):\n        if hasattr(self, \"object\") and context.mode == 'OBJECT':\n            if not event.shift:\n                bpy.ops.object.select_all(action='DESELECT')\n            self.object.select_set(True)\n            bpy.context.view_layer.objects.active = self.object\n\n        return {'RUNNING_MODAL'}\n\n    def modal(self, context, event, tweak):\n        return {'RUNNING_MODAL'}\n\n\nclass HubsGizmoGroup(GizmoGroup):\n    bl_idname = \"OBJECT_GGT_hba_gizmo_group\"\n    bl_label = \"Hubs gizmo group\"\n    bl_space_type = 'VIEW_3D'\n    bl_region_type = 'WINDOW'\n    bl_options = {'3D', 'PERSISTENT', 'SHOW_MODAL_ALL', 'SELECT'}\n\n    has_widgets = False\n    windows_processed = 0\n\n    def add_gizmo(self, ob, host, host_type):\n        for component_item in host.hubs_component_list.items:\n            component_name = component_item.name\n            component_class = get_component_by_name(component_name)\n            if not component_class:\n                continue\n            gizmo = component_class.create_gizmo(host, self)\n            if gizmo:\n                if component_name not in self.widgets:\n                    self.widgets[component_name] = {}\n\n                host_key = ob.name_full + host.name\n                if host_key not in self.widgets[component_name]:\n                    self.widgets[component_name][host_key] = {\n                        'ob': ob,\n                        'host_name': host.name,\n                        'host_type': host_type,\n                        'gizmo': gizmo\n                    }\n\n    def setup(self, context):\n        # A new instance of the gizmo group is instantiated, and setup is called once for each instance, for each open window.\n        self.widgets = {}\n\n        for ob in context.scene.objects:\n            self.add_gizmo(ob, ob, 'OBJECT')\n            if ob.type == 'ARMATURE':\n                if ob.mode == 'EDIT':\n                    for edit_bone in ob.data.edit_bones:\n                        self.add_gizmo(ob, edit_bone, 'BONE')\n                else:\n                    for bone in ob.data.bones:\n                        self.add_gizmo(ob, bone, 'BONE')\n\n        if self.widgets:\n            HubsGizmoGroup.has_widgets = True\n\n        HubsGizmoGroup.windows_processed += 1\n\n        if HubsGizmoGroup.windows_processed == len(context.window_manager.windows):\n            if not HubsGizmoGroup.has_widgets:\n                bpy.app.timers.register(unregister_gizmo_system)\n                return\n\n    def update_gizmo(self, component_name, ob, bone, target, gizmo):\n        component_class = get_component_by_name(component_name)\n        component_class.update_gizmo(ob, bone, target, gizmo)\n\n    def update_object_gizmo(self, component_name, ob, gizmo):\n        self.update_gizmo(component_name, ob, None, ob, gizmo)\n\n    def update_bone_gizmo(self, component_name, ob, bone, pose_bone, gizmo):\n        self.update_gizmo(component_name, ob, pose_bone, bone, gizmo)\n\n    def refresh(self, context):\n        for component_name in self.widgets:\n            component_widgets = self.widgets[component_name].copy()\n            for widget in component_widgets.values():\n                gizmo = widget['gizmo']\n                ob = widget['ob']\n                host_name = widget['host_name']\n\n                try:\n                    if widget['host_type'] == 'BONE':\n                        # https://docs.blender.org/api/current/info_gotcha.html#editbones-posebones-bone-bones\n                        if ob.mode == 'EDIT':\n                            edit_bone = ob.data.edit_bones[host_name]\n                            self.update_bone_gizmo(\n                                component_name, ob, edit_bone, edit_bone, gizmo)\n                        else:\n                            bone = ob.data.bones[host_name]\n                            pose_bone = ob.pose.bones[host_name]\n                            self.update_bone_gizmo(\n                                component_name, ob, bone, pose_bone, gizmo)\n                    else:\n                        self.update_object_gizmo(\n                            component_name, ob, gizmo)\n\n                except (ReferenceError, KeyError):\n                    # ReferenceErrors shouldn't happen, but if objects and widgets have gotten out of sync refresh the whole system.\n                    # KeyErrors can happen when an object's armature is changed, so refresh the whole system for this as well.\n                    bpy.app.timers.register(update_gizmos)\n                    return\n\n\nobjects_count = -1\ngizmo_system_registered = False\nmsgbus_owners = []\n\n\ndef msgbus_callback(*args):\n    update_gizmos()\n\n\n@persistent\ndef undo_post(dummy):\n    update_gizmos()\n\n\n@persistent\ndef redo_post(dummy):\n    update_gizmos()\n\n\n@persistent\ndef depsgraph_update_post(dummy):\n    global objects_count\n    do_gizmo_update = False\n    open_scenes_object_count = 0\n    wm = bpy.context.window_manager\n    for window in wm.windows:\n        open_scenes_object_count += len(window.scene.objects)\n        active_object = window.view_layer.objects.active\n        if active_object:\n            if active_object.type == 'ARMATURE' and active_object.mode == 'EDIT':\n                edited_objects = set(window.view_layer.objects.selected)\n                edited_objects.add(active_object)\n                for ob in edited_objects:\n                    if ob.type != 'ARMATURE':\n                        # edited/selected objects can include objects other armatures.\n                        continue\n                    if len(ob.data.edit_bones) != ob.data.hubs_old_bones_length:\n                        do_gizmo_update = True\n                        ob.data.hubs_old_bones_length = len(ob.data.edit_bones)\n\n    if open_scenes_object_count != objects_count:\n        do_gizmo_update = True\n\n    objects_count = open_scenes_object_count\n\n    if do_gizmo_update:\n        update_gizmos()\n\n\n@persistent\ndef load_post(dummy):\n    global objects_count\n    objects_count = -1\n    unregister_gizmo_system()\n    register_gizmo_system()\n\n\ndef register_gizmo_system():\n    global gizmo_system_registered\n    global msgbus_owners\n\n    if undo_post not in bpy.app.handlers.undo_post:\n        bpy.app.handlers.undo_post.append(\n            undo_post)\n    if redo_post not in bpy.app.handlers.redo_post:\n        bpy.app.handlers.redo_post.append(\n            redo_post)\n\n    for bonetype in [bpy.types.Bone, bpy.types.EditBone]:\n        owner = object()\n        msgbus_owners.append(owner)\n        bpy.msgbus.subscribe_rna(\n            key=(bonetype, \"name\"),\n            owner=owner,\n            args=(bpy.context,),\n            notify=msgbus_callback,\n        )\n\n    register_gizmos()\n    gizmo_system_registered = True\n\n\ndef register_gizmos():\n    try:\n        HubsGizmoGroup.has_widgets = False\n        HubsGizmoGroup.windows_processed = 0\n        bpy.utils.register_class(CustomModelGizmo)\n        bpy.utils.register_class(HubsGizmoGroup)\n    except Exception:\n        pass\n\n\ndef unregister_gizmo_system():\n    global gizmo_system_registered\n    global msgbus_owners\n\n    if undo_post in bpy.app.handlers.undo_post:\n        bpy.app.handlers.undo_post.remove(\n            undo_post)\n    if redo_post in bpy.app.handlers.redo_post:\n        bpy.app.handlers.redo_post.remove(\n            redo_post)\n\n    for owner in msgbus_owners:\n        bpy.msgbus.clear_by_owner(owner)\n    msgbus_owners.clear()\n\n    unregister_gizmos()\n    gizmo_system_registered = False\n\n\ndef unregister_gizmos():\n    try:\n        bpy.utils.unregister_class(HubsGizmoGroup)\n        bpy.utils.unregister_class(CustomModelGizmo)\n    except Exception:\n        pass\n\n\ndef update_gizmos():\n    global gizmo_system_registered\n    unregister_gizmos()\n    register_gizmos() if gizmo_system_registered else register_gizmo_system()\n\n\ndef register_functions():\n    def register():\n        global objects_count\n        objects_count = -1\n\n        if load_post not in bpy.app.handlers.load_post:\n            bpy.app.handlers.load_post.append(load_post)\n        if depsgraph_update_post not in bpy.app.handlers.depsgraph_update_post:\n            bpy.app.handlers.depsgraph_update_post.append(\n                depsgraph_update_post)\n\n        bpy.types.Armature.hubs_old_bones_length = IntProperty(\n            options={'HIDDEN', 'SKIP_SAVE'})\n\n        register_gizmo_system()\n\n    def unregister():\n        if load_post in bpy.app.handlers.load_post:\n            bpy.app.handlers.load_post.remove(load_post)\n        if depsgraph_update_post in bpy.app.handlers.depsgraph_update_post:\n            bpy.app.handlers.depsgraph_update_post.remove(\n                depsgraph_update_post)\n\n        unregister_gizmo_system()\n\n        del bpy.types.Armature.hubs_old_bones_length\n\n    return register, unregister\n\n\nregister, unregister = register_functions()\n"
  },
  {
    "path": "addons/io_hubs_addon/components/handlers.py",
    "content": "import bpy\nfrom bpy.app.handlers import persistent\nfrom .components_registry import get_components_registry\nfrom .utils import redirect_c_stdout, get_host_components, is_linked, get_host_reference_message, has_component\nfrom .gizmos import update_gizmos\nfrom .types import MigrationType, PanelType\nimport io\nimport sys\nimport traceback\n\nprevious_undo_steps_dump = \"\"\nprevious_undo_step_index = 0\nprevious_window_setups = []\nfile_loading = False\nmsgbus_owners = []\nobject_data_switched = False\n\n\ndef migrate(component, migration_type, panel_type, host, migration_report, ob=None):\n    instance_version = tuple(component.instance_version)\n    definition_version = component.__class__.get_definition_version()\n    was_migrated = False\n\n    if instance_version < definition_version:\n        was_migrated = component.migrate(\n            migration_type, panel_type, instance_version, host, migration_report, ob=ob)\n\n        if type(was_migrated) is not bool:\n            print(f\"Warning: the {component.get_display_name()} component didn't return whether a migration occurred.\")\n            # Fall back to assuming there was a migration since the version increased.\n            was_migrated = True\n\n        component.instance_version = definition_version\n\n    if instance_version > definition_version:\n        host_reference = get_host_reference_message(panel_type, host, ob=ob)\n        migration_report.append(\n            f\"Warning: The {component.get_display_name()} component on the {panel_type.value} {host_reference} is from a future version v{instance_version} and may not be correct.\")\n\n    try:\n        unsupported_host = panel_type not in component.__class__.get_panel_type(\n        ) or not component.__class__.poll(panel_type, host, ob=ob)\n    except Exception:\n        # The poll likely failed on an armature without an object.\n        unsupported_host = True\n\n    if unsupported_host:\n        message = component.__class__.get_unsupported_host_message(panel_type, host, ob=ob)\n        migration_report.append(message)\n\n    return was_migrated\n\n\ndef migrate_components(\n        migration_type, *, do_beta_versioning=False, do_update_gizmos=True, display_report=True,\n        override_report_title=\"\"):\n    migration_report = []\n    migrated_linked_components = []\n    armature_objects = {}\n    link_migration_occurred = False\n    display_registration_message = False\n\n    if do_beta_versioning:\n        display_registration_message |= handle_beta_versioning()\n\n    for scene in bpy.data.scenes:\n        for component in get_host_components(scene):\n            if not has_component(scene, component.get_name()):\n                # The component was removed in a previous migration\n                continue\n            try:\n                was_migrated = migrate(\n                    component, migration_type, PanelType.SCENE, scene, migration_report)\n            except Exception as e:\n                was_migrated = True\n                error = f\"Error: Migration failed for component {component.get_display_name()} on scene \\\"{scene.name_full}\\\"\"\n                migration_report.append(f\"{error}\\n{e} (See Blender's console for details)\")\n                print(error)\n                traceback.print_exc()\n\n            display_registration_message |= was_migrated\n            if was_migrated and is_linked(scene):\n                link_migration_occurred = True\n                component_info = f\"{component.get_display_name()} component on scene \\\"{scene.name_full}\\\"\"\n                migrated_linked_components.append(component_info)\n\n    for ob in bpy.data.objects:\n        for component in get_host_components(ob):\n            if not has_component(ob, component.get_name()):\n                # The component was removed in a previous migration\n                continue\n            try:\n                was_migrated = migrate(\n                    component, migration_type, PanelType.OBJECT, ob, migration_report, ob=ob)\n            except Exception as e:\n                was_migrated = True\n                error = f\"Error: Migration failed for component {component.get_display_name()} on object \\\"{ob.name_full}\\\"\"\n                migration_report.append(f\"{error}\\n{e} (See Blender's console for details)\")\n                print(error)\n                traceback.print_exc()\n\n            display_registration_message |= was_migrated\n            if was_migrated and is_linked(ob):\n                link_migration_occurred = True\n                component_info = f\"{component.get_display_name()} component on object \\\"{ob.name_full}\\\"\"\n                migrated_linked_components.append(component_info)\n\n        if ob.type == 'ARMATURE':\n            if ob.mode == 'EDIT':\n                ob.update_from_editmode()\n\n            armature_name = ob.data.name_full\n            if armature_name not in armature_objects:\n                # Store the first object to use this armature for later when armatures are migrated (armatures can only be migrated once anyway)\n                armature_objects[armature_name] = ob\n\n    for armature in bpy.data.armatures:\n        ob = armature_objects.get(armature.name_full, armature)\n        for bone in armature.bones:\n            for component in get_host_components(bone):\n                if not has_component(bone, component.get_name()):\n                    # The component was removed in a previous migration\n                    continue\n                try:\n                    was_migrated = migrate(\n                        component, migration_type, PanelType.BONE, bone, migration_report, ob=ob)\n                except Exception as e:\n                    was_migrated = True\n                    error = f\"Error: Migration failed for component {component.get_display_name()} on bone \\\"{bone.name}\\\" in \\\"{ob.name_full}\\\"\"\n                    migration_report.append(f\"{error}\\n{e} (See Blender's console for details)\")\n                    print(error)\n                    traceback.print_exc()\n\n                display_registration_message |= was_migrated\n                if was_migrated and is_linked(ob):\n                    link_migration_occurred = True\n                    component_info = f\"{component.get_display_name()} component on bone \\\"{bone.name}\\\" in \\\"{ob.name_full}\\\"\"\n                    migrated_linked_components.append(component_info)\n\n    for material in bpy.data.materials:\n        for component in get_host_components(material):\n            if not has_component(material, component.get_name()):\n                # The component was removed in a previous migration\n                continue\n            try:\n                was_migrated = migrate(\n                    component, migration_type, PanelType.MATERIAL, material, migration_report)\n            except Exception as e:\n                was_migrated = True\n                error = f\"Error: Migration failed for component {component.get_display_name()} on material \\\"{material.name_full}\\\"\"\n                migration_report.append(f\"{error}\\n{e} (See Blender's console for details)\")\n                print(error)\n                traceback.print_exc()\n\n            display_registration_message |= was_migrated\n            if was_migrated and is_linked(material):\n                link_migration_occurred = True\n                component_info = f\"{component.get_display_name()} component on material \\\"{material.name_full}\\\"\"\n                migrated_linked_components.append(component_info)\n\n    if do_update_gizmos:\n        update_gizmos()\n\n    if link_migration_occurred:\n        migration_report.insert(\n            0,\n            \"WARNING: A MIGRATION WAS PERFORMED ON LINKED COMPONENTS, THIS IS UNSTABLE AND MAY NOT BE PERMANENT.  RESAVE THE LINKED BLEND FILES WITH THE NEW VERSION TO AVOID THIS.\")\n        migration_report.append(\"MIGRATED LINKED COMPONENTS:\")\n        migration_report.extend(migrated_linked_components)\n\n    if migration_type == MigrationType.REGISTRATION and display_registration_message:\n        migration_report.insert(0, \"WARNING: A MIGRATION WAS PERFORMED AFTER ADD-ON REGISTRATION.  AN UNDO STEP HAS BEEN ADDED TO STORE THE RESULTS OF THE MIGRATION.  IF YOU UNDO PAST THIS UNDO STEP YOU WILL HAVE TO INITIATE ANOTHER MIGRATION.\\nRELOADING THE FILE WITH THE ADD-ON ALREADY ENABLED IS ADVISED.\")\n\n    if migration_report and display_report:\n        title = \"Component Migration Report\"\n        if override_report_title:\n            title = override_report_title\n\n        def report_migration():\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=title, report_string='\\n\\n'.join(migration_report))\n        bpy.app.timers.register(report_migration)\n\n\ndef version_beta_components():\n    for scene in bpy.data.scenes:\n        if not is_linked(scene):\n            for component in get_host_components(scene):\n                component.instance_version = (1, 0, 0)\n\n    for ob in bpy.data.objects:\n        if not is_linked(ob):\n            for component in get_host_components(ob):\n                component.instance_version = (1, 0, 0)\n            if ob.type == 'ARMATURE':\n                for bone in ob.data.bones:\n                    for component in get_host_components(bone):\n                        component.instance_version = (1, 0, 0)\n\n    for material in bpy.data.materials:\n        if not is_linked(material):\n            for component in get_host_components(material):\n                component.instance_version = (1, 0, 0)\n\n\ndef handle_beta_versioning():\n    did_versioning = False\n    extension_properties = bpy.context.scene.HubsComponentsExtensionProperties\n    if extension_properties:\n        file_version = extension_properties.get('version')\n        if file_version:\n            if tuple(file_version) == (1, 0, 0):\n                did_versioning = True\n                version_beta_components()\n\n            del bpy.context.scene.HubsComponentsExtensionProperties['version']\n\n    return did_versioning\n\n\n@persistent\ndef load_post(dummy):\n    global previous_undo_steps_dump\n    global previous_undo_step_index\n    global previous_window_setups\n    global file_loading\n    previous_undo_steps_dump = \"\"\n    previous_undo_step_index = 0\n    previous_window_setups = []\n    file_loading = True\n\n    migrate_components(MigrationType.GLOBAL, do_beta_versioning=True)\n    register_msgbus()\n\n\ndef find_active_undo_step_index(undo_steps):\n    index = 0\n    for step in undo_steps:\n        if \"[*\" in step:\n            return index\n\n        index += 1\n\n    return None\n\n\n@persistent\ndef undo_stack_handler(dummy, depsgraph):\n    global previous_undo_steps_dump\n    global previous_undo_step_index\n    global file_loading\n    global object_data_switched\n\n    # Return if Blender isn't in a fully loaded state. (Prevents Blender crashing)\n    if file_loading:\n        if not bpy.context.space_data:\n            return\n\n        file_loading = False\n\n    # Get a representation of the undo stack.\n    binary_stream = io.BytesIO()\n\n    with redirect_c_stdout(binary_stream):\n        bpy.context.window_manager.print_undo_steps()\n\n    undo_steps_dump = binary_stream.getvalue().decode(sys.stdout.encoding)\n    binary_stream.close()\n\n    if undo_steps_dump == previous_undo_steps_dump:\n        # The undo stack hasn't changed, so return early.  Note: this prevents modal operators (and anything else) from triggering things repeatedly when nothing has changed.\n        return\n\n    # Convert the undo stack representation into a list of undo steps (removing the unneeded header and footer in the process) and find the active undo step index.\n    undo_steps = undo_steps_dump.split(\"\\n\")[1:-1]\n    undo_step_index = find_active_undo_step_index(undo_steps)\n\n    # Get the interim undo steps that need to be processed (can be more than one) and whether the change has been forward ('DO') or backward ('UNDO').  'UNDO' includes the previous index, while 'DO' does not.\n    try:\n        if undo_step_index < previous_undo_step_index:  # UNDO\n            start = previous_undo_step_index\n            stop = undo_step_index\n            interim_undo_steps = [undo_steps[i] for i in range(start, stop, -1)]\n            step_type = 'UNDO'\n        else:  # DO\n            start = previous_undo_step_index + 1\n            stop = undo_step_index\n            interim_undo_steps = [undo_steps[i] for i in range(start, stop)]\n            step_type = 'DO'\n\n    except Exception:  # Fall back to just processing the current undo step.\n        print(\"Warning: Couldn't get the full range of undo steps to process.  Falling back to the current one.\")\n        interim_undo_steps = []\n        step_type = 'DO'\n\n    # Multiple undo steps/operations are being processed at once in this handler, so allow tasks to be combined into one that is executed at the end.  This also allows performance heavy tasks to be run as little as possible.  In general, any actual work performed should be scheduled as a task.\n    task_scheduler = set()\n    # task options\n    display_report = False\n\n    # Handle the undo steps that have passed since the previous time this executed. This accounts for steps undone, users jumping around in the history ,and any updates that might have been missed.\n    for undo_step in interim_undo_steps:\n        step_name = undo_step.split(\"name=\")[-1][1:-1]\n\n        if step_type == 'DO' and step_name in {'Link'}:\n            # Components need to be migrated after they are linked, but don't need to be remigrated when returning to the link step, and don't store the migrated values in subsequent undo steps until after they have been made local.\n            task_scheduler.add('migrate_components')\n            display_report = False\n\n        if step_type == 'UNDO' and step_name in {'Make Local', 'Localized Data'}:\n            # Components need to be migrated again if they are returned to a linked state.\n            task_scheduler.add('migrate_components')\n            display_report = False\n            task_scheduler.add('update_gizmos')\n\n        if step_type == 'UNDO' and step_name in {'Delete', 'Unlink Object'}:\n            # Linked components need to be migrated again if their removal was undone.\n            task_scheduler.add('migrate_components')\n            display_report = False\n\n        if step_name in {'Add Hubs Component', 'Remove Hubs Component'}:\n            task_scheduler.add('update_gizmos')\n\n    # If the user has jumped ahead/back multiple undo steps, update the gizmos in case the number of objects/bones in the scene has remained the same, but gizmo objects have been added/removed.\n    if abs(previous_undo_step_index - undo_step_index) > 1:\n        task_scheduler.add('update_gizmos')\n\n    # Handle the active undo step.  Migrations (or anything that modifies blend data) need to be handled here because the undo step in which they occurred holds the unmodified data, so the modifications need to be applied each time it becomes active.\n    active_step_name = undo_steps[undo_step_index].split(\"name=\")[-1][1:-1]\n\n    if step_type == 'DO' and active_step_name in {'Link'}:\n        # Components need to be migrated after they are linked, but don't need to be remigrated when returning to the link step, and don't store the migrated values in subsequent undo steps until after they have been made local.\n        task_scheduler.add('migrate_components')\n        display_report = True\n\n    if step_type == 'DO' and active_step_name in {'Add Hubs Component', 'Remove Hubs Component'}:\n        task_scheduler.add('update_gizmos')\n\n    if active_step_name in {'Append'}:\n        task_scheduler.add('migrate_components')\n        display_report = (step_type == 'DO')\n\n    # Handle specific depsgraph updates.\n    if depsgraph.id_type_updated('ARMATURE') and object_data_switched:\n        # Update gizmos when switching the armature for an object.\n        object_data_switched = False\n        task_scheduler.add('update_gizmos')\n\n    # Execute the scheduled tasks.\n    # Note: Blender seems to somehow be caching calls to update_gizmos, so having it as a scheduled task may not affect performance.  Calls to migrate_components are not cached by Blender.\n    for task in task_scheduler:\n        if task == 'update_gizmos':\n            update_gizmos()\n        elif task == 'migrate_components':\n            migrate_components(MigrationType.LOCAL, do_update_gizmos=False, display_report=display_report,\n                               override_report_title=\"Append/Link: Component Migration Report\")\n        else:\n            print('Error: unrecognized task scheduled')\n\n    # Store things for comparison next time.\n    previous_undo_steps_dump = undo_steps_dump\n    previous_undo_step_index = undo_step_index\n\n\ndef scene_and_view_layer_update_notifier(self, context):\n    \"\"\"Some scene/view layer actions/changes don't trigger a depsgraph update so watch the top bar for changes to the scene or view layer by hooking into it's draw method.  Known actions that don't trigger a depsgraph update:\n    - Creating a new scene.\n    - Switching the scene.\n    - Creating a new view layer.\n    - Switching the view layer - if the last action was also a view layer switch\"\"\"\n    global previous_window_setups\n    wm = context.window_manager\n    current_window_setups = [w.scene.name + w.view_layer.name for w in wm.windows]\n    if sorted(current_window_setups) != sorted(previous_window_setups):\n        bpy.app.timers.register(update_gizmos)\n        previous_window_setups = current_window_setups\n\n\ndef register_msgbus():\n    global msgbus_owners\n    owner = object()\n    msgbus_owners.append(owner)\n\n    def msgbus_update(*args):\n        global object_data_switched\n        object_data_switched = True\n\n    bpy.msgbus.subscribe_rna(\n        key=(bpy.types.Object, \"data\"),\n        owner=owner,\n        args=(bpy.context,),\n        notify=msgbus_update,\n    )\n\n\ndef register():\n    global previous_undo_steps_dump\n    global previous_undo_step_index\n    global previous_window_setups\n    previous_undo_steps_dump = \"\"\n    previous_undo_step_index = 0\n    previous_window_setups = []\n\n    if load_post not in bpy.app.handlers.load_post:\n        bpy.app.handlers.load_post.append(load_post)\n\n    # Calling undo_stack_handler in background mode causes a segmentation fault so we skip in that mode.\n    if undo_stack_handler not in bpy.app.handlers.depsgraph_update_post and not bpy.app.background:\n        bpy.app.handlers.depsgraph_update_post.append(undo_stack_handler)\n\n    bpy.types.TOPBAR_HT_upper_bar.append(scene_and_view_layer_update_notifier)\n\n    register_msgbus()\n\n\ndef unregister():\n    global msgbus_owners\n\n    if load_post in bpy.app.handlers.load_post:\n        bpy.app.handlers.load_post.remove(load_post)\n\n    if undo_stack_handler in bpy.app.handlers.depsgraph_update_post and not bpy.app.background:\n        bpy.app.handlers.depsgraph_update_post.remove(undo_stack_handler)\n\n    bpy.types.TOPBAR_HT_upper_bar.remove(scene_and_view_layer_update_notifier)\n\n    for owner in msgbus_owners:\n        bpy.msgbus.clear_by_owner(owner)\n    msgbus_owners.clear()\n"
  },
  {
    "path": "addons/io_hubs_addon/components/hubs_component.py",
    "content": "from bpy.types import PropertyGroup\nfrom bpy.props import IntVectorProperty\nfrom .types import Category, PanelType, NodeType\nfrom ..io.utils import import_component, assign_property\n\n\nclass HubsComponent(PropertyGroup):\n    _definition = {\n        # The name that will be used in the glTF file MOZ_hubs_components object when exporting the component.\n        'name': 'template',\n        # Name to be used in the panels, if not set the component name will be used\n        'display_name': 'Hubs Component Template',\n        # Category that is shown in the \"Add Component\" menu\n        'category': Category.MISC,\n        # Node type to where the component will be registered\n        'node_type': NodeType.NODE,\n        # Panel types where this component will be shown\n        'panel_type': [PanelType.OBJECT],\n        # The dependencies of this component (by id). They will be added as a result of adding this component.\n        'deps': [],\n        # Name of the icon to load. It can be a image file in the icons directory or one of the Blender builtin icons id\n        'icon': 'icon.png',\n        # Version of the component. This will be used to trigger component migrations.\n        'version': (0, 0, 1)\n    }\n\n    # Properties defined here are for internal use and won't be displayed by default in components or exported.\n\n    # The internal version of the component.  This is first set when a component is added and is updated during migrations, if necessary.\n    instance_version: IntVectorProperty(size=3)\n\n    @classmethod\n    def __get_definition(cls, key, default):\n        if key in cls._definition and cls._definition[key]:\n            return cls._definition[key]\n        return default\n\n    @classmethod\n    def get_id(cls):\n        name = cls.__get_definition('name', cls.__name__)\n        return 'hubs_component_' + name.replace('-', '_')\n\n    @classmethod\n    def get_name(cls):\n        return cls.__get_definition('name', cls.get_id())\n\n    @classmethod\n    def get_display_name(cls, default=None):\n        default = cls.__name__ if default is None else default\n        return cls.__get_definition('display_name', default)\n\n    @classmethod\n    def get_node_type(cls):\n        return cls.__get_definition('node_type', NodeType.NODE)\n\n    @classmethod\n    def get_panel_type(cls):\n        return cls.__get_definition('panel_type', [PanelType.OBJECT])\n\n    @classmethod\n    def get_category(cls):\n        return cls.__get_definition('category', None)\n\n    @classmethod\n    def get_category_name(cls):\n        return cls.get_category().value\n\n    @classmethod\n    def get_definition_version(cls):\n        return cls.__get_definition('version', (0, 0, 0))\n\n    @classmethod\n    def init(cls, obj):\n        '''Called right after the component is added to give the component a chance to initialize'''\n        pass\n\n    @classmethod\n    def init_instance_version(cls, obj):\n        component = getattr(obj, cls.get_id())\n        component.instance_version = cls.get_definition_version()\n\n    @classmethod\n    def create_gizmo(cls, obj, gizmo_group):\n        return None\n\n    @classmethod\n    def update_gizmo(cls, obj, bone, target, gizmo):\n        from .gizmos import gizmo_update\n        gizmo_update(obj, gizmo)\n\n    @classmethod\n    def get_deps(cls):\n        return cls.__get_definition('deps', [])\n\n    @classmethod\n    def get_icon(cls):\n        return cls.__get_definition('icon', None)\n\n    @classmethod\n    def is_dep_only(cls):\n        return not cls.get_category()\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        if type(self) is HubsComponent:\n            raise Exception(\n                'HubsComponent is an abstract class and cannot be instantiated directly')\n\n    def draw(self, context, layout, panel):\n        '''Draw method to be called by the panel. The base class method will print all the component properties'''\n        for key in self.get_properties():\n            if not self.bl_rna.properties[key].is_hidden:\n                layout.prop(data=self, property=key)\n\n    def pre_export(self, export_settings, host, ob=None):\n        '''This is called by the exporter before starting the export process'''\n        pass\n\n    def gather(self, export_settings, object):\n        '''This is called by the exporter and will return all the component properties by default'''\n        from ..io.utils import gather_properties\n        return gather_properties(export_settings, object, self)\n\n    @classmethod\n    def gather_import(cls, gltf, blender_host, component_name, component_value, import_report, blender_ob=None):\n        component = import_component(component_name, blender_host)\n        if component_value:\n            for property_name, property_value in component_value.items():\n                assign_property(gltf.vnodes, component,\n                                property_name, property_value)\n\n    def post_export(self, export_settings, host, ob=None):\n        '''This is called by the exporter after the export process has finished'''\n        pass\n\n    def migrate(self, migration_type, panel_type, instance_version, host, migration_report, ob=None):\n        '''This is called when an object component needs to migrate the data from previous add-on versions.\n        The migration_type argument is the type of migration, GLOBAL represents file loads, and LOCAL represents things like append/link.\n        The panel_type argument is used to determine what data-block the component is on.\n        The instance_version argument represents the version of the component that will be migrated from, as a tuple.\n        The host argument is what the component is attached to, object/bone.\n        The migration_report argument is a list that you can append messages to and they will be displayed to the user after the migration has finished.\n        The ob argument is used for bone migrations and is the armature object that the bone is part of.  Note: this is passed for object migrations as well, and will fall back to passing the armature if the object isn't available.\n        Returns a boolean to indicate whether a migration was performed.\n        '''\n        return False\n\n    @classmethod\n    def gather_name(cls):\n        return cls.get_name()\n\n    @classmethod\n    def draw_global(cls, context, layout, panel):\n        '''Draw method to be called by the panel. This can be used to draw global component properties in a panel before the component properties.'''\n\n    @classmethod\n    def get_properties(cls):\n        if hasattr(cls, '__annotations__'):\n            # Python versions below 3.10 will sometimes return the base class' annotations if there are none in the subclass, so make sure only the subclass' annotations are returned.\n            baseclass_properties = HubsComponent.__annotations__.keys()\n            subclass_properties = cls.__annotations__.keys()\n            return [prop for prop in subclass_properties if prop not in baseclass_properties]\n        return {}\n\n    @classmethod\n    def poll(cls, panel_type, host, ob=None):\n        '''This method will return true if this component's shown be shown or run.\n        This is currently called when checking if the component should be added to the components pop-up, when the components properties panel is drawn, and during migrations to warn about unsupported hosts.\n        The ob argument is guaranteed to be present only for objects/bones, although it will fall back to using the armature for bones if the object isn't available.'''\n        return True\n\n    @classmethod\n    def get_unsupported_host_message(cls, panel_type, host, ob=None):\n        '''This method will return the message to use if this component isn't supported on this host.\n        This is currently called during migrations.\n        The ob argument will fall back to an armature for bones if an object isn't available.'''\n        from .utils import get_host_reference_message\n        host_reference = get_host_reference_message(panel_type, host, ob=ob)\n        host_type = panel_type.value\n        message = f\"Warning: Unsupported component on {host_type} {host_reference}, {host_type}s don't support {cls.get_display_name()} components\"\n\n        return message\n\n    @staticmethod\n    def register():\n        '''This is called by the Blender runtime when the component is registered.\n        Here you can register any classes that the component is using.'''\n        pass\n\n    @staticmethod\n    def unregister():\n        '''This is called by the Blender runtime when the component is unregistered.\n        Here you can unregister any classes that you have registered.'''\n        pass\n"
  },
  {
    "path": "addons/io_hubs_addon/components/models/audio.py",
    "content": "SHAPE = ((-0.500000, 0.000000, -0.362840),(0.500000, 0.000000, -0.362840),(0.500000, 0.000000, 0.362840),(-0.500000, 0.000000, -0.362840),(0.500000, 0.000000, 0.362840),(-0.500000, 0.000000, 0.362840),(0.228459, -0.095301, 0.228459),(0.128507, -0.080516, 0.310241),(0.123642, -0.095301, 0.298496),(0.298496, -0.095301, 0.123641),(0.237449, -0.080516, 0.237448),(0.228459, -0.095301, 0.228459),(0.323090, -0.095301, 0.000000),(0.310242, -0.080516, 0.128506),(0.298496, -0.095301, 0.123641),(0.298496, -0.095301, -0.123641),(0.335803, -0.080516, 0.000000),(0.323090, -0.095301, 0.000000),(0.298496, -0.095301, -0.123641),(0.237449, -0.080516, -0.237448),(0.310242, -0.080516, -0.128506),(0.228459, -0.095301, -0.228458),(0.128507, -0.080516, -0.310241),(0.237449, -0.080516, -0.237448),(0.123642, -0.095301, -0.298495),(0.000001, -0.080516, -0.335802),(0.128507, -0.080516, -0.310241),(0.000001, -0.095301, -0.323089),(-0.128505, -0.080516, -0.310241),(0.000001, -0.080516, -0.335802),(-0.228458, -0.095301, -0.228458),(-0.128505, -0.080516, -0.310241),(-0.123640, -0.095301, -0.298495),(-0.298495, -0.095301, -0.123641),(-0.237447, -0.080516, -0.237448),(-0.228458, -0.095301, -0.228458),(-0.298495, -0.095301, -0.123641),(-0.335801, -0.080516, 0.000000),(-0.310240, -0.080516, -0.128506),(-0.298495, -0.095301, 0.123641),(-0.335801, -0.080516, 0.000000),(-0.323088, -0.095301, 0.000000),(-0.228458, -0.095301, 0.228459),(-0.310240, -0.080516, 0.128506),(-0.298495, -0.095301, 0.123641),(-0.123640, -0.095301, 0.298496),(-0.237447, -0.080516, 0.237448),(-0.228458, -0.095301, 0.228459),(0.000001, -0.095301, 0.323089),(-0.128505, -0.080516, 0.310241),(-0.123640, -0.095301, 0.298496),(-0.196763, -0.067532, 0.196764),(-0.076460, 0.000000, 0.184591),(-0.106487, -0.067532, 0.257084),(0.000001, -0.067532, -0.278266),(0.076460, 0.000000, -0.184591),(0.000000, 0.000000, -0.199800),(0.000001, -0.067532, 0.278266),(0.076460, 0.000000, 0.184591),(0.106488, -0.067532, 0.257084),(-0.106487, -0.067532, 0.257084),(0.000000, 0.000000, 0.199800),(0.000001, -0.067532, 0.278266),(-0.106487, -0.067532, -0.257084),(0.000000, 0.000000, -0.199800),(-0.076460, 0.000000, -0.184591),(0.106488, -0.067532, 0.257084),(0.141280, 0.000000, 0.141280),(0.196764, -0.067532, 0.196764),(-0.196763, -0.067532, -0.196764),(-0.076460, 0.000000, -0.184591),(-0.141280, 0.000000, -0.141280),(0.196764, -0.067532, 0.196764),(0.184591, 0.000000, 0.076460),(0.257085, -0.067532, 0.106488),(-0.257084, -0.067532, -0.106488),(-0.141280, 0.000000, -0.141280),(-0.184591, 0.000000, -0.076460),(0.257085, -0.067532, 0.106488),(0.199800, 0.000000, 0.000000),(0.278266, -0.067532, 0.000000),(-0.257084, -0.067532, -0.106488),(-0.199800, 0.000000, 0.000000),(-0.278265, -0.067532, 0.000000),(0.257085, -0.067532, -0.106488),(0.199800, 0.000000, 0.000000),(0.184591, 0.000000, -0.076460),(-0.278265, -0.067532, 0.000000),(-0.184591, 0.000000, 0.076460),(-0.257084, -0.067532, 0.106488),(0.196764, -0.067532, -0.196764),(0.184591, 0.000000, -0.076460),(0.141280, 0.000000, -0.141280),(-0.257084, -0.067532, 0.106488),(-0.141280, 0.000000, 0.141280),(-0.196763, -0.067532, 0.196764),(-0.128505, -0.080516, 0.310241),(0.000000, -0.000000, 0.236914),(-0.090663, 0.000000, 0.218880),(-0.237447, -0.080516, 0.237448),(-0.090663, 0.000000, 0.218880),(-0.167523, 0.000000, 0.167523),(-0.310240, -0.080516, 0.128506),(-0.167523, 0.000000, 0.167523),(-0.218879, 0.000000, 0.090663),(-0.335801, -0.080516, 0.000000),(-0.218879, 0.000000, 0.090663),(-0.236913, 0.000000, 0.000000),(-0.218879, 0.000000, -0.090663),(-0.335801, -0.080516, 0.000000),(-0.236913, 0.000000, 0.000000),(-0.167523, 0.000000, -0.167523),(-0.310240, -0.080516, -0.128506),(-0.218879, 0.000000, -0.090663),(-0.090663, 0.000000, -0.218879),(-0.237447, -0.080516, -0.237448),(-0.167523, 0.000000, -0.167523),(0.000000, 0.000000, -0.236913),(-0.128505, -0.080516, -0.310241),(-0.090663, 0.000000, -0.218879),(0.090663, 0.000000, -0.218879),(0.000001, -0.080516, -0.335802),(0.000000, 0.000000, -0.236913),(0.167523, 0.000000, -0.167523),(0.128507, -0.080516, -0.310241),(0.090663, 0.000000, -0.218879),(0.218880, 0.000000, -0.090663),(0.237449, -0.080516, -0.237448),(0.167523, 0.000000, -0.167523),(0.236914, 0.000000, 0.000000),(0.310242, -0.080516, -0.128506),(0.218880, 0.000000, -0.090663),(0.310242, -0.080516, 0.128506),(0.236914, 0.000000, 0.000000),(0.218880, 0.000000, 0.090663),(0.237449, -0.080516, 0.237448),(0.218880, 0.000000, 0.090663),(0.167523, 0.000000, 0.167523),(0.128507, -0.080516, 0.310241),(0.167523, 0.000000, 0.167523),(0.090663, 0.000000, 0.218880),(0.000001, -0.080516, 0.335802),(0.090663, 0.000000, 0.218880),(0.000000, -0.000000, 0.236914),(0.123642, -0.095301, -0.298495),(0.211498, -0.082967, -0.211497),(0.114462, -0.082967, -0.276334),(-0.298495, -0.095301, 0.123641),(-0.211496, -0.082967, 0.211497),(-0.228458, -0.095301, 0.228459),(0.228459, -0.095301, -0.228458),(0.276335, -0.082967, -0.114461),(0.211498, -0.082967, -0.211497),(-0.323088, -0.095301, 0.000000),(-0.276333, -0.082967, 0.114461),(-0.298495, -0.095301, 0.123641),(0.298496, -0.095301, -0.123641),(0.299102, -0.082967, 0.000000),(0.276335, -0.082967, -0.114461),(-0.298495, -0.095301, -0.123641),(-0.299101, -0.082967, 0.000000),(-0.323088, -0.095301, 0.000000),(0.298496, -0.095301, 0.123641),(0.299102, -0.082967, 0.000000),(0.323090, -0.095301, 0.000000),(-0.228458, -0.095301, -0.228458),(-0.276333, -0.082967, -0.114461),(-0.298495, -0.095301, -0.123641),(0.228459, -0.095301, 0.228459),(0.276335, -0.082967, 0.114461),(0.298496, -0.095301, 0.123641),(-0.123640, -0.095301, -0.298495),(-0.211496, -0.082967, -0.211497),(-0.228458, -0.095301, -0.228458),(0.123642, -0.095301, 0.298496),(0.211498, -0.082967, 0.211497),(0.228459, -0.095301, 0.228459),(0.000001, -0.095301, -0.323089),(-0.114461, -0.082967, -0.276334),(-0.123640, -0.095301, -0.298495),(-0.123640, -0.095301, 0.298496),(0.000001, -0.082967, 0.299102),(0.000001, -0.095301, 0.323089),(0.000001, -0.095301, 0.323089),(0.114462, -0.082967, 0.276334),(0.123642, -0.095301, 0.298496),(0.000001, -0.095301, -0.323089),(0.114462, -0.082967, -0.276334),(0.000001, -0.082967, -0.299102),(-0.228458, -0.095301, 0.228459),(-0.114461, -0.082967, 0.276334),(-0.123640, -0.095301, 0.298496),(0.362201, -0.107929, -0.150028),(0.348407, -0.107762, -0.069303),(0.387390, -0.108020, -0.077057),(-0.348405, -0.107762, -0.069303),(-0.362199, -0.107929, -0.150028),(-0.387388, -0.108020, -0.077057),(0.277329, -0.107941, 0.277148),(0.195801, -0.107931, 0.295860),(0.219479, -0.108088, 0.328575),(-0.195798, -0.107931, 0.295860),(-0.277327, -0.107941, 0.277148),(-0.219477, -0.108088, 0.328575),(0.277329, -0.107941, -0.277148),(0.295367, -0.107762, -0.197358),(0.328413, -0.108020, -0.219438),(-0.348405, -0.107762, 0.069302),(-0.392041, -0.107929, -0.000000),(-0.387388, -0.108020, 0.077056),(-0.295365, -0.107762, -0.197358),(-0.277327, -0.107941, -0.277148),(-0.328411, -0.108020, -0.219438),(0.392043, -0.107929, -0.000000),(0.348407, -0.107762, 0.069302),(0.387390, -0.108020, 0.077056),(-0.295365, -0.107762, 0.197358),(-0.362199, -0.107929, 0.150028),(-0.328411, -0.108020, 0.219438),(0.362201, -0.107929, 0.150028),(0.295367, -0.107762, 0.197358),(0.328413, -0.108020, 0.219438),(0.252395, -0.145456, -0.382567),(0.354805, -0.145454, -0.354519),(0.280016, -0.145617, -0.420616),(-0.449813, -0.145227, -0.089474),(-0.463371, -0.145448, -0.191935),(-0.495566, -0.145548, -0.098575),(0.449816, -0.145227, -0.089474),(0.501553, -0.145448, -0.000000),(0.495569, -0.145548, -0.098575),(-0.252392, -0.145456, 0.382567),(-0.354802, -0.145454, 0.354519),(-0.280013, -0.145617, 0.420616),(0.381338, -0.145226, 0.254800),(0.354805, -0.145454, 0.354519),(0.420123, -0.145548, 0.280717),(-0.449813, -0.145227, 0.089473),(-0.501550, -0.145448, -0.000000),(-0.495566, -0.145548, 0.098574),(0.381338, -0.145226, -0.254800),(0.463374, -0.145448, -0.191935),(0.420123, -0.145548, -0.280717),(-0.381335, -0.145226, -0.254800),(-0.354802, -0.145454, -0.354520),(-0.420120, -0.145548, -0.280717),(0.449816, -0.145227, 0.089473),(0.463374, -0.145448, 0.191935),(0.495569, -0.145548, 0.098574),(-0.381335, -0.145226, 0.254800),(-0.463371, -0.145448, 0.191935),(-0.420120, -0.145548, 0.280717),(0.354805, -0.145454, 0.354519),(0.252395, -0.145456, 0.382567),(0.280016, -0.145617, 0.420616),(-0.354802, -0.145454, 0.354519),(-0.381335, -0.145226, 0.254800),(-0.420120, -0.145548, 0.280717),(0.501553, -0.145448, -0.000000),(0.449816, -0.145227, 0.089473),(0.495569, -0.145548, 0.098574),(-0.463371, -0.145448, -0.191935),(-0.381335, -0.145226, -0.254800),(-0.420120, -0.145548, -0.280717),(0.354805, -0.145454, -0.354519),(0.381338, -0.145226, -0.254800),(0.420123, -0.145548, -0.280717),(-0.463371, -0.145448, 0.191935),(-0.449813, -0.145227, 0.089473),(-0.495566, -0.145548, 0.098574),(0.463374, -0.145448, 0.191935),(0.381338, -0.145226, 0.254800),(0.420123, -0.145548, 0.280717),(-0.354802, -0.145454, -0.354520),(-0.252392, -0.145456, -0.382567),(-0.280013, -0.145617, -0.420616),(0.463374, -0.145448, -0.191935),(0.449816, -0.145227, -0.089474),(0.495569, -0.145548, -0.098575),(-0.501550, -0.145448, -0.000000),(-0.449813, -0.145227, -0.089474),(-0.495566, -0.145548, -0.098575),(-0.277327, -0.107941, 0.277148),(-0.295365, -0.107762, 0.197358),(-0.328411, -0.108020, 0.219438),(-0.362199, -0.107929, -0.150028),(-0.295365, -0.107762, -0.197358),(-0.328411, -0.108020, -0.219438),(-0.362199, -0.107929, 0.150028),(-0.348405, -0.107762, 0.069302),(-0.387388, -0.108020, 0.077056),(-0.277327, -0.107941, -0.277148),(-0.195798, -0.107931, -0.295861),(-0.219477, -0.108088, -0.328576),(-0.392041, -0.107929, -0.000000),(-0.348405, -0.107762, -0.069303),(-0.387388, -0.108020, -0.077057),(0.277329, -0.107941, 0.277148),(0.295367, -0.107762, 0.197358),(0.249662, -0.107816, 0.249649),(0.362201, -0.107929, -0.150028),(0.295367, -0.107762, -0.197358),(0.326163, -0.107826, -0.135101),(0.362201, -0.107929, 0.150028),(0.348407, -0.107762, 0.069302),(0.326163, -0.107826, 0.135101),(0.277329, -0.107941, -0.277148),(0.195801, -0.107931, -0.295861),(0.249662, -0.107816, -0.249649),(0.392043, -0.107929, -0.000000),(0.348407, -0.107762, -0.069303),(0.353036, -0.107826, -0.000000),(0.219479, -0.108088, -0.328576),(0.185681, -0.112150, -0.314268),(0.195801, -0.107931, -0.295861),(0.280016, -0.145617, 0.420616),(0.242157, -0.149913, 0.402607),(0.257907, -0.150086, 0.424342),(0.219479, -0.108088, 0.328575),(0.185681, -0.112150, 0.314268),(0.199198, -0.112320, 0.332804),(0.280016, -0.145617, -0.420616),(0.242157, -0.149913, -0.402608),(0.252395, -0.145456, -0.382567),(-0.219477, -0.108088, 0.328575),(-0.185679, -0.112150, 0.314268),(-0.195798, -0.107931, 0.295860),(-0.219477, -0.108088, -0.328576),(-0.185679, -0.112150, -0.314268),(-0.199196, -0.112320, -0.332804),(-0.280013, -0.145617, 0.420616),(-0.242153, -0.149913, 0.402607),(-0.252392, -0.145456, 0.382567),(-0.280013, -0.145617, -0.420616),(-0.242154, -0.149913, -0.402608),(-0.257904, -0.150086, -0.424342),(-0.002862, 0.000000, 0.066096),(-0.027207, 0.000000, 0.116094),(-0.027207, 0.000000, -0.031918),(0.000001, -0.080516, 0.335802),(0.123642, -0.095301, 0.298496),(0.128507, -0.080516, 0.310241),(0.106488, -0.067532, -0.257084),(0.141280, 0.000000, -0.141280),(0.076460, 0.000000, -0.184591),(-0.027207, 0.000000, -0.031918),(-0.043270, 0.000000, -0.025400),(-0.002768, 0.000000, -0.084581),(-0.043270, 0.000000, -0.025400),(-0.059014, 0.000000, -0.022269),(-0.080924, 0.000000, -0.026627),(-0.099498, 0.000000, -0.039038),(-0.043270, 0.000000, -0.025400),(-0.080924, 0.000000, -0.026627),(-0.099498, 0.000000, -0.039038),(-0.111909, 0.000000, -0.057612),(-0.043270, 0.000000, -0.025400),(-0.111909, 0.000000, -0.057612),(-0.116267, 0.000000, -0.079521),(-0.043270, 0.000000, -0.025400),(-0.116267, 0.000000, -0.079521),(-0.111909, 0.000000, -0.101431),(-0.043270, 0.000000, -0.025400),(-0.111909, 0.000000, -0.101431),(-0.099498, 0.000000, -0.120005),(-0.043270, 0.000000, -0.025400),(-0.099498, 0.000000, -0.120005),(-0.080924, 0.000000, -0.132416),(-0.002768, 0.000000, -0.084581),(-0.080924, 0.000000, -0.132416),(-0.059014, 0.000000, -0.136774),(-0.002768, 0.000000, -0.084581),(-0.059014, 0.000000, -0.136774),(-0.037105, 0.000000, -0.132416),(-0.002768, 0.000000, -0.084581),(-0.037105, 0.000000, -0.132416),(-0.018531, 0.000000, -0.120005),(-0.002768, 0.000000, -0.084581),(-0.018531, 0.000000, -0.120005),(-0.006120, 0.000000, -0.101431),(-0.002768, 0.000000, -0.084581),(-0.002862, 0.000000, 0.066096),(0.097449, 0.000000, 0.052513),(0.097449, 0.000000, 0.130106),(-0.002768, 0.000000, -0.084581),(-0.002862, 0.000000, 0.066096),(-0.027207, 0.000000, -0.031918),(-0.002862, 0.000000, 0.066096),(0.097449, 0.000000, 0.130106),(-0.027207, 0.000000, 0.116094),(-0.043270, 0.000000, -0.025400),(-0.099498, 0.000000, -0.120005),(-0.002768, 0.000000, -0.084581),(0.228459, -0.095301, 0.228459),(0.237449, -0.080516, 0.237448),(0.128507, -0.080516, 0.310241),(0.298496, -0.095301, 0.123641),(0.310242, -0.080516, 0.128506),(0.237449, -0.080516, 0.237448),(0.323090, -0.095301, 0.000000),(0.335803, -0.080516, 0.000000),(0.310242, -0.080516, 0.128506),(0.298496, -0.095301, -0.123641),(0.310242, -0.080516, -0.128506),(0.335803, -0.080516, 0.000000),(0.298496, -0.095301, -0.123641),(0.228459, -0.095301, -0.228458),(0.237449, -0.080516, -0.237448),(0.228459, -0.095301, -0.228458),(0.123642, -0.095301, -0.298495),(0.128507, -0.080516, -0.310241),(0.123642, -0.095301, -0.298495),(0.000001, -0.095301, -0.323089),(0.000001, -0.080516, -0.335802),(0.000001, -0.095301, -0.323089),(-0.123640, -0.095301, -0.298495),(-0.128505, -0.080516, -0.310241),(-0.228458, -0.095301, -0.228458),(-0.237447, -0.080516, -0.237448),(-0.128505, -0.080516, -0.310241),(-0.298495, -0.095301, -0.123641),(-0.310240, -0.080516, -0.128506),(-0.237447, -0.080516, -0.237448),(-0.298495, -0.095301, -0.123641),(-0.323088, -0.095301, 0.000000),(-0.335801, -0.080516, 0.000000),(-0.298495, -0.095301, 0.123641),(-0.310240, -0.080516, 0.128506),(-0.335801, -0.080516, 0.000000),(-0.228458, -0.095301, 0.228459),(-0.237447, -0.080516, 0.237448),(-0.310240, -0.080516, 0.128506),(-0.123640, -0.095301, 0.298496),(-0.128505, -0.080516, 0.310241),(-0.237447, -0.080516, 0.237448),(0.000001, -0.095301, 0.323089),(0.000001, -0.080516, 0.335802),(-0.128505, -0.080516, 0.310241),(-0.196763, -0.067532, 0.196764),(-0.141280, 0.000000, 0.141280),(-0.076460, 0.000000, 0.184591),(0.000001, -0.067532, -0.278266),(0.106488, -0.067532, -0.257084),(0.076460, 0.000000, -0.184591),(0.000001, -0.067532, 0.278266),(0.000000, 0.000000, 0.199800),(0.076460, 0.000000, 0.184591),(-0.106487, -0.067532, 0.257084),(-0.076460, 0.000000, 0.184591),(0.000000, 0.000000, 0.199800),(-0.106487, -0.067532, -0.257084),(0.000001, -0.067532, -0.278266),(0.000000, 0.000000, -0.199800),(0.106488, -0.067532, 0.257084),(0.076460, 0.000000, 0.184591),(0.141280, 0.000000, 0.141280),(-0.196763, -0.067532, -0.196764),(-0.106487, -0.067532, -0.257084),(-0.076460, 0.000000, -0.184591),(0.196764, -0.067532, 0.196764),(0.141280, 0.000000, 0.141280),(0.184591, 0.000000, 0.076460),(-0.257084, -0.067532, -0.106488),(-0.196763, -0.067532, -0.196764),(-0.141280, 0.000000, -0.141280),(0.257085, -0.067532, 0.106488),(0.184591, 0.000000, 0.076460),(0.199800, 0.000000, 0.000000),(-0.257084, -0.067532, -0.106488),(-0.184591, 0.000000, -0.076460),(-0.199800, 0.000000, 0.000000),(0.257085, -0.067532, -0.106488),(0.278266, -0.067532, 0.000000),(0.199800, 0.000000, 0.000000),(-0.278265, -0.067532, 0.000000),(-0.199800, 0.000000, 0.000000),(-0.184591, 0.000000, 0.076460),(0.196764, -0.067532, -0.196764),(0.257085, -0.067532, -0.106488),(0.184591, 0.000000, -0.076460),(-0.257084, -0.067532, 0.106488),(-0.184591, 0.000000, 0.076460),(-0.141280, 0.000000, 0.141280),(-0.128505, -0.080516, 0.310241),(0.000001, -0.080516, 0.335802),(0.000000, -0.000000, 0.236914),(-0.237447, -0.080516, 0.237448),(-0.128505, -0.080516, 0.310241),(-0.090663, 0.000000, 0.218880),(-0.310240, -0.080516, 0.128506),(-0.237447, -0.080516, 0.237448),(-0.167523, 0.000000, 0.167523),(-0.335801, -0.080516, 0.000000),(-0.310240, -0.080516, 0.128506),(-0.218879, 0.000000, 0.090663),(-0.218879, 0.000000, -0.090663),(-0.310240, -0.080516, -0.128506),(-0.335801, -0.080516, 0.000000),(-0.167523, 0.000000, -0.167523),(-0.237447, -0.080516, -0.237448),(-0.310240, -0.080516, -0.128506),(-0.090663, 0.000000, -0.218879),(-0.128505, -0.080516, -0.310241),(-0.237447, -0.080516, -0.237448),(0.000000, 0.000000, -0.236913),(0.000001, -0.080516, -0.335802),(-0.128505, -0.080516, -0.310241),(0.090663, 0.000000, -0.218879),(0.128507, -0.080516, -0.310241),(0.000001, -0.080516, -0.335802),(0.167523, 0.000000, -0.167523),(0.237449, -0.080516, -0.237448),(0.128507, -0.080516, -0.310241),(0.218880, 0.000000, -0.090663),(0.310242, -0.080516, -0.128506),(0.237449, -0.080516, -0.237448),(0.236914, 0.000000, 0.000000),(0.335803, -0.080516, 0.000000),(0.310242, -0.080516, -0.128506),(0.310242, -0.080516, 0.128506),(0.335803, -0.080516, 0.000000),(0.236914, 0.000000, 0.000000),(0.237449, -0.080516, 0.237448),(0.310242, -0.080516, 0.128506),(0.218880, 0.000000, 0.090663),(0.128507, -0.080516, 0.310241),(0.237449, -0.080516, 0.237448),(0.167523, 0.000000, 0.167523),(0.000001, -0.080516, 0.335802),(0.128507, -0.080516, 0.310241),(0.090663, 0.000000, 0.218880),(0.123642, -0.095301, -0.298495),(0.228459, -0.095301, -0.228458),(0.211498, -0.082967, -0.211497),(-0.298495, -0.095301, 0.123641),(-0.276333, -0.082967, 0.114461),(-0.211496, -0.082967, 0.211497),(0.228459, -0.095301, -0.228458),(0.298496, -0.095301, -0.123641),(0.276335, -0.082967, -0.114461),(-0.323088, -0.095301, 0.000000),(-0.299101, -0.082967, 0.000000),(-0.276333, -0.082967, 0.114461),(0.298496, -0.095301, -0.123641),(0.323090, -0.095301, 0.000000),(0.299102, -0.082967, 0.000000),(-0.298495, -0.095301, -0.123641),(-0.276333, -0.082967, -0.114461),(-0.299101, -0.082967, 0.000000),(0.298496, -0.095301, 0.123641),(0.276335, -0.082967, 0.114461),(0.299102, -0.082967, 0.000000),(-0.228458, -0.095301, -0.228458),(-0.211496, -0.082967, -0.211497),(-0.276333, -0.082967, -0.114461),(0.228459, -0.095301, 0.228459),(0.211498, -0.082967, 0.211497),(0.276335, -0.082967, 0.114461),(-0.123640, -0.095301, -0.298495),(-0.114461, -0.082967, -0.276334),(-0.211496, -0.082967, -0.211497),(0.123642, -0.095301, 0.298496),(0.114462, -0.082967, 0.276334),(0.211498, -0.082967, 0.211497),(0.000001, -0.095301, -0.323089),(0.000001, -0.082967, -0.299102),(-0.114461, -0.082967, -0.276334),(-0.123640, -0.095301, 0.298496),(-0.114461, -0.082967, 0.276334),(0.000001, -0.082967, 0.299102),(0.000001, -0.095301, 0.323089),(0.000001, -0.082967, 0.299102),(0.114462, -0.082967, 0.276334),(0.000001, -0.095301, -0.323089),(0.123642, -0.095301, -0.298495),(0.114462, -0.082967, -0.276334),(-0.228458, -0.095301, 0.228459),(-0.211496, -0.082967, 0.211497),(-0.114461, -0.082967, 0.276334),(0.362201, -0.107929, -0.150028),(0.326163, -0.107826, -0.135101),(0.348407, -0.107762, -0.069303),(-0.348405, -0.107762, -0.069303),(-0.326161, -0.107826, -0.135101),(-0.362199, -0.107929, -0.150028),(0.277329, -0.107941, 0.277148),(0.249662, -0.107816, 0.249649),(0.195801, -0.107931, 0.295860),(-0.195798, -0.107931, 0.295860),(-0.249660, -0.107816, 0.249649),(-0.277327, -0.107941, 0.277148),(0.277329, -0.107941, -0.277148),(0.249662, -0.107816, -0.249649),(0.295367, -0.107762, -0.197358),(-0.348405, -0.107762, 0.069302),(-0.353034, -0.107826, -0.000000),(-0.392041, -0.107929, -0.000000),(-0.295365, -0.107762, -0.197358),(-0.249660, -0.107816, -0.249649),(-0.277327, -0.107941, -0.277148),(0.392043, -0.107929, -0.000000),(0.353036, -0.107826, -0.000000),(0.348407, -0.107762, 0.069302),(-0.295365, -0.107762, 0.197358),(-0.326161, -0.107826, 0.135101),(-0.362199, -0.107929, 0.150028),(0.362201, -0.107929, 0.150028),(0.326163, -0.107826, 0.135101),(0.295367, -0.107762, 0.197358),(0.252395, -0.145456, -0.382567),(0.322367, -0.145291, -0.322310),(0.354805, -0.145454, -0.354519),(-0.449813, -0.145227, -0.089474),(-0.421138, -0.145297, -0.174442),(-0.463371, -0.145448, -0.191935),(0.449816, -0.145227, -0.089474),(0.455839, -0.145297, -0.000000),(0.501553, -0.145448, -0.000000),(-0.252392, -0.145456, 0.382567),(-0.322364, -0.145291, 0.322310),(-0.354802, -0.145454, 0.354519),(0.381338, -0.145226, 0.254800),(0.322367, -0.145291, 0.322310),(0.354805, -0.145454, 0.354519),(-0.449813, -0.145227, 0.089473),(-0.455836, -0.145297, -0.000000),(-0.501550, -0.145448, -0.000000),(0.381338, -0.145226, -0.254800),(0.421140, -0.145297, -0.174442),(0.463374, -0.145448, -0.191935),(-0.381335, -0.145226, -0.254800),(-0.322364, -0.145291, -0.322310),(-0.354802, -0.145454, -0.354520),(0.449816, -0.145227, 0.089473),(0.421140, -0.145297, 0.174441),(0.463374, -0.145448, 0.191935),(-0.381335, -0.145226, 0.254800),(-0.421138, -0.145297, 0.174441),(-0.463371, -0.145448, 0.191935),(0.354805, -0.145454, 0.354519),(0.322367, -0.145291, 0.322310),(0.252395, -0.145456, 0.382567),(-0.354802, -0.145454, 0.354519),(-0.322364, -0.145291, 0.322310),(-0.381335, -0.145226, 0.254800),(0.501553, -0.145448, -0.000000),(0.455839, -0.145297, -0.000000),(0.449816, -0.145227, 0.089473),(-0.463371, -0.145448, -0.191935),(-0.421138, -0.145297, -0.174442),(-0.381335, -0.145226, -0.254800),(0.354805, -0.145454, -0.354519),(0.322367, -0.145291, -0.322310),(0.381338, -0.145226, -0.254800),(-0.463371, -0.145448, 0.191935),(-0.421138, -0.145297, 0.174441),(-0.449813, -0.145227, 0.089473),(0.463374, -0.145448, 0.191935),(0.421140, -0.145297, 0.174441),(0.381338, -0.145226, 0.254800),(-0.354802, -0.145454, -0.354520),(-0.322364, -0.145291, -0.322310),(-0.252392, -0.145456, -0.382567),(0.463374, -0.145448, -0.191935),(0.421140, -0.145297, -0.174442),(0.449816, -0.145227, -0.089474),(-0.501550, -0.145448, -0.000000),(-0.455836, -0.145297, -0.000000),(-0.449813, -0.145227, -0.089474),(-0.277327, -0.107941, 0.277148),(-0.249660, -0.107816, 0.249649),(-0.295365, -0.107762, 0.197358),(-0.362199, -0.107929, -0.150028),(-0.326161, -0.107826, -0.135101),(-0.295365, -0.107762, -0.197358),(-0.362199, -0.107929, 0.150028),(-0.326161, -0.107826, 0.135101),(-0.348405, -0.107762, 0.069302),(-0.277327, -0.107941, -0.277148),(-0.249660, -0.107816, -0.249649),(-0.195798, -0.107931, -0.295861),(-0.392041, -0.107929, -0.000000),(-0.353034, -0.107826, -0.000000),(-0.348405, -0.107762, -0.069303),(0.277329, -0.107941, 0.277148),(0.328413, -0.108020, 0.219438),(0.295367, -0.107762, 0.197358),(0.362201, -0.107929, -0.150028),(0.328413, -0.108020, -0.219438),(0.295367, -0.107762, -0.197358),(0.362201, -0.107929, 0.150028),(0.387390, -0.108020, 0.077056),(0.348407, -0.107762, 0.069302),(0.277329, -0.107941, -0.277148),(0.219479, -0.108088, -0.328576),(0.195801, -0.107931, -0.295861),(0.392043, -0.107929, -0.000000),(0.387390, -0.108020, -0.077057),(0.348407, -0.107762, -0.069303),(0.219479, -0.108088, -0.328576),(0.199198, -0.112320, -0.332804),(0.185681, -0.112150, -0.314268),(0.280016, -0.145617, 0.420616),(0.252395, -0.145456, 0.382567),(0.242157, -0.149913, 0.402607),(0.219479, -0.108088, 0.328575),(0.195801, -0.107931, 0.295860),(0.185681, -0.112150, 0.314268),(0.280016, -0.145617, -0.420616),(0.257907, -0.150086, -0.424342),(0.242157, -0.149913, -0.402608),(-0.219477, -0.108088, 0.328575),(-0.199196, -0.112320, 0.332804),(-0.185679, -0.112150, 0.314268),(-0.219477, -0.108088, -0.328576),(-0.195798, -0.107931, -0.295861),(-0.185679, -0.112150, -0.314268),(-0.280013, -0.145617, 0.420616),(-0.257904, -0.150086, 0.424342),(-0.242153, -0.149913, 0.402607),(-0.280013, -0.145617, -0.420616),(-0.252392, -0.145456, -0.382567),(-0.242154, -0.149913, -0.402608),(0.000001, -0.080516, 0.335802),(0.000001, -0.095301, 0.323089),(0.123642, -0.095301, 0.298496),(0.106488, -0.067532, -0.257084),(0.196764, -0.067532, -0.196764),(0.141280, 0.000000, -0.141280),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/box.py",
    "content": "SHAPE = ((0.500000, 0.500000, 0.500000),(-0.500000, 0.500000, 0.500000),(-0.475000, 0.475000, 0.500000),(0.500000, 0.500000, 0.500000),(-0.475000, 0.475000, 0.500000),(0.475000, 0.475000, 0.500000),(-0.500000, 0.500000, 0.500000),(-0.500000, -0.500000, 0.500000),(-0.475000, -0.475000, 0.500000),(-0.500000, 0.500000, 0.500000),(-0.475000, -0.475000, 0.500000),(-0.475000, 0.475000, 0.500000),(-0.500000, -0.500000, 0.500000),(0.500000, -0.500000, 0.500000),(0.475000, -0.475000, 0.500000),(-0.500000, -0.500000, 0.500000),(0.475000, -0.475000, 0.500000),(-0.475000, -0.475000, 0.500000),(0.500000, -0.500000, 0.500000),(0.500000, 0.500000, 0.500000),(0.475000, 0.475000, 0.500000),(0.500000, -0.500000, 0.500000),(0.475000, 0.475000, 0.500000),(0.475000, -0.475000, 0.500000),(0.500000, -0.500000, -0.500000),(0.500000, -0.500000, 0.500000),(0.475000, -0.500000, 0.475000),(0.500000, -0.500000, -0.500000),(0.475000, -0.500000, 0.475000),(0.475000, -0.500000, -0.475000),(0.500000, -0.500000, 0.500000),(-0.500000, -0.500000, 0.500000),(-0.475000, -0.500000, 0.475000),(0.500000, -0.500000, 0.500000),(-0.475000, -0.500000, 0.475000),(0.475000, -0.500000, 0.475000),(-0.500000, -0.500000, 0.500000),(-0.500000, -0.500000, -0.500000),(-0.475000, -0.500000, -0.475000),(-0.500000, -0.500000, 0.500000),(-0.475000, -0.500000, -0.475000),(-0.475000, -0.500000, 0.475000),(-0.500000, -0.500000, -0.500000),(0.500000, -0.500000, -0.500000),(0.475000, -0.500000, -0.475000),(-0.500000, -0.500000, -0.500000),(0.475000, -0.500000, -0.475000),(-0.475000, -0.500000, -0.475000),(-0.500000, -0.500000, -0.500000),(-0.500000, -0.500000, 0.500000),(-0.500000, -0.475000, 0.475000),(-0.500000, -0.500000, -0.500000),(-0.500000, -0.475000, 0.475000),(-0.500000, -0.475000, -0.475000),(-0.500000, -0.500000, 0.500000),(-0.500000, 0.500000, 0.500000),(-0.500000, 0.475000, 0.475000),(-0.500000, -0.500000, 0.500000),(-0.500000, 0.475000, 0.475000),(-0.500000, -0.475000, 0.475000),(-0.500000, 0.500000, 0.500000),(-0.500000, 0.500000, -0.500000),(-0.500000, 0.475000, -0.475000),(-0.500000, 0.500000, 0.500000),(-0.500000, 0.475000, -0.475000),(-0.500000, 0.475000, 0.475000),(-0.500000, 0.500000, -0.500000),(-0.500000, -0.500000, -0.500000),(-0.500000, -0.475000, -0.475000),(-0.500000, 0.500000, -0.500000),(-0.500000, -0.475000, -0.475000),(-0.500000, 0.475000, -0.475000),(-0.500000, 0.500000, -0.500000),(0.500000, 0.500000, -0.500000),(0.475000, 0.475000, -0.500000),(-0.500000, 0.500000, -0.500000),(0.475000, 0.475000, -0.500000),(-0.475000, 0.475000, -0.500000),(0.500000, 0.500000, -0.500000),(0.500000, -0.500000, -0.500000),(0.475000, -0.475000, -0.500000),(0.500000, 0.500000, -0.500000),(0.475000, -0.475000, -0.500000),(0.475000, 0.475000, -0.500000),(0.500000, -0.500000, -0.500000),(-0.500000, -0.500000, -0.500000),(-0.475000, -0.475000, -0.500000),(0.500000, -0.500000, -0.500000),(-0.475000, -0.475000, -0.500000),(0.475000, -0.475000, -0.500000),(-0.500000, -0.500000, -0.500000),(-0.500000, 0.500000, -0.500000),(-0.475000, 0.475000, -0.500000),(-0.500000, -0.500000, -0.500000),(-0.475000, 0.475000, -0.500000),(-0.475000, -0.475000, -0.500000),(0.500000, 0.500000, -0.500000),(0.500000, 0.500000, 0.500000),(0.500000, 0.475000, 0.475000),(0.500000, 0.500000, -0.500000),(0.500000, 0.475000, 0.475000),(0.500000, 0.475000, -0.475000),(0.500000, 0.500000, 0.500000),(0.500000, -0.500000, 0.500000),(0.500000, -0.475000, 0.475000),(0.500000, 0.500000, 0.500000),(0.500000, -0.475000, 0.475000),(0.500000, 0.475000, 0.475000),(0.500000, -0.500000, 0.500000),(0.500000, -0.500000, -0.500000),(0.500000, -0.475000, -0.475000),(0.500000, -0.500000, 0.500000),(0.500000, -0.475000, -0.475000),(0.500000, -0.475000, 0.475000),(0.500000, -0.500000, -0.500000),(0.500000, 0.500000, -0.500000),(0.500000, 0.475000, -0.475000),(0.500000, -0.500000, -0.500000),(0.500000, 0.475000, -0.475000),(0.500000, -0.475000, -0.475000),(-0.500000, 0.500000, -0.500000),(-0.500000, 0.500000, 0.500000),(-0.475000, 0.500000, 0.475000),(-0.500000, 0.500000, -0.500000),(-0.475000, 0.500000, 0.475000),(-0.475000, 0.500000, -0.475000),(-0.500000, 0.500000, 0.500000),(0.500000, 0.500000, 0.500000),(0.475000, 0.500000, 0.475000),(-0.500000, 0.500000, 0.500000),(0.475000, 0.500000, 0.475000),(-0.475000, 0.500000, 0.475000),(0.500000, 0.500000, 0.500000),(0.500000, 0.500000, -0.500000),(0.475000, 0.500000, -0.475000),(0.500000, 0.500000, 0.500000),(0.475000, 0.500000, -0.475000),(0.475000, 0.500000, 0.475000),(0.500000, 0.500000, -0.500000),(-0.500000, 0.500000, -0.500000),(-0.475000, 0.500000, -0.475000),(0.500000, 0.500000, -0.500000),(-0.475000, 0.500000, -0.475000),(0.475000, 0.500000, -0.475000),(-0.500000, 0.475000, -0.475000),(-0.475000, 0.475000, -0.475000),(-0.475000, 0.475000, 0.475000),(-0.500000, 0.475000, -0.475000),(-0.475000, 0.475000, 0.475000),(-0.500000, 0.475000, 0.475000),(-0.500000, 0.475000, 0.475000),(-0.475000, 0.475000, 0.475000),(-0.475000, -0.475000, 0.475000),(-0.500000, 0.475000, 0.475000),(-0.475000, -0.475000, 0.475000),(-0.500000, -0.475000, 0.475000),(-0.500000, -0.475000, 0.475000),(-0.475000, -0.475000, 0.475000),(-0.475000, -0.475000, -0.475000),(-0.500000, -0.475000, 0.475000),(-0.475000, -0.475000, -0.475000),(-0.500000, -0.475000, -0.475000),(-0.500000, -0.475000, -0.475000),(-0.475000, -0.475000, -0.475000),(-0.475000, 0.475000, -0.475000),(-0.500000, -0.475000, -0.475000),(-0.475000, 0.475000, -0.475000),(-0.500000, 0.475000, -0.475000),(-0.475000, -0.475000, 0.500000),(0.475000, -0.475000, 0.500000),(0.475000, -0.475000, 0.475000),(-0.475000, -0.475000, 0.500000),(0.475000, -0.475000, 0.475000),(-0.475000, -0.475000, 0.475000),(0.475000, -0.475000, 0.500000),(0.475000, 0.475000, 0.500000),(0.475000, 0.475000, 0.475000),(0.475000, -0.475000, 0.500000),(0.475000, 0.475000, 0.475000),(0.475000, -0.475000, 0.475000),(0.475000, 0.475000, 0.500000),(-0.475000, 0.475000, 0.500000),(-0.475000, 0.475000, 0.475000),(0.475000, 0.475000, 0.500000),(-0.475000, 0.475000, 0.475000),(0.475000, 0.475000, 0.475000),(-0.475000, 0.475000, 0.500000),(-0.475000, -0.475000, 0.500000),(-0.475000, -0.475000, 0.475000),(-0.475000, 0.475000, 0.500000),(-0.475000, -0.475000, 0.475000),(-0.475000, 0.475000, 0.475000),(0.475000, 0.475000, -0.500000),(0.475000, 0.475000, -0.475000),(-0.475000, 0.475000, -0.475000),(0.475000, 0.475000, -0.500000),(-0.475000, 0.475000, -0.475000),(-0.475000, 0.475000, -0.500000),(-0.475000, 0.475000, -0.500000),(-0.475000, 0.475000, -0.475000),(-0.475000, -0.475000, -0.475000),(-0.475000, 0.475000, -0.500000),(-0.475000, -0.475000, -0.475000),(-0.475000, -0.475000, -0.500000),(-0.475000, -0.475000, -0.500000),(-0.475000, -0.475000, -0.475000),(0.475000, -0.475000, -0.475000),(-0.475000, -0.475000, -0.500000),(0.475000, -0.475000, -0.475000),(0.475000, -0.475000, -0.500000),(0.475000, -0.475000, -0.500000),(0.475000, -0.475000, -0.475000),(0.475000, 0.475000, -0.475000),(0.475000, -0.475000, -0.500000),(0.475000, 0.475000, -0.475000),(0.475000, 0.475000, -0.500000),(-0.475000, -0.500000, -0.475000),(-0.475000, -0.475000, -0.475000),(-0.475000, -0.475000, 0.475000),(-0.475000, -0.500000, -0.475000),(-0.475000, -0.475000, 0.475000),(-0.475000, -0.500000, 0.475000),(-0.475000, -0.500000, 0.475000),(-0.475000, -0.475000, 0.475000),(0.475000, -0.475000, 0.475000),(-0.475000, -0.500000, 0.475000),(0.475000, -0.475000, 0.475000),(0.475000, -0.500000, 0.475000),(0.475000, -0.500000, 0.475000),(0.475000, -0.475000, 0.475000),(0.475000, -0.475000, -0.475000),(0.475000, -0.500000, 0.475000),(0.475000, -0.475000, -0.475000),(0.475000, -0.500000, -0.475000),(0.475000, -0.500000, -0.475000),(0.475000, -0.475000, -0.475000),(-0.475000, -0.475000, -0.475000),(0.475000, -0.500000, -0.475000),(-0.475000, -0.475000, -0.475000),(-0.475000, -0.500000, -0.475000),(0.475000, 0.500000, -0.475000),(0.475000, 0.475000, -0.475000),(0.475000, 0.475000, 0.475000),(0.475000, 0.500000, -0.475000),(0.475000, 0.475000, 0.475000),(0.475000, 0.500000, 0.475000),(0.475000, 0.500000, 0.475000),(0.475000, 0.475000, 0.475000),(-0.475000, 0.475000, 0.475000),(0.475000, 0.500000, 0.475000),(-0.475000, 0.475000, 0.475000),(-0.475000, 0.500000, 0.475000),(-0.475000, 0.500000, 0.475000),(-0.475000, 0.475000, 0.475000),(-0.475000, 0.475000, -0.475000),(-0.475000, 0.500000, 0.475000),(-0.475000, 0.475000, -0.475000),(-0.475000, 0.500000, -0.475000),(-0.475000, 0.500000, -0.475000),(-0.475000, 0.475000, -0.475000),(0.475000, 0.475000, -0.475000),(-0.475000, 0.500000, -0.475000),(0.475000, 0.475000, -0.475000),(0.475000, 0.500000, -0.475000),(0.500000, 0.475000, -0.475000),(0.500000, 0.475000, 0.475000),(0.475000, 0.475000, 0.475000),(0.500000, 0.475000, -0.475000),(0.475000, 0.475000, 0.475000),(0.475000, 0.475000, -0.475000),(0.500000, 0.475000, 0.475000),(0.500000, -0.475000, 0.475000),(0.475000, -0.475000, 0.475000),(0.500000, 0.475000, 0.475000),(0.475000, -0.475000, 0.475000),(0.475000, 0.475000, 0.475000),(0.500000, -0.475000, 0.475000),(0.500000, -0.475000, -0.475000),(0.475000, -0.475000, -0.475000),(0.500000, -0.475000, 0.475000),(0.475000, -0.475000, -0.475000),(0.475000, -0.475000, 0.475000),(0.500000, -0.475000, -0.475000),(0.500000, 0.475000, -0.475000),(0.475000, 0.475000, -0.475000),(0.500000, -0.475000, -0.475000),(0.475000, 0.475000, -0.475000),(0.475000, -0.475000, -0.475000),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/directional_light.py",
    "content": "SHAPE = ((0.000000, 0.181373, 0.036077),(0.128250, 0.128250, -0.036077),(0.000000, 0.181373, -0.036077),(-0.072648, 0.072648, -0.153760),(0.000000, 0.036077, -0.181373),(-0.025510, 0.025511, -0.181373),(0.128250, 0.128250, 0.036077),(0.000000, 0.153760, 0.102740),(0.108725, 0.108725, 0.102740),(0.025511, 0.025510, -0.181373),(0.000000, 0.102739, -0.153760),(0.072648, 0.072648, -0.153760),(0.181373, -0.000000, -0.036077),(0.128250, -0.128250, 0.036077),(0.128250, -0.128250, -0.036077),(0.000000, 0.153760, 0.102740),(-0.072648, 0.072648, 0.153761),(0.000000, 0.102739, 0.153761),(0.000000, 0.102739, 0.153761),(0.025511, 0.025510, 0.181373),(0.072648, 0.072648, 0.153761),(0.102739, -0.000000, 0.153761),(0.025510, -0.025511, 0.181373),(0.072648, -0.072648, 0.153761),(0.000000, 0.153760, 0.102740),(0.072648, 0.072648, 0.153761),(0.108725, 0.108725, 0.102740),(0.000000, 0.181373, 0.036077),(-0.108725, 0.108725, 0.102740),(0.000000, 0.153760, 0.102740),(0.181373, -0.000000, 0.036077),(0.108725, -0.108725, 0.102740),(0.128250, -0.128250, 0.036077),(0.128250, 0.128250, -0.036077),(0.181373, -0.000000, 0.036077),(0.181373, -0.000000, -0.036077),(0.000000, -0.000000, 0.184926),(0.036077, -0.000000, 0.181373),(0.025511, 0.025510, 0.181373),(0.108725, 0.108725, 0.102740),(0.102739, -0.000000, 0.153761),(0.153760, -0.000000, 0.102740),(0.025511, 0.025510, -0.181373),(0.102739, -0.000000, -0.153760),(0.036077, -0.000000, -0.181373),(0.000000, 0.181373, -0.036077),(0.108725, 0.108725, -0.102739),(0.000000, 0.153760, -0.102739),(-0.072648, 0.072648, 0.153761),(0.000000, 0.036077, 0.181373),(0.000000, 0.102739, 0.153761),(0.000000, -0.000000, -0.184926),(0.000000, 0.036077, -0.181373),(0.025511, 0.025510, -0.181373),(0.153760, -0.000000, -0.102739),(0.128250, -0.128250, -0.036077),(0.108725, -0.108725, -0.102739),(0.108725, -0.108725, 0.102740),(0.102739, -0.000000, 0.153761),(0.072648, -0.072648, 0.153761),(0.128250, -0.128250, -0.036077),(-0.000000, -0.181373, 0.036077),(-0.000000, -0.181373, -0.036077),(0.102739, -0.000000, -0.153760),(0.108725, -0.108725, -0.102739),(0.072648, -0.072648, -0.153760),(0.000000, -0.000000, -0.184926),(0.025511, 0.025510, -0.181373),(0.036077, -0.000000, -0.181373),(0.072648, -0.072648, 0.153761),(-0.000000, -0.036077, 0.181373),(-0.000000, -0.102739, 0.153761),(0.036077, -0.000000, -0.181373),(0.072648, -0.072648, -0.153760),(0.025510, -0.025511, -0.181373),(0.128250, -0.128250, 0.036077),(-0.000000, -0.153760, 0.102740),(-0.000000, -0.181373, 0.036077),(0.000000, -0.000000, 0.184926),(0.025510, -0.025511, 0.181373),(0.036077, -0.000000, 0.181373),(-0.000000, -0.153760, 0.102740),(0.072648, -0.072648, 0.153761),(-0.000000, -0.102739, 0.153761),(-0.000000, -0.181373, -0.036077),(-0.128250, -0.128250, 0.036077),(-0.128250, -0.128250, -0.036077),(0.108725, -0.108725, -0.102739),(-0.000000, -0.181373, -0.036077),(-0.000000, -0.153760, -0.102739),(0.000000, -0.000000, -0.184926),(0.036077, -0.000000, -0.181373),(0.025510, -0.025511, -0.181373),(-0.000000, -0.102739, 0.153761),(-0.025511, -0.025510, 0.181373),(-0.072648, -0.072648, 0.153761),(0.025510, -0.025511, -0.181373),(-0.000000, -0.102739, -0.153760),(-0.000000, -0.036077, -0.181373),(-0.000000, -0.181373, 0.036077),(-0.108725, -0.108725, 0.102740),(-0.128250, -0.128250, 0.036077),(0.072648, -0.072648, -0.153760),(-0.000000, -0.153760, -0.102739),(-0.000000, -0.102739, -0.153760),(0.000000, -0.000000, 0.184926),(-0.000000, -0.036077, 0.181373),(0.025510, -0.025511, 0.181373),(-0.000000, -0.153760, 0.102740),(-0.072648, -0.072648, 0.153761),(-0.108725, -0.108725, 0.102740),(-0.128250, -0.128250, -0.036077),(-0.181373, 0.000000, 0.036077),(-0.181373, 0.000000, -0.036077),(-0.000000, -0.153760, -0.102739),(-0.128250, -0.128250, -0.036077),(-0.108725, -0.108725, -0.102739),(0.000000, -0.000000, -0.184926),(0.025510, -0.025511, -0.181373),(-0.000000, -0.036077, -0.181373),(-0.108725, -0.108725, 0.102740),(-0.102739, 0.000000, 0.153761),(-0.153760, 0.000000, 0.102740),(-0.000000, -0.036077, -0.181373),(-0.072648, -0.072648, -0.153760),(-0.025511, -0.025510, -0.181373),(-0.128250, -0.128250, 0.036077),(-0.153760, 0.000000, 0.102740),(-0.181373, 0.000000, 0.036077),(-0.000000, -0.102739, -0.153760),(-0.108725, -0.108725, -0.102739),(-0.072648, -0.072648, -0.153760),(-0.102739, 0.000000, 0.153761),(-0.025511, -0.025510, 0.181373),(-0.036077, 0.000000, 0.181373),(0.000000, -0.000000, 0.184926),(-0.025511, -0.025510, 0.181373),(-0.000000, -0.036077, 0.181373),(-0.181373, 0.000000, -0.036077),(-0.128250, 0.128250, 0.036077),(-0.128250, 0.128250, -0.036077),(-0.102739, 0.000000, -0.153760),(-0.108725, -0.108725, -0.102739),(-0.153760, 0.000000, -0.102739),(-0.108725, -0.108725, -0.102739),(-0.181373, 0.000000, -0.036077),(-0.153760, 0.000000, -0.102739),(-0.025511, -0.025510, -0.181373),(-0.102739, 0.000000, -0.153760),(-0.036077, 0.000000, -0.181373),(-0.181373, 0.000000, 0.036077),(-0.108725, 0.108725, 0.102740),(-0.128250, 0.128250, 0.036077),(-0.072648, 0.072648, 0.153761),(-0.036077, 0.000000, 0.181373),(-0.025510, 0.025511, 0.181373),(0.000000, -0.000000, 0.184926),(-0.036077, 0.000000, 0.181373),(-0.025511, -0.025510, 0.181373),(0.000000, -0.000000, -0.184926),(-0.000000, -0.036077, -0.181373),(-0.025511, -0.025510, -0.181373),(-0.128250, 0.128250, 0.036077),(0.000000, 0.181373, -0.036077),(-0.128250, 0.128250, -0.036077),(-0.102739, 0.000000, -0.153760),(-0.108725, 0.108725, -0.102739),(-0.072648, 0.072648, -0.153760),(-0.153760, 0.000000, -0.102739),(-0.128250, 0.128250, -0.036077),(-0.108725, 0.108725, -0.102739),(-0.153760, 0.000000, 0.102740),(-0.072648, 0.072648, 0.153761),(-0.108725, 0.108725, 0.102740),(0.000000, -0.000000, 0.184926),(-0.025510, 0.025511, 0.181373),(-0.036077, 0.000000, 0.181373),(-0.036077, 0.000000, -0.181373),(-0.072648, 0.072648, -0.153760),(-0.025510, 0.025511, -0.181373),(0.000000, -0.000000, -0.184926),(-0.025511, -0.025510, -0.181373),(-0.036077, 0.000000, -0.181373),(-0.108725, 0.108725, -0.102739),(0.000000, 0.102739, -0.153760),(-0.072648, 0.072648, -0.153760),(-0.128250, 0.128250, -0.036077),(0.000000, 0.153760, -0.102739),(-0.108725, 0.108725, -0.102739),(0.000000, -0.000000, -0.184926),(-0.025510, 0.025511, -0.181373),(0.000000, 0.036077, -0.181373),(0.000000, -0.000000, 0.184926),(0.000000, 0.036077, 0.181373),(-0.025510, 0.025511, 0.181373),(0.000000, -0.000000, -0.184926),(-0.036077, 0.000000, -0.181373),(-0.025510, 0.025511, -0.181373),(0.153760, -0.000000, -0.102739),(0.128250, 0.128250, -0.036077),(0.181373, -0.000000, -0.036077),(0.000000, 0.153760, -0.102739),(0.072648, 0.072648, -0.153760),(0.000000, 0.102739, -0.153760),(0.102739, -0.000000, 0.153761),(0.025511, 0.025510, 0.181373),(0.036077, -0.000000, 0.181373),(0.072648, 0.072648, -0.153760),(0.153760, -0.000000, -0.102739),(0.102739, -0.000000, -0.153760),(0.000000, -0.000000, 0.184926),(0.025511, 0.025510, 0.181373),(0.000000, 0.036077, 0.181373),(0.128250, 0.128250, 0.036077),(0.153760, -0.000000, 0.102740),(0.181373, -0.000000, 0.036077),(0.000000, -0.032030, 0.501351),(0.000000, 0.000000, 0.232005),(0.022648, -0.022648, 0.501351),(0.022648, -0.022648, 0.501351),(0.000000, 0.000000, 0.232005),(0.032030, -0.000000, 0.501351),(0.032030, -0.000000, 0.501351),(0.000000, 0.000000, 0.232005),(0.022648, 0.022648, 0.501351),(0.022648, 0.022648, 0.501351),(0.000000, 0.000000, 0.232005),(0.000000, 0.032030, 0.501351),(0.000000, 0.032030, 0.501351),(0.000000, 0.000000, 0.232005),(-0.022648, 0.022648, 0.501351),(-0.022648, 0.022648, 0.501351),(0.000000, 0.000000, 0.232005),(-0.032030, -0.000000, 0.501351),(-0.032030, -0.000000, 0.501351),(0.000000, 0.000000, 0.232005),(-0.022648, -0.022648, 0.501351),(-0.022648, -0.022648, 0.501351),(0.000000, 0.000000, 0.232005),(0.000000, -0.032030, 0.501351),(0.000000, -0.032030, -0.501351),(0.022648, -0.022648, -0.501351),(0.000000, -0.000000, -0.232005),(0.022648, -0.022648, -0.501351),(0.032030, 0.000000, -0.501351),(0.000000, -0.000000, -0.232005),(0.032030, 0.000000, -0.501351),(0.022648, 0.022648, -0.501351),(0.000000, -0.000000, -0.232005),(0.022648, 0.022648, -0.501351),(0.000000, 0.032030, -0.501351),(0.000000, -0.000000, -0.232005),(0.000000, 0.032030, -0.501351),(-0.022648, 0.022648, -0.501351),(0.000000, -0.000000, -0.232005),(-0.022648, 0.022648, -0.501351),(-0.032030, 0.000000, -0.501351),(0.000000, -0.000000, -0.232005),(-0.032030, 0.000000, -0.501351),(-0.022648, -0.022648, -0.501351),(0.000000, -0.000000, -0.232005),(-0.022648, -0.022648, -0.501351),(0.000000, -0.032030, -0.501351),(0.000000, -0.000000, -0.232005),(0.501351, -0.032030, 0.000000),(0.232005, 0.000000, -0.000000),(0.501351, -0.022648, -0.022648),(0.501351, -0.022648, -0.022648),(0.232005, 0.000000, -0.000000),(0.501351, -0.000000, -0.032030),(0.501351, -0.000000, -0.032030),(0.232005, 0.000000, -0.000000),(0.501351, 0.022648, -0.022648),(0.501351, 0.022648, -0.022648),(0.232005, 0.000000, -0.000000),(0.501351, 0.032030, 0.000000),(0.501351, 0.032030, 0.000000),(0.232005, 0.000000, -0.000000),(0.501351, 0.022648, 0.022648),(0.501351, 0.022648, 0.022648),(0.232005, 0.000000, -0.000000),(0.501351, -0.000000, 0.032030),(0.501351, -0.000000, 0.032030),(0.232005, 0.000000, -0.000000),(0.501351, -0.022648, 0.022648),(0.501351, -0.022648, 0.022648),(0.232005, 0.000000, -0.000000),(0.501351, -0.032030, 0.000000),(-0.501351, -0.032029, -0.000000),(-0.501351, -0.022648, -0.022648),(-0.232005, 0.000000, 0.000000),(-0.501351, -0.022648, -0.022648),(-0.501351, 0.000000, -0.032030),(-0.232005, 0.000000, 0.000000),(-0.501351, 0.000000, -0.032030),(-0.501351, 0.022649, -0.022648),(-0.232005, 0.000000, 0.000000),(-0.501351, 0.022649, -0.022648),(-0.501351, 0.032030, -0.000000),(-0.232005, 0.000000, 0.000000),(-0.501351, 0.032030, -0.000000),(-0.501351, 0.022649, 0.022648),(-0.232005, 0.000000, 0.000000),(-0.501351, 0.022649, 0.022648),(-0.501351, 0.000000, 0.032030),(-0.232005, 0.000000, 0.000000),(-0.501351, 0.000000, 0.032030),(-0.501351, -0.022648, 0.022648),(-0.232005, 0.000000, 0.000000),(-0.501351, -0.022648, 0.022648),(-0.501351, -0.032029, -0.000000),(-0.232005, 0.000000, 0.000000),(-0.370524, -0.022648, -0.338494),(-0.354509, -0.032030, -0.354509),(-0.164052, -0.000000, -0.164052),(-0.377158, -0.000000, -0.331861),(-0.370524, -0.022648, -0.338494),(-0.164052, -0.000000, -0.164052),(-0.370524, 0.022648, -0.338494),(-0.377158, -0.000000, -0.331861),(-0.164052, -0.000000, -0.164052),(-0.354509, 0.032030, -0.354509),(-0.370524, 0.022648, -0.338494),(-0.164052, -0.000000, -0.164052),(-0.338494, 0.022648, -0.370524),(-0.354509, 0.032030, -0.354509),(-0.164052, -0.000000, -0.164052),(-0.331861, -0.000000, -0.377157),(-0.338494, 0.022648, -0.370524),(-0.164052, -0.000000, -0.164052),(-0.338494, -0.022648, -0.370524),(-0.331861, -0.000000, -0.377157),(-0.164052, -0.000000, -0.164052),(-0.354509, -0.032030, -0.354509),(-0.370524, -0.022648, -0.338494),(-0.377158, -0.000000, -0.331861),(-0.377158, -0.000000, -0.331861),(-0.370524, 0.022648, -0.338494),(-0.354509, 0.032030, -0.354509),(-0.354509, 0.032030, -0.354509),(-0.338494, 0.022648, -0.370524),(-0.331861, -0.000000, -0.377157),(-0.331861, -0.000000, -0.377157),(-0.338494, -0.022648, -0.370524),(-0.354509, -0.032030, -0.354509),(-0.354509, -0.032030, -0.354509),(-0.377158, -0.000000, -0.331861),(-0.354509, 0.032030, -0.354509),(-0.354509, 0.032030, -0.354509),(-0.331861, -0.000000, -0.377157),(-0.354509, -0.032030, -0.354509),(-0.015524, -0.417144, 0.000000),(0.000001, -0.417144, 0.017897),(0.000001, -0.156002, 0.029354),(0.000000, 0.181373, 0.036077),(0.128250, 0.128250, 0.036077),(0.128250, 0.128250, -0.036077),(-0.072648, 0.072648, -0.153760),(0.000000, 0.102739, -0.153760),(0.000000, 0.036077, -0.181373),(0.128250, 0.128250, 0.036077),(0.000000, 0.181373, 0.036077),(0.000000, 0.153760, 0.102740),(0.025511, 0.025510, -0.181373),(0.000000, 0.036077, -0.181373),(0.000000, 0.102739, -0.153760),(0.181373, -0.000000, -0.036077),(0.181373, -0.000000, 0.036077),(0.128250, -0.128250, 0.036077),(0.000000, 0.153760, 0.102740),(-0.108725, 0.108725, 0.102740),(-0.072648, 0.072648, 0.153761),(0.000000, 0.102739, 0.153761),(0.000000, 0.036077, 0.181373),(0.025511, 0.025510, 0.181373),(0.102739, -0.000000, 0.153761),(0.036077, -0.000000, 0.181373),(0.025510, -0.025511, 0.181373),(0.000000, 0.153760, 0.102740),(0.000000, 0.102739, 0.153761),(0.072648, 0.072648, 0.153761),(0.000000, 0.181373, 0.036077),(-0.128250, 0.128250, 0.036077),(-0.108725, 0.108725, 0.102740),(0.181373, -0.000000, 0.036077),(0.153760, -0.000000, 0.102740),(0.108725, -0.108725, 0.102740),(0.128250, 0.128250, -0.036077),(0.128250, 0.128250, 0.036077),(0.181373, -0.000000, 0.036077),(0.108725, 0.108725, 0.102740),(0.072648, 0.072648, 0.153761),(0.102739, -0.000000, 0.153761),(0.025511, 0.025510, -0.181373),(0.072648, 0.072648, -0.153760),(0.102739, -0.000000, -0.153760),(0.000000, 0.181373, -0.036077),(0.128250, 0.128250, -0.036077),(0.108725, 0.108725, -0.102739),(-0.072648, 0.072648, 0.153761),(-0.025510, 0.025511, 0.181373),(0.000000, 0.036077, 0.181373),(0.153760, -0.000000, -0.102739),(0.181373, -0.000000, -0.036077),(0.128250, -0.128250, -0.036077),(0.108725, -0.108725, 0.102740),(0.153760, -0.000000, 0.102740),(0.102739, -0.000000, 0.153761),(0.128250, -0.128250, -0.036077),(0.128250, -0.128250, 0.036077),(-0.000000, -0.181373, 0.036077),(0.102739, -0.000000, -0.153760),(0.153760, -0.000000, -0.102739),(0.108725, -0.108725, -0.102739),(0.072648, -0.072648, 0.153761),(0.025510, -0.025511, 0.181373),(-0.000000, -0.036077, 0.181373),(0.036077, -0.000000, -0.181373),(0.102739, -0.000000, -0.153760),(0.072648, -0.072648, -0.153760),(0.128250, -0.128250, 0.036077),(0.108725, -0.108725, 0.102740),(-0.000000, -0.153760, 0.102740),(-0.000000, -0.153760, 0.102740),(0.108725, -0.108725, 0.102740),(0.072648, -0.072648, 0.153761),(-0.000000, -0.181373, -0.036077),(-0.000000, -0.181373, 0.036077),(-0.128250, -0.128250, 0.036077),(0.108725, -0.108725, -0.102739),(0.128250, -0.128250, -0.036077),(-0.000000, -0.181373, -0.036077),(-0.000000, -0.102739, 0.153761),(-0.000000, -0.036077, 0.181373),(-0.025511, -0.025510, 0.181373),(0.025510, -0.025511, -0.181373),(0.072648, -0.072648, -0.153760),(-0.000000, -0.102739, -0.153760),(-0.000000, -0.181373, 0.036077),(-0.000000, -0.153760, 0.102740),(-0.108725, -0.108725, 0.102740),(0.072648, -0.072648, -0.153760),(0.108725, -0.108725, -0.102739),(-0.000000, -0.153760, -0.102739),(-0.000000, -0.153760, 0.102740),(-0.000000, -0.102739, 0.153761),(-0.072648, -0.072648, 0.153761),(-0.128250, -0.128250, -0.036077),(-0.128250, -0.128250, 0.036077),(-0.181373, 0.000000, 0.036077),(-0.000000, -0.153760, -0.102739),(-0.000000, -0.181373, -0.036077),(-0.128250, -0.128250, -0.036077),(-0.108725, -0.108725, 0.102740),(-0.072648, -0.072648, 0.153761),(-0.102739, 0.000000, 0.153761),(-0.000000, -0.036077, -0.181373),(-0.000000, -0.102739, -0.153760),(-0.072648, -0.072648, -0.153760),(-0.128250, -0.128250, 0.036077),(-0.108725, -0.108725, 0.102740),(-0.153760, 0.000000, 0.102740),(-0.000000, -0.102739, -0.153760),(-0.000000, -0.153760, -0.102739),(-0.108725, -0.108725, -0.102739),(-0.102739, 0.000000, 0.153761),(-0.072648, -0.072648, 0.153761),(-0.025511, -0.025510, 0.181373),(-0.181373, 0.000000, -0.036077),(-0.181373, 0.000000, 0.036077),(-0.128250, 0.128250, 0.036077),(-0.102739, 0.000000, -0.153760),(-0.072648, -0.072648, -0.153760),(-0.108725, -0.108725, -0.102739),(-0.108725, -0.108725, -0.102739),(-0.128250, -0.128250, -0.036077),(-0.181373, 0.000000, -0.036077),(-0.025511, -0.025510, -0.181373),(-0.072648, -0.072648, -0.153760),(-0.102739, 0.000000, -0.153760),(-0.181373, 0.000000, 0.036077),(-0.153760, 0.000000, 0.102740),(-0.108725, 0.108725, 0.102740),(-0.072648, 0.072648, 0.153761),(-0.102739, 0.000000, 0.153761),(-0.036077, 0.000000, 0.181373),(-0.128250, 0.128250, 0.036077),(0.000000, 0.181373, 0.036077),(0.000000, 0.181373, -0.036077),(-0.102739, 0.000000, -0.153760),(-0.153760, 0.000000, -0.102739),(-0.108725, 0.108725, -0.102739),(-0.153760, 0.000000, -0.102739),(-0.181373, 0.000000, -0.036077),(-0.128250, 0.128250, -0.036077),(-0.153760, 0.000000, 0.102740),(-0.102739, 0.000000, 0.153761),(-0.072648, 0.072648, 0.153761),(-0.036077, 0.000000, -0.181373),(-0.102739, 0.000000, -0.153760),(-0.072648, 0.072648, -0.153760),(-0.108725, 0.108725, -0.102739),(0.000000, 0.153760, -0.102739),(0.000000, 0.102739, -0.153760),(-0.128250, 0.128250, -0.036077),(0.000000, 0.181373, -0.036077),(0.000000, 0.153760, -0.102739),(0.153760, -0.000000, -0.102739),(0.108725, 0.108725, -0.102739),(0.128250, 0.128250, -0.036077),(0.000000, 0.153760, -0.102739),(0.108725, 0.108725, -0.102739),(0.072648, 0.072648, -0.153760),(0.102739, -0.000000, 0.153761),(0.072648, 0.072648, 0.153761),(0.025511, 0.025510, 0.181373),(0.072648, 0.072648, -0.153760),(0.108725, 0.108725, -0.102739),(0.153760, -0.000000, -0.102739),(0.128250, 0.128250, 0.036077),(0.108725, 0.108725, 0.102740),(0.153760, -0.000000, 0.102740),(-0.501351, -0.032029, -0.000000),(-0.501351, -0.022648, 0.022648),(-0.501351, 0.000000, 0.032030),(-0.501351, 0.000000, 0.032030),(-0.501351, 0.022649, 0.022648),(-0.501351, 0.032030, -0.000000),(-0.501351, 0.032030, -0.000000),(-0.501351, 0.022649, -0.022648),(-0.501351, 0.000000, -0.032030),(-0.501351, 0.000000, -0.032030),(-0.501351, -0.022648, -0.022648),(-0.501351, -0.032029, -0.000000),(-0.501351, -0.032029, -0.000000),(-0.501351, 0.000000, 0.032030),(-0.501351, 0.032030, -0.000000),(-0.501351, 0.032030, -0.000000),(-0.501351, 0.000000, -0.032030),(-0.501351, -0.032029, -0.000000),(-0.354509, -0.032030, -0.354509),(-0.338494, -0.022648, -0.370524),(-0.164052, -0.000000, -0.164052),(0.000000, -0.032030, -0.501351),(-0.022648, -0.022648, -0.501351),(-0.032030, 0.000000, -0.501351),(-0.032030, 0.000000, -0.501351),(-0.022648, 0.022648, -0.501351),(0.000000, 0.032030, -0.501351),(0.000000, 0.032030, -0.501351),(0.022648, 0.022648, -0.501351),(0.032030, 0.000000, -0.501351),(0.032030, 0.000000, -0.501351),(0.022648, -0.022648, -0.501351),(0.000000, -0.032030, -0.501351),(0.000000, -0.032030, -0.501351),(-0.032030, 0.000000, -0.501351),(0.000000, 0.032030, -0.501351),(0.000000, 0.032030, -0.501351),(0.032030, 0.000000, -0.501351),(0.000000, -0.032030, -0.501351),(0.501351, -0.000000, 0.032030),(0.501351, -0.022648, 0.022648),(0.501351, -0.032030, 0.000000),(0.501351, -0.032030, 0.000000),(0.501351, -0.022648, -0.022648),(0.501351, -0.000000, -0.032030),(0.501351, -0.000000, -0.032030),(0.501351, 0.022648, -0.022648),(0.501351, 0.032030, 0.000000),(0.501351, 0.032030, 0.000000),(0.501351, 0.022648, 0.022648),(0.501351, -0.000000, 0.032030),(0.501351, -0.000000, 0.032030),(0.501351, -0.032030, 0.000000),(0.501351, -0.000000, -0.032030),(0.501351, -0.000000, -0.032030),(0.501351, 0.032030, 0.000000),(0.501351, -0.000000, 0.032030),(-0.032030, -0.000000, 0.501351),(-0.022648, -0.022648, 0.501351),(0.000000, -0.032030, 0.501351),(0.000000, -0.032030, 0.501351),(0.022648, -0.022648, 0.501351),(0.032030, -0.000000, 0.501351),(0.032030, -0.000000, 0.501351),(0.022648, 0.022648, 0.501351),(0.000000, 0.032030, 0.501351),(0.000000, 0.032030, 0.501351),(-0.022648, 0.022648, 0.501351),(-0.032030, -0.000000, 0.501351),(-0.032030, -0.000000, 0.501351),(0.000000, -0.032030, 0.501351),(0.032030, -0.000000, 0.501351),(0.032030, -0.000000, 0.501351),(0.000000, 0.032030, 0.501351),(-0.032030, -0.000000, 0.501351),(0.000001, -0.156002, 0.029354),(0.000001, -0.417144, 0.017897),(0.015525, -0.417144, 0.000000),(-0.037686, -0.156002, 0.000000),(-0.015524, -0.417144, 0.000000),(0.000001, -0.156002, 0.029354),(0.037687, -0.156002, 0.000000),(0.000001, -0.156002, 0.029354),(0.015525, -0.417144, 0.000000),(-0.015524, -0.417144, 0.000000),(0.000001, -0.156002, -0.029353),(0.000001, -0.417144, -0.017896),(0.000001, -0.156002, -0.029353),(0.015525, -0.417144, 0.000000),(0.000001, -0.417144, -0.017896),(-0.037686, -0.156002, 0.000000),(0.000001, -0.156002, -0.029353),(-0.015524, -0.417144, 0.000000),(0.037687, -0.156002, 0.000000),(0.015525, -0.417144, 0.000000),(0.000001, -0.156002, -0.029353),(0.000001, -0.417144, 0.017897),(-0.015524, -0.417144, 0.000000),(-0.127998, -0.318886, 0.000000),(0.128000, -0.318886, 0.000000),(0.015525, -0.417144, 0.000000),(0.000001, -0.417144, 0.017897),(0.000001, -0.625057, 0.000000),(0.000001, -0.417144, 0.017897),(-0.127998, -0.318886, 0.000000),(0.000001, -0.625057, 0.000000),(0.128000, -0.318886, 0.000000),(0.000001, -0.417144, 0.017897),(0.000001, -0.417144, -0.017896),(-0.127998, -0.318886, 0.000000),(-0.015524, -0.417144, 0.000000),(0.128000, -0.318886, 0.000000),(0.000001, -0.417144, -0.017896),(0.015525, -0.417144, 0.000000),(0.000001, -0.625057, 0.000000),(-0.127998, -0.318886, 0.000000),(0.000001, -0.417144, -0.017896),(0.000001, -0.625057, 0.000000),(0.000001, -0.417144, -0.017896),(0.128000, -0.318886, 0.000000),(0.000000, 0.000000, 0.232005),(-0.032030, -0.000000, 0.501351),(-0.022648, 0.022648, 0.501351),(-0.022648, 0.022648, 0.501351),(-0.022648, -0.022648, 0.501351),(0.000000, -0.032030, 0.501351),(0.000000, 0.032030, 0.501351),(0.022648, -0.022648, 0.501351),(0.022648, 0.022648, 0.501351),(-0.022648, 0.022648, 0.501351),(0.000000, -0.032030, 0.501351),(0.000000, 0.032030, 0.501351),(0.022648, 0.022648, 0.501351),(0.032030, -0.000000, 0.501351),(0.000000, 0.000000, 0.232005),(0.000000, 0.000000, 0.232005),(-0.022648, 0.022648, 0.501351),(0.000000, 0.032030, 0.501351),(0.000000, 0.000000, 0.232005),(0.000000, 0.032030, 0.501351),(0.022648, 0.022648, 0.501351),(-0.338494, -0.022649, 0.370524),(-0.354509, -0.032030, 0.354509),(-0.164052, -0.000000, 0.164053),(-0.331861, -0.000000, 0.377158),(-0.338494, -0.022649, 0.370524),(-0.164052, -0.000000, 0.164053),(-0.338494, 0.022648, 0.370524),(-0.331861, -0.000000, 0.377158),(-0.164052, -0.000000, 0.164053),(-0.354509, 0.032030, 0.354509),(-0.338494, 0.022648, 0.370524),(-0.164052, -0.000000, 0.164053),(-0.370524, 0.022648, 0.338494),(-0.354509, 0.032030, 0.354509),(-0.164052, -0.000000, 0.164053),(-0.377158, -0.000000, 0.331861),(-0.370524, 0.022648, 0.338494),(-0.164052, -0.000000, 0.164053),(-0.370524, -0.022649, 0.338494),(-0.377158, -0.000000, 0.331861),(-0.164052, -0.000000, 0.164053),(-0.354509, -0.032030, 0.354509),(-0.338494, -0.022649, 0.370524),(-0.331861, -0.000000, 0.377158),(-0.331861, -0.000000, 0.377158),(-0.338494, 0.022648, 0.370524),(-0.354509, 0.032030, 0.354509),(-0.354509, 0.032030, 0.354509),(-0.370524, 0.022648, 0.338494),(-0.377158, -0.000000, 0.331861),(-0.377158, -0.000000, 0.331861),(-0.370524, -0.022649, 0.338494),(-0.354509, -0.032030, 0.354509),(-0.354509, -0.032030, 0.354509),(-0.331861, -0.000000, 0.377158),(-0.354509, 0.032030, 0.354509),(-0.354509, 0.032030, 0.354509),(-0.377158, -0.000000, 0.331861),(-0.354509, -0.032030, 0.354509),(-0.354509, -0.032030, 0.354509),(-0.370524, -0.022649, 0.338494),(-0.164052, -0.000000, 0.164053),(0.370524, -0.022649, 0.338494),(0.354509, -0.032030, 0.354509),(0.164052, -0.000000, 0.164053),(0.377158, -0.000000, 0.331861),(0.370524, -0.022649, 0.338494),(0.164052, -0.000000, 0.164053),(0.370524, 0.022648, 0.338494),(0.377158, -0.000000, 0.331861),(0.164052, -0.000000, 0.164053),(0.354509, 0.032030, 0.354509),(0.370524, 0.022648, 0.338494),(0.164052, -0.000000, 0.164053),(0.338494, 0.022648, 0.370524),(0.354509, 0.032030, 0.354509),(0.164052, -0.000000, 0.164053),(0.331861, -0.000000, 0.377158),(0.338494, 0.022648, 0.370524),(0.164052, -0.000000, 0.164053),(0.338494, -0.022649, 0.370524),(0.331861, -0.000000, 0.377158),(0.164052, -0.000000, 0.164053),(0.354509, -0.032030, 0.354509),(0.370524, -0.022649, 0.338494),(0.377158, -0.000000, 0.331861),(0.377158, -0.000000, 0.331861),(0.370524, 0.022648, 0.338494),(0.354509, 0.032030, 0.354509),(0.354509, 0.032030, 0.354509),(0.338494, 0.022648, 0.370524),(0.331861, -0.000000, 0.377158),(0.331861, -0.000000, 0.377158),(0.338494, -0.022649, 0.370524),(0.354509, -0.032030, 0.354509),(0.354509, -0.032030, 0.354509),(0.377158, -0.000000, 0.331861),(0.354509, 0.032030, 0.354509),(0.354509, 0.032030, 0.354509),(0.331861, -0.000000, 0.377158),(0.354509, -0.032030, 0.354509),(0.354509, -0.032030, 0.354509),(0.338494, -0.022649, 0.370524),(0.164052, -0.000000, 0.164053),(0.338494, -0.022648, -0.370524),(0.354509, -0.032030, -0.354509),(0.164052, -0.000000, -0.164052),(0.331861, -0.000000, -0.377157),(0.338494, -0.022648, -0.370524),(0.164052, -0.000000, -0.164052),(0.338494, 0.022648, -0.370524),(0.331861, -0.000000, -0.377157),(0.164052, -0.000000, -0.164052),(0.354509, 0.032030, -0.354509),(0.338494, 0.022648, -0.370524),(0.164052, -0.000000, -0.164052),(0.370524, 0.022648, -0.338494),(0.354509, 0.032030, -0.354509),(0.164052, -0.000000, -0.164052),(0.377158, -0.000000, -0.331861),(0.370524, 0.022648, -0.338494),(0.164052, -0.000000, -0.164052),(0.370524, -0.022648, -0.338494),(0.377158, -0.000000, -0.331861),(0.164052, -0.000000, -0.164052),(0.354509, -0.032030, -0.354509),(0.338494, -0.022648, -0.370524),(0.331861, -0.000000, -0.377157),(0.331861, -0.000000, -0.377157),(0.338494, 0.022648, -0.370524),(0.354509, 0.032030, -0.354509),(0.354509, 0.032030, -0.354509),(0.370524, 0.022648, -0.338494),(0.377158, -0.000000, -0.331861),(0.377158, -0.000000, -0.331861),(0.370524, -0.022648, -0.338494),(0.354509, -0.032030, -0.354509),(0.354509, -0.032030, -0.354509),(0.331861, -0.000000, -0.377157),(0.354509, 0.032030, -0.354509),(0.354509, 0.032030, -0.354509),(0.377158, -0.000000, -0.331861),(0.354509, -0.032030, -0.354509),(0.354509, -0.032030, -0.354509),(0.370524, -0.022648, -0.338494),(0.164052, -0.000000, -0.164052),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/image.py",
    "content": "SHAPE = ((0.179200, -0.003164, 0.143934),(-0.379381, -0.003164, 0.218799),(0.374179, -0.003164, 0.218799),(0.176258, -0.003164, 0.053778),(-0.042987, -0.003164, 0.049414),(0.152390, -0.003164, 0.064234),(0.374179, -0.003164, -0.227073),(0.224317, -0.003164, 0.064234),(0.374179, -0.003164, 0.218799),(0.374179, -0.003164, -0.227073),(0.203420, -0.003164, 0.053778),(0.224317, -0.003164, 0.064234),(-0.042987, -0.003164, 0.049414),(0.176258, -0.003164, 0.053778),(0.255820, -0.003164, -0.227073),(0.255820, -0.003164, -0.227073),(0.203420, -0.003164, 0.053778),(0.374179, -0.003164, -0.227073),(0.176258, -0.003164, 0.053778),(0.203420, -0.003164, 0.053778),(0.255820, -0.003164, -0.227073),(0.152390, -0.003164, 0.064234),(-0.042987, -0.003164, 0.049414),(0.140885, -0.003164, 0.085722),(-0.379381, -0.003164, 0.218799),(-0.185834, -0.003164, -0.056347),(-0.379381, -0.003164, -0.227073),(-0.379381, -0.003164, -0.227073),(-0.185834, -0.003164, -0.056347),(-0.245138, -0.003164, -0.227073),(-0.185834, -0.003164, -0.056347),(-0.042987, -0.003164, 0.049414),(-0.115578, -0.003164, -0.121322),(0.240318, -0.003164, 0.085722),(0.374179, -0.003164, 0.218799),(0.224317, -0.003164, 0.064234),(0.240318, -0.003164, 0.110617),(0.374179, -0.003164, 0.218799),(0.240318, -0.003164, 0.085722),(-0.379381, -0.003164, 0.218799),(-0.042987, -0.003164, 0.049414),(-0.185834, -0.003164, -0.056347),(-0.042987, -0.003164, 0.049414),(0.141931, -0.003164, 0.110617),(0.140885, -0.003164, 0.085722),(-0.042987, -0.003164, 0.049414),(0.155332, -0.003164, 0.133878),(0.141931, -0.003164, 0.110617),(0.227260, -0.003164, 0.133878),(0.374179, -0.003164, 0.218799),(0.240318, -0.003164, 0.110617),(0.206362, -0.003164, 0.143301),(0.374179, -0.003164, 0.218799),(0.227260, -0.003164, 0.133878),(-0.379381, -0.003164, 0.218799),(0.155332, -0.003164, 0.133878),(-0.042987, -0.003164, 0.049414),(0.179200, -0.003164, 0.143934),(0.374179, -0.003164, 0.218799),(0.206362, -0.003164, 0.143301),(-0.379381, -0.003164, 0.218799),(0.179200, -0.003164, 0.143934),(0.155332, -0.003164, 0.133878),(0.172613, -0.005452, 0.169954),(0.374179, -0.005452, 0.218799),(-0.379381, -0.005452, 0.218799),(0.374179, -0.005452, -0.227073),(0.374179, -0.005452, 0.218799),(0.243650, -0.005452, 0.044467),(0.374179, -0.005452, -0.227073),(0.243650, -0.005452, 0.044467),(0.210748, -0.005452, 0.028005),(0.336084, -0.005452, -0.227073),(0.374179, -0.005452, -0.227073),(0.210748, -0.005452, 0.028005),(0.167981, -0.005452, 0.028005),(0.336084, -0.005452, -0.227073),(0.210748, -0.005452, 0.028005),(0.130400, -0.005452, 0.044467),(0.112286, -0.005452, 0.078300),(-0.059786, -0.005452, 0.136211),(-0.379381, -0.005452, 0.218799),(-0.379381, -0.005452, -0.227073),(-0.212899, -0.005452, 0.046316),(-0.379381, -0.005452, -0.227073),(-0.313268, -0.005452, -0.227073),(-0.212899, -0.005452, 0.046316),(-0.212899, -0.005452, 0.046316),(-0.128645, -0.005452, -0.037325),(-0.059786, -0.005452, 0.136211),(0.268843, -0.005452, 0.078300),(0.243650, -0.005452, 0.044467),(0.374179, -0.005452, 0.218799),(0.268843, -0.005452, 0.117497),(0.268843, -0.005452, 0.078300),(0.374179, -0.005452, 0.218799),(-0.379381, -0.005452, 0.218799),(-0.212899, -0.005452, 0.046316),(-0.059786, -0.005452, 0.136211),(-0.059786, -0.005452, 0.136211),(0.112286, -0.005452, 0.078300),(0.113934, -0.005452, 0.117497),(-0.059786, -0.005452, 0.136211),(0.113934, -0.005452, 0.117497),(0.135032, -0.005452, 0.154122),(0.248282, -0.005452, 0.154122),(0.268843, -0.005452, 0.117497),(0.374179, -0.005452, 0.218799),(0.215379, -0.005452, 0.168957),(0.248282, -0.005452, 0.154122),(0.374179, -0.005452, 0.218799),(-0.379381, -0.005452, 0.218799),(-0.059786, -0.005452, 0.136211),(0.135032, -0.005452, 0.154122),(0.172613, -0.005452, 0.169954),(0.215379, -0.005452, 0.168957),(0.374179, -0.005452, 0.218799),(-0.379381, -0.005452, 0.218799),(0.135032, -0.005452, 0.154122),(0.172613, -0.005452, 0.169954),(0.501103, 0.000000, -0.325349),(0.501103, -0.000000, 0.325349),(0.433878, -0.000000, 0.269627),(-0.501103, -0.000000, 0.325349),(-0.501103, 0.000000, -0.325349),(-0.433878, 0.000000, -0.269627),(0.433878, -0.000000, 0.269627),(0.501103, -0.000000, 0.325349),(-0.501103, -0.000000, 0.325349),(-0.433878, 0.000000, -0.269627),(-0.501103, 0.000000, -0.325349),(0.501103, 0.000000, -0.325349),(0.336084, -0.005452, -0.227073),(0.130400, -0.005452, 0.044467),(-0.059786, -0.005452, 0.136211),(0.336084, -0.005452, -0.227073),(0.167981, -0.005452, 0.028005),(0.130400, -0.005452, 0.044467),(0.501103, 0.000000, -0.325349),(0.433878, -0.000000, 0.269627),(0.433878, 0.000000, -0.269627),(-0.501103, -0.000000, 0.325349),(-0.433878, 0.000000, -0.269627),(-0.433878, -0.000000, 0.269627),(0.433878, -0.000000, 0.269627),(-0.501103, -0.000000, 0.325349),(-0.433878, -0.000000, 0.269627),(-0.433878, 0.000000, -0.269627),(0.501103, 0.000000, -0.325349),(0.433878, 0.000000, -0.269627),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/link.py",
    "content": "SHAPE = ((0.153029, -0.091493, -0.027939),(0.036019, -0.018590, 0.143833),(0.046648, -0.042210, 0.187375),(0.153029, -0.091493, -0.027939),(0.046648, -0.042210, 0.187375),(0.174287, -0.121736, -0.000000),(-0.007655, -0.109699, -0.173613),(0.330949, -0.109699, -0.173613),(0.303646, -0.114328, -0.122298),(-0.007655, -0.109699, -0.173613),(0.303646, -0.114328, -0.122298),(0.019648, -0.114328, -0.122298),(0.367100, -0.090125, 0.028674),(0.303646, -0.051107, -0.064950),(0.291960, -0.089904, -0.076381),(0.367100, -0.090125, 0.028674),(0.291960, -0.089904, -0.076381),(0.343727, -0.121736, 0.000000),(0.019648, -0.114328, -0.122298),(0.303646, -0.114328, -0.122298),(0.291960, -0.089904, -0.076381),(0.019648, -0.114328, -0.122298),(0.291960, -0.089904, -0.076381),(0.031335, -0.089904, -0.076381),(0.019648, -0.051107, -0.064950),(0.303646, -0.051107, -0.064950),(0.330949, -0.022160, -0.094205),(0.019648, -0.051107, -0.064950),(0.330949, -0.022160, -0.094205),(-0.007655, -0.022160, -0.094205),(0.474212, -0.091339, 0.027573),(0.357202, -0.019389, -0.145071),(0.330949, -0.022160, -0.094205),(0.474212, -0.091339, 0.027573),(0.330949, -0.022160, -0.094205),(0.421706, -0.077966, 0.039704),(-0.007655, -0.221312, 0.094205),(-0.033908, -0.224082, 0.145071),(-0.150918, -0.152133, -0.027573),(-0.007655, -0.221312, 0.094205),(-0.150918, -0.152133, -0.027573),(-0.098412, -0.165505, -0.039704),(-0.033908, -0.224082, 0.145071),(-0.044537, -0.200221, 0.188328),(-0.172177, -0.121736, 0.000000),(-0.033908, -0.224082, 0.145071),(-0.172177, -0.121736, 0.000000),(-0.150918, -0.152133, -0.027573),(-0.044537, -0.043250, -0.188328),(0.367831, -0.043250, -0.188328),(0.357202, -0.080183, -0.200218),(-0.044537, -0.043250, -0.188328),(0.357202, -0.080183, -0.200218),(-0.033908, -0.080183, -0.200218),(0.019648, -0.192364, 0.064950),(-0.007655, -0.221312, 0.094205),(-0.098412, -0.165505, -0.039704),(0.019648, -0.192364, 0.064950),(-0.098412, -0.165505, -0.039704),(-0.043806, -0.153346, -0.028674),(0.291960, -0.089904, -0.076381),(0.303646, -0.114328, -0.122298),(0.367100, -0.153346, -0.028674),(0.291960, -0.089904, -0.076381),(0.367100, -0.153346, -0.028674),(0.343727, -0.121736, 0.000000),(0.031335, -0.089904, -0.076381),(0.291960, -0.089904, -0.076381),(0.303646, -0.051107, -0.064950),(0.031335, -0.089904, -0.076381),(0.303646, -0.051107, -0.064950),(0.019648, -0.051107, -0.064950),(0.421706, -0.165505, -0.039704),(0.330949, -0.221312, 0.094205),(0.303646, -0.192364, 0.064950),(0.421706, -0.165505, -0.039704),(0.303646, -0.192364, 0.064950),(0.367100, -0.153346, -0.028674),(-0.007655, -0.221312, 0.094205),(0.330949, -0.221312, 0.094205),(0.357202, -0.224082, 0.145071),(-0.007655, -0.221312, 0.094205),(0.357202, -0.224082, 0.145071),(-0.033908, -0.224082, 0.145071),(0.474212, -0.152133, -0.027573),(0.495471, -0.121736, 0.000000),(0.367831, -0.200221, 0.188328),(0.474212, -0.152133, -0.027573),(0.367831, -0.200221, 0.188328),(0.357202, -0.224082, 0.145071),(-0.044537, -0.200221, 0.188328),(0.367831, -0.200221, 0.188328),(0.357202, -0.163288, 0.200218),(-0.044537, -0.200221, 0.188328),(0.357202, -0.163288, 0.200218),(-0.033908, -0.163288, 0.200218),(-0.007655, -0.133772, 0.173613),(0.330949, -0.133772, 0.173613),(0.303646, -0.129143, 0.122299),(-0.007655, -0.133772, 0.173613),(0.303646, -0.129143, 0.122299),(0.019648, -0.129143, 0.122299),(0.343727, -0.121736, 0.000000),(0.367100, -0.153346, -0.028674),(0.303646, -0.192364, 0.064950),(0.343727, -0.121736, 0.000000),(0.303646, -0.192364, 0.064950),(0.291960, -0.153567, 0.076381),(-0.043806, -0.153346, -0.028674),(-0.098412, -0.165505, -0.039704),(-0.007655, -0.109699, -0.173613),(-0.043806, -0.153346, -0.028674),(-0.007655, -0.109699, -0.173613),(0.019648, -0.114328, -0.122298),(-0.007655, -0.022160, -0.094205),(0.330949, -0.022160, -0.094205),(0.357202, -0.019389, -0.145071),(-0.007655, -0.022160, -0.094205),(0.357202, -0.019389, -0.145071),(-0.033908, -0.019389, -0.145071),(-0.020433, -0.121736, 0.000000),(-0.043806, -0.153346, -0.028674),(0.019648, -0.114328, -0.122298),(-0.020433, -0.121736, 0.000000),(0.019648, -0.114328, -0.122298),(0.031335, -0.089904, -0.076381),(-0.007655, -0.109699, -0.173613),(-0.098412, -0.165505, -0.039704),(-0.150918, -0.152133, -0.027573),(-0.007655, -0.109699, -0.173613),(-0.150918, -0.152133, -0.027573),(-0.033908, -0.080183, -0.200218),(-0.033908, -0.163288, 0.200218),(0.357202, -0.163288, 0.200218),(0.330949, -0.133772, 0.173613),(-0.033908, -0.163288, 0.200218),(0.330949, -0.133772, 0.173613),(-0.007655, -0.133772, 0.173613),(0.367831, -0.043250, -0.188328),(0.357202, -0.019389, -0.145071),(0.474212, -0.091339, 0.027573),(0.367831, -0.043250, -0.188328),(0.474212, -0.091339, 0.027573),(0.495471, -0.121736, 0.000000),(0.357202, -0.080183, -0.200218),(0.367831, -0.043250, -0.188328),(0.495471, -0.121736, 0.000000),(0.357202, -0.080183, -0.200218),(0.495471, -0.121736, 0.000000),(0.474212, -0.152133, -0.027573),(-0.007655, -0.133772, 0.173613),(0.019648, -0.129143, 0.122299),(-0.043806, -0.090125, 0.028674),(-0.007655, -0.133772, 0.173613),(-0.043806, -0.090125, 0.028674),(-0.098412, -0.077966, 0.039704),(0.031335, -0.153567, 0.076381),(0.291960, -0.153567, 0.076381),(0.303646, -0.192364, 0.064950),(0.031335, -0.153567, 0.076381),(0.303646, -0.192364, 0.064950),(0.019648, -0.192364, 0.064950),(-0.043806, -0.090125, 0.028674),(-0.020433, -0.121736, 0.000000),(0.031335, -0.089904, -0.076381),(-0.043806, -0.090125, 0.028674),(0.031335, -0.089904, -0.076381),(0.019648, -0.051107, -0.064950),(0.421706, -0.077966, 0.039704),(0.330949, -0.022160, -0.094205),(0.303646, -0.051107, -0.064950),(0.421706, -0.077966, 0.039704),(0.303646, -0.051107, -0.064950),(0.367100, -0.090125, 0.028674),(-0.150918, -0.091339, 0.027573),(-0.033908, -0.163288, 0.200218),(-0.007655, -0.133772, 0.173613),(-0.150918, -0.091339, 0.027573),(-0.007655, -0.133772, 0.173613),(-0.098412, -0.077966, 0.039704),(0.421706, -0.165505, -0.039704),(0.474212, -0.152133, -0.027573),(0.357202, -0.224082, 0.145071),(0.421706, -0.165505, -0.039704),(0.357202, -0.224082, 0.145071),(0.330949, -0.221312, 0.094205),(-0.044537, -0.200221, 0.188328),(-0.033908, -0.224082, 0.145071),(0.357202, -0.224082, 0.145071),(-0.044537, -0.200221, 0.188328),(0.357202, -0.224082, 0.145071),(0.367831, -0.200221, 0.188328),(-0.044537, -0.200221, 0.188328),(-0.033908, -0.163288, 0.200218),(-0.150918, -0.091339, 0.027573),(-0.044537, -0.200221, 0.188328),(-0.150918, -0.091339, 0.027573),(-0.172177, -0.121736, 0.000000),(-0.007655, -0.221312, 0.094205),(0.019648, -0.192364, 0.064950),(0.303646, -0.192364, 0.064950),(-0.007655, -0.221312, 0.094205),(0.303646, -0.192364, 0.064950),(0.330949, -0.221312, 0.094205),(0.019648, -0.129143, 0.122299),(0.031335, -0.153567, 0.076381),(-0.020433, -0.121736, 0.000000),(0.019648, -0.129143, 0.122299),(-0.020433, -0.121736, 0.000000),(-0.043806, -0.090125, 0.028674),(0.019648, -0.129143, 0.122299),(0.303646, -0.129143, 0.122299),(0.291960, -0.153567, 0.076381),(0.019648, -0.129143, 0.122299),(0.291960, -0.153567, 0.076381),(0.031335, -0.153567, 0.076381),(-0.098412, -0.077966, 0.039704),(-0.043806, -0.090125, 0.028674),(0.019648, -0.051107, -0.064950),(-0.098412, -0.077966, 0.039704),(0.019648, -0.051107, -0.064950),(-0.007655, -0.022160, -0.094205),(0.421706, -0.077966, 0.039704),(0.330949, -0.133772, 0.173613),(0.357202, -0.163288, 0.200218),(0.421706, -0.077966, 0.039704),(0.357202, -0.163288, 0.200218),(0.474212, -0.091339, 0.027573),(-0.033908, -0.019389, -0.145071),(0.357202, -0.019389, -0.145071),(0.367831, -0.043250, -0.188328),(-0.033908, -0.019389, -0.145071),(0.367831, -0.043250, -0.188328),(-0.044537, -0.043250, -0.188328),(-0.033908, -0.080183, -0.200218),(0.357202, -0.080183, -0.200218),(0.330949, -0.109699, -0.173613),(-0.033908, -0.080183, -0.200218),(0.330949, -0.109699, -0.173613),(-0.007655, -0.109699, -0.173613),(0.303646, -0.114328, -0.122298),(0.330949, -0.109699, -0.173613),(0.421706, -0.165505, -0.039704),(0.303646, -0.114328, -0.122298),(0.421706, -0.165505, -0.039704),(0.367100, -0.153346, -0.028674),(0.421706, -0.077966, 0.039704),(0.367100, -0.090125, 0.028674),(0.303646, -0.129143, 0.122299),(0.421706, -0.077966, 0.039704),(0.303646, -0.129143, 0.122299),(0.330949, -0.133772, 0.173613),(0.367100, -0.090125, 0.028674),(0.343727, -0.121736, 0.000000),(0.291960, -0.153567, 0.076381),(0.367100, -0.090125, 0.028674),(0.291960, -0.153567, 0.076381),(0.303646, -0.129143, 0.122299),(0.330949, -0.109699, -0.173613),(0.357202, -0.080183, -0.200218),(0.474212, -0.152133, -0.027573),(0.330949, -0.109699, -0.173613),(0.474212, -0.152133, -0.027573),(0.421706, -0.165505, -0.039704),(-0.020433, -0.121736, 0.000000),(0.031335, -0.153567, 0.076381),(0.019648, -0.192364, 0.064950),(-0.020433, -0.121736, 0.000000),(0.019648, -0.192364, 0.064950),(-0.043806, -0.153346, -0.028674),(-0.172177, -0.121736, 0.000000),(-0.150918, -0.091339, 0.027573),(-0.033908, -0.019389, -0.145071),(-0.172177, -0.121736, 0.000000),(-0.033908, -0.019389, -0.145071),(-0.044537, -0.043250, -0.188328),(-0.150918, -0.091339, 0.027573),(-0.098412, -0.077966, 0.039704),(-0.007655, -0.022160, -0.094205),(-0.150918, -0.091339, 0.027573),(-0.007655, -0.022160, -0.094205),(-0.033908, -0.019389, -0.145071),(-0.305757, -0.192721, -0.064097),(-0.333060, -0.221830, -0.093001),(0.009765, -0.221830, -0.093001),(-0.305757, -0.192721, -0.064097),(0.009765, -0.221830, -0.093001),(-0.017537, -0.192721, -0.064097),(-0.333060, -0.134733, -0.173462),(0.009765, -0.134733, -0.173462),(0.036019, -0.164396, -0.199710),(-0.333060, -0.134733, -0.173462),(0.036019, -0.164396, -0.199710),(-0.359313, -0.164396, -0.199710),(-0.345838, -0.121736, -0.000000),(-0.294070, -0.153989, -0.075995),(-0.305757, -0.129820, -0.122205),(-0.345838, -0.121736, -0.000000),(-0.305757, -0.129820, -0.122205),(-0.369211, -0.090285, -0.029054),(-0.423816, -0.165284, 0.040230),(-0.369211, -0.153186, 0.029054),(-0.305757, -0.113651, 0.122205),(-0.423816, -0.165284, 0.040230),(-0.305757, -0.113651, 0.122205),(-0.333060, -0.108738, 0.173462),(0.100522, -0.165284, 0.040230),(0.009765, -0.221830, -0.093001),(0.036019, -0.224882, -0.143833),(0.100522, -0.165284, 0.040230),(0.036019, -0.224882, -0.143833),(0.153029, -0.151979, 0.027939),(0.036019, -0.079076, 0.199710),(0.009765, -0.108738, 0.173462),(0.100522, -0.165284, 0.040230),(0.036019, -0.079076, 0.199710),(0.100522, -0.165284, 0.040230),(0.153029, -0.151979, 0.027939),(-0.369942, -0.042210, 0.187375),(-0.359313, -0.079076, 0.199710),(0.036019, -0.079076, 0.199710),(-0.369942, -0.042210, 0.187375),(0.036019, -0.079076, 0.199710),(0.046648, -0.042210, 0.187375),(-0.497581, -0.121736, -0.000000),(-0.369942, -0.201262, -0.187375),(-0.359313, -0.224882, -0.143833),(-0.497581, -0.121736, -0.000000),(-0.359313, -0.224882, -0.143833),(-0.476323, -0.151979, 0.027939),(-0.369211, -0.090285, -0.029054),(-0.305757, -0.129820, -0.122205),(-0.333060, -0.134733, -0.173462),(-0.369211, -0.090285, -0.029054),(-0.333060, -0.134733, -0.173462),(-0.423816, -0.078187, -0.040230),(-0.305757, -0.113651, 0.122205),(-0.369211, -0.153186, 0.029054),(-0.345838, -0.121736, -0.000000),(-0.305757, -0.113651, 0.122205),(-0.345838, -0.121736, -0.000000),(-0.294070, -0.089482, 0.075995),(-0.305757, -0.192721, -0.064097),(-0.294070, -0.153989, -0.075995),(-0.345838, -0.121736, -0.000000),(-0.305757, -0.192721, -0.064097),(-0.345838, -0.121736, -0.000000),(-0.369211, -0.153186, 0.029054),(-0.305757, -0.129820, -0.122205),(-0.017537, -0.129820, -0.122205),(0.009765, -0.134733, -0.173462),(-0.305757, -0.129820, -0.122205),(0.009765, -0.134733, -0.173462),(-0.333060, -0.134733, -0.173462),(-0.359313, -0.224882, -0.143833),(0.036019, -0.224882, -0.143833),(0.009765, -0.221830, -0.093001),(-0.359313, -0.224882, -0.143833),(0.009765, -0.221830, -0.093001),(-0.333060, -0.221830, -0.093001),(-0.359313, -0.018590, 0.143833),(-0.476323, -0.091493, -0.027939),(-0.497581, -0.121736, -0.000000),(-0.359313, -0.018590, 0.143833),(-0.497581, -0.121736, -0.000000),(-0.369942, -0.042210, 0.187375),(-0.359313, -0.164396, -0.199710),(-0.369942, -0.201262, -0.187375),(-0.497581, -0.121736, -0.000000),(-0.359313, -0.164396, -0.199710),(-0.497581, -0.121736, -0.000000),(-0.476323, -0.091493, -0.027939),(0.009765, -0.021641, 0.093001),(0.036019, -0.018590, 0.143833),(0.153029, -0.091493, -0.027939),(0.009765, -0.021641, 0.093001),(0.153029, -0.091493, -0.027939),(0.100522, -0.078187, -0.040230),(-0.369942, -0.201262, -0.187375),(0.046648, -0.201262, -0.187375),(0.036019, -0.224882, -0.143833),(-0.369942, -0.201262, -0.187375),(0.036019, -0.224882, -0.143833),(-0.359313, -0.224882, -0.143833),(0.100522, -0.165284, 0.040230),(0.045917, -0.153186, 0.029054),(-0.017537, -0.192721, -0.064097),(0.100522, -0.165284, 0.040230),(-0.017537, -0.192721, -0.064097),(0.009765, -0.221830, -0.093001),(-0.305757, -0.192721, -0.064097),(-0.017537, -0.192721, -0.064097),(-0.029224, -0.153989, -0.075995),(-0.305757, -0.192721, -0.064097),(-0.029224, -0.153989, -0.075995),(-0.294070, -0.153989, -0.075995),(0.022543, -0.121736, -0.000000),(0.045917, -0.090285, -0.029054),(-0.017537, -0.129820, -0.122205),(0.022543, -0.121736, -0.000000),(-0.017537, -0.129820, -0.122205),(-0.029224, -0.153989, -0.075995),(0.367831, -0.200221, 0.188328),(0.495471, -0.121736, 0.000000),(0.474212, -0.091339, 0.027573),(0.367831, -0.200221, 0.188328),(0.474212, -0.091339, 0.027573),(0.357202, -0.163288, 0.200218),(-0.333060, -0.021641, 0.093001),(-0.423816, -0.078187, -0.040230),(-0.476323, -0.091493, -0.027939),(-0.333060, -0.021641, 0.093001),(-0.476323, -0.091493, -0.027939),(-0.359313, -0.018590, 0.143833),(-0.476323, -0.151979, 0.027939),(-0.359313, -0.224882, -0.143833),(-0.333060, -0.221830, -0.093001),(-0.476323, -0.151979, 0.027939),(-0.333060, -0.221830, -0.093001),(-0.423816, -0.165284, 0.040230),(-0.497581, -0.121736, -0.000000),(-0.476323, -0.151979, 0.027939),(-0.359313, -0.079076, 0.199710),(-0.497581, -0.121736, -0.000000),(-0.359313, -0.079076, 0.199710),(-0.369942, -0.042210, 0.187375),(0.046648, -0.201262, -0.187375),(0.174287, -0.121736, -0.000000),(0.153029, -0.151979, 0.027939),(0.046648, -0.201262, -0.187375),(0.153029, -0.151979, 0.027939),(0.036019, -0.224882, -0.143833),(-0.305757, -0.050750, 0.064096),(-0.333060, -0.021641, 0.093001),(0.009765, -0.021641, 0.093001),(-0.305757, -0.050750, 0.064096),(0.009765, -0.021641, 0.093001),(-0.017537, -0.050750, 0.064096),(0.045917, -0.153186, 0.029054),(0.022543, -0.121736, -0.000000),(-0.029224, -0.153989, -0.075995),(0.045917, -0.153186, 0.029054),(-0.029224, -0.153989, -0.075995),(-0.017537, -0.192721, -0.064097),(-0.017537, -0.113651, 0.122205),(-0.029224, -0.089482, 0.075995),(0.022543, -0.121736, -0.000000),(-0.017537, -0.113651, 0.122205),(0.022543, -0.121736, -0.000000),(0.045917, -0.153186, 0.029054),(0.100522, -0.078187, -0.040230),(0.009765, -0.134733, -0.173462),(-0.017537, -0.129820, -0.122205),(0.100522, -0.078187, -0.040230),(-0.017537, -0.129820, -0.122205),(0.045917, -0.090285, -0.029054),(-0.333060, -0.108738, 0.173462),(0.009765, -0.108738, 0.173462),(0.036019, -0.079076, 0.199710),(-0.333060, -0.108738, 0.173462),(0.036019, -0.079076, 0.199710),(-0.359313, -0.079076, 0.199710),(-0.369942, -0.201262, -0.187375),(-0.359313, -0.164396, -0.199710),(0.036019, -0.164396, -0.199710),(-0.369942, -0.201262, -0.187375),(0.036019, -0.164396, -0.199710),(0.046648, -0.201262, -0.187375),(-0.359313, -0.079076, 0.199710),(-0.476323, -0.151979, 0.027939),(-0.423816, -0.165284, 0.040230),(-0.359313, -0.079076, 0.199710),(-0.423816, -0.165284, 0.040230),(-0.333060, -0.108738, 0.173462),(-0.369942, -0.042210, 0.187375),(0.046648, -0.042210, 0.187375),(0.036019, -0.018590, 0.143833),(-0.369942, -0.042210, 0.187375),(0.036019, -0.018590, 0.143833),(-0.359313, -0.018590, 0.143833),(-0.333060, -0.221830, -0.093001),(-0.305757, -0.192721, -0.064097),(-0.369211, -0.153186, 0.029054),(-0.333060, -0.221830, -0.093001),(-0.369211, -0.153186, 0.029054),(-0.423816, -0.165284, 0.040230),(-0.294070, -0.089482, 0.075995),(-0.029224, -0.089482, 0.075995),(-0.017537, -0.113651, 0.122205),(-0.294070, -0.089482, 0.075995),(-0.017537, -0.113651, 0.122205),(-0.305757, -0.113651, 0.122205),(-0.294070, -0.089482, 0.075995),(-0.305757, -0.050750, 0.064096),(-0.017537, -0.050750, 0.064096),(-0.294070, -0.089482, 0.075995),(-0.017537, -0.050750, 0.064096),(-0.029224, -0.089482, 0.075995),(0.100522, -0.165284, 0.040230),(0.009765, -0.108738, 0.173462),(-0.017537, -0.113651, 0.122205),(0.100522, -0.165284, 0.040230),(-0.017537, -0.113651, 0.122205),(0.045917, -0.153186, 0.029054),(-0.359313, -0.018590, 0.143833),(0.036019, -0.018590, 0.143833),(0.009765, -0.021641, 0.093001),(-0.359313, -0.018590, 0.143833),(0.009765, -0.021641, 0.093001),(-0.333060, -0.021641, 0.093001),(-0.029224, -0.089482, 0.075995),(-0.017537, -0.050750, 0.064096),(0.045917, -0.090285, -0.029054),(-0.029224, -0.089482, 0.075995),(0.045917, -0.090285, -0.029054),(0.022543, -0.121736, -0.000000),(0.009765, -0.134733, -0.173462),(0.100522, -0.078187, -0.040230),(0.153029, -0.091493, -0.027939),(0.009765, -0.134733, -0.173462),(0.153029, -0.091493, -0.027939),(0.036019, -0.164396, -0.199710),(-0.017537, -0.050750, 0.064096),(0.009765, -0.021641, 0.093001),(0.100522, -0.078187, -0.040230),(-0.017537, -0.050750, 0.064096),(0.100522, -0.078187, -0.040230),(0.045917, -0.090285, -0.029054),(-0.369211, -0.090285, -0.029054),(-0.423816, -0.078187, -0.040230),(-0.333060, -0.021641, 0.093001),(-0.369211, -0.090285, -0.029054),(-0.333060, -0.021641, 0.093001),(-0.305757, -0.050750, 0.064096),(-0.294070, -0.153989, -0.075995),(-0.029224, -0.153989, -0.075995),(-0.017537, -0.129820, -0.122205),(-0.294070, -0.153989, -0.075995),(-0.017537, -0.129820, -0.122205),(-0.305757, -0.129820, -0.122205),(-0.305757, -0.113651, 0.122205),(-0.017537, -0.113651, 0.122205),(0.009765, -0.108738, 0.173462),(-0.305757, -0.113651, 0.122205),(0.009765, -0.108738, 0.173462),(-0.333060, -0.108738, 0.173462),(-0.345838, -0.121736, -0.000000),(-0.369211, -0.090285, -0.029054),(-0.305757, -0.050750, 0.064096),(-0.345838, -0.121736, -0.000000),(-0.305757, -0.050750, 0.064096),(-0.294070, -0.089482, 0.075995),(0.046648, -0.042210, 0.187375),(0.036019, -0.079076, 0.199710),(0.153029, -0.151979, 0.027939),(0.046648, -0.042210, 0.187375),(0.153029, -0.151979, 0.027939),(0.174287, -0.121736, -0.000000),(-0.333060, -0.134733, -0.173462),(-0.359313, -0.164396, -0.199710),(-0.476323, -0.091493, -0.027939),(-0.333060, -0.134733, -0.173462),(-0.476323, -0.091493, -0.027939),(-0.423816, -0.078187, -0.040230),(-0.150918, -0.152133, -0.027573),(-0.172177, -0.121736, 0.000000),(-0.044537, -0.043250, -0.188328),(-0.150918, -0.152133, -0.027573),(-0.044537, -0.043250, -0.188328),(-0.033908, -0.080183, -0.200218),(-0.500488, 0.000000, -0.246896),(0.500488, 0.000000, -0.246896),(0.500488, 0.000000, 0.246896),(-0.500488, 0.000000, -0.246896),(0.500488, 0.000000, 0.246896),(-0.500488, 0.000000, 0.246896),(0.153029, -0.091493, -0.027939),(0.174287, -0.121736, -0.000000),(0.046648, -0.201262, -0.187375),(0.153029, -0.091493, -0.027939),(0.046648, -0.201262, -0.187375),(0.036019, -0.164396, -0.199710),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/particle_emitter.py",
    "content": "SHAPE = ((-0.480059, 0.000000, 1.590102),(-0.480059, 0.000000, 1.797271),(-0.272890, 0.000000, 1.797271),(-0.480059, 0.000000, 1.590102),(-0.272890, 0.000000, 1.797271),(-0.272890, 0.000000, 1.590102),(0.025917, -0.000000, 0.663329),(0.025917, 0.000000, 0.893517),(0.256106, 0.000000, 0.893517),(0.025917, -0.000000, 0.663329),(0.256106, 0.000000, 0.893517),(0.256106, -0.000000, 0.663329),(-0.727202, 0.000000, 0.252196),(-0.727202, 0.000000, 0.528422),(-0.450976, 0.000000, 0.528422),(-0.727202, 0.000000, 0.252196),(-0.450976, 0.000000, 0.528422),(-0.450976, 0.000000, 0.252196),(-0.253207, -0.000000, 0.207170),(-0.253207, -0.000000, 0.483396),(0.023019, -0.000000, 0.483396),(-0.253207, -0.000000, 0.207170),(0.023019, -0.000000, 0.483396),(0.023019, -0.000000, 0.207170),(-0.230188, 0.000000, 1.150942),(-0.230188, 0.000000, 1.381130),(0.000000, 0.000000, 1.381130),(-0.230188, 0.000000, 1.150942),(0.000000, 0.000000, 1.381130),(0.000000, 0.000000, 1.150942),(-0.522977, -0.000000, 0.645539),(-0.522977, -0.000000, 0.875728),(-0.292788, -0.000000, 0.875728),(-0.522977, -0.000000, 0.645539),(-0.292788, -0.000000, 0.875728),(-0.292788, -0.000000, 0.645539),(0.085573, 0.000000, 1.549731),(0.085573, 0.000000, 1.687844),(0.223686, 0.000000, 1.687844),(0.085573, 0.000000, 1.549731),(0.223686, 0.000000, 1.687844),(0.223686, 0.000000, 1.549731),(-0.588475, 0.000000, 1.071826),(-0.588475, 0.000000, 1.255976),(-0.404325, 0.000000, 1.255976),(-0.588475, 0.000000, 1.071826),(-0.404325, 0.000000, 1.255976),(-0.404325, 0.000000, 1.071826),(0.299069, -0.000000, 0.218679),(0.299069, -0.000000, 0.471886),(0.552276, -0.000000, 0.471886),(0.299069, -0.000000, 0.218679),(0.552276, -0.000000, 0.471886),(0.552276, -0.000000, 0.218679),(-0.218725, -0.000000, 2.048898),(-0.218725, -0.000000, 2.210031),(-0.057593, -0.000000, 2.210031),(-0.218725, -0.000000, 2.048898),(-0.057593, -0.000000, 2.210031),(-0.057593, -0.000000, 2.048898),(0.103454, 0.000000, 1.076043),(0.103454, 0.000000, 1.306231),(0.333643, 0.000000, 1.306231),(0.103454, 0.000000, 1.076043),(0.333643, 0.000000, 1.306231),(0.333643, 0.000000, 1.076043),(-0.480059, 0.100000, 1.590102),(-0.272890, 0.100000, 1.590102),(-0.272890, 0.100000, 1.797271),(-0.480059, 0.100000, 1.590102),(-0.272890, 0.100000, 1.797271),(-0.480059, 0.100000, 1.797271),(0.025917, 0.100000, 0.663329),(0.256106, 0.100000, 0.663329),(0.256106, 0.100000, 0.893517),(0.025917, 0.100000, 0.663329),(0.256106, 0.100000, 0.893517),(0.025917, 0.100000, 0.893517),(-0.727202, 0.100000, 0.252196),(-0.450976, 0.100000, 0.252196),(-0.450976, 0.100000, 0.528422),(-0.727202, 0.100000, 0.252196),(-0.450976, 0.100000, 0.528422),(-0.727202, 0.100000, 0.528422),(-0.253207, 0.100000, 0.207170),(0.023019, 0.100000, 0.207170),(0.023019, 0.100000, 0.483396),(-0.253207, 0.100000, 0.207170),(0.023019, 0.100000, 0.483396),(-0.253207, 0.100000, 0.483396),(-0.230188, 0.100000, 1.150942),(0.000000, 0.100000, 1.150942),(0.000000, 0.100000, 1.381130),(-0.230188, 0.100000, 1.150942),(0.000000, 0.100000, 1.381130),(-0.230188, 0.100000, 1.381130),(-0.522977, 0.100000, 0.645539),(-0.292788, 0.100000, 0.645539),(-0.292788, 0.100000, 0.875728),(-0.522977, 0.100000, 0.645539),(-0.292788, 0.100000, 0.875728),(-0.522977, 0.100000, 0.875728),(0.085573, 0.100000, 1.549731),(0.223686, 0.100000, 1.549731),(0.223686, 0.100000, 1.687844),(0.085573, 0.100000, 1.549731),(0.223686, 0.100000, 1.687844),(0.085573, 0.100000, 1.687844),(-0.588475, 0.100000, 1.071826),(-0.404325, 0.100000, 1.071826),(-0.404325, 0.100000, 1.255976),(-0.588475, 0.100000, 1.071826),(-0.404325, 0.100000, 1.255976),(-0.588475, 0.100000, 1.255976),(0.299069, 0.100000, 0.218679),(0.552276, 0.100000, 0.218679),(0.552276, 0.100000, 0.471886),(0.299069, 0.100000, 0.218679),(0.552276, 0.100000, 0.471886),(0.299069, 0.100000, 0.471886),(-0.218725, 0.100000, 2.048898),(-0.057593, 0.100000, 2.048898),(-0.057593, 0.100000, 2.210031),(-0.218725, 0.100000, 2.048898),(-0.057593, 0.100000, 2.210031),(-0.218725, 0.100000, 2.210031),(0.103454, 0.100000, 1.076043),(0.333643, 0.100000, 1.076043),(0.333643, 0.100000, 1.306231),(0.103454, 0.100000, 1.076043),(0.333643, 0.100000, 1.306231),(0.103454, 0.100000, 1.306231),(0.085573, 0.000000, 1.687844),(0.085573, 0.000000, 1.549731),(0.085573, 0.100000, 1.549731),(0.085573, 0.000000, 1.687844),(0.085573, 0.100000, 1.549731),(0.085573, 0.100000, 1.687844),(-0.450976, 0.000000, 0.528422),(-0.727202, 0.000000, 0.528422),(-0.727202, 0.100000, 0.528422),(-0.450976, 0.000000, 0.528422),(-0.727202, 0.100000, 0.528422),(-0.450976, 0.100000, 0.528422),(-0.218725, -0.000000, 2.210031),(-0.218725, -0.000000, 2.048898),(-0.218725, 0.100000, 2.048898),(-0.218725, -0.000000, 2.210031),(-0.218725, 0.100000, 2.048898),(-0.218725, 0.100000, 2.210031),(0.223686, 0.000000, 1.687844),(0.085573, 0.000000, 1.687844),(0.085573, 0.100000, 1.687844),(0.223686, 0.000000, 1.687844),(0.085573, 0.100000, 1.687844),(0.223686, 0.100000, 1.687844),(0.256106, 0.000000, 0.893517),(0.025917, 0.000000, 0.893517),(0.025917, 0.100000, 0.893517),(0.256106, 0.000000, 0.893517),(0.025917, 0.100000, 0.893517),(0.256106, 0.100000, 0.893517),(-0.057593, -0.000000, 2.210031),(-0.218725, -0.000000, 2.210031),(-0.218725, 0.100000, 2.210031),(-0.057593, -0.000000, 2.210031),(-0.218725, 0.100000, 2.210031),(-0.057593, 0.100000, 2.210031),(-0.230188, 0.000000, 1.381130),(-0.230188, 0.000000, 1.150942),(-0.230188, 0.100000, 1.150942),(-0.230188, 0.000000, 1.381130),(-0.230188, 0.100000, 1.150942),(-0.230188, 0.100000, 1.381130),(-0.480059, 0.000000, 1.797271),(-0.480059, 0.000000, 1.590102),(-0.480059, 0.100000, 1.590102),(-0.480059, 0.000000, 1.797271),(-0.480059, 0.100000, 1.590102),(-0.480059, 0.100000, 1.797271),(-0.480059, 0.000000, 1.590102),(-0.272890, 0.000000, 1.590102),(-0.272890, 0.100000, 1.590102),(-0.480059, 0.000000, 1.590102),(-0.272890, 0.100000, 1.590102),(-0.480059, 0.100000, 1.590102),(-0.230188, 0.000000, 1.150942),(0.000000, 0.000000, 1.150942),(0.000000, 0.100000, 1.150942),(-0.230188, 0.000000, 1.150942),(0.000000, 0.100000, 1.150942),(-0.230188, 0.100000, 1.150942),(-0.218725, -0.000000, 2.048898),(-0.057593, -0.000000, 2.048898),(-0.057593, 0.100000, 2.048898),(-0.218725, -0.000000, 2.048898),(-0.057593, 0.100000, 2.048898),(-0.218725, 0.100000, 2.048898),(-0.272890, 0.000000, 1.590102),(-0.272890, 0.000000, 1.797271),(-0.272890, 0.100000, 1.797271),(-0.272890, 0.000000, 1.590102),(-0.272890, 0.100000, 1.797271),(-0.272890, 0.100000, 1.590102),(-0.404325, 0.000000, 1.255976),(-0.588475, 0.000000, 1.255976),(-0.588475, 0.100000, 1.255976),(-0.404325, 0.000000, 1.255976),(-0.588475, 0.100000, 1.255976),(-0.404325, 0.100000, 1.255976),(0.023019, -0.000000, 0.483396),(-0.253207, -0.000000, 0.483396),(-0.253207, 0.100000, 0.483396),(0.023019, -0.000000, 0.483396),(-0.253207, 0.100000, 0.483396),(0.023019, 0.100000, 0.483396),(0.333643, 0.000000, 1.076043),(0.333643, 0.000000, 1.306231),(0.333643, 0.100000, 1.306231),(0.333643, 0.000000, 1.076043),(0.333643, 0.100000, 1.306231),(0.333643, 0.100000, 1.076043),(-0.272890, 0.000000, 1.797271),(-0.480059, 0.000000, 1.797271),(-0.480059, 0.100000, 1.797271),(-0.272890, 0.000000, 1.797271),(-0.480059, 0.100000, 1.797271),(-0.272890, 0.100000, 1.797271),(-0.404325, 0.000000, 1.071826),(-0.404325, 0.000000, 1.255976),(-0.404325, 0.100000, 1.255976),(-0.404325, 0.000000, 1.071826),(-0.404325, 0.100000, 1.255976),(-0.404325, 0.100000, 1.071826),(-0.588475, 0.000000, 1.071826),(-0.404325, 0.000000, 1.071826),(-0.404325, 0.100000, 1.071826),(-0.588475, 0.000000, 1.071826),(-0.404325, 0.100000, 1.071826),(-0.588475, 0.100000, 1.071826),(0.333643, 0.000000, 1.306231),(0.103454, 0.000000, 1.306231),(0.103454, 0.100000, 1.306231),(0.333643, 0.000000, 1.306231),(0.103454, 0.100000, 1.306231),(0.333643, 0.100000, 1.306231),(-0.522977, -0.000000, 0.645539),(-0.292788, -0.000000, 0.645539),(-0.292788, 0.100000, 0.645539),(-0.522977, -0.000000, 0.645539),(-0.292788, 0.100000, 0.645539),(-0.522977, 0.100000, 0.645539),(-0.253207, -0.000000, 0.483396),(-0.253207, -0.000000, 0.207170),(-0.253207, 0.100000, 0.207170),(-0.253207, -0.000000, 0.483396),(-0.253207, 0.100000, 0.207170),(-0.253207, 0.100000, 0.483396),(-0.588475, 0.000000, 1.255976),(-0.588475, 0.000000, 1.071826),(-0.588475, 0.100000, 1.071826),(-0.588475, 0.000000, 1.255976),(-0.588475, 0.100000, 1.071826),(-0.588475, 0.100000, 1.255976),(0.103454, 0.000000, 1.306231),(0.103454, 0.000000, 1.076043),(0.103454, 0.100000, 1.076043),(0.103454, 0.000000, 1.306231),(0.103454, 0.100000, 1.076043),(0.103454, 0.100000, 1.306231),(0.000000, 0.000000, 1.150942),(0.000000, 0.000000, 1.381130),(0.000000, 0.100000, 1.381130),(0.000000, 0.000000, 1.150942),(0.000000, 0.100000, 1.381130),(0.000000, 0.100000, 1.150942),(-0.253207, -0.000000, 0.207170),(0.023019, -0.000000, 0.207170),(0.023019, 0.100000, 0.207170),(-0.253207, -0.000000, 0.207170),(0.023019, 0.100000, 0.207170),(-0.253207, 0.100000, 0.207170),(0.000000, 0.000000, 1.381130),(-0.230188, 0.000000, 1.381130),(-0.230188, 0.100000, 1.381130),(0.000000, 0.000000, 1.381130),(-0.230188, 0.100000, 1.381130),(0.000000, 0.100000, 1.381130),(0.103454, 0.000000, 1.076043),(0.333643, 0.000000, 1.076043),(0.333643, 0.100000, 1.076043),(0.103454, 0.000000, 1.076043),(0.333643, 0.100000, 1.076043),(0.103454, 0.100000, 1.076043),(0.023019, -0.000000, 0.207170),(0.023019, -0.000000, 0.483396),(0.023019, 0.100000, 0.483396),(0.023019, -0.000000, 0.207170),(0.023019, 0.100000, 0.483396),(0.023019, 0.100000, 0.207170),(-0.727202, 0.000000, 0.528422),(-0.727202, 0.000000, 0.252196),(-0.727202, 0.100000, 0.252196),(-0.727202, 0.000000, 0.528422),(-0.727202, 0.100000, 0.252196),(-0.727202, 0.100000, 0.528422),(0.223686, 0.000000, 1.549731),(0.223686, 0.000000, 1.687844),(0.223686, 0.100000, 1.687844),(0.223686, 0.000000, 1.549731),(0.223686, 0.100000, 1.687844),(0.223686, 0.100000, 1.549731),(0.256106, -0.000000, 0.663329),(0.256106, 0.000000, 0.893517),(0.256106, 0.100000, 0.893517),(0.256106, -0.000000, 0.663329),(0.256106, 0.100000, 0.893517),(0.256106, 0.100000, 0.663329),(-0.727202, 0.000000, 0.252196),(-0.450976, 0.000000, 0.252196),(-0.450976, 0.100000, 0.252196),(-0.727202, 0.000000, 0.252196),(-0.450976, 0.100000, 0.252196),(-0.727202, 0.100000, 0.252196),(0.085573, 0.000000, 1.549731),(0.223686, 0.000000, 1.549731),(0.223686, 0.100000, 1.549731),(0.085573, 0.000000, 1.549731),(0.223686, 0.100000, 1.549731),(0.085573, 0.100000, 1.549731),(0.299069, -0.000000, 0.471886),(0.299069, -0.000000, 0.218679),(0.299069, 0.100000, 0.218679),(0.299069, -0.000000, 0.471886),(0.299069, 0.100000, 0.218679),(0.299069, 0.100000, 0.471886),(0.552276, -0.000000, 0.218679),(0.552276, -0.000000, 0.471886),(0.552276, 0.100000, 0.471886),(0.552276, -0.000000, 0.218679),(0.552276, 0.100000, 0.471886),(0.552276, 0.100000, 0.218679),(-0.522977, -0.000000, 0.875728),(-0.522977, -0.000000, 0.645539),(-0.522977, 0.100000, 0.645539),(-0.522977, -0.000000, 0.875728),(-0.522977, 0.100000, 0.645539),(-0.522977, 0.100000, 0.875728),(0.552276, -0.000000, 0.471886),(0.299069, -0.000000, 0.471886),(0.299069, 0.100000, 0.471886),(0.552276, -0.000000, 0.471886),(0.299069, 0.100000, 0.471886),(0.552276, 0.100000, 0.471886),(0.299069, -0.000000, 0.218679),(0.552276, -0.000000, 0.218679),(0.552276, 0.100000, 0.218679),(0.299069, -0.000000, 0.218679),(0.552276, 0.100000, 0.218679),(0.299069, 0.100000, 0.218679),(-0.292788, -0.000000, 0.875728),(-0.522977, -0.000000, 0.875728),(-0.522977, 0.100000, 0.875728),(-0.292788, -0.000000, 0.875728),(-0.522977, 0.100000, 0.875728),(-0.292788, 0.100000, 0.875728),(-0.450976, 0.000000, 0.252196),(-0.450976, 0.000000, 0.528422),(-0.450976, 0.100000, 0.528422),(-0.450976, 0.000000, 0.252196),(-0.450976, 0.100000, 0.528422),(-0.450976, 0.100000, 0.252196),(0.025917, 0.000000, 0.893517),(0.025917, -0.000000, 0.663329),(0.025917, 0.100000, 0.663329),(0.025917, 0.000000, 0.893517),(0.025917, 0.100000, 0.663329),(0.025917, 0.100000, 0.893517),(-0.292788, -0.000000, 0.645539),(-0.292788, -0.000000, 0.875728),(-0.292788, 0.100000, 0.875728),(-0.292788, -0.000000, 0.645539),(-0.292788, 0.100000, 0.875728),(-0.292788, 0.100000, 0.645539),(-0.057593, -0.000000, 2.048898),(-0.057593, -0.000000, 2.210031),(-0.057593, 0.100000, 2.210031),(-0.057593, -0.000000, 2.048898),(-0.057593, 0.100000, 2.210031),(-0.057593, 0.100000, 2.048898),(0.025917, -0.000000, 0.663329),(0.256106, -0.000000, 0.663329),(0.256106, 0.100000, 0.663329),(0.025917, -0.000000, 0.663329),(0.256106, 0.100000, 0.663329),(0.025917, 0.100000, 0.663329),(-1.000000, -1.000000, 0.000000),(1.000000, -1.000000, 0.000000),(1.000000, 1.000000, 0.000000),(-1.000000, -1.000000, 0.000000),(1.000000, 1.000000, 0.000000),(-1.000000, 1.000000, 0.000000),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/point_light.py",
    "content": "SHAPE = ((-0.000000, 0.226909, 0.131224),(0.173669, 0.173669, 0.037235),(-0.000000, 0.245605, 0.037235),(-0.000000, 0.093989, 0.264144),(0.122802, 0.122803, 0.210904),(-0.000000, 0.173669, 0.210904),(-0.000000, 0.226909, -0.056754),(0.173669, 0.173669, 0.037235),(0.160449, 0.160449, -0.056754),(-0.000000, 0.226909, 0.131224),(0.122802, 0.122803, 0.210904),(0.160449, 0.160449, 0.131224),(-0.000000, 0.093989, 0.264144),(-0.000000, 0.000000, 0.282840),(0.066460, 0.066460, 0.264144),(0.173669, 0.173669, 0.037235),(0.226909, 0.000000, -0.056754),(0.160449, 0.160449, -0.056754),(0.160449, 0.160449, 0.131224),(0.173669, 0.000000, 0.210904),(0.226909, 0.000000, 0.131224),(0.066460, 0.066460, 0.264144),(-0.000000, 0.000000, 0.282840),(0.093989, 0.000000, 0.264144),(0.067179, 0.067178, -0.282677),(0.148421, -0.000000, -0.207369),(0.095005, -0.000000, -0.282677),(0.160449, 0.160449, 0.131224),(0.245605, 0.000000, 0.037235),(0.173669, 0.173669, 0.037235),(0.066460, 0.066460, 0.264144),(0.173669, 0.000000, 0.210904),(0.122802, 0.122803, 0.210904),(0.226909, 0.000000, -0.056754),(0.173669, -0.173669, 0.037235),(0.160449, -0.160449, -0.056754),(0.226909, 0.000000, 0.131224),(0.122802, -0.122802, 0.210904),(0.160449, -0.160449, 0.131224),(0.093989, 0.000000, 0.264144),(-0.000000, 0.000000, 0.282840),(0.066460, -0.066460, 0.264144),(0.000000, 0.148421, -0.207369),(-0.067178, 0.067178, -0.282677),(-0.104949, 0.104949, -0.207369),(0.226909, 0.000000, 0.131224),(0.173669, -0.173669, 0.037235),(0.245605, 0.000000, 0.037235),(0.093989, 0.000000, 0.264144),(0.122802, -0.122802, 0.210904),(0.173669, 0.000000, 0.210904),(0.138153, -0.138153, -0.132062),(0.226909, 0.000000, -0.056754),(0.160449, -0.160449, -0.056754),(0.160449, -0.160449, 0.131224),(-0.000000, -0.245605, 0.037235),(0.173669, -0.173669, 0.037235),(0.066460, -0.066460, 0.264144),(-0.000000, -0.173669, 0.210904),(0.122802, -0.122802, 0.210904),(0.160449, -0.160449, -0.056754),(-0.000000, -0.245605, 0.037235),(-0.000000, -0.226909, -0.056754),(0.122802, -0.122802, 0.210904),(-0.000000, -0.226909, 0.131224),(0.160449, -0.160449, 0.131224),(0.066460, -0.066460, 0.264144),(-0.000000, 0.000000, 0.282840),(-0.000000, -0.093989, 0.264144),(-0.000000, -0.245605, 0.037235),(-0.160449, -0.160449, 0.131224),(-0.173669, -0.173669, 0.037235),(-0.000000, -0.093989, 0.264144),(-0.122803, -0.122802, 0.210904),(-0.000000, -0.173669, 0.210904),(-0.000000, -0.245605, 0.037235),(-0.160449, -0.160449, -0.056754),(-0.000000, -0.226909, -0.056754),(-0.000000, -0.173669, 0.210904),(-0.160449, -0.160449, 0.131224),(-0.000000, -0.226909, 0.131224),(-0.000000, -0.093989, 0.264144),(-0.000000, 0.000000, 0.282840),(-0.066460, -0.066460, 0.264144),(0.104950, 0.104949, -0.207369),(0.000000, 0.095005, -0.282677),(0.000000, 0.148421, -0.207369),(-0.160449, -0.160449, -0.056754),(-0.245605, 0.000000, 0.037235),(-0.226910, 0.000000, -0.056754),(-0.122803, -0.122802, 0.210904),(-0.226910, 0.000000, 0.131224),(-0.160449, -0.160449, 0.131224),(-0.066460, -0.066460, 0.264144),(-0.000000, 0.000000, 0.282840),(-0.093989, 0.000000, 0.264144),(0.000000, -0.195378, -0.132062),(0.160449, -0.160449, -0.056754),(-0.000000, -0.226909, -0.056754),(-0.160449, -0.160449, 0.131224),(-0.245605, 0.000000, 0.037235),(-0.173669, -0.173669, 0.037235),(-0.066460, -0.066460, 0.264144),(-0.173669, 0.000000, 0.210904),(-0.122803, -0.122802, 0.210904),(-0.173669, 0.000000, 0.210904),(-0.160449, 0.160449, 0.131224),(-0.226910, 0.000000, 0.131224),(-0.093989, 0.000000, 0.264144),(-0.000000, 0.000000, 0.282840),(-0.066460, 0.066460, 0.264144),(-0.104949, 0.104949, -0.207369),(-0.095004, -0.000000, -0.282677),(-0.148421, -0.000000, -0.207369),(-0.245605, 0.000000, 0.037235),(-0.160449, 0.160449, 0.131224),(-0.173669, 0.173669, 0.037235),(-0.093989, 0.000000, 0.264144),(-0.122803, 0.122803, 0.210904),(-0.173669, 0.000000, 0.210904),(-0.245605, 0.000000, 0.037235),(-0.160449, 0.160449, -0.056754),(-0.226910, 0.000000, -0.056754),(-0.138153, -0.138153, -0.132062),(-0.000000, -0.226909, -0.056754),(-0.160449, -0.160449, -0.056754),(-0.160449, 0.160449, 0.131224),(-0.000000, 0.245605, 0.037235),(-0.173669, 0.173669, 0.037235),(-0.066460, 0.066460, 0.264144),(-0.000000, 0.173669, 0.210904),(-0.122803, 0.122803, 0.210904),(-0.160449, 0.160449, -0.056754),(-0.000000, 0.245605, 0.037235),(-0.000000, 0.226909, -0.056754),(-0.122803, 0.122803, 0.210904),(-0.000000, 0.226909, 0.131224),(-0.160449, 0.160449, 0.131224),(-0.066460, 0.066460, 0.264144),(-0.000000, 0.000000, 0.282840),(-0.000000, 0.093989, 0.264144),(0.000000, -0.000000, -0.445589),(0.000000, 0.070206, -0.444960),(0.049644, 0.049643, -0.444960),(0.000000, -0.000000, -0.445589),(0.049644, 0.049643, -0.444960),(0.070207, -0.000000, -0.444960),(0.000000, -0.000000, -0.445589),(0.070207, -0.000000, -0.444960),(0.049644, -0.049643, -0.444960),(0.000000, -0.000000, -0.445589),(0.049644, -0.049643, -0.444960),(0.000000, -0.070206, -0.444960),(0.000000, -0.000000, -0.445589),(0.000000, -0.070206, -0.444960),(-0.049643, -0.049643, -0.444960),(0.000000, -0.000000, -0.445589),(-0.049643, -0.049643, -0.444960),(-0.070206, -0.000000, -0.444960),(0.000000, -0.000000, -0.445589),(-0.070206, -0.000000, -0.444960),(-0.049643, 0.049643, -0.444960),(0.000000, -0.000000, -0.445589),(-0.049643, 0.049643, -0.444960),(0.000000, 0.070206, -0.444960),(-0.049643, 0.049643, -0.444960),(0.000000, 0.090119, -0.433296),(0.000000, 0.070206, -0.444960),(-0.070206, -0.000000, -0.444960),(-0.063723, 0.063724, -0.433296),(-0.049643, 0.049643, -0.444960),(-0.063723, -0.063724, -0.433296),(-0.070206, -0.000000, -0.444960),(-0.049643, -0.049643, -0.444960),(0.000000, -0.090119, -0.433296),(-0.049643, -0.049643, -0.444960),(0.000000, -0.070206, -0.444960),(0.063724, -0.063724, -0.433296),(0.000000, -0.070206, -0.444960),(0.049644, -0.049643, -0.444960),(0.090119, -0.000000, -0.433296),(0.049644, -0.049643, -0.444960),(0.070207, -0.000000, -0.444960),(0.049644, 0.049643, -0.444960),(0.090119, -0.000000, -0.433296),(0.070207, -0.000000, -0.444960),(0.000000, 0.070206, -0.444960),(0.063724, 0.063724, -0.433296),(0.049644, 0.049643, -0.444960),(0.000001, 0.099347, -0.412708),(0.068022, 0.068021, -0.399513),(0.070250, 0.070249, -0.412708),(0.070250, 0.070249, -0.412708),(0.096197, -0.000000, -0.399513),(0.099348, -0.000000, -0.412708),(0.096197, -0.000000, -0.399513),(0.070250, -0.070249, -0.412708),(0.099348, -0.000000, -0.412708),(0.068022, -0.068021, -0.399513),(0.000001, -0.099347, -0.412708),(0.070250, -0.070249, -0.412708),(0.000000, -0.096196, -0.399513),(-0.070249, -0.070249, -0.412708),(0.000001, -0.099347, -0.412708),(-0.068021, -0.068021, -0.399513),(-0.099347, -0.000000, -0.412708),(-0.070249, -0.070249, -0.412708),(-0.099347, -0.000000, -0.412708),(-0.068021, 0.068021, -0.399513),(-0.070249, 0.070249, -0.412708),(-0.070249, 0.070249, -0.412708),(0.000000, 0.096196, -0.399513),(0.000001, 0.099347, -0.412708),(-0.068435, -0.068435, -0.349237),(-0.099911, -0.000000, -0.365233),(-0.070647, -0.070648, -0.365233),(0.000001, -0.096782, -0.349237),(-0.070647, -0.070648, -0.365233),(0.000001, -0.099911, -0.365233),(-0.068435, 0.068435, -0.349237),(-0.099911, -0.000000, -0.365233),(-0.096782, -0.000000, -0.349237),(0.000001, 0.096782, -0.349237),(-0.070647, 0.070648, -0.365233),(-0.068435, 0.068435, -0.349237),(0.096783, -0.000000, -0.349237),(0.070649, -0.070648, -0.365233),(0.099912, -0.000000, -0.365233),(0.096783, -0.000000, -0.349237),(0.070649, 0.070648, -0.365233),(0.068436, 0.068435, -0.349237),(0.068436, 0.068435, -0.349237),(0.000001, 0.099911, -0.365233),(0.000001, 0.096782, -0.349237),(0.068436, -0.068435, -0.349237),(0.000001, -0.099911, -0.365233),(0.070649, -0.070648, -0.365233),(-0.070249, 0.070249, -0.412708),(0.000000, 0.090119, -0.433296),(-0.063723, 0.063724, -0.433296),(-0.099347, -0.000000, -0.412708),(-0.063723, 0.063724, -0.433296),(-0.090118, -0.000000, -0.433296),(-0.063723, -0.063724, -0.433296),(-0.099347, -0.000000, -0.412708),(-0.090118, -0.000000, -0.433296),(0.000000, -0.090119, -0.433296),(-0.070249, -0.070249, -0.412708),(-0.063723, -0.063724, -0.433296),(0.063724, -0.063724, -0.433296),(0.000001, -0.099347, -0.412708),(0.000000, -0.090119, -0.433296),(0.090119, -0.000000, -0.433296),(0.070250, -0.070249, -0.412708),(0.063724, -0.063724, -0.433296),(0.070250, 0.070249, -0.412708),(0.090119, -0.000000, -0.433296),(0.063724, 0.063724, -0.433296),(0.000001, 0.099347, -0.412708),(0.063724, 0.063724, -0.433296),(0.000000, 0.090119, -0.433296),(-0.068379, -0.068380, -0.307574),(-0.099958, -0.000000, -0.321721),(-0.070681, -0.070682, -0.321721),(0.000001, -0.096703, -0.307574),(-0.070681, -0.070682, -0.321721),(0.000001, -0.099959, -0.321721),(-0.068379, 0.068379, -0.307574),(-0.099958, -0.000000, -0.321721),(-0.096703, -0.000000, -0.307574),(0.000001, 0.096703, -0.307574),(-0.070681, 0.070682, -0.321721),(-0.068379, 0.068379, -0.307574),(0.096704, -0.000000, -0.307574),(0.070682, -0.070682, -0.321721),(0.099959, -0.000000, -0.321721),(0.096704, -0.000000, -0.307574),(0.070682, 0.070682, -0.321721),(0.068380, 0.068379, -0.307574),(0.068380, 0.068379, -0.307574),(0.000001, 0.099959, -0.321721),(0.000001, 0.096703, -0.307574),(0.068380, -0.068380, -0.307574),(0.000001, -0.099959, -0.321721),(0.070682, -0.070682, -0.321721),(0.440526, -0.023107, -0.493787),(0.231328, 0.000977, -0.274618),(0.434003, -0.000114, -0.500706),(0.440526, -0.023107, -0.493787),(0.455855, 0.032388, -0.476649),(0.456116, -0.032649, -0.476886),(0.471643, -0.023126, -0.459901),(0.231328, 0.000977, -0.274618),(0.456116, -0.032649, -0.476886),(0.477994, -0.000114, -0.452801),(0.231328, 0.000977, -0.274618),(0.471643, -0.023126, -0.459901),(0.471447, 0.022882, -0.459746),(0.231328, 0.000977, -0.274618),(0.477994, -0.000114, -0.452801),(0.455855, 0.032388, -0.476649),(0.231328, 0.000977, -0.274618),(0.471447, 0.022882, -0.459746),(0.456116, -0.032649, -0.476886),(0.231328, 0.000977, -0.274618),(0.440526, -0.023107, -0.493787),(0.434003, -0.000114, -0.500706),(0.231328, 0.000977, -0.274618),(0.440352, 0.022863, -0.493607),(-0.432046, 0.032388, 0.478010),(-0.415921, 0.022882, 0.494406),(-0.219336, 0.000977, 0.263572),(-0.415921, 0.022882, 0.494406),(-0.409303, -0.000114, 0.501282),(-0.219336, 0.000977, 0.263572),(-0.409303, -0.000114, 0.501282),(-0.416085, -0.023126, 0.494593),(-0.219336, 0.000977, 0.263572),(-0.416085, -0.023126, 0.494593),(-0.432295, -0.032649, 0.478259),(-0.219336, 0.000977, 0.263572),(-0.432295, -0.032649, 0.478259),(-0.448419, -0.023107, 0.461866),(-0.219336, 0.000977, 0.263572),(-0.448419, -0.023107, 0.461866),(-0.455012, -0.000114, 0.455014),(-0.219336, 0.000977, 0.263572),(-0.455012, -0.000114, 0.455014),(-0.448230, 0.022863, 0.461701),(-0.219336, 0.000977, 0.263572),(-0.448230, 0.022863, 0.461701),(-0.432046, 0.032388, 0.478010),(-0.219336, 0.000977, 0.263572),(0.432048, 0.032383, 0.477735),(0.448386, 0.022873, 0.461565),(0.219338, 0.000977, 0.265851),(0.448386, 0.022873, 0.461565),(0.455237, -0.000114, 0.454930),(0.219338, 0.000977, 0.265851),(0.455237, -0.000114, 0.454930),(0.448574, -0.023118, 0.461729),(0.219338, 0.000977, 0.265851),(0.448574, -0.023118, 0.461729),(0.432297, -0.032645, 0.477985),(0.219338, 0.000977, 0.265851),(0.432297, -0.032645, 0.477985),(0.415954, -0.023108, 0.494161),(0.219338, 0.000977, 0.265851),(0.415954, -0.023108, 0.494161),(0.409122, -0.000114, 0.500778),(0.219338, 0.000977, 0.265851),(0.409122, -0.000114, 0.500778),(0.415789, 0.022864, 0.493972),(0.219338, 0.000977, 0.265851),(0.415789, 0.022864, 0.493972),(0.432048, 0.032383, 0.477735),(0.219338, 0.000977, 0.265851),(-0.195378, 0.000000, -0.132062),(-0.160449, -0.160449, -0.056754),(-0.226910, 0.000000, -0.056754),(-0.099958, -0.000000, -0.321721),(-0.068376, -0.068377, -0.336351),(-0.070681, -0.070682, -0.321721),(-0.070681, -0.070682, -0.321721),(0.000001, -0.096700, -0.336351),(0.000001, -0.099959, -0.321721),(-0.099958, -0.000000, -0.321721),(-0.068376, 0.068377, -0.336351),(-0.096699, -0.000000, -0.336351),(-0.070681, 0.070682, -0.321721),(0.000001, 0.096700, -0.336351),(-0.068376, 0.068377, -0.336351),(0.070682, -0.070682, -0.321721),(0.096700, -0.000000, -0.336352),(0.099959, -0.000000, -0.321721),(0.070682, 0.070682, -0.321721),(0.096700, -0.000000, -0.336352),(0.068377, 0.068377, -0.336352),(0.000001, 0.099959, -0.321721),(0.068377, 0.068377, -0.336352),(0.000001, 0.096700, -0.336351),(0.000001, -0.099959, -0.321721),(0.068377, -0.068377, -0.336352),(0.070682, -0.070682, -0.321721),(-0.099911, -0.000000, -0.365233),(-0.068430, -0.068431, -0.381501),(-0.070647, -0.070648, -0.365233),(-0.070647, -0.070648, -0.365233),(0.000001, -0.096776, -0.381501),(0.000001, -0.099911, -0.365233),(-0.099911, -0.000000, -0.365233),(-0.068430, 0.068431, -0.381501),(-0.096775, -0.000000, -0.381501),(-0.070647, 0.070648, -0.365233),(0.000001, 0.096776, -0.381501),(-0.068430, 0.068431, -0.381501),(0.070649, -0.070648, -0.365233),(0.096776, -0.000000, -0.381501),(0.099912, -0.000000, -0.365233),(0.070649, 0.070648, -0.365233),(0.096776, -0.000000, -0.381501),(0.068431, 0.068431, -0.381501),(0.000001, 0.099911, -0.365233),(0.068431, 0.068431, -0.381501),(0.000001, 0.096776, -0.381501),(0.000001, -0.099911, -0.365233),(0.068431, -0.068431, -0.381501),(0.070649, -0.070648, -0.365233),(-0.049643, 0.049643, -0.444960),(-0.063723, 0.063724, -0.433296),(0.000000, 0.090119, -0.433296),(-0.070206, -0.000000, -0.444960),(-0.090118, -0.000000, -0.433296),(-0.063723, 0.063724, -0.433296),(-0.063723, -0.063724, -0.433296),(-0.090118, -0.000000, -0.433296),(-0.070206, -0.000000, -0.444960),(0.000000, -0.090119, -0.433296),(-0.063723, -0.063724, -0.433296),(-0.049643, -0.049643, -0.444960),(0.063724, -0.063724, -0.433296),(0.000000, -0.090119, -0.433296),(0.000000, -0.070206, -0.444960),(0.090119, -0.000000, -0.433296),(0.063724, -0.063724, -0.433296),(0.049644, -0.049643, -0.444960),(0.049644, 0.049643, -0.444960),(0.063724, 0.063724, -0.433296),(0.090119, -0.000000, -0.433296),(0.000000, 0.070206, -0.444960),(0.000000, 0.090119, -0.433296),(0.063724, 0.063724, -0.433296),(0.000001, 0.099347, -0.412708),(0.000000, 0.096196, -0.399513),(0.068022, 0.068021, -0.399513),(0.070250, 0.070249, -0.412708),(0.068022, 0.068021, -0.399513),(0.096197, -0.000000, -0.399513),(0.096197, -0.000000, -0.399513),(0.068022, -0.068021, -0.399513),(0.070250, -0.070249, -0.412708),(0.068022, -0.068021, -0.399513),(0.000000, -0.096196, -0.399513),(0.000001, -0.099347, -0.412708),(0.000000, -0.096196, -0.399513),(-0.068021, -0.068021, -0.399513),(-0.070249, -0.070249, -0.412708),(-0.068021, -0.068021, -0.399513),(-0.096196, -0.000000, -0.399513),(-0.099347, -0.000000, -0.412708),(-0.099347, -0.000000, -0.412708),(-0.096196, -0.000000, -0.399513),(-0.068021, 0.068021, -0.399513),(-0.070249, 0.070249, -0.412708),(-0.068021, 0.068021, -0.399513),(0.000000, 0.096196, -0.399513),(-0.068435, -0.068435, -0.349237),(-0.096782, -0.000000, -0.349237),(-0.099911, -0.000000, -0.365233),(0.000001, -0.096782, -0.349237),(-0.068435, -0.068435, -0.349237),(-0.070647, -0.070648, -0.365233),(-0.068435, 0.068435, -0.349237),(-0.070647, 0.070648, -0.365233),(-0.099911, -0.000000, -0.365233),(0.000001, 0.096782, -0.349237),(0.000001, 0.099911, -0.365233),(-0.070647, 0.070648, -0.365233),(0.096783, -0.000000, -0.349237),(0.068436, -0.068435, -0.349237),(0.070649, -0.070648, -0.365233),(0.096783, -0.000000, -0.349237),(0.099912, -0.000000, -0.365233),(0.070649, 0.070648, -0.365233),(0.068436, 0.068435, -0.349237),(0.070649, 0.070648, -0.365233),(0.000001, 0.099911, -0.365233),(0.068436, -0.068435, -0.349237),(0.000001, -0.096782, -0.349237),(0.000001, -0.099911, -0.365233),(-0.070249, 0.070249, -0.412708),(0.000001, 0.099347, -0.412708),(0.000000, 0.090119, -0.433296),(-0.099347, -0.000000, -0.412708),(-0.070249, 0.070249, -0.412708),(-0.063723, 0.063724, -0.433296),(-0.063723, -0.063724, -0.433296),(-0.070249, -0.070249, -0.412708),(-0.099347, -0.000000, -0.412708),(0.000000, -0.090119, -0.433296),(0.000001, -0.099347, -0.412708),(-0.070249, -0.070249, -0.412708),(0.063724, -0.063724, -0.433296),(0.070250, -0.070249, -0.412708),(0.000001, -0.099347, -0.412708),(0.090119, -0.000000, -0.433296),(0.099348, -0.000000, -0.412708),(0.070250, -0.070249, -0.412708),(0.070250, 0.070249, -0.412708),(0.099348, -0.000000, -0.412708),(0.090119, -0.000000, -0.433296),(0.000001, 0.099347, -0.412708),(0.070250, 0.070249, -0.412708),(0.063724, 0.063724, -0.433296),(-0.068379, -0.068380, -0.307574),(-0.096703, -0.000000, -0.307574),(-0.099958, -0.000000, -0.321721),(0.000001, -0.096703, -0.307574),(-0.068379, -0.068380, -0.307574),(-0.070681, -0.070682, -0.321721),(-0.068379, 0.068379, -0.307574),(-0.070681, 0.070682, -0.321721),(-0.099958, -0.000000, -0.321721),(0.000001, 0.096703, -0.307574),(0.000001, 0.099959, -0.321721),(-0.070681, 0.070682, -0.321721),(0.096704, -0.000000, -0.307574),(0.068380, -0.068380, -0.307574),(0.070682, -0.070682, -0.321721),(0.096704, -0.000000, -0.307574),(0.099959, -0.000000, -0.321721),(0.070682, 0.070682, -0.321721),(0.068380, 0.068379, -0.307574),(0.070682, 0.070682, -0.321721),(0.000001, 0.099959, -0.321721),(0.068380, -0.068380, -0.307574),(0.000001, -0.096703, -0.307574),(0.000001, -0.099959, -0.321721),(0.455855, 0.032388, -0.476649),(0.434003, -0.000114, -0.500706),(0.440352, 0.022863, -0.493607),(0.409122, -0.000114, 0.500778),(0.432297, -0.032645, 0.477985),(0.455237, -0.000114, 0.454930),(-0.415921, 0.022882, 0.494406),(-0.432046, 0.032388, 0.478010),(-0.432295, -0.032649, 0.478259),(-0.099958, -0.000000, -0.321721),(-0.096699, -0.000000, -0.336351),(-0.068376, -0.068377, -0.336351),(-0.070681, -0.070682, -0.321721),(-0.068376, -0.068377, -0.336351),(0.000001, -0.096700, -0.336351),(-0.099958, -0.000000, -0.321721),(-0.070681, 0.070682, -0.321721),(-0.068376, 0.068377, -0.336351),(-0.070681, 0.070682, -0.321721),(0.000001, 0.099959, -0.321721),(0.000001, 0.096700, -0.336351),(0.070682, -0.070682, -0.321721),(0.068377, -0.068377, -0.336352),(0.096700, -0.000000, -0.336352),(0.070682, 0.070682, -0.321721),(0.099959, -0.000000, -0.321721),(0.096700, -0.000000, -0.336352),(0.000001, 0.099959, -0.321721),(0.070682, 0.070682, -0.321721),(0.068377, 0.068377, -0.336352),(0.000001, -0.099959, -0.321721),(0.000001, -0.096700, -0.336351),(0.068377, -0.068377, -0.336352),(-0.099911, -0.000000, -0.365233),(-0.096775, -0.000000, -0.381501),(-0.068430, -0.068431, -0.381501),(-0.070647, -0.070648, -0.365233),(-0.068430, -0.068431, -0.381501),(0.000001, -0.096776, -0.381501),(-0.099911, -0.000000, -0.365233),(-0.070647, 0.070648, -0.365233),(-0.068430, 0.068431, -0.381501),(-0.070647, 0.070648, -0.365233),(0.000001, 0.099911, -0.365233),(0.000001, 0.096776, -0.381501),(0.070649, -0.070648, -0.365233),(0.068431, -0.068431, -0.381501),(0.096776, -0.000000, -0.381501),(0.070649, 0.070648, -0.365233),(0.099912, -0.000000, -0.365233),(0.096776, -0.000000, -0.381501),(0.000001, 0.099911, -0.365233),(0.070649, 0.070648, -0.365233),(0.068431, 0.068431, -0.381501),(0.000001, -0.099911, -0.365233),(0.000001, -0.096776, -0.381501),(0.068431, -0.068431, -0.381501),(-0.000000, 0.226909, 0.131224),(0.160449, 0.160449, 0.131224),(0.173669, 0.173669, 0.037235),(-0.000000, 0.093989, 0.264144),(0.066460, 0.066460, 0.264144),(0.122802, 0.122803, 0.210904),(-0.000000, 0.226909, -0.056754),(-0.000000, 0.245605, 0.037235),(0.173669, 0.173669, 0.037235),(-0.000000, 0.226909, 0.131224),(-0.000000, 0.173669, 0.210904),(0.122802, 0.122803, 0.210904),(0.173669, 0.173669, 0.037235),(0.245605, 0.000000, 0.037235),(0.226909, 0.000000, -0.056754),(0.160449, 0.160449, 0.131224),(0.122802, 0.122803, 0.210904),(0.173669, 0.000000, 0.210904),(-0.095004, -0.000000, -0.282677),(-0.104949, -0.104949, -0.207369),(-0.148421, -0.000000, -0.207369),(0.160449, 0.160449, 0.131224),(0.226909, 0.000000, 0.131224),(0.245605, 0.000000, 0.037235),(0.066460, 0.066460, 0.264144),(0.093989, 0.000000, 0.264144),(0.173669, 0.000000, 0.210904),(0.226909, 0.000000, -0.056754),(0.245605, 0.000000, 0.037235),(0.173669, -0.173669, 0.037235),(0.226909, 0.000000, 0.131224),(0.173669, 0.000000, 0.210904),(0.122802, -0.122802, 0.210904),(0.104950, 0.104949, -0.207369),(0.195378, 0.000000, -0.132062),(0.148421, -0.000000, -0.207369),(0.226909, 0.000000, 0.131224),(0.160449, -0.160449, 0.131224),(0.173669, -0.173669, 0.037235),(0.093989, 0.000000, 0.264144),(0.066460, -0.066460, 0.264144),(0.122802, -0.122802, 0.210904),(-0.067178, -0.067178, -0.282677),(0.000000, -0.148421, -0.207369),(-0.104949, -0.104949, -0.207369),(0.160449, -0.160449, 0.131224),(-0.000000, -0.226909, 0.131224),(-0.000000, -0.245605, 0.037235),(0.066460, -0.066460, 0.264144),(-0.000000, -0.093989, 0.264144),(-0.000000, -0.173669, 0.210904),(0.160449, -0.160449, -0.056754),(0.173669, -0.173669, 0.037235),(-0.000000, -0.245605, 0.037235),(0.122802, -0.122802, 0.210904),(-0.000000, -0.173669, 0.210904),(-0.000000, -0.226909, 0.131224),(-0.000000, -0.245605, 0.037235),(-0.000000, -0.226909, 0.131224),(-0.160449, -0.160449, 0.131224),(-0.000000, -0.093989, 0.264144),(-0.066460, -0.066460, 0.264144),(-0.122803, -0.122802, 0.210904),(-0.000000, -0.245605, 0.037235),(-0.173669, -0.173669, 0.037235),(-0.160449, -0.160449, -0.056754),(-0.000000, -0.173669, 0.210904),(-0.122803, -0.122802, 0.210904),(-0.160449, -0.160449, 0.131224),(-0.160449, 0.160449, -0.056754),(-0.195378, 0.000000, -0.132062),(-0.226910, 0.000000, -0.056754),(-0.160449, -0.160449, -0.056754),(-0.173669, -0.173669, 0.037235),(-0.245605, 0.000000, 0.037235),(-0.122803, -0.122802, 0.210904),(-0.173669, 0.000000, 0.210904),(-0.226910, 0.000000, 0.131224),(-0.138153, 0.138153, -0.132062),(-0.148421, -0.000000, -0.207369),(-0.195378, 0.000000, -0.132062),(-0.160449, -0.160449, 0.131224),(-0.226910, 0.000000, 0.131224),(-0.245605, 0.000000, 0.037235),(-0.066460, -0.066460, 0.264144),(-0.093989, 0.000000, 0.264144),(-0.173669, 0.000000, 0.210904),(-0.173669, 0.000000, 0.210904),(-0.122803, 0.122803, 0.210904),(-0.160449, 0.160449, 0.131224),(-0.148421, -0.000000, -0.207369),(-0.138153, -0.138153, -0.132062),(-0.195378, 0.000000, -0.132062),(-0.245605, 0.000000, 0.037235),(-0.226910, 0.000000, 0.131224),(-0.160449, 0.160449, 0.131224),(-0.093989, 0.000000, 0.264144),(-0.066460, 0.066460, 0.264144),(-0.122803, 0.122803, 0.210904),(-0.245605, 0.000000, 0.037235),(-0.173669, 0.173669, 0.037235),(-0.160449, 0.160449, -0.056754),(-0.104949, -0.104949, -0.207369),(0.000000, -0.195378, -0.132062),(-0.138153, -0.138153, -0.132062),(-0.160449, 0.160449, 0.131224),(-0.000000, 0.226909, 0.131224),(-0.000000, 0.245605, 0.037235),(-0.066460, 0.066460, 0.264144),(-0.000000, 0.093989, 0.264144),(-0.000000, 0.173669, 0.210904),(-0.160449, 0.160449, -0.056754),(-0.173669, 0.173669, 0.037235),(-0.000000, 0.245605, 0.037235),(-0.122803, 0.122803, 0.210904),(-0.000000, 0.173669, 0.210904),(-0.000000, 0.226909, 0.131224),(0.000000, -0.095005, -0.282677),(0.104950, -0.104949, -0.207369),(0.000000, -0.148421, -0.207369),(0.138153, 0.138153, -0.132062),(0.226909, 0.000000, -0.056754),(0.195378, 0.000000, -0.132062),(0.000000, -0.148421, -0.207369),(0.138153, -0.138153, -0.132062),(0.000000, -0.195378, -0.132062),(0.160449, 0.160449, -0.056754),(0.000000, 0.195378, -0.132062),(-0.000000, 0.226909, -0.056754),(0.138153, 0.138153, -0.132062),(0.000000, 0.148421, -0.207369),(0.000000, 0.195378, -0.132062),(0.067179, -0.067178, -0.282677),(0.148421, -0.000000, -0.207369),(0.104950, -0.104949, -0.207369),(0.104950, -0.104949, -0.207369),(0.195378, 0.000000, -0.132062),(0.138153, -0.138153, -0.132062),(-0.000000, 0.226909, -0.056754),(-0.138153, 0.138153, -0.132062),(-0.160449, 0.160449, -0.056754),(0.000000, 0.195378, -0.132062),(-0.104949, 0.104949, -0.207369),(-0.138153, 0.138153, -0.132062),(0.067179, 0.067178, -0.282677),(0.104950, 0.104949, -0.207369),(0.148421, -0.000000, -0.207369),(0.000000, 0.148421, -0.207369),(0.000000, 0.095005, -0.282677),(-0.067178, 0.067178, -0.282677),(0.138153, -0.138153, -0.132062),(0.195378, 0.000000, -0.132062),(0.226909, 0.000000, -0.056754),(0.104950, 0.104949, -0.207369),(0.067179, 0.067178, -0.282677),(0.000000, 0.095005, -0.282677),(0.000000, -0.195378, -0.132062),(0.138153, -0.138153, -0.132062),(0.160449, -0.160449, -0.056754),(-0.104949, 0.104949, -0.207369),(-0.067178, 0.067178, -0.282677),(-0.095004, -0.000000, -0.282677),(-0.138153, -0.138153, -0.132062),(0.000000, -0.195378, -0.132062),(-0.000000, -0.226909, -0.056754),(-0.195378, 0.000000, -0.132062),(-0.138153, -0.138153, -0.132062),(-0.160449, -0.160449, -0.056754),(0.434003, -0.000114, -0.500706),(0.455855, 0.032388, -0.476649),(0.440526, -0.023107, -0.493787),(0.440352, 0.022863, -0.493607),(0.231328, 0.000977, -0.274618),(0.455855, 0.032388, -0.476649),(0.456116, -0.032649, -0.476886),(0.477994, -0.000114, -0.452801),(0.471643, -0.023126, -0.459901),(0.477994, -0.000114, -0.452801),(0.456116, -0.032649, -0.476886),(0.471447, 0.022882, -0.459746),(0.471447, 0.022882, -0.459746),(0.456116, -0.032649, -0.476886),(0.455855, 0.032388, -0.476649),(0.432048, 0.032383, 0.477735),(0.415789, 0.022864, 0.493972),(0.409122, -0.000114, 0.500778),(0.409122, -0.000114, 0.500778),(0.415954, -0.023108, 0.494161),(0.432297, -0.032645, 0.477985),(0.432297, -0.032645, 0.477985),(0.448574, -0.023118, 0.461729),(0.455237, -0.000114, 0.454930),(0.455237, -0.000114, 0.454930),(0.448386, 0.022873, 0.461565),(0.432048, 0.032383, 0.477735),(0.432048, 0.032383, 0.477735),(0.409122, -0.000114, 0.500778),(0.455237, -0.000114, 0.454930),(-0.432046, 0.032388, 0.478010),(-0.448230, 0.022863, 0.461701),(-0.455012, -0.000114, 0.455014),(-0.455012, -0.000114, 0.455014),(-0.448419, -0.023107, 0.461866),(-0.432046, 0.032388, 0.478010),(-0.448419, -0.023107, 0.461866),(-0.432295, -0.032649, 0.478259),(-0.432046, 0.032388, 0.478010),(-0.432295, -0.032649, 0.478259),(-0.416085, -0.023126, 0.494593),(-0.409303, -0.000114, 0.501282),(-0.409303, -0.000114, 0.501282),(-0.415921, 0.022882, 0.494406),(-0.432295, -0.032649, 0.478259),(-0.095004, -0.000000, -0.282677),(-0.067178, -0.067178, -0.282677),(-0.104949, -0.104949, -0.207369),(0.104950, 0.104949, -0.207369),(0.138153, 0.138153, -0.132062),(0.195378, 0.000000, -0.132062),(-0.067178, -0.067178, -0.282677),(0.000000, -0.095005, -0.282677),(0.000000, -0.148421, -0.207369),(-0.160449, 0.160449, -0.056754),(-0.138153, 0.138153, -0.132062),(-0.195378, 0.000000, -0.132062),(-0.138153, 0.138153, -0.132062),(-0.104949, 0.104949, -0.207369),(-0.148421, -0.000000, -0.207369),(-0.148421, -0.000000, -0.207369),(-0.104949, -0.104949, -0.207369),(-0.138153, -0.138153, -0.132062),(-0.104949, -0.104949, -0.207369),(0.000000, -0.148421, -0.207369),(0.000000, -0.195378, -0.132062),(0.000000, -0.095005, -0.282677),(0.067179, -0.067178, -0.282677),(0.104950, -0.104949, -0.207369),(0.138153, 0.138153, -0.132062),(0.160449, 0.160449, -0.056754),(0.226909, 0.000000, -0.056754),(0.000000, -0.148421, -0.207369),(0.104950, -0.104949, -0.207369),(0.138153, -0.138153, -0.132062),(0.160449, 0.160449, -0.056754),(0.138153, 0.138153, -0.132062),(0.000000, 0.195378, -0.132062),(0.138153, 0.138153, -0.132062),(0.104950, 0.104949, -0.207369),(0.000000, 0.148421, -0.207369),(0.067179, -0.067178, -0.282677),(0.095005, -0.000000, -0.282677),(0.148421, -0.000000, -0.207369),(0.104950, -0.104949, -0.207369),(0.148421, -0.000000, -0.207369),(0.195378, 0.000000, -0.132062),(-0.000000, 0.226909, -0.056754),(0.000000, 0.195378, -0.132062),(-0.138153, 0.138153, -0.132062),(0.000000, 0.195378, -0.132062),(0.000000, 0.148421, -0.207369),(-0.104949, 0.104949, -0.207369),(-0.440526, -0.023107, -0.493787),(-0.434003, -0.000114, -0.500706),(-0.231329, 0.000977, -0.274618),(-0.440526, -0.023107, -0.493787),(-0.456116, -0.032649, -0.476886),(-0.455855, 0.032388, -0.476649),(-0.471643, -0.023126, -0.459901),(-0.456116, -0.032649, -0.476886),(-0.231329, 0.000977, -0.274618),(-0.477994, -0.000114, -0.452801),(-0.471643, -0.023126, -0.459901),(-0.231329, 0.000977, -0.274618),(-0.471448, 0.022882, -0.459746),(-0.477994, -0.000114, -0.452801),(-0.231329, 0.000977, -0.274618),(-0.455855, 0.032388, -0.476649),(-0.471448, 0.022882, -0.459746),(-0.231329, 0.000977, -0.274618),(-0.456116, -0.032649, -0.476886),(-0.440526, -0.023107, -0.493787),(-0.231329, 0.000977, -0.274618),(-0.434003, -0.000114, -0.500706),(-0.440352, 0.022863, -0.493607),(-0.231329, 0.000977, -0.274618),(-0.455855, 0.032388, -0.476649),(-0.440352, 0.022863, -0.493607),(-0.434003, -0.000114, -0.500706),(-0.434003, -0.000114, -0.500706),(-0.440526, -0.023107, -0.493787),(-0.455855, 0.032388, -0.476649),(-0.440352, 0.022863, -0.493607),(-0.455855, 0.032388, -0.476649),(-0.231329, 0.000977, -0.274618),(-0.456116, -0.032649, -0.476886),(-0.471643, -0.023126, -0.459901),(-0.477994, -0.000114, -0.452801),(-0.477994, -0.000114, -0.452801),(-0.471448, 0.022882, -0.459746),(-0.456116, -0.032649, -0.476886),(-0.471448, 0.022882, -0.459746),(-0.455855, 0.032388, -0.476649),(-0.456116, -0.032649, -0.476886),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/scene_preview_camera.py",
    "content": "SHAPE = ((0.000000, -0.014454, 0.006692),(-0.939086, -1.070925, 0.495799),(-0.952800, -1.077091, 0.493699),(0.000000, -0.014454, 0.006692),(-0.952800, -1.077091, 0.493699),(0.000000, -0.010000, 0.000000),(-0.939086, -1.070925, 0.495799),(0.000000, -0.014454, 0.006692),(-0.000000, 0.010000, 0.000000),(-0.939086, -1.070925, 0.495799),(-0.000000, 0.010000, 0.000000),(-0.967200, -1.082909, 0.506301),(-0.939086, -1.070925, 0.495799),(0.939086, -1.070925, 0.495799),(0.952800, -1.077091, 0.493699),(-0.939086, -1.070925, 0.495799),(0.952800, -1.077091, 0.493699),(-0.952800, -1.077091, 0.493699),(0.939086, -1.070925, 0.495799),(-0.939086, -1.070925, 0.495799),(-0.967200, -1.082909, 0.506301),(0.939086, -1.070925, 0.495799),(-0.967200, -1.082909, 0.506301),(0.967200, -1.082909, 0.506301),(0.939086, -1.070925, 0.495799),(0.000000, -0.014454, 0.006692),(0.000000, -0.010000, 0.000000),(0.939086, -1.070925, 0.495799),(0.000000, -0.010000, 0.000000),(0.952800, -1.077091, 0.493699),(0.000000, -0.014454, 0.006692),(0.939086, -1.070925, 0.495799),(0.967200, -1.082909, 0.506301),(0.000000, -0.014454, 0.006692),(0.967200, -1.082909, 0.506301),(-0.000000, 0.010000, 0.000000),(0.950000, -1.080000, -0.490000),(0.950000, -1.080000, 0.490000),(0.952800, -1.077091, 0.493699),(0.950000, -1.080000, -0.490000),(0.952800, -1.077091, 0.493699),(0.952800, -1.077091, -0.493699),(0.950000, -1.080000, 0.490000),(0.950000, -1.080000, -0.490000),(0.967200, -1.082909, -0.506301),(0.950000, -1.080000, 0.490000),(0.967200, -1.082909, -0.506301),(0.967200, -1.082909, 0.506301),(0.950000, -1.080000, 0.490000),(-0.950000, -1.080000, 0.490000),(-0.952800, -1.077091, 0.493699),(0.950000, -1.080000, 0.490000),(-0.952800, -1.077091, 0.493699),(0.952800, -1.077091, 0.493699),(-0.950000, -1.080000, 0.490000),(0.950000, -1.080000, 0.490000),(0.967200, -1.082909, 0.506301),(-0.950000, -1.080000, 0.490000),(0.967200, -1.082909, 0.506301),(-0.967200, -1.082909, 0.506301),(-0.950000, -1.080000, 0.490000),(-0.950000, -1.080000, -0.490000),(-0.952800, -1.077091, -0.493699),(-0.950000, -1.080000, 0.490000),(-0.952800, -1.077091, -0.493699),(-0.952800, -1.077091, 0.493699),(-0.950000, -1.080000, -0.490000),(-0.950000, -1.080000, 0.490000),(-0.967200, -1.082909, 0.506301),(-0.950000, -1.080000, -0.490000),(-0.967200, -1.082909, 0.506301),(-0.967200, -1.082909, -0.506301),(-0.950000, -1.080000, -0.490000),(0.950000, -1.080000, -0.490000),(0.952800, -1.077091, -0.493699),(-0.950000, -1.080000, -0.490000),(0.952800, -1.077091, -0.493699),(-0.952800, -1.077091, -0.493699),(0.950000, -1.080000, -0.490000),(-0.950000, -1.080000, -0.490000),(-0.967200, -1.082909, -0.506301),(0.950000, -1.080000, -0.490000),(-0.967200, -1.082909, -0.506301),(0.967200, -1.082909, -0.506301),(-0.953356, -1.072526, -0.485958),(-0.953356, -1.072526, 0.485958),(-0.952800, -1.077091, 0.493699),(-0.953356, -1.072526, -0.485958),(-0.952800, -1.077091, 0.493699),(-0.952800, -1.077091, -0.493699),(-0.953356, -1.072526, 0.485958),(-0.953356, -1.072526, -0.485958),(-0.967200, -1.082909, -0.506301),(-0.953356, -1.072526, 0.485958),(-0.967200, -1.082909, -0.506301),(-0.967200, -1.082909, 0.506301),(-0.953356, -1.072526, 0.485958),(-0.020317, -0.022857, 0.000000),(0.000000, -0.010000, 0.000000),(-0.953356, -1.072526, 0.485958),(0.000000, -0.010000, 0.000000),(-0.952800, -1.077091, 0.493699),(-0.020317, -0.022857, 0.000000),(-0.953356, -1.072526, 0.485958),(-0.967200, -1.082909, 0.506301),(-0.020317, -0.022857, 0.000000),(-0.967200, -1.082909, 0.506301),(-0.000000, 0.010000, 0.000000),(-0.020317, -0.022857, 0.000000),(-0.953356, -1.072526, -0.485958),(-0.952800, -1.077091, -0.493699),(-0.020317, -0.022857, 0.000000),(-0.952800, -1.077091, -0.493699),(0.000000, -0.010000, 0.000000),(-0.953356, -1.072526, -0.485958),(-0.020317, -0.022857, 0.000000),(-0.000000, 0.010000, 0.000000),(-0.953356, -1.072526, -0.485958),(-0.000000, 0.010000, 0.000000),(-0.967200, -1.082909, -0.506301),(0.000000, -0.014454, -0.006692),(0.939086, -1.070925, -0.495799),(0.952800, -1.077091, -0.493699),(0.000000, -0.014454, -0.006692),(0.952800, -1.077091, -0.493699),(0.000000, -0.010000, 0.000000),(0.939086, -1.070925, -0.495799),(0.000000, -0.014454, -0.006692),(-0.000000, 0.010000, 0.000000),(0.939086, -1.070925, -0.495799),(-0.000000, 0.010000, 0.000000),(0.967200, -1.082909, -0.506301),(0.939086, -1.070925, -0.495799),(-0.939086, -1.070925, -0.495799),(-0.952800, -1.077091, -0.493699),(0.939086, -1.070925, -0.495799),(-0.952800, -1.077091, -0.493699),(0.952800, -1.077091, -0.493699),(-0.939086, -1.070925, -0.495799),(0.939086, -1.070925, -0.495799),(0.967200, -1.082909, -0.506301),(-0.939086, -1.070925, -0.495799),(0.967200, -1.082909, -0.506301),(-0.967200, -1.082909, -0.506301),(-0.939086, -1.070925, -0.495799),(0.000000, -0.014454, -0.006692),(0.000000, -0.010000, 0.000000),(-0.939086, -1.070925, -0.495799),(0.000000, -0.010000, 0.000000),(-0.952800, -1.077091, -0.493699),(0.000000, -0.014454, -0.006692),(-0.939086, -1.070925, -0.495799),(-0.967200, -1.082909, -0.506301),(0.000000, -0.014454, -0.006692),(-0.967200, -1.082909, -0.506301),(-0.000000, 0.010000, 0.000000),(0.020317, -0.022857, 0.000000),(0.953356, -1.072526, 0.485958),(0.952800, -1.077091, 0.493699),(0.020317, -0.022857, 0.000000),(0.952800, -1.077091, 0.493699),(0.000000, -0.010000, 0.000000),(0.953356, -1.072526, 0.485958),(0.020317, -0.022857, 0.000000),(-0.000000, 0.010000, 0.000000),(0.953356, -1.072526, 0.485958),(-0.000000, 0.010000, 0.000000),(0.967200, -1.082909, 0.506301),(0.953356, -1.072526, 0.485958),(0.953356, -1.072526, -0.485958),(0.952800, -1.077091, -0.493699),(0.953356, -1.072526, 0.485958),(0.952800, -1.077091, -0.493699),(0.952800, -1.077091, 0.493699),(0.953356, -1.072526, -0.485958),(0.953356, -1.072526, 0.485958),(0.967200, -1.082909, 0.506301),(0.953356, -1.072526, -0.485958),(0.967200, -1.082909, 0.506301),(0.967200, -1.082909, -0.506301),(0.953356, -1.072526, -0.485958),(0.020317, -0.022857, 0.000000),(0.000000, -0.010000, 0.000000),(0.953356, -1.072526, -0.485958),(0.000000, -0.010000, 0.000000),(0.952800, -1.077091, -0.493699),(0.020317, -0.022857, 0.000000),(0.953356, -1.072526, -0.485958),(0.967200, -1.082909, -0.506301),(0.020317, -0.022857, 0.000000),(0.967200, -1.082909, -0.506301),(-0.000000, 0.010000, 0.000000),(0.633167, -1.080000, 0.553006),(-0.633167, -1.080000, 0.553006),(-0.663860, -1.090000, 0.543006),(0.633167, -1.080000, 0.553006),(-0.663860, -1.090000, 0.543006),(0.663860, -1.090000, 0.543006),(-0.633167, -1.080000, 0.553006),(0.633167, -1.080000, 0.553006),(0.663860, -1.070000, 0.543006),(-0.633167, -1.080000, 0.553006),(0.663860, -1.070000, 0.543006),(-0.663860, -1.070000, 0.543006),(-0.633167, -1.080000, 0.553006),(0.000000, -1.080000, 1.014572),(0.000000, -1.090000, 1.026947),(-0.633167, -1.080000, 0.553006),(0.000000, -1.090000, 1.026947),(-0.663860, -1.090000, 0.543006),(0.000000, -1.080000, 1.014572),(-0.633167, -1.080000, 0.553006),(-0.663860, -1.070000, 0.543006),(0.000000, -1.080000, 1.014572),(-0.663860, -1.070000, 0.543006),(0.000000, -1.070000, 1.026947),(0.000000, -1.080000, 1.014572),(0.633167, -1.080000, 0.553006),(0.663860, -1.090000, 0.543006),(0.000000, -1.080000, 1.014572),(0.663860, -1.090000, 0.543006),(0.000000, -1.090000, 1.026947),(0.633167, -1.080000, 0.553006),(0.000000, -1.080000, 1.014572),(0.000000, -1.070000, 1.026947),(0.633167, -1.080000, 0.553006),(0.000000, -1.070000, 1.026947),(0.663860, -1.070000, 0.543006),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/spawn_point.py",
    "content": "SHAPE = ((0.100819, -0.134342, 1.378268),(-0.100819, -0.117241, 1.378268),(-0.100819, -0.134342, 1.378268),(-0.100819, -0.117241, 1.378268),(0.100819, -0.134342, 1.378268),(0.100819, -0.117241, 1.378268),(-0.100819, -0.134342, 1.378268),(0.100819, -0.134342, 1.176630),(0.100819, -0.134342, 1.378268),(-0.100819, -0.117241, 1.176630),(0.100819, -0.117241, 1.176630),(-0.100819, -0.134342, 1.176630),(0.100819, -0.134342, 1.176630),(-0.100819, -0.134342, 1.176630),(0.100819, -0.117241, 1.176630),(0.100819, -0.117241, 1.176630),(0.100819, -0.117241, 1.378268),(0.100819, -0.134342, 1.176630),(0.100819, -0.134342, 1.378268),(0.100819, -0.134342, 1.176630),(0.100819, -0.117241, 1.378268),(-0.100819, -0.134342, 1.378268),(-0.100819, -0.117241, 1.176630),(-0.100819, -0.134342, 1.176630),(-0.100819, -0.117241, 1.176630),(-0.100819, -0.134342, 1.378268),(-0.100819, -0.117241, 1.378268),(0.100819, -0.134342, 1.176630),(-0.100819, -0.134342, 1.378268),(-0.100819, -0.134342, 1.176630),(-0.000000, 0.053446, 1.710669),(-0.064521, 0.026720, 1.710669),(-0.091246, -0.037800, 1.710668),(-0.000000, 0.053446, 1.710669),(-0.091246, -0.037800, 1.710668),(-0.000000, -0.037800, 1.717347),(-0.000000, 0.053446, 1.710669),(-0.034890, 0.046399, 1.710426),(-0.064521, 0.026720, 1.710669),(-0.091246, -0.037800, 1.710668),(-0.084201, -0.072691, 1.710426),(-0.064521, -0.102321, 1.710669),(0.064520, 0.026720, 1.710669),(-0.000000, 0.053446, 1.710669),(0.091246, -0.037800, 1.710668),(0.091246, -0.037800, 1.710668),(-0.000000, -0.037800, 1.717347),(-0.000000, -0.129046, 1.710668),(0.091246, -0.037800, 1.710668),(-0.000000, 0.053446, 1.710669),(-0.000000, -0.037800, 1.717347),(0.091246, -0.037800, 1.710668),(0.084201, -0.002909, 1.710426),(0.064520, 0.026720, 1.710669),(0.091246, -0.037800, 1.710668),(-0.000000, -0.129046, 1.710668),(0.064520, -0.102321, 1.710669),(-0.000000, -0.037800, 1.717347),(-0.091246, -0.037800, 1.710668),(-0.000000, -0.129046, 1.710668),(-0.000000, -0.129046, 1.710668),(-0.091246, -0.037800, 1.710668),(-0.064521, -0.102321, 1.710669),(-0.000000, -0.129046, 1.710668),(0.034891, -0.122001, 1.710426),(0.064520, -0.102321, 1.710669),(-0.045969, -0.148779, 1.557691),(-0.084940, -0.122740, 1.557751),(-0.084940, -0.122740, 1.506513),(-0.045969, -0.148779, 1.557691),(-0.084940, -0.122740, 1.506513),(-0.045969, -0.148779, 1.506513),(-0.084940, -0.122740, 1.557751),(-0.110979, -0.083769, 1.669221),(-0.110979, -0.083769, 1.557693),(-0.084940, -0.122740, 1.557751),(-0.084940, -0.122740, 1.669338),(-0.110979, -0.083769, 1.669221),(-0.084940, -0.122740, 1.506513),(-0.110979, -0.083769, 1.557693),(-0.110979, -0.083769, 1.506513),(-0.084940, -0.122740, 1.506513),(-0.084940, -0.122740, 1.557751),(-0.110979, -0.083769, 1.557693),(-0.045969, -0.148779, 1.506513),(-0.000000, -0.157924, 1.557751),(-0.045969, -0.148779, 1.557691),(-0.084940, 0.047140, 1.506513),(-0.110979, 0.008169, 1.557693),(-0.084940, 0.047140, 1.557751),(-0.084940, 0.047140, 1.506513),(-0.045969, 0.073179, 1.557691),(-0.045969, 0.073179, 1.506513),(-0.045969, 0.073179, 1.557691),(-0.084940, 0.047140, 1.506513),(-0.084940, 0.047140, 1.557751),(-0.045969, 0.073179, 1.557691),(-0.000000, 0.082323, 1.506513),(-0.045969, 0.073179, 1.506513),(-0.045969, 0.073179, 1.557691),(-0.045969, 0.073179, 1.669218),(-0.000000, 0.082323, 1.557751),(-0.084940, 0.047140, 1.557751),(-0.045969, 0.073179, 1.669218),(-0.045969, 0.073179, 1.557691),(-0.084940, 0.047140, 1.557751),(-0.110979, 0.008169, 1.669221),(-0.084940, 0.047140, 1.669338),(0.110979, 0.008169, 1.506513),(0.084940, 0.047140, 1.506513),(0.110979, 0.008169, 1.557693),(0.084940, 0.047140, 1.506513),(0.045969, 0.073179, 1.557693),(0.084940, 0.047140, 1.557751),(0.110979, 0.008169, 1.557693),(0.120123, -0.037800, 1.506513),(0.110979, 0.008169, 1.506513),(0.110979, 0.008169, 1.557693),(0.084940, 0.047140, 1.506513),(0.084940, 0.047140, 1.557751),(0.084940, 0.047140, 1.557751),(0.045969, 0.073179, 1.669221),(0.084940, 0.047140, 1.669338),(-0.110979, 0.008169, 1.557693),(-0.084940, 0.047140, 1.506513),(-0.110979, 0.008169, 1.506513),(-0.000000, -0.157924, 1.557751),(0.045969, -0.148780, 1.506513),(0.045969, -0.148780, 1.557693),(-0.000000, -0.157924, 1.557751),(-0.045969, -0.148779, 1.506513),(-0.000000, -0.165867, 1.504920),(-0.000000, -0.157924, 1.557751),(0.045969, -0.148780, 1.669221),(-0.000000, -0.157924, 1.669337),(-0.000000, -0.157924, 1.557751),(-0.000000, -0.157924, 1.669337),(-0.045969, -0.148779, 1.669218),(-0.000000, 0.082323, 1.506513),(-0.000000, 0.082323, 1.557751),(0.045969, 0.073179, 1.557693),(-0.000000, 0.082323, 1.506513),(-0.045969, 0.073179, 1.557691),(-0.000000, 0.082323, 1.557751),(-0.000000, 0.082323, 1.557751),(-0.045969, 0.073179, 1.669218),(-0.000000, 0.082323, 1.669337),(-0.000000, 0.082323, 1.557751),(0.045969, 0.073179, 1.669221),(0.045969, 0.073179, 1.557693),(0.045969, -0.148780, 1.506513),(-0.000000, -0.157924, 1.557751),(-0.000000, -0.165867, 1.504920),(0.045969, -0.148780, 1.557693),(0.045969, -0.148780, 1.506513),(0.084940, -0.122740, 1.506513),(0.045969, 0.073179, 1.506513),(-0.000000, 0.082323, 1.506513),(0.045969, 0.073179, 1.557693),(0.045969, 0.073179, 1.557693),(0.084940, 0.047140, 1.506513),(0.045969, 0.073179, 1.506513),(0.045969, 0.073179, 1.557693),(0.045969, 0.073179, 1.669221),(0.084940, 0.047140, 1.557751),(0.084940, -0.122740, 1.557751),(0.084940, -0.122740, 1.669338),(0.045969, -0.148780, 1.669221),(0.084940, -0.122740, 1.557751),(0.045969, -0.148780, 1.557693),(0.084940, -0.122740, 1.506513),(0.084940, -0.122740, 1.557751),(0.084940, -0.122740, 1.506513),(0.110979, -0.083769, 1.557693),(0.084940, -0.122740, 1.506513),(0.110979, -0.083769, 1.506513),(0.110979, -0.083769, 1.557693),(-0.120123, -0.037800, 1.506513),(-0.120123, -0.037800, 1.557751),(-0.110979, 0.008169, 1.557693),(-0.120123, -0.037800, 1.506513),(-0.110979, 0.008169, 1.557693),(-0.110979, 0.008169, 1.506513),(-0.120123, -0.037800, 1.557751),(-0.120123, -0.037800, 1.669337),(-0.110979, 0.008169, 1.669221),(-0.120123, -0.037800, 1.557751),(-0.110979, 0.008169, 1.669221),(-0.110979, 0.008169, 1.557693),(0.120123, -0.037800, 1.506513),(0.110979, 0.008169, 1.557693),(0.120123, -0.037800, 1.557751),(0.120123, -0.037800, 1.557751),(0.110979, 0.008169, 1.669221),(0.120123, -0.037800, 1.669337),(-0.110979, -0.083769, 1.557693),(-0.120123, -0.037800, 1.506513),(-0.110979, -0.083769, 1.506513),(-0.120123, -0.037800, 1.506513),(-0.110979, -0.083769, 1.557693),(-0.120123, -0.037800, 1.557751),(-0.120123, -0.037800, 1.557751),(-0.110979, -0.083769, 1.669221),(-0.120123, -0.037800, 1.669337),(0.110979, -0.083769, 1.506513),(0.120123, -0.037800, 1.506513),(0.110979, -0.083769, 1.557693),(0.110979, -0.083769, 1.557693),(0.120123, -0.037800, 1.506513),(0.120123, -0.037800, 1.557751),(0.110979, -0.083769, 1.557693),(0.110979, -0.083769, 1.669221),(0.084940, -0.122740, 1.557751),(-0.034890, -0.121999, 1.710426),(-0.000000, -0.129046, 1.710668),(-0.064521, -0.102321, 1.710669),(0.034891, 0.046401, 1.710426),(-0.000000, 0.053446, 1.710669),(0.064520, 0.026720, 1.710669),(-0.084201, -0.002909, 1.710426),(-0.091246, -0.037800, 1.710668),(-0.064521, 0.026720, 1.710669),(0.084201, -0.072691, 1.710426),(0.091246, -0.037800, 1.710668),(0.064520, -0.102321, 1.710669),(-0.064521, -0.102321, 1.710669),(-0.110979, -0.083769, 1.669221),(-0.084940, -0.122740, 1.669338),(-0.064521, -0.102321, 1.710669),(-0.045969, -0.148779, 1.669218),(-0.034890, -0.121999, 1.710426),(-0.045969, -0.148779, 1.669218),(-0.064521, -0.102321, 1.710669),(-0.084940, -0.122740, 1.669338),(-0.034890, -0.121999, 1.710426),(-0.045969, -0.148779, 1.669218),(-0.000000, -0.157924, 1.669337),(-0.110979, -0.083769, 1.669221),(-0.064521, -0.102321, 1.710669),(-0.084201, -0.072691, 1.710426),(-0.084201, -0.072691, 1.710426),(-0.120123, -0.037800, 1.669337),(-0.110979, -0.083769, 1.669221),(-0.120123, -0.037800, 1.669337),(-0.084201, -0.072691, 1.710426),(-0.091246, -0.037800, 1.710668),(0.064520, -0.102321, 1.710669),(0.110979, -0.083769, 1.669221),(0.084201, -0.072691, 1.710426),(0.110979, -0.083769, 1.669221),(0.064520, -0.102321, 1.710669),(0.084940, -0.122740, 1.669338),(0.110979, -0.083769, 1.669221),(0.120123, -0.037800, 1.669337),(0.084201, -0.072691, 1.710426),(0.084201, -0.072691, 1.710426),(0.120123, -0.037800, 1.669337),(0.091246, -0.037800, 1.710668),(0.034891, -0.122001, 1.710426),(-0.000000, -0.157924, 1.669337),(0.045969, -0.148780, 1.669221),(0.034891, -0.122001, 1.710426),(0.045969, -0.148780, 1.669221),(0.064520, -0.102321, 1.710669),(0.045969, -0.148780, 1.669221),(0.084940, -0.122740, 1.669338),(0.064520, -0.102321, 1.710669),(-0.000000, -0.157924, 1.669337),(0.034891, -0.122001, 1.710426),(-0.000000, -0.129046, 1.710668),(-0.000000, -0.129046, 1.710668),(-0.034890, -0.121999, 1.710426),(-0.000000, -0.157924, 1.669337),(0.045969, 0.073179, 1.669221),(0.064520, 0.026720, 1.710669),(0.084940, 0.047140, 1.669338),(0.064520, 0.026720, 1.710669),(0.045969, 0.073179, 1.669221),(0.034891, 0.046401, 1.710426),(0.084940, 0.047140, 1.669338),(0.064520, 0.026720, 1.710669),(0.110979, 0.008169, 1.669221),(0.034891, 0.046401, 1.710426),(-0.000000, 0.082323, 1.669337),(-0.000000, 0.053446, 1.710669),(0.084201, -0.002909, 1.710426),(0.110979, 0.008169, 1.669221),(0.064520, 0.026720, 1.710669),(0.084201, -0.002909, 1.710426),(0.120123, -0.037800, 1.669337),(0.110979, 0.008169, 1.669221),(0.120123, -0.037800, 1.669337),(0.084201, -0.002909, 1.710426),(0.091246, -0.037800, 1.710668),(-0.120123, -0.037800, 1.669337),(-0.084201, -0.002909, 1.710426),(-0.110979, 0.008169, 1.669221),(-0.120123, -0.037800, 1.669337),(-0.091246, -0.037800, 1.710668),(-0.084201, -0.002909, 1.710426),(-0.110979, 0.008169, 1.669221),(-0.084201, -0.002909, 1.710426),(-0.064521, 0.026720, 1.710669),(-0.110979, 0.008169, 1.669221),(-0.064521, 0.026720, 1.710669),(-0.084940, 0.047140, 1.669338),(-0.084940, 0.047140, 1.669338),(-0.064521, 0.026720, 1.710669),(-0.045969, 0.073179, 1.669218),(-0.045969, 0.073179, 1.669218),(-0.034890, 0.046399, 1.710426),(-0.000000, 0.082323, 1.669337),(-0.045969, 0.073179, 1.669218),(-0.064521, 0.026720, 1.710669),(-0.034890, 0.046399, 1.710426),(-0.000000, 0.082323, 1.669337),(0.034891, 0.046401, 1.710426),(0.045969, 0.073179, 1.669221),(-0.000000, 0.082323, 1.669337),(-0.034890, 0.046399, 1.710426),(-0.000000, 0.053446, 1.710669),(-0.076214, -0.114014, 1.492280),(-0.041247, -0.137378, 1.492280),(-0.045969, -0.148779, 1.506513),(-0.076214, -0.114014, 1.492280),(-0.110979, -0.083769, 1.506513),(-0.099578, -0.079047, 1.492280),(-0.110979, -0.083769, 1.506513),(-0.076214, -0.114014, 1.492280),(-0.084940, -0.122740, 1.506513),(-0.099578, -0.079047, 1.492280),(-0.120123, -0.037800, 1.506513),(-0.107783, -0.037800, 1.492280),(-0.045969, -0.148779, 1.506513),(-0.084940, -0.122740, 1.506513),(-0.076214, -0.114014, 1.492280),(-0.041247, -0.137378, 1.492280),(-0.000000, -0.145583, 1.492280),(-0.045969, -0.148779, 1.506513),(-0.000000, -0.165867, 1.504920),(-0.045969, -0.148779, 1.506513),(-0.000000, -0.145583, 1.492280),(-0.084940, 0.047140, 1.506513),(-0.099578, 0.003446, 1.492280),(-0.110979, 0.008169, 1.506513),(-0.099578, 0.003446, 1.492280),(-0.084940, 0.047140, 1.506513),(-0.076214, 0.038414, 1.492280),(-0.076214, 0.038414, 1.492280),(-0.045969, 0.073179, 1.506513),(-0.041247, 0.061778, 1.492280),(-0.045969, 0.073179, 1.506513),(-0.076214, 0.038414, 1.492280),(-0.084940, 0.047140, 1.506513),(-0.041247, 0.061778, 1.492280),(-0.000000, 0.082323, 1.506513),(-0.000000, 0.069982, 1.492280),(-0.000000, 0.082323, 1.506513),(-0.041247, 0.061778, 1.492280),(-0.045969, 0.073179, 1.506513),(-0.120123, -0.037800, 1.506513),(-0.099578, 0.003446, 1.492280),(-0.107783, -0.037800, 1.492280),(-0.120123, -0.037800, 1.506513),(-0.110979, 0.008169, 1.506513),(-0.099578, 0.003446, 1.492280),(0.084940, 0.047140, 1.506513),(0.041246, 0.061778, 1.492280),(0.045969, 0.073179, 1.506513),(0.041246, 0.061778, 1.492280),(-0.000000, 0.069982, 1.492280),(-0.000000, 0.082323, 1.506513),(0.041246, 0.061778, 1.492280),(-0.000000, 0.082323, 1.506513),(0.045969, 0.073179, 1.506513),(0.041246, 0.061778, 1.492280),(0.084940, 0.047140, 1.506513),(0.076214, 0.038414, 1.492280),(0.076214, 0.038414, 1.492280),(0.110979, 0.008169, 1.506513),(0.099578, 0.003446, 1.492280),(0.110979, 0.008169, 1.506513),(0.076214, 0.038414, 1.492280),(0.084940, 0.047140, 1.506513),(0.099578, 0.003446, 1.492280),(0.120123, -0.037800, 1.506513),(0.107783, -0.037800, 1.492280),(0.120123, -0.037800, 1.506513),(0.099578, 0.003446, 1.492280),(0.110979, 0.008169, 1.506513),(0.045969, -0.148780, 1.506513),(-0.000000, -0.165867, 1.504920),(-0.000000, -0.145583, 1.492280),(0.045969, -0.148780, 1.506513),(-0.000000, -0.145583, 1.492280),(0.041247, -0.137378, 1.492280),(0.045969, -0.148780, 1.506513),(0.076214, -0.114014, 1.492280),(0.084940, -0.122740, 1.506513),(0.076214, -0.114014, 1.492280),(0.045969, -0.148780, 1.506513),(0.041247, -0.137378, 1.492280),(0.084940, -0.122740, 1.506513),(0.099578, -0.079047, 1.492280),(0.110979, -0.083769, 1.506513),(0.099578, -0.079047, 1.492280),(0.084940, -0.122740, 1.506513),(0.076214, -0.114014, 1.492280),(0.099578, -0.079047, 1.492280),(0.107783, -0.037800, 1.492280),(0.120123, -0.037800, 1.506513),(-0.120123, -0.037800, 1.506513),(-0.099578, -0.079047, 1.492280),(-0.110979, -0.083769, 1.506513),(0.120123, -0.037800, 1.506513),(0.110979, -0.083769, 1.506513),(0.099578, -0.079047, 1.492280),(-0.099578, 0.003446, 1.492280),(0.099578, 0.003446, 1.492280),(-0.000000, -0.145583, 1.492280),(-0.099578, 0.003446, 1.492280),(0.041246, 0.061778, 1.492280),(0.099578, 0.003446, 1.492280),(-0.099578, 0.003446, 1.492280),(-0.099578, -0.079047, 1.492280),(-0.107783, -0.037800, 1.492280),(0.099578, 0.003446, 1.492280),(0.041246, 0.061778, 1.492280),(0.076214, 0.038414, 1.492280),(-0.000000, -0.145583, 1.492280),(0.099578, 0.003446, 1.492280),(0.041247, -0.137378, 1.492280),(-0.041247, 0.061778, 1.492280),(-0.099578, 0.003446, 1.492280),(-0.076214, 0.038414, 1.492280),(0.041246, 0.061778, 1.492280),(-0.099578, 0.003446, 1.492280),(-0.041247, 0.061778, 1.492280),(0.041246, 0.061778, 1.492280),(-0.041247, 0.061778, 1.492280),(-0.000000, 0.069982, 1.492280),(0.041247, -0.137378, 1.492280),(0.099578, -0.079047, 1.492280),(0.076214, -0.114014, 1.492280),(0.041247, -0.137378, 1.492280),(0.099578, 0.003446, 1.492280),(0.099578, -0.079047, 1.492280),(0.099578, -0.079047, 1.492280),(0.099578, 0.003446, 1.492280),(0.107783, -0.037800, 1.492280),(-0.041247, -0.137378, 1.492280),(-0.099578, -0.079047, 1.492280),(-0.099578, 0.003446, 1.492280),(-0.041247, -0.137378, 1.492280),(-0.099578, 0.003446, 1.492280),(-0.000000, -0.145583, 1.492280),(-0.041247, -0.137378, 1.492280),(-0.076214, -0.114014, 1.492280),(-0.099578, -0.079047, 1.492280),(-0.045969, -0.148779, 1.669218),(-0.045969, -0.148779, 1.557691),(-0.000000, -0.157924, 1.557751),(-0.045969, -0.148779, 1.669218),(-0.084940, -0.122740, 1.557751),(-0.045969, -0.148779, 1.557691),(-0.084940, -0.122740, 1.669338),(-0.084940, -0.122740, 1.557751),(-0.045969, -0.148779, 1.669218),(-0.110979, -0.083769, 1.669221),(-0.120123, -0.037800, 1.557751),(-0.110979, -0.083769, 1.557693),(-0.110979, 0.008169, 1.669221),(-0.084940, 0.047140, 1.557751),(-0.110979, 0.008169, 1.557693),(-0.045969, 0.073179, 1.669218),(-0.084940, 0.047140, 1.557751),(-0.084940, 0.047140, 1.669338),(0.045969, 0.073179, 1.669221),(-0.000000, 0.082323, 1.557751),(-0.000000, 0.082323, 1.669337),(0.110979, 0.008169, 1.669221),(0.110979, 0.008169, 1.557693),(0.084940, 0.047140, 1.557751),(0.110979, 0.008169, 1.669221),(0.120123, -0.037800, 1.557751),(0.110979, 0.008169, 1.557693),(0.110979, 0.008169, 1.669221),(0.084940, 0.047140, 1.557751),(0.084940, 0.047140, 1.669338),(0.110979, -0.083769, 1.669221),(0.110979, -0.083769, 1.557693),(0.120123, -0.037800, 1.557751),(0.110979, -0.083769, 1.669221),(0.120123, -0.037800, 1.557751),(0.120123, -0.037800, 1.669337),(0.084940, -0.122740, 1.669338),(0.084940, -0.122740, 1.557751),(0.110979, -0.083769, 1.669221),(0.045969, -0.148780, 1.669221),(0.045969, -0.148780, 1.557693),(0.084940, -0.122740, 1.557751),(0.045969, -0.148780, 1.669221),(-0.000000, -0.157924, 1.557751),(0.045969, -0.148780, 1.557693),(-0.061427, -0.087414, 1.570988),(-0.061427, -0.158580, 1.570988),(-0.081631, -0.158580, 1.579796),(-0.061427, -0.158580, 1.570988),(-0.061427, -0.087414, 1.570988),(-0.041224, -0.158580, 1.579796),(-0.081631, -0.158580, 1.579796),(-0.081631, -0.087414, 1.579796),(-0.061427, -0.087414, 1.570988),(-0.081631, -0.158580, 1.579796),(-0.090439, -0.087414, 1.600000),(-0.081631, -0.087414, 1.579796),(-0.041224, -0.158580, 1.579796),(-0.061427, -0.087414, 1.570988),(-0.041224, -0.087414, 1.579796),(-0.041224, -0.158580, 1.579796),(-0.041224, -0.087414, 1.579796),(-0.032416, -0.087414, 1.600000),(-0.061427, -0.144377, 1.600000),(-0.041224, -0.158580, 1.579796),(-0.032416, -0.158580, 1.600000),(-0.061427, -0.144377, 1.600000),(-0.041224, -0.158580, 1.620204),(-0.061427, -0.158580, 1.629012),(-0.061427, -0.144377, 1.600000),(-0.081631, -0.158580, 1.579796),(-0.061427, -0.158580, 1.570988),(-0.061427, -0.144377, 1.600000),(-0.032416, -0.158580, 1.600000),(-0.041224, -0.158580, 1.620204),(-0.081631, -0.158580, 1.620204),(-0.061427, -0.144377, 1.600000),(-0.061427, -0.158580, 1.629012),(-0.061427, -0.158580, 1.629012),(-0.081631, -0.087414, 1.620204),(-0.081631, -0.158580, 1.620204),(-0.061427, -0.158580, 1.629012),(-0.041224, -0.087414, 1.620204),(-0.061427, -0.087414, 1.629012),(-0.081631, -0.087414, 1.620204),(-0.061427, -0.158580, 1.629012),(-0.061427, -0.087414, 1.629012),(-0.081631, -0.158580, 1.620204),(-0.081631, -0.087414, 1.620204),(-0.090439, -0.087414, 1.600000),(-0.041224, -0.158580, 1.620204),(-0.041224, -0.087414, 1.620204),(-0.061427, -0.158580, 1.629012),(-0.041224, -0.158580, 1.620204),(-0.032416, -0.087414, 1.600000),(-0.041224, -0.087414, 1.620204),(-0.032416, -0.158580, 1.600000),(-0.032416, -0.087414, 1.600000),(-0.041224, -0.158580, 1.620204),(-0.032416, -0.087414, 1.600000),(-0.032416, -0.158580, 1.600000),(-0.041224, -0.158580, 1.579796),(-0.090439, -0.087414, 1.600000),(-0.090439, -0.158580, 1.600000),(-0.081631, -0.158580, 1.620204),(-0.090439, -0.158580, 1.600000),(-0.090439, -0.087414, 1.600000),(-0.081631, -0.158580, 1.579796),(-0.090439, -0.158580, 1.600000),(-0.061427, -0.144377, 1.600000),(-0.081631, -0.158580, 1.620204),(-0.061427, -0.158580, 1.570988),(-0.041224, -0.158580, 1.579796),(-0.061427, -0.144377, 1.600000),(-0.081631, -0.158580, 1.579796),(-0.061427, -0.144377, 1.600000),(-0.090439, -0.158580, 1.600000),(0.061427, -0.087414, 1.570988),(0.061427, -0.158580, 1.570988),(0.041224, -0.158580, 1.579796),(0.061427, -0.158580, 1.570988),(0.061427, -0.087414, 1.570988),(0.081631, -0.158580, 1.579796),(0.041224, -0.158580, 1.579796),(0.041224, -0.087414, 1.579796),(0.061427, -0.087414, 1.570988),(0.041224, -0.158580, 1.579796),(0.032416, -0.087414, 1.600000),(0.041224, -0.087414, 1.579796),(0.081631, -0.158580, 1.579796),(0.061427, -0.087414, 1.570988),(0.081631, -0.087414, 1.579796),(0.081631, -0.158580, 1.579796),(0.081631, -0.087414, 1.579796),(0.090439, -0.087414, 1.600000),(0.061427, -0.144377, 1.600000),(0.081631, -0.158580, 1.579796),(0.090439, -0.158580, 1.600000),(0.061427, -0.144377, 1.600000),(0.081631, -0.158580, 1.620204),(0.061427, -0.158580, 1.629012),(0.061427, -0.144377, 1.600000),(0.090439, -0.158580, 1.600000),(0.081631, -0.158580, 1.620204),(0.061427, -0.144377, 1.600000),(0.041224, -0.158580, 1.579796),(0.061427, -0.158580, 1.570988),(0.041224, -0.158580, 1.620204),(0.061427, -0.144377, 1.600000),(0.061427, -0.158580, 1.629012),(0.061427, -0.158580, 1.629012),(0.041224, -0.087414, 1.620204),(0.041224, -0.158580, 1.620204),(0.041224, -0.087414, 1.620204),(0.061427, -0.158580, 1.629012),(0.061427, -0.087414, 1.629012),(0.041224, -0.158580, 1.620204),(0.041224, -0.087414, 1.620204),(0.032416, -0.087414, 1.600000),(0.061427, -0.087414, 1.629012),(0.081631, -0.158580, 1.620204),(0.081631, -0.087414, 1.620204),(0.081631, -0.158580, 1.620204),(0.061427, -0.087414, 1.629012),(0.061427, -0.158580, 1.629012),(0.081631, -0.158580, 1.620204),(0.090439, -0.087414, 1.600000),(0.081631, -0.087414, 1.620204),(0.090439, -0.158580, 1.600000),(0.090439, -0.087414, 1.600000),(0.081631, -0.158580, 1.620204),(0.090439, -0.087414, 1.600000),(0.090439, -0.158580, 1.600000),(0.081631, -0.158580, 1.579796),(0.032416, -0.087414, 1.600000),(0.032416, -0.158580, 1.600000),(0.041224, -0.158580, 1.620204),(0.032416, -0.158580, 1.600000),(0.032416, -0.087414, 1.600000),(0.041224, -0.158580, 1.579796),(0.041224, -0.158580, 1.579796),(0.061427, -0.144377, 1.600000),(0.032416, -0.158580, 1.600000),(0.032416, -0.158580, 1.600000),(0.061427, -0.144377, 1.600000),(0.041224, -0.158580, 1.620204),(0.061427, -0.158580, 1.570988),(0.081631, -0.158580, 1.579796),(0.061427, -0.144377, 1.600000),(-0.066998, -0.049239, 0.901656),(-0.118497, -0.117241, 1.170262),(-0.135000, -0.100738, 1.170262),(0.066687, -0.049319, 0.902031),(0.135000, -0.100738, 1.170262),(0.118497, -0.117241, 1.170262),(0.135000, -0.100738, 1.170262),(0.118497, -0.117241, 1.399744),(0.118497, -0.117241, 1.170262),(-0.135000, -0.100738, 1.399744),(-0.135000, -0.100738, 1.170262),(-0.118497, -0.117241, 1.399744),(-0.118497, -0.117241, 1.399744),(-0.135000, -0.100738, 1.170262),(-0.118497, -0.117241, 1.170262),(-0.118497, -0.117241, 1.399744),(0.118497, -0.117241, 1.399744),(-0.118497, -0.100738, 1.416247),(0.118497, -0.100738, 1.416247),(-0.118497, -0.100738, 1.416247),(0.118497, -0.117241, 1.399744),(-0.118497, -0.100738, 1.416247),(-0.135000, 0.115312, 1.399744),(-0.135000, -0.100738, 1.399744),(-0.135000, 0.115312, 1.399744),(-0.118497, -0.100738, 1.416247),(-0.118497, 0.118497, 1.416247),(0.118497, -0.117241, 1.399744),(0.135000, -0.100738, 1.170262),(0.135000, -0.100738, 1.399744),(0.135000, -0.100738, 1.399744),(0.135000, 0.115312, 1.399744),(0.118497, -0.100738, 1.416247),(0.118497, -0.100738, 1.416247),(0.135000, 0.115312, 1.399744),(0.116835, 0.116835, 1.416247),(-0.118497, 0.132118, 1.399998),(-0.118398, 0.091370, 1.170262),(-0.135000, 0.115312, 1.399744),(-0.135000, 0.074741, 1.170262),(-0.135000, 0.115312, 1.399744),(-0.118398, 0.091370, 1.170262),(-0.118497, 0.118497, 1.416247),(0.116835, 0.116835, 1.416247),(-0.118497, 0.132118, 1.399998),(0.118497, 0.132118, 1.399998),(-0.118497, 0.132118, 1.399998),(0.116835, 0.116835, 1.416247),(0.135000, 0.115312, 1.399744),(0.118398, 0.091370, 1.170262),(0.118497, 0.132118, 1.399998),(0.118398, 0.091370, 1.170262),(0.135000, 0.115312, 1.399744),(0.135000, 0.074741, 1.170262),(-0.066389, 0.064813, 0.902684),(-0.135000, 0.074741, 1.170262),(-0.118398, 0.091370, 1.170262),(0.066736, 0.065159, 0.902684),(0.118398, 0.091370, 1.170262),(0.135000, 0.074741, 1.170262),(-0.118497, -0.117241, 1.170262),(0.066687, -0.049319, 0.902031),(0.118497, -0.117241, 1.170262),(0.066687, -0.049319, 0.902031),(-0.118497, -0.117241, 1.170262),(-0.066998, -0.049239, 0.901656),(0.116835, 0.116835, 1.416247),(-0.118497, -0.100738, 1.416247),(0.118497, -0.100738, 1.416247),(-0.118497, -0.100738, 1.416247),(0.116835, 0.116835, 1.416247),(-0.118497, 0.118497, 1.416247),(0.118398, 0.091370, 1.170262),(-0.066389, 0.064813, 0.902684),(-0.118398, 0.091370, 1.170262),(0.118398, 0.091370, 1.170262),(-0.118398, 0.091370, 1.170262),(-0.118497, 0.132118, 1.399998),(0.118398, 0.091370, 1.170262),(-0.118497, 0.132118, 1.399998),(0.118497, 0.132118, 1.399998),(-0.066389, 0.064813, 0.902684),(0.118398, 0.091370, 1.170262),(0.066736, 0.065159, 0.902684),(0.066687, -0.049319, 0.902031),(-0.066998, -0.049239, 0.901656),(-0.066389, 0.064813, 0.902684),(0.066687, -0.049319, 0.902031),(-0.066389, 0.064813, 0.902684),(0.066736, 0.065159, 0.902684),(0.066736, 0.065159, 0.902684),(0.135000, 0.074741, 1.170262),(0.066687, -0.049319, 0.902031),(0.135000, 0.074741, 1.170262),(0.135000, -0.100738, 1.399744),(0.135000, -0.100738, 1.170262),(0.135000, -0.100738, 1.170262),(0.066687, -0.049319, 0.902031),(0.135000, 0.074741, 1.170262),(-0.066998, -0.049239, 0.901656),(-0.135000, 0.074741, 1.170262),(-0.066389, 0.064813, 0.902684),(-0.135000, 0.074741, 1.170262),(-0.135000, -0.100738, 1.399744),(-0.135000, 0.115312, 1.399744),(-0.135000, 0.074741, 1.170262),(-0.066998, -0.049239, 0.901656),(-0.135000, -0.100738, 1.170262),(-0.135000, -0.100738, 1.399744),(-0.135000, 0.074741, 1.170262),(-0.135000, -0.100738, 1.170262),(0.135000, -0.100738, 1.399744),(0.135000, 0.074741, 1.170262),(0.135000, 0.115312, 1.399744),(0.118497, -0.117241, 1.399744),(-0.118497, -0.117241, 1.399744),(-0.118497, -0.117241, 1.170262),(0.118497, -0.117241, 1.399744),(-0.118497, -0.117241, 1.170262),(0.118497, -0.117241, 1.170262),(-0.118497, -0.117241, 1.399744),(-0.118497, -0.100738, 1.416247),(-0.135000, -0.100738, 1.399744),(0.135000, -0.100738, 1.399744),(0.118497, -0.100738, 1.416247),(0.118497, -0.117241, 1.399744),(-0.135000, 0.115312, 1.399744),(-0.118497, 0.118497, 1.416247),(-0.118497, 0.132118, 1.399998),(0.118497, 0.132118, 1.399998),(0.116835, 0.116835, 1.416247),(0.135000, 0.115312, 1.399744),(0.069207, -0.069207, 0.698620),(-0.069206, 0.069206, 0.698620),(-0.069206, -0.069207, 0.698620),(-0.069206, 0.069206, 0.698620),(0.069207, -0.069207, 0.698620),(0.069207, 0.069206, 0.698620),(-0.069206, 0.069206, 0.698620),(0.069207, 0.069206, 0.698620),(0.000000, -0.000000, 0.000000),(0.069207, 0.069206, 0.698620),(0.069207, -0.069207, 0.698620),(0.000000, -0.000000, 0.000000),(0.069207, -0.069207, 0.698620),(-0.069206, -0.069207, 0.698620),(0.000000, -0.000000, 0.000000),(-0.069206, -0.069207, 0.698620),(-0.069206, 0.069206, 0.698620),(0.000000, -0.000000, 0.000000),(0.036000, -0.273481, 1.600000),(-0.036000, -0.225744, 1.600000),(-0.036000, -0.273481, 1.600000),(0.036000, -0.273481, 1.600000),(-0.036000, -0.315162, 1.600000),(0.036000, -0.315162, 1.600000),(-0.036000, -0.225744, 1.600000),(0.036000, -0.273481, 1.600000),(0.036000, -0.225744, 1.600000),(-0.036000, -0.225744, 1.600000),(0.036000, -0.168273, 1.600000),(-0.036000, -0.168273, 1.600000),(0.036000, -0.225744, 1.600000),(0.036000, -0.168273, 1.600000),(-0.036000, -0.225744, 1.600000),(-0.036000, -0.315162, 1.600000),(0.036000, -0.273481, 1.600000),(-0.036000, -0.273481, 1.600000),(0.100800, -0.315162, 1.600000),(0.000000, -0.447718, 1.600000),(-0.100800, -0.315162, 1.600000),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/spot_light.py",
    "content": "SHAPE = ((-0.000000, -0.136614, 0.103780),(-0.000000, -0.273228, 0.213055),(0.081533, -0.273228, 0.196837),(-0.000000, -0.136614, 0.103780),(0.081533, -0.273228, 0.196837),(0.039715, -0.136614, 0.095881),(0.039715, -0.136614, 0.095881),(0.081533, -0.273228, 0.196837),(0.150653, -0.273228, 0.150653),(0.039715, -0.136614, 0.095881),(0.150653, -0.273228, 0.150653),(0.073384, -0.136614, 0.073384),(0.073384, -0.136614, 0.073384),(0.150653, -0.273228, 0.150653),(0.196837, -0.273228, 0.081533),(0.073384, -0.136614, 0.073384),(0.196837, -0.273228, 0.081533),(0.095881, -0.136614, 0.039715),(0.095881, -0.136614, 0.039715),(0.196837, -0.273228, 0.081533),(0.213055, -0.273228, -0.000000),(0.095881, -0.136614, 0.039715),(0.213055, -0.273228, -0.000000),(0.103780, -0.136614, -0.000000),(0.103780, -0.136614, -0.000000),(0.213055, -0.273228, -0.000000),(0.196837, -0.273228, -0.081533),(0.103780, -0.136614, -0.000000),(0.196837, -0.273228, -0.081533),(0.095881, -0.136614, -0.039715),(0.095881, -0.136614, -0.039715),(0.196837, -0.273228, -0.081533),(0.150653, -0.273228, -0.150653),(0.095881, -0.136614, -0.039715),(0.150653, -0.273228, -0.150653),(0.073384, -0.136614, -0.073384),(0.073384, -0.136614, -0.073384),(0.150653, -0.273228, -0.150653),(0.081533, -0.273228, -0.196837),(0.073384, -0.136614, -0.073384),(0.081533, -0.273228, -0.196837),(0.039715, -0.136614, -0.095881),(0.039715, -0.136614, -0.095881),(0.081533, -0.273228, -0.196837),(-0.000000, -0.273228, -0.213055),(0.039715, -0.136614, -0.095881),(-0.000000, -0.273228, -0.213055),(-0.000000, -0.136614, -0.103780),(-0.000000, -0.136614, -0.103780),(-0.000000, -0.273228, -0.213055),(-0.081533, -0.273228, -0.196837),(-0.000000, -0.136614, -0.103780),(-0.081533, -0.273228, -0.196837),(-0.039715, -0.136614, -0.095881),(-0.039715, -0.136614, -0.095881),(-0.081533, -0.273228, -0.196837),(-0.150653, -0.273228, -0.150653),(-0.039715, -0.136614, -0.095881),(-0.150653, -0.273228, -0.150653),(-0.073384, -0.136614, -0.073384),(-0.073384, -0.136614, -0.073384),(-0.150653, -0.273228, -0.150653),(-0.196837, -0.273228, -0.081533),(-0.073384, -0.136614, -0.073384),(-0.196837, -0.273228, -0.081533),(-0.095881, -0.136614, -0.039715),(-0.095881, -0.136614, -0.039715),(-0.196837, -0.273228, -0.081533),(-0.213055, -0.273228, -0.000000),(-0.095881, -0.136614, -0.039715),(-0.213055, -0.273228, -0.000000),(-0.103780, -0.136614, -0.000000),(-0.103780, -0.136614, -0.000000),(-0.213055, -0.273228, -0.000000),(-0.196837, -0.273228, 0.081533),(-0.103780, -0.136614, -0.000000),(-0.196837, -0.273228, 0.081533),(-0.095881, -0.136614, 0.039715),(-0.095881, -0.136614, 0.039715),(-0.196837, -0.273228, 0.081533),(-0.150653, -0.273228, 0.150653),(-0.095881, -0.136614, 0.039715),(-0.150653, -0.273228, 0.150653),(-0.073384, -0.136614, 0.073384),(-0.073384, -0.136614, 0.073384),(-0.150653, -0.273228, 0.150653),(-0.081533, -0.273228, 0.196837),(-0.073384, -0.136614, 0.073384),(-0.081533, -0.273228, 0.196837),(-0.039715, -0.136614, 0.095881),(-0.039715, -0.136614, 0.095881),(-0.081533, -0.273228, 0.196837),(-0.000000, -0.273228, 0.213055),(-0.039715, -0.136614, 0.095881),(-0.000000, -0.273228, 0.213055),(-0.000000, -0.136614, 0.103780),(0.032018, -0.430293, -0.467249),(-0.022558, -0.435454, -0.462855),(-0.031498, -0.404397, -0.492328),(0.032018, -0.430293, -0.467249),(0.006328, -0.438765, -0.458397),(-0.022558, -0.435454, -0.462855),(-0.031498, -0.404397, -0.492328),(-0.006163, -0.395421, -0.499781),(0.021860, -0.399256, -0.496531),(0.038693, -0.413807, -0.483397),(0.021860, -0.399256, -0.496531),(-0.000000, -0.273228, -0.247900),(-0.022558, -0.435454, -0.462855),(-0.038680, -0.421726, -0.476810),(-0.031498, -0.404397, -0.492328),(-0.038680, -0.421726, -0.476810),(-0.022558, -0.435454, -0.462855),(-0.000000, -0.273228, -0.247900),(0.032018, -0.430293, -0.467249),(0.038693, -0.413807, -0.483397),(-0.000000, -0.273228, -0.247900),(0.021860, -0.399256, -0.496531),(0.038693, -0.413807, -0.483397),(0.032018, -0.430293, -0.467249),(-0.031498, -0.404397, -0.492328),(-0.038680, -0.421726, -0.476810),(-0.000000, -0.273228, -0.247900),(0.021860, -0.399256, -0.496531),(0.032018, -0.430293, -0.467249),(-0.031498, -0.404397, -0.492328),(-0.022558, -0.435454, -0.462855),(0.006328, -0.438765, -0.458397),(-0.000000, -0.273228, -0.247900),(0.021860, -0.399256, -0.496531),(-0.006163, -0.395421, -0.499781),(-0.000000, -0.273228, -0.247900),(-0.006163, -0.395421, -0.499781),(-0.031498, -0.404397, -0.492328),(-0.000000, -0.273228, -0.247900),(0.006328, -0.438765, -0.458397),(0.032018, -0.430293, -0.467249),(-0.000000, -0.273228, -0.247900),(-0.467249, -0.430293, -0.032018),(-0.462855, -0.435454, 0.022558),(-0.492328, -0.404397, 0.031498),(-0.467249, -0.430293, -0.032018),(-0.458397, -0.438766, -0.006328),(-0.462855, -0.435454, 0.022558),(-0.492328, -0.404397, 0.031498),(-0.499781, -0.395421, 0.006163),(-0.496531, -0.399256, -0.021860),(-0.483397, -0.413807, -0.038693),(-0.496531, -0.399256, -0.021860),(-0.247900, -0.273228, 0.000000),(-0.462855, -0.435454, 0.022558),(-0.476810, -0.421726, 0.038680),(-0.492328, -0.404397, 0.031498),(-0.476810, -0.421726, 0.038680),(-0.462855, -0.435454, 0.022558),(-0.247900, -0.273228, 0.000000),(-0.467249, -0.430293, -0.032018),(-0.483397, -0.413807, -0.038693),(-0.247900, -0.273228, 0.000000),(-0.496531, -0.399256, -0.021860),(-0.483397, -0.413807, -0.038693),(-0.467249, -0.430293, -0.032018),(-0.492328, -0.404397, 0.031498),(-0.476810, -0.421726, 0.038680),(-0.247900, -0.273228, 0.000000),(-0.496531, -0.399256, -0.021860),(-0.467249, -0.430293, -0.032018),(-0.492328, -0.404397, 0.031498),(-0.462855, -0.435454, 0.022558),(-0.458397, -0.438766, -0.006328),(-0.247900, -0.273228, 0.000000),(-0.496531, -0.399256, -0.021860),(-0.499781, -0.395421, 0.006163),(-0.247900, -0.273228, 0.000000),(-0.499781, -0.395421, 0.006163),(-0.492328, -0.404397, 0.031498),(-0.247900, -0.273228, 0.000000),(-0.458397, -0.438766, -0.006328),(-0.467249, -0.430293, -0.032018),(-0.247900, -0.273228, 0.000000),(-0.032018, -0.430293, 0.467249),(0.022558, -0.435454, 0.462855),(0.031498, -0.404397, 0.492328),(-0.032018, -0.430293, 0.467249),(-0.006328, -0.438766, 0.458397),(0.022558, -0.435454, 0.462855),(0.031498, -0.404397, 0.492328),(0.006163, -0.395421, 0.499781),(-0.021860, -0.399256, 0.496531),(-0.038693, -0.413807, 0.483397),(-0.021860, -0.399256, 0.496531),(0.000000, -0.273228, 0.247900),(0.022558, -0.435454, 0.462855),(0.038680, -0.421727, 0.476810),(0.031498, -0.404397, 0.492328),(0.038680, -0.421727, 0.476810),(0.022558, -0.435454, 0.462855),(0.000000, -0.273228, 0.247900),(-0.032018, -0.430293, 0.467249),(-0.038693, -0.413807, 0.483397),(0.000000, -0.273228, 0.247900),(-0.021860, -0.399256, 0.496531),(-0.038693, -0.413807, 0.483397),(-0.032018, -0.430293, 0.467249),(0.031498, -0.404397, 0.492328),(0.038680, -0.421727, 0.476810),(0.000000, -0.273228, 0.247900),(-0.021860, -0.399256, 0.496531),(-0.032018, -0.430293, 0.467249),(0.031498, -0.404397, 0.492328),(0.022558, -0.435454, 0.462855),(-0.006328, -0.438766, 0.458397),(0.000000, -0.273228, 0.247900),(-0.021860, -0.399256, 0.496531),(0.006163, -0.395421, 0.499781),(0.000000, -0.273228, 0.247900),(0.006163, -0.395421, 0.499781),(0.031498, -0.404397, 0.492328),(0.000000, -0.273228, 0.247900),(-0.006328, -0.438766, 0.458397),(-0.032018, -0.430293, 0.467249),(0.000000, -0.273228, 0.247900),(0.467249, -0.430293, 0.032017),(0.462855, -0.435454, -0.022558),(0.492328, -0.404397, -0.031498),(0.467249, -0.430293, 0.032017),(0.458397, -0.438765, 0.006328),(0.462855, -0.435454, -0.022558),(0.492328, -0.404397, -0.031498),(0.499781, -0.395421, -0.006163),(0.496531, -0.399256, 0.021860),(0.483397, -0.413807, 0.038693),(0.496531, -0.399256, 0.021860),(0.247900, -0.273228, -0.000000),(0.462855, -0.435454, -0.022558),(0.476810, -0.421726, -0.038680),(0.492328, -0.404397, -0.031498),(0.476810, -0.421726, -0.038680),(0.462855, -0.435454, -0.022558),(0.247900, -0.273228, -0.000000),(0.467249, -0.430293, 0.032017),(0.483397, -0.413807, 0.038693),(0.247900, -0.273228, -0.000000),(0.496531, -0.399256, 0.021860),(0.483397, -0.413807, 0.038693),(0.467249, -0.430293, 0.032017),(0.492328, -0.404397, -0.031498),(0.476810, -0.421726, -0.038680),(0.247900, -0.273228, -0.000000),(0.496531, -0.399256, 0.021860),(0.467249, -0.430293, 0.032017),(0.492328, -0.404397, -0.031498),(0.462855, -0.435454, -0.022558),(0.458397, -0.438765, 0.006328),(0.247900, -0.273228, -0.000000),(0.496531, -0.399256, 0.021860),(0.499781, -0.395421, -0.006163),(0.247900, -0.273228, -0.000000),(0.499781, -0.395421, -0.006163),(0.492328, -0.404397, -0.031498),(0.247900, -0.273228, -0.000000),(0.458397, -0.438765, 0.006328),(0.467249, -0.430293, 0.032017),(0.247900, -0.273228, -0.000000),(-0.035475, 0.000000, 0.085645),(-0.039715, -0.136614, 0.095881),(-0.000000, -0.136614, 0.103780),(-0.035475, 0.000000, 0.085645),(-0.000000, -0.136614, 0.103780),(-0.000000, 0.000000, 0.092701),(-0.065549, 0.000000, 0.065550),(-0.073384, -0.136614, 0.073384),(-0.039715, -0.136614, 0.095881),(-0.065549, 0.000000, 0.065550),(-0.039715, -0.136614, 0.095881),(-0.035475, 0.000000, 0.085645),(-0.085645, 0.000000, 0.035475),(-0.095881, -0.136614, 0.039715),(-0.073384, -0.136614, 0.073384),(-0.085645, 0.000000, 0.035475),(-0.073384, -0.136614, 0.073384),(-0.065549, 0.000000, 0.065550),(-0.092701, 0.000000, 0.000000),(-0.103780, -0.136614, -0.000000),(-0.095881, -0.136614, 0.039715),(-0.092701, 0.000000, 0.000000),(-0.095881, -0.136614, 0.039715),(-0.085645, 0.000000, 0.035475),(-0.085645, 0.000000, -0.035475),(-0.095881, -0.136614, -0.039715),(-0.103780, -0.136614, -0.000000),(-0.085645, 0.000000, -0.035475),(-0.103780, -0.136614, -0.000000),(-0.092701, 0.000000, 0.000000),(-0.065549, 0.000000, -0.065549),(-0.073384, -0.136614, -0.073384),(-0.095881, -0.136614, -0.039715),(-0.065549, 0.000000, -0.065549),(-0.095881, -0.136614, -0.039715),(-0.085645, 0.000000, -0.035475),(-0.035475, 0.000000, -0.085645),(-0.039715, -0.136614, -0.095881),(-0.073384, -0.136614, -0.073384),(-0.035475, 0.000000, -0.085645),(-0.073384, -0.136614, -0.073384),(-0.065549, 0.000000, -0.065549),(-0.000000, 0.000000, -0.092701),(-0.000000, -0.136614, -0.103780),(-0.039715, -0.136614, -0.095881),(-0.000000, 0.000000, -0.092701),(-0.039715, -0.136614, -0.095881),(-0.035475, 0.000000, -0.085645),(0.035475, 0.000000, -0.085645),(0.039715, -0.136614, -0.095881),(-0.000000, -0.136614, -0.103780),(0.035475, 0.000000, -0.085645),(-0.000000, -0.136614, -0.103780),(-0.000000, 0.000000, -0.092701),(0.065549, 0.000000, -0.065549),(0.073384, -0.136614, -0.073384),(0.039715, -0.136614, -0.095881),(0.065549, 0.000000, -0.065549),(0.039715, -0.136614, -0.095881),(0.035475, 0.000000, -0.085645),(0.085645, 0.000000, -0.035475),(0.095881, -0.136614, -0.039715),(0.073384, -0.136614, -0.073384),(0.085645, 0.000000, -0.035475),(0.073384, -0.136614, -0.073384),(0.065549, 0.000000, -0.065549),(0.092701, 0.000000, 0.000000),(0.103780, -0.136614, -0.000000),(0.095881, -0.136614, -0.039715),(0.092701, 0.000000, 0.000000),(0.095881, -0.136614, -0.039715),(0.085645, 0.000000, -0.035475),(0.085645, 0.000000, 0.035475),(0.095881, -0.136614, 0.039715),(0.103780, -0.136614, -0.000000),(0.085645, 0.000000, 0.035475),(0.103780, -0.136614, -0.000000),(0.092701, 0.000000, 0.000000),(0.065549, 0.000000, 0.065550),(0.073384, -0.136614, 0.073384),(0.095881, -0.136614, 0.039715),(0.065549, 0.000000, 0.065550),(0.095881, -0.136614, 0.039715),(0.085645, 0.000000, 0.035475),(0.035475, 0.000000, 0.085645),(0.039715, -0.136614, 0.095881),(0.073384, -0.136614, 0.073384),(0.035475, 0.000000, 0.085645),(0.073384, -0.136614, 0.073384),(0.065549, 0.000000, 0.065550),(-0.000000, 0.000000, 0.092701),(-0.000000, -0.136614, 0.103780),(0.039715, -0.136614, 0.095881),(-0.000000, 0.000000, 0.092701),(0.039715, -0.136614, 0.095881),(0.035475, 0.000000, 0.085645),(0.000000, -0.229197, 0.098270),(0.063210, -0.177151, 0.063210),(0.000000, -0.177151, 0.089393),(0.000000, -0.302802, 0.052675),(0.057715, -0.273320, 0.057715),(0.000000, -0.273320, 0.081621),(0.000000, -0.125105, 0.059123),(0.063210, -0.177151, 0.063210),(0.041807, -0.125105, 0.041807),(0.000000, -0.229197, 0.098270),(0.057715, -0.273320, 0.057715),(0.069488, -0.229197, 0.069488),(0.000000, -0.302802, 0.052675),(0.000000, -0.313155, -0.000000),(0.037247, -0.302802, 0.037247),(0.063210, -0.177151, 0.063210),(0.059123, -0.125105, 0.000000),(0.041807, -0.125105, 0.041807),(0.069488, -0.229197, 0.069488),(0.081621, -0.273320, 0.000000),(0.098270, -0.229197, 0.000000),(0.037247, -0.302802, 0.037247),(0.000000, -0.313155, -0.000000),(0.052675, -0.302802, -0.000000),(0.069488, -0.229197, 0.069488),(0.089393, -0.177151, 0.000000),(0.063210, -0.177151, 0.063210),(0.037247, -0.302802, 0.037247),(0.081621, -0.273320, 0.000000),(0.057715, -0.273320, 0.057715),(0.059123, -0.125105, 0.000000),(0.063210, -0.177151, -0.063210),(0.041807, -0.125105, -0.041807),(0.098270, -0.229197, 0.000000),(0.057715, -0.273320, -0.057715),(0.069488, -0.229197, -0.069488),(0.052675, -0.302802, -0.000000),(0.000000, -0.313155, -0.000000),(0.037247, -0.302802, -0.037247),(0.098270, -0.229197, 0.000000),(0.063210, -0.177151, -0.063210),(0.089393, -0.177151, 0.000000),(0.052675, -0.302802, -0.000000),(0.057715, -0.273320, -0.057715),(0.081621, -0.273320, 0.000000),(0.069488, -0.229197, -0.069488),(0.000000, -0.177151, -0.089393),(0.063210, -0.177151, -0.063210),(0.037247, -0.302802, -0.037247),(0.000000, -0.273320, -0.081621),(0.057715, -0.273320, -0.057715),(0.041807, -0.125105, -0.041807),(0.000000, -0.177151, -0.089393),(0.000000, -0.125105, -0.059123),(0.057715, -0.273320, -0.057715),(0.000000, -0.229197, -0.098270),(0.069488, -0.229197, -0.069488),(0.037247, -0.302802, -0.037247),(0.000000, -0.313155, -0.000000),(0.000000, -0.302802, -0.052675),(0.000000, -0.177151, -0.089393),(-0.069487, -0.229197, -0.069488),(-0.063210, -0.177151, -0.063210),(0.000000, -0.302802, -0.052675),(-0.057715, -0.273320, -0.057715),(0.000000, -0.273320, -0.081621),(0.000000, -0.177151, -0.089393),(-0.041807, -0.125105, -0.041807),(0.000000, -0.125105, -0.059123),(0.000000, -0.273320, -0.081621),(-0.069487, -0.229197, -0.069488),(0.000000, -0.229197, -0.098270),(0.000000, -0.302802, -0.052675),(0.000000, -0.313155, -0.000000),(-0.037247, -0.302802, -0.037247),(-0.041807, -0.125105, -0.041807),(-0.089392, -0.177151, 0.000000),(-0.059123, -0.125105, 0.000000),(-0.057715, -0.273320, -0.057715),(-0.098270, -0.229197, 0.000000),(-0.069487, -0.229197, -0.069488),(-0.037247, -0.302802, -0.037247),(0.000000, -0.313155, -0.000000),(-0.052675, -0.302802, -0.000000),(-0.069487, -0.229197, -0.069488),(-0.089392, -0.177151, 0.000000),(-0.063210, -0.177151, -0.063210),(-0.037247, -0.302802, -0.037247),(-0.081621, -0.273320, 0.000000),(-0.057715, -0.273320, -0.057715),(-0.081621, -0.273320, 0.000000),(-0.069487, -0.229197, 0.069488),(-0.098270, -0.229197, 0.000000),(-0.052675, -0.302802, -0.000000),(0.000000, -0.313155, -0.000000),(-0.037247, -0.302802, 0.037247),(-0.089392, -0.177151, 0.000000),(-0.069487, -0.229197, 0.069488),(-0.063210, -0.177151, 0.063210),(-0.052675, -0.302802, -0.000000),(-0.057715, -0.273320, 0.057715),(-0.081621, -0.273320, 0.000000),(-0.089392, -0.177151, 0.000000),(-0.041807, -0.125105, 0.041807),(-0.059123, -0.125105, 0.000000),(-0.069487, -0.229197, 0.069488),(0.000000, -0.177151, 0.089393),(-0.063210, -0.177151, 0.063210),(-0.037247, -0.302802, 0.037247),(0.000000, -0.273320, 0.081621),(-0.057715, -0.273320, 0.057715),(-0.041807, -0.125105, 0.041807),(0.000000, -0.177151, 0.089393),(0.000000, -0.125105, 0.059123),(-0.057715, -0.273320, 0.057715),(0.000000, -0.229197, 0.098270),(-0.069487, -0.229197, 0.069488),(-0.037247, -0.302802, 0.037247),(0.000000, -0.313155, -0.000000),(0.000000, -0.302802, 0.052675),(0.000000, -0.229197, 0.098270),(0.069488, -0.229197, 0.069488),(0.063210, -0.177151, 0.063210),(0.000000, -0.302802, 0.052675),(0.037247, -0.302802, 0.037247),(0.057715, -0.273320, 0.057715),(0.000000, -0.125105, 0.059123),(0.000000, -0.177151, 0.089393),(0.063210, -0.177151, 0.063210),(0.000000, -0.229197, 0.098270),(0.000000, -0.273320, 0.081621),(0.057715, -0.273320, 0.057715),(0.063210, -0.177151, 0.063210),(0.089393, -0.177151, 0.000000),(0.059123, -0.125105, 0.000000),(0.069488, -0.229197, 0.069488),(0.057715, -0.273320, 0.057715),(0.081621, -0.273320, 0.000000),(0.069488, -0.229197, 0.069488),(0.098270, -0.229197, 0.000000),(0.089393, -0.177151, 0.000000),(0.037247, -0.302802, 0.037247),(0.052675, -0.302802, -0.000000),(0.081621, -0.273320, 0.000000),(0.059123, -0.125105, 0.000000),(0.089393, -0.177151, 0.000000),(0.063210, -0.177151, -0.063210),(0.098270, -0.229197, 0.000000),(0.081621, -0.273320, 0.000000),(0.057715, -0.273320, -0.057715),(0.098270, -0.229197, 0.000000),(0.069488, -0.229197, -0.069488),(0.063210, -0.177151, -0.063210),(0.052675, -0.302802, -0.000000),(0.037247, -0.302802, -0.037247),(0.057715, -0.273320, -0.057715),(0.069488, -0.229197, -0.069488),(0.000000, -0.229197, -0.098270),(0.000000, -0.177151, -0.089393),(0.037247, -0.302802, -0.037247),(0.000000, -0.302802, -0.052675),(0.000000, -0.273320, -0.081621),(0.041807, -0.125105, -0.041807),(0.063210, -0.177151, -0.063210),(0.000000, -0.177151, -0.089393),(0.057715, -0.273320, -0.057715),(0.000000, -0.273320, -0.081621),(0.000000, -0.229197, -0.098270),(0.000000, -0.177151, -0.089393),(0.000000, -0.229197, -0.098270),(-0.069487, -0.229197, -0.069488),(0.000000, -0.302802, -0.052675),(-0.037247, -0.302802, -0.037247),(-0.057715, -0.273320, -0.057715),(0.000000, -0.177151, -0.089393),(-0.063210, -0.177151, -0.063210),(-0.041807, -0.125105, -0.041807),(0.000000, -0.273320, -0.081621),(-0.057715, -0.273320, -0.057715),(-0.069487, -0.229197, -0.069488),(-0.041807, -0.125105, -0.041807),(-0.063210, -0.177151, -0.063210),(-0.089392, -0.177151, 0.000000),(-0.057715, -0.273320, -0.057715),(-0.081621, -0.273320, 0.000000),(-0.098270, -0.229197, 0.000000),(-0.069487, -0.229197, -0.069488),(-0.098270, -0.229197, 0.000000),(-0.089392, -0.177151, 0.000000),(-0.037247, -0.302802, -0.037247),(-0.052675, -0.302802, -0.000000),(-0.081621, -0.273320, 0.000000),(-0.081621, -0.273320, 0.000000),(-0.057715, -0.273320, 0.057715),(-0.069487, -0.229197, 0.069488),(-0.089392, -0.177151, 0.000000),(-0.098270, -0.229197, 0.000000),(-0.069487, -0.229197, 0.069488),(-0.052675, -0.302802, -0.000000),(-0.037247, -0.302802, 0.037247),(-0.057715, -0.273320, 0.057715),(-0.089392, -0.177151, 0.000000),(-0.063210, -0.177151, 0.063210),(-0.041807, -0.125105, 0.041807),(-0.069487, -0.229197, 0.069488),(0.000000, -0.229197, 0.098270),(0.000000, -0.177151, 0.089393),(-0.037247, -0.302802, 0.037247),(0.000000, -0.302802, 0.052675),(0.000000, -0.273320, 0.081621),(-0.041807, -0.125105, 0.041807),(-0.063210, -0.177151, 0.063210),(0.000000, -0.177151, 0.089393),(-0.057715, -0.273320, 0.057715),(0.000000, -0.273320, 0.081621),(0.000000, -0.229197, 0.098270),(0.041807, -0.125105, 0.041807),(0.023779, 0.000000, 0.057407),(0.000000, -0.125105, 0.059123),(0.041807, -0.125105, 0.041807),(0.057407, 0.000000, 0.023779),(0.043938, 0.000000, 0.043938),(0.059123, -0.125105, 0.000000),(0.057407, 0.000000, 0.023779),(0.041807, -0.125105, 0.041807),(0.059123, -0.125105, 0.000000),(0.057407, 0.000000, -0.023779),(0.062137, 0.000000, -0.000000),(0.041807, -0.125105, -0.041807),(0.057407, 0.000000, -0.023779),(0.059123, -0.125105, 0.000000),(0.041807, -0.125105, -0.041807),(0.023779, 0.000000, -0.057407),(0.043938, 0.000000, -0.043938),(0.000000, -0.125105, -0.059123),(0.023779, 0.000000, -0.057407),(0.041807, -0.125105, -0.041807),(0.000000, -0.125105, -0.059123),(-0.023779, 0.000000, -0.057407),(0.000000, 0.000000, -0.062137),(-0.041807, -0.125105, -0.041807),(-0.023779, 0.000000, -0.057407),(0.000000, -0.125105, -0.059123),(-0.041807, -0.125105, -0.041807),(-0.057407, 0.000000, -0.023779),(-0.043938, 0.000000, -0.043938),(-0.059123, -0.125105, 0.000000),(-0.057407, 0.000000, -0.023779),(-0.041807, -0.125105, -0.041807),(-0.059123, -0.125105, 0.000000),(-0.057407, 0.000000, 0.023779),(-0.062137, 0.000000, -0.000000),(-0.041807, -0.125105, 0.041807),(-0.057407, 0.000000, 0.023779),(-0.059123, -0.125105, 0.000000),(-0.041807, -0.125105, 0.041807),(-0.023779, 0.000000, 0.057407),(-0.043938, 0.000000, 0.043938),(0.000000, -0.125105, 0.059123),(-0.023779, 0.000000, 0.057407),(-0.041807, -0.125105, 0.041807),(0.000000, -0.125105, 0.059123),(0.023779, 0.000000, 0.057407),(0.000000, 0.000000, 0.062137),(0.041807, -0.125105, 0.041807),(0.043938, 0.000000, 0.043938),(0.023779, 0.000000, 0.057407),(0.059123, -0.125105, 0.000000),(0.062137, 0.000000, -0.000000),(0.057407, 0.000000, 0.023779),(0.041807, -0.125105, -0.041807),(0.043938, 0.000000, -0.043938),(0.057407, 0.000000, -0.023779),(0.000000, -0.125105, -0.059123),(0.000000, 0.000000, -0.062137),(0.023779, 0.000000, -0.057407),(-0.041807, -0.125105, -0.041807),(-0.043938, 0.000000, -0.043938),(-0.023779, 0.000000, -0.057407),(-0.059123, -0.125105, 0.000000),(-0.062137, 0.000000, -0.000000),(-0.057407, 0.000000, -0.023779),(-0.041807, -0.125105, 0.041807),(-0.043938, 0.000000, 0.043938),(-0.057407, 0.000000, 0.023779),(0.000000, -0.125105, 0.059123),(0.000000, 0.000000, 0.062137),(-0.023779, 0.000000, 0.057407),)"
  },
  {
    "path": "addons/io_hubs_addon/components/models/video.py",
    "content": "SHAPE = ((0.301114, -0.005712, 0.153260),(0.429815, -0.005712, 0.132392),(0.429815, -0.005712, 0.153260),(-0.521948, -0.005712, 0.008985),(-0.473534, -0.005712, 0.003730),(-0.473534, -0.005712, 0.132392),(-0.176476, -0.005712, -0.168574),(-0.186545, -0.005712, -0.169010),(-0.345418, -0.005712, -0.295329),(-0.521948, -0.005712, -0.290074),(-0.521948, -0.005712, -0.316610),(-0.474118, -0.005712, -0.295329),(0.301114, -0.005712, 0.281922),(0.429815, -0.005712, 0.281922),(0.477645, -0.005712, 0.329738),(0.301114, -0.005712, 0.153260),(0.301114, -0.005712, 0.132392),(0.429815, -0.005712, 0.132392),(-0.495405, -0.005712, 0.329738),(-0.521948, -0.005712, 0.329738),(-0.495405, -0.005712, 0.276667),(-0.521948, -0.005712, 0.329738),(-0.521948, -0.005712, 0.008985),(-0.495405, -0.005712, 0.276667),(-0.521948, -0.005712, 0.008985),(-0.473534, -0.005712, -0.017137),(-0.473534, -0.005712, 0.003730),(-0.473534, -0.005712, -0.017137),(-0.344834, -0.005712, -0.017137),(-0.473534, -0.005712, 0.003730),(-0.344834, -0.005712, -0.017137),(-0.344834, -0.005712, 0.003730),(-0.473534, -0.005712, 0.003730),(-0.473534, -0.005712, 0.132392),(-0.474118, -0.005712, 0.153260),(-0.521948, -0.005712, 0.008985),(-0.474118, -0.005712, 0.153260),(-0.474118, -0.005712, 0.281922),(-0.495405, -0.005712, 0.276667),(-0.474118, -0.005712, 0.153260),(-0.495405, -0.005712, 0.276667),(-0.521948, -0.005712, 0.008985),(-0.473534, -0.005712, -0.017137),(-0.521948, -0.005712, 0.008985),(-0.473534, -0.005712, -0.145799),(-0.521948, -0.005712, 0.008985),(-0.521948, -0.005712, -0.290074),(-0.495405, -0.005712, -0.171922),(-0.495405, -0.005712, -0.171922),(-0.474118, -0.005712, -0.166667),(-0.473534, -0.005712, -0.145799),(-0.474118, -0.005712, -0.166667),(-0.345418, -0.005712, -0.166667),(-0.473534, -0.005712, -0.145799),(-0.521948, -0.005712, 0.008985),(-0.495405, -0.005712, -0.171922),(-0.473534, -0.005712, -0.145799),(-0.344834, -0.005712, 0.003730),(-0.344834, -0.005712, -0.017137),(-0.318172, -0.005712, 0.008986),(-0.344834, -0.005712, -0.017137),(-0.344834, -0.005712, -0.145799),(-0.190316, -0.005712, -0.159664),(-0.344834, -0.005712, 0.003730),(-0.318172, -0.005712, 0.008986),(-0.344834, -0.005712, 0.132392),(-0.344834, -0.005712, -0.145799),(-0.473534, -0.005712, -0.145799),(-0.345418, -0.005712, -0.166667),(-0.345418, -0.005712, -0.295329),(-0.474118, -0.005712, -0.295329),(-0.521948, -0.005712, -0.343145),(-0.474118, -0.005712, -0.295329),(-0.521948, -0.005712, -0.316610),(-0.521948, -0.005712, -0.343145),(-0.344834, -0.005712, -0.145799),(-0.345418, -0.005712, -0.166667),(-0.190316, -0.005712, -0.159664),(-0.318172, -0.005712, 0.008986),(-0.344834, -0.005712, -0.017137),(-0.190316, -0.005712, -0.159664),(-0.344834, -0.005712, 0.132392),(-0.318172, -0.005712, 0.008986),(-0.345418, -0.005712, 0.153260),(-0.345418, -0.005712, -0.295329),(-0.521948, -0.005712, -0.343145),(0.301114, -0.005712, -0.295329),(-0.521948, -0.005712, -0.343145),(0.477645, -0.005712, -0.343145),(0.301114, -0.005712, -0.295329),(-0.345418, -0.005712, -0.166667),(-0.345418, -0.005712, -0.295329),(-0.186545, -0.005712, -0.169010),(0.477645, -0.005712, -0.343145),(0.477645, -0.005712, 0.127137),(0.429815, -0.005712, -0.295329),(0.477645, -0.005712, -0.343145),(0.429815, -0.005712, -0.295329),(0.301114, -0.005712, -0.295329),(-0.474118, -0.005712, 0.153260),(-0.473534, -0.005712, 0.132392),(-0.344834, -0.005712, 0.132392),(-0.345418, -0.005712, 0.153260),(-0.474118, -0.005712, 0.153260),(-0.344834, -0.005712, 0.132392),(0.301114, -0.005712, -0.166667),(0.429815, -0.005712, -0.166667),(0.429815, -0.005712, -0.145799),(-0.345418, -0.005712, -0.295329),(0.301114, -0.005712, -0.295329),(-0.176476, -0.005712, -0.168574),(0.301114, -0.005712, -0.295329),(0.301114, -0.005712, -0.166667),(0.132173, -0.005712, -0.028202),(-0.176476, -0.005712, -0.168574),(0.301114, -0.005712, -0.295329),(0.132173, -0.005712, -0.028202),(-0.345418, -0.005712, 0.281922),(-0.345418, -0.005712, 0.153260),(-0.318172, -0.005712, 0.329738),(-0.318172, -0.005712, 0.329738),(-0.345418, -0.005712, 0.153260),(-0.318172, -0.005712, 0.008986),(0.301114, -0.005712, -0.166667),(0.429815, -0.005712, -0.145799),(0.301114, -0.005712, -0.145799),(0.301114, -0.005712, -0.166667),(0.301114, -0.005712, -0.145799),(0.132173, -0.005712, -0.028202),(0.301114, -0.005712, -0.145799),(0.301114, -0.005712, -0.017137),(0.142242, -0.005712, -0.019480),(0.301114, -0.005712, -0.017137),(0.429815, -0.005712, -0.017137),(0.429815, -0.005712, 0.003730),(0.301114, -0.005712, 0.003730),(0.138879, -0.005712, 0.008986),(0.142242, -0.005712, 0.006073),(0.301114, -0.005712, -0.017137),(0.429815, -0.005712, 0.003730),(0.301114, -0.005712, 0.003730),(-0.495405, -0.005712, 0.276667),(-0.474118, -0.005712, 0.281922),(-0.495405, -0.005712, 0.329738),(-0.474118, -0.005712, 0.281922),(-0.345418, -0.005712, 0.281922),(-0.495405, -0.005712, 0.329738),(-0.495405, -0.005712, 0.329738),(-0.345418, -0.005712, 0.281922),(-0.318172, -0.005712, 0.329738),(-0.190316, -0.005712, -0.159664),(-0.190316, -0.005712, 0.008986),(-0.318172, -0.005712, 0.008986),(0.301114, -0.005712, -0.017137),(0.301114, -0.005712, 0.003730),(0.146013, -0.005712, -0.006703),(0.142242, -0.005712, 0.006073),(0.146013, -0.005712, -0.006703),(0.146013, -0.005712, -0.006703),(0.301114, -0.005712, 0.003730),(0.142242, -0.005712, 0.006073),(0.146013, -0.005712, -0.006703),(-0.186545, -0.005712, -0.169010),(-0.190316, -0.005712, -0.159664),(-0.345418, -0.005712, -0.166667),(0.146013, -0.005712, -0.006703),(0.142242, -0.005712, -0.019480),(0.301114, -0.005712, -0.017137),(0.142242, -0.005712, -0.019480),(0.132173, -0.005712, -0.028202),(0.301114, -0.005712, -0.145799),(-0.474118, -0.005712, -0.295329),(-0.474118, -0.005712, -0.166667),(-0.495405, -0.005712, -0.171922),(-0.495405, -0.005712, -0.171922),(-0.521948, -0.005712, -0.290074),(-0.474118, -0.005712, -0.295329),(0.429815, -0.005712, -0.017137),(0.429815, -0.005712, -0.145799),(0.477645, -0.005712, 0.127137),(0.429815, -0.005712, -0.145799),(0.429815, -0.005712, -0.166667),(0.477645, -0.005712, 0.127137),(0.429815, -0.005712, -0.017137),(0.477645, -0.005712, 0.127137),(0.429815, -0.005712, 0.003730),(0.429815, -0.005712, -0.166667),(0.429815, -0.005712, -0.295329),(0.477645, -0.005712, 0.127137),(-0.318172, -0.005712, 0.329738),(-0.318172, -0.005712, 0.008986),(-0.190316, -0.005712, 0.146257),(-0.318172, -0.005712, 0.008986),(-0.190316, -0.005712, 0.008986),(-0.190316, -0.005712, 0.146257),(0.477645, -0.005712, 0.127137),(0.477645, -0.005712, 0.329738),(0.429815, -0.005712, 0.281922),(0.429815, -0.005712, 0.132392),(0.429815, -0.005712, 0.003730),(0.477645, -0.005712, 0.127137),(0.429815, -0.005712, 0.132392),(0.477645, -0.005712, 0.127137),(0.429815, -0.005712, 0.153260),(-0.318172, -0.005712, 0.329738),(-0.190316, -0.005712, 0.146257),(-0.186545, -0.005712, 0.155603),(-0.318172, -0.005712, 0.329738),(-0.186545, -0.005712, 0.155603),(-0.176476, -0.005712, 0.155167),(0.429815, -0.005712, 0.153260),(0.477645, -0.005712, 0.127137),(0.429815, -0.005712, 0.281922),(0.477645, -0.005712, 0.329738),(-0.318172, -0.005712, 0.329738),(0.301114, -0.005712, 0.281922),(-0.318172, -0.005712, 0.329738),(-0.176476, -0.005712, 0.155167),(0.301114, -0.005712, 0.281922),(0.132173, -0.005712, 0.014795),(0.138879, -0.005712, 0.008986),(0.301114, -0.005712, 0.132392),(0.138879, -0.005712, 0.008986),(0.301114, -0.005712, 0.003730),(0.301114, -0.005712, 0.132392),(0.301114, -0.005712, 0.132392),(0.301114, -0.005712, 0.153260),(0.132173, -0.005712, 0.014795),(0.301114, -0.005712, 0.153260),(0.301114, -0.005712, 0.281922),(0.132173, -0.005712, 0.014795),(0.132173, -0.005712, 0.014795),(0.301114, -0.005712, 0.281922),(-0.176476, -0.005712, 0.155167),(0.321729, -0.000000, 0.173868),(0.409200, -0.000000, 0.173868),(0.409200, 0.000000, 0.111784),(-0.521948, 0.000000, 0.008985),(-0.453504, 0.000000, 0.111784),(-0.453504, 0.000000, 0.024338),(-0.146304, -0.000000, -0.119575),(-0.366033, 0.000000, -0.274721),(-0.153372, 0.000000, -0.119881),(-0.521948, -0.000000, -0.290074),(-0.453504, 0.000000, -0.274721),(-0.521948, -0.000000, -0.316610),(0.321729, 0.000000, 0.261314),(0.477645, 0.000000, 0.329738),(0.409200, 0.000000, 0.261314),(0.321729, -0.000000, 0.173868),(0.409200, 0.000000, 0.111784),(0.321729, 0.000000, 0.111784),(-0.495405, 0.000000, 0.329738),(-0.495405, 0.000000, 0.276667),(-0.521948, 0.000000, 0.329738),(-0.521948, 0.000000, 0.329738),(-0.495405, 0.000000, 0.276667),(-0.521948, 0.000000, 0.008985),(-0.521948, 0.000000, 0.008985),(-0.453504, 0.000000, 0.024338),(-0.453504, 0.000000, -0.037746),(-0.453504, 0.000000, -0.037746),(-0.453504, 0.000000, 0.024338),(-0.366033, 0.000000, -0.037746),(-0.366033, 0.000000, -0.037746),(-0.453504, 0.000000, 0.024338),(-0.366033, 0.000000, 0.024338),(-0.453504, 0.000000, 0.111784),(-0.521948, 0.000000, 0.008985),(-0.453504, -0.000000, 0.173868),(-0.453504, -0.000000, 0.173868),(-0.495405, 0.000000, 0.276667),(-0.453504, -0.000000, 0.261314),(-0.453504, -0.000000, 0.173868),(-0.521948, 0.000000, 0.008985),(-0.495405, 0.000000, 0.276667),(-0.453504, 0.000000, -0.037746),(-0.453504, 0.000000, -0.125191),(-0.521948, 0.000000, 0.008985),(-0.521948, 0.000000, 0.008985),(-0.495405, 0.000000, -0.171922),(-0.521948, -0.000000, -0.290074),(-0.495405, 0.000000, -0.171922),(-0.453504, 0.000000, -0.125191),(-0.453504, 0.000000, -0.187275),(-0.453504, 0.000000, -0.187275),(-0.453504, 0.000000, -0.125191),(-0.366033, 0.000000, -0.187275),(-0.521948, 0.000000, 0.008985),(-0.453504, 0.000000, -0.125191),(-0.495405, 0.000000, -0.171922),(-0.366033, 0.000000, 0.024338),(-0.318172, 0.000000, 0.008986),(-0.366033, 0.000000, -0.037746),(-0.366033, 0.000000, -0.037746),(-0.156019, 0.000000, -0.113321),(-0.366033, 0.000000, -0.125191),(-0.366033, 0.000000, 0.024338),(-0.366033, 0.000000, 0.111784),(-0.318172, 0.000000, 0.008986),(-0.366033, 0.000000, -0.125191),(-0.366033, 0.000000, -0.187275),(-0.453504, 0.000000, -0.125191),(-0.366033, 0.000000, -0.274721),(-0.521948, 0.000000, -0.343145),(-0.453504, 0.000000, -0.274721),(-0.453504, 0.000000, -0.274721),(-0.521948, 0.000000, -0.343145),(-0.521948, -0.000000, -0.316610),(-0.366033, 0.000000, -0.125191),(-0.156019, 0.000000, -0.113321),(-0.366033, 0.000000, -0.187275),(-0.318172, 0.000000, 0.008986),(-0.156019, 0.000000, -0.113321),(-0.366033, 0.000000, -0.037746),(-0.366033, 0.000000, 0.111784),(-0.366033, -0.000000, 0.173868),(-0.318172, 0.000000, 0.008986),(-0.366033, 0.000000, -0.274721),(0.321729, -0.000000, -0.274721),(-0.521948, 0.000000, -0.343145),(-0.521948, 0.000000, -0.343145),(0.321729, -0.000000, -0.274721),(0.477645, 0.000000, -0.343145),(-0.366033, 0.000000, -0.187275),(-0.153372, 0.000000, -0.119881),(-0.366033, 0.000000, -0.274721),(0.477645, 0.000000, -0.343145),(0.409200, -0.000000, -0.274721),(0.477645, 0.000000, 0.127137),(0.477645, 0.000000, -0.343145),(0.321729, -0.000000, -0.274721),(0.409200, -0.000000, -0.274721),(-0.453504, -0.000000, 0.173868),(-0.366033, 0.000000, 0.111784),(-0.453504, 0.000000, 0.111784),(-0.366033, -0.000000, 0.173868),(-0.366033, 0.000000, 0.111784),(-0.453504, -0.000000, 0.173868),(0.321729, -0.000000, -0.187275),(0.409200, -0.000000, -0.125191),(0.409200, 0.000000, -0.187275),(-0.366033, 0.000000, -0.274721),(-0.146304, -0.000000, -0.119575),(0.321729, -0.000000, -0.274721),(0.321729, -0.000000, -0.274721),(0.070346, -0.000000, -0.021043),(0.321729, -0.000000, -0.187275),(-0.146304, -0.000000, -0.119575),(0.070346, -0.000000, -0.021043),(0.321729, -0.000000, -0.274721),(-0.366033, -0.000000, 0.261314),(-0.318172, 0.000000, 0.329738),(-0.366033, -0.000000, 0.173868),(-0.318172, 0.000000, 0.329738),(-0.318172, 0.000000, 0.008986),(-0.366033, -0.000000, 0.173868),(0.321729, -0.000000, -0.187275),(0.321729, -0.000000, -0.125191),(0.409200, -0.000000, -0.125191),(0.321729, -0.000000, -0.187275),(0.070346, -0.000000, -0.021043),(0.321729, -0.000000, -0.125191),(0.321729, -0.000000, -0.125191),(0.077414, -0.000000, -0.014921),(0.321729, -0.000000, -0.037746),(0.321729, -0.000000, -0.037746),(0.409200, 0.000000, 0.024338),(0.409200, 0.000000, -0.037746),(0.321729, 0.000000, 0.024338),(0.077414, 0.000000, 0.003015),(0.075054, 0.000000, 0.005060),(0.321729, -0.000000, -0.037746),(0.321729, 0.000000, 0.024338),(0.409200, 0.000000, 0.024338),(-0.495405, 0.000000, 0.276667),(-0.495405, 0.000000, 0.329738),(-0.453504, -0.000000, 0.261314),(-0.453504, -0.000000, 0.261314),(-0.495405, 0.000000, 0.329738),(-0.366033, -0.000000, 0.261314),(-0.495405, 0.000000, 0.329738),(-0.318172, 0.000000, 0.329738),(-0.366033, -0.000000, 0.261314),(-0.156019, 0.000000, -0.113321),(-0.318172, 0.000000, 0.008986),(-0.156019, 0.000000, 0.005060),(0.321729, -0.000000, -0.037746),(0.080061, -0.000000, -0.005953),(0.321729, 0.000000, 0.024338),(0.077414, 0.000000, 0.003015),(0.080061, -0.000000, -0.005953),(0.080061, -0.000000, -0.005953),(0.321729, 0.000000, 0.024338),(0.080061, -0.000000, -0.005953),(0.077414, 0.000000, 0.003015),(-0.153372, 0.000000, -0.119881),(-0.366033, 0.000000, -0.187275),(-0.156019, 0.000000, -0.113321),(0.080061, -0.000000, -0.005953),(0.321729, -0.000000, -0.037746),(0.077414, -0.000000, -0.014921),(0.077414, -0.000000, -0.014921),(0.321729, -0.000000, -0.125191),(0.070346, -0.000000, -0.021043),(-0.453504, 0.000000, -0.274721),(-0.495405, 0.000000, -0.171922),(-0.453504, 0.000000, -0.187275),(-0.495405, 0.000000, -0.171922),(-0.453504, 0.000000, -0.274721),(-0.521948, -0.000000, -0.290074),(0.409200, 0.000000, -0.037746),(0.477645, 0.000000, 0.127137),(0.409200, -0.000000, -0.125191),(0.409200, -0.000000, -0.125191),(0.477645, 0.000000, 0.127137),(0.409200, 0.000000, -0.187275),(0.409200, 0.000000, -0.037746),(0.409200, 0.000000, 0.024338),(0.477645, 0.000000, 0.127137),(0.409200, 0.000000, -0.187275),(0.477645, 0.000000, 0.127137),(0.409200, -0.000000, -0.274721),(-0.318172, 0.000000, 0.329738),(-0.156019, 0.000000, 0.101415),(-0.318172, 0.000000, 0.008986),(-0.318172, 0.000000, 0.008986),(-0.156019, 0.000000, 0.101415),(-0.156019, 0.000000, 0.005060),(0.477645, 0.000000, 0.127137),(0.409200, 0.000000, 0.261314),(0.477645, 0.000000, 0.329738),(0.409200, 0.000000, 0.111784),(0.477645, 0.000000, 0.127137),(0.409200, 0.000000, 0.024338),(0.409200, 0.000000, 0.111784),(0.409200, -0.000000, 0.173868),(0.477645, 0.000000, 0.127137),(-0.318172, 0.000000, 0.329738),(-0.153372, 0.000000, 0.107975),(-0.156019, 0.000000, 0.101415),(-0.318172, 0.000000, 0.329738),(-0.146304, 0.000000, 0.107669),(-0.153372, 0.000000, 0.107975),(0.409200, -0.000000, 0.173868),(0.409200, 0.000000, 0.261314),(0.477645, 0.000000, 0.127137),(0.477645, 0.000000, 0.329738),(0.321729, 0.000000, 0.261314),(-0.318172, 0.000000, 0.329738),(-0.318172, 0.000000, 0.329738),(0.321729, 0.000000, 0.261314),(-0.146304, 0.000000, 0.107669),(0.070346, 0.000000, 0.009137),(0.321729, 0.000000, 0.111784),(0.075054, 0.000000, 0.005060),(0.075054, 0.000000, 0.005060),(0.321729, 0.000000, 0.111784),(0.321729, 0.000000, 0.024338),(0.321729, 0.000000, 0.111784),(0.070346, 0.000000, 0.009137),(0.321729, -0.000000, 0.173868),(0.321729, -0.000000, 0.173868),(0.070346, 0.000000, 0.009137),(0.321729, 0.000000, 0.261314),(0.070346, 0.000000, 0.009137),(-0.146304, 0.000000, 0.107669),(0.321729, 0.000000, 0.261314),)"
  },
  {
    "path": "addons/io_hubs_addon/components/operators.py",
    "content": "import bpy\nfrom bpy.props import StringProperty, IntProperty, BoolProperty, CollectionProperty\nfrom bpy.types import Operator, PropertyGroup\nfrom functools import reduce\n\nfrom .types import PanelType, MigrationType\nfrom .utils import get_object_source, has_component, add_component, remove_component, wrap_text, display_wrapped_text, is_dep_required, update_image_editors\nfrom .components_registry import get_components_registry, get_component_by_name\nfrom ..preferences import get_addon_pref\nfrom .handlers import migrate_components\nfrom .gizmos import update_gizmos\nfrom .utils import is_linked, redraw_component_ui\nfrom ..icons import get_hubs_icons\nimport os\n\n\nclass AddHubsComponent(Operator):\n    bl_idname = \"wm.add_hubs_component\"\n    bl_label = \"Add Hubs Component\"\n    bl_property = \"component_name\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    panel_type: StringProperty(name=\"panel_type\")\n    component_name: StringProperty(name=\"component_name\")\n\n    @classmethod\n    def poll(cls, context):\n        if hasattr(context, \"panel\"):\n            panel = getattr(context, 'panel')\n            panel_type = PanelType(panel.bl_context)\n            if panel_type == PanelType.SCENE:\n                if is_linked(context.scene):\n                    if bpy.app.version >= (3, 0, 0):\n                        cls.poll_message_set(\n                            \"Cannot add components to linked scenes\")\n                    return False\n            elif panel_type == PanelType.OBJECT:\n                if is_linked(context.active_object):\n                    if bpy.app.version >= (3, 0, 0):\n                        cls.poll_message_set(\n                            \"Cannot add components to linked objects\")\n                    return False\n            elif panel_type == PanelType.MATERIAL:\n                if is_linked(context.active_object.active_material):\n                    if bpy.app.version >= (3, 0, 0):\n                        cls.poll_message_set(\n                            \"Cannot add components to linked materials\")\n                    return False\n            elif panel_type == PanelType.BONE:\n                if is_linked(context.active_bone):\n                    if bpy.app.version >= (3, 0, 0):\n                        cls.poll_message_set(\n                            \"Cannot add components to linked bones\")\n                    return False\n\n        return True\n\n    def execute(self, context):\n        if self.component_name == '':\n            return\n\n        obj = get_object_source(context, self.panel_type)\n        add_component(obj, self.component_name)\n\n        # Redraw panel and trigger depsgraph update\n        context.area.tag_redraw()\n        context.window_manager.update_tag()\n        return {'FINISHED'}\n\n    def invoke(self, context, event):\n        panel_type = self.panel_type\n\n        # Filter components that are not targeted to this object type or their poll method call returns False\n        def filter_source_type(cmp):\n            (_, component_class) = cmp\n            host = get_object_source(context, panel_type)\n            return not component_class.is_dep_only() and PanelType(panel_type) in component_class.get_panel_type() and component_class.poll(PanelType(panel_type), host, ob=context.object)\n\n        components_registry = get_components_registry()\n        hubs_icons = get_hubs_icons()\n        filtered_components = dict(\n            filter(filter_source_type, components_registry.items()))\n\n        def sort_by_category(acc, cmp):\n            (_, component_class) = cmp\n            category = component_class.get_category_name()\n            acc[category] = acc.get(category, [])\n            acc[category].append(cmp)\n            return acc\n\n        components_by_category = reduce(\n            sort_by_category, filtered_components.items(), {})\n        obj = get_object_source(context, panel_type)\n\n        def draw(self, context):\n            added_comps = 0\n            row_length = get_addon_pref(context).row_length\n            row = self.layout.row()\n\n            column_sorted_category_components = {}\n            row_max_cmp_len = {}\n\n            # sort components categories alphabetically and into columns and record the length of\n            # the longest category per row.  Number of columns == row_length\n            for cat_idx, category_cmps in enumerate(sorted(components_by_category.items())):\n                # add a tuple of the categories and components to the proper column index based on row length\n                try:\n                    column_sorted_category_components[cat_idx % row_length].append(\n                        category_cmps)\n                except KeyError:\n                    column_sorted_category_components[cat_idx % row_length] = [\n                        category_cmps]\n                # if the row length is zero, then just add a column for each category\n                except ZeroDivisionError:\n                    column_sorted_category_components[cat_idx] = [\n                        category_cmps]\n\n                # get the number of components in this category\n                cmp_len = len(category_cmps[1])\n\n                # get which row we're on\n                try:\n                    row_idx = len(\n                        column_sorted_category_components[cat_idx % row_length]) - 1\n                except ZeroDivisionError:\n                    row_idx = len(\n                        column_sorted_category_components[cat_idx]) - 1\n\n                # update the maximum number of components in a category for this row\n                try:\n                    row_max_cmp_len[row_idx] = cmp_len if cmp_len > row_max_cmp_len[row_idx] else row_max_cmp_len[row_idx]\n                except KeyError:\n                    row_max_cmp_len[row_idx] = cmp_len\n\n            # loop through the columns\n            for column_idx, category_cmps in column_sorted_category_components.items():\n                column = row.column()\n\n                # loop through and add the categories for this column\n                for cat_idx, (category, cmps) in enumerate(category_cmps):\n                    column.label(text=category)\n                    column.separator()\n\n                    # loop through and add the components in this category\n                    cmp_idx = 0\n                    for (component_name, component_class) in cmps:\n                        if component_class.is_dep_only():\n                            continue\n\n                        cmp_idx += 1\n                        component_name = component_class.get_name()\n                        component_display_name = component_class.get_display_name()\n\n                        op = None\n                        if component_class.get_icon() is not None:\n                            icon = component_class.get_icon()\n                            if icon.find('.') != -1:\n                                if has_component(obj, component_name):\n                                    op = column.label(\n                                        text=component_display_name, icon_value=hubs_icons[icon].icon_id)\n                                else:\n                                    op = column.operator(\n                                        AddHubsComponent.bl_idname, text=component_display_name,\n                                        icon_value=hubs_icons[icon].icon_id)\n                                    op.component_name = component_name\n                                    op.panel_type = panel_type\n                            else:\n                                if has_component(obj, component_name):\n                                    op = column.label(\n                                        text=component_display_name, icon=icon)\n                                else:\n                                    op = column.operator(\n                                        AddHubsComponent.bl_idname, text=component_display_name, icon=icon)\n                                    op.component_name = component_name\n                                    op.panel_type = panel_type\n                        else:\n                            if has_component(obj, component_name):\n                                op = column.label(text=component_display_name)\n                            else:\n                                op = column.operator(\n                                    AddHubsComponent.bl_idname, text=component_display_name, icon='ADD')\n                                op.component_name = component_name\n                                op.panel_type = panel_type\n\n                        added_comps += 1\n\n                    # add blank space padding to category so it will take up the same space as the category with the most components in that row (keeps rows aligned)\n                    while cmp_idx < row_max_cmp_len[cat_idx] and cat_idx + 1 < len(category_cmps):\n                        column.label(text=\"\")\n                        cmp_idx += 1\n\n                    # add blank space between rows, but not after final row\n                    if cat_idx + 1 < len(column_sorted_category_components[column_idx]):\n                        column.label(text=\"\")\n\n            if added_comps == 0:\n                column = row.column()\n                column.label(\n                    text=\"No components available for this object type\")\n\n        bpy.context.window_manager.popup_menu(draw)\n\n        return {'FINISHED'}\n\n\nclass RemoveHubsComponent(Operator):\n    bl_idname = \"wm.remove_hubs_component\"\n    bl_label = \"Remove Hubs Component\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    panel_type: StringProperty(name=\"panel_type\")\n    component_name: StringProperty(name=\"component_name\")\n\n    @classmethod\n    def poll(cls, context):\n        if hasattr(context, \"panel\"):\n            panel = getattr(context, 'panel')\n            panel_type = PanelType(panel.bl_context)\n            if panel_type == PanelType.SCENE:\n                if is_linked(context.scene):\n                    if bpy.app.version >= (3, 0, 0):\n                        cls.poll_message_set(\n                            \"Cannot remove components from linked scenes\")\n                    return False\n            elif panel_type == PanelType.OBJECT:\n                if is_linked(context.active_object):\n                    if bpy.app.version >= (3, 0, 0):\n                        cls.poll_message_set(\n                            \"Cannot remove components from linked objects\")\n                    return False\n            elif panel_type == PanelType.MATERIAL:\n                if is_linked(context.active_object.active_material):\n                    if bpy.app.version >= (3, 0, 0):\n                        cls.poll_message_set(\n                            \"Cannot remove components from linked materials\")\n                    return False\n            elif panel_type == PanelType.BONE:\n                if is_linked(context.active_bone):\n                    if bpy.app.version >= (3, 0, 0):\n                        cls.poll_message_set(\n                            \"Cannot add components to linked bones\")\n                    return False\n\n        return True\n\n    def execute(self, context):\n        if self.component_name == '':\n            return\n        obj = get_object_source(context, self.panel_type)\n        remove_component(obj, self.component_name)\n\n        # Redraw panel and trigger depsgraph update\n        context.area.tag_redraw()\n        context.window_manager.update_tag()\n        return {'FINISHED'}\n\n\nclass MigrateHubsComponents(Operator):\n    bl_idname = \"wm.migrate_hubs_components\"\n    bl_label = \"Migrate Hubs Components\"\n    bl_description = \"Loops through all objects/components and attempts to migrate them to the current version based on their internal version\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    # For some reason using a default value with this property doesn't work properly, so the value must be manually specified each time.\n    is_registration: BoolProperty(options={'HIDDEN'})\n\n    def execute(self, context):\n        if self.is_registration:\n            migrate_components(MigrationType.REGISTRATION,\n                               do_beta_versioning=True)\n        else:\n            migrate_components(MigrationType.LOCAL, do_beta_versioning=True)\n\n        return {'FINISHED'}\n\n\nclass UpdateHubsGizmos(Operator):\n    bl_idname = \"wm.update_hubs_gizmos\"\n    bl_label = \"Refresh Hubs Gizmos\"\n    bl_description = \"Force a re-evaluation of all objects/components and update their gizmos\"\n\n    def execute(self, context):\n        update_gizmos()\n        return {'FINISHED'}\n\n\nclass ViewLastReport(Operator):\n    bl_idname = \"wm.hubs_view_last_report\"\n    bl_label = \"View Last Hubs Report\"\n    bl_description = \"Show the latest Hubs report in the Hubs Report Viewer\"\n\n    @classmethod\n    def poll(cls, context):\n        wm = context.window_manager\n        return wm.hubs_report_last_title and wm.hubs_report_last_report_string\n\n    def execute(self, context):\n        wm = context.window_manager\n        title = wm.hubs_report_last_title\n        report_string = wm.hubs_report_last_report_string\n        bpy.ops.wm.hubs_report_viewer(\n            'INVOKE_DEFAULT', title=title, report_string=report_string)\n        return {'FINISHED'}\n\n\nclass ViewReportInInfoEditor(Operator):\n    bl_idname = \"wm.hubs_view_report_in_info_editor\"\n    bl_label = \"View Report in the Info Editor\"\n    bl_description = \"Save the Hubs report to the Info Editor and open it for viewing\"\n\n    title: StringProperty(default=\"\")\n    report_string: StringProperty()\n\n    def highlight_info_report(self):\n        context_override = bpy.context.copy()\n        for window in bpy.context.window_manager.windows:\n            for area in window.screen.areas:\n                if area.type == 'INFO':\n                    for region in area.regions:\n                        if region.type == 'WINDOW':\n                            context_override['area'] = area\n                            context_override['region'] = region\n                            # Find and select the last info message for each Info editor.\n                            index = 0\n                            while bpy.ops.info.select_pick(\n                                    context_override, report_index=index, extend=False) != {'CANCELLED'}:\n                                index += 1\n                            bpy.ops.info.select_pick(\n                                context_override, report_index=index, extend=False)\n\n    def execute(self, context):\n        messages = split_and_prefix_report_messages(self.report_string)\n        info_report_string = '\\n'.join(\n            [message.replace('\\n', '  ') for message in messages])\n        self.report(\n            {'INFO'}, f\"Hubs {self.title}\\n{info_report_string}\\nEnd of Hubs {self.title}\")\n        bpy.ops.screen.info_log_show()\n        bpy.app.timers.register(self.highlight_info_report)\n        return {'FINISHED'}\n\n\nclass ReportScroller(Operator):\n    bl_idname = \"wm.hubs_report_scroller\"\n    bl_label = \"Hubs Report Scroller\"\n\n    increment: IntProperty()\n    maximum: IntProperty()\n\n    @classmethod\n    def description(self, context, properties):\n        if properties.increment == -1:\n            return \"Scroll up one line.\\nShift+Click to scroll to the beginning\"\n        if properties.increment == 1:\n            return \"Scroll down one line.\\nShift+Click to scroll to the end\"\n\n    def invoke(self, context, event):\n        wm = context.window_manager\n\n        if event.shift:  # Jump to beginning/end\n            if self.increment == -1:\n                wm.hubs_report_scroll_index = 0\n                wm.hubs_report_scroll_percentage = 0\n                return {'FINISHED'}\n            else:  # 1\n                wm.hubs_report_scroll_index = self.maximum\n                wm.hubs_report_scroll_percentage = 100\n                return {'FINISHED'}\n\n        else:  # Increment/Decrement\n            current_scroll_index = wm.hubs_report_scroll_index\n            if current_scroll_index + self.increment < 0:\n                return {'CANCELLED'}\n            elif current_scroll_index + self.increment > self.maximum:\n                return {'CANCELLED'}\n            else:\n                wm.hubs_report_scroll_index += self.increment\n                current_scroll_index = wm.hubs_report_scroll_index\n                wm.hubs_report_scroll_percentage = current_scroll_index * 100 // self.maximum\n                return {'FINISHED'}\n\n\nclass ReportViewer(Operator):\n    bl_idname = \"wm.hubs_report_viewer\"\n    bl_label = \"Hubs Report Viewer\"\n\n    title: StringProperty(default=\"\")\n    report_string: StringProperty()\n\n    def draw(self, context):\n        layout = self.layout\n\n        layout.label(text=self.title)\n\n        row = layout.row()\n        column = row.column()\n        box = column.box()\n\n        wm = context.window_manager\n        report_length = len(self.messages)\n        maximum_scrolling = len(self.report_display_blocks) - 1\n        start_index = wm.hubs_report_scroll_index\n        block_messages = self.report_display_blocks[start_index]\n\n        displayed_lines = 0\n        message_column = box.column()\n        for message in block_messages:\n            display_wrapped_text(message_column, message, heading_icon='INFO')\n            displayed_lines += len(message)\n\n        # Add padding to the bottom of the report if needed (accounts for the formatting changes when there are only a few messages in the report).\n        while displayed_lines < self.lines_to_show:\n            display_wrapped_text(message_column, [\"\"])\n            displayed_lines += 1\n\n        scroll_column = row.column()\n        scroll_column.enabled = report_length > len(block_messages)\n\n        scroll_up = scroll_column.row()\n        scroll_up.enabled = start_index > 0\n        op = scroll_up.operator(ReportScroller.bl_idname,\n                                text=\"\", icon=\"TRIA_UP\")\n        op.increment = -1\n        op.maximum = maximum_scrolling\n\n        scroll_down = scroll_column.row()\n        scroll_down.enabled = start_index < maximum_scrolling\n        op = scroll_down.operator(\n            ReportScroller.bl_idname, text=\"\", icon=\"TRIA_DOWN\")\n        op.increment = 1\n        op.maximum = maximum_scrolling\n\n        total_messages = column.row()\n        total_messages.alignment = 'RIGHT'\n        total_messages.label(text=f\"{report_length} Messages\")\n\n        scroll_percentage = column.row()\n        scroll_percentage.enabled = False\n        scroll_percentage.prop(\n            wm, \"hubs_report_scroll_percentage\", slider=True)\n\n        layout.separator()\n\n        op = layout.operator(ViewReportInInfoEditor.bl_idname)\n        op.title = self.title\n        op.report_string = self.report_string\n\n    def execute(self, context):\n        return {'FINISHED'}\n\n    def init_report_display_blocks(self):\n        start_index = 0\n        self.report_display_blocks = {}\n\n        final_block = False\n        while start_index < len(self.messages) and not final_block:\n            block_messages = []\n            for message in self.messages[start_index:]:\n                wrapped_message = wrap_text(message, max_length=90)\n                block_messages.append(wrapped_message)\n\n            last_message = None\n            while True:\n                if len(block_messages) == 1:\n                    break\n\n                if len(block_messages) > self.messages_to_show:\n                    last_message = block_messages.pop()\n                elif sum([len(message) + 1 for message in block_messages]) - 1 > self.lines_to_show:\n                    # The +1 and -1 are used to account for padding lines between messages.\n                    last_message = block_messages.pop()\n                else:\n                    break\n\n            if last_message is None:\n                final_block = True\n\n            current_block_lines = sum([len(message)\n                                      for message in block_messages])\n            needed_padding_lines = self.lines_to_show - current_block_lines\n\n            message_iter = iter(block_messages)\n            while needed_padding_lines > 0:\n                try:\n                    next(message_iter).append(\"\")\n                except StopIteration:\n                    if len(self.messages) < 4:\n                        # Evenly spacing the messages doesn't look good if there are only a few messages in the report, so let any extra padding be added to the end when it's displayed.\n                        break\n\n                    message_iter = reversed(block_messages)\n                    next(message_iter).append(\"\")\n\n                needed_padding_lines += -1\n\n            self.report_display_blocks[start_index] = block_messages\n            start_index += 1\n\n    def invoke(self, context, event):\n        wm = context.window_manager\n        self.messages = split_and_prefix_report_messages(self.report_string)\n        self.lines_to_show = 15\n        self.messages_to_show = 5\n        wm.hubs_report_scroll_index = 0\n        wm.hubs_report_scroll_percentage = 0\n        wm.hubs_report_last_title = self.title\n        wm.hubs_report_last_report_string = self.report_string\n        self.init_report_display_blocks()\n        return wm.invoke_props_dialog(self, width=600)\n\n\ndef split_and_prefix_report_messages(report_string):\n    return [f\"{i + 1:02d}   {message}\" for i, message in enumerate(report_string.split(\"\\n\\n\"))]\n\n\nclass CopyHubsComponent(Operator):\n    bl_idname = \"wm.copy_hubs_component\"\n    bl_label = \"Copy component from active object\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    panel_type: StringProperty(name=\"panel_type\")\n    component_name: StringProperty(name=\"component_name\")\n\n    @classmethod\n    def poll(cls, context):\n        if is_linked(context.scene):\n            if bpy.app.version >= (3, 0, 0):\n                cls.poll_message_set(\n                    \"Cannot copy components when in linked scenes\")\n            return False\n\n        if hasattr(context, \"panel\"):\n            panel = getattr(context, 'panel')\n            panel_type = PanelType(panel.bl_context)\n            return panel_type != PanelType.SCENE\n\n        return True\n\n    def get_selected_bones(self, context):\n        selected_bones = context.selected_pose_bones if context.mode == \"POSE\" else context.selected_editable_bones\n        selected_armatures = [\n            sel_ob for sel_ob in context.selected_objects if sel_ob.type == \"ARMATURE\"]\n        selected_hosts = []\n        for armature in selected_armatures:\n            armature_bones = armature.pose.bones if context.mode == \"POSE\" else armature.data.edit_bones\n            target_armature_bones = armature.data.bones if context.mode == \"POSE\" else armature.data.edit_bones\n            target_bones = [\n                bone for bone in armature_bones if bone in selected_bones]\n            for target_bone in target_bones:\n                selected_hosts.extend(\n                    [bone for bone in target_armature_bones if target_bone.name == bone.name])\n        return selected_hosts\n\n    def get_selected_hosts(self, context):\n        selected_hosts = []\n        for host in context.selected_objects:\n            if host.type == \"ARMATURE\" and context.mode != \"OBJECT\":\n                selected_hosts.extend(self.get_selected_bones(context))\n            else:\n                selected_hosts.append(host)\n\n        return selected_hosts\n\n    def execute(self, context):\n        src_host = None\n        selected_hosts = []\n        if self.panel_type == PanelType.OBJECT.value:\n            src_host = context.active_object\n            selected_hosts = self.get_selected_hosts(context)\n        elif self.panel_type == PanelType.BONE.value:\n            src_host = context.active_bone\n            selected_hosts = self.get_selected_hosts(context)\n        elif self.panel_type == PanelType.MATERIAL.value:\n            src_host = context.active_object.active_material\n            selected_hosts = [\n                ob.active_material for ob in context.selected_objects\n                if ob.active_material and ob.active_material is not None and ob.active_material is not src_host]\n\n        component_class = get_component_by_name(self.component_name)\n        component_id = component_class.get_id()\n        for dest_host in selected_hosts:\n            if is_linked(dest_host):\n                continue\n\n            if component_class.is_dep_only():\n                if not is_dep_required(dest_host, None, self.component_name):\n                    continue\n\n            if not has_component(dest_host, self.component_name):\n                add_component(dest_host, self.component_name)\n\n            for key, value in getattr(src_host, component_id).items():\n                getattr(dest_host, component_id)[key] = value\n\n            deps_names = component_class.get_deps()\n            for dep_name in deps_names:\n                dep_class = get_component_by_name(dep_name)\n                dep_id = dep_class.get_id()\n                for key, value in getattr(src_host, dep_id).items():\n                    getattr(dest_host, dep_id)[key] = value\n\n        return {'FINISHED'}\n\n\nclass OpenImage(Operator):\n    bl_idname = \"image.hubs_open_image\"\n    bl_label = \"Open Image\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    directory: StringProperty()\n    filepath: StringProperty(subtype=\"FILE_PATH\")\n    files: CollectionProperty(type=PropertyGroup)\n    filter_folder: BoolProperty(default=True, options={\"HIDDEN\"})\n    filter_image: BoolProperty(default=True, options={\"HIDDEN\"})\n    target_property: StringProperty(options={\"HIDDEN\"})\n\n    relative_path: BoolProperty(\n        name=\"Relative Path\", description=\"Select the file relative to the blend file\", default=True)\n\n    disabled_message = \"Can't open/assign images to linked data blocks. Please make it local first\"\n\n    @classmethod\n    def description(cls, context, properties):\n        description_text = \"Load an external image \"\n        if bpy.app.version < (3, 0, 0) and is_linked(context.host):\n            description_text += f\"\\nDisabled: {cls.disabled_message}\"\n\n        return description_text\n\n    @classmethod\n    def poll(cls, context):\n        if hasattr(context, \"host\"):\n            if is_linked(context.host):\n                if bpy.app.version >= (3, 0, 0):\n                    cls.poll_message_set(f\"{cls.disabled_message}.\")\n                return False\n\n        return True\n\n    def execute(self, context):\n        if not self.files[0].name:\n            self.report({'INFO'}, \"Open image cancelled. No image selected.\")\n            return {'CANCELLED'}\n\n        old_img = getattr(self.target, self.target_property)\n\n        # Load/Reload the first image and assign it to the target property, then load the rest of the images if they're not already loaded. This mimics Blender's default open files behavior.\n        # self.files is sorted alphabetically by Blender, self.files[0] is the 1. of the selection in alphabetical order\n        primary_filepath = os.path.join(self.directory, self.files[0].name)\n        primary_img = bpy.data.images.load(\n            filepath=primary_filepath, check_existing=True)\n        primary_img.reload()\n        setattr(self.target, self.target_property, primary_img)\n\n        for f in self.files[1:]:\n            bpy.data.images.load(filepath=os.path.join(\n                self.directory, f.name), check_existing=True)\n\n        update_image_editors(old_img, primary_img)\n        redraw_component_ui(context)\n        return {'FINISHED'}\n\n    def invoke(self, context, event):\n        self.target = context.target\n\n        last_image = getattr(self.target, self.target_property)\n        if type(last_image) is bpy.types.Image:  # if the component has been assigned before, get its filepath\n            self.filepath = last_image.filepath  # start the file browser at the location of the previous file\n\n        context.window_manager.fileselect_add(self)\n        return {'RUNNING_MODAL'}\n\n\ndef register():\n    bpy.utils.register_class(AddHubsComponent)\n    bpy.utils.register_class(RemoveHubsComponent)\n    bpy.utils.register_class(MigrateHubsComponents)\n    bpy.utils.register_class(UpdateHubsGizmos)\n    bpy.utils.register_class(ReportViewer)\n    bpy.utils.register_class(ReportScroller)\n    bpy.utils.register_class(ViewLastReport)\n    bpy.utils.register_class(ViewReportInInfoEditor)\n    bpy.utils.register_class(CopyHubsComponent)\n    bpy.utils.register_class(OpenImage)\n    bpy.types.WindowManager.hubs_report_scroll_index = IntProperty(\n        default=0, min=0)\n    bpy.types.WindowManager.hubs_report_scroll_percentage = IntProperty(\n        name=\"Scroll Position\", default=0, min=0, max=100, subtype='PERCENTAGE')\n    bpy.types.WindowManager.hubs_report_last_title = StringProperty()\n    bpy.types.WindowManager.hubs_report_last_report_string = StringProperty()\n\n\ndef unregister():\n    bpy.utils.unregister_class(AddHubsComponent)\n    bpy.utils.unregister_class(RemoveHubsComponent)\n    bpy.utils.unregister_class(MigrateHubsComponents)\n    bpy.utils.unregister_class(UpdateHubsGizmos)\n    bpy.utils.unregister_class(ReportViewer)\n    bpy.utils.unregister_class(ReportScroller)\n    bpy.utils.unregister_class(ViewLastReport)\n    bpy.utils.unregister_class(ViewReportInInfoEditor)\n    bpy.utils.unregister_class(CopyHubsComponent)\n    bpy.utils.unregister_class(OpenImage)\n    del bpy.types.WindowManager.hubs_report_scroll_index\n    del bpy.types.WindowManager.hubs_report_scroll_percentage\n    del bpy.types.WindowManager.hubs_report_last_title\n    del bpy.types.WindowManager.hubs_report_last_report_string\n"
  },
  {
    "path": "addons/io_hubs_addon/components/types.py",
    "content": "from enum import Enum\n\n\nclass PanelType(Enum):\n    OBJECT = 'object'\n    SCENE = 'scene'\n    MATERIAL = 'material'\n    BONE = 'bone'\n\n\nclass NodeType(Enum):\n    NODE = 'object'\n    SCENE = 'scene'\n    MATERIAL = 'material'\n\n\nclass Category(Enum):\n    OBJECT = 'Object'\n    SCENE = 'Scene'\n    ELEMENTS = 'Elements'\n    ANIMATION = 'Animation'\n    AVATAR = 'Avatar'\n    MISC = 'Misc'\n    LIGHTS = 'Lights'\n    MEDIA = 'Media'\n    USER = 'User'\n\n\nclass MigrationType(Enum):\n    GLOBAL = 'global'\n    LOCAL = 'local'\n    REGISTRATION = 'registration'\n"
  },
  {
    "path": "addons/io_hubs_addon/components/ui.py",
    "content": "import bpy\nfrom bpy.props import StringProperty\nfrom .types import PanelType\nfrom .components_registry import get_component_by_name, get_components_registry\nfrom .utils import get_object_source, is_linked\n\n\ndef draw_component_global(panel, context):\n    layout = panel.layout\n    components_registry = get_components_registry()\n    for _, component_class in components_registry.items():\n        component_class.draw_global(context, layout, panel)\n\n\ndef draw_component(panel, context, obj, row, component_item):\n    component_name = component_item.name\n    component_class = get_component_by_name(component_name)\n    if component_class:\n        panel_type = PanelType(panel.bl_context)\n        if panel_type not in component_class.get_panel_type() or not component_class.poll(panel_type, obj, ob=context.object):\n            col = row.box().column()\n            top_row = col.row()\n            top_row.label(\n                text=f\"Unsupported host for component '{component_class.get_display_name()}'\", icon=\"ERROR\")\n            remove_component_operator = top_row.operator(\n                \"wm.remove_hubs_component\",\n                text=\"\",\n                icon=\"X\"\n            )\n            remove_component_operator.component_name = component_name\n            remove_component_operator.panel_type = panel.bl_context\n            return\n\n        component_id = component_class.get_id()\n        component = getattr(obj, component_id)\n\n        has_properties = len(component_class.get_properties()) > 0\n\n        col = row.box().column()\n        top_row = col.row()\n\n        if has_properties:\n            top_row.prop(component_item, \"expanded\",\n                         icon=\"TRIA_DOWN\" if component_item.expanded else \"TRIA_RIGHT\",\n                         icon_only=True, emboss=False\n                         )\n\n        display_name = component_class.get_display_name()\n\n        top_row.label(text=display_name)\n\n        if has_properties or not component_class.is_dep_only():\n            top_row.context_pointer_set(\"panel\", panel)\n            copy_component_operator = top_row.operator(\n                \"wm.copy_hubs_component\",\n                text=\"\",\n                icon=\"PASTEDOWN\"\n            )\n            copy_component_operator.component_name = component_name\n            copy_component_operator.panel_type = panel.bl_context\n\n        if not (component_class.is_dep_only() or component_item.isDependency):\n            top_row.context_pointer_set(\"panel\", panel)\n            remove_component_operator = top_row.operator(\n                \"wm.remove_hubs_component\",\n                text=\"\",\n                icon=\"X\"\n            )\n            remove_component_operator.component_name = component_name\n            remove_component_operator.panel_type = panel.bl_context\n\n        body_col = col.column()\n        body_col.enabled = not is_linked(obj)\n        if component_item.expanded:\n            component.draw(context, body_col, panel)\n\n    else:\n        col = row.box().column()\n        top_row = col.row()\n        top_row.label(\n            text=f\"Unknown component '{component_name}'\", icon=\"ERROR\")\n        top_row.context_pointer_set(\"panel\", panel)\n        remove_component_operator = top_row.operator(\n            \"wm.remove_hubs_component\",\n            text=\"\",\n            icon=\"X\"\n        )\n        remove_component_operator.component_name = component_name\n        remove_component_operator.panel_type = panel.bl_context\n\n\ndef draw_components_list(panel, context):\n    layout = panel.layout\n\n    obj = get_object_source(context, panel.bl_context)\n\n    if not obj:\n        return\n\n    layout.context_pointer_set(\"panel\", panel)\n    add_component_operator = layout.operator(\n        \"wm.add_hubs_component\",\n        text=\"Add Component\",\n        icon=\"ADD\"\n    )\n    add_component_operator.panel_type = panel.bl_context\n\n    for component_item in obj.hubs_component_list.items:\n        row = layout.row()\n        draw_component(panel, context, obj, row, component_item)\n\n    layout.separator()\n\n\ndef add_link_indicator(layout, datablock):\n    if datablock.library:\n        library = datablock.library\n        icon = 'LINKED'\n    else:\n        library = datablock.override_library.reference.library\n        icon = 'LIBRARY_DATA_OVERRIDE'\n\n    tooltip = (\n        f\"{datablock.name}\\n\"\n        f\"\\n\"\n        f\"Source Library:\\n\"\n        f\"[{library.name}]\\n\"\n        f\"{library.filepath}\"\n    )\n    layout.operator(\"ui.hubs_tooltip_label\", text='',\n                    icon=icon).tooltip = tooltip\n\n\nclass HubsObjectPanel(bpy.types.Panel):\n    bl_label = \"Hubs\"\n    bl_idname = \"OBJECT_PT_hubs\"\n    bl_space_type = 'PROPERTIES'\n    bl_region_type = 'WINDOW'\n    bl_context = \"object\"\n\n    def draw(self, context):\n        draw_components_list(self, context)\n\n\nclass HUBS_PT_ToolsPanel(bpy.types.Panel):\n    bl_idname = \"HUBS_PT_ToolsPanel\"\n    bl_space_type = 'VIEW_3D'\n    bl_region_type = 'UI'\n    bl_label = \"Hubs\"\n    bl_category = \"Hubs\"\n    bl_context = 'objectmode'\n\n    def draw(self, context):\n        pass\n\n\nclass HubsScenePanel(bpy.types.Panel):\n    bl_label = 'Hubs'\n    bl_idname = \"SCENE_PT_hubs\"\n    bl_space_type = 'PROPERTIES'\n    bl_region_type = 'WINDOW'\n    bl_context = 'scene'\n\n    def draw(self, context):\n        draw_component_global(self, context)\n        layout = self.layout\n        layout.separator()\n        draw_components_list(self, context)\n\n\nclass HubsMaterialPanel(bpy.types.Panel):\n    bl_label = 'Hubs'\n    bl_idname = \"MATERIAL_PT_hubs\"\n    bl_space_type = 'PROPERTIES'\n    bl_region_type = 'WINDOW'\n    bl_context = 'material'\n\n    def draw(self, context):\n        draw_components_list(self, context)\n\n\nclass HubsBonePanel(bpy.types.Panel):\n    bl_label = \"Hubs\"\n    bl_idname = \"BONE_PT_hubs\"\n    bl_space_type = 'PROPERTIES'\n    bl_region_type = 'WINDOW'\n    bl_context = \"bone\"\n\n    def draw(self, context):\n        draw_components_list(self, context)\n\n\nclass TooltipLabel(bpy.types.Operator):\n    bl_idname = \"ui.hubs_tooltip_label\"\n    bl_label = \"---\"\n\n    tooltip: StringProperty(default=\" \")\n\n    @classmethod\n    def description(cls, context, properties):\n        return properties.tooltip\n\n    def execute(self, context):\n        return {'CANCELLED'}\n\n\ndef window_menu_addition(self, context):\n    layout = self.layout\n    layout.separator()\n    layout.operator(\"wm.hubs_view_last_report\")\n\n\ndef object_menu_addition(self, context):\n    layout = self.layout\n    layout.separator()\n    op = layout.operator(\"wm.migrate_hubs_components\")\n    op.is_registration = False\n\n\ndef gizmo_display_popover_addition(self, context):\n    layout = self.layout\n    layout.separator()\n    layout.operator(\"wm.update_hubs_gizmos\")\n\n\ndef register():\n    bpy.utils.register_class(HubsObjectPanel)\n    bpy.utils.register_class(HubsScenePanel)\n    bpy.utils.register_class(HubsMaterialPanel)\n    bpy.utils.register_class(HubsBonePanel)\n    bpy.utils.register_class(TooltipLabel)\n    bpy.utils.register_class(HUBS_PT_ToolsPanel)\n\n    bpy.types.TOPBAR_MT_window.append(window_menu_addition)\n    bpy.types.VIEW3D_MT_object.append(object_menu_addition)\n    bpy.types.VIEW3D_PT_gizmo_display.append(gizmo_display_popover_addition)\n\n\ndef unregister():\n    bpy.utils.unregister_class(HubsObjectPanel)\n    bpy.utils.unregister_class(HubsScenePanel)\n    bpy.utils.unregister_class(HubsMaterialPanel)\n    bpy.utils.unregister_class(HubsBonePanel)\n    bpy.utils.unregister_class(TooltipLabel)\n    bpy.utils.unregister_class(HUBS_PT_ToolsPanel)\n\n    bpy.types.TOPBAR_MT_window.remove(window_menu_addition)\n    bpy.types.VIEW3D_MT_object.remove(object_menu_addition)\n    bpy.types.VIEW3D_PT_gizmo_display.remove(gizmo_display_popover_addition)\n"
  },
  {
    "path": "addons/io_hubs_addon/components/utils.py",
    "content": "import tempfile\nimport bpy\nfrom .components_registry import get_component_by_name, get_components_registry\nfrom .gizmos import update_gizmos\nfrom .types import PanelType\nfrom mathutils import Vector\nfrom contextlib import contextmanager\nimport os\nimport sys\nimport platform\nimport ctypes\nimport ctypes.util\n\nV_S1 = Vector((1.0, 1.0, 1.0))\n\n\ndef add_component(obj, component_name):\n    component_item = obj.hubs_component_list.items.add()\n    component_item.name = component_name\n\n    component_class = get_component_by_name(component_name)\n    if component_class:\n        if 'create_gizmo' in component_class.__dict__:\n            update_gizmos()\n        component_class.init_instance_version(obj)\n        for dep_name in component_class.get_deps():\n            dep_class = get_component_by_name(dep_name)\n            if dep_class:\n                dep_exists = obj.hubs_component_list.items.find(dep_name) > -1\n                if not dep_exists:\n                    add_component(obj, dep_name)\n            else:\n                print(\"Dependency '%s' from module '%s' not registered\" %\n                      (dep_name, component_name))\n        component_class.init(obj)\n\n\ndef remove_component(obj, component_name):\n    component_items = obj.hubs_component_list.items\n    component_items.remove(component_items.find(component_name))\n    component_class = get_component_by_name(component_name)\n\n    component_class = get_component_by_name(component_name)\n    if component_class:\n        obj.property_unset(component_class.get_id())\n        if 'create_gizmo' in component_class.__dict__:\n            update_gizmos()\n        for dep_name in component_class.get_deps():\n            dep_class = get_component_by_name(dep_name)\n            dep_name = dep_class.get_name()\n            if dep_class:\n                if not is_dep_required(obj, component_name, dep_name):\n                    remove_component(obj, dep_name)\n            else:\n                print(\"Dependecy '%s' from module '%s' not registered\" %\n                      (dep_name, component_name))\n\n\ndef get_objects_with_component(component_name):\n    return [ob for ob in bpy.context.view_layer.objects if has_component(ob, component_name)]\n\n\ndef has_component(obj, component_name):\n    component_items = obj.hubs_component_list.items\n    return component_name in component_items\n\n\ndef has_components(obj, component_names):\n    component_items = obj.hubs_component_list.items\n    for name in component_names:\n        if name not in component_items:\n            return False\n    return True\n\n\ndef is_dep_required(obj, component_name, dep_name):\n    '''Checks if there is any other component that requires this dependency'''\n    is_required = False\n    items = obj.hubs_component_list.items\n    for cmp in items:\n        if cmp.name != component_name:\n            dep_component_class = get_component_by_name(\n                cmp.name)\n            if dep_name in dep_component_class.get_deps():\n                is_required = True\n                break\n    return is_required\n\n\ndef get_object_source(context, panel_type):\n    if panel_type == \"material\":\n        return context.material\n    elif panel_type == \"bone\":\n        return context.bone or context.edit_bone\n    elif panel_type == \"scene\":\n        return context.scene\n    else:\n        return context.object\n\n\ndef children_recurse(ob, result):\n    for child in ob.children:\n        result.append(child)\n        children_recurse(child, result)\n\n\ndef children_recursive(ob):\n    if bpy.app.version < (3, 1, 0):\n        ret = []\n        children_recurse(ob, ret)\n        return ret\n    else:\n        return ob.children_recursive\n\n\ndef is_gpu_available(context):\n    cycles_addon = context.preferences.addons[\"cycles\"]\n    return cycles_addon and cycles_addon.preferences.has_active_device()\n\n\ndef redraw_component_ui(context):\n    for window in context.window_manager.windows:\n        for area in window.screen.areas:\n            if area.type == 'PROPERTIES':\n                area.tag_redraw()\n\n\ndef is_linked(datablock):\n    if not datablock:\n        return False\n    return bool(datablock.id_data.library or datablock.id_data.override_library)\n\n\ndef update_image_editors(old_img, img):\n    for window in bpy.context.window_manager.windows:\n        for area in window.screen.areas:\n            if area.type == 'IMAGE_EDITOR':\n                if area.spaces.active.image == old_img:\n                    area.spaces.active.image = img\n\n# Note: Set up stuff specifically for C FILE pointers so that they aren't truncated to 32 bits on 64 bit systems.\n\n\nclass _FILE(ctypes.Structure):\n    \"\"\"opaque C FILE type\"\"\"\n\n\nif platform.system() == \"Windows\":\n    try:\n        # Get stdio from the CRT Blender's using (currently ships with Blender)\n        libc = ctypes.windll.LoadLibrary('api-ms-win-crt-stdio-l1-1-0')\n\n        try:  # Attempt to set up flushing for the C stdout.\n            libc.__acrt_iob_func.restype = ctypes.POINTER(_FILE)\n            stdout = libc.__acrt_iob_func(1)\n\n            def c_fflush():\n                try:\n                    libc.fflush(stdout)\n                except BaseException as e:\n                    print(\"Error: Unable to flush the C stdout\")\n\n        except BaseException as e:  # Fall back to flushing all open output streams.\n            print(\"Warning: Couldn't get the C stdout\")\n\n            def c_fflush():\n                try:\n                    libc.fflush(None)\n                except BaseException as e:\n                    print(\"Error: Unable to flush the C stdout\")\n\n    # Warn and fail gracefully.  Flushing the C stdout is required because Windows switches to full buffering when redirected.\n    except BaseException as e:\n        print(\"Error: Unable to find the C runtime.\")\n\n        def c_fflush():\n            print(\"Error: Unable to flush the C stdout\")\n\n\nelse:  # Linux/Mac\n    try:  # get the C runtime\n        libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))\n\n        try:  # Attempt to set up flushing for the C stdout.\n            if platform.system() == \"Linux\":\n                c_stdout = ctypes.POINTER(_FILE).in_dll(libc, 'stdout')\n            else:  # Mac\n                c_stdout = ctypes.POINTER(_FILE).in_dll(libc, '__stdoutp')\n\n            def c_fflush():\n                try:\n                    libc.fflush(c_stdout)\n                except BaseException as e:\n                    print(\"Warning: Unable to flush the C stdout.\")\n\n        # The C stdout wasn't found.  This is unlikely to happen, but if it does then just skip flushing since Linux/Mac doesn't seem to strictly require a C-level flush to work.\n        except BaseException as e:\n            print(\"Warning: Couldn't get the C stdout.\")\n\n            def c_fflush():\n                pass\n\n    # The C runtime wasn't found.  This is unlikely to happen, but if it does then just skip flushing since Linux/Mac doesn't seem to strictly require a C-level flush to work.\n    except BaseException as e:\n        print(\"Warning: Unable to find the C runtime.\")\n\n        def c_fflush():\n            pass\n\n\n@contextmanager\ndef redirect_c_stdout(binary_stream):\n    stdout_file_descriptor = sys.stdout.fileno()\n    original_stdout_file_descriptor_copy = os.dup(stdout_file_descriptor)\n    try:\n        # Flush the C-level buffer of stdout before redirecting.  This should make sure that only the desired data is captured.\n        c_fflush()\n        #  Move the file pointer to the start of the file\n        __stack_tmp_file.seek(0)\n        # Redirect stdout to your pipe.\n        os.dup2(__stack_tmp_file.fileno(), stdout_file_descriptor)\n        yield  # wait for input\n    finally:\n        # Flush the C-level buffer of stdout before returning things to normal.  This seems to be mainly needed on Windows because it looks like Windows changes the buffering policy to be fully buffered when redirecting stdout.\n        c_fflush()\n        # Redirect stdout back to the original file descriptor.\n        os.dup2(original_stdout_file_descriptor_copy, stdout_file_descriptor)\n        # Truncate file to the written amount of bytes\n        __stack_tmp_file.truncate()\n        #  Move the file pointer to the start of the file\n        __stack_tmp_file.seek(0)\n        # Write back to the input stream\n        binary_stream.write(__stack_tmp_file.read())\n        # Close the remaining open file descriptor.\n        os.close(original_stdout_file_descriptor_copy)\n\n\ndef get_host_components(host):\n    # Note: this used to be a generator but we detected some issues in Mac so we reverted to returning an array.\n    components = []\n    for component_item in host.hubs_component_list.items:\n        component_name = component_item.name\n        component_class = get_component_by_name(component_name)\n        if not component_class:\n            continue\n\n        component = getattr(host, component_class.get_id())\n        components.append(component)\n    return components\n\n\ndef wrap_text(text, max_length=70):\n    '''Wraps text in a string so that the total characters in a single line doesn't exceed the specified maximum length.  Lines are broken by word, and the increased width of capital letters is accounted for so that the displayed line length is roughly the same regardless of case.  The maximum length is based on lowercase characters.'''\n    wrapped_lines = []\n\n    for section in text.split('\\n'):\n        text_line = ''\n        line_length = 0\n        words = section.split(' ')\n\n        for word in words:\n            word_length = 0\n            for char in word:\n                word_length += 1\n                if char.isupper():\n                    word_length += 0.25\n\n            if line_length + word_length < max_length:\n                text_line += word + ' '\n                line_length += word_length + 1\n\n            else:\n                wrapped_lines.append(text_line.rstrip())\n                text_line = word + ' '\n                line_length = word_length + 1\n\n        if text_line.rstrip():\n            wrapped_lines.append(text_line.rstrip())\n\n    return wrapped_lines\n\n\ndef display_wrapped_text(layout, wrapped_text, *, heading_icon='NONE'):\n    if not wrapped_text:\n        return\n\n    padding_icon = 'NONE' if heading_icon == 'NONE' else 'BLANK1'\n    text_column = layout.column()\n    text_column.scale_y = 0.7\n    for i, line in enumerate(wrapped_text):\n        if i == 0:\n            text_column.label(text=line, icon=heading_icon)\n        else:\n            text_column.label(text=line, icon=padding_icon)\n\n\ndef get_host_reference_message(panel_type, host, ob=None):\n    '''The ob argument is used for bone hosts and is the armature object, but will fall back to the armature if the armature object isn't available.'''\n    if panel_type == PanelType.BONE:\n        ob_type = \"armature\" if type(ob) is bpy.types.Armature else \"object\"\n        host_reference = f\"\\\"{host.name}\\\" in {ob_type} \\\"{ob.name_full}\\\"\"\n    else:\n        host_reference = f\"\\\"{host.name_full}\\\"\"\n\n    return host_reference\n\n\ndef get_host_or_parents_scaled(obj):\n    parents = [obj]\n    while parents:\n        parent = parents.pop()\n        if parent.scale != V_S1:\n            return True\n\n        if parent.parent:\n            parents.insert(0, parent.parent)\n\n        if hasattr(parent, 'parent_bone') and parent.parent_bone:\n            parents.insert(0, parent.parent.pose.bones[parent.parent_bone])\n\n    return False\n\n\n__stack_tmp_file = None\n\n\ndef register():\n    global __stack_tmp_file\n    __stack_tmp_file = tempfile.NamedTemporaryFile(\n        mode='w+b', buffering=0, delete=False, dir=bpy.app.tempdir)\n\n\ndef unregister():\n    __stack_tmp_file.close()\n    os.unlink(__stack_tmp_file.name)\n"
  },
  {
    "path": "addons/io_hubs_addon/debugger.py",
    "content": "from bpy.app.handlers import persistent\nimport bpy\nfrom bpy.types import Context\n\nfrom .preferences import EXPORT_TMP_FILE_NAME, EXPORT_TMP_SCREENSHOT_FILE_NAME\nfrom .utils import is_module_available, save_prefs, find_area, image_type_to_file_ext\nfrom .icons import get_hubs_icons\nfrom .hubs_session import HubsSession, PARAMS_TO_STRING\nfrom . import api\nfrom bpy.types import AnyType\n\nDEMO_SERVER_URL = \"\"\nROOM_FLAGS_DOC_URL = \"https://github.com/Hubs-Foundation/hubs-docs/blob/master/docs/hubs-query-string-parameters.md\"\n\n\ndef export_scene(context):\n    export_prefs = context.scene.hubs_scene_debugger_room_export_prefs\n    import os\n    extension = '.glb'\n    args = {\n        # Settings from \"Remember Export Settings\"\n        **dict(bpy.context.scene.get('glTF2ExportSettings', {})),\n\n        'export_format': ('GLB' if extension == '.glb' else 'GLTF_SEPARATE'),\n        'filepath': os.path.join(bpy.app.tempdir, EXPORT_TMP_FILE_NAME),\n        'export_cameras': export_prefs.export_cameras,\n        'export_lights': export_prefs.export_lights,\n        'use_selection': export_prefs.use_selection,\n        'use_visible': export_prefs.use_visible,\n        'use_renderable': export_prefs.use_renderable,\n        'use_active_collection': export_prefs.use_active_collection,\n        'export_apply': export_prefs.export_apply,\n        'export_force_sampling': False,\n    }\n    if bpy.app.version >= (3, 2, 0):\n        args['use_active_scene'] = True\n\n    bpy.ops.export_scene.gltf(**args)\n\n\nhubs_session = None\n\n\ndef is_instance_set(context):\n    prefs = context.window_manager.hubs_scene_debugger_prefs\n    return prefs.hubs_instance_idx != -1\n\n\ndef is_room_set(context):\n    prefs = context.window_manager.hubs_scene_debugger_prefs\n    return prefs.hubs_room_idx != -1\n\n\nclass HubsUpdateRoomOperator(bpy.types.Operator):\n    bl_idname = \"hubs_scene.update_room\"\n    bl_label = \"View Scene\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def description(cls, context, properties):\n        is_scene_update = context.scene.hubs_scene_debugger_room_create_prefs.debugLocalScene\n        if hubs_session.is_alive():\n            room_params = hubs_session.room_params\n            is_scene_update = \"debugLocalScene\" in room_params\n\n        if is_scene_update:\n            return \"Updates the currently opened room scene with the Blender scene\"\n        else:\n            return \"Spawns the Blender scene in the currently opened room as an object\"\n\n    @classmethod\n    def poll(cls, context: Context):\n        return hubs_session and hubs_session.user_logged_in and hubs_session.user_in_room\n\n    def execute(self, context):\n        try:\n            selected_obs = bpy.context.selected_objects\n            active_ob = bpy.context.active_object\n\n            viewpoint = None\n            if context.scene.hubs_scene_debugger_room_export_prefs.avatar_to_viewport:\n                area = find_area(\"VIEW_3D\")\n                if area is not None:\n                    r3d = area.spaces[0].region_3d\n                    view_mat = r3d.view_matrix.inverted()\n                    loc, rot, _ = view_mat.decompose()\n                    from mathutils import Matrix, Vector, Euler\n                    from math import radians\n                    final_loc = loc + Vector((0, 0, -1.6))\n                    rot_offset = Matrix.Rotation(radians(180), 4, 'Z').to_4x4()\n                    final_rot = rot.to_matrix().to_4x4() @ rot_offset\n                    euler = final_rot.to_euler()\n                    euler.x = 0\n                    euler.y = 0\n\n                    bpy.ops.object.empty_add(location=final_loc, rotation=(euler.x, euler.y, euler.z), type=\"ARROWS\")\n                    viewpoint = bpy.context.object\n                    viewpoint.name = \"__scene_debugger_viewpoint\"\n                    from .components.utils import add_component\n                    add_component(viewpoint, \"waypoint\")\n\n                    for ob in selected_obs:\n                        ob.select_set(True)\n                    context.view_layer.objects.active = active_ob\n\n            export_scene(context)\n\n            hubs_session.update()\n            hubs_session.bring_to_front(context)\n\n            if viewpoint:\n                hubs_session.move_to_waypoint(\"__scene_debugger_viewpoint\")\n                ob = bpy.context.scene.objects[\"__scene_debugger_viewpoint\"]\n                if ob:\n                    bpy.data.objects.remove(ob, do_unlink=True)\n\n            for ob in selected_obs:\n                ob.select_set(True)\n            context.view_layer.objects.active = active_ob\n\n            return {'FINISHED'}\n        except Exception as err:\n            print(err)\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\", report_string='\\n\\n'.join(\n                [\"The scene export has failed\", \"Check the export logs or quit the browser instance and try again\", f'{err}']))\n\n            if viewpoint:\n                ob = bpy.context.scene.objects[\"__scene_debugger_viewpoint\"]\n                if ob:\n                    bpy.data.objects.remove(ob, do_unlink=True)\n\n            return {'CANCELLED'}\n\n\nclass HubsCreateRoomOperator(bpy.types.Operator):\n    bl_idname = \"hubs_scene.create_room\"\n    bl_label = \"Create a new room\"\n    bl_description = \"Creates a new room in the selected instance and opens it in the browser selected in the add-on preferences. The specified room flags will be applied\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context: Context):\n        return is_instance_set(context)\n\n    def execute(self, context):\n        try:\n            was_alive = hubs_session.init(context)\n\n            prefs = context.window_manager.hubs_scene_debugger_prefs\n            hubs_instance_url = prefs.hubs_instances[prefs.hubs_instance_idx].url\n            hubs_session.load(\n                f'{hubs_instance_url}?new&{hubs_session.url_params_string_from_prefs(context)}')\n\n            if was_alive:\n                hubs_session.bring_to_front(context)\n\n            return {'FINISHED'}\n\n        except Exception as err:\n            hubs_session.close()\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string=f'The room creation has failed: {err}')\n            return {\"CANCELLED\"}\n\n\nclass HubsOpenRoomOperator(bpy.types.Operator):\n    bl_idname = \"hubs_scene.open_room\"\n    bl_label = \"Open selected room\"\n    bl_description = \"Opens the selected room in the browser selected in the add-on preferences. The specified room flags will be applied\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context: Context):\n        return is_room_set(context)\n\n    def execute(self, context):\n        try:\n            was_alive = hubs_session.init(context)\n\n            prefs = context.window_manager.hubs_scene_debugger_prefs\n            room_url = prefs.hubs_rooms[prefs.hubs_room_idx].url\n\n            params = hubs_session.url_params_string_from_prefs(context)\n            if params:\n                if \"?\" in room_url:\n                    hubs_session.load(f'{room_url}&{params}')\n                else:\n                    hubs_session.load(f'{room_url}?{params}')\n            else:\n                hubs_session.load(room_url)\n\n            if was_alive:\n                hubs_session.bring_to_front(context)\n\n            return {'FINISHED'}\n\n        except Exception as err:\n            hubs_session.close()\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string=f'An error happened while opening the room: {err}')\n            return {\"CANCELLED\"}\n\n\nclass HubsCloseRoomOperator(bpy.types.Operator):\n    bl_idname = \"hubs_scene.close_room\"\n    bl_label = \"Close\"\n    bl_description = \"Close session\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context: Context):\n        return hubs_session.is_alive()\n\n    def execute(self, context):\n        try:\n            hubs_session.close()\n            return {'FINISHED'}\n\n        except Exception as err:\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string=f'An error happened while closing the browser window: {err}')\n            return {\"CANCELLED\"}\n\n\nclass HubsOpenAddonPrefsOperator(bpy.types.Operator):\n    bl_idname = \"hubs_scene.open_addon_prefs\"\n    bl_label = \"Open Preferences\"\n    bl_description = \"Open Preferences\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context: Context):\n        return not hubs_session.is_alive()\n\n    def execute(self, context):\n        bpy.ops.screen.userpref_show('INVOKE_DEFAULT')\n        context.preferences.active_section\n        bpy.ops.preferences.addon_expand(module=__package__)\n        bpy.ops.preferences.addon_show(module=__package__)\n        return {'FINISHED'}\n\n\nclass HUBS_PT_ToolsSceneDebuggerCreatePanel(bpy.types.Panel):\n    bl_idname = \"HUBS_PT_ToolsSceneDebuggerCreatePanel\"\n    bl_space_type = 'VIEW_3D'\n    bl_region_type = 'UI'\n    bl_label = \"Create Room\"\n    bl_context = 'objectmode'\n    bl_parent_id = \"HUBS_PT_ToolsSceneDebuggerPanel\"\n\n    @classmethod\n    def poll(cls, context: Context):\n        return is_module_available(\"selenium\")\n\n    def draw(self, context: Context):\n        prefs = context.window_manager.hubs_scene_debugger_prefs\n        box = self.layout.box()\n        row = box.row()\n        row.label(text=\"Instances:\")\n        row = box.row()\n        list_row = row.row()\n        list_row.template_list(HUBS_UL_ToolsSceneDebuggerServers.bl_idname, \"\", prefs,\n                               \"hubs_instances\", prefs, \"hubs_instance_idx\", rows=3)\n        col = row.column()\n        col.operator(HubsSceneDebuggerInstanceAdd.bl_idname,\n                     icon='ADD', text=\"\")\n        col.operator(HubsSceneDebuggerInstanceRemove.bl_idname,\n                     icon='REMOVE', text=\"\")\n\n        row = box.row()\n        row.operator(HubsCreateRoomOperator.bl_idname)\n\n\nclass HUBS_PT_ToolsSceneDebuggerOpenPanel(bpy.types.Panel):\n    bl_idname = \"HUBS_PT_ToolsSceneDebuggerOpenPanel\"\n    bl_space_type = 'VIEW_3D'\n    bl_region_type = 'UI'\n    bl_label = \"Open Room\"\n    bl_context = 'objectmode'\n    bl_parent_id = \"HUBS_PT_ToolsSceneDebuggerPanel\"\n\n    @classmethod\n    def poll(cls, context: Context):\n        return is_module_available(\"selenium\")\n\n    def draw(self, context: Context):\n        box = self.layout.box()\n        prefs = context.window_manager.hubs_scene_debugger_prefs\n        row = box.row()\n        row.label(text=\"Rooms:\")\n        row = box.row()\n        list_row = row.row()\n        list_row.template_list(HUBS_UL_ToolsSceneDebuggerRooms.bl_idname, \"\", prefs,\n                               \"hubs_rooms\", prefs, \"hubs_room_idx\", rows=3)\n        col = row.column()\n        op = col.operator(HubsSceneDebuggerRoomAdd.bl_idname,\n                          icon='ADD', text=\"\")\n        op.url = DEMO_SERVER_URL\n        col.operator(HubsSceneDebuggerRoomRemove.bl_idname,\n                     icon='REMOVE', text=\"\")\n\n        row = box.row()\n        row.operator(HubsOpenRoomOperator.bl_idname)\n\n\nclass HUBS_PT_ToolsSceneDebuggerUpdatePanel(bpy.types.Panel):\n    bl_idname = \"HUBS_PT_ToolsSceneDebuggerUpdatePanel\"\n    bl_space_type = 'VIEW_3D'\n    bl_region_type = 'UI'\n    bl_label = \"Update Room Scene\"\n    bl_context = 'objectmode'\n    bl_parent_id = \"HUBS_PT_ToolsSceneDebuggerPanel\"\n\n    @classmethod\n    def poll(cls, context: Context):\n        return is_module_available(\"selenium\")\n\n    def draw(self, context: Context):\n        box = self.layout.box()\n        row = box.row()\n        row.label(\n            text=\"Set the default export options in the glTF export panel\")\n        row = box.row()\n        col = row.column(heading=\"Limit To:\")\n        col.use_property_split = True\n        col.prop(context.scene.hubs_scene_debugger_room_export_prefs,\n                 \"use_selection\")\n        col.prop(context.scene.hubs_scene_debugger_room_export_prefs,\n                 \"use_visible\")\n        col.prop(context.scene.hubs_scene_debugger_room_export_prefs,\n                 \"use_renderable\")\n        col.prop(context.scene.hubs_scene_debugger_room_export_prefs,\n                 \"use_active_collection\")\n        if bpy.app.version >= (3, 2, 0):\n            col_row = col.row()\n            col_row.enabled = False\n            col_row.prop(context.scene.hubs_scene_debugger_room_export_prefs,\n                         \"use_active_scene\")\n        row = box.row()\n        col = row.column(heading=\"Data:\")\n        col.use_property_split = True\n        col.prop(context.scene.hubs_scene_debugger_room_export_prefs,\n                 \"export_cameras\")\n        col.prop(context.scene.hubs_scene_debugger_room_export_prefs,\n                 \"export_lights\")\n        row = box.row()\n        col = row.column(heading=\"Mesh:\")\n        col.use_property_split = True\n        col.prop(context.scene.hubs_scene_debugger_room_export_prefs,\n                 \"export_apply\")\n\n        row = box.row()\n        col = row.column(heading=\"Animation:\")\n        col.use_property_split = True\n        col_row = col.row()\n        col_row.enabled = False\n        col_row.prop(context.scene.hubs_scene_debugger_room_export_prefs,\n                     \"export_force_sampling\")\n\n        row = box.row()\n        if not hubs_session.is_alive() or not hubs_session.user_logged_in:\n            row = box.row()\n            row.alert = True\n            row.label(\n                text=\"You need to be signed in to Hubs to update the room scene\")\n\n        update_mode = \"Update current scene\" if context.scene.hubs_scene_debugger_room_create_prefs.debugLocalScene else \"Spawn as object\"\n        if hubs_session.is_alive():\n            room_params = hubs_session.room_params\n            update_mode = \"Update current scene\" if \"debugLocalScene\" in room_params else \"Spawn as object\"\n        row = box.row()\n        row.operator(HubsUpdateRoomOperator.bl_idname,\n                     text=f'{update_mode}')\n\n        row = box.row()\n        row.prop(context.scene.hubs_scene_debugger_room_export_prefs, \"avatar_to_viewport\")\n        if \"debugLocalScene\" not in hubs_session.room_params:\n            row.enabled = False\n\n\nclass HUBS_PT_ToolsSceneSessionPanel(bpy.types.Panel):\n    bl_idname = \"HUBS_PT_ToolsSceneSessionPanel\"\n    bl_space_type = 'VIEW_3D'\n    bl_region_type = 'UI'\n    bl_label = \"Status\"\n    bl_context = 'objectmode'\n    bl_parent_id = \"HUBS_PT_ToolsPanel\"\n\n    def draw(self, context):\n        main_box = self.layout.box()\n\n        if is_module_available(\"selenium\"):\n            row = main_box.row(align=True)\n            row.alignment = \"CENTER\"\n            col = row.column()\n            col.alignment = \"LEFT\"\n            col.label(text=\"Connection Status:\")\n            hubs_icons = get_hubs_icons()\n            if hubs_session.is_alive():\n                if hubs_session.user_logged_in:\n                    if hubs_session.user_in_room:\n                        col = row.column()\n                        col.alignment = \"LEFT\"\n                        col.active_default = True\n                        col.label(\n                            icon_value=hubs_icons[\"green-dot.png\"].icon_id)\n                        row = main_box.row(align=True)\n                        row.alignment = \"CENTER\"\n                        row.label(text=f'In room: {hubs_session.room_name}')\n\n                    else:\n                        col = row.column()\n                        col.alignment = \"LEFT\"\n                        col.label(\n                            icon_value=hubs_icons[\"orange-dot.png\"].icon_id)\n                        row = main_box.row(align=True)\n                        row.alignment = \"CENTER\"\n                        row.label(text=\"Entering the room...\")\n                else:\n                    col = row.column()\n                    col.alignment = \"LEFT\"\n                    col.alert = True\n                    col.label(icon_value=hubs_icons[\"orange-dot.png\"].icon_id)\n                    row = main_box.row(align=True)\n                    row.alignment = \"CENTER\"\n                    row.label(text=\"Waiting for session sign in...\")\n\n                ret_instance = hubs_session.reticulum_url\n                if ret_instance:\n                    row = main_box.row(align=True)\n                    row.alignment = \"CENTER\"\n                    row.label(\n                        text=f'Connected to Instance: {ret_instance}')\n\n            else:\n                col = row.column()\n                col.alignment = \"LEFT\"\n                col.alert = True\n                col.label(icon_value=hubs_icons[\"red-dot.png\"].icon_id)\n                row = main_box.row(align=True)\n                row.alignment = \"CENTER\"\n                row.label(text=\"Waiting for session...\")\n\n            row = self.layout.row()\n            row.operator(HubsCloseRoomOperator.bl_idname, text='Close')\n\n        else:\n            row = main_box.row()\n            row.alert = True\n            row.label(\n                text=\"Selenium needs to be installed for the scene debugger functionality. Install from preferences.\")\n            row = main_box.row()\n            row.operator(HubsOpenAddonPrefsOperator.bl_idname,\n                         text='Setup')\n\n\nclass HUBS_PT_ToolsSceneDebuggerPanel(bpy.types.Panel):\n    bl_idname = \"HUBS_PT_ToolsSceneDebuggerPanel\"\n    bl_space_type = 'VIEW_3D'\n    bl_region_type = 'UI'\n    bl_label = \"Debug\"\n    bl_context = 'objectmode'\n    bl_parent_id = \"HUBS_PT_ToolsPanel\"\n\n    @classmethod\n    def poll(cls, context: Context):\n        return is_module_available(\"selenium\")\n\n    def draw(self, context):\n        params_icons = {}\n        if hubs_session.is_alive():\n            for key in PARAMS_TO_STRING.keys():\n                params_icons[key] = 'PANEL_CLOSE'\n\n            for param in hubs_session.room_params:\n                if param in params_icons:\n                    params_icons[param] = 'CHECKMARK'\n        else:\n            for key in PARAMS_TO_STRING.keys():\n                params_icons[key] = 'REMOVE'\n\n        box = self.layout.box()\n        row = box.row(align=True)\n        row.alignment = \"EXPAND\"\n        grid = row.grid_flow(columns=2, align=True,\n                             even_rows=False, even_columns=False)\n        grid.alignment = \"CENTER\"\n        flags_row = grid.row()\n        flags_row.label(text=\"Room flags\")\n        op = flags_row.operator(\"wm.url_open\", text=\"\", icon=\"HELP\")\n        op.url = ROOM_FLAGS_DOC_URL\n        for key in PARAMS_TO_STRING.keys():\n            grid.prop(context.scene.hubs_scene_debugger_room_create_prefs,\n                      key)\n        grid.label(text=\"Is Active?\")\n        for key in PARAMS_TO_STRING.keys():\n            grid.label(icon=params_icons[key])\n\n\ndef add_instance(context):\n    prefs = context.window_manager.hubs_scene_debugger_prefs\n    new_instance = prefs.hubs_instances.add()\n    new_instance.name = \"Demo Hub\"\n    new_instance.url = DEMO_SERVER_URL\n    prefs.hubs_instance_idx = len(\n        prefs.hubs_instances) - 1\n\n    save_prefs(context)\n\n\nclass HubsSceneDebuggerInstanceAdd(bpy.types.Operator):\n    bl_idname = \"hubs_scene.scene_debugger_instance_add\"\n    bl_label = \"Add Server Instance\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    def execute(self, context):\n        add_instance(context)\n\n        return {'FINISHED'}\n\n\nclass HubsSceneDebuggerInstanceRemove(bpy.types.Operator):\n    bl_idname = \"hubs_scene.scene_debugger_instance_remove\"\n    bl_label = \"Remove Server Instance\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    def execute(self, context):\n        prefs = context.window_manager.hubs_scene_debugger_prefs\n        prefs.hubs_instances.remove(prefs.hubs_instance_idx)\n\n        if prefs.hubs_instance_idx >= len(prefs.hubs_instances):\n            prefs.hubs_instance_idx -= 1\n\n        save_prefs(context)\n\n        return {'FINISHED'}\n\n\nclass HubsSceneDebuggerRoomAdd(bpy.types.Operator):\n    bl_idname = \"hubs_scene.scene_debugger_room_add\"\n    bl_label = \"Add Room\"\n    bl_description = \"Adds the current active room url to the list, if there is no active room it will add an empty string\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    url: bpy.props.StringProperty(name=\"Room Url\")\n\n    def execute(self, context):\n        prefs = context.window_manager.hubs_scene_debugger_prefs\n        new_room = prefs.hubs_rooms.add()\n        url = self.url\n        if hubs_session.is_alive():\n            current_url = hubs_session.get_url()\n            if current_url:\n                url = current_url\n                if \"hub_id=\" in url:\n                    url = url.split(\"&\")[0]\n                else:\n                    url = url.split(\"?\")[0]\n\n        new_room.name = \"Room Name\"\n        if hubs_session.is_alive():\n            room_name = hubs_session.room_name\n            if room_name:\n                new_room.name = room_name\n        new_room.url = url\n        prefs.hubs_room_idx = len(\n            prefs.hubs_rooms) - 1\n\n        save_prefs(context)\n\n        return {'FINISHED'}\n\n\nclass HubsSceneDebuggerRoomRemove(bpy.types.Operator):\n    bl_idname = \"hubs_scene.scene_debugger_room_remove\"\n    bl_label = \"Remove Room\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context: Context):\n        prefs = context.window_manager.hubs_scene_debugger_prefs\n        return prefs.hubs_room_idx >= 0\n\n    def execute(self, context):\n        prefs = context.window_manager.hubs_scene_debugger_prefs\n        prefs.hubs_rooms.remove(prefs.hubs_room_idx)\n\n        if prefs.hubs_room_idx >= len(prefs.hubs_rooms):\n            prefs.hubs_room_idx -= 1\n\n        save_prefs(context)\n\n        return {'FINISHED'}\n\n\nclass HUBS_UL_ToolsSceneDebuggerServers(bpy.types.UIList):\n    bl_idname = \"HUBS_UL_ToolsSceneDebuggerServers\"\n    bl_label = \"Instances\"\n\n    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):\n        split = layout.split(factor=0.25)\n        split.prop(item, \"name\", text=\"\", emboss=False)\n        split.prop(item, \"url\", text=\"\", emboss=False)\n\n\nclass HUBS_UL_ToolsSceneDebuggerRooms(bpy.types.UIList):\n    bl_idname = \"HUBS_UL_ToolsSceneDebuggerRooms\"\n    bl_label = \"Rooms\"\n\n    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):\n        split = layout.split(factor=0.25)\n        split.prop(item, \"name\", text=\"\", emboss=False)\n        split.prop(item, \"url\", text=\"\", emboss=False)\n\n\nclass HubsPublishSceneOperator(bpy.types.Operator):\n    bl_idname = \"hubs_scene.publish_scene\"\n    bl_label = \"Publish\"\n    bl_description = \"Publish current Blender scene\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context: Context):\n        props = context.scene.hubs_scene_debugger_scene_publish_props\n        return hubs_session.is_alive() and hubs_session.user_logged_in and props.screenshot and props.scene_name\n\n    def execute(self, context):\n        try:\n            export_scene(context)\n            import os\n            url = hubs_session.reticulum_url\n\n            scene_data = {}\n\n            name = context.scene.hubs_scene_debugger_scene_publish_props.scene_name\n            scene_data.update({\"name\": name})\n\n            glb_path = os.path.join(bpy.app.tempdir, EXPORT_TMP_FILE_NAME)\n            glb = open(glb_path, \"rb\")\n            glb_data = api.upload_media(url, glb)\n            scene_data.update({\n                \"model_file_id\": glb_data[\"file_id\"],\n                \"model_file_token\": glb_data[\"access_token\"]\n            })\n\n            screenshot = context.scene.hubs_scene_debugger_scene_publish_props.screenshot\n            if screenshot.type in ['RENDER_RESULT', 'COMPOSITING'] or screenshot.packed_file:\n                screenshot_full = os.path.join(\n                    bpy.app.tempdir, EXPORT_TMP_SCREENSHOT_FILE_NAME +\n                    image_type_to_file_ext(screenshot.file_format))\n                screenshot.save_render(screenshot_full)\n            else:\n                screenshot_full = bpy.path.abspath(screenshot.filepath, library=screenshot.library)\n            screenshot_norm = os.path.normpath(screenshot_full)\n            screenshot_data = api.upload_media(\n                url, open(screenshot_norm, \"rb\"))\n            scene_data.update({\n                \"screenshot_file_id\": screenshot_data[\"file_id\"],\n                \"screenshot_file_token\": screenshot_data[\"access_token\"]\n            })\n\n            scene_data.update({\n                \"allow_remixing\": False,\n                \"allow_promotion\": False,\n                \"attributions\": {\n                    \"creator\": \"\",\n                    \"content\": []\n                }\n            })\n            api.publish_scene(url, hubs_session.get_token(), scene_data)\n\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string=f'Scene {name} successfully published')\n\n            bpy.ops.hubs_scene.get_scenes()\n\n            return {'FINISHED'}\n\n        except Exception as err:\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string=f'An error happened while publishing the scene: {err}')\n            return {\"CANCELLED\"}\n\n\nclass HubsUpdateSceneOperator(bpy.types.Operator):\n    bl_idname = \"hubs_scene.update_scene\"\n    bl_label = \"Update\"\n    bl_description = \"Updates the selected scene with the Blender scene\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context: Context):\n        return hubs_session.is_alive() and hubs_session.user_logged_in and context.window_manager.hubs_scene_debugger_scenes_props.scene_idx > -1\n\n    def execute(self, context):\n        try:\n            export_scene(context)\n            import os\n            url = hubs_session.reticulum_url\n\n            scenes = context.window_manager.hubs_scene_debugger_scenes_props\n            scene = scenes.scenes[scenes.scene_idx]\n\n            scene_data = {}\n\n            glb_path = os.path.join(bpy.app.tempdir, EXPORT_TMP_FILE_NAME)\n            glb = open(glb_path, \"rb\")\n            glb_data = api.upload_media(url, glb)\n            scene_data.update({\n                \"model_file_id\": glb_data[\"file_id\"],\n                \"model_file_token\": glb_data[\"access_token\"]\n            })\n            api.publish_scene(url, hubs_session.get_token(),\n                              scene_data, scene.scene_id)\n\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string=f'Scene {scene.name} successfully updated')\n\n            return {'FINISHED'}\n\n        except Exception as err:\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string=f'An error happened while updated the scene: {err}')\n            return {\"CANCELLED\"}\n\n    def invoke(self, context, event):\n        def draw(self, context):\n            row = self.layout.row()\n            row.label(\n                text=\"Are you sure that you want to overwrite the selected scene?\")\n            row = self.layout.row()\n            col = row.column()\n            col.operator(HubsUpdateSceneOperator.bl_idname, text=\"Yes\")\n\n        bpy.context.window_manager.popup_menu(draw)\n        return {'FINISHED'}\n\n\nclass HubsCreateRoomWithSceneOperator(bpy.types.Operator):\n    bl_idname = \"hubs_scene.create_room_with_scene\"\n    bl_label = \"Create Room\"\n    bl_description = \"Creates a new room in the selected instance and opens it in the browser selected in the add-on preferences. The currently selected scene from the scenes list will be used. The specified room flags will be applied\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context: Context):\n        return hubs_session.is_alive() and hubs_session.user_logged_in and context.window_manager.hubs_scene_debugger_scenes_props.scene_idx > -1\n\n    def execute(self, context):\n        try:\n            scenes_props = context.window_manager.hubs_scene_debugger_scenes_props\n            scene = scenes_props.scenes[scenes_props.scene_idx]\n\n            # Try to create a Hubs with credentials\n            response = api.create_room(\n                hubs_session.reticulum_url, token=hubs_session.get_token(),\n                scene_name=scene.name, scene_id=scene.scene_id)\n            if \"error\" in response:\n                hubs_session.set_credentials(None, None)\n\n                # Try to create a Hubs anonymously\n                response = api.create_room(\n                    hubs_session.reticulum_url, scene_name=scene.name, scene_id=scene.scene_id)\n                if \"error\" in response:\n                    raise Exception(response[\"error\"])\n\n            if \"creator_assignment_token\" in response:\n                embed_token = None\n                creator_token = response[\"creator_assignment_token\"]\n                if creator_token:\n                    if \"embed_token\" in response:\n                        embed_token = response[\"embed_token\"]\n                    hubs_session.set_creator_assignment_token(\n                        creator_token, embed_token)\n\n            was_alive = hubs_session.init(context)\n\n            params = hubs_session.url_params_string_from_prefs(context)\n            if hubs_session.is_local_instance():\n                from urllib.parse import urlparse\n                parsed = urlparse(hubs_session.client_url)\n                port = str(parsed.port)\n                url = f'{parsed.scheme}://{parsed.hostname}{\":\"+port if port else \"\"}/hub.html?hub_id={response[\"hub_id\"]}&{params}'\n            else:\n                url = f'{response[\"url\"]}?{params}'\n\n            hubs_session.load(url)\n\n            if was_alive:\n                hubs_session.bring_to_front(context)\n\n            return {'FINISHED'}\n\n        except Exception as err:\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string=f'An error happened while opening the scene: {err}')\n            return {\"CANCELLED\"}\n\n\nclass HubsGetScenesOperator(bpy.types.Operator):\n    bl_idname = \"hubs_scene.get_scenes\"\n    bl_label = \"Get Scenes\"\n    bl_description = \"Gets the scene list from your account\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context: Context):\n        return hubs_session.is_alive() and hubs_session.user_logged_in\n\n    def execute(self, context):\n        scenes_props = context.window_manager.hubs_scene_debugger_scenes_props\n        scenes_props.instance = hubs_session.reticulum_url\n        scenes_props.scenes.clear()\n        try:\n            url = hubs_session.reticulum_url\n            scenes = api.get_projects(url, hubs_session.get_token())\n\n            for scene in scenes:\n                new_scene = scenes_props.scenes.add()\n                new_scene[\"scene_id\"] = scene[\"scene_id\"]\n                new_scene[\"name\"] = scene[\"name\"]\n                new_scene[\"url\"] = scene[\"url\"]\n                new_scene[\"description\"] = scene[\"description\"]\n                new_scene[\"screenshot_url\"] = scene[\"screenshot_url\"]\n                scenes_props.scene_idx = len(scenes_props.scenes) - 1\n\n            if len(scenes_props.scenes) > 0:\n                scenes_props.scene_idx = 0\n\n            save_prefs(context)\n\n            return {'FINISHED'}\n\n        except Exception as err:\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string=f'An error happened while getting the scenes: {err}')\n            return {\"CANCELLED\"}\n\n\nclass HUBS_UL_ToolsSceneDebuggerProjects(bpy.types.UIList):\n    bl_idname = \"HUBS_UL_ToolsSceneDebuggerProjects\"\n    bl_label = \"Projects\"\n\n    def filter_items(self, context: Context, data: AnyType, property: str):\n        scene_props = context.window_manager.hubs_scene_debugger_scenes_props\n        items = getattr(data, property)\n        filtered = [self.bitflag_filter_item] * len(items)\n        ordered = [i for i, item in enumerate(items)]\n        ret_instance = hubs_session.reticulum_url if hubs_session.is_alive() else None\n        filter = not scene_props.instance or ret_instance != scene_props.instance\n        if filter:\n            for i, item in enumerate(items):\n                filtered[i] &= ~self.bitflag_filter_item\n\n        return filtered, ordered\n\n    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):\n        split = layout.split(factor=0.75)\n        split.prop(item, \"name\", text=\"\", emboss=False)\n        split.prop(item, \"scene_id\", text=\"\", emboss=False)\n\n\nclass HUBS_PT_ToolsSceneDebuggerPublishScenePanel(bpy.types.Panel):\n    bl_idname = \"HUBS_PT_ToolsSceneDebuggerPublishScenePanel\"\n    bl_space_type = 'VIEW_3D'\n    bl_region_type = 'UI'\n    bl_label = \"Publish\"\n    bl_context = 'objectmode'\n    bl_parent_id = \"HUBS_PT_ToolsPanel\"\n\n    @classmethod\n    def poll(cls, context: Context):\n        return is_module_available(\"selenium\")\n\n    def draw(self, context: Context):\n        if not hubs_session.is_alive() or not hubs_session.user_logged_in:\n            box = self.layout.box()\n            row = box.row()\n            row.alert = True\n            row.label(\n                text=\"You need to be signed in to Hubs to get, update or publish scenes\")\n            row = box.row()\n            row.alert = True\n            row.label(\n                text=\"Create or open a room to open a session\")\n\n        box = self.layout.box()\n        row = box.row()\n        row.label(text=\"Manage:\")\n        row = box.row()\n        list_row = row.row()\n        list_row.template_list(\n            HUBS_UL_ToolsSceneDebuggerProjects.bl_idname, \"\", context.window_manager.hubs_scene_debugger_scenes_props,\n            \"scenes\", context.window_manager.hubs_scene_debugger_scenes_props, \"scene_idx\", rows=3)\n\n        row = box.row()\n        col = row.column()\n        col.operator(HubsGetScenesOperator.bl_idname)\n        col = row.column()\n        col.operator(HubsUpdateSceneOperator.bl_idname)\n\n        row = box.row()\n        row = row.column()\n        row.operator(HubsCreateRoomWithSceneOperator.bl_idname)\n\n        box = self.layout.box()\n        row = box.row()\n        row.label(text=\"Publish:\")\n        row = box.row()\n        publish_props_box = row.box()\n        row = publish_props_box.row()\n        row.prop(context.scene.hubs_scene_debugger_scene_publish_props, \"scene_name\")\n        row = publish_props_box.row()\n        col = row.column()\n        col.prop(context.scene.hubs_scene_debugger_scene_publish_props, \"screenshot\")\n        col = row.column()\n        col.context_pointer_set(\n            \"target\", context.scene.hubs_scene_debugger_scene_publish_props)\n        col.context_pointer_set(\"host\", context.scene)\n        op = col.operator(\"image.hubs_open_image\", text='', icon='FILE_FOLDER')\n        op.target_property = \"screenshot\"\n        row = box.row()\n        op = row.operator(HubsPublishSceneOperator.bl_idname)\n\n\nclass HubsSceneDebuggerRoomCreatePrefs(bpy.types.PropertyGroup):\n    newLoader: bpy.props.BoolProperty(\n        name=PARAMS_TO_STRING[\"newLoader\"][\"name\"],\n        default=True, description=PARAMS_TO_STRING[\"newLoader\"][\"description\"])\n    ecsDebug: bpy.props.BoolProperty(\n        name=PARAMS_TO_STRING[\"ecsDebug\"][\"name\"],\n        default=True, description=PARAMS_TO_STRING[\"ecsDebug\"][\"description\"])\n    vr_entry_type: bpy.props.BoolProperty(\n        name=PARAMS_TO_STRING[\"vr_entry_type\"][\"name\"],\n        default=True, description=PARAMS_TO_STRING[\"vr_entry_type\"][\"description\"])\n    debugLocalScene: bpy.props.BoolProperty(name=PARAMS_TO_STRING[\"debugLocalScene\"][\"name\"], default=True,\n                                            description=PARAMS_TO_STRING[\"debugLocalScene\"][\"description\"])\n\n\nclass HubsSceneDebuggerRoomExportPrefs(bpy.types.PropertyGroup):\n    export_cameras: bpy.props.BoolProperty(name=\"Export Cameras\", default=False,\n                                           description=\"Export cameras\", options=set())\n    export_lights: bpy.props.BoolProperty(\n        name=\"Punctual Lights\", default=False,\n        description=\"Punctual Lights, Export directional, point, and spot lights. Uses \\\"KHR_lights_punctual\\\" glTF extension\",\n        options=set())\n    use_selection: bpy.props.BoolProperty(name=\"Selection Only\", default=False,\n                                          description=\"Selection Only, Export selected objects only.\",\n                                          options=set())\n    export_apply: bpy.props.BoolProperty(\n        name=\"Apply Modifiers\", default=True,\n        description=\"Apply Modifiers, Apply modifiers (excluding Armatures) to mesh objects -WARNING: prevents exporting shape keys.\",\n        options=set())\n    use_visible: bpy.props.BoolProperty(\n        name='Visible Objects',\n        description='Export visible objects only',\n        default=False,\n        options=set()\n    )\n\n    use_renderable: bpy.props.BoolProperty(\n        name='Renderable Objects',\n        description='Export renderable objects only',\n        default=False,\n        options=set()\n    )\n\n    use_active_collection: bpy.props.BoolProperty(\n        name='Active Collection',\n        description='Export objects in the active collection only',\n        default=False,\n        options=set()\n    )\n    use_active_scene: bpy.props.BoolProperty(\n        name='Active Scene',\n        description='Export objects in the active scene only.  This has been forced ON because Hubs can only use one scene anyway',\n        default=True, options=set())\n    export_force_sampling: bpy.props.BoolProperty(\n        name='Sampling Animations',\n        description='Apply sampling to all animations.  This has been forced OFF because it can break animations in Hubs',\n        default=False, options=set())\n    avatar_to_viewport: bpy.props.BoolProperty(\n        name='Spawn using viewport transform',\n        description='Spawn the avatar in the current viewport camera position/rotation',\n        default=False, options=set())\n\n\nclass HubsSceneProject(bpy.types.PropertyGroup):\n    scene_id: bpy.props.StringProperty(\n        name=\"Id\",\n        description=\"Scene id\",\n        default=\"Scene id\",\n        get=lambda self: self[\"scene_id\"]\n    )\n    name: bpy.props.StringProperty(\n        name=\"Name\",\n        description=\"Scene name\",\n        default=\"Scene name\",\n        get=lambda self: self[\"name\"]\n    )\n    description: bpy.props.StringProperty(\n        name=\"Description\",\n        description=\"Scene description\",\n        default=\"Scene description\",\n        get=lambda self: self[\"description\"]\n    )\n    url: bpy.props.StringProperty(\n        name=\"Scene URL\",\n        description=\"Scene URL\",\n        default=\"Scene URL\",\n        get=lambda self: self[\"url\"]\n    )\n    screenshot_url: bpy.props.StringProperty(\n        name=\"Screenshot URL\",\n        description=\"Scene URL\",\n        default=\"Scene URL\",\n        get=lambda self: self[\"screenshot_url\"]\n    )\n\n\nclass HubsSceneDebuggerScenePublishProps(bpy.types.PropertyGroup):\n    scene_name: bpy.props.StringProperty(\n        name=\"Name\",\n        description=\"Scene name\",\n        default=\"Scene name\"\n    )\n    screenshot: bpy.props.PointerProperty(\n        name=\"Screenshot\",\n        description=\"Scene screenshot\",\n        type=bpy.types.Image\n    )\n\n\ndef save_prefs_on_prop_update(self, context):\n    save_prefs(context)\n\n\nclass HubsSceneDebuggerScenes(bpy.types.PropertyGroup):\n    instance: bpy.props.StringProperty(\n        name=\"Instance\",\n        description=\"Instance URL\"\n    )\n    scenes: bpy.props.CollectionProperty(\n        type=HubsSceneProject)\n\n    scene_idx: bpy.props.IntProperty(\n        default=-1, update=save_prefs_on_prop_update)\n\n\ndef set_url(self, value):\n    try:\n        import urllib\n        parsed = urllib.parse.urlparse(value)\n        parsed = parsed._replace(scheme=\"https\")\n        self.url_ = urllib.parse.urlunparse(parsed)\n    except Exception:\n        self.url_ = DEMO_SERVER_URL\n\n\ndef get_url(self):\n    return self.url_\n\n\nclass HubsUrl(bpy.types.PropertyGroup):\n    name: bpy.props.StringProperty(update=save_prefs_on_prop_update)\n    url: bpy.props.StringProperty(\n        set=set_url, get=get_url, update=save_prefs_on_prop_update)\n    url_: bpy.props.StringProperty(options={\"HIDDEN\"})\n\n\nclass HubsSceneDebuggerPrefs(bpy.types.PropertyGroup):\n    hubs_instances: bpy.props.CollectionProperty(\n        type=HubsUrl)\n\n    hubs_instance_idx: bpy.props.IntProperty(\n        default=-1, update=save_prefs_on_prop_update)\n\n    hubs_room_idx: bpy.props.IntProperty(\n        default=-1, update=save_prefs_on_prop_update)\n\n    hubs_rooms: bpy.props.CollectionProperty(\n        type=HubsUrl)\n\n\ndef init():\n    if not bpy.app.timers.is_registered(update_session):\n        bpy.app.timers.register(update_session)\n\n    from .utils import load_prefs\n    load_prefs(bpy.context)\n\n    prefs = bpy.context.window_manager.hubs_scene_debugger_prefs\n    if len(prefs.hubs_instances) == 0:\n        add_instance(bpy.context)\n\n\n@persistent\ndef load_post(dummy):\n    init()\n\n\n@persistent\ndef update_session():\n    hubs_session.update_session_state()\n    return 2.0\n\n\nclasses = (\n    HubsUrl,\n    HubsSceneDebuggerPrefs,\n    HubsCreateRoomOperator,\n    HubsOpenRoomOperator,\n    HubsCloseRoomOperator,\n    HubsUpdateRoomOperator,\n    HUBS_PT_ToolsSceneSessionPanel,\n    HUBS_PT_ToolsSceneDebuggerPanel,\n    HUBS_PT_ToolsSceneDebuggerCreatePanel,\n    HUBS_PT_ToolsSceneDebuggerOpenPanel,\n    HUBS_PT_ToolsSceneDebuggerUpdatePanel,\n    HubsSceneDebuggerRoomCreatePrefs,\n    HubsOpenAddonPrefsOperator,\n    HubsSceneDebuggerRoomExportPrefs,\n    HubsSceneDebuggerInstanceAdd,\n    HubsSceneDebuggerInstanceRemove,\n    HubsSceneDebuggerRoomAdd,\n    HubsSceneDebuggerRoomRemove,\n    HUBS_UL_ToolsSceneDebuggerServers,\n    HUBS_UL_ToolsSceneDebuggerRooms,\n    HUBS_PT_ToolsSceneDebuggerPublishScenePanel,\n    HubsPublishSceneOperator,\n    HubsUpdateSceneOperator,\n    HubsCreateRoomWithSceneOperator,\n    HubsGetScenesOperator,\n    HUBS_UL_ToolsSceneDebuggerProjects,\n    HubsSceneProject,\n    HubsSceneDebuggerScenePublishProps,\n    HubsSceneDebuggerScenes\n)\n\n\ndef register():\n    global hubs_session\n    hubs_session = HubsSession()\n\n    for cls in (classes):\n        bpy.utils.register_class(cls)\n\n    bpy.types.Scene.hubs_scene_debugger_room_create_prefs = bpy.props.PointerProperty(\n        type=HubsSceneDebuggerRoomCreatePrefs)\n    bpy.types.Scene.hubs_scene_debugger_room_export_prefs = bpy.props.PointerProperty(\n        type=HubsSceneDebuggerRoomExportPrefs)\n    bpy.types.Scene.hubs_scene_debugger_scene_publish_props = bpy.props.PointerProperty(\n        type=HubsSceneDebuggerScenePublishProps)\n    bpy.types.WindowManager.hubs_scene_debugger_scenes_props = bpy.props.PointerProperty(\n        type=HubsSceneDebuggerScenes)\n    bpy.types.WindowManager.hubs_scene_debugger_prefs = bpy.props.PointerProperty(\n        type=HubsSceneDebuggerPrefs)\n\n    if load_post not in bpy.app.handlers.load_post:\n        bpy.app.handlers.load_post.append(load_post)\n\n    init()\n\n\ndef unregister():\n    for cls in reversed(classes):\n        bpy.utils.unregister_class(cls)\n\n    del bpy.types.Scene.hubs_scene_debugger_room_create_prefs\n    del bpy.types.Scene.hubs_scene_debugger_room_export_prefs\n    del bpy.types.Scene.hubs_scene_debugger_scene_publish_props\n    del bpy.types.WindowManager.hubs_scene_debugger_scenes_props\n    del bpy.types.WindowManager.hubs_scene_debugger_prefs\n\n    if bpy.app.timers.is_registered(update_session):\n        bpy.app.timers.unregister(update_session)\n\n    if load_post in bpy.app.handlers.load_post:\n        bpy.app.handlers.load_post.remove(load_post)\n\n    hubs_session.close()\n"
  },
  {
    "path": "addons/io_hubs_addon/dependencies/__init__.py",
    "content": "from ..utils import load_dependency\n\nselenium = None\n\n\ndef get_selenium():\n    global selenium\n    if selenium is None:\n        selenium = load_dependency(\"selenium.webdriver\")\n\n    return selenium\n"
  },
  {
    "path": "addons/io_hubs_addon/hubs_session.py",
    "content": "import bpy\nfrom .preferences import get_addon_pref, EXPORT_TMP_FILE_NAME\nfrom .utils import is_module_available, get_browser_profile_directory\n\nPARAMS_TO_STRING = {\n    \"newLoader\": {\n        \"name\": \"Use New Loader\",\n        \"description\": \"Makes the room use the new bitECS loader.  This causes all media/objects in the room and scene to be loaded with the new loader and has various changes to the UI interface and functionality of objects.  This is required for Behavior Graphs. (newLoader)\"\n    },\n    \"ecsDebug\": {\n        \"name\": \"Show ECS Debug Panel\",\n        \"description\": \"Enables the ECS debugging side panel to get hierarchical information on the underlying structure of elements in the room and which components are applied to each element. (ecsDebug)\"\n    },\n    \"vr_entry_type\": {\n        \"name\": \"Skip Entry\",\n        \"description\": \"Omits the entry setup panel and goes straight into the room. (vr_entry_type=2d_now)\",\n        \"value\": \"2d_now\"\n    },\n    \"debugLocalScene\": {\n        \"name\": \"Allow Scene Update\",\n        \"description\": \"Allows the scene to be overridden by the contents of the current Blender scene. Enable this if you want to update the scene.  Disable this if you just want to spawn an object in the room. (debugLocalScene)\"\n    },\n}\n\nJS_DROP_FILE = \"\"\"\n    var target = arguments[0],\n        offsetX = arguments[1],\n        offsetY = arguments[2],\n        document = target.ownerDocument || document,\n        window = document.defaultView || window;\n\n    var input = document.createElement('INPUT');\n    input.type = 'file';\n    input.onchange = function () {\n      var rect = target.getBoundingClientRect(),\n          x = rect.left + (offsetX || (rect.width >> 1)),\n          y = rect.top + (offsetY || (rect.height >> 1)),\n          dataTransfer = { files: this.files };\n          dataTransfer.getData = o => undefined;\n\n      ['dragenter', 'dragover', 'drop'].forEach(function (name) {\n        var evt = document.createEvent('MouseEvent');\n        evt.initMouseEvent(name, !0, !0, window, 0, 0, 0, x, y, !1, !1, !1, !1, 0, null);\n        evt.dataTransfer = dataTransfer;\n        target.dispatchEvent(evt);\n      });\n\n      setTimeout(function () { document.body.removeChild(input); }, 25);\n    };\n    document.body.appendChild(input);\n    return input;\n\"\"\"\n\nJS_STATE_UPDATE = \"\"\"\n    let params = { signedIn: false, entered: false, roomName: \"\", reticulumUrl: \"\" };\n    try { params[\"signedIn\"] = APP?.hubChannel?.signedIn; } catch(e) {};\n    try { params[\"entered\"] = APP?.scene?.is(\"entered\"); } catch(e) {};\n    try { params[\"roomName\"] = APP?.hub?.name || APP?.hub?.slug || APP?.hub?.hub_id; } catch(e) {};\n    try { params[\"reticulumUrl\"] = window.$P.getReticulumFetchUrl(\"\"); } catch (e) {};\n    return params;\n\"\"\"\nJS_WAYPOINT_UPDATE = \"\"\"\n    window.__scene_debugger_scene_update_listener = () => {\n        try {\n            setTimeout(() => {\n                window.location = `${window.location.href}#${arguments[0]}`;\n                const mat = APP.world.scene.getObjectByName(`${arguments[0]}`).matrixWorld;\n                APP.scene.systems[\"hubs-systems\"].characterController.travelByWaypoint(mat, false, false);\n            }, 0);\n        } catch(e) {\n            console.warn(e);\n        };\n        APP.scene.removeEventListener(\"environment-scene-loaded\", window.__scene_debugger_scene_update_listener);\n        delete window.__scene_debugger_scene_update_listener;\n    };\n    APP.scene.addEventListener(\"environment-scene-loaded\", window.__scene_debugger_scene_update_listener);\n\"\"\"\n\n\nclass HubsSession:\n    _web_driver = None\n    _user_logged_in = False\n    _user_in_room = False\n    _room_name = \"\"\n    _room_params = {}\n    _reticulum_url = \"\"\n    _client_url = \"\"\n\n    def init(self, context):\n        browser = get_addon_pref(context).browser\n        if self.is_alive():\n            if self._web_driver.name != browser.lower():\n                self.close()\n                self.__create_instance(context)\n                return False\n            return True\n        else:\n            self.__create_instance(context)\n            return False\n\n    def close(self):\n        if self._web_driver:\n            # Hack, without this the browser instances don't close the session correctly and\n            # you get a \"[Browser] didn't shutdown correctly\" message on reopen.\n            # Only seen in Windows so far so limiting to it for now.\n            import platform\n            if platform == \"windows\":\n                windows = self._web_driver.window_handles\n                for w in windows:\n                    self._web_driver.switch_to.window(w)\n                    self._web_driver.close()\n\n            self._web_driver.quit()\n            self._web_driver = None\n\n    def __create_instance(self, context):\n        if not self._web_driver or not self.is_alive():\n            self.close()\n            browser = get_addon_pref(context).browser\n            import os\n            file_path = get_browser_profile_directory(browser)\n            if not os.path.exists(file_path):\n                os.mkdir(file_path)\n\n            from .dependencies import get_selenium\n            selenium = get_selenium()\n            if browser == \"Firefox\":\n                options = selenium.FirefoxOptions()\n                override_ff_path = get_addon_pref(\n                    context).override_firefox_path\n                ff_path = get_addon_pref(context).firefox_path\n                if override_ff_path and ff_path:\n                    options.binary_location = ff_path\n                # This should work but it doesn't https://github.com/SeleniumHQ/selenium/issues/11028 so using arguments instead\n                # firefox_profile = selenium.FirefoxProfile(file_path)\n                # firefox_profile.accept_untrusted_certs = True\n                # firefox_profile.assume_untrusted_cert_issuer = True\n                # options.profile = firefox_profile\n                options.add_argument(\"-profile\")\n                options.add_argument(file_path)\n                options.set_preference(\"javascript.options.shared_memory\", True)\n                self._web_driver = selenium.Firefox(options=options)\n            else:\n                options = selenium.ChromeOptions()\n                options.add_argument('--enable-features=SharedArrayBuffer')\n                options.add_argument('--ignore-certificate-errors')\n                options.add_argument(\n                    f'user-data-dir={file_path}')\n                override_chrome_path = get_addon_pref(\n                    context).override_chrome_path\n                chrome_path = get_addon_pref(context).chrome_path\n                if override_chrome_path and chrome_path:\n                    options.binary_location = chrome_path\n                self._web_driver = selenium.Chrome(options=options)\n\n    def update_session_state(self):\n        if self.is_alive():\n            url = self._web_driver.current_url\n            from urllib.parse import urlparse\n            from urllib.parse import parse_qs\n            parsed = urlparse(url)\n            params = parse_qs(parsed.query, keep_blank_values=True)\n            self._room_params = {k: v for k, v in params.items() if k != \"hub_id\"}\n\n            self._client_url = f'{parsed.scheme}://{parsed.hostname}:{parsed.port}'\n\n            params = self._web_driver.execute_script(JS_STATE_UPDATE)\n            self._user_logged_in = params[\"signedIn\"] or \"debugLocalScene\" not in self._room_params\n            self._user_in_room = params[\"entered\"]\n            self._room_name = params[\"roomName\"]\n            self._reticulum_url = params[\"reticulumUrl\"]\n            if not self._reticulum_url:\n                import urllib\n                base_assets_path = self._get_env_meta(\"base_assets_path\")\n                isUsingCloudflare = base_assets_path and \"workers.dev\" in base_assets_path\n                if isUsingCloudflare:\n                    ret_host = urllib.parse.urlparse(base_assets_path).hostname\n                else:\n                    ret_host = self._get_env_meta(\"upload_host\")\n                    if not ret_host:\n                        ret_host = self._get_env_meta(\"reticulum_server\")\n                if ret_host:\n                    ret_port = urllib.parse.urlparse(ret_host).port\n                    self._reticulum_url = f'https://{ret_host}{\":\"+ret_port if ret_port else \"\"}'\n\n        else:\n            self._user_logged_in = False\n            self._user_in_room = False\n            self._room_name = \"\"\n            self.reticulumUrl = \"\"\n\n    def bring_to_front(self, context):\n        # In some systems switch_to doesn't work, the code below is a hack to make it work\n        # for the affected platforms/browsers that we have detected so far.\n        browser = get_addon_pref(context).browser\n        import platform\n        if browser == \"Firefox\" or platform.system == \"Windows\":\n            ws = self._web_driver.get_window_size()\n            self._web_driver.minimize_window()\n            self._web_driver.set_window_size(ws['width'], ws['height'])\n        self._web_driver.switch_to.window(self._web_driver.current_window_handle)\n\n    def is_alive(self):\n        try:\n            if not self._web_driver or not is_module_available(\"selenium\"):\n                return False\n            else:\n                return bool(self._web_driver.current_url)\n        except Exception:\n            return False\n\n    def update(self):\n        import os\n        document = self._web_driver.find_element(\"tag name\", \"html\")\n        file_input = self._web_driver.execute_script(JS_DROP_FILE, document, 0, 0)\n        file_input.send_keys(os.path.join(bpy.app.tempdir, EXPORT_TMP_FILE_NAME))\n\n    def get_local_storage(self, item):\n        store = None\n        if self.is_alive():\n            store = self._web_driver.execute_script(f'return window.localStorage.getItem(\"{item}\");')\n\n        return store\n\n    def set_local_storage(self, data):\n        if self.is_alive():\n            self._web_driver.execute_script(f'window.localStorage.setItem(\"___hubs_store\", {data});')\n\n    def get_url(self):\n        return self._web_driver.current_url\n\n    def url_params_string_from_prefs(self, context):\n        params = \"\"\n        keys = list(PARAMS_TO_STRING.keys())\n        for key in keys:\n            if getattr(context.scene.hubs_scene_debugger_room_create_prefs, key):\n                value = f'={PARAMS_TO_STRING[key][\"value\"]}' if \"value\" in PARAMS_TO_STRING[key] else \"\"\n                key = key if not params else f'&{key}'\n                params = f'{params}{key}{value}'\n\n        return params\n\n    def _get_env_meta(self, name):\n        return self._web_driver.execute_script(f'return document.querySelector(\\'meta[name=\"env:{name}\"]\\')?.content')\n\n    def get_token(self):\n        if self.is_alive():\n            hubs_store = self.get_local_storage(\"___hubs_store\")\n            if hubs_store:\n                import json\n                hubs_store = json.loads(hubs_store)\n                has_credentials = \"credentials\" in hubs_store\n                if has_credentials:\n                    credentials = hubs_store[\"credentials\"]\n                    if \"token\" in credentials:\n                        return credentials[\"token\"]\n\n        return None\n\n    def set_credentials(self, email, token):\n        if self.is_alive():\n            hubs_store = self.get_local_storage(\"___hubs_store\")\n            if hubs_store:\n                import json\n                hubs_store = json.loads(hubs_store)\n                has_credentials = \"credentials\" in hubs_store\n                if has_credentials:\n                    credentials = hubs_store[\"credentials\"]\n                    credentials[\"email\"] = email\n                    credentials[\"token\"] = token\n                    self.set_local_storage(hubs_store)\n\n    def set_creator_assignment_token(self, hub_id, creator_token, embed_token):\n        if self.is_alive():\n            hubs_store = self.get_local_storage(\"___hubs_store\")\n            if hubs_store:\n                import json\n                hubs_store = json.loads(hubs_store)\n                has_token = \"creatorAssignmentTokens\" in hubs_store\n                if not has_token:\n                    hubs_store[\"creatorAssignmentTokens\"] = []\n                #  creator\n                if creator_token:\n                    creator_tokens = hubs_store[\"creatorAssignmentTokens\"]\n                    if creator_tokens:\n                        creator_tokens.append({\n                            \"hub_id\": hub_id,\n                            \"creatorAssignmentToken\": creator_token\n                        })\n                    else:\n                        creator_tokens = [{\n                            \"hub_id\": hub_id,\n                            \"creatorAssignmentToken\": creator_token\n                        }]\n                # embed\n                if embed_token:\n                    embed_tokens = hubs_store[\"embed_tokens\"]\n                    if embed_tokens:\n                        embed_tokens.append({\n                            \"hub_id\": hub_id,\n                            \"embedToken\": embed_token\n                        })\n                    else:\n                        embed_tokens = [{\n                            \"hub_id\": hub_id,\n                            \"embedToken\": embed_token\n                        }]\n                self.set_local_storage(hubs_store)\n\n    def load(self, url):\n        self._web_driver.get(url)\n\n    def is_local_instance(self):\n        return \"hub_id\" in self._web_driver.current_url\n\n    def move_to_waypoint(self, name):\n        self._web_driver.execute_script(JS_WAYPOINT_UPDATE, name)\n\n    @property\n    def user_logged_in(self):\n        return self._user_logged_in\n\n    @property\n    def user_in_room(self):\n        return self._user_in_room\n\n    @property\n    def room_name(self):\n        return self._room_name\n\n    @property\n    def room_params(self):\n        return self._room_params\n\n    @property\n    def reticulum_url(self):\n        return self._reticulum_url\n\n    @property\n    def client_url(self):\n        return self._client_url\n"
  },
  {
    "path": "addons/io_hubs_addon/icons.py",
    "content": "import bpy\nimport os\nfrom os import listdir\nfrom os.path import join, isfile\nimport bpy.utils.previews\n\n\ndef load_icons():\n    global __hubs_icons\n    __hubs_icons = {}\n    pcoll = bpy.utils.previews.new()\n    icons_dir = os.path.join(os.path.dirname(__file__), \"icons\")\n    icons = [f for f in listdir(icons_dir) if isfile(join(icons_dir, f))]\n    for icon in icons:\n        pcoll.load(icon, os.path.join(icons_dir, icon), 'IMAGE')\n        print(\"Loading icon: \" + icon)\n    __hubs_icons[\"hubs\"] = pcoll\n\n\ndef unload_icons():\n    global __hubs_icons\n    bpy.utils.previews.remove(__hubs_icons[\"hubs\"])\n    del __hubs_icons\n\n\ndef get_hubs_icons():\n    global __hubs_icons\n    return __hubs_icons[\"hubs\"]\n\n\n__hubs_icons = {}\n\n\ndef register():\n    load_icons()\n\n\ndef unregister():\n    unload_icons()\n"
  },
  {
    "path": "addons/io_hubs_addon/io/gltf_exporter.py",
    "content": "import bpy\nfrom .utils import HUBS_CONFIG\nfrom bpy.props import PointerProperty\nfrom ..components.components_registry import get_components_registry\nfrom ..components.utils import get_host_components\nimport traceback\n\nif bpy.app.version < (3, 0, 0):\n    from io_scene_gltf2.blender.exp import gltf2_blender_export\n    from io_scene_gltf2.io.exp.gltf2_io_user_extensions import export_user_extensions\n\n    # gather_gltf_hook does not expose the info we need, make a custom hook for now\n    # ideally we can resolve this upstream somehow https://github.com/KhronosGroup/glTF-Blender-IO/issues/1009\n    orig_gather_gltf = gltf2_blender_export.__gather_gltf\n\n\ndef patched_gather_gltf(exporter, export_settings):\n    orig_gather_gltf(exporter, export_settings)\n    export_user_extensions('hubs_gather_gltf_hook',\n                           export_settings, exporter._GlTF2Exporter__gltf)\n    exporter._GlTF2Exporter__traverse(exporter._GlTF2Exporter__gltf.extensions)\n\n\nEXTENSION_NAME = HUBS_CONFIG[\"gltfExtensionName\"]\nEXTENSION_VERSION = HUBS_CONFIG[\"gltfExtensionVersion\"]\n\n\ndef get_version_string():\n    from .. import (bl_info)\n    info = bl_info['version']\n    return f\"{info[0]}.{info[1]}.{info[2]}\"\n\n\ndef export_callback(callback_method, export_settings):\n    # Note: we loop through copied lists of the potential component hosts\n    # to allow the callbacks to change the host names.  This is needed\n    # because a name change will cause Blender to update the host lists in\n    # mid iteration and so multiple callbacks could be executed for the same\n    # component/host.\n\n    for scene in bpy.data.scenes[:]:\n        for component in get_host_components(scene):\n            component_callback = getattr(component, callback_method)\n            try:\n                component_callback(export_settings, scene)\n            except Exception:\n                traceback.print_exc()\n\n    for ob in bpy.data.objects[:]:\n        for component in get_host_components(ob):\n            component_callback = getattr(component, callback_method)\n            try:\n                component_callback(export_settings, ob, ob)\n            except Exception:\n                traceback.print_exc()\n\n        if ob.type == 'ARMATURE':\n            for bone in ob.data.bones[:]:\n                for component in get_host_components(bone):\n                    component_callback = getattr(component, callback_method)\n                    try:\n                        component_callback(export_settings, bone, ob)\n                    except Exception:\n                        traceback.print_exc()\n\n    for material in bpy.data.materials[:]:\n        for component in get_host_components(material):\n            component_callback = getattr(component, callback_method)\n            try:\n                component_callback(export_settings, material)\n            except Exception:\n                traceback.print_exc()\n\n\ndef glTF2_pre_export_callback(export_settings):\n    # Import BLACK_LIST here instead of at the beginning of the file to make sure we're always referencing the same one as the glTF add-on.\n    # https://github.com/Hubs-Foundation/hubs-blender-exporter/pull/166#issuecomment-1335083605\n    if bpy.app.version >= (4, 3, 0):\n        from io_scene_gltf2.blender.com.extras import BLACK_LIST\n    else:\n        from io_scene_gltf2.blender.com.gltf2_blender_extras import BLACK_LIST\n\n    BLACK_LIST.extend(glTF2ExportUserExtension.EXCLUDED_PROPERTIES)\n    export_callback(\"pre_export\", export_settings)\n\n\ndef glTF2_post_export_callback(export_settings):\n    # Import BLACK_LIST here instead of at the beginning of the file to make sure we're always referencing the same one as the glTF add-on.\n    # https://github.com/Hubs-Foundation/hubs-blender-exporter/pull/166#issuecomment-1335083605\n    if bpy.app.version >= (4, 3, 0):\n        from io_scene_gltf2.blender.com.extras import BLACK_LIST\n    else:\n        from io_scene_gltf2.blender.com.gltf2_blender_extras import BLACK_LIST\n\n    export_callback(\"post_export\", export_settings)\n    for excluded_prop in glTF2ExportUserExtension.EXCLUDED_PROPERTIES:\n        if excluded_prop in BLACK_LIST:\n            BLACK_LIST.remove(excluded_prop)\n\n\n# This class name is specifically looked for by gltf-blender-io and it's hooks are automatically invoked on export\n\n\nclass glTF2ExportUserExtension:\n\n    EXCLUDED_PROPERTIES = []\n\n    @classmethod\n    def add_excluded_property(cls, key):\n        if key not in glTF2ExportUserExtension.EXCLUDED_PROPERTIES:\n            glTF2ExportUserExtension.EXCLUDED_PROPERTIES.append(key)\n\n    @classmethod\n    def remove_excluded_property(cls, key):\n        if key in glTF2ExportUserExtension.EXCLUDED_PROPERTIES:\n            glTF2ExportUserExtension.EXCLUDED_PROPERTIES.remove(key)\n\n    def __init__(self):\n        # We need to wait until we create the gltf2UserExtension to import the gltf2 modules\n        # Otherwise, it may fail because the gltf2 may not be loaded yet\n        from io_scene_gltf2.io.com.gltf2_io_extensions import Extension\n\n        self.Extension = Extension\n        self.properties = bpy.context.scene.HubsComponentsExtensionProperties\n        self.was_used = False\n        self.delayed_gathers = []\n\n    def hubs_gather_gltf_hook(self, gltf2_object, export_settings):\n        if not self.properties.enabled or not self.was_used:\n            return\n\n        extension_name = EXTENSION_NAME\n        gltf2_object.extensions[extension_name] = self.Extension(\n            name=extension_name,\n            extension={\n                \"version\": EXTENSION_VERSION,\n                \"exporterVersion\": get_version_string()\n            },\n            required=False\n        )\n\n        if gltf2_object.asset.extras is None:\n            gltf2_object.asset.extras = {}\n        gltf2_object.asset.extras[\"HUBS_blenderExporterVersion\"] = get_version_string(\n        )\n        gltf2_object.asset.extras[\"gltf_yup\"] = export_settings['gltf_yup']\n\n    def gather_gltf_extensions_hook(self, gltf2_plan, export_settings):\n        self.hubs_gather_gltf_hook(gltf2_plan, export_settings)\n\n    def gather_scene_hook(self, gltf2_object, blender_scene, export_settings):\n        if not self.properties.enabled:\n            return\n\n        self.export_hubs_components(gltf2_object, blender_scene, export_settings)\n        self.call_delayed_gathers()\n\n    def gather_node_hook(self, gltf2_object, blender_object, export_settings):\n        if not self.properties.enabled:\n            return\n\n        self.export_hubs_components(gltf2_object, blender_object, export_settings)\n\n    def gather_material_hook(self, gltf2_object, blender_material, export_settings):\n        if not self.properties.enabled:\n            return\n\n        self.export_hubs_components(\n            gltf2_object, blender_material, export_settings)\n\n        from .utils import gather_lightmap_texture_info\n        if blender_material.node_tree and blender_material.use_nodes:\n            lightmap_texture_info = gather_lightmap_texture_info(\n                blender_material, export_settings)\n            if lightmap_texture_info:\n                gltf2_object.extensions[\"MOZ_lightmap\"] = self.Extension(\n                    name=\"MOZ_lightmap\",\n                    extension=lightmap_texture_info,\n                    required=False,\n                )\n\n    def gather_material_unlit_hook(self, gltf2_object, blender_material, export_settings):\n        self.gather_material_hook(\n            gltf2_object, blender_material, export_settings)\n\n    def gather_joint_hook(self, gltf2_object, blender_pose_bone, export_settings):\n        if not self.properties.enabled:\n            return\n        self.export_hubs_components(\n            gltf2_object, blender_pose_bone.bone, export_settings)\n\n    def call_delayed_gathers(self):\n        for delayed_gather in self.delayed_gathers:\n            component_data, component_name, gather = delayed_gather\n            component_data[component_name] = gather()\n        self.delayed_gathers.clear()\n\n    def export_hubs_components(self, gltf2_object, blender_object, export_settings):\n        component_list = blender_object.hubs_component_list\n\n        registered_hubs_components = get_components_registry()\n\n        if component_list.items:\n            extension_name = EXTENSION_NAME\n            component_data = {}\n\n            for component_item in component_list.items:\n                component_name = component_item.name\n                if component_name in registered_hubs_components:\n                    component_class = registered_hubs_components[component_name]\n                    component = getattr(\n                        blender_object, component_class.get_id())\n                    data = component.gather(export_settings, blender_object)\n                    if hasattr(data, \"delayed_gather\"):\n                        self.delayed_gathers.append(\n                            (component_data, component_class.gather_name(), data))\n                    else:\n                        component_data[component_class.gather_name()] = data\n                else:\n                    print('Could not export unsupported component \"%s\"' %\n                          (component_name))\n\n            if gltf2_object.extensions is None:\n                gltf2_object.extensions = {}\n            gltf2_object.extensions[extension_name] = self.Extension(\n                name=extension_name,\n                extension=component_data,\n                required=False\n            )\n\n            self.was_used = True\n\n\nclass HubsComponentsExtensionProperties(bpy.types.PropertyGroup):\n    enabled: bpy.props.BoolProperty(\n        name=\"Export Hubs Components\",\n        description='Include this extension in the exported glTF file',\n        default=True\n    )\n\n\nclass HubsGLTFExportPanel(bpy.types.Panel):\n\n    bl_idname = \"HBA_PT_Export_Panel\"\n    bl_label = \"Hubs Export Panel\"\n    bl_space_type = 'FILE_BROWSER'\n    bl_region_type = 'TOOL_PROPS'\n    bl_label = \"Hubs Components\"\n    bl_parent_id = \"GLTF_PT_export_user_extensions\"\n    bl_options = {'DEFAULT_CLOSED'}\n\n    @classmethod\n    def poll(cls, context):\n        sfile = context.space_data\n        operator = sfile.active_operator\n        return operator.bl_idname == \"EXPORT_SCENE_OT_gltf\"\n\n    def draw_header(self, context):\n        props = bpy.context.scene.HubsComponentsExtensionProperties\n        self.layout.prop(props, 'enabled', text=\"\")\n\n    def draw(self, context):\n        self.draw_body(context, self.layout)\n\n    @staticmethod\n    def draw_body(context, layout):\n        layout.use_property_split = True\n        layout.use_property_decorate = False  # No animation.\n\n        props = bpy.context.scene.HubsComponentsExtensionProperties\n        layout.active = props.enabled\n\n        box = layout.box()\n        box.label(text=\"No options yet\")\n\n\ndef register():\n    print(\"Register glTF Exporter\")\n    if bpy.app.version < (3, 0, 0):\n        gltf2_blender_export.__gather_gltf = patched_gather_gltf\n    bpy.utils.register_class(HubsComponentsExtensionProperties)\n    bpy.types.Scene.HubsComponentsExtensionProperties = PointerProperty(\n        type=HubsComponentsExtensionProperties)\n    glTF2ExportUserExtension.add_excluded_property(\"HubsComponentsExtensionProperties\")\n\n\ndef unregister():\n    print(\"Unregister glTF Exporter\")\n    del bpy.types.Scene.HubsComponentsExtensionProperties\n    bpy.utils.unregister_class(HubsComponentsExtensionProperties)\n    if bpy.app.version < (3, 0, 0):\n        gltf2_blender_export.__gather_gltf = orig_gather_gltf\n    glTF2ExportUserExtension.remove_excluded_property(\"HubsComponentsExtensionProperties\")\n"
  },
  {
    "path": "addons/io_hubs_addon/io/gltf_importer.py",
    "content": "import bpy\nimport traceback\nfrom .utils import HUBS_CONFIG, import_image, import_all_textures\nfrom ..components.components_registry import get_component_by_name\nfrom bpy.props import BoolProperty, PointerProperty\n\n# Version-specific imports\nif bpy.app.version >= (4, 3, 0):\n    from io_scene_gltf2.blender.imp.image import BlenderImage\n    from io_scene_gltf2.blender.imp.node import BlenderNode\n    from io_scene_gltf2.blender.imp.material import BlenderMaterial\n    from io_scene_gltf2.blender.imp.scene import BlenderScene\nelse:\n    from io_scene_gltf2.blender.imp.gltf2_blender_image import BlenderImage\n    from io_scene_gltf2.blender.imp.gltf2_blender_node import BlenderNode\n    from io_scene_gltf2.blender.imp.gltf2_blender_material import BlenderMaterial\n    from io_scene_gltf2.blender.imp.gltf2_blender_scene import BlenderScene\n\nEXTENSION_NAME = HUBS_CONFIG[\"gltfExtensionName\"]\n\narmatures = {}\ndelayed_gathers = []\nimport_report = []\n\n\ndef call_delayed_gathers():\n    global delayed_gathers\n    global import_report\n    for gather_import in delayed_gathers:\n        gather_import_args = gather_import.__closure__[0].cell_contents\n        blender_host = gather_import_args[2]\n        component_name = gather_import_args[3]\n        try:\n            gather_import()\n        except Exception:\n            traceback.print_exc()\n            print(f\"Failed to import {component_name} component on {blender_host.name} continuing on...\")\n            import_report.append(\n                f\"Failed to import {component_name} component on {blender_host.name}.  See the console for details.\")\n    delayed_gathers.clear()\n\n\ndef import_hubs_components(gltf_node, blender_host, gltf, blender_ob=None):\n    global import_report\n    if gltf_node and gltf_node.extensions and EXTENSION_NAME in gltf_node.extensions:\n        components_data = gltf_node.extensions[EXTENSION_NAME]\n        for component_name in components_data.keys():\n            component_class = get_component_by_name(component_name)\n            if component_class:\n                component_value = components_data[component_name]\n                try:\n                    data = component_class.gather_import(\n                        gltf, blender_host, component_name, component_value, import_report, blender_ob=blender_ob)\n                    if data and hasattr(data, \"delayed_gather\"):\n                        global delayed_gathers\n                        delayed_gathers.append((data))\n                except Exception:\n                    traceback.print_exc()\n                    print(f\"Failed to import {component_name} component on {blender_host.name} continuing on...\")\n                    import_report.append(\n                        f\"Failed to import {component_name} component on {blender_host.name}.  See the console for details.\")\n            else:\n                if component_name != \"heightfield\":\n                    # heightfield is a Spoke-only component and not needed in Blender.\n                    print(f'Could not import unsupported component \"{component_name}\"')\n                    import_report.append(\n                        f\"Could not import unsupported component {component_name} component on {blender_host.name}.\")\n\n\ndef add_lightmap(gltf_material, blender_mat, gltf):\n    if gltf_material and gltf_material.extensions and 'MOZ_lightmap' in gltf_material.extensions:\n        extension = gltf_material.extensions['MOZ_lightmap']\n\n        texture_index = extension['index']\n\n        gltf_texture = gltf.data.textures[texture_index]\n        blender_image_name, _ = import_image(gltf, gltf_texture)\n        blender_image = bpy.data.images[blender_image_name]\n\n        blender_mat.use_nodes = True\n        nodes = blender_mat.node_tree.nodes\n        lightmap_node = nodes.new('moz_lightmap.node')\n        lightmap_node.location = (-300, 0)\n        lightmap_node.intensity = extension['intensity']\n        node_tex = nodes.new('ShaderNodeTexImage')\n        node_tex.image = blender_image\n        node_tex.location = (-600, 0)\n        blender_mat.node_tree.links.new(\n            node_tex.outputs[\"Color\"], lightmap_node.inputs[\"Lightmap\"])\n        node_uv = nodes.new('ShaderNodeUVMap')\n        node_uv.uv_map = 'UVMap.%03d' % 1\n        node_uv.location = (-900, 0)\n        blender_mat.node_tree.links.new(\n            node_uv.outputs[\"UV\"], node_tex.inputs[\"Vector\"])\n\n\ndef add_bones(gltf):\n    # Bones are created after the armatures so we need to wait until all nodes have been processed to be able to access the bones objects\n    global armatures\n    for armature in armatures.values():\n        blender_object = armature['armature']\n        gltf_bones = armature['gltf_bones']\n        for bone in blender_object.data.bones:\n            gltf_bone = gltf_bones[bone.name]\n            import_hubs_components(\n                gltf_bone, bone, gltf, blender_ob=blender_object)\n\n\ndef store_bones_for_import(gltf, vnode):\n    # Store the glTF bones with the armature so their components can be imported once the Blender bones are created.\n    global armatures\n    children = vnode.children[:]\n    gltf_bones = {}\n    while children:\n        child_index = children.pop()\n        child_vnode = gltf.vnodes[child_index]\n        if child_vnode.type == vnode.Bone:\n            gltf_bones[child_vnode.name] = gltf.data.nodes[child_index]\n            children.extend(child_vnode.children)\n\n    armatures[vnode.blender_object.name] = {\n        'armature': vnode.blender_object, 'gltf_bones': gltf_bones}\n\n\ndef show_import_report():\n    global import_report\n    if not import_report:\n        return\n\n    title = \"Import Report\"\n\n    def report_import():\n        bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=title, report_string='\\n\\n'.join(import_report))\n    bpy.app.timers.register(report_import)\n\n\nclass glTF2ImportUserExtension:\n\n    def __init__(self):\n        from io_scene_gltf2.io.com.gltf2_io_extensions import Extension\n        self.extensions = [\n            Extension(name=EXTENSION_NAME, extension={}, required=True)]\n        self.properties = bpy.context.scene.HubsComponentsExtensionImportProperties\n        global delayed_gathers\n        delayed_gathers.clear()\n\n    def gather_import_scene_before_hook(self, gltf_scene, blender_scene, gltf):\n        if not self.properties.enabled:\n            return\n\n        global armatures\n        armatures.clear()\n        global delayed_gathers\n        delayed_gathers.clear()\n        global import_report\n        import_report.clear()\n\n        if gltf.data.asset and gltf.data.asset.extras:\n            if 'gltf_yup' in gltf.data.asset.extras:\n                gltf.import_settings['gltf_yup'] = gltf.data.asset.extras[\n                    'gltf_yup']\n\n        import_all_textures(gltf)\n\n    def gather_import_scene_after_nodes_hook(self, gltf_scene, blender_scene, gltf):\n        if not self.properties.enabled:\n            return\n\n        import_hubs_components(gltf_scene, blender_scene, gltf)\n\n        add_bones(gltf)\n        armatures.clear()\n\n    def gather_import_node_after_hook(self, vnode, gltf_node, blender_object, gltf):\n        if not self.properties.enabled:\n            return\n\n        import_hubs_components(\n            gltf_node, blender_object, gltf, blender_ob=blender_object)\n\n        #  Node hooks are not called for bones. Bones are created together with their armature.\n        # Unfortunately the bones are created after this hook is called so we need to wait until all nodes have been created.\n        if vnode.is_arma:\n            store_bones_for_import(gltf, vnode)\n\n    def gather_import_image_after_hook(self, gltf_img, blender_image, gltf):\n        # As of Blender 3.2.0 the importer doesn't import images that are not referenced by a material socket.\n        # We handle this case by case in each component's gather_import override.\n        pass\n\n    def gather_import_texture_after_hook(\n            self, gltf_texture, node_tree, mh, tex_info, location, label, color_socket, alpha_socket, is_data, gltf):\n        # As of Blender 3.2.0 the importer doesn't import textures that are not referenced by a material socket image.\n        # We handle this case by case in each component's gather_import override.\n        pass\n\n    def gather_import_material_after_hook(self, gltf_material, vertex_color, blender_mat, gltf):\n        if not self.properties.enabled:\n            return\n\n        import_hubs_components(\n            gltf_material, blender_mat, gltf)\n\n        add_lightmap(gltf_material, blender_mat, gltf)\n\n    def gather_import_scene_after_animation_hook(self, gltf_scene, blender_scene, gltf):\n        call_delayed_gathers()\n        show_import_report()\n\n\n# import hooks were only recently added to the glTF exporter, so make a custom hook for now\norig_BlenderNode_create_object = BlenderNode.create_object\norig_BlenderMaterial_create = BlenderMaterial.create\norig_BlenderScene_create = BlenderScene.create\n\n\n@staticmethod\ndef patched_BlenderNode_create_object(gltf, vnode_id):\n    blender_object = orig_BlenderNode_create_object(gltf, vnode_id)\n\n    vnode = gltf.vnodes[vnode_id]\n    node = None\n\n    if vnode.camera_node_idx is not None:\n        parent_vnode = gltf.vnodes[vnode.parent]\n        node = gltf.data.nodes[vnode.parent]\n        if node.name != parent_vnode.name:\n            if parent_vnode.name:\n                print(\"Falling back to getting the node from the vnode name.\")\n                node = [n for n in gltf.data.nodes if n.name == parent_vnode.name][0]\n            else:\n                print(\"Couldn't find the equivalent node for the vnode.\")\n\n    else:\n        node = gltf.data.nodes[vnode_id]\n        if node.name != vnode.name:\n            if vnode.name:\n                print(\"Falling back to getting the node from the vnode name.\")\n                node = [n for n in gltf.data.nodes if n.name == vnode.name][0]\n            else:\n                print(\"Couldn't find the equivalent node for the vnode.\")\n\n    import_hubs_components(node, vnode.blender_object, gltf, blender_ob=vnode.blender_object)\n\n    #  Node hooks are not called for bones. Bones are created together with their armature.\n    # Unfortunately the bones are created after this hook is called so we need to wait until all nodes have been created.\n    if vnode.is_arma:\n        store_bones_for_import(gltf, vnode)\n\n    return blender_object\n\n\n@staticmethod\ndef patched_BlenderMaterial_create(gltf, material_idx, vertex_color):\n    orig_BlenderMaterial_create(\n        gltf, material_idx, vertex_color)\n    gltf_material = gltf.data.materials[material_idx]\n    blender_mat_name = next(iter(gltf_material.blender_material.values()))\n    blender_mat = bpy.data.materials[blender_mat_name]\n    import_hubs_components(gltf_material, blender_mat, gltf)\n\n    add_lightmap(gltf_material, blender_mat, gltf)\n\n\n@staticmethod\ndef patched_BlenderScene_create(gltf):\n    global armatures\n    global delayed_gathers\n    global import_report\n    armatures.clear()\n    delayed_gathers.clear()\n    import_report.clear()\n\n    import_all_textures(gltf)\n    orig_BlenderScene_create(gltf)\n    gltf_scene = gltf.data.scenes[gltf.data.scene]\n    blender_object = bpy.data.scenes[gltf.blender_scene]\n    import_hubs_components(gltf_scene, blender_object, gltf)\n\n    # Bones are created after the armatures so we need to wait until all nodes have been processed to be able to access the bones objects\n    add_bones(gltf)\n    armatures.clear()\n\n    call_delayed_gathers()\n    show_import_report()\n\n\nclass HubsGLTFImportPanel(bpy.types.Panel):\n\n    bl_idname = \"HBA_PT_Import_Panel\"\n    bl_label = \"Hubs Import Panel\"\n    bl_space_type = 'FILE_BROWSER'\n    bl_region_type = 'TOOL_PROPS'\n    bl_label = \"Hubs Components\"\n    bl_parent_id = \"GLTF_PT_import_user_extensions\"\n    bl_options = {'DEFAULT_CLOSED'}\n\n    @classmethod\n    def poll(cls, context):\n        sfile = context.space_data\n        operator = sfile.active_operator\n        return operator.bl_idname == \"IMPORT_SCENE_OT_gltf\"\n\n    def draw_header(self, context):\n        props = bpy.context.scene.HubsComponentsExtensionImportProperties\n        self.layout.prop(props, 'enabled', text=\"\")\n\n    def draw(self, context):\n        self.draw_body(context, self.layout)\n\n    @staticmethod\n    def draw_body(context, layout):\n        layout.use_property_split = True\n        layout.use_property_decorate = False  # No animation.\n\n        props = bpy.context.scene.HubsComponentsExtensionImportProperties\n        layout.active = props.enabled\n\n        box = layout.box()\n        box.label(text=\"No options yet\")\n\n\nclass HubsImportProperties(bpy.types.PropertyGroup):\n    enabled: BoolProperty(\n        name=\"Import Hubs Components\",\n        description='Import Hubs components from the glTF file',\n        default=True\n    )\n\n\ndef register():\n    print(\"Register glTF Importer\")\n    if bpy.app.version < (3, 1, 0):\n        BlenderNode.create_object = patched_BlenderNode_create_object\n        BlenderMaterial.create = patched_BlenderMaterial_create\n        BlenderScene.create = patched_BlenderScene_create\n    bpy.utils.register_class(HubsImportProperties)\n    bpy.types.Scene.HubsComponentsExtensionImportProperties = PointerProperty(\n        type=HubsImportProperties)\n\n\ndef unregister():\n    print(\"Unregister glTF Importer\")\n    if bpy.app.version < (3, 1, 0):\n        BlenderNode.create_object = orig_BlenderNode_create_object\n        BlenderMaterial.create = orig_BlenderMaterial_create\n        BlenderScene.create = orig_BlenderScene_create\n    del bpy.types.Scene.HubsComponentsExtensionImportProperties\n    bpy.utils.unregister_class(HubsImportProperties)\n"
  },
  {
    "path": "addons/io_hubs_addon/io/panels.py",
    "content": "import bpy\nfrom .gltf_exporter import HubsGLTFExportPanel\nfrom .gltf_importer import HubsGLTFImportPanel\n\n\ndef register_panels():\n    try:\n        bpy.utils.register_class(HubsGLTFExportPanel)\n        bpy.utils.register_class(HubsGLTFImportPanel)\n    except Exception:\n        pass\n    return unregister_panels\n\n\ndef unregister_panels():\n    # Since panels are registered on demand, it is possible it is not registered\n    try:\n        bpy.utils.unregister_class(HubsGLTFImportPanel)\n        bpy.utils.unregister_class(HubsGLTFExportPanel)\n    except Exception:\n        pass\n"
  },
  {
    "path": "addons/io_hubs_addon/io/utils.py",
    "content": "import bpy\nimport os\nimport re\nfrom ..nodes.lightmap import MozLightmapNode\nfrom io_scene_gltf2.io.com import gltf2_io_extensions\nfrom io_scene_gltf2.io.com import gltf2_io\nfrom typing import Optional, Tuple, Union\n\n# Version-specific imports\nif bpy.app.version >= (4, 5, 0):\n    from io_scene_gltf2.blender.com import extras as gltf2_blender_extras\n    from io_scene_gltf2.blender.exp import joints as gltf2_blender_gather_joints\n    from io_scene_gltf2.blender.exp import nodes as gltf2_blender_gather_nodes\n    from io_scene_gltf2.blender.exp.cache import cached\n    from io_scene_gltf2.blender.exp.material import encode_image as gltf2_blender_image\n    from io_scene_gltf2.blender.exp.material import materials as gltf2_blender_gather_materials\n    from io_scene_gltf2.blender.exp.material import search_node_tree as gltf2_blender_search_node_tree\n    from io_scene_gltf2.blender.exp.material import texture_info as gltf2_blender_gather_texture_info\n    from io_scene_gltf2.blender.exp.material.image import set_real_uri as gltf2_blender_set_real_uri\n    from io_scene_gltf2.blender.imp.image import BlenderImage\n    from io_scene_gltf2.io.exp import binary_data as gltf2_io_binary_data\n    from io_scene_gltf2.io.exp import image_data as gltf2_io_image_data\nelif bpy.app.version >= (4, 3, 0):\n    from io_scene_gltf2.blender.com import extras as gltf2_blender_extras\n    from io_scene_gltf2.blender.exp import joints as gltf2_blender_gather_joints\n    from io_scene_gltf2.blender.exp import nodes as gltf2_blender_gather_nodes\n    from io_scene_gltf2.blender.exp.cache import cached\n    from io_scene_gltf2.blender.exp.material import encode_image as gltf2_blender_image\n    from io_scene_gltf2.blender.exp.material import materials as gltf2_blender_gather_materials\n    from io_scene_gltf2.blender.exp.material import search_node_tree as gltf2_blender_search_node_tree\n    from io_scene_gltf2.blender.exp.material import texture_info as gltf2_blender_gather_texture_info\n    from io_scene_gltf2.blender.imp.image import BlenderImage\n    from io_scene_gltf2.io.exp import binary_data as gltf2_io_binary_data\n    from io_scene_gltf2.io.exp import image_data as gltf2_io_image_data\nelif bpy.app.version >= (4, 1, 0):\n    from io_scene_gltf2.blender.com import gltf2_blender_extras\n    # import the gather_nodes before the gather_joints to avoid a circular import specific to Blender 4.1\n    from io_scene_gltf2.blender.exp import (\n        gltf2_blender_gather_nodes,\n        gltf2_blender_gather_joints\n    )\n    from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached\n    from io_scene_gltf2.blender.exp.material import (\n        gltf2_blender_gather_materials,\n        gltf2_blender_search_node_tree,\n        gltf2_blender_gather_texture_info\n    )\n    from io_scene_gltf2.blender.exp.material.extensions import gltf2_blender_image\n    from io_scene_gltf2.blender.imp.gltf2_blender_image import BlenderImage\n    from io_scene_gltf2.io.exp import gltf2_io_binary_data\n    from io_scene_gltf2.io.exp import gltf2_io_image_data\nelif bpy.app.version >= (3, 6, 0):\n    from io_scene_gltf2.blender.com import gltf2_blender_extras\n    from io_scene_gltf2.blender.exp import (\n        gltf2_blender_gather_joints,\n        gltf2_blender_gather_nodes\n    )\n    from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached\n    from io_scene_gltf2.blender.exp.material import (\n        gltf2_blender_gather_materials,\n        gltf2_blender_gather_texture_info\n    )\n    from io_scene_gltf2.blender.exp.material.extensions import gltf2_blender_image\n    from io_scene_gltf2.blender.imp.gltf2_blender_image import BlenderImage\n    from io_scene_gltf2.io.exp import gltf2_io_binary_data\n    from io_scene_gltf2.io.exp import gltf2_io_image_data\nelse:\n    from io_scene_gltf2.blender.com import gltf2_blender_extras\n    from io_scene_gltf2.blender.exp import (\n        gltf2_blender_export_keys,\n        gltf2_blender_image,\n        gltf2_blender_gather_materials,\n        gltf2_blender_gather_joints,\n        gltf2_blender_gather_nodes,\n        gltf2_blender_gather_texture_info\n    )\n    from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached\n    from io_scene_gltf2.blender.imp.gltf2_blender_image import BlenderImage\n    from io_scene_gltf2.io.exp import gltf2_io_binary_data\n    from io_scene_gltf2.io.exp import gltf2_io_image_data\n\n\nHUBS_CONFIG = {\n    \"gltfExtensionName\": \"MOZ_hubs_components\",\n    \"gltfExtensionVersion\": 4,\n}\n\nimported_textures = {}\n\n# gather_texture/image with HDR support via MOZ_texture_rgbe\n\n\nclass HubsImageData(gltf2_io_image_data.ImageData):\n    @property\n    def file_extension(self):\n        if self._mime_type == \"image/vnd.radiance\":\n            return \".hdr\"\n        return super().file_extension\n\n\nclass HubsExportImage(gltf2_blender_image.ExportImage):\n    @staticmethod\n    def from_blender_image(image: bpy.types.Image):\n        export_image = HubsExportImage()\n        for chan in range(image.channels):\n            export_image.fill_image(image, dst_chan=chan, src_chan=chan)\n        return export_image\n\n    def encode(self, mime_type: Optional[str], export_settings) -> Union[Tuple[bytes, bool], bytes]:\n        if mime_type == \"image/vnd.radiance\":\n            if bpy.app.version < (4, 1, 0):\n                return self.encode_from_image_hdr(self.blender_image())\n            else:\n                return self.encode_from_image_hdr(self.blender_image(export_settings))\n        if bpy.app.version < (3, 5, 0):\n            return super().encode(mime_type)\n        else:\n            return super().encode(mime_type, export_settings)\n\n    # TODO this should allow conversion from other HDR formats (namely EXR),\n    # in memory images, and combining separate channels like SDR images\n    def encode_from_image_hdr(self, image: bpy.types.Image) -> Union[Tuple[bytes, bool], bytes]:\n        if image.file_format == \"HDR\" and image.source == 'FILE' and not image.is_dirty:\n            if image.packed_file is not None:\n                return image.packed_file.data\n            else:\n                src_path = bpy.path.abspath(image.filepath_raw)\n                if os.path.isfile(src_path):\n                    with open(src_path, 'rb') as f:\n                        return f.read()\n\n        raise Exception(\n            \"HDR images must be saved as a .hdr file before exporting\")\n\n\n@cached\ndef gather_image(blender_image, export_settings):\n    if not blender_image:\n        return None\n\n    name, _extension = os.path.splitext(\n        os.path.basename(blender_image.filepath))\n\n    if export_settings[\"gltf_image_format\"] == \"AUTO\":\n        if blender_image.file_format == \"HDR\":\n            mime_type = \"image/vnd.radiance\"\n        else:\n            mime_type = \"image/png\"\n    else:\n        mime_type = \"image/jpeg\"\n\n    data = HubsExportImage.from_blender_image(blender_image).encode(mime_type, export_settings)\n\n    if type(data) is tuple:\n        data = data[0]\n\n    if export_settings['gltf_format'] == 'GLTF_SEPARATE':\n        # io_scene_gltf2.blender.exp.material.texture.__gather_source can be used as a reference for what's needed here.\n        uri = HubsImageData(data=data, mime_type=mime_type, name=name)\n        buffer_view = None\n        if bpy.app.version >= (4, 5, 0):\n            gltf2_blender_set_real_uri(uri, export_settings)\n    else:\n        uri = None\n        buffer_view = gltf2_io_binary_data.BinaryData(data=data)\n\n    return gltf2_io.Image(\n        buffer_view=buffer_view,\n        extensions=None,\n        extras=None,\n        mime_type=mime_type,\n        name=name,\n        uri=uri\n    )\n\n    # export_user_extensions('gather_image_hook', export_settings, image, blender_shader_sockets)\n\n    return None\n\n\n@cached\ndef gather_texture(blender_image, export_settings):\n    image = gather_image(blender_image, export_settings)\n\n    if not image:\n        return None\n\n    texture_extensions = {}\n    is_hdr = blender_image and blender_image.file_format == \"HDR\"\n\n    if is_hdr:\n        ext_name = \"MOZ_texture_rgbe\"\n        texture_extensions[ext_name] = gltf2_io_extensions.Extension(\n            name=ext_name,\n            extension={\n                \"source\": image\n            },\n            required=False\n        )\n\n    # export_user_extensions('gather_texture_hook', export_settings, texture, blender_shader_sockets)\n\n    return gltf2_io.Texture(\n        extensions=texture_extensions,\n        extras=None,\n        name=None,\n        sampler=None,\n        source=None if is_hdr else image\n    )\n\n\ndef gather_properties(export_settings, object, component):\n    value = {}\n\n    for key in component.get_properties():\n        value[key] = gather_property(\n            export_settings, object, component, key)\n\n    if value:\n        return value\n    else:\n        # Hubs expects this to just be an empty dictionary, but the glTF exporter strips them out with its __fix_json function in gltf2_blender_export.py\n        # Add one dummy component per __fix_json call so that we end up with an empty dictionary.\n        if bpy.app.version < (4, 2, 0):\n            return {\"__empty_component_dummy\": None}\n        else:\n            return {\"__empty_component_dummy\": {\"__empty_component_dummy\": None}}\n\n\ndef gather_property(export_settings, blender_object, target, property_name):\n    property_definition = target.bl_rna.properties[property_name]\n    property_value = getattr(target, property_name)\n    isArray = getattr(property_definition, 'is_array', None)\n\n    if isArray and property_definition.is_array:\n        if property_definition.subtype.startswith('COLOR'):\n            return gather_color_property(\n                export_settings, blender_object, target, property_name, property_definition.subtype)\n        else:\n            return gather_vec_property(export_settings, blender_object, target, property_name)\n\n    elif (property_definition.bl_rna.identifier == 'PointerProperty'):\n        if type(property_value) is bpy.types.Object:\n            return gather_node_property(export_settings, blender_object, target, property_name)\n        elif type(property_value) is bpy.types.Material:\n            return gather_material_property(export_settings, blender_object, target, property_name)\n        elif type(property_value) is bpy.types.Image:\n            return gather_image_property(export_settings, blender_object, target, property_name)\n        elif type(property_value) is bpy.types.Texture:\n            return gather_texture_property(export_settings, blender_object, target, property_name)\n\n    return gltf2_blender_extras.__to_json_compatible(property_value)\n\n\ndef gather_array_property(export_settings, blender_object, target, property_name):\n    value = []\n\n    property_value = getattr(target, property_name)\n    for item in property_value:\n        item_value = gather_property(\n            export_settings, blender_object, item, None)\n        value.append(item_value)\n\n    return value\n\n\ndef gather_node_property(export_settings, blender_object, target, property_name):\n    blender_object = getattr(target, property_name)\n\n    if blender_object:\n        if bpy.app.version < (3, 2, 0):\n            node = gltf2_blender_gather_nodes.gather_node(\n                blender_object,\n                blender_object.library.name if blender_object.library else None,\n                blender_object.users_scene[0],\n                None,\n                export_settings\n            )\n        else:\n            vtree = export_settings['vtree']\n            vnode = vtree.nodes[next((uuid for uuid in vtree.nodes if (\n                vtree.nodes[uuid].blender_object == blender_object)), None)]\n            node = vnode.node or gltf2_blender_gather_nodes.gather_node(\n                vnode,\n                export_settings\n            )\n\n        return {\n            \"__mhc_link_type\": \"node\",\n            \"index\": node\n        }\n    else:\n        return None\n\n# PointerProperty doesn't support bones so for now we have to call this manually where using an object pointer\n\n\ndef gather_joint_property(export_settings, blender_object, target, property_name):\n    joint_name = getattr(target, property_name)\n    joint = blender_object.pose.bones[joint_name]\n\n    if joint:\n        if bpy.app.version < (3, 2, 0):\n            node = gltf2_blender_gather_joints.gather_joint(\n                blender_object,\n                joint,\n                export_settings\n            )\n        else:\n            vtree = export_settings['vtree']\n            vnode = vtree.nodes[next((uuid for uuid in vtree.nodes if (\n                vtree.nodes[uuid].blender_bone == joint)), None)]\n            node = vnode.node or gltf2_blender_gather_joints.gather_joint_vnode(\n                vnode,\n                export_settings\n            )\n\n        return {\n            \"__mhc_link_type\": \"node\",\n            \"index\": node\n        }\n    else:\n        return None\n\n\ndef gather_material_property(export_settings, blender_object, target, property_name):\n    blender_material = getattr(target, property_name)\n\n    if blender_material:\n        material = gltf2_blender_gather_materials.gather_material(\n            blender_material, export_settings)\n        return material\n    else:\n        return None\n\n\ndef gather_vec_property(export_settings, blender_object, target, property_name):\n    vec = getattr(target, property_name)\n\n    property_definition = target.bl_rna.properties[property_name]\n    unit = getattr(property_definition, 'unit', None)\n    subtype = getattr(property_definition, 'subtype', None)\n\n    # We export vectors with no unit and no subtype as arrays. This is not ideal, we should find a way\n    # to tag properties as Array/Object to decouple the Blender type from the export type.\n    if unit == 'NONE' and subtype == 'NONE':\n        out = []\n        for value in vec:\n            out.append(value)\n    else:\n        out = {\n            \"x\": vec[0],\n            \"y\": vec[1],\n        }\n\n        if len(vec) > 2:\n            out[\"z\"] = vec[2]\n        if len(vec) > 3:\n            out[\"w\"] = vec[3]\n\n    return out\n\n\ndef gather_image_property(export_settings, blender_object, target, property_name):\n    blender_image = getattr(target, property_name)\n    image = gather_image(blender_image, export_settings)\n    if image:\n        return {\n            \"__mhc_link_type\": \"image\",\n            \"index\": image\n        }\n    else:\n        return None\n\n\ndef gather_texture_property(export_settings, blender_object, target, property_name):\n    blender_image = getattr(target, property_name)\n    texture = gather_texture(blender_image, export_settings)\n    if texture:\n        return {\n            \"__mhc_link_type\": \"texture\",\n            \"index\": texture\n        }\n    else:\n        return None\n\n\ndef srgb2lin(s):\n    if s <= 0.0404482362771082:\n        lin = s / 12.92\n    else:\n        lin = pow(((s + 0.055) / 1.055), 2.4)\n    return lin\n\n\ndef lin2srgb(lin):\n    if lin > 0.0031308:\n        s = 1.055 * (pow(lin, (1.0 / 2.4))) - 0.055\n    else:\n        s = 12.92 * lin\n    return s\n\n\ndef gather_color_property(export_settings, object, component, property_name, color_type):\n    c = list(getattr(component, property_name))\n\n    # Blender stores colors in linear space for subtype COLOR and sRGB for COLOR_GAMMA\n    # Hubs expects colors in the glTF components to be in sRGB so we convert them here if needed.\n    if color_type == \"COLOR\":\n        c[0] = lin2srgb(c[0])\n        c[1] = lin2srgb(c[1])\n        c[2] = lin2srgb(c[2])\n\n    c[0] = max(0, min(int(c[0] * 256.0), 255))\n    c[1] = max(0, min(int(c[1] * 256.0), 255))\n    c[2] = max(0, min(int(c[2] * 256.0), 255))\n\n    return \"#{0:02x}{1:02x}{2:02x}\".format(c[0], c[1], c[2], 255)\n\n\n# MOZ_lightmap extension data\n\n\ndef gather_lightmap_texture_info(blender_material, export_settings):\n    nodes = blender_material.node_tree.nodes\n    lightmap_node = next(\n        (n for n in nodes if isinstance(n, MozLightmapNode)), None)\n\n    if not lightmap_node:\n        return\n\n    texture_socket = lightmap_node.inputs.get(\"Lightmap\")\n    intensity = lightmap_node.intensity\n\n    # TODO this assumes a single image directly connected to the socket\n    blender_image = texture_socket.links[0].from_node.image\n    texture = gather_texture(blender_image, export_settings)\n    socket = lightmap_node.inputs.get(\"Lightmap\") if bpy.app.version < (4, 1, 0) \\\n        else gltf2_blender_search_node_tree.NodeSocket(texture_socket, blender_material)\n    tex_attributes = gltf2_blender_gather_texture_info.__gather_texture_transform_and_tex_coord(\n        socket, export_settings)\n    tex_transform, tex_coord = tex_attributes[:2]\n    texture_info = gltf2_io.TextureInfo(\n        extensions=gltf2_blender_gather_texture_info.__gather_extensions(\n            tex_transform, export_settings),\n        extras=None,\n        index=texture,\n        tex_coord=tex_coord\n    )\n\n    if not texture_info:\n        return\n\n    return {\n        \"intensity\": intensity,\n        'extensions': texture_info.extensions,\n        'extras': texture_info.extras,\n        \"index\": texture_info.index,\n        \"texCoord\": texture_info.tex_coord\n    }\n\n\ndef import_image(gltf, gltf_texture):\n    texture_extensions = gltf_texture.extensions\n    if texture_extensions and texture_extensions.get('MOZ_texture_rgbe'):\n        source = gltf_texture.extensions['MOZ_texture_rgbe']['source']\n    else:\n        source = gltf_texture.source\n\n    BlenderImage.create(\n        gltf, source)\n    pyimg = gltf.data.images[source]\n    blender_image_name = pyimg.blender_image_name\n    blender_image = bpy.data.images[blender_image_name]\n    if pyimg.mime_type == \"image/vnd.radiance\":\n        if bpy.app.version < (4, 0, 0):\n            blender_image.colorspace_settings.name = \"Linear\"\n        else:\n            blender_image.colorspace_settings.name = \"Linear Rec.709\"\n\n    return blender_image_name, source\n\n\ndef import_all_textures(gltf):\n    global imported_textures\n    imported_textures.clear()\n\n    if not gltf.data.textures:\n        return\n\n    for index, gltf_texture in enumerate(gltf.data.textures):\n        blender_image_name, source = import_image(gltf, gltf_texture)\n        imported_textures[index] = blender_image_name\n\n\ndef import_component(component_name, blender_object):\n    from ..components.utils import add_component, has_component\n    from ..components.components_registry import get_component_by_name\n    component_class = get_component_by_name(component_name)\n    if component_class:\n        if not has_component(blender_object, component_name):\n            add_component(blender_object, component_name)\n\n    return getattr(blender_object, component_class.get_id())\n\n\ndef set_color_from_hex(blender_component, property_name, hexcolor):\n    hexcolor = hexcolor.lstrip('#')\n    rgb_int = [int(hexcolor[i:i + 2], 16) for i in (0, 2, 4)]\n\n    for x, value in enumerate(rgb_int):\n        rgb_float = value / 255 if value > 0 else 0\n        if blender_component.bl_rna.properties[property_name].subtype == 'COLOR':\n            # Blender stores colors in linear space for subtype COLOR and sRGB for COLOR_GAMMA\n            # Colors in the glTF components are in sRGB so we convert them here if needed.\n            rgb_float = srgb2lin(rgb_float)\n        getattr(blender_component, property_name)[x] = rgb_float\n\n\ndef assign_property(vnodes, blender_component, property_name, property_value):\n    if isinstance(property_value, dict):\n        if property_value.get('__mhc_link_type'):\n            if len(property_value) == 2:\n                if property_value['__mhc_link_type'] == \"node\":\n                    try:\n                        setattr(blender_component, property_name,\n                                vnodes[property_value['index']].blender_object)\n                    except AttributeError:\n                        # Assume that the target is a bone\n                        bone_vnode = vnodes[property_value['index']]\n                        armature_vnode = vnodes[bone_vnode.bone_arma]\n                        setattr(blender_component, property_name,\n                                armature_vnode.blender_object)\n                        setattr(blender_component, \"bone\",\n                                bone_vnode.blender_bone_name)\n                elif property_value['__mhc_link_type'] == \"texture\":\n                    global imported_textures\n                    blender_image_name = imported_textures[property_value['index']]\n                    blender_image = bpy.data.images[blender_image_name]\n                    setattr(blender_component, property_name, blender_image)\n\n        else:\n            blender_subcomponent = getattr(blender_component, property_name)\n            for x, subproperty_value in enumerate(property_value.values()):\n                blender_subcomponent[x] = subproperty_value\n\n    elif re.fullmatch(\"#[0-9a-fA-F]*\", str(property_value)):\n        set_color_from_hex(blender_component, property_name, property_value)\n\n    else:\n        if not hasattr(blender_component, property_name):\n            return\n        setattr(blender_component, property_name, property_value)\n"
  },
  {
    "path": "addons/io_hubs_addon/nodes/__init__.py",
    "content": "from . import (lightmap)\n\n\ndef register():\n    lightmap.register()\n\n\ndef unregister():\n    lightmap.unregister()\n"
  },
  {
    "path": "addons/io_hubs_addon/nodes/lightmap.py",
    "content": "import bpy\n\nimport nodeitems_utils\nfrom nodeitems_utils import NodeCategory, NodeItem\nfrom bpy.types import Node\n\n\nclass MozCategory(NodeCategory):\n    @classmethod\n    def poll(cls, context):\n        return context.space_data.tree_type == 'ShaderNodeTree'\n\n\nnode_categories = [\n    MozCategory(\"MOZ_NODES\", \"Hubs\", items=[\n        NodeItem(\"moz_lightmap.node\")\n    ]),\n]\n\n\ndef add_node_menu_blender4(self, context):\n    self.layout.menu(\"NODE_MT_moz_nodes\")\n\n\nclass NODE_MT_moz_nodes(bpy.types.Menu):\n    \"\"\"Add node menu for Blender 4.x\"\"\"\n    bl_label = \"Hubs\"\n    bl_idname = \"NODE_MT_moz_nodes\"\n\n    def draw(self, context):\n        layout = self.layout\n        op = layout.operator(\"node.add_node\", text=\"MOZ_lightmap settings\")\n        op.type = \"moz_lightmap.node\"\n        op.use_transform = True\n\n\nclass MozLightmapNode(Node):\n    \"\"\"MOZ_lightmap settings node\"\"\"\n    bl_idname = 'moz_lightmap.node'\n    bl_label = 'MOZ_lightmap settings'\n    bl_icon = 'LIGHT'\n    bl_width_min = 216.3\n    bl_width_max = 330.0\n\n    intensity: bpy.props.FloatProperty(\n        name=\"Intensity\", soft_min=0, soft_max=1, default=1)\n\n    def init(self, context):\n        lightmap = self.inputs.new('NodeSocketColor', \"Lightmap\")\n        lightmap.hide_value = True\n\n        self.width = 216.3\n\n    @classmethod\n    def poll(cls, ntree):\n        return ntree.bl_idname == 'ShaderNodeTree'\n\n    def draw_buttons(self, context, layout):\n        layout.prop(self, \"intensity\")\n\n    def draw_label(self):\n        return \"MOZ_lightmap\"\n\n\ndef register_blender_4():\n    bpy.utils.register_class(NODE_MT_moz_nodes)\n    bpy.types.NODE_MT_shader_node_add_all.append(add_node_menu_blender4)\n    bpy.utils.register_class(MozLightmapNode)\n\n\ndef unregister_blender_4():\n    bpy.types.NODE_MT_shader_node_add_all.remove(add_node_menu_blender4)\n    bpy.utils.unregister_class(NODE_MT_moz_nodes)\n    bpy.utils.unregister_class(MozLightmapNode)\n\n\ndef register_blender_3():\n    bpy.utils.register_class(MozLightmapNode)\n    nodeitems_utils.register_node_categories(\"MOZ_NODES\", node_categories)\n\n\ndef unregister_blender_3():\n    bpy.utils.unregister_class(MozLightmapNode)\n    nodeitems_utils.unregister_node_categories(\"MOZ_NODES\")\n\n\ndef register():\n    if bpy.app.version < (4, 0, 0):\n        register_blender_3()\n    else:\n        register_blender_4()\n\n\ndef unregister():\n    if bpy.app.version < (4, 0, 0):\n        unregister_blender_3()\n    else:\n        unregister_blender_4()\n"
  },
  {
    "path": "addons/io_hubs_addon/preferences.py",
    "content": "import bpy\nfrom bpy.types import AddonPreferences, Context\nfrom bpy.props import IntProperty, StringProperty, EnumProperty, BoolProperty, PointerProperty, CollectionProperty\nfrom .utils import get_addon_package, is_module_available, get_browser_profile_directory\nimport platform\nfrom os.path import join, dirname, realpath\n\nEXPORT_TMP_FILE_NAME = \"__hubs_tmp_scene_.glb\"\nEXPORT_TMP_SCREENSHOT_FILE_NAME = \"__hubs_tmp_screenshot_\"\n\n\ndef get_addon_pref(context):\n    addon_package = get_addon_package()\n    return context.preferences.addons[addon_package].preferences\n\n\ndef get_recast_lib_path():\n    recast_lib = join(dirname(realpath(__file__)), \"bin\", \"recast\")\n\n    file_name = None\n    if platform.system() == 'Windows':\n        file_name = \"RecastBlenderAddon.dll\"\n    elif platform.system() == 'Darwin':\n        file_name = \"libRecastBlenderAddon.dylib\"\n    else:\n        file_name = \"libRecastBlenderAddon.so\"\n\n    return join(recast_lib, file_name)\n\n\nclass DepsProperty(bpy.types.PropertyGroup):\n    name: StringProperty(default=\" \")\n    version: StringProperty(default=\"\")\n\n\nclass InstallDepsOperator(bpy.types.Operator):\n    bl_idname = \"pref.hubs_prefs_install_dep\"\n    bl_label = \"Install a python dependency through pip\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    dep_config: PointerProperty(type=DepsProperty)\n\n    def execute(self, context):\n        import subprocess\n        import sys\n\n        result = subprocess.run([sys.executable, '-m', 'ensurepip'],\n                                capture_output=True, text=True, input=\"y\")\n        if not is_module_available('pip', local_dependency=False):\n            print(result.stderr)\n            report_messages = [\n                f\"Installing {self.dep_config.name} has failed.  Pip is not present and can't be installed\",\n                \"See the terminal for more details.  Windows users can access their terminal by going to Window ‣ Toggle System Console\"\n            ]\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string='\\n\\n'.join(report_messages))\n            return {'CANCELLED'}\n        if result.returncode != 0:\n            print(\"ensurepip failed but pip appears to be present anyway.  Continuing on.\")\n\n        result = subprocess.run(\n            [sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip'],\n            capture_output=True, text=True, input=\"y\")\n        if result.returncode != 0:\n            print(\"Upgrading pip has failed.  Continuing on.\")\n\n        from .utils import get_or_create_deps_path\n        dep = self.dep_config.name\n        if self.dep_config.version:\n            dep = f'{self.dep_config.name}=={self.dep_config.version}'\n\n        result = subprocess.run(\n            [sys.executable, '-m', 'pip', 'install', '--upgrade', dep,\n             '-t', get_or_create_deps_path(self.dep_config.name)],\n            capture_output=True, text=True, input=\"y\")\n        if not is_module_available(self.dep_config.name):\n            report_messages = [\n                f\"Installing {self.dep_config.name} has failed.\",\n                \"See the terminal for more details.  Windows users can access their terminal by going to Window ‣ Toggle System Console\"\n            ]\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string='\\n\\n'.join(report_messages))\n            return {'CANCELLED'}\n        else:\n            # Installing packages with pip always seems to have a successful return code,\n            # regardless of whether any errors were encountered.\n            # So don't bother trying to notify the user of any potential errors.\n            # We assume that since the module is there, everything is fine.\n            # If needed, change capture_output to False and check the terminal for any errors.\n            print(f\"{self.dep_config.name} has been installed successfully.\")\n            report_messages = [f\"{self.dep_config.name} has been installed successfully.\"]\n            bpy.ops.wm.hubs_report_viewer('INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n                                          report_string='\\n\\n'.join(report_messages))\n            return {'FINISHED'}\n\n\nclass UninstallDepsOperator(bpy.types.Operator):\n    bl_idname = \"pref.hubs_prefs_uninstall_dep\"\n    bl_label = \"Uninstall a python dependency through pip\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    dep_config: PointerProperty(type=DepsProperty)\n\n    def execute(self, context):\n        from .utils import get_or_create_deps_path\n        import shutil\n        shutil.rmtree(get_or_create_deps_path(self.dep_config.name))\n\n        return {'FINISHED'}\n\n\nclass DeleteProfileOperator(bpy.types.Operator):\n    bl_idname = \"pref.hubs_prefs_remove_profile\"\n    bl_label = \"Delete\"\n    bl_description = \"Delete Browser profile\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    browser: StringProperty()\n\n    @classmethod\n    def poll(cls, context: Context):\n        if hasattr(context, \"prefs\"):\n            prefs = getattr(context, 'prefs')\n            path = get_browser_profile_directory(prefs.browser)\n            import os\n            return os.path.exists(path)\n\n        return False\n\n    def execute(self, context):\n        path = get_browser_profile_directory(self.browser)\n        import os\n        if os.path.exists(path):\n            import shutil\n            shutil.rmtree(path)\n\n        return {'FINISHED'}\n\n\ndef set_prefs_dirty(self, context):\n    context.preferences.is_dirty = True\n\n\nclass HubsUserComponentsPath(bpy.types.PropertyGroup):\n    name: StringProperty(\n        name='User components path entry name',\n        description='An optional, user defined label to allow quick discernment between different user component definition directories.',\n        update=set_prefs_dirty)\n    path: StringProperty(\n        name='User components path path',\n        description='The path to a user defined component definitions directory. You can copy external components here and they will be loaded automatically.',\n        subtype='FILE_PATH',\n        update=set_prefs_dirty\n    )\n\n\nclass HubsUserComponentsPathAdd(bpy.types.Operator):\n    bl_idname = \"hubs_preferences.add_user_components_path\"\n    bl_label = \"Add user components path\"\n    bl_description = \"Adds a new component path entry\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    def execute(self, context):\n        addon_prefs = addon_prefs = get_addon_pref(bpy.context)\n        paths = addon_prefs.user_components_paths\n        paths.add()\n\n        context.preferences.is_dirty = True\n\n        return {'FINISHED'}\n\n\nclass HubsUserComponentsPathRemove(bpy.types.Operator):\n    bl_idname = \"hubs_preferences.remove_user_components_path\"\n    bl_label = \"Remove user components path entry\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    index: bpy.props.IntProperty(name=\"User Components Path Index\", default=0)\n\n    def execute(self, context):\n        addon_prefs = addon_prefs = get_addon_pref(bpy.context)\n        paths = addon_prefs.user_components_paths\n        paths.remove(self.index)\n\n        context.preferences.is_dirty = True\n\n        return {'FINISHED'}\n\n\ndef draw_user_modules_path_panel(context, layout, prefs):\n    box = layout.box()\n    box.row().label(text=\"Additional components directories:\")\n\n    dirs_layout = box.row()\n\n    entries = prefs.user_components_paths\n\n    if len(entries) == 0:\n        dirs_layout.operator(HubsUserComponentsPathAdd.bl_idname,\n                             text=\"Add\", icon='ADD')\n        return\n\n    dirs_layout.use_property_split = False\n    dirs_layout.use_property_decorate = False\n\n    box = dirs_layout.box()\n    split = box.split(factor=0.35)\n    name_col = split.column()\n    path_col = split.column()\n\n    row = name_col.row(align=True)  # Padding\n    row.separator()\n    row.label(text=\"Name\")\n\n    row = path_col.row(align=True)  # Padding\n    row.separator()\n    row.label(text=\"Path\")\n\n    row.operator(HubsUserComponentsPathAdd.bl_idname,\n                 text=\"\", icon='ADD', emboss=False)\n\n    for i, entry in enumerate(entries):\n        row = name_col.row()\n        row.alert = not entry.name\n        row.prop(entry, \"name\", text=\"\")\n\n        row = path_col.row()\n        subrow = row.row()\n        subrow.alert = not entry.path\n        subrow.prop(entry, \"path\", text=\"\")\n        row.operator(HubsUserComponentsPathRemove.bl_idname,\n                     text=\"\", icon='X', emboss=False).index = i\n\n\nclass HubsPreferences(AddonPreferences):\n    bl_idname = __package__\n\n    row_length: IntProperty(\n        name=\"Add Component Menu Row Length\",\n        description=\"Allows you to control how many categories are added to a row before it starts on the next row. Set to 0 to have it all on one row\",\n        default=4,\n        min=0,\n    )\n\n    recast_lib_path: StringProperty(\n        name='Recast library path',\n        subtype='FILE_PATH',\n        default=get_recast_lib_path()\n    )\n\n    viewer_available: BoolProperty()\n\n    browser: EnumProperty(\n        name=\"Choose a browser\", description=\"Type\",\n        items=[(\"Firefox\", \"Firefox\", \"Use Firefox as the viewer browser\"),\n               (\"Chrome\", \"Chrome\", \"Use Chrome as the viewer browser\")],\n        default=\"Firefox\")\n\n    override_firefox_path: BoolProperty(\n        name=\"Override Firefox executable path\", description=\"Override Firefox executable path\", default=False)\n    firefox_path: StringProperty(\n        name=\"Firefox executable path\", description=\"Binary path\", subtype='FILE_PATH')\n    override_chrome_path: BoolProperty(\n        name=\"Override Chrome executable path\", description=\"Override Chrome executable path\", default=False)\n    chrome_path: StringProperty(\n        name=\"Chrome executable path\", description=\"Binary path\", subtype='FILE_PATH')\n\n    user_components_paths: CollectionProperty(type=HubsUserComponentsPath)\n\n    def draw(self, context):\n        layout = self.layout\n        box = layout.box()\n\n        box.row().prop(self, \"row_length\")\n        box.row().prop(self, \"recast_lib_path\")\n\n        draw_user_modules_path_panel(context, layout, self)\n        box = layout.box()\n        box.label(text=\"Scene debugger configuration\")\n\n        modules_available = is_module_available(\"selenium\")\n        if modules_available:\n            browser_box = box.box()\n            row = browser_box.row()\n            row.prop(self, \"browser\")\n            row = browser_box.row()\n            col = row.column()\n            col.label(text=f'Delete {self.browser} profile')\n            col = row.column()\n            col.context_pointer_set(\"prefs\", self)\n            op = col.operator(DeleteProfileOperator.bl_idname)\n            row = browser_box.row()\n            row.label(\n                text=\"This will only delete the Hubs related profile, not your local browser profile\")\n            op.browser = self.browser\n            if self.browser == \"Firefox\":\n                row = browser_box.row()\n                row.prop(self, \"override_firefox_path\")\n                if self.override_firefox_path:\n                    row = browser_box.row()\n                    row.label(\n                        text=\"In some cases the browser binary might not be located automatically, in those cases you'll need to specify the binary location manually below\")\n                    row = browser_box.row()\n                    row.alert = True\n                    row.label(\n                        text=\"You don't need to set a path below unless the binary cannot be located automatically.\")\n                    row = browser_box.row()\n                    row.prop(self, \"firefox_path\",)\n            elif self.browser == \"Chrome\":\n                row = browser_box.row()\n                row.prop(self, \"override_chrome_path\")\n                if self.override_chrome_path:\n                    row = browser_box.row()\n                    row.label(\n                        text=\"In some cases the browser binary might not be located automatically, in those cases you'll need to specify the binary location manually below\")\n                    row = browser_box.row()\n                    row.alert = True\n                    row.label(\n                        text=\"You don't need to set a path below unless the binary cannot be located automatically.\")\n                    row = browser_box.row()\n                    row.prop(self, \"chrome_path\")\n\n        modules_box = box.box()\n        row = modules_box.row()\n        row.alert = not modules_available\n        row.label(\n            text=\"Modules found.\"\n            if modules_available else\n            \"Selenium module not found. These modules are required to run the viewer\")\n        row = modules_box.row()\n        if modules_available:\n            op = row.operator(UninstallDepsOperator.bl_idname,\n                              text=\"Uninstall dependencies (selenium)\")\n            op.dep_config.name = \"selenium\"\n        else:\n            op = row.operator(InstallDepsOperator.bl_idname,\n                              text=\"Install dependencies (selenium)\")\n            op.dep_config.name = \"selenium\"\n            op.dep_config.version = \"4.15.2\"\n\n\ndef register():\n    bpy.utils.register_class(HubsUserComponentsPath)\n    bpy.utils.register_class(HubsUserComponentsPathAdd)\n    bpy.utils.register_class(HubsUserComponentsPathRemove)\n    bpy.utils.register_class(DepsProperty)\n    bpy.utils.register_class(HubsPreferences)\n    bpy.utils.register_class(InstallDepsOperator)\n    bpy.utils.register_class(UninstallDepsOperator)\n    bpy.utils.register_class(DeleteProfileOperator)\n\n\ndef unregister():\n    bpy.utils.unregister_class(DeleteProfileOperator)\n    bpy.utils.unregister_class(UninstallDepsOperator)\n    bpy.utils.unregister_class(InstallDepsOperator)\n    bpy.utils.unregister_class(HubsPreferences)\n    bpy.utils.unregister_class(DepsProperty)\n    bpy.utils.unregister_class(HubsUserComponentsPathRemove)\n    bpy.utils.unregister_class(HubsUserComponentsPathAdd)\n    bpy.utils.unregister_class(HubsUserComponentsPath)\n"
  },
  {
    "path": "addons/io_hubs_addon/third_party/__init__.py",
    "content": "from . import (recast)\n\n\ndef register():\n    recast.register()\n\n\ndef unregister():\n    recast.unregister()\n"
  },
  {
    "path": "addons/io_hubs_addon/third_party/recast.py",
    "content": "# ***** BEGIN GPL LICENSE BLOCK *****\n#\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\tSee the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software Foundation,\n# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n#\n# ***** END GPL LICENCE BLOCK *****\n\nimport os\nimport traceback\nimport bpy\n\nfrom bpy.props import IntProperty, FloatProperty, EnumProperty, PointerProperty, FloatVectorProperty, BoolProperty\nfrom bpy.types import Panel, PropertyGroup\nfrom mathutils import Matrix, Vector\nfrom math import radians\nfrom ..preferences import get_addon_pref\nfrom ..components.utils import add_component, get_objects_with_component, has_component, is_linked\n\nimport ctypes\nimport ctypes.util\nfrom ctypes import c_int, c_float\n\nimport bmesh\n\n\nCELL_SIZE_DEFAULT = 0.166\nCELL_HEIGHT_DEFAULT = 0.10\nSLOPE_MAX_DEFAULT = radians(45)\nCLIMB_MAX_DEFAULT = 0.3\nAGENT_HEIGHT_DEFAULT = 1.70\nAGENT_RADIUS_DEFAULT = 0.5\nEDGE_MAX_LENGTH = 12.0\nEDGE_MAX_ERROR = 1.0\nREGION_MIN_SIZE = 4.0\nREGION_MERGE_SIZE = 20.0\nVERTS_PER_POLY_DEFAULT = 3\nSAMPLE_DIST_DEFAULT = 13.0\nSAMPLE_MAX_ERROR_DEFAULT = 1.0\nPARTITIONING_DEFAULT = 'WATERSHED'\nCOLOR_DEFAULT = (0.0, 1.0, 0.0, 1.0)\nAUTO_CELL_DEFAULT = True\n\n# x -> x'\n# y -> -z'\n# z -> y'\n\n\ndef swap(vec):\n    return Vector([vec.x, vec.z, -vec.y])\n\n\ndef reswap(vec):\n    return Vector([vec.x, -vec.z, vec.y])\n\n\nclass RecastData(ctypes.Structure):\n    _fields_ = [(\"cellsize\", c_float),\n                (\"cellheight\", c_float),\n                (\"agentmaxslope\", c_float),\n                (\"agentmaxclimb\", c_float),\n                (\"agentheight\", c_float),\n                (\"agentradius\", c_float),\n                (\"edgemaxlen\", c_float),\n                (\"edgemaxerror\", c_float),\n                (\"regionminsize\", c_float),\n                (\"regionmergesize\", c_float),\n                (\"vertsperpoly\", c_int),\n                (\"detailsampledist\", c_float),\n                (\"detailsamplemaxerror\", c_float),\n                (\"partitioning\", ctypes.c_short),\n                (\"pad1\", ctypes.c_short)]\n\n\nclass recast_polyMesh(ctypes.Structure):\n    _fields_ = [(\"verts\", ctypes.POINTER(ctypes.c_ushort)),  # The mesh vertices. [Form: (x, y, z) * #nverts]\n                (\"polys\", ctypes.POINTER(ctypes.c_ushort)),  # Polygon and neighbor data. [Length: #maxpolys * 2 * #nvp]\n                # The region id assigned to each polygon. [Length: #maxpolys]\n                (\"regs\", ctypes.POINTER(ctypes.c_ushort)),\n                # The user defined flags for each polygon. [Length: #maxpolys]\n                (\"flags\", ctypes.POINTER(ctypes.c_ushort)),\n                (\"areas\", ctypes.POINTER(ctypes.c_ubyte)),  # The area id assigned to each polygon. [Length: #maxpolys]\n                (\"nverts\", c_int),                          # The number of vertices.\n                (\"npolys\", c_int),                          # The number of polygons.\n                (\"maxpolys\", c_int),                        # The number of allocated polygons.\n                (\"nvp\", c_int),                             # The maximum number of vertices per polygon.\n                (\"bmin\", c_float * 3),                        # The minimum bounds in world space. [(x, y, z)]\n                (\"bmax\", c_float * 3),                        # The maximum bounds in world space. [(x, y, z)]\n                (\"cs\", c_float),                            # The size of each cell. (On the xz-plane.)\n                (\"ch\", c_float),                            # The height of each cell. (The minimum increment along the y-axis.)\n                # The AABB border size used to generate the source data from which the mesh was derived.\n                (\"borderSize\", c_int),\n                (\"maxEdgeError\", c_float)]                 # The max error of the polygon edges in the mesh.\n\n\nclass recast_polyMeshDetail(ctypes.Structure):\n    _fields_ = [(\"meshes\", ctypes.POINTER(ctypes.c_uint)),  # The sub-mesh data. [Size: 4*#nmeshes]\n                (\"verts\", ctypes.POINTER(ctypes.c_float)),  # The mesh vertices. [Size: 3*#nverts]\n                (\"tris\", ctypes.POINTER(ctypes.c_ubyte)),  # The mesh triangles. [Size: 4*#ntris]\n                (\"nmeshes\", c_int),                        # The number of sub-meshes defined by #meshes.\n                (\"nverts\", c_int),                         # The number of vertices in #verts.\n                (\"ntris\", c_int)]                         # The number of triangles in #tris.\n\n\nclass recast_polyMesh_holder(ctypes.Structure):\n    _fields_ = [(\"pmesh\", ctypes.POINTER(recast_polyMesh))]\n\n\nclass recast_polyMeshDetail_holder(ctypes.Structure):\n    _fields_ = [(\"dmesh\", ctypes.POINTER(recast_polyMeshDetail))]\n\n\ndef recastDataFromBlender(scene):\n    recastData = RecastData()\n    recastData.cellsize = scene.recast_navmesh.cell_size\n    recastData.cellheight = scene.recast_navmesh.cell_height\n    recastData.agentmaxslope = scene.recast_navmesh.slope_max\n    recastData.agentmaxclimb = scene.recast_navmesh.climb_max\n    recastData.agentheight = scene.recast_navmesh.agent_height\n    recastData.agentradius = scene.recast_navmesh.agent_radius\n    recastData.edgemaxlen = scene.recast_navmesh.edge_max_len\n    recastData.edgemaxerror = scene.recast_navmesh.edge_max_error\n    recastData.regionminsize = scene.recast_navmesh.region_min_size\n    recastData.regionmergesize = scene.recast_navmesh.region_merge_size\n    recastData.vertsperpoly = scene.recast_navmesh.verts_per_poly\n    recastData.detailsampledist = scene.recast_navmesh.sample_dist\n    recastData.detailsamplemaxerror = scene.recast_navmesh.sample_max_error\n    recastData.partitioning = 0\n    if scene.recast_navmesh.partitioning == \"WATERSHED\":\n        recastData.partitioning = 0\n    if scene.recast_navmesh.partitioning == \"MONOTONE\":\n        recastData.partitioning = 1\n    if scene.recast_navmesh.partitioning == \"LAYERS\":\n        recastData.partitioning = 2\n    recastData.pad1 = 0\n    return recastData\n\n\ndef object_has_collection(ob, groupName):\n    for group in ob.users_collection:\n        if group.name == groupName:\n            return True\n    return False\n\n\ndef objects_from_collection(allObjects, collectionName):\n    objects = []\n    for ob in allObjects:\n        if object_has_collection(ob, collectionName):\n            objects.append(ob)\n    return objects\n\n# take care of applying modiffiers and triangulation\n\n\ndef extractTriangulatedInputMeshList(objects, matrix, verts_offset, verts, tris, depsgraph):\n    for ob in objects:\n        if ob.instance_type == 'COLLECTION':\n            subobjects = objects_from_collection(bpy.data.objects, ob.name)\n            parent_matrix = matrix @ ob.matrix_world\n            verts_offset = extractTriangulatedInputMeshList(\n                subobjects, parent_matrix, verts_offset, verts, tris, depsgraph)\n\n        if ob.type != 'MESH':\n            continue\n\n        bm = bmesh.new()\n        bm.from_object(ob, depsgraph)\n        real_matrix_world = matrix @ ob.matrix_world\n        bmesh.ops.transform(bm, matrix=real_matrix_world, verts=bm.verts)\n\n        tm = bmesh.ops.triangulate(bm, faces=bm.faces[:])\n        # tm['faces']   # but it seems that it modify bmesh anyway\n\n        bm.verts.ensure_lookup_table()\n        bm.faces.ensure_lookup_table()\n\n        for v in bm.verts:\n            vp = swap(v.co)  # swap from blender coordinates to recast coordinates\n            verts.append(vp.x)\n            verts.append(vp.y)\n            verts.append(vp.z)\n\n        for f in bm.faces:\n            for i in f.verts:  # After triangulation it will always be 3 vertexes\n                tris.append(i.index + verts_offset)\n\n        verts_offset += len(bm.verts)\n        bm.free()\n    return verts_offset\n\n# take care of applying modiffiers and triangulation\n\n\ndef extractTriangulatedInputMesh(context):\n    depsgraph = context.evaluated_depsgraph_get()\n    verts = []\n    tris = []\n    list = context.selected_objects\n    extractTriangulatedInputMeshList(list, Matrix(), 0, verts, tris, depsgraph)\n    return (verts, tris)\n\n\ndef createMesh(context, dmesh_holder, obj=None):\n    scene = context.scene\n    if not obj:\n        mesh = bpy.data.meshes.new(\"navmesh\")  # add a new mesh\n        obj = bpy.data.objects.new(\"navmesh\", mesh)  # add a new object using the mesh\n        scene.collection.objects.link(obj)\n        from ..components.definitions.nav_mesh import NavMesh\n        add_component(obj, NavMesh.get_name())\n    else:\n        mesh = obj.data\n\n    bpy.ops.object.select_all(action='DESELECT')\n    context.view_layer.objects.active = obj  # set as the active object in the scene\n    obj.select_set(True)  # select object\n    bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)\n\n    bm = bmesh.new()\n    nverts = (int)(dmesh_holder.dmesh.contents.nverts)\n    for i in range(nverts):\n        x = dmesh_holder.dmesh.contents.verts[i * 3 + 0]\n        y = dmesh_holder.dmesh.contents.verts[i * 3 + 1]\n        z = dmesh_holder.dmesh.contents.verts[i * 3 + 2]\n        v = reswap(Vector([x, y, z]))\n        bm.verts.new(v)  # add a new vert\n    bm.verts.ensure_lookup_table()\n\n    nmeshes = (int)(dmesh_holder.dmesh.contents.nmeshes)\n    for j in range(nmeshes):\n        baseVerts = dmesh_holder.dmesh.contents.meshes[j * 4 + 0]\n        meshNVerts = dmesh_holder.dmesh.contents.meshes[j * 4 + 1]\n        baseTri = dmesh_holder.dmesh.contents.meshes[j * 4 + 2]\n        meshNTris = dmesh_holder.dmesh.contents.meshes[j * 4 + 3]\n        meshVertsList = []\n        # if len(meshVertsList) >= 3:\n        #    bm.faces.new(meshVertsList)\n\n        for i in range(meshNTris):\n            i1 = dmesh_holder.dmesh.contents.tris[(baseTri + i) * 4 + 0] + baseVerts\n            i2 = dmesh_holder.dmesh.contents.tris[(baseTri + i) * 4 + 1] + baseVerts\n            i3 = dmesh_holder.dmesh.contents.tris[(baseTri + i) * 4 + 2] + baseVerts\n            flags = dmesh_holder.dmesh.contents.tris[(baseTri + i) * 4 + 3]\n            # print(\"face = (%i, %i, %i)\" % (i1, i2, i3))\n            bm.faces.new((bm.verts[i1], bm.verts[i2], bm.verts[i3]))  # add a new vert\n\n    # Recast: The vertex indices in the triangle array are local to the sub-mesh, not global. To translate into an global index in the vertices array, the values must be offset by the sub-mesh's base vertex index.\n    # ntris = (int)(dmesh_holder.dmesh.contents.ntris)\n    # for i in range(ntris):\n    #    i1 = dmesh_holder.dmesh.contents.tris[i*3+0]\n    #    i2 = dmesh_holder.dmesh.contents.tris[i*3+1]\n    #    i3 = dmesh_holder.dmesh.contents.tris[i*3+2]\n    #    print(\"face[%i] = (%i, %i, %i)\" % (i, i1, i2, i3))\n    #    bm.faces.new((bm.verts[i1], bm.verts[i2], bm.verts[i3]))  # add a new vert\n\n    bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.00001)\n\n    # make the bmesh the object's mesh\n    bm.to_mesh(mesh)\n    bm.free()  # always do this when finished\n\n    # Assign nav mesh color\n    mat = bpy.data.materials.get(\"Navmesh Material\")\n    if mat is None:\n        mat = bpy.data.materials.new(name=\"Navmesh Material\")\n        mat.diffuse_color = context.scene.recast_navmesh.color\n\n    if mesh.materials:\n        mesh.materials[0] = mat\n    else:\n        mesh.materials.append(mat)\n\n\ndef get_auto_cell_size(context):\n    bounding_boxes = []\n    for obj in context.selected_objects:\n        if obj.type == 'MESH':\n            bbox = [obj.matrix_world @ Vector(point) for point in obj.bound_box]\n            bounding_boxes.extend(bbox)\n\n    bound_box_x_coords = []\n    bound_box_y_coords = []\n    for point in bounding_boxes:\n        bound_box_x_coords.append(point.x)\n        bound_box_y_coords.append(point.y)\n\n    size_x = abs(min(bound_box_x_coords) - max(bound_box_x_coords))\n    size_y = abs(min(bound_box_y_coords) - max(bound_box_y_coords))\n    area = size_x * size_y\n\n    return pow(area, 1 / 3) / 50\n\n\nclass RecastNavMeshResetOperator(bpy.types.Operator):\n    bl_idname = \"recast.reset_navigation_mesh\"\n    bl_label = \"Reset\"\n    bl_description = \"Reset navigation mesh properties to default.\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context):\n        if is_linked(context.scene):\n            if bpy.app.version >= (3, 0, 0):\n                cls.poll_message_set(\"Cannot reset navigation mesh settings when in a linked scene\")\n            return False\n\n        return True\n\n    def execute(self, context):\n        scene = context.scene\n\n        scene.recast_navmesh.cell_size = CELL_SIZE_DEFAULT\n        scene.recast_navmesh.cell_height = CELL_HEIGHT_DEFAULT\n        scene.recast_navmesh.slope_max = SLOPE_MAX_DEFAULT\n        scene.recast_navmesh.climb_max = CLIMB_MAX_DEFAULT\n        scene.recast_navmesh.agent_height = AGENT_HEIGHT_DEFAULT\n        scene.recast_navmesh.agent_radius = AGENT_RADIUS_DEFAULT\n        scene.recast_navmesh.edge_max_len = EDGE_MAX_LENGTH\n        scene.recast_navmesh.edge_max_error = EDGE_MAX_ERROR\n        scene.recast_navmesh.region_min_size = REGION_MIN_SIZE\n        scene.recast_navmesh.region_merge_size = REGION_MERGE_SIZE\n        scene.recast_navmesh.verts_per_poly = VERTS_PER_POLY_DEFAULT\n        scene.recast_navmesh.sample_dist = SAMPLE_DIST_DEFAULT\n        scene.recast_navmesh.sample_max_error = SAMPLE_MAX_ERROR_DEFAULT\n        scene.recast_navmesh.partitioning = PARTITIONING_DEFAULT\n        scene.recast_navmesh.color = COLOR_DEFAULT\n        scene.recast_navmesh.auto_cell = AUTO_CELL_DEFAULT\n\n        return {'FINISHED'}\n\n\nclass RecastNavMeshGenerateOperator(bpy.types.Operator):\n    bl_idname = \"recast.build_navigation_mesh\"\n    bl_label = \"Build Navigation Mesh\"\n    bl_description = \"Build navigation mesh from the selected objects using recast.\"\n    bl_options = {'REGISTER', 'UNDO'}\n\n    @classmethod\n    def poll(cls, context):\n        if is_linked(context.scene):\n            if bpy.app.version >= (3, 0, 0):\n                cls.poll_message_set(\"Cannot build a navigation mesh when in a linked scene\")\n            return False\n\n        return True\n\n    def execute(self, context):\n        # bpy.ops.wm.call_menu(name=\"ADDITIVE_ANIMATION_insert_keyframe_menu\")\n\n        active_object = context.active_object\n        selected_objects = context.selected_objects\n        if len([obj for obj in selected_objects if obj.type == 'MESH']) == 0:\n            self.report({'WARNING'}, 'No meshes selected')\n            return {\"CANCELLED\"}\n\n        from ..components.definitions.nav_mesh import NavMesh\n        nav_mesh_id = NavMesh.get_name()\n        for ob in context.selected_objects:\n            if has_component(ob, nav_mesh_id):\n                self.report({'ERROR'}, 'A Navmesh cannot be part of the selection')\n                return {'CANCELLED'}\n\n        navMesh = None\n        navMeshes = get_objects_with_component(nav_mesh_id)\n        if navMeshes:\n            navMesh = navMeshes[0]\n\n        addon_prefs = get_addon_pref(context)\n        libpath = os.path.abspath(addon_prefs.recast_lib_path)\n        libpathr = libpath.replace(\"\\\\\", \"/\")\n        if not os.path.exists(libpathr):\n            self.report({'ERROR'}, 'File not exists: %s\\n' % libpathr)\n            return {'CANCELLED'}\n\n        verts, tris = extractTriangulatedInputMesh(context)\n        vertsCount = len(verts)\n        trisCount = len(tris)\n        nverts = (int)(len(verts) / 3)\n        ntris = (int)(len(tris) / 3)\n        recastData = recastDataFromBlender(context.scene)\n        if context.scene.recast_navmesh.auto_cell:\n            recastData.cellsize = get_auto_cell_size(context)\n\n        prevWorkingDir = os.getcwd()\n        nextWorkingDir = os.path.dirname(libpathr)\n        os.chdir(nextWorkingDir)\n        try:\n            recast = ctypes.CDLL(libpathr)\n        except OSError as e:\n            tracebackStr = traceback.format_exc()\n            self.report(\n                {'ERROR'},\n                'Failed to load shared library: %s\\nPath to shared library: %s\\n\\nTraceback: %s' %\n                (str(e),\n                 libpathr, tracebackStr))\n            os.chdir(prevWorkingDir)\n            return {'FINISHED'}\n\n        os.chdir(prevWorkingDir)\n\n        pmesh = recast_polyMesh_holder()\n        dmesh = recast_polyMeshDetail_holder()\n        nreportMsg = 128\n        reportMsg = ctypes.create_string_buffer(b'\\000' * nreportMsg)     # 128 chars mutable text\n        recast.buildNavMesh.argtypes = [\n            ctypes.POINTER(RecastData),\n            c_int, c_float * vertsCount, c_int, c_int * trisCount, ctypes.POINTER(recast_polyMesh_holder),\n            ctypes.POINTER(recast_polyMeshDetail_holder),\n            ctypes.c_char_p, c_int]\n        recast.buildNavMesh.restype = c_int\n        recast.freeNavMesh.argtypes = [\n            ctypes.POINTER(recast_polyMesh_holder),\n            ctypes.POINTER(recast_polyMeshDetail_holder),\n            ctypes.c_char_p, c_int]\n        recast.freeNavMesh.restype = c_int\n\n        ok = recast.buildNavMesh(recastData, nverts, (c_float * vertsCount)(* verts), ntris,\n                                 (c_int * trisCount)(*tris), pmesh, dmesh, reportMsg, nreportMsg)\n        print(\"Report msg: %s\" % reportMsg.raw)\n        if not ok:\n            self.report({'ERROR'}, 'buildNavMesh C++ error: %s' % reportMsg.value)\n\n        if not dmesh.dmesh:\n            self.report({'ERROR'}, 'buildNavMesh C++ error: %s' % 'No recast_polyMeshDetail')\n        else:\n            # print(\"ABC %i\" % pmesh.pmesh.contents.nverts)\n            # dmeshv1 = dmesh.dmesh.contents.verts[0]\n            # print(\"dmeshv1 %f\" % dmeshv1)\n\n            createMesh(context, dmesh, obj=navMesh)\n\n        # what was allocated in C/C++ should be also deallocated there\n        recast.freeNavMesh(pmesh, dmesh, reportMsg, nreportMsg)\n\n        bpy.ops.object.select_all(action='DESELECT')\n        for obj in selected_objects:\n            obj.select_set(True)\n        context.view_layer.objects.active = active_object\n\n        return {'FINISHED'}\n\n\nclass RecastNavMeshPropertyGroup(PropertyGroup):\n    # based on https://docs.blender.org/api/2.79/bpy.types.SceneGameRecastData.html\n    cell_size: FloatProperty(\n        name=\"cell_size\",\n        description=\"Cell size\",\n        default=CELL_SIZE_DEFAULT,\n        min=0.0,\n        max=30.0,\n        subtype='DISTANCE')\n\n    cell_height: FloatProperty(\n        name=\"cell_height\",\n        description=\"Cell height\",\n        default=CELL_HEIGHT_DEFAULT,\n        min=0.0,\n        max=30.0,\n        subtype='DISTANCE')\n\n    agent_height: FloatProperty(\n        name=\"agent_height\",\n        description=\"Agent height\",\n        default=AGENT_HEIGHT_DEFAULT,\n        min=0.0,\n        max=30.0,\n        subtype='DISTANCE')\n\n    agent_radius: FloatProperty(\n        name=\"agent_radius\",\n        description=\"Agent radius\",\n        default=AGENT_RADIUS_DEFAULT,\n        min=0.0,\n        max=30.0,\n        subtype='DISTANCE')\n\n    slope_max: FloatProperty(\n        name=\"slope_max\",\n        description=\"Maximum slope\",\n        default=SLOPE_MAX_DEFAULT,\n        min=0.0,\n        max=radians(90),\n        subtype='ANGLE')\n\n    climb_max: FloatProperty(\n        name=\"climb_max\",\n        description=\"Maximum step height\",\n        default=CLIMB_MAX_DEFAULT,\n        min=0.0,\n        max=30.0,\n        subtype='DISTANCE')\n\n    region_min_size: FloatProperty(\n        name=\"region_min_size\",\n        description=\"Minimum region size\",\n        default=REGION_MIN_SIZE,\n        min=0.0,\n        max=30.0,\n        unit='AREA')\n\n    region_merge_size: FloatProperty(\n        name=\"region_merge_size\",\n        description=\"Merged region size\",\n        default=REGION_MERGE_SIZE,\n        min=0.0,\n        max=30.0,\n        unit='AREA')\n\n    edge_max_error: FloatProperty(\n        name=\"edge_max_error\",\n        description=\"Max edge error\",\n        default=EDGE_MAX_ERROR,\n        min=0.0,\n        max=30.0,\n        subtype='DISTANCE')\n\n    edge_max_len: FloatProperty(\n        name=\"edge_max_len\",\n        description=\"Max edge length\",\n        default=EDGE_MAX_LENGTH,\n        min=0.0,\n        max=30.0,\n        subtype='DISTANCE')\n\n    verts_per_poly: IntProperty(\n        name=\"verts_per_poly\",\n        description=\"Verts per poly\",\n        default=VERTS_PER_POLY_DEFAULT,\n        min=3,\n        max=10\n    )\n\n    sample_dist: FloatProperty(\n        name=\"sample_dist\",\n        description=\"Sample distance\",\n        default=SAMPLE_DIST_DEFAULT,\n        min=0.0,\n        max=30.0,\n        subtype='DISTANCE')\n\n    sample_max_error: FloatProperty(\n        name=\"sample_max_error\",\n        description=\"Max sample error\",\n        default=SAMPLE_MAX_ERROR_DEFAULT,\n        min=0.0,\n        max=30.0,\n        subtype='DISTANCE')\n\n    partitioning: EnumProperty(\n        name=\"partitioning\",\n        items=[(\"WATERSHED\", \"WATERSHED\", \"WATERSHED\"),\n               (\"MONOTONE\", \"MONOTONE\", \"MONOTONE\"),\n               (\"LAYERS\", \"LAYERS\", \"LAYERS\")],\n        default=PARTITIONING_DEFAULT)\n\n    color: FloatVectorProperty(name=\"Color\",\n                               description=\"Color\",\n                               subtype='COLOR_GAMMA',\n                               default=COLOR_DEFAULT,\n                               size=4,\n                               min=0,\n                               max=1)\n\n    auto_cell: BoolProperty(name=\"Auto cell size\", default=AUTO_CELL_DEFAULT)\n\n\nclass RecastAdvancedNavMeshPanel(bpy.types.Panel):\n    bl_idname = \"SCENE_PT_blendcast_adv\"\n    bl_parent_id = \"SCENE_PT_blendcast\"\n    bl_label = \"Advanced Settings\"\n    bl_space_type = 'PROPERTIES'\n    bl_region_type = 'WINDOW'\n    bl_context = \"scene\"\n    bl_options = {'DEFAULT_CLOSED'}\n\n    def draw(self, context):\n        layout = self.layout\n        recastPropertyGroup = context.scene.recast_navmesh\n\n        col = layout.column()\n        col.row().label(text=\"Region:\")\n        col.row().prop(recastPropertyGroup, \"region_merge_size\", text=\"Merged region size\")\n        col.row().prop(recastPropertyGroup, \"partitioning\", text=\"Partitioning\")\n\n        col.row().label(text=\"Polygonization:\")\n        col.row().prop(recastPropertyGroup, \"edge_max_len\", text=\"Max edge length\")\n        col.row().prop(recastPropertyGroup, \"edge_max_error\", text=\"Max edge error\")\n        col.row().prop(recastPropertyGroup, \"verts_per_poly\", text=\"Verts per poly\")\n\n        col.row().label(text=\"Detail mesh:\")\n        col.row().prop(recastPropertyGroup, \"sample_dist\", text=\"Sample distance\")\n        col.row().prop(recastPropertyGroup, \"sample_max_error\", text=\"Max sample error\")\n\n\nclass RecastNavMeshPanel(Panel):\n    \"\"\"Creates a Panel in the Object properties window\"\"\"\n    bl_label = \"Recast navmesh\"\n    bl_idname = \"SCENE_PT_blendcast\"\n    bl_space_type = 'PROPERTIES'\n    bl_region_type = 'WINDOW'\n    bl_context = \"scene\"\n\n    def draw(self, context):\n        layout = self.layout\n        recastPropertyGroup = context.scene.recast_navmesh\n\n        layout.operator(\"recast.build_navigation_mesh\")\n        layout.operator(\"recast.reset_navigation_mesh\")\n        layout.prop(recastPropertyGroup, \"color\", text=\"Color\")\n\n        layout.label(text=\"Rasterization:\")\n        col = layout.column()\n        col.row().prop(recastPropertyGroup, \"auto_cell\", text=\"Auto cell size\")\n        if not recastPropertyGroup.auto_cell:\n            col.row().prop(recastPropertyGroup, \"cell_size\", text=\"Cell size\")\n        col.row().prop(recastPropertyGroup, \"cell_height\", text=\"Cell height\")\n\n        layout.label(text=\"Agent:\")\n        col = layout.column()\n        col.row().prop(recastPropertyGroup, \"agent_height\", text=\"Height\")\n        col.row().prop(recastPropertyGroup, \"agent_radius\", text=\"Radius\")\n        col.row().prop(recastPropertyGroup, \"climb_max\", text=\"Maximum step height\")\n        col.row().prop(recastPropertyGroup, \"slope_max\", text=\"Maximum slope\")\n\n        layout.label(text=\"Region:\")\n        col = layout.column()\n        col.row().prop(recastPropertyGroup, \"region_min_size\", text=\"Min region size\")\n\n\nclasses = [\n    RecastNavMeshPropertyGroup,\n    RecastNavMeshPanel,\n    RecastAdvancedNavMeshPanel,\n    RecastNavMeshGenerateOperator,\n    RecastNavMeshResetOperator\n]\n\n\ndef register():\n    for cls in classes:\n        bpy.utils.register_class(cls)\n    bpy.types.Scene.recast_navmesh = PointerProperty(type=RecastNavMeshPropertyGroup)\n\n\ndef unregister():\n    for cls in classes:\n        bpy.utils.unregister_class(cls)\n    del bpy.types.Scene.recast_navmesh\n\n\nif __name__ == \"__main__\":\n    register()\n"
  },
  {
    "path": "addons/io_hubs_addon/utils.py",
    "content": "import functools\n\n\ndef get_addon_package():\n    return __package__\n\n\ndef rsetattr(obj, attr, val):\n    pre, _, post = attr.rpartition('.')\n    return setattr(rgetattr(obj, pre) if pre else obj, post, val)\n\n\ndef rgetattr(obj, attr, *args):\n    def _getattr(obj, attr):\n        return getattr(obj, attr, *args)\n    return functools.reduce(_getattr, [obj] + attr.split('.'))\n\n\ndef delayed_gather(func):\n    \"\"\" It delays the gather until all resources are available \"\"\"\n    def wrapper_delayed_gather(*args, **kwargs):\n        def gather():\n            return func(*args, **kwargs)\n        gather.delayed_gather = True\n        return gather\n    return wrapper_delayed_gather\n\n\ndef get_or_create_deps_path(name):\n    import os\n    deps_path = os.path.abspath(os.path.join(\n        __file__, \"..\", \".__deps__\", name))\n    if not os.path.exists(deps_path):\n        os.makedirs(deps_path, exist_ok=True)\n    return deps_path\n\n\ndef is_module_available(name, local_dependency=True):\n    import sys\n    old_syspath = sys.path[:]\n    old_sysmod = sys.modules.copy()\n\n    try:\n        if local_dependency:\n            path = get_or_create_deps_path(name)\n            sys.path.insert(0, str(path))\n\n        import importlib\n        try:\n            loader = importlib.util.find_spec(name)\n        except ImportError as ex:\n            print(f'{name} not found')\n\n        if local_dependency:\n            import os\n            path = os.path.join(path, name)\n            return bool(loader and os.path.exists(path))\n        else:\n            return bool(loader)\n\n    finally:\n        # Restore without assigning a new list instance. That way references\n        # held by other code will stay valid.\n        sys.path[:] = old_syspath\n        sys.modules.clear()\n        sys.modules.update(old_sysmod)\n\n\ndef load_dependency(name):\n    import sys\n    old_syspath = sys.path[:]\n    old_sysmod = sys.modules.copy()\n\n    module = None\n    try:\n        modules = name.split(\".\")\n        path = get_or_create_deps_path(modules[0])\n\n        import importlib\n        sys.path.insert(0, str(path))\n\n        try:\n            module = importlib.import_module(name)\n        except ImportError as ex:\n            print(f'Unable to load {name}')\n\n    finally:\n        # Restore without assigning a new list instance. That way references\n        # held by other code will stay valid.\n        sys.path[:] = old_syspath\n        sys.modules.clear()\n        sys.modules.update(old_sysmod)\n\n    return module\n\n\nHUBS_PREFS_DIR = \".__hubs_blender_addon_preferences\"\nHUBS_SELENIUM_PROFILE_FIREFOX = \"hubs_selenium_profile.firefox\"\nHUBS_SELENIUM_PROFILE_CHROME = \"hubs_selenium_profile.chrome\"\nHUBS_PREFS = \"hubs_prefs.json\"\n\n\ndef get_prefs_dir_path():\n    import os\n    home_directory = os.path.expanduser(\"~\")\n    prefs_dir_path = os.path.join(home_directory, HUBS_PREFS_DIR)\n    return os.path.normpath(prefs_dir_path)\n\n\ndef create_prefs_dir():\n    import os\n    prefs_dir = get_prefs_dir_path()\n    if not os.path.exists(prefs_dir):\n        os.makedirs(prefs_dir)\n\n\ndef get_browser_profile_directory(browser):\n    import os\n    prefs_folder = get_prefs_dir_path()\n    file_path = \"\"\n    if browser == \"Firefox\":\n        file_path = os.path.join(\n            prefs_folder, HUBS_SELENIUM_PROFILE_FIREFOX)\n    elif browser == \"Chrome\":\n        file_path = os.path.join(\n            prefs_folder, HUBS_SELENIUM_PROFILE_CHROME)\n\n    return os.path.normpath(file_path)\n\n\ndef get_prefs_path():\n    import os\n    prefs_folder = get_prefs_dir_path()\n    prefs_path = os.path.join(prefs_folder, HUBS_PREFS)\n    return os.path.normpath(prefs_path)\n\n\ndef save_prefs(context):\n    prefs = context.window_manager.hubs_scene_debugger_prefs\n\n    data = {\n        \"scene_debugger\": {},\n        \"scene_publisher\": {}\n    }\n\n    instances_array = []\n    for instance in prefs.hubs_instances:\n        instances_array.append({\n            \"name\": instance.name,\n            \"url\": instance.url\n        })\n    data[\"scene_debugger\"] = {\n        \"hubs_instance_idx\": prefs.hubs_instance_idx,\n        \"hubs_instances\": instances_array\n    }\n\n    rooms_array = []\n    for room in prefs.hubs_rooms:\n        rooms_array.append({\n            \"name\": room.name,\n            \"url\": room.url\n        })\n    data[\"scene_debugger\"].update({\n        \"hubs_room_idx\": prefs.hubs_room_idx,\n        \"hubs_rooms\": rooms_array\n    })\n\n    scene_props = context.window_manager.hubs_scene_debugger_scenes_props\n    scenes_array = []\n    for scene in scene_props.scenes:\n        scenes_array.append({\n            \"scene_id\": scene[\"scene_id\"],\n            \"name\": scene[\"name\"],\n            \"description\": scene[\"description\"],\n            \"url\": scene[\"url\"],\n            \"screenshot_url\": scene[\"screenshot_url\"],\n        })\n    data[\"scene_publisher\"].update({\n        \"instance\": scene_props.instance,\n        \"scenes\": scenes_array,\n        \"scene_idx\": scene_props.scene_idx\n    })\n\n    out_path = get_prefs_path()\n    try:\n        import json\n        json_data = json.dumps(data)\n        with open(out_path, \"w\") as outfile:\n            outfile.write(json_data)\n\n    except Exception as err:\n        import bpy\n        bpy.ops.wm.hubs_report_viewer(\n            'INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n            report_string=f'An error happened while saving the preferences from {out_path}: {err}')\n\n\ndef load_prefs(context):\n    data = {}\n\n    out_path = get_prefs_path()\n    import os\n    if not os.path.isfile(out_path):\n        return\n\n    try:\n        import json\n        import os\n        with open(out_path, \"r\") as outfile:\n            if (os.path.getsize(out_path)) == 0:\n                return\n            data = json.load(outfile)\n\n    except Exception as err:\n        import bpy\n        bpy.ops.wm.hubs_report_viewer(\n            'INVOKE_DEFAULT', title=\"Hubs scene debugger report\",\n            report_string=f'An error happened while loading the preferences from {out_path}: {err}')\n\n    if not data:\n        return\n\n    prefs = context.window_manager.hubs_scene_debugger_prefs\n    if \"scene_debugger\" in data:\n        scene_debugger = data[\"scene_debugger\"]\n        prefs[\"hubs_instance_idx\"] = scene_debugger[\"hubs_instance_idx\"]\n        prefs.hubs_instances.clear()\n        instances = scene_debugger[\"hubs_instances\"]\n        for instance in instances:\n            new_instance = prefs.hubs_instances.add()\n            new_instance.name = instance[\"name\"]\n            new_instance.url = instance[\"url\"]\n\n        prefs[\"hubs_room_idx\"] = scene_debugger[\"hubs_room_idx\"]\n        prefs.hubs_rooms.clear()\n        rooms = scene_debugger[\"hubs_rooms\"]\n        for room in rooms:\n            new_room = prefs.hubs_rooms.add()\n            new_room.name = room[\"name\"]\n            new_room.url = room[\"url\"]\n\n    scene_props = context.window_manager.hubs_scene_debugger_scenes_props\n    if \"scene_publisher\" in data:\n        scene_publisher = data[\"scene_publisher\"]\n        scene_props.instance = scene_publisher[\"instance\"]\n        scene_props.scene_idx = scene_publisher[\"scene_idx\"]\n        scene_props.scenes.clear()\n        scenes = scene_publisher[\"scenes\"]\n        for scene in scenes:\n            new_scene = scene_props.scenes.add()\n            new_scene[\"scene_id\"] = scene[\"scene_id\"]\n            new_scene[\"name\"] = scene[\"name\"]\n            new_scene[\"description\"] = scene[\"description\"]\n            new_scene[\"url\"] = scene[\"url\"]\n            new_scene[\"screenshot_url\"] = scene[\"screenshot_url\"]\n\n    prefs[\"hubs_room_idx\"] = scene_debugger[\"hubs_room_idx\"]\n    prefs.hubs_rooms.clear()\n    rooms = scene_debugger[\"hubs_rooms\"]\n    for room in rooms:\n        new_room = prefs.hubs_rooms.add()\n        new_room.name = room[\"name\"]\n        new_room.url = room[\"url\"]\n\n\ndef find_area(area_type):\n    try:\n        import bpy\n        for a in bpy.data.window_managers[0].windows[0].screen.areas:\n            if a.type == area_type:\n                return a\n        return None\n    except Exception as err:\n        return None\n\n\ndef image_type_to_file_ext(image_type):\n    file_extension = None\n    if image_type == 'PNG':\n        file_extension = '.png'\n    elif image_type == 'JPEG':\n        file_extension = '.jpg'\n    elif image_type == 'BMP':\n        file_extension = '.bmp'\n    elif image_type == 'JPEG2000':\n        file_extension = '.jpeg'\n    elif image_type == 'TARGA':\n        file_extension = '.tga'\n    elif image_type == 'TARGA_RAW':\n        file_extension = '.tga'\n    return file_extension\n\n\ndef is_addon_enabled():\n    import bpy\n    return get_addon_package() in bpy.context.preferences.addons\n"
  },
  {
    "path": "check_style.py",
    "content": "import subprocess\nimport sys\nfrom shutil import which\n\nif which(\"pycodestyle\") is None:\n    print(\"Error: pycodestyle could not be found. Please install pycodestyle and run this script again: https://pypi.org/project/pycodestyle/\")\n    sys.exit(1)\n\ncp = subprocess.run([\"pycodestyle\", \"--exclude=models\", \"--ignore=E501,W504\", \"addons\"])\nsys.exit(cp.returncode)\n"
  },
  {
    "path": "format.py",
    "content": "import subprocess\nimport sys\nfrom shutil import which\n\nif which(\"autopep8\") is None:\n    print(\"Error: autopep8 could not be found. Please install autopep8 and run this script again: https://pypi.org/project/autopep8/\")\n    sys.exit(1)\n\ncp = subprocess.run([\"autopep8\", \"--exclude=models\", \"--in-place\",\n                     \"--recursive\", \"--max-line-length=120\", \"--experimental\", \"addons\"])\nsys.exit(cp.returncode)\n"
  },
  {
    "path": "scripts/export_gizmo.py",
    "content": "# Blender utility script to export a mesh in the Gizmo format.\n# Usage:\n# Run Blender from the terminal.\n# Create a new script file, copy this script in the new file and run.\n\nimport bpy\n\nfrom bpy.props import StringProperty\nfrom bpy_extras.io_utils import ImportHelper\nfrom bpy.types import Operator\n\n\ndef convert(objects):\n    '''Prints the model vertices in gizmo format and world space'''\n    out = 'SHAPE = ('\n    for ob in objects:\n        if ob.type == 'MESH':\n            mesh = ob.data\n            mat = ob.matrix_world\n            mesh.calc_loop_triangles()\n            for tri in mesh.loop_triangles:\n                for i in range(3):\n                    v_index = tri.vertices[i]\n                    v = mat @ mesh.vertices[v_index].co\n                    out += '(%f, %f, %f),' % (v.x, v.y, v.z)\n    out += ')'\n    return out\n\n\nclass SaveGizmoOperator(Operator, ImportHelper):\n\n    bl_idname = \"hubs.save_gizmo\"\n    bl_label = \"Save Gizmo\"\n\n    filter_glob: StringProperty(\n        default='*.py;',\n        options={'HIDDEN'}\n    )\n\n    def execute(self, context):\n        \"\"\"Save gizmo outout to a file.\"\"\"\n        gizmo = convert(context.selected_objects)\n\n        f = open(self.filepath, \"w\")\n        f.write(gizmo)\n        f.close()\n\n        return {'FINISHED'}\n\n\ndef register():\n    bpy.utils.register_class(SaveGizmoOperator)\n\n\ndef unregister():\n    bpy.utils.unregister_class(SaveGizmoOperator)\n\n\nif __name__ == \"__main__\":\n    register()\n    bpy.ops.hubs.save_gizmo('INVOKE_DEFAULT')\n"
  },
  {
    "path": "setup.sh",
    "content": "wget https://github.com/nutti/fake-bpy-module/releases/download/20221006/fake_bpy_modules_3.3-20221006.zip -O temp.zip; unzip temp.zip; rm temp.zip"
  },
  {
    "path": "tests/.eslintrc.json",
    "content": "{\n  \"extends\": \"eslint:recommended\",\n  \"parserOptions\": {\n    \"ecmaVersion\": 2017\n  },\n  \"globals\": {\n    \"describe\": \"readonly\",\n    \"it\": \"readonly\"\n  },\n  \"env\": {\n    \"es6\": true,\n    \"node\": true\n  },\n  \"rules\": {\n    \"indent\": [\n      \"error\",\n      2\n    ],\n    \"semi\": 1,\n    \"no-extra-semi\": 1,\n    \"no-unused-vars\": 0,\n    \"no-console\": [\n      \"off\"\n    ]\n  }\n}"
  },
  {
    "path": "tests/.npmrc",
    "content": "package-lock=false"
  },
  {
    "path": "tests/export_gltf.py",
    "content": "# Copyright 2018-2021 The Khronos Group Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport bpy\nimport os\nimport sys\n\nbpy.ops.preferences.addon_enable(module=\"io_hubs_addon\")\n\ntry:\n    argv = sys.argv\n    if \"--\" in argv:\n        argv = argv[argv.index(\"--\") + 1:]  # get all args after \"--\"\n    else:\n        argv = []\n\n    extension = '.gltf'\n    if '--glb' in argv:\n        extension = '.glb'\n\n    path = os.path.splitext(bpy.data.filepath)[0] + extension\n    path_parts = os.path.split(path)\n    output_dir = os.path.join(path_parts[0], argv[0])\n    if not os.path.exists(output_dir):\n        os.makedirs(output_dir)\n    args = {\n        # Settings from \"Remember Export Settings\"\n        **dict(bpy.context.scene.get('glTF2ExportSettings', {})),\n\n        'export_format': ('GLB' if extension == '.glb' else 'GLTF_SEPARATE'),\n        'filepath': os.path.join(output_dir, path_parts[1]),\n        'export_cameras': True,\n        'export_extras': True\n    }\n    bpy.ops.export_scene.gltf(**args)\nexcept Exception as err:\n    print(err, file=sys.stderr)\n    sys.exit(1)\n"
  },
  {
    "path": "tests/package.json",
    "content": "{\n  \"name\": \"io-hubs-addon-tests\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Test suite for io-hubs-addon\",\n  \"dependencies\": {},\n  \"devDependencies\": {\n    \"eslint\": \"^6.8.0\",\n    \"gltf-validator\": \"^2.0.0-dev.3.2\",\n    \"mocha\": \"^7.1.1\",\n    \"mochawesome\": \"^6.1.0\",\n    \"validator\": \"^13.7.0\"\n  },\n  \"scripts\": {\n    \"test\": \"mocha --reporter mochawesome\",\n    \"test-bail\": \"mocha -b --reporter mochawesome\",\n    \"lint\": \"eslint **/*.js\",\n    \"lint:fix\": \"eslint --fix **/*.js\"\n  },\n  \"mocha\": {\n    \"timeout\": 60000\n  }\n}"
  },
  {
    "path": "tests/roundtrip_gltf.py",
    "content": "# Copyright 2018-2021 The Khronos Group Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport bpy\nimport os\nimport sys\n\nbpy.ops.preferences.addon_enable(module=\"io_hubs_addon\")\n\ntry:\n    argv = sys.argv\n    if \"--\" in argv:\n        argv = argv[argv.index(\"--\") + 1:]  # get all args after \"--\"\n    else:\n        argv = []\n\n    filepath = argv[0]\n\n    bpy.ops.object.select_all(action='SELECT')\n\n    for collection in bpy.data.collections:\n        for object in collection.objects:\n            collection.objects.unlink(object)\n\n    for bpy_data_iter in (\n        bpy.data.objects,\n        bpy.data.meshes,\n        bpy.data.lights,\n        bpy.data.cameras,\n        bpy.data.armatures,\n        bpy.data.actions,\n        bpy.data.images,\n        bpy.data.lightprobes,\n        bpy.data.materials,\n        bpy.data.shape_keys,\n        bpy.data.textures\n    ):\n        for id_data in bpy_data_iter:\n            bpy_data_iter.remove(id_data)\n\n    bpy.ops.import_scene.gltf(filepath=argv[0])\n\n    extension = '.gltf'\n    export_format = 'GLTF_SEPARATE'\n    if '--glb' in argv:\n        extension = '.glb'\n        export_format = 'GLB'\n\n    path = os.path.splitext(filepath)[0] + extension\n    path_parts = os.path.split(path)\n    output_dir = os.path.join(path_parts[0], argv[1])\n    if not os.path.exists(output_dir):\n        os.makedirs(output_dir)\n    if '--use-variants' in argv:\n        bpy.context.preferences.addons['io_scene_gltf2'].preferences.KHR_materials_variants_ui = True\n    if '--no-sample-anim' in argv:\n        bpy.ops.export_scene.gltf(export_format=export_format, filepath=os.path.join(\n            output_dir, path_parts[1]), export_force_sampling=False, export_cameras=True)\n    elif '--use-original-specular' in argv:\n        bpy.ops.export_scene.gltf(export_format=export_format, filepath=os.path.join(\n            output_dir, path_parts[1]), export_original_specular=True, export_cameras=True)\n    else:\n        bpy.ops.export_scene.gltf(\n            export_format=export_format, filepath=os.path.join(output_dir, path_parts[1]), export_cameras=True)\n\nexcept Exception as err:\n    print(err, file=sys.stderr)\n    sys.exit(1)\n"
  },
  {
    "path": "tests/test/test_export.js",
    "content": "const fs = require('fs');\nconst glob = require('glob')\nconst path = require('path');\nconst { test } = require('./tests/link.js');\nconst utils = require('./utils.js');\n\nconst OUT_PREFIX = process.env.OUT_PREFIX || '../tests_out';\n\nprocess.env['BLENDER_USER_SCRIPTS'] = path.join(process.cwd(), '..');\n\nconst blenderVersions = (() => {\n  if (process.platform == 'darwin') {\n    return [\n      \"/Applications/Blender.app/Contents/MacOS/Blender\"\n    ];\n  }\n  else if (process.platform == 'linux') {\n    return [\n      \"blender\"\n    ];\n  }\n})();\n\nconst basePath = path.join(__dirname);\nconst tests = glob.sync(path.join(basePath, 'tests', '*.js')).reduce((loaded, file) => {\n  const mod = require('./' + path.relative(basePath, file));\n  loaded.push(mod);\n  return loaded;\n}, []);\n\ndescribe('Exporter', function () {\n  const blenderSampleScenes = fs.readdirSync('scenes').filter(f => f.endsWith('.blend')).map(f => f.substring(0, f.length - 6));\n\n  blenderVersions.forEach(function (blenderVersion) {\n    let variants = [\n      ['', '']\n    ];\n\n    variants.forEach(function (variant) {\n      const args = variant[1];\n      describe(blenderVersion + '_export' + variant[0], function () {\n        blenderSampleScenes.forEach((scene) => {\n          it(scene, function (done) {\n            let outDirName = 'out' + blenderVersion + variant[0];\n            let blenderPath = `scenes/${scene}.blend`;\n            let ext = args.indexOf('--glb') === -1 ? '.gltf' : '.glb';\n            let outDirPath = path.resolve(OUT_PREFIX, outDirName, 'export');\n            let dstPath = path.resolve(outDirPath, `${scene}${ext}`);\n            utils.blenderFileToGltf(blenderVersion, blenderPath, outDirPath, (error) => {\n              if (error)\n                return done(error);\n\n              utils.validateGltf(dstPath, done);\n            }, args);\n          });\n        });\n      });\n    });\n\n    describe(blenderVersion + '_export_results', function () {\n      let outDirName = 'out' + blenderVersion;\n      let outDirPath = path.resolve(OUT_PREFIX, outDirName, 'export');\n\n      tests.forEach(test => {\n        it(test.description, () => test.test(outDirPath));\n      });\n    });\n  });\n});\n\ndescribe('Importer / Exporter (Roundtrip)', function () {\n  const blenderSampleScenes = fs.readdirSync('scenes').filter(f => f.endsWith('.blend')).map(f => f.substring(0, f.length - 6));\n\n  blenderVersions.forEach(function (blenderVersion) {\n    let variants = [\n      ['', '']\n    ];\n\n    variants.forEach(function (variant) {\n      const args = variant[1];\n      describe(blenderVersion + '_roundtrip' + variant[0], function () {\n        blenderSampleScenes.forEach(scene => {\n          it(scene, function (done) {\n            let outDirName = 'out' + blenderVersion + variant[0];\n            let ext = args.indexOf('--glb') === -1 ? '.gltf' : '.glb';\n            let exportSrcPath = path.resolve(OUT_PREFIX, outDirName, 'export');\n            let gltfSrcPath = path.resolve(exportSrcPath, `${scene}${ext}`);\n            let outDirPath = path.resolve(OUT_PREFIX, outDirName, 'roundtrip');\n            let gltfDstPath = path.resolve(outDirPath, `${scene}${ext}`);\n            let options = args;\n\n            utils.blenderRoundtripGltf(blenderVersion, gltfSrcPath, outDirPath, (error) => {\n              if (error)\n                return done(error);\n\n              utils.validateGltf(gltfSrcPath, (error, gltfSrcReport) => {\n                if (error)\n                  return done(error);\n\n                utils.validateGltf(gltfDstPath, (error, gltfDstReport) => {\n                  if (error)\n                    return done(error);\n\n                  let reduceKeys = function (raw, allowed) {\n                    return Object.keys(raw)\n                      .filter(key => allowed.includes(key))\n                      .reduce((obj, key) => {\n                        obj[key] = raw[key];\n                        return obj;\n                      }, {});\n                  };\n\n                  done();\n                });\n              });\n            }, options);\n          });\n        });\n      });\n    });\n\n    describe(blenderVersion + '_roundtrip_results', function () {\n      let outDirName = 'out' + blenderVersion;\n      let outDirPath = path.resolve(OUT_PREFIX, outDirName, 'roundtrip');\n\n      tests.forEach(test => {\n        it(test.description, () => test.test(outDirPath));\n      });\n    });\n  });\n});"
  },
  {
    "path": "tests/test/tests/ambient-light.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export ambient-light',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'ambient-light.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"ambient-light\": {\n                \"color\": \"#0cff00\",\n                \"intensity\": 1\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/ammo-shape.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export ammo-shape',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'ammo-shape.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"ammo-shape\": {\n                \"type\": \"hull\",\n                \"fit\": \"all\",\n                \"halfExtents\": {\n                    \"x\": 0.5,\n                    \"y\": 0.5,\n                    \"z\": 0.5\n                },\n                \"minHalfExtent\": 0,\n                \"maxHalfExtent\": 1000,\n                \"sphereRadius\": 0.5,\n                \"offset\": {\n                    \"x\": 0,\n                    \"y\": 0,\n                    \"z\": 0\n                },\n                \"includeInvisible\": false\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/audio-settings.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export audio-settings',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'audio-settings.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const scene = asset.scenes[0];\n        assert.strictEqual(utils.checkExtensionAdded(scene, 'MOZ_hubs_components'), true);\n\n        const ext = scene.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"audio-settings\": {\n                \"avatarDistanceModel\": \"inverse\",\n                \"avatarRolloffFactor\": 2,\n                \"avatarRefDistance\": 1,\n                \"avatarMaxDistance\": 10000,\n                \"mediaVolume\": 0.5,\n                \"mediaDistanceModel\": \"inverse\",\n                \"mediaRolloffFactor\": 2,\n                \"mediaRefDistance\": 1,\n                \"mediaMaxDistance\": 10000,\n                \"mediaConeInnerAngle\": 360,\n                \"mediaConeOuterAngle\": 0,\n                \"mediaConeOuterGain\": 0\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/audio-target.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export audio-target and zone-audio-source',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'audio-target.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const source = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(source, 'MOZ_hubs_components'), true);\n\n        const target = asset.nodes[1];\n        assert.strictEqual(utils.checkExtensionAdded(target, 'MOZ_hubs_components'), true);\n\n        const sourceExt = source.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(sourceExt, {\n            \"zone-audio-source\": {\n                \"onlyMods\": true,\n                \"muteSelf\": true,\n                \"debug\": false\n            }\n        });\n\n        const targetExt = target.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(targetExt, {\n            \"audio-target\": {\n                \"srcNode\": {\n                    \"__mhc_link_type\": \"node\",\n                    \"index\": 0\n                },\n                \"minDelay\": 0.009999999776482582,\n                \"maxDelay\": 0.029999999329447746,\n                \"debug\": false\n            },\n            \"audio-params\": {\n                \"audioType\": \"pannernode\",\n                \"gain\": 1,\n                \"distanceModel\": \"inverse\",\n                \"refDistance\": 1,\n                \"rolloffFactor\": 1,\n                \"maxDistance\": 10000,\n                \"coneInnerAngle\": 360,\n                \"coneOuterAngle\": 0,\n                \"coneOuterGain\": 0\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/audio-zone.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export audio-zone',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'audio-zone.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext[\"audio-zone\"], {\n            \"inOut\": true,\n            \"outIn\": true,\n            \"dynamic\": false\n        });\n        assert.deepStrictEqual(ext[\"audio-params\"], {\n            \"audioType\": \"pannernode\",\n            \"gain\": 1,\n            \"distanceModel\": \"inverse\",\n            \"refDistance\": 1,\n            \"rolloffFactor\": 1,\n            \"maxDistance\": 10000,\n            \"coneInnerAngle\": 360,\n            \"coneOuterAngle\": 0,\n            \"coneOuterGain\": 0\n        });\n        assert.strictEqual(utils.UUID_REGEX.test(ext['networked']['id']), true);\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/audio.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export audio',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'audio.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext[\"audio\"], {\n            \"src\": \"https://example.org/files/a3670163-1e78-485c-b70d-9af51f6afaff.mp3\",\n            \"autoPlay\": true,\n            \"controls\": true,\n            \"loop\": true\n        });\n        assert.deepStrictEqual(ext[\"audio-params\"], {\n            \"audioType\": \"pannernode\",\n            \"gain\": 1,\n            \"distanceModel\": \"inverse\",\n            \"refDistance\": 1,\n            \"rolloffFactor\": 1,\n            \"maxDistance\": 10000,\n            \"coneInnerAngle\": 360,\n            \"coneOuterAngle\": 0,\n            \"coneOuterGain\": 0\n        });\n        assert.strictEqual(utils.UUID_REGEX.test(ext['networked']['id']), true);\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/billboard.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export billboard',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'billboard.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"billboard\": {\n                \"onlyY\": false\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/directional-light.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export directional-light',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'directional-light.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"directional-light\": {\n                \"color\": \"#0cff00\",\n                \"intensity\": 1,\n                \"castShadow\": false,\n                \"shadowMapResolution\": [\n                    512,\n                    512\n                ],\n                \"shadowBias\": 0,\n                \"shadowRadius\": 1\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/environment-settings.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export environment-settings',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'environment-settings.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const scene = asset.scenes[0];\n        assert.strictEqual(utils.checkExtensionAdded(scene, 'MOZ_hubs_components'), true);\n\n        const ext = scene.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"environment-settings\": {\n                \"toneMapping\": \"LUTToneMapping\",\n                \"toneMappingExposure\": 1,\n                \"backgroundColor\": \"#0cff00\",\n                \"backgroundTexture\": {\n                    \"__mhc_link_type\": \"texture\",\n                    \"index\": 0\n                },\n                \"envMapTexture\": {\n                    \"__mhc_link_type\": \"texture\",\n                    \"index\": 1\n                }\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/fog.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export fog',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'fog.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const scene = asset.scenes[0];\n        assert.strictEqual(utils.checkExtensionAdded(scene, 'MOZ_hubs_components'), true);\n\n        const ext = scene.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"fog\": {\n                \"type\": \"linear\",\n                \"color\": \"#0cff00\",\n                \"near\": 1,\n                \"far\": 100,\n                \"density\": 0.10000000149011612\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/frustrum.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export frustrum',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'frustrum.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"frustrum\": {\n                \"culled\": false\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/hemisphere-light.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export hemisphere-light',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'hemisphere-light.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"hemisphere-light\": {\n                \"skyColor\": \"#0cff00\",\n                \"groundColor\": \"#0cff00\",\n                \"intensity\": 1\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/image.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export image',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'image.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext[\"image\"], {\n            \"src\": \"https://example.org/files/81e942e8-6ae2-4cc5-b363-f064e9ea3f61.jpg\",\n            \"controls\": true,\n            \"alphaCutoff\": 0.5,\n            \"alphaMode\": \"opaque\",\n            \"projection\": \"flat\"\n        });\n        assert.strictEqual(utils.UUID_REGEX.test(ext['networked']['id']), true);\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/link.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export link',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'link.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext['link'], { href: 'https://example.org' });\n        assert.strictEqual(utils.UUID_REGEX.test(ext['networked']['id']), true);\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/loop-animation.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export loop-animation',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'loop-animation.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        const loopAnimation = ext['loop-animation'];\n\n        const clip_names = loopAnimation.clip.split(\",\").sort();\n        const animation_names = asset.animations.reduce((accumulator, animation) => {\n            accumulator.push(animation.name);\n            return accumulator;\n        }, []).sort();\n        assert.deepStrictEqual(clip_names, animation_names);\n\n        assert.deepStrictEqual(ext, {\n            \"loop-animation\": {\n                \"clip\": loopAnimation.clip,\n                \"startOffset\": 0,\n                \"timeScale\": 1\n            }\n        });\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/media-frame.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export media-frame',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'media-frame.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext['media-frame'], {\n            align: {\n                \"x\": 'center',\n                \"y\": 'center',\n                \"z\": 'center'\n            },\n            \"bounds\": {\n                \"x\": 1,\n                \"y\": 1,\n                \"z\": 4\n            },\n            \"mediaType\": \"all-2d\",\n            \"snapToCenter\": true,\n            \"scaleToBounds\": true\n        });\n        assert.strictEqual(utils.UUID_REGEX.test(ext['networked']['id']), true);\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/model.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export model',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'model.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext[\"model\"], {\n            \"src\": \"https://example.org/ModelFile.glb\"\n        });\n        assert.strictEqual(utils.UUID_REGEX.test(ext['networked']['id']), true);\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/morph-audio-feedback.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export morph-audio-feedback',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'morph-audio-feedback.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"morph-audio-feedback\": {\n                \"name\": \"Key 1\",\n                \"minValue\": 0,\n                \"maxValue\": 1\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/nav-mesh.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export nav-mesh',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'nav-mesh.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, { \n            'nav-mesh': {}, \n            'visible': {\n                'visible': false\n            }\n        });\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/particle-emitter.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export particle-emitter',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'particle-emitter.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"particle-emitter\": {\n                \"particleCount\":10,\n                \"src\":\"\",\n                \"ageRandomness\":10,\n                \"lifetime\":1,\n                \"lifetimeRandomness\":5,\n                \"sizeCurve\":\"linear\",\n                \"startSize\":1,\n                \"endSize\":1,\n                \"sizeRandomness\":0,\n                \"colorCurve\":\"linear\",\n                \"startColor\":\"#0cff00\",\n                \"startOpacity\":1,\n                \"middleColor\":\"#0cff00\",\n                \"middleOpacity\":1,\n                \"endColor\":\"#0cff00\",\n                \"endOpacity\":1,\n                \"velocityCurve\":\"linear\",\n                \"startVelocity\":{\n                    \"x\":0,\n                    \"y\":0,\n                    \"z\":0.5\n                },\n                \"endVelocity\":{\n                    \"x\":0,\n                    \"y\":0,\n                    \"z\":0.5\n                },\n                \"angularVelocity\":0\n            }\n        });\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/personal-space-invader.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export personal-space-invader',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'personal-space-invader.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"personal-space-invader\": {\n                \"radius\": 0.10000000149011612,\n                \"useMaterial\": false,\n                \"invadingOpacity\": 0.30000001192092896\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/point-light.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export point-light',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'point-light.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"point-light\": {\n                \"color\": \"#0cff00\",\n                \"intensity\": 1,\n                \"range\": 0,\n                \"decay\": 2,\n                \"castShadow\": false,\n                \"shadowMapResolution\": [\n                    512,\n                    512\n                ],\n                \"shadowBias\": 0,\n                \"shadowRadius\": 1\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/scale-audio-feedback.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export scale-audio-feedback',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'scale-audio-feedback.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"scale-audio-feedback\": {\n                \"minScale\": 1,\n                \"maxScale\": 1.5\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/shadow.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export shadow',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'shadow.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"shadow\": {\n                \"cast\": true,\n                \"receive\": true\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/simple-water.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export simple-water',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'simple-water.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"simple-water\": {\n                \"color\": \"#0cff00\",\n                \"opacity\": 1,\n                \"tideHeight\": 0.009999999776482582,\n                \"tideScale\": {\n                    \"x\": 1,\n                    \"y\": 1\n                },\n                \"tideSpeed\": {\n                    \"x\": 0.5,\n                    \"y\": 0.5\n                },\n                \"waveHeight\": 1,\n                \"waveScale\": {\n                    \"x\": 1,\n                    \"y\": 20\n                },\n                \"waveSpeed\": {\n                    \"x\": 0.05000000074505806,\n                    \"y\": 6\n                },\n                \"ripplesSpeed\": 0.25,\n                \"ripplesScale\": 1\n            }\n        });\n    }\n}"
  },
  {
    "path": "tests/test/tests/skybox.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export skybox',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'skybox.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"skybox\": {\n                \"azimuth\": 0.15000000596046448,\n                \"inclination\": 0,\n                \"luminance\": 1,\n                \"mieCoefficient\": 0.004999999888241291,\n                \"mieDirectionalG\": 0.800000011920929,\n                \"turbidity\": 10,\n                \"rayleigh\": 2,\n                \"distance\": 8000\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/spawner.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export spawner',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'spawner.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"spawner\": {\n                \"src\": \"https://example.org/files/81e942e8-6ae2-4cc5-b363-f064e9ea3f61.jpg\",\n                \"mediaOptions\": {\n                    \"applyGravity\": true\n                }\n            }\n        });\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/spot-light.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export spot-light',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'spot-light.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"spot-light\": {\n                \"color\": \"#0cff00\",\n                \"intensity\": 1,\n                \"range\": 0,\n                \"decay\": 2,\n                \"innerConeAngle\": 0,\n                \"outerConeAngle\": 0.7853981852531433,\n                \"castShadow\": false,\n                \"shadowMapResolution\": [\n                    512,\n                    512\n                ],\n                \"shadowBias\": 0,\n                \"shadowRadius\": 1\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/text.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export text',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'text.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"text\": {\n                \"value\": \"Hello World!\",\n                \"fontSize\": 0.07500000298023224,\n                \"textAlign\": \"left\",\n                \"anchorX\": \"center\",\n                \"anchorY\": \"middle\",\n                \"color\": \"#0cff00\",\n                \"letterSpacing\": 0,\n                \"lineHeight\": 0,\n                \"outlineWidth\": \"0\",\n                \"outlineColor\": \"#0cff00\",\n                \"outlineBlur\": \"0\",\n                \"outlineOffsetX\": \"0\",\n                \"outlineOffsetY\": \"0\",\n                \"outlineOpacity\": 1,\n                \"fillOpacity\": 1,\n                \"strokeWidth\": \"0\",\n                \"strokeColor\": \"#0cff00\",\n                \"strokeOpacity\": 1,\n                \"textIndent\": 0,\n                \"whiteSpace\": \"normal\",\n                \"overflowWrap\": \"normal\",\n                \"opacity\": 1,\n                \"side\": \"front\",\n                \"maxWidth\": 1,\n                \"curveRadius\": 0,\n                \"direction\": \"auto\"\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/text_clip-rect.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export text with clip rect property',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'text_clip-rect.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"text\": {\n                \"value\": \"Hello World!\",\n                \"fontSize\": 0.07500000298023224,\n                \"textAlign\": \"left\",\n                \"anchorX\": \"center\",\n                \"anchorY\": \"middle\",\n                \"color\": \"#0cff00\",\n                \"letterSpacing\": 0,\n                \"clipRect\": [\n                    -0.10000000149011612,\n                    -0.20000000298023224,\n                    0.30000001192092896,\n                    0.4000000059604645\n                ],\n                \"lineHeight\": 0,\n                \"outlineWidth\": \"0\",\n                \"outlineColor\": \"#0cff00\",\n                \"outlineBlur\": \"0\",\n                \"outlineOffsetX\": \"0\",\n                \"outlineOffsetY\": \"0\",\n                \"outlineOpacity\": 1,\n                \"fillOpacity\": 1,\n                \"strokeWidth\": \"0\",\n                \"strokeColor\": \"#0cff00\",\n                \"strokeOpacity\": 1,\n                \"textIndent\": 0,\n                \"whiteSpace\": \"normal\",\n                \"overflowWrap\": \"normal\",\n                \"opacity\": 1,\n                \"side\": \"front\",\n                \"maxWidth\": 1,\n                \"curveRadius\": 0,\n                \"direction\": \"auto\"\n            }\n        });\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/uv-scroll.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export uv-scroll',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'uv-scroll.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, {\n            \"uv-scroll\": {\n                \"speed\": {\n                    \"x\": 0,\n                    \"y\": 0\n                },\n                \"increment\": {\n                    \"x\": 0,\n                    \"y\": 0\n                }\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/video-texture.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export video-texture-source and video-texture-target',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'video-texture.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const { node: camera, index: cameraIndex } = utils.nodeWithName(asset, \"Camera\");\n        assert.strictEqual(utils.checkExtensionAdded(camera, 'MOZ_hubs_components'), true);\n\n        const { node: material } = utils.materialWithName(asset, \"Material.001\");\n        assert.strictEqual(utils.checkExtensionAdded(material, 'MOZ_hubs_components'), true);\n\n        const videoTextureSourceExt = camera.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(videoTextureSourceExt, {\n            \"video-texture-source\": {\n                \"resolution\": [\n                    1280,\n                    720\n                ],\n                \"fps\": 15\n            }\n        });\n\n        const videoTextureTargetExt = material.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(videoTextureTargetExt, {\n            \"video-texture-target\": {\n                \"targetBaseColorMap\": true,\n                \"targetEmissiveMap\": true,\n                \"srcNode\": {\n                    \"__mhc_link_type\": \"node\",\n                    \"index\": cameraIndex\n                }\n            }\n        });\n    }\n};"
  },
  {
    "path": "tests/test/tests/video.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export video',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'video.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext[\"video\"], {\n            \"src\": \"https://example.org/files/b4dc97b5-6523-4b61-91ae-d14a80ffd398.mp4\",\n            \"projection\": \"flat\",\n            \"autoPlay\": true,\n            \"controls\": true,\n            \"loop\": true\n        });\n        assert.deepStrictEqual(ext[\"audio-params\"], {\n            \"audioType\": \"pannernode\",\n            \"gain\": 1,\n            \"distanceModel\": \"inverse\",\n            \"refDistance\": 1,\n            \"rolloffFactor\": 1,\n            \"maxDistance\": 10000,\n            \"coneInnerAngle\": 360,\n            \"coneOuterAngle\": 0,\n            \"coneOuterGain\": 0\n        });\n        assert.strictEqual(utils.UUID_REGEX.test(ext['networked']['id']), true);\n    }\n};\n"
  },
  {
    "path": "tests/test/tests/visible.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export visible',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'visible.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext, { visible: { visible: true } });\n    }\n};"
  },
  {
    "path": "tests/test/tests/waypoint.js",
    "content": "const fs = require('fs');\nconst path = require('path')\nconst assert = require('assert');\nconst utils = require('../utils.js');\n\nmodule.exports = {\n    description: 'can export waypoint',\n    test: outDirPath => {\n        let gltfPath = path.resolve(outDirPath, 'waypoint.gltf');\n        const asset = JSON.parse(fs.readFileSync(gltfPath));\n\n        assert.strictEqual(asset.extensionsUsed.includes('MOZ_hubs_components'), true);\n        assert.strictEqual(utils.checkExtensionAdded(asset, 'MOZ_hubs_components'), true);\n\n        const node = asset.nodes[0];\n        assert.strictEqual(utils.checkExtensionAdded(node, 'MOZ_hubs_components'), true);\n\n        const ext = node.extensions['MOZ_hubs_components'];\n        assert.deepStrictEqual(ext['waypoint'], {\n            \"canBeSpawnPoint\": false,\n            \"canBeOccupied\": false,\n            \"canBeClicked\": false,\n            \"willDisableMotion\": false,\n            \"willDisableTeleporting\": false,\n            \"snapToNavMesh\": false,\n            \"willMaintainInitialOrientation\": false\n        });\n        assert.strictEqual(utils.UUID_REGEX.test(ext['networked']['id']), true);\n    }\n};"
  },
  {
    "path": "tests/test/utils.js",
    "content": "const fs = require('fs');\nconst path = require('path');\nconst validator = require('gltf-validator');\n\nconst UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nfunction blenderFileToGltf(blenderVersion, blenderPath, outDirName, done, options = '') {\n  const { exec } = require('child_process');\n  const cmd = `${blenderVersion} -b --factory-startup --addons io_hubs_addon -noaudio ${blenderPath} --python export_gltf.py -- ${outDirName} ${options}`;\n  var prc = exec(cmd, (error, stdout, stderr) => {\n    //if (stderr) process.stderr.write(stderr);\n\n    if (error) {\n      console.log(stdout);\n      done(error);\n      return;\n    }\n    done();\n  });\n}\n\nfunction blenderRoundtripGltf(blenderVersion, gltfPath, outDirName, done, options = '') {\n  const { exec } = require('child_process');\n  const cmd = `${blenderVersion} -b --factory-startup --addons io_hubs_addon -noaudio --python roundtrip_gltf.py -- ${gltfPath} ${outDirName} ${options}`;\n  var prc = exec(cmd, (error, stdout, stderr) => {\n    //if (stderr) process.stderr.write(stderr);\n\n    if (error) {\n      done(error);\n      return;\n    }\n    done();\n  });\n}\n\nfunction validateGltf(gltfPath, done) {\n  const asset = fs.readFileSync(gltfPath);\n  validator.validateBytes(new Uint8Array(asset), {\n    uri: gltfPath,\n    externalResourceFunction: (uri) =>\n      new Promise((resolve, reject) => {\n        uri = path.resolve(path.dirname(gltfPath), decodeURIComponent(uri));\n        // console.info(\"Loading external file: \" + uri);\n        fs.readFile(uri, (err, data) => {\n          if (err) {\n            console.error(err.toString());\n            reject(err.toString());\n            return;\n          }\n          resolve(data);\n        });\n      })\n  }).then((result) => {\n    // [result] will contain validation report in object form.\n    if (result.issues.numErrors > 0) {\n      const errors = result.issues.messages.filter(i => i.severity === 0)\n        .reduce((msg, i, idx) => (idx > 5) ? msg : `${msg}\\n${i.pointer} - ${i.message} (${i.code})`, '');\n      done(new Error(\"Validation failed for \" + gltfPath + '\\nFirst few messages:' + errors), result);\n      return;\n    }\n    done(null, result);\n  }, (result) => {\n    // Promise rejection means that arguments were invalid or validator was unable\n    // to detect file format (glTF or GLB).\n    // [result] will contain exception string.\n    done(result);\n  });\n}\n\nfunction checkExtensionAdded(asset, etxName) {\n  return Object.prototype.hasOwnProperty.call(asset.extensions, etxName);\n}\n\nfunction nodeWithName(gltf, name) {\n  const node = gltf.nodes.filter(node => { return node.name === name; }).pop();\n  const index = gltf.nodes.indexOf(node);\n  return {\n    node,\n    index\n  };\n}\n\nfunction materialWithName(gltf, name) {\n  const node = gltf.materials.filter(node => { return node.name === name; }).pop();\n  const index = gltf.nodes.indexOf(node);\n  return {\n    node,\n    index\n  };\n}\n\nmodule.exports = {\n  UUID_REGEX,\n  blenderFileToGltf,\n  blenderRoundtripGltf,\n  validateGltf,\n  checkExtensionAdded,\n  nodeWithName,\n  materialWithName\n};"
  },
  {
    "path": "third_parties/recast/app/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\nset(CMAKE_OSX_ARCHITECTURES \"arm64;x86_64\" CACHE STRING \"\" FORCE)\n\nproject(RecastBlenderAddon LANGUAGES CXX)\n\nset(BUILD_TEST_APP_EXE OFF CACHE BOOL \"Build test app exe file\")\nset(BUILD_LIB ON CACHE BOOL \"Build dll file\")\nset(RECAST_LIB \"${CMAKE_CURRENT_SOURCE_DIR}/../recast/Recast/libRecast.a\" CACHE PATH \"Path to recast.lib file.\")\nset(RECAST_ROOT_DIR \"${CMAKE_CURRENT_SOURCE_DIR}/../recast\" CACHE PATH \"Path to recast root directory.\")\nset(VERBOSE_LOGS OFF CACHE BOOL \"Print entry and result values of arrays\")\n\nset(CMAKE_INCLUDE_CURRENT_DIR ON)\nset(CMAKE_CXX_STANDARD 11)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\n\ninclude_directories(${RECAST_ROOT_DIR}/Recast/Include)\n\nadd_definitions(-DRECASTBLENDERADDON_LIBRARY)\n\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS_INIT} -fPIC\")\n\nif(VERBOSE_LOGS)\n    add_definitions(-DVERBOSE_LOGS)\nendif(VERBOSE_LOGS)\n\nif(BUILD_LIB)\n    add_library(RecastBlenderAddon SHARED recast-capi.cpp mesh_navmesh.cpp)\n    target_link_libraries(RecastBlenderAddon ${RECAST_LIB})\nendif(BUILD_LIB)\n"
  },
  {
    "path": "third_parties/recast/app/main.cpp",
    "content": "/*\n * ***** BEGIN GPL LICENSE BLOCK *****\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; either version 2\n * of the License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software Foundation,\n * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n * Contributor(s): Przemysław Bągard,\n *\n * ***** END GPL LICENSE BLOCK *****\n */\n\n#include <stdio.h>\n#include <string.h>\n#include \"recast-capi.h\"\n#include \"mesh_navmesh.h\"\n\nint main(int argc, char *argv[])\n{\n    RecastData recastData;\n    recastData.cellsize = 0.300000f;\n    recastData.cellheight = 0.200000f;\n    recastData.agentmaxslope = 0.785398f;\n    recastData.agentmaxclimb = 0.9f;\n    recastData.agentheight = 2.0f;\n    recastData.agentradius = 0.6f;\n    recastData.edgemaxlen = 12.0f;\n    recastData.edgemaxerror = 1.3f;\n    recastData.regionminsize = 8.0;\n    recastData.regionmergesize = 20.0;\n    recastData.vertsperpoly = 6;\n    recastData.detailsampledist = 6.0;\n    recastData.detailsamplemaxerror = 1.0;\n    recastData.partitioning = 0;\n    recastData.pad1 = 0;\n\n    int reportsMaxChars = 128;\n    char msg[128];\n    strncpy(msg, \"\", reportsMaxChars);\n\n    int nverts = 12;\n    const int ntris = 14;\n    float verts[] = {\n      1.000000, 1.000000, -1.000000,\n      1.000000, -1.000000, -1.000000,\n      1.000000, 1.000000, 1.000000,\n      1.000000, -1.000000, 1.000000,\n      -1.000000, 1.000000, -1.000000,\n      -1.000000, -1.000000, -1.000000,\n      -1.000000, 1.000000, 1.000000,\n      -1.000000, -1.000000, 1.000000,\n      -10.000000, 0.000000, 10.000000,\n      10.000000, 0.000000, 10.000000,\n      -10.000000, 0.000000, -10.000000,\n      10.000000, 0.000000, -10.000000\n    };\n    int tris[] = {\n        4, 2, 0,\n        2, 7, 3,\n        6, 5, 7,\n        1, 7, 5,\n        0, 3, 1,\n        4, 1, 5,\n        4, 6, 2,\n        2, 6, 7,\n        6, 4, 5,\n        1, 3, 7,\n        0, 2, 3,\n        4, 0, 1,\n        9, 10, 8,\n        9, 11, 10\n    };\n\n    for (int i = 0; i < ntris; ++i) {\n        for (int j = 0; j < 3; ++j) {\n            int vertexIndex = tris[i*3+j];\n            printf(\"trisVertex[%i][%i] = (%f, %f, %f)\\n\", i, j, verts[vertexIndex*3+0], verts[vertexIndex*3+1], verts[vertexIndex*3+2]);\n        }\n    }\n\n\n    struct recast_polyMesh_holder pmeshHolder;\n    struct recast_polyMeshDetail_holder dmeshHolder;\n\n    int result = buildNavMesh(&recastData, nverts, verts, ntris, tris,\n                              &pmeshHolder, &dmeshHolder,\n                              msg, reportsMaxChars);\n\n//    int buildNavMesh(const RecastData *recastParams, int nverts, float *verts, int ntris, int *tris,\n//                     struct recast_polyMesh_holder *pmeshHolder, struct recast_polyMeshDetail_holder *dmeshHolder,\n//                     char *reports, int reportsMaxChars)\n\n    freeNavMesh(&pmeshHolder, &dmeshHolder, msg, reportsMaxChars);\n\n    return 0;\n}\n"
  },
  {
    "path": "third_parties/recast/app/mesh_navmesh.cpp",
    "content": "/*\n * ***** BEGIN GPL LICENSE BLOCK *****\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; either version 2\n * of the License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software Foundation,\n * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n * The Original Code is Copyright (C) 2011 by Blender Foundation\n * All rights reserved.\n *\n * This file was forked from Blender 2.79b.\n *\n * Contributor(s): Benoit Bolsee,\n *                 Nick Samarin,\n *                 Przemysław Bągard,\n *\n * ***** END GPL LICENSE BLOCK *****\n */\n\n/** \\file blender/editors/mesh/mesh_navmesh.c\n *  \\ingroup edmesh\n */\n\n#define _USE_MATH_DEFINES\n#include <cmath>\n#include \"math.h\"\n#include <Recast.h>\n#include <stdio.h>\n#include <string.h>\n#include \"mesh_navmesh.h\"\n#include \"recast-capi.h\"\n\n#define RAD2DEGF(_rad) ((_rad)*(float)(180.0/M_PI))\n#define DEG2RADF(_deg) ((_deg)*(float)(M_PI/180.0))\n\nint buildNavMesh(const RecastData *recastParams, int nverts, float *verts, int ntris, int *tris,\n                 struct recast_polyMesh_holder *pmeshHolder, struct recast_polyMeshDetail_holder *dmeshHolder,\n                 char *reports, int reportsMaxChars)\n{\n    float bmin[3], bmax[3];\n    struct recast_heightfield *solid;\n    unsigned char *triflags;\n    struct recast_compactHeightfield *chf;\n    struct recast_contourSet *cset;\n    int width, height, walkableHeight, walkableClimb, walkableRadius;\n    int minRegionArea, mergeRegionArea, maxEdgeLen;\n    float detailSampleDist, detailSampleMaxError;\n\n    printf(\"--- buildNavMesh start params\\n\");\n    printf(\"Cell size: %f\\n\", recastParams->cellsize);\n    printf(\"nverts: %i\\n\", nverts);\n    printf(\"ntris: %i\\n\", ntris);\n    printf(\"reportsMaxChars: %i\\n\", reportsMaxChars);\n#ifdef VERBOSE_LOGS\n    for (int i = 0; i < nverts; ++i) {\n        printf(\"verts[%i]: (%f, %f, %f)\\n\", i, verts[i*3+0], verts[i*3+1], verts[i*3+2]);\n    }\n    for (int i = 0; i < ntris; ++i) {\n        printf(\"tris[%i]: (%i, %i, %i)\\n\", i, tris[i*3+0], tris[i*3+1], tris[i*3+2]);\n    }\n#endif\n    printf(\"buildNavMesh start params ---\\n\");\n\n\n    /* clear reports string */\n    strncpy(reports, \"\", reportsMaxChars);\n    pmeshHolder->pmesh = NULL;\n    dmeshHolder->dmesh = NULL;\n\n    recast_calcBounds(verts, nverts, bmin, bmax);\n\n    /* ** Step 1. Initialize build config ** */\n    walkableHeight = (int)ceilf(recastParams->agentheight / recastParams->cellheight);\n    walkableClimb = (int)floorf(recastParams->agentmaxclimb / recastParams->cellheight);\n    walkableRadius = (int)ceilf(recastParams->agentradius / recastParams->cellsize);\n    minRegionArea = (int)(recastParams->regionminsize * recastParams->regionminsize);\n    mergeRegionArea = (int)(recastParams->regionmergesize * recastParams->regionmergesize);\n    maxEdgeLen = (int)(recastParams->edgemaxlen / recastParams->cellsize);\n    detailSampleDist = recastParams->detailsampledist < 0.9f ? 0 :\n                       recastParams->cellsize * recastParams->detailsampledist;\n    detailSampleMaxError = recastParams->cellheight * recastParams->detailsamplemaxerror;\n\n    /* Set the area where the navigation will be build. */\n    recast_calcGridSize(bmin, bmax, recastParams->cellsize, &width, &height);\n\n    /* zero dimensions cause zero alloc later on [#33758] */\n    if (width <= 0 || height <= 0) {\n        strncpy(reports, \"Object has a width or height of zero\", reportsMaxChars);\n        return 0;\n    }\n\n    /* ** Step 2: Rasterize input polygon soup ** */\n    /* Allocate voxel heightfield where we rasterize our input data to */\n    solid = recast_newHeightfield();\n\n    if (!recast_createHeightfield(solid, width, height, bmin, bmax, recastParams->cellsize, recastParams->cellheight)) {\n        recast_destroyHeightfield(solid);\n        strncpy(reports, \"Failed to create height field\", reportsMaxChars);\n        return 0;\n    }\n\n    /* Allocate array that can hold triangle flags */\n//    triflags = MEM_callocN(sizeof(unsigned char) * ntris, \"buildNavMesh triflags\");\n//    triflags = (unsigned char *)calloc(ntris, sizeof(unsigned char));\n    triflags = new unsigned char[ntris];\n    memset(triflags, 0, ntris*sizeof(unsigned char));\n\n    /* Find triangles which are walkable based on their slope and rasterize them */\n    recast_markWalkableTriangles(RAD2DEGF(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags);\n    recast_rasterizeTriangles(verts, nverts, tris, triflags, ntris, solid, 1);\n//    MEM_freeN(triflags);\n//    free(triflags);\n    delete [] triflags;\n\n\n    /* ** Step 3: Filter walkables surfaces ** */\n    recast_filterLowHangingWalkableObstacles(walkableClimb, solid);\n    recast_filterLedgeSpans(walkableHeight, walkableClimb, solid);\n    recast_filterWalkableLowHeightSpans(walkableHeight, solid);\n\n    /* ** Step 4: Partition walkable surface to simple regions ** */\n\n    chf = recast_newCompactHeightfield();\n    if (!recast_buildCompactHeightfield(walkableHeight, walkableClimb, solid, chf)) {\n        recast_destroyHeightfield(solid);\n        recast_destroyCompactHeightfield(chf);\n\n        strncpy(reports, \"Failed to create compact height field\", reportsMaxChars);\n        return 0;\n    }\n\n    recast_destroyHeightfield(solid);\n    solid = NULL;\n\n    if (!recast_erodeWalkableArea(walkableRadius, chf)) {\n        recast_destroyCompactHeightfield(chf);\n\n        strncpy(reports, \"Failed to erode walkable area\", reportsMaxChars);\n        return 0;\n    }\n\n    if (recastParams->partitioning == RC_PARTITION_WATERSHED) {\n        /* Prepare for region partitioning, by calculating distance field along the walkable surface */\n        if (!recast_buildDistanceField(chf)) {\n            recast_destroyCompactHeightfield(chf);\n\n            strncpy(reports, \"Failed to build distance field\", reportsMaxChars);\n            return 0;\n        }\n\n        /* Partition the walkable surface into simple regions without holes */\n        if (!recast_buildRegions(chf, 0, minRegionArea, mergeRegionArea)) {\n            recast_destroyCompactHeightfield(chf);\n\n            strncpy(reports, \"Failed to build watershed regions\", reportsMaxChars);\n            return 0;\n        }\n    }\n    else if (recastParams->partitioning == RC_PARTITION_MONOTONE) {\n        /* Partition the walkable surface into simple regions without holes */\n        /* Monotone partitioning does not need distancefield. */\n        if (!recast_buildRegionsMonotone(chf, 0, minRegionArea, mergeRegionArea)) {\n            recast_destroyCompactHeightfield(chf);\n\n            strncpy(reports, \"Failed to build monotone regions\", reportsMaxChars);\n            return 0;\n        }\n    }\n    else { /* RC_PARTITION_LAYERS */\n        /* Partition the walkable surface into simple regions without holes */\n        if (!recast_buildLayerRegions(chf, 0, minRegionArea)) {\n            recast_destroyCompactHeightfield(chf);\n\n            strncpy(reports, \"Failed to build layer regions\", reportsMaxChars);\n            return 0;\n        }\n    }\n\n    /* ** Step 5: Trace and simplify region contours ** */\n    /* Create contours */\n    cset = recast_newContourSet();\n\n    if (!recast_buildContours(chf, recastParams->edgemaxerror, maxEdgeLen, cset, RECAST_CONTOUR_TESS_WALL_EDGES)) {\n        recast_destroyCompactHeightfield(chf);\n        recast_destroyContourSet(cset);\n\n        strncpy(reports, \"Failed to build contours\", reportsMaxChars);\n        return 0;\n    }\n\n    /* ** Step 6: Build polygons mesh from contours ** */\n    pmeshHolder->pmesh = recast_newPolyMesh();\n    if (!recast_buildPolyMesh(cset, recastParams->vertsperpoly, pmeshHolder->pmesh)) {\n        recast_destroyCompactHeightfield(chf);\n        recast_destroyContourSet(cset);\n        recast_destroyPolyMesh(pmeshHolder->pmesh);\n\n        strncpy(reports, \"Failed to build poly mesh\", reportsMaxChars);\n        return 0;\n    }\n\n\n    /* ** Step 7: Create detail mesh which allows to access approximate height on each polygon ** */\n\n    dmeshHolder->dmesh = recast_newPolyMeshDetail();\n    if (!recast_buildPolyMeshDetail(pmeshHolder->pmesh, chf, detailSampleDist, detailSampleMaxError, dmeshHolder->dmesh)) {\n        recast_destroyCompactHeightfield(chf);\n        recast_destroyContourSet(cset);\n        recast_destroyPolyMesh(pmeshHolder->pmesh);\n        recast_destroyPolyMeshDetail(dmeshHolder->dmesh);\n\n        strncpy(reports, \"Failed to build poly mesh detail\", reportsMaxChars);\n        return 0;\n    }\n\n    recast_destroyCompactHeightfield(chf);\n    recast_destroyContourSet(cset);\n\n    printf(\"--- buildNavMesh end params\\n\");\n    if(pmeshHolder->pmesh) {\n        printf(\"- pmesh:\\n\");\n        struct rcPolyMesh* pmesh = (struct rcPolyMesh*)(pmeshHolder->pmesh);\n        printf(\"pmesh->nverts: %i\\n\", pmesh->nverts);\n        printf(\"pmesh->npolys: %i\\n\", pmesh->npolys);\n        printf(\"pmesh->maxpolys: %i\\n\", pmesh->maxpolys);\n        printf(\"pmesh->nvp: %i\\n\", pmesh->nvp);\n        printf(\"pmesh->bmin: (%f, %f, %f)\\n\", pmesh->bmin[0], pmesh->bmin[1], pmesh->bmin[2]);\n        printf(\"pmesh->bmax: (%f, %f, %f)\\n\", pmesh->bmax[0], pmesh->bmax[1], pmesh->bmax[2]);\n        printf(\"pmesh->cs: %f\\n\", pmesh->cs);\n        printf(\"pmesh->ch: %f\\n\", pmesh->ch);\n        printf(\"pmesh->borderSize: %i\\n\", pmesh->borderSize);\n        printf(\"pmesh->maxEdgeError: %f\\n\", pmesh->maxEdgeError);\n#ifdef VERBOSE_LOGS\n        for (int i = 0; i < pmesh->nverts; ++i) {\n            printf(\"pmesh->verts[%i]: (%u, %u, %u)\\n\", i, pmesh->verts[i*3+0], pmesh->verts[i*3+1], pmesh->verts[i*3+2]);\n        }\n#endif\n    }\n\n    if(dmeshHolder->dmesh) {\n        printf(\"- dmesh:\\n\");\n        struct rcPolyMeshDetail* dmesh = (struct rcPolyMeshDetail*)(dmeshHolder->dmesh);\n        printf(\"dmesh->nmeshes: %i\\n\", dmesh->nmeshes);\n        printf(\"dmesh->nverts: %i\\n\", dmesh->nverts);\n        printf(\"dmesh->ntris: %i\\n\", dmesh->ntris);\n#ifdef VERBOSE_LOGS\n        for (int i = 0; i < dmesh->nverts; ++i) {\n            printf(\"dmesh->verts[%i]: (%f, %f, %f)\\n\", i, dmesh->verts[i*3+0], dmesh->verts[i*3+1], dmesh->verts[i*3+2]);\n        }\n        for (int i = 0; i < dmesh->ntris; ++i) {\n            printf(\"dmesh->tris[%i]: (%u, %u, %u, %u)\\n\", i, dmesh->tris[i*4+0], dmesh->tris[i*4+1], dmesh->tris[i*4+2], dmesh->tris[i*4+3]);\n        }\n        for (int i = 0; i < dmesh->nmeshes; ++i) {\n            printf(\"dmesh->meshes[%i]: (%u, %u, %u, %u)\\n\", i, dmesh->meshes[i*4+0], dmesh->meshes[i*4+1], dmesh->meshes[i*4+2], dmesh->meshes[i*4+3]);\n        }\n#endif\n    }\n    printf(\"buildNavMesh end params ---\\n\");\n\n    return 1;\n}\n\n//int Sample_SoloMesh::handleBuild()\n//{\n//\tif (!m_geom || !m_geom->getMesh())\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Input mesh is not specified.\");\n//\t\treturn 0;\n//\t}\n\n//\tcleanup();\n\n//\tconst float* bmin = m_geom->getNavMeshBoundsMin();\n//\tconst float* bmax = m_geom->getNavMeshBoundsMax();\n//\tconst float* verts = m_geom->getMesh()->getVerts();\n//\tconst int nverts = m_geom->getMesh()->getVertCount();\n//\tconst int* tris = m_geom->getMesh()->getTris();\n//\tconst int ntris = m_geom->getMesh()->getTriCount();\n\n//\t//\n//\t// Step 1. Initialize build config.\n//\t//\n\n//\t// Init build configuration from GUI\n//\tmemset(&m_cfg, 0, sizeof(m_cfg));\n//\tm_cfg.cs = m_cellSize;\n//\tm_cfg.ch = m_cellHeight;\n//\tm_cfg.walkableSlopeAngle = m_agentMaxSlope;\n//\tm_cfg.walkableHeight = (int)ceilf(m_agentHeight / m_cfg.ch);\n//\tm_cfg.walkableClimb = (int)floorf(m_agentMaxClimb / m_cfg.ch);\n//\tm_cfg.walkableRadius = (int)ceilf(m_agentRadius / m_cfg.cs);\n//\tm_cfg.maxEdgeLen = (int)(m_edgeMaxLen / m_cellSize);\n//\tm_cfg.maxSimplificationError = m_edgeMaxError;\n//\tm_cfg.minRegionArea = (int)rcSqr(m_regionMinSize);\t\t// Note: area = size*size\n//\tm_cfg.mergeRegionArea = (int)rcSqr(m_regionMergeSize);\t// Note: area = size*size\n//\tm_cfg.maxVertsPerPoly = (int)m_vertsPerPoly;\n//\tm_cfg.detailSampleDist = m_detailSampleDist < 0.9f ? 0 : m_cellSize * m_detailSampleDist;\n//\tm_cfg.detailSampleMaxError = m_cellHeight * m_detailSampleMaxError;\n\n//\t// Set the area where the navigation will be build.\n//\t// Here the bounds of the input mesh are used, but the\n//\t// area could be specified by an user defined box, etc.\n//\trcVcopy(m_cfg.bmin, bmin);\n//\trcVcopy(m_cfg.bmax, bmax);\n//\trcCalcGridSize(m_cfg.bmin, m_cfg.bmax, m_cfg.cs, &m_cfg.width, &m_cfg.height);\n\n//\t// Reset build times gathering.\n//\tm_ctx->resetTimers();\n\n//\t// Start the build process.\n//\tm_ctx->startTimer(RC_TIMER_TOTAL);\n\n//\tm_ctx->log(RC_LOG_PROGRESS, \"Building navigation:\");\n//\tm_ctx->log(RC_LOG_PROGRESS, \" - %d x %d cells\", m_cfg.width, m_cfg.height);\n//\tm_ctx->log(RC_LOG_PROGRESS, \" - %.1fK verts, %.1fK tris\", nverts/1000.0f, ntris/1000.0f);\n\n//\t//\n//\t// Step 2. Rasterize input polygon soup.\n//\t//\n\n//\t// Allocate voxel heightfield where we rasterize our input data to.\n//\tm_solid = rcAllocHeightfield();\n//\tif (!m_solid)\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Out of memory 'solid'.\");\n//\t\treturn 0;\n//\t}\n//\tif (!rcCreateHeightfield(m_ctx, *m_solid, m_cfg.width, m_cfg.height, m_cfg.bmin, m_cfg.bmax, m_cfg.cs, m_cfg.ch))\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not create solid heightfield.\");\n//\t\treturn 0;\n//\t}\n\n//\t// Allocate array that can hold triangle area types.\n//\t// If you have multiple meshes you need to process, allocate\n//\t// and array which can hold the max number of triangles you need to process.\n//\tm_triareas = new unsigned char[ntris];\n//\tif (!m_triareas)\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Out of memory 'm_triareas' (%d).\", ntris);\n//\t\treturn 0;\n//\t}\n\n//\t// Find triangles which are walkable based on their slope and rasterize them.\n//\t// If your input data is multiple meshes, you can transform them here, calculate\n//\t// the are type for each of the meshes and rasterize them.\n//\tmemset(m_triareas, 0, ntris*sizeof(unsigned char));\n//\trcMarkWalkableTriangles(m_ctx, m_cfg.walkableSlopeAngle, verts, nverts, tris, ntris, m_triareas);\n//\tif (!rcRasterizeTriangles(m_ctx, verts, nverts, tris, m_triareas, ntris, *m_solid, m_cfg.walkableClimb))\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not rasterize triangles.\");\n//\t\treturn 0;\n//\t}\n\n//\tif (!m_keepInterResults)\n//\t{\n//\t\tdelete [] m_triareas;\n//\t\tm_triareas = 0;\n//\t}\n\n//\t//\n//\t// Step 3. Filter walkables surfaces.\n//\t//\n\n//\t// Once all geoemtry is rasterized, we do initial pass of filtering to\n//\t// remove unwanted overhangs caused by the conservative rasterization\n//\t// as well as filter spans where the character cannot possibly stand.\n//\tif (m_filterLowHangingObstacles)\n//\t\trcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid);\n//\tif (m_filterLedgeSpans)\n//\t\trcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);\n//\tif (m_filterWalkableLowHeightSpans)\n//\t\trcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid);\n\n\n//\t//\n//\t// Step 4. Partition walkable surface to simple regions.\n//\t//\n\n//\t// Compact the heightfield so that it is faster to handle from now on.\n//\t// This will result more cache coherent data as well as the neighbours\n//\t// between walkable cells will be calculated.\n//\tm_chf = rcAllocCompactHeightfield();\n//\tif (!m_chf)\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Out of memory 'chf'.\");\n//\t\treturn 0;\n//\t}\n//\tif (!rcBuildCompactHeightfield(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid, *m_chf))\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not build compact data.\");\n//\t\treturn 0;\n//\t}\n\n//\tif (!m_keepInterResults)\n//\t{\n//\t\trcFreeHeightField(m_solid);\n//\t\tm_solid = 0;\n//\t}\n\n//\t// Erode the walkable area by agent radius.\n//\tif (!rcErodeWalkableArea(m_ctx, m_cfg.walkableRadius, *m_chf))\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not erode.\");\n//\t\treturn 0;\n//\t}\n\n//\t// (Optional) Mark areas.\n//\tconst ConvexVolume* vols = m_geom->getConvexVolumes();\n//\tfor (int i  = 0; i < m_geom->getConvexVolumeCount(); ++i)\n//\t\trcMarkConvexPolyArea(m_ctx, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, (unsigned char)vols[i].area, *m_chf);\n\n\n//\t// Partition the heightfield so that we can use simple algorithm later to triangulate the walkable areas.\n//\t// There are 3 martitioning methods, each with some pros and cons:\n//\t// 1) Watershed partitioning\n//\t//   - the classic Recast partitioning\n//\t//   - creates the nicest tessellation\n//\t//   - usually slowest\n//\t//   - partitions the heightfield into nice regions without holes or overlaps\n//\t//   - the are some corner cases where this method creates produces holes and overlaps\n//\t//      - holes may appear when a small obstacles is close to large open area (triangulation can handle this)\n//\t//      - overlaps may occur if you have narrow spiral corridors (i.e stairs), this make triangulation to fail\n//\t//   * generally the best choice if you precompute the nacmesh, use this if you have large open areas\n//\t// 2) Monotone partioning\n//\t//   - fastest\n//\t//   - partitions the heightfield into regions without holes and overlaps (guaranteed)\n//\t//   - creates long thin polygons, which sometimes causes paths with detours\n//\t//   * use this if you want fast navmesh generation\n//\t// 3) Layer partitoining\n//\t//   - quite fast\n//\t//   - partitions the heighfield into non-overlapping regions\n//\t//   - relies on the triangulation code to cope with holes (thus slower than monotone partitioning)\n//\t//   - produces better triangles than monotone partitioning\n//\t//   - does not have the corner cases of watershed partitioning\n//\t//   - can be slow and create a bit ugly tessellation (still better than monotone)\n//\t//     if you have large open areas with small obstacles (not a problem if you use tiles)\n//\t//   * good choice to use for tiled navmesh with medium and small sized tiles\n\n//\tif (m_partitionType == SAMPLE_PARTITION_WATERSHED)\n//\t{\n//\t\t// Prepare for region partitioning, by calculating distance field along the walkable surface.\n//\t\tif (!rcBuildDistanceField(m_ctx, *m_chf))\n//\t\t{\n//\t\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not build distance field.\");\n//\t\t\treturn 0;\n//\t\t}\n\n//\t\t// Partition the walkable surface into simple regions without holes.\n//\t\tif (!rcBuildRegions(m_ctx, *m_chf, 0, m_cfg.minRegionArea, m_cfg.mergeRegionArea))\n//\t\t{\n//\t\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not build watershed regions.\");\n//\t\t\treturn 0;\n//\t\t}\n//\t}\n//\telse if (m_partitionType == SAMPLE_PARTITION_MONOTONE)\n//\t{\n//\t\t// Partition the walkable surface into simple regions without holes.\n//\t\t// Monotone partitioning does not need distancefield.\n//\t\tif (!rcBuildRegionsMonotone(m_ctx, *m_chf, 0, m_cfg.minRegionArea, m_cfg.mergeRegionArea))\n//\t\t{\n//\t\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not build monotone regions.\");\n//\t\t\treturn 0;\n//\t\t}\n//\t}\n//\telse // SAMPLE_PARTITION_LAYERS\n//\t{\n//\t\t// Partition the walkable surface into simple regions without holes.\n//\t\tif (!rcBuildLayerRegions(m_ctx, *m_chf, 0, m_cfg.minRegionArea))\n//\t\t{\n//\t\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not build layer regions.\");\n//\t\t\treturn 0;\n//\t\t}\n//\t}\n\n//\t//\n//\t// Step 5. Trace and simplify region contours.\n//\t//\n\n//\t// Create contours.\n//\tm_cset = rcAllocContourSet();\n//\tif (!m_cset)\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Out of memory 'cset'.\");\n//\t\treturn 0;\n//\t}\n//\tif (!rcBuildContours(m_ctx, *m_chf, m_cfg.maxSimplificationError, m_cfg.maxEdgeLen, *m_cset))\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not create contours.\");\n//\t\treturn 0;\n//\t}\n\n//\t//\n//\t// Step 6. Build polygons mesh from contours.\n//\t//\n\n//\t// Build polygon navmesh from the contours.\n//\tm_pmesh = rcAllocPolyMesh();\n//\tif (!m_pmesh)\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Out of memory 'pmesh'.\");\n//\t\treturn 0;\n//\t}\n//\tif (!rcBuildPolyMesh(m_ctx, *m_cset, m_cfg.maxVertsPerPoly, *m_pmesh))\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not triangulate contours.\");\n//\t\treturn 0;\n//\t}\n\n//\t//\n//\t// Step 7. Create detail mesh which allows to access approximate height on each polygon.\n//\t//\n\n//\tm_dmesh = rcAllocPolyMeshDetail();\n//\tif (!m_dmesh)\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Out of memory 'pmdtl'.\");\n//\t\treturn 0;\n//\t}\n\n//\tif (!rcBuildPolyMeshDetail(m_ctx, *m_pmesh, *m_chf, m_cfg.detailSampleDist, m_cfg.detailSampleMaxError, *m_dmesh))\n//\t{\n//\t\tm_ctx->log(RC_LOG_ERROR, \"buildNavigation: Could not build detail mesh.\");\n//\t\treturn 0;\n//\t}\n\n//\tif (!m_keepInterResults)\n//\t{\n//\t\trcFreeCompactHeightfield(m_chf);\n//\t\tm_chf = 0;\n//\t\trcFreeContourSet(m_cset);\n//\t\tm_cset = 0;\n//\t}\n\n//\t// At this point the navigation mesh data is ready, you can access it from m_pmesh.\n//\t// See duDebugDrawPolyMesh or dtCreateNavMeshData as examples how to access the data.\n\n//\t//\n//\t// (Optional) Step 8. Create Detour data from Recast poly mesh.\n//\t//\n\n//\t// The GUI may allow more max points per polygon than Detour can handle.\n//\t// Only build the detour navmesh if we do not exceed the limit.\n//\tif (m_cfg.maxVertsPerPoly <= DT_VERTS_PER_POLYGON)\n//\t{\n//\t\tunsigned char* navData = 0;\n//\t\tint navDataSize = 0;\n\n//\t\t// Update poly flags from areas.\n//\t\tfor (int i = 0; i < m_pmesh->npolys; ++i)\n//\t\t{\n//\t\t\tif (m_pmesh->areas[i] == RC_WALKABLE_AREA)\n//\t\t\t\tm_pmesh->areas[i] = SAMPLE_POLYAREA_GROUND;\n\n//\t\t\tif (m_pmesh->areas[i] == SAMPLE_POLYAREA_GROUND ||\n//\t\t\t\tm_pmesh->areas[i] == SAMPLE_POLYAREA_GRASS ||\n//\t\t\t\tm_pmesh->areas[i] == SAMPLE_POLYAREA_ROAD)\n//\t\t\t{\n//\t\t\t\tm_pmesh->flags[i] = SAMPLE_POLYFLAGS_WALK;\n//\t\t\t}\n//\t\t\telse if (m_pmesh->areas[i] == SAMPLE_POLYAREA_WATER)\n//\t\t\t{\n//\t\t\t\tm_pmesh->flags[i] = SAMPLE_POLYFLAGS_SWIM;\n//\t\t\t}\n//\t\t\telse if (m_pmesh->areas[i] == SAMPLE_POLYAREA_DOOR)\n//\t\t\t{\n//\t\t\t\tm_pmesh->flags[i] = SAMPLE_POLYFLAGS_WALK | SAMPLE_POLYFLAGS_DOOR;\n//\t\t\t}\n//\t\t}\n\n\n//\t\tdtNavMeshCreateParams params;\n//\t\tmemset(&params, 0, sizeof(params));\n//\t\tparams.verts = m_pmesh->verts;\n//\t\tparams.vertCount = m_pmesh->nverts;\n//\t\tparams.polys = m_pmesh->polys;\n//\t\tparams.polyAreas = m_pmesh->areas;\n//\t\tparams.polyFlags = m_pmesh->flags;\n//\t\tparams.polyCount = m_pmesh->npolys;\n//\t\tparams.nvp = m_pmesh->nvp;\n//\t\tparams.detailMeshes = m_dmesh->meshes;\n//\t\tparams.detailVerts = m_dmesh->verts;\n//\t\tparams.detailVertsCount = m_dmesh->nverts;\n//\t\tparams.detailTris = m_dmesh->tris;\n//\t\tparams.detailTriCount = m_dmesh->ntris;\n//\t\tparams.offMeshConVerts = m_geom->getOffMeshConnectionVerts();\n//\t\tparams.offMeshConRad = m_geom->getOffMeshConnectionRads();\n//\t\tparams.offMeshConDir = m_geom->getOffMeshConnectionDirs();\n//\t\tparams.offMeshConAreas = m_geom->getOffMeshConnectionAreas();\n//\t\tparams.offMeshConFlags = m_geom->getOffMeshConnectionFlags();\n//\t\tparams.offMeshConUserID = m_geom->getOffMeshConnectionId();\n//\t\tparams.offMeshConCount = m_geom->getOffMeshConnectionCount();\n//\t\tparams.walkableHeight = m_agentHeight;\n//\t\tparams.walkableRadius = m_agentRadius;\n//\t\tparams.walkableClimb = m_agentMaxClimb;\n//\t\trcVcopy(params.bmin, m_pmesh->bmin);\n//\t\trcVcopy(params.bmax, m_pmesh->bmax);\n//\t\tparams.cs = m_cfg.cs;\n//\t\tparams.ch = m_cfg.ch;\n//\t\tparams.buildBvTree = true;\n\n//\t\tif (!dtCreateNavMeshData(&params, &navData, &navDataSize))\n//\t\t{\n//\t\t\tm_ctx->log(RC_LOG_ERROR, \"Could not build Detour navmesh.\");\n//\t\t\treturn 0;\n//\t\t}\n\n//\t\tm_navMesh = dtAllocNavMesh();\n//\t\tif (!m_navMesh)\n//\t\t{\n//\t\t\tdtFree(navData);\n//\t\t\tm_ctx->log(RC_LOG_ERROR, \"Could not create Detour navmesh\");\n//\t\t\treturn 0;\n//\t\t}\n\n//\t\tdtStatus status;\n\n//\t\tstatus = m_navMesh->init(navData, navDataSize, DT_TILE_FREE_DATA);\n//\t\tif (dtStatusFailed(status))\n//\t\t{\n//\t\t\tdtFree(navData);\n//\t\t\tm_ctx->log(RC_LOG_ERROR, \"Could not init Detour navmesh\");\n//\t\t\treturn 0;\n//\t\t}\n\n//\t\tstatus = m_navQuery->init(m_navMesh, 2048);\n//\t\tif (dtStatusFailed(status))\n//\t\t{\n//\t\t\tm_ctx->log(RC_LOG_ERROR, \"Could not init Detour navmesh query\");\n//\t\t\treturn 0;\n//\t\t}\n//\t}\n\n//\tm_ctx->stopTimer(RC_TIMER_TOTAL);\n\n//\t// Show performance stats.\n//\tduLogBuildTimes(*m_ctx, m_ctx->getAccumulatedTime(RC_TIMER_TOTAL));\n//\tm_ctx->log(RC_LOG_PROGRESS, \">> Polymesh: %d vertices  %d polygons\", m_pmesh->nverts, m_pmesh->npolys);\n\n//\tm_totalBuildTimeMs = m_ctx->getAccumulatedTime(RC_TIMER_TOTAL)/1000.0f;\n\n//\tif (m_tool)\n//\t\tm_tool->init(this);\n//\tinitToolStates(this);\n\n//\treturn true;\n//}\n\n\nint freeNavMesh(struct recast_polyMesh_holder *pmeshHolder, struct recast_polyMeshDetail_holder *dmeshHolder,\n                char *reports, int reportsMaxChars) {\n\n    /* clear reports string */\n    strncpy(reports, \"\", reportsMaxChars);\n\n    if(pmeshHolder) {\n        recast_destroyPolyMesh(pmeshHolder->pmesh);\n    }\n    if(dmeshHolder) {\n        recast_destroyPolyMeshDetail(dmeshHolder->dmesh);\n    }\n\n    return 1;\n}\n\n//static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, struct recast_polyMeshDetail *dmesh,\n//                                  Base *base, unsigned int lay)\n//{\n//\tfloat co[3], rot[3];\n//\tBMEditMesh *em;\n//\tint i, j, k;\n//\tunsigned short *v;\n//\tint face[3];\n//\tScene *scene = CTX_data_scene(C);\n//\tObject *obedit;\n//\tint createob = base == NULL;\n//\tint nverts, nmeshes, nvp;\n//\tunsigned short *verts, *polys;\n//\tunsigned int *meshes;\n//\tfloat bmin[3], cs, ch, *dverts;\n//\tunsigned char *tris;\n\n//\tzero_v3(co);\n//\tzero_v3(rot);\n\n//\tif (createob) {\n//\t\t/* create new object */\n//\t\tobedit = ED_object_add_type(C, OB_MESH, \"Navmesh\", co, rot, false, lay);\n//\t}\n//\telse {\n//\t\tobedit = base->object;\n//\t\tBKE_scene_base_deselect_all(scene);\n//\t\tBKE_scene_base_select(scene, base);\n//\t\tcopy_v3_v3(obedit->loc, co);\n//\t\tcopy_v3_v3(obedit->rot, rot);\n//\t}\n\n//\tED_object_editmode_enter(C, EM_DO_UNDO | EM_IGNORE_LAYER);\n//\tem = BKE_editmesh_from_object(obedit);\n\n//\tif (!createob) {\n//\t\t/* clear */\n//\t\tEDBM_mesh_clear(em);\n//\t}\n\n//\t/* create verts for polygon mesh */\n//\tverts = recast_polyMeshGetVerts(pmesh, &nverts);\n//\trecast_polyMeshGetBoundbox(pmesh, bmin, NULL);\n//\trecast_polyMeshGetCell(pmesh, &cs, &ch);\n\n//\tfor (i = 0; i < nverts; i++) {\n//\t\tv = &verts[3 * i];\n//\t\tco[0] = bmin[0] + v[0] * cs;\n//\t\tco[1] = bmin[1] + v[1] * ch;\n//\t\tco[2] = bmin[2] + v[2] * cs;\n//\t\tSWAP(float, co[1], co[2]);\n//\t\tBM_vert_create(em->bm, co, NULL, BM_CREATE_NOP);\n//\t}\n\n//\t/* create custom data layer to save polygon idx */\n//\tCustomData_add_layer_named(&em->bm->pdata, CD_RECAST, CD_CALLOC, NULL, 0, \"createRepresentation recastData\");\n//\tCustomData_bmesh_init_pool(&em->bm->pdata, 0, BM_FACE);\n\t\n//\t/* create verts and faces for detailed mesh */\n//\tmeshes = recast_polyMeshDetailGetMeshes(dmesh, &nmeshes);\n//\tpolys = recast_polyMeshGetPolys(pmesh, NULL, &nvp);\n//\tdverts = recast_polyMeshDetailGetVerts(dmesh, NULL);\n//\ttris = recast_polyMeshDetailGetTris(dmesh, NULL);\n\n//\tfor (i = 0; i < nmeshes; i++) {\n//\t\tint uniquevbase = em->bm->totvert;\n//\t\tunsigned int vbase = meshes[4 * i + 0];\n//\t\tunsigned short ndv = meshes[4 * i + 1];\n//\t\tunsigned short tribase = meshes[4 * i + 2];\n//\t\tunsigned short trinum = meshes[4 * i + 3];\n//\t\tconst unsigned short *p = &polys[i * nvp * 2];\n//\t\tint nv = 0;\n\n//\t\tfor (j = 0; j < nvp; ++j) {\n//\t\t\tif (p[j] == 0xffff) break;\n//\t\t\tnv++;\n//\t\t}\n\n//\t\t/* create unique verts  */\n//\t\tfor (j = nv; j < ndv; j++) {\n//\t\t\tcopy_v3_v3(co, &dverts[3 * (vbase + j)]);\n//\t\t\tSWAP(float, co[1], co[2]);\n//\t\t\tBM_vert_create(em->bm, co, NULL, BM_CREATE_NOP);\n//\t\t}\n\n//\t\t/* need to rebuild entirely because array size changes */\n//\t\tBM_mesh_elem_table_init(em->bm, BM_VERT);\n\n//\t\t/* create faces */\n//\t\tfor (j = 0; j < trinum; j++) {\n//\t\t\tunsigned char *tri = &tris[4 * (tribase + j)];\n//\t\t\tBMFace *newFace;\n//\t\t\tint *polygonIdx;\n\n//\t\t\tfor (k = 0; k < 3; k++) {\n//\t\t\t\tif (tri[k] < nv)\n//\t\t\t\t\tface[k] = p[tri[k]];  /* shared vertex */\n//\t\t\t\telse\n//\t\t\t\t\tface[k] = uniquevbase + tri[k] - nv;  /* unique vertex */\n//\t\t\t}\n//\t\t\tnewFace = BM_face_create_quad_tri(em->bm,\n//\t\t\t                                  BM_vert_at_index(em->bm, face[0]),\n//\t\t\t                                  BM_vert_at_index(em->bm, face[2]),\n//\t\t\t                                  BM_vert_at_index(em->bm, face[1]), NULL,\n//\t\t\t                                  NULL, BM_CREATE_NOP);\n\n//\t\t\t/* set navigation polygon idx to the custom layer */\n//\t\t\tpolygonIdx = (int *)CustomData_bmesh_get(&em->bm->pdata, newFace->head.data, CD_RECAST);\n//\t\t\t*polygonIdx = i + 1; /* add 1 to avoid zero idx */\n//\t\t}\n//\t}\n\n//\trecast_destroyPolyMesh(pmesh);\n//\trecast_destroyPolyMeshDetail(dmesh);\n\n//\tDAG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA);\n//\tWM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);\n\n\n//\tED_object_editmode_exit(C, EM_FREEDATA);\n//\tWM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);\n\n//\tif (createob) {\n//\t\tobedit->gameflag &= ~OB_COLLISION;\n//\t\tobedit->gameflag |= OB_NAVMESH;\n//\t\tobedit->body_type = OB_BODY_TYPE_NAVMESH;\n//\t}\n\n//\tBKE_mesh_ensure_navmesh(obedit->data);\n\n//\treturn obedit;\n//}\n\n//static int navmesh_create_exec(bContext *C, wmOperator *op)\n//{\n//\tScene *scene = CTX_data_scene(C);\n//\tLinkNode *obs = NULL;\n//\tBase *navmeshBase = NULL;\n\n//\tCTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)\n//\t{\n//\t\tif (base->object->type == OB_MESH) {\n//\t\t\tif (base->object->body_type == OB_BODY_TYPE_NAVMESH) {\n//\t\t\t\tif (!navmeshBase || base == scene->basact) {\n//\t\t\t\t\tnavmeshBase = base;\n//\t\t\t\t}\n//\t\t\t}\n//\t\t\telse {\n//\t\t\t\tBLI_linklist_prepend(&obs, base->object);\n//\t\t\t}\n//\t\t}\n//\t}\n//\tCTX_DATA_END;\n\n//\tif (obs) {\n//\t\tstruct recast_polyMesh *pmesh = NULL;\n//\t\tstruct recast_polyMeshDetail *dmesh = NULL;\n//\t\tbool ok;\n//\t\tunsigned int lay = 0;\n\n//\t\tint nverts = 0, ntris = 0;\n//\t\tint *tris = NULL;\n//\t\tfloat *verts = NULL;\n\n//\t\tcreateVertsTrisData(C, obs, &nverts, &verts, &ntris, &tris, &lay);\n//\t\tBLI_linklist_free(obs, NULL);\n//\t\tif ((ok = buildNavMesh(&scene->gm.recastData, nverts, verts, ntris, tris, &pmesh, &dmesh, op->reports))) {\n//\t\t\tcreateRepresentation(C, pmesh, dmesh, navmeshBase, lay);\n//\t\t}\n\n//\t\tMEM_freeN(verts);\n//\t\tMEM_freeN(tris);\n\n//\t\treturn ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;\n//\t}\n//\telse {\n//\t\tBKE_report(op->reports, RPT_ERROR, \"No mesh objects found\");\n\n//\t\treturn OPERATOR_CANCELLED;\n//\t}\n//}\n\n//void MESH_OT_navmesh_make(wmOperatorType *ot)\n//{\n//\t/* identifiers */\n//\tot->name = \"Create Navigation Mesh\";\n//\tot->description = \"Create navigation mesh for selected objects\";\n//\tot->idname = \"MESH_OT_navmesh_make\";\n\n//\t/* api callbacks */\n//\tot->exec = navmesh_create_exec;\n\n//\t/* flags */\n//\tot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;\n//}\n\n//static int navmesh_face_copy_exec(bContext *C, wmOperator *op)\n//{\n//\tObject *obedit = CTX_data_edit_object(C);\n//\tBMEditMesh *em = BKE_editmesh_from_object(obedit);\n\n//\t/* do work here */\n//\tBMFace *efa_act = BM_mesh_active_face_get(em->bm, false, false);\n\n//\tif (efa_act) {\n//\t\tif (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) {\n//\t\t\tBMFace *efa;\n//\t\t\tBMIter iter;\n//\t\t\tint targetPolyIdx = *(int *)CustomData_bmesh_get(&em->bm->pdata, efa_act->head.data, CD_RECAST);\n//\t\t\ttargetPolyIdx = targetPolyIdx >= 0 ? targetPolyIdx : -targetPolyIdx;\n\n//\t\t\tif (targetPolyIdx > 0) {\n//\t\t\t\t/* set target poly idx to other selected faces */\n//\t\t\t\tBM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {\n//\t\t\t\t\tif (BM_elem_flag_test(efa, BM_ELEM_SELECT) && efa != efa_act) {\n//\t\t\t\t\t\tint *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_RECAST);\n//\t\t\t\t\t\t*recastDataBlock = targetPolyIdx;\n//\t\t\t\t\t}\n//\t\t\t\t}\n//\t\t\t}\n//\t\t\telse {\n//\t\t\t\tBKE_report(op->reports, RPT_ERROR, \"Active face has no index set\");\n//\t\t\t}\n//\t\t}\n//\t}\n\n//\tDAG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA);\n//\tWM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);\n\n//\treturn OPERATOR_FINISHED;\n//}\n\n//void MESH_OT_navmesh_face_copy(struct wmOperatorType *ot)\n//{\n//\t/* identifiers */\n//\tot->name = \"NavMesh Copy Face Index\";\n//\tot->description = \"Copy the index from the active face\";\n//\tot->idname = \"MESH_OT_navmesh_face_copy\";\n\n//\t/* api callbacks */\n//\tot->poll = ED_operator_editmesh;\n//\tot->exec = navmesh_face_copy_exec;\n\n//\t/* flags */\n//\tot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;\n//}\n\n//static int compare(const void *a, const void *b)\n//{\n//\treturn (*(int *)a - *(int *)b);\n//}\n\n//static int findFreeNavPolyIndex(BMEditMesh *em)\n//{\n//\t/* construct vector of indices */\n//\tint numfaces = em->bm->totface;\n//\tint *indices = MEM_callocN(sizeof(int) * numfaces, \"findFreeNavPolyIndex(indices)\");\n//\tBMFace *ef;\n//\tBMIter iter;\n//\tint i, idx = em->bm->totface - 1, freeIdx = 1;\n\n//\t/*XXX this originally went last to first, but that isn't possible anymore*/\n//\tBM_ITER_MESH (ef, &iter, em->bm, BM_FACES_OF_MESH) {\n//\t\tint polyIdx = *(int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST);\n//\t\tindices[idx] = polyIdx;\n//\t\tidx--;\n//\t}\n\n//\tqsort(indices, numfaces, sizeof(int), compare);\n\n//\t/* search first free index */\n//\tfreeIdx = 1;\n//\tfor (i = 0; i < numfaces; i++) {\n//\t\tif (indices[i] == freeIdx)\n//\t\t\tfreeIdx++;\n//\t\telse if (indices[i] > freeIdx)\n//\t\t\tbreak;\n//\t}\n\n//\tMEM_freeN(indices);\n\n//\treturn freeIdx;\n//}\n\n//static int navmesh_face_add_exec(bContext *C, wmOperator *UNUSED(op))\n//{\n//\tObject *obedit = CTX_data_edit_object(C);\n//\tBMEditMesh *em = BKE_editmesh_from_object(obedit);\n//\tBMFace *ef;\n//\tBMIter iter;\n\t\n//\tif (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) {\n//\t\tint targetPolyIdx = findFreeNavPolyIndex(em);\n\n//\t\tif (targetPolyIdx > 0) {\n//\t\t\t/* set target poly idx to selected faces */\n//\t\t\t/*XXX this originally went last to first, but that isn't possible anymore*/\n\t\t\t\n//\t\t\tBM_ITER_MESH (ef, &iter, em->bm, BM_FACES_OF_MESH) {\n//\t\t\t\tif (BM_elem_flag_test(ef, BM_ELEM_SELECT)) {\n//\t\t\t\t\tint *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST);\n//\t\t\t\t\t*recastDataBlock = targetPolyIdx;\n//\t\t\t\t}\n//\t\t\t}\n//\t\t}\n//\t}\n\n//\tDAG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA);\n//\tWM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);\n\n//\treturn OPERATOR_FINISHED;\n//}\n\n//void MESH_OT_navmesh_face_add(struct wmOperatorType *ot)\n//{\n//\t/* identifiers */\n//\tot->name = \"NavMesh New Face Index\";\n//\tot->description = \"Add a new index and assign it to selected faces\";\n//\tot->idname = \"MESH_OT_navmesh_face_add\";\n\n//\t/* api callbacks */\n//\tot->poll = ED_operator_editmesh;\n//\tot->exec = navmesh_face_add_exec;\n\n//\t/* flags */\n//\tot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;\n//}\n\n//static int navmesh_obmode_data_poll(bContext *C)\n//{\n//\tObject *ob = ED_object_active_context(C);\n//\tif (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {\n//\t\tMesh *me = ob->data;\n//\t\treturn CustomData_has_layer(&me->pdata, CD_RECAST);\n//\t}\n//\treturn false;\n//}\n\n//static int navmesh_obmode_poll(bContext *C)\n//{\n//\tObject *ob = ED_object_active_context(C);\n//\tif (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {\n//\t\treturn true;\n//\t}\n//\treturn false;\n//}\n\n//static int navmesh_reset_exec(bContext *C, wmOperator *UNUSED(op))\n//{\n//\tObject *ob = ED_object_active_context(C);\n//\tMesh *me = ob->data;\n\n//\tCustomData_free_layers(&me->pdata, CD_RECAST, me->totpoly);\n\n//\tBKE_mesh_ensure_navmesh(me);\n\n//\tDAG_id_tag_update(&me->id, OB_RECALC_DATA);\n//\tWM_event_add_notifier(C, NC_GEOM | ND_DATA, &me->id);\n\n//\treturn OPERATOR_FINISHED;\n//}\n\n//void MESH_OT_navmesh_reset(struct wmOperatorType *ot)\n//{\n//\t/* identifiers */\n//\tot->name = \"NavMesh Reset Index Values\";\n//\tot->description = \"Assign a new index to every face\";\n//\tot->idname = \"MESH_OT_navmesh_reset\";\n\n//\t/* api callbacks */\n//\tot->poll = navmesh_obmode_poll;\n//\tot->exec = navmesh_reset_exec;\n\n//\t/* flags */\n//\tot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;\n//}\n\n//static int navmesh_clear_exec(bContext *C, wmOperator *UNUSED(op))\n//{\n//\tObject *ob = ED_object_active_context(C);\n//\tMesh *me = ob->data;\n\n//\tCustomData_free_layers(&me->pdata, CD_RECAST, me->totpoly);\n\n//\tDAG_id_tag_update(&me->id, OB_RECALC_DATA);\n//\tWM_event_add_notifier(C, NC_GEOM | ND_DATA, &me->id);\n\n//\treturn OPERATOR_FINISHED;\n//}\n\n//void MESH_OT_navmesh_clear(struct wmOperatorType *ot)\n//{\n//\t/* identifiers */\n//\tot->name = \"NavMesh Clear Data\";\n//\tot->description = \"Remove navmesh data from this mesh\";\n//\tot->idname = \"MESH_OT_navmesh_clear\";\n\n//\t/* api callbacks */\n//\tot->poll = navmesh_obmode_data_poll;\n//\tot->exec = navmesh_clear_exec;\n\n//\t/* flags */\n//\tot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;\n//}\n"
  },
  {
    "path": "third_parties/recast/app/mesh_navmesh.h",
    "content": "/*\n * ***** BEGIN GPL LICENSE BLOCK *****\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; either version 2\n * of the License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software Foundation,\n * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n * The Original Code is Copyright (C) 2011 by Blender Foundation\n * All rights reserved.\n *\n * Contributor(s): Benoit Bolsee,\n *                 Nick Samarin,\n *                 Przemysław Bągard,\n *\n * ***** END GPL LICENSE BLOCK *****\n */\n\n#ifndef MESH_NAVMESH_H\n#define MESH_NAVMESH_H\n\n#include \"recast-capi.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/// Just holder class which will allocate pmesh inside.\n/// This class will be created on python side.\nstruct RECASTBLENDERADDON_EXPORT recast_polyMesh_holder\n{\n    struct recast_polyMesh *pmesh;\n};\n\nstruct RECASTBLENDERADDON_EXPORT recast_polyMeshDetail_holder\n{\n    struct recast_polyMeshDetail *dmesh;\n};\n\ntypedef RECASTBLENDERADDON_EXPORT struct RecastData {\n    float cellsize;\n    float cellheight;\n    float agentmaxslope;\n    float agentmaxclimb;\n    float agentheight;\n    float agentradius;\n    float edgemaxlen;\n    float edgemaxerror;\n    float regionminsize;\n    float regionmergesize;\n    int vertsperpoly;\n    float detailsampledist;\n    float detailsamplemaxerror;\n//    short pad1, pad2;\n    short partitioning;\n    short pad1;\n} RecastData;\n\n/* RecastData.partitioning */\n#define RC_PARTITION_WATERSHED 0\n#define RC_PARTITION_MONOTONE 1\n#define RC_PARTITION_LAYERS 2\n\n//#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403))\n//#  define ATTR_MALLOC __attribute__((malloc))\n//#else\n//#  define ATTR_MALLOC\n//#endif\n\n//void MEM_lockfree_freeN(void *vmemh);\n//void *MEM_lockfree_callocN(size_t len, const char *UNUSED(str)) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);\n\n//void (*MEM_freeN)(void *vmemh) = MEM_lockfree_freeN;\n//void *(*MEM_callocN)(size_t len, const char *str) = MEM_lockfree_callocN;\n\n\nint RECASTBLENDERADDON_EXPORT buildNavMesh(const RecastData *recastParams, int nverts, float *verts, int ntris, int *tris,\n                                                     struct recast_polyMesh_holder *pmeshHolder, struct recast_polyMeshDetail_holder *dmeshHolder,\n                                                     char *reports, int reportsMaxChars);\n\n\nint RECASTBLENDERADDON_EXPORT freeNavMesh(struct recast_polyMesh_holder *pmeshHolder, struct recast_polyMeshDetail_holder *dmeshHolder,\n                                                    char *reports, int reportsMaxChars);\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "third_parties/recast/app/recast-capi.cpp",
    "content": "/*\n *\n * ***** BEGIN GPL LICENSE BLOCK *****\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; either version 2\n * of the License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software Foundation,\n * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n * The Original Code is Copyright (C) 2011 Blender Foundation.\n * All rights reserved.\n *\n * This file was forked from Blender 2.79b.\n *\n * Contributor(s): Sergey Sharybin,\n *                 Przemysław Bągard,\n *\n * ***** END GPL LICENSE BLOCK *****\n */\n\n#include \"recast-capi.h\"\n\n#include <math.h>\n#include \"Recast.h\"\n\nstatic rcContext *sctx;\n\n#define INIT_SCTX()\t\t\t\\\n\tif (sctx == NULL) sctx = new rcContext(false)\n\n//int recast_buildMeshAdjacency(unsigned short* polys, const int npolys,\n//\t\t\tconst int nverts, const int vertsPerPoly)\n//{\n//\treturn (int) buildMeshAdjacency(polys, npolys, nverts, vertsPerPoly);\n//}\n\nvoid recast_calcBounds(const float *verts, int nv, float *bmin, float *bmax)\n{\n\trcCalcBounds(verts, nv, bmin, bmax);\n}\n\nvoid recast_calcGridSize(const float *bmin, const float *bmax, float cs, int *w, int *h)\n{\n\trcCalcGridSize(bmin, bmax, cs, w, h);\n}\n\nstruct recast_heightfield *recast_newHeightfield(void)\n{\n\treturn (struct recast_heightfield *) rcAllocHeightfield();\n}\n\nvoid recast_destroyHeightfield(struct recast_heightfield *heightfield)\n{\n\trcFreeHeightField((rcHeightfield *) heightfield);\n}\n\nint recast_createHeightfield(struct recast_heightfield *hf, int width, int height,\n\t\t\tconst float *bmin, const float* bmax, float cs, float ch)\n{\n\tINIT_SCTX();\n\treturn rcCreateHeightfield(sctx, *(rcHeightfield *)hf, width, height, bmin, bmax, cs, ch);\n}\n\nvoid recast_markWalkableTriangles(const float walkableSlopeAngle,const float *verts, int nv,\n\t\t\tconst int *tris, int nt, unsigned char *areas)\n{\n\tINIT_SCTX();\n\trcMarkWalkableTriangles(sctx, walkableSlopeAngle, verts, nv, tris, nt, areas);\n}\n\nvoid recast_clearUnwalkableTriangles(const float walkableSlopeAngle, const float* verts, int nv,\n\t\t\tconst int* tris, int nt, unsigned char* areas)\n{\n\tINIT_SCTX();\n\trcClearUnwalkableTriangles(sctx, walkableSlopeAngle, verts, nv, tris, nt, areas);\n}\n\nint recast_addSpan(struct recast_heightfield *hf, const int x, const int y,\n\t\t\tconst unsigned short smin, const unsigned short smax,\n\t\t\tconst unsigned char area, const int flagMergeThr)\n{\n\tINIT_SCTX();\n\treturn rcAddSpan(sctx, *(rcHeightfield *) hf, x, y, smin, smax, area, flagMergeThr);\n}\n\nint recast_rasterizeTriangle(const float *v0, const float *v1, const float *v2,\n\t\t\tconst unsigned char area, struct recast_heightfield *solid,\n\t\t\tconst int flagMergeThr)\n{\n\tINIT_SCTX();\n\treturn rcRasterizeTriangle(sctx, v0, v1, v2, area, *(rcHeightfield *) solid, flagMergeThr);\n}\n\nint recast_rasterizeTriangles(const float *verts, const int nv, const int *tris,\n\t\t\tconst unsigned char *areas, const int nt, struct recast_heightfield *solid,\n\t\t\tconst int flagMergeThr)\n{\n\tINIT_SCTX();\n\treturn rcRasterizeTriangles(sctx, verts, nv, tris, areas, nt, *(rcHeightfield *) solid, flagMergeThr);\n}\n\nvoid recast_filterLedgeSpans(const int walkableHeight, const int walkableClimb,\n\t\t\tstruct recast_heightfield *solid)\n{\n\tINIT_SCTX();\n\trcFilterLedgeSpans(sctx, walkableHeight, walkableClimb, *(rcHeightfield *) solid);\n}\n\nvoid recast_filterWalkableLowHeightSpans(int walkableHeight, struct recast_heightfield *solid)\n{\n\tINIT_SCTX();\n\trcFilterWalkableLowHeightSpans(sctx, walkableHeight, *(rcHeightfield *) solid);\n}\n\nvoid recast_filterLowHangingWalkableObstacles(const int walkableClimb, struct recast_heightfield *solid)\n{\n\tINIT_SCTX();\n\trcFilterLowHangingWalkableObstacles(sctx, walkableClimb, *(rcHeightfield *) solid);\n}\n\nint recast_getHeightFieldSpanCount(struct recast_heightfield *hf)\n{\n\tINIT_SCTX();\n\treturn rcGetHeightFieldSpanCount(sctx, *(rcHeightfield *) hf);\n}\n\nstruct recast_heightfieldLayerSet *recast_newHeightfieldLayerSet(void)\n{\n\treturn (struct recast_heightfieldLayerSet *) rcAllocHeightfieldLayerSet();\n}\n\nvoid recast_destroyHeightfieldLayerSet(struct recast_heightfieldLayerSet *lset)\n{\n\trcFreeHeightfieldLayerSet( (rcHeightfieldLayerSet *) lset);\n}\n\nstruct recast_compactHeightfield *recast_newCompactHeightfield(void)\n{\n\treturn (struct recast_compactHeightfield *) rcAllocCompactHeightfield();\n}\n\nvoid recast_destroyCompactHeightfield(struct recast_compactHeightfield *compactHeightfield)\n{\n\trcFreeCompactHeightfield( (rcCompactHeightfield *) compactHeightfield);\n}\n\nint recast_buildCompactHeightfield(const int walkableHeight, const int walkableClimb,\n\t\t\tstruct recast_heightfield *hf, struct recast_compactHeightfield *chf)\n{\n\tINIT_SCTX();\n\treturn rcBuildCompactHeightfield(sctx, walkableHeight, walkableClimb, \n\t\t*(rcHeightfield *) hf, *(rcCompactHeightfield *) chf);\n}\n\nint recast_erodeWalkableArea(int radius, struct recast_compactHeightfield *chf)\n{\n\tINIT_SCTX();\n\treturn rcErodeWalkableArea(sctx, radius, *(rcCompactHeightfield *) chf);\n}\n\nint recast_medianFilterWalkableArea(struct recast_compactHeightfield *chf)\n{\n\tINIT_SCTX();\n\treturn rcMedianFilterWalkableArea(sctx, *(rcCompactHeightfield *) chf);\n}\n\nvoid recast_markBoxArea(const float *bmin, const float *bmax, unsigned char areaId,\n\t\t\tstruct recast_compactHeightfield *chf)\n{\n\tINIT_SCTX();\n\trcMarkBoxArea(sctx, bmin, bmax, areaId, *(rcCompactHeightfield *) chf);\n}\n\nvoid recast_markConvexPolyArea(const float* verts, const int nverts,\n\t\t\tconst float hmin, const float hmax, unsigned char areaId,\n\t\t\tstruct recast_compactHeightfield *chf)\n{\n\tINIT_SCTX();\n\trcMarkConvexPolyArea(sctx, verts, nverts, hmin, hmax, areaId, *(rcCompactHeightfield *) chf);\n}\n\nint recast_offsetPoly(const float* verts, const int nverts,\n\t\t\tconst float offset, float *outVerts, const int maxOutVerts)\n{\n\treturn rcOffsetPoly(verts, nverts, offset, outVerts, maxOutVerts);\n}\n\nvoid recast_markCylinderArea(const float* pos, const float r, const float h,\n\t\t\tunsigned char areaId, struct recast_compactHeightfield *chf)\n{\n\tINIT_SCTX();\n\trcMarkCylinderArea(sctx, pos, r, h, areaId, *(rcCompactHeightfield *) chf);\n}\n\nint recast_buildDistanceField(struct recast_compactHeightfield *chf)\n{\n\tINIT_SCTX();\n\treturn rcBuildDistanceField(sctx, *(rcCompactHeightfield *) chf);\n}\n\nint recast_buildRegions(struct recast_compactHeightfield *chf,\n\t\t\tconst int borderSize, const int minRegionArea, const int mergeRegionArea)\n{\n\tINIT_SCTX();\n\treturn rcBuildRegions(sctx, *(rcCompactHeightfield *) chf, borderSize,\n\t\t\t\tminRegionArea, mergeRegionArea);\n}\n\nint recast_buildLayerRegions(struct recast_compactHeightfield *chf,\n\t\t\tconst int borderSize, const int minRegionArea)\n{\n\tINIT_SCTX();\n\treturn rcBuildLayerRegions(sctx, *(rcCompactHeightfield *) chf, borderSize,\n\t\t\t\tminRegionArea);\n}\n\nint recast_buildRegionsMonotone(struct recast_compactHeightfield *chf,\n\t\t\tconst int borderSize, const int minRegionArea, const int mergeRegionArea)\n{\n\tINIT_SCTX();\n\treturn rcBuildRegionsMonotone(sctx, *(rcCompactHeightfield *) chf, borderSize,\n\t\t\t\tminRegionArea, mergeRegionArea);\n}\n\nstruct recast_contourSet *recast_newContourSet(void)\n{\n\treturn (struct recast_contourSet *) rcAllocContourSet();\n}\n\nvoid recast_destroyContourSet(struct recast_contourSet *contourSet)\n{\n\trcFreeContourSet((rcContourSet *) contourSet);\n}\n\nint recast_buildContours(struct recast_compactHeightfield *chf,\n\t\t\tconst float maxError, const int maxEdgeLen, struct recast_contourSet *cset,\n\t\t\tconst int buildFlags)\n{\n\tINIT_SCTX();\n\treturn rcBuildContours(sctx, *(rcCompactHeightfield *) chf, maxError, maxEdgeLen, *(rcContourSet *) cset, buildFlags);\n}\n\nstruct recast_polyMesh *recast_newPolyMesh(void)\n{\n\treturn (recast_polyMesh *) rcAllocPolyMesh();\n}\n\nvoid recast_destroyPolyMesh(struct recast_polyMesh *polyMesh)\n{\n\trcFreePolyMesh((rcPolyMesh *) polyMesh);\n}\n\nint recast_buildPolyMesh(struct recast_contourSet *cset, const int nvp, struct recast_polyMesh *mesh)\n{\n\tINIT_SCTX();\n\treturn rcBuildPolyMesh(sctx, *(rcContourSet *) cset, nvp, *(rcPolyMesh *) mesh);\n}\n\nint recast_mergePolyMeshes(struct recast_polyMesh **meshes, const int nmeshes, struct recast_polyMesh *mesh)\n{\n\tINIT_SCTX();\n\treturn rcMergePolyMeshes(sctx, (rcPolyMesh **) meshes, nmeshes, *(rcPolyMesh *) mesh);\n}\n\nint recast_copyPolyMesh(const struct recast_polyMesh *src, struct recast_polyMesh *dst)\n{\n\tINIT_SCTX();\n\treturn rcCopyPolyMesh(sctx, *(const rcPolyMesh *) src, *(rcPolyMesh *) dst);\n}\n\nunsigned short *recast_polyMeshGetVerts(struct recast_polyMesh *mesh, int *nverts)\n{\n\trcPolyMesh *pmesh = (rcPolyMesh *)mesh;\n\n\tif (nverts)\n\t\t*nverts = pmesh->nverts;\n\n\treturn pmesh->verts;\n}\n\nvoid recast_polyMeshGetBoundbox(struct recast_polyMesh *mesh, float *bmin, float *bmax)\n{\n\trcPolyMesh *pmesh = (rcPolyMesh *)mesh;\n\n\tif (bmin) {\n\t\tbmin[0] = pmesh->bmin[0];\n\t\tbmin[1] = pmesh->bmin[1];\n\t\tbmin[2] = pmesh->bmin[2];\n\t}\n\n\tif (bmax) {\n\t\tbmax[0] = pmesh->bmax[0];\n\t\tbmax[1] = pmesh->bmax[1];\n\t\tbmax[2] = pmesh->bmax[2];\n\t}\n}\n\nvoid recast_polyMeshGetCell(struct recast_polyMesh *mesh, float *cs, float *ch)\n{\n\trcPolyMesh *pmesh = (rcPolyMesh *)mesh;\n\n\tif (cs)\n\t\t*cs = pmesh->cs;\n\n\tif (ch)\n\t\t*ch = pmesh->ch;\n}\n\nunsigned short *recast_polyMeshGetPolys(struct recast_polyMesh *mesh, int *npolys, int *nvp)\n{\n\trcPolyMesh *pmesh = (rcPolyMesh *)mesh;\n\n\tif (npolys)\n\t\t*npolys = pmesh->npolys;\n\n\tif (nvp)\n\t\t*nvp = pmesh->nvp;\n\n\treturn pmesh->polys;\n}\n\nstruct recast_polyMeshDetail *recast_newPolyMeshDetail(void)\n{\n\treturn (struct recast_polyMeshDetail *) rcAllocPolyMeshDetail();\n}\n\nvoid recast_destroyPolyMeshDetail(struct recast_polyMeshDetail *polyMeshDetail)\n{\n\trcFreePolyMeshDetail((rcPolyMeshDetail *) polyMeshDetail);\n}\n\nint recast_buildPolyMeshDetail(const struct recast_polyMesh *mesh, const struct recast_compactHeightfield *chf,\n\t\t\tconst float sampleDist, const float sampleMaxError, struct recast_polyMeshDetail *dmesh)\n{\n\tINIT_SCTX();\n\treturn rcBuildPolyMeshDetail(sctx, *(rcPolyMesh *) mesh, *(rcCompactHeightfield *) chf,\n\t\t\tsampleDist, sampleMaxError, *(rcPolyMeshDetail *) dmesh);\n}\n\nint recast_mergePolyMeshDetails(struct recast_polyMeshDetail **meshes, const int nmeshes, struct recast_polyMeshDetail *mesh)\n{\n\tINIT_SCTX();\n\treturn rcMergePolyMeshDetails(sctx, (rcPolyMeshDetail **) meshes, nmeshes, *(rcPolyMeshDetail *) mesh);\n}\n\nfloat *recast_polyMeshDetailGetVerts(struct recast_polyMeshDetail *mesh, int *nverts)\n{\n\trcPolyMeshDetail *dmesh = (rcPolyMeshDetail *)mesh;\n\n\tif (nverts)\n\t\t*nverts = dmesh->nverts;\n\n\treturn dmesh->verts;\n}\n\nunsigned char *recast_polyMeshDetailGetTris(struct recast_polyMeshDetail *mesh, int *ntris)\n{\n\trcPolyMeshDetail *dmesh = (rcPolyMeshDetail *)mesh;\n\n\tif (ntris)\n\t\t*ntris = dmesh->ntris;\n\n\treturn dmesh->tris;\n}\n\nunsigned int *recast_polyMeshDetailGetMeshes(struct recast_polyMeshDetail *mesh, int *nmeshes)\n{\n\trcPolyMeshDetail *dmesh = (rcPolyMeshDetail *)mesh;\n\n\tif (nmeshes)\n\t\t*nmeshes = dmesh->nmeshes;\n\n\treturn dmesh->meshes;\n}\n\n"
  },
  {
    "path": "third_parties/recast/app/recast-capi.h",
    "content": "/*\n *\n * ***** BEGIN GPL LICENSE BLOCK *****\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; either version 2\n * of the License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software Foundation,\n * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n * The Original Code is Copyright (C) 2011 Blender Foundation.\n * All rights reserved.\n *\n * This file was forked from Blender 2.79b.\n *\n * Contributor(s): Sergey Sharybin,\n *                 Przemysław Bągard,\n *\n * ***** END GPL LICENSE BLOCK *****\n */\n\n#ifndef RECAST_C_API_H\n#define RECAST_C_API_H\n\n// for size_t\n#include <stddef.h>\n#include \"recast-capi_global.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nstruct RECASTBLENDERADDON_EXPORT recast_polyMesh;\nstruct RECASTBLENDERADDON_EXPORT recast_polyMeshDetail;\nstruct RECASTBLENDERADDON_EXPORT recast_heightfield;\nstruct RECASTBLENDERADDON_EXPORT recast_compactHeightfield;\nstruct RECASTBLENDERADDON_EXPORT recast_heightfieldLayerSet;\nstruct RECASTBLENDERADDON_EXPORT recast_contourSet;\n\n// recast_polyMesh must match rcPolyMesh\n///// Represents a polygon mesh suitable for use in building a navigation mesh.\n///// @ingroup recast\n//struct rcPolyMesh\n//{\n//\trcPolyMesh();\n//\t~rcPolyMesh();\n//\tunsigned short* verts;\t///< The mesh vertices. [Form: (x, y, z) * #nverts]\n//\tunsigned short* polys;\t///< Polygon and neighbor data. [Length: #maxpolys * 2 * #nvp]\n//\tunsigned short* regs;\t///< The region id assigned to each polygon. [Length: #maxpolys]\n//\tunsigned short* flags;\t///< The user defined flags for each polygon. [Length: #maxpolys]\n//\tunsigned char* areas;\t///< The area id assigned to each polygon. [Length: #maxpolys]\n//\tint nverts;\t\t\t\t///< The number of vertices.\n//\tint npolys;\t\t\t\t///< The number of polygons.\n//\tint maxpolys;\t\t\t///< The number of allocated polygons.\n//\tint nvp;\t\t\t\t///< The maximum number of vertices per polygon.\n//\tfloat bmin[3];\t\t\t///< The minimum bounds in world space. [(x, y, z)]\n//\tfloat bmax[3];\t\t\t///< The maximum bounds in world space. [(x, y, z)]\n//\tfloat cs;\t\t\t\t///< The size of each cell. (On the xz-plane.)\n//\tfloat ch;\t\t\t\t///< The height of each cell. (The minimum increment along the y-axis.)\n//\tint borderSize;\t\t\t///< The AABB border size used to generate the source data from which the mesh was derived.\n//\tfloat maxEdgeError;\t\t///< The max error of the polygon edges in the mesh.\n//};\n\n///// Contains triangle meshes that represent detailed height data associated\n///// with the polygons in its associated polygon mesh object.\n///// @ingroup recast\n//struct rcPolyMeshDetail\n//{\n//\tunsigned int* meshes;\t///< The sub-mesh data. [Size: 4*#nmeshes]\n//\tfloat* verts;\t\t\t///< The mesh vertices. [Size: 3*#nverts]\n//\tunsigned char* tris;\t///< The mesh triangles. [Size: 4*#ntris]\n//\tint nmeshes;\t\t\t///< The number of sub-meshes defined by #meshes.\n//\tint nverts;\t\t\t\t///< The number of vertices in #verts.\n//\tint ntris;\t\t\t\t///< The number of triangles in #tris.\n//};\n\n\n\nenum RECASTBLENDERADDON_EXPORT recast_BuildContoursFlags\n{\n\tRECAST_CONTOUR_TESS_WALL_EDGES = 0x01,\n\tRECAST_CONTOUR_TESS_AREA_EDGES = 0x02,\n};\n\n//int recast_buildMeshAdjacency(unsigned short* polys, const int npolys,\n//\t\t\tconst int nverts, const int vertsPerPoly);\n\nRECASTBLENDERADDON_EXPORT void recast_calcBounds(const float *verts, int nv, float *bmin, float *bmax);\n\nRECASTBLENDERADDON_EXPORT void recast_calcGridSize(const float *bmin, const float *bmax, float cs, int *w, int *h);\n\nRECASTBLENDERADDON_EXPORT struct recast_heightfield *recast_newHeightfield(void);\n\nRECASTBLENDERADDON_EXPORT void recast_destroyHeightfield(struct recast_heightfield *heightfield);\n\nRECASTBLENDERADDON_EXPORT int recast_createHeightfield(struct recast_heightfield *hf, int width, int height,\n\t\t\tconst float *bmin, const float* bmax, float cs, float ch);\n\nRECASTBLENDERADDON_EXPORT void recast_markWalkableTriangles(const float walkableSlopeAngle,const float *verts, int nv,\n\t\t\tconst int *tris, int nt, unsigned char *areas);\n\nRECASTBLENDERADDON_EXPORT void recast_clearUnwalkableTriangles(const float walkableSlopeAngle, const float* verts, int nv,\n\t\t\tconst int* tris, int nt, unsigned char* areas);\n\nRECASTBLENDERADDON_EXPORT int recast_addSpan(struct recast_heightfield *hf, const int x, const int y,\n\t\t\tconst unsigned short smin, const unsigned short smax,\n\t\t\tconst unsigned char area, const int flagMergeThr);\n\nRECASTBLENDERADDON_EXPORT int recast_rasterizeTriangle(const float* v0, const float* v1, const float* v2,\n\t\t\tconst unsigned char area, struct recast_heightfield *solid,\n\t\t\tconst int flagMergeThr);\n\nRECASTBLENDERADDON_EXPORT int recast_rasterizeTriangles(const float *verts, const int nv, const int *tris,\n\t\t\tconst unsigned char *areas, const int nt, struct recast_heightfield *solid,\n\t\t\tconst int flagMergeThr);\n\nRECASTBLENDERADDON_EXPORT void recast_filterLedgeSpans(const int walkableHeight, const int walkableClimb,\n\t\t\tstruct recast_heightfield *solid);\n\nRECASTBLENDERADDON_EXPORT void recast_filterWalkableLowHeightSpans(int walkableHeight, struct recast_heightfield *solid);\n\nRECASTBLENDERADDON_EXPORT void recast_filterLowHangingWalkableObstacles(const int walkableClimb, struct recast_heightfield *solid);\n\nRECASTBLENDERADDON_EXPORT int recast_getHeightFieldSpanCount(struct recast_heightfield *hf);\n\nRECASTBLENDERADDON_EXPORT struct recast_heightfieldLayerSet *recast_newHeightfieldLayerSet(void);\n\nRECASTBLENDERADDON_EXPORT void recast_destroyHeightfieldLayerSet(struct recast_heightfieldLayerSet *lset);\n\nRECASTBLENDERADDON_EXPORT struct recast_compactHeightfield *recast_newCompactHeightfield(void);\n\nRECASTBLENDERADDON_EXPORT void recast_destroyCompactHeightfield(struct recast_compactHeightfield *compactHeightfield);\n\nRECASTBLENDERADDON_EXPORT int recast_buildCompactHeightfield(const int walkableHeight, const int walkableClimb,\n\t\t\tstruct recast_heightfield *hf, struct recast_compactHeightfield *chf);\n\nRECASTBLENDERADDON_EXPORT int recast_erodeWalkableArea(int radius, struct recast_compactHeightfield *chf);\n\nRECASTBLENDERADDON_EXPORT int recast_medianFilterWalkableArea(struct recast_compactHeightfield *chf);\n\nRECASTBLENDERADDON_EXPORT void recast_markBoxArea(const float *bmin, const float *bmax, unsigned char areaId,\n\t\t\tstruct recast_compactHeightfield *chf);\n\nRECASTBLENDERADDON_EXPORT void recast_markConvexPolyArea(const float* verts, const int nverts,\n\t\t\tconst float hmin, const float hmax, unsigned char areaId,\n\t\t\tstruct recast_compactHeightfield *chf);\n\nRECASTBLENDERADDON_EXPORT int recast_offsetPoly(const float* verts, const int nverts,\n\t\t\tconst float offset, float *outVerts, const int maxOutVerts);\n\nRECASTBLENDERADDON_EXPORT void recast_markCylinderArea(const float* pos, const float r, const float h,\n\t\t\tunsigned char areaId, struct recast_compactHeightfield *chf);\n\nRECASTBLENDERADDON_EXPORT int recast_buildDistanceField(struct recast_compactHeightfield *chf);\n\nRECASTBLENDERADDON_EXPORT int recast_buildRegions(struct recast_compactHeightfield *chf,\n\t\t\tconst int borderSize, const int minRegionArea, const int mergeRegionArea);\n\nRECASTBLENDERADDON_EXPORT int recast_buildLayerRegions(struct recast_compactHeightfield *chf,\n\t\t\tconst int borderSize, const int minRegionArea);\n\nRECASTBLENDERADDON_EXPORT int recast_buildRegionsMonotone(struct recast_compactHeightfield *chf,\n\t\t\tconst int borderSize, const int minRegionArea, const int mergeRegionArea);\n\n/* Contour set */\n\nRECASTBLENDERADDON_EXPORT struct recast_contourSet *recast_newContourSet(void);\n\nRECASTBLENDERADDON_EXPORT void recast_destroyContourSet(struct recast_contourSet *contourSet);\n\nRECASTBLENDERADDON_EXPORT int recast_buildContours(struct recast_compactHeightfield *chf,\n\t\t\tconst float maxError, const int maxEdgeLen, struct recast_contourSet *cset,\n\t\t\tconst int buildFlags);\n\n/* Poly mesh */\n\nRECASTBLENDERADDON_EXPORT struct recast_polyMesh *recast_newPolyMesh(void);\n\nRECASTBLENDERADDON_EXPORT void recast_destroyPolyMesh(struct recast_polyMesh *polyMesh);\n\nRECASTBLENDERADDON_EXPORT int recast_buildPolyMesh(struct recast_contourSet *cset, const int nvp, struct recast_polyMesh *mesh);\n\nRECASTBLENDERADDON_EXPORT int recast_mergePolyMeshes(struct recast_polyMesh **meshes, const int nmeshes, struct recast_polyMesh *mesh);\n\nRECASTBLENDERADDON_EXPORT int recast_copyPolyMesh(const struct recast_polyMesh *src, struct recast_polyMesh *dst);\n\nRECASTBLENDERADDON_EXPORT unsigned short *recast_polyMeshGetVerts(struct recast_polyMesh *mesh, int *nverts);\n\nRECASTBLENDERADDON_EXPORT void recast_polyMeshGetBoundbox(struct recast_polyMesh *mesh, float *bmin, float *bmax);\n\nRECASTBLENDERADDON_EXPORT void recast_polyMeshGetCell(struct recast_polyMesh *mesh, float *cs, float *ch);\n\nRECASTBLENDERADDON_EXPORT unsigned short *recast_polyMeshGetPolys(struct recast_polyMesh *mesh, int *npolys, int *nvp);\n\n/* Poly mesh detail */\n\nRECASTBLENDERADDON_EXPORT struct recast_polyMeshDetail *recast_newPolyMeshDetail(void);\n\nRECASTBLENDERADDON_EXPORT void recast_destroyPolyMeshDetail(struct recast_polyMeshDetail *polyMeshDetail);\n\nRECASTBLENDERADDON_EXPORT int recast_buildPolyMeshDetail(const struct recast_polyMesh *mesh, const struct recast_compactHeightfield *chf,\n\t\t\tconst float sampleDist, const float sampleMaxError, struct recast_polyMeshDetail *dmesh);\n\nRECASTBLENDERADDON_EXPORT int recast_mergePolyMeshDetails(struct recast_polyMeshDetail **meshes, const int nmeshes, struct recast_polyMeshDetail *mesh);\n\nRECASTBLENDERADDON_EXPORT float *recast_polyMeshDetailGetVerts(struct recast_polyMeshDetail *mesh, int *nverts);\n\nRECASTBLENDERADDON_EXPORT unsigned char *recast_polyMeshDetailGetTris(struct recast_polyMeshDetail *mesh, int *ntris);\n\nRECASTBLENDERADDON_EXPORT unsigned int *recast_polyMeshDetailGetMeshes(struct recast_polyMeshDetail *mesh, int *nmeshes);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // RECAST_C_API_H\n"
  },
  {
    "path": "third_parties/recast/app/recast-capi_global.h",
    "content": "/*\n * ***** BEGIN GPL LICENSE BLOCK *****\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; either version 2\n * of the License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software Foundation,\n * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n * Contributor(s): Przemysław Bągard,\n *\n * ***** END GPL LICENSE BLOCK *****\n */\n\n#ifndef RECASTBLENDERADDON_GLOBAL_H\n#define RECASTBLENDERADDON_GLOBAL_H\n\n#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)\n#  define Q_DECL_EXPORT __declspec(dllexport)\n#  define Q_DECL_IMPORT __declspec(dllimport)\n#else\n#  define Q_DECL_EXPORT     __attribute__((visibility(\"default\")))\n#  define Q_DECL_IMPORT     __attribute__((visibility(\"default\")))\n#endif\n\n#if defined(RECASTBLENDERADDON_LIBRARY)\n#  define RECASTBLENDERADDON_EXPORT Q_DECL_EXPORT\n#else\n#  define RECASTBLENDERADDON_EXPORT Q_DECL_IMPORT\n#endif\n\n#endif\n"
  },
  {
    "path": "third_parties/recast/recast/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.0)\n\nset(CMAKE_OSX_ARCHITECTURES \"arm64;x86_64\" CACHE STRING \"\" FORCE)\n\nproject(RecastNavigation)\n\n# lib versions\nSET(SOVERSION 1)\nSET(VERSION 1.0.0)\n\noption(RECASTNAVIGATION_STATIC \"Build static libraries\" ON)\n\nadd_subdirectory(Recast)\n\n"
  },
  {
    "path": "third_parties/recast/recast/CONTRIBUTING.md",
    "content": "# Contributing to Recast and Detour\n\nWe'd love for you to contribute to our source code and to make Recast and Detour even better than they are\ntoday! Here are the guidelines we'd like you to follow:\n\n - [Code of Conduct](#coc)\n - [Question or Problem?](#question)\n - [Issues and Bugs](#issue)\n - [Feature Requests](#feature)\n - [Submission Guidelines](#submission-guidelines)\n - [Git Commit Guidelines](#git-commit-guidelines)\n\n## <a name=\"coc\"></a> Code of Conduct\nThis project adheres to the [Open Code of Conduct][code-of-conduct].\nBy participating, you are expected to honor this code.\n\n## <a name=\"question\"></a> Got a Question or Problem?\n\nIf you have questions about how to use Recast or Detour, please direct these to the [Google Group][groups]\ndiscussion list. We are also available on [Gitter][gitter].\n\n## <a name=\"issue\"></a> Found an Issue?\nIf you find a bug in the source code or a mistake in the documentation, you can help us by\nsubmitting an issue to our [GitHub Repository][github]. Even better you can submit a Pull Request\nwith a fix.\n\n**Please see the Submission Guidelines below**.\n\n## <a name=\"feature\"></a> Want a Feature?\nYou can request a new feature by submitting an issue to our [GitHub Repository][github]. If you\nwould like to implement a new feature then consider what kind of change it is:\n\n* **Major Changes** that you wish to contribute to the project should be discussed first on our\n[Google Group][groups] or in [GitHub Issues][github-issues] so that we can better coordinate our efforts, prevent\nduplication of work, and help you to craft the change so that it is successfully accepted into the\nproject.\n* **Small Changes** can be crafted and submitted to the [GitHub Repository][github] as a Pull Request.\n\n## Submission Guidelines\n\n### Submitting an Issue\nBefore you submit your issue search the [GitHub Issues][github-issues] archive,\nmaybe your question was already answered.\n\nIf your issue appears to be a bug, and hasn't been reported, open a new issue.\nHelp us to maximize the effort we can spend fixing issues and adding new\nfeatures, by not reporting duplicate issues. Providing the following information will increase the\nchances of your issue being dealt with quickly:\n\n* **Overview of the Issue** - what type of issue is it, and why is it an issue for you?\n* **Callstack** - if it's a crash or other runtime error, a callstack will help diagnosis\n* **Screenshots** - for navmesh generation problems, a picture really is worth a thousand words.\n    Implement `duDebugDraw` and call some methods from DetourDebugDraw.h. Seriously, just do it, we'll definitely ask you to if you haven't!\n* **Logs** - stdout and stderr from the console, or log files if there are any.\n    If integrating into your own codebase, be sure to implement the log callbacks in `rcContext`.\n* **Reproduction steps** - a minimal, unambigious set of steps including input, that causes the error for you.\n    e.g. input geometry and settings you can use to input into RecastDemo to get it to fail.\n\tNote: These can be saved by pressing the 9 key in RecastDemo, and the resulting .gset file can be shared (with the .obj if it is not one of the default ones).\n* **Recast version(s) and/or git commit hash** - particularly if you can find the point at which the error first started happening\n* **Environment** - operating system, compiler etc.\n* **Related issues** - has a similar issue been reported before?\n* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be\n  causing the problem (line of code or commit)\n\nHere is a great example of a well defined issue: https://github.com/recastnavigation/recastnavigation/issues/12\n\n**If you get help, help others. Good karma rulez!**\n\n### Submitting a Pull Request\nBefore you submit your pull request consider the following guidelines:\n\n* Search [GitHub Pull Requests][github-pulls] for an open or closed Pull Request\n  that relates to your submission. You don't want to duplicate effort.\n* Make your changes in a new git branch:\n\n     ```shell\n     git checkout -b my-fix-branch master\n     ```\n\n* Implement your changes, **including appropriate tests if appropriate/possible**.\n* Commit your changes using a descriptive commit message that follows our\n  [commit message conventions](#commit-message-format).\n\n     ```shell\n     git commit -a\n     ```\n  Note: the optional commit `-a` command line option will automatically \"add\" and \"rm\" edited files.\n\n* Squash any work-in-progress commits (by rebasing) to form a series of commits that make sense individually.\n  Ideally the pull request will be small and focused enough that it fits sensibly in one commit.\n\n     ```shell\n     git rebase -i origin/master\n     ```\n\n* Push your branch to GitHub:\n\n    ```shell\n    git push origin my-fix-branch\n    ```\n\n* In GitHub, send a pull request to `recastnavigation:master`.\n* If we suggest changes then:\n  * Make the required updates.\n  * Commit your changes to your branch (e.g. `my-fix-branch`).\n  * Squash the changes, overwriting history in your fix branch - we don't want history to include incomplete work.\n  * Push the changes to your GitHub repository (this will update your Pull Request).\n\nIf you have rebased to squash commits together, you will need to force push to update the PR:\n\n    ```shell\n    git rebase master -i\n    git push origin my-fix-branch -f\n    ```\n\nThat's it! Thank you for your contribution!\n\n#### After your pull request is merged\n\nAfter your pull request is merged, you can safely delete your branch and pull the changes\nfrom the main (upstream) repository:\n\n* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:\n\n    ```shell\n    git push origin --delete my-fix-branch\n    ```\n\n* Check out the master branch:\n\n    ```shell\n    git checkout master -f\n    ```\n\n* Delete the local branch:\n\n    ```shell\n    git branch -D my-fix-branch\n    ```\n\n* Update your master with the latest upstream version:\n\n    ```shell\n    git pull --ff upstream master\n    ```\n\n## Git Commit Guidelines\n\n### Commit content\n\nDo your best to factor commits appropriately, i.e not too large with unrelated\nthings in the same commit, and not too small with the same small change applied N\ntimes in N different commits. If there was some accidental reformatting or whitespace\nchanges during the course of your commits, please rebase them away before submitting\nthe PR.\n\n### Commit Message Format\nPlease format commit messages as follows (based on this [excellent post](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)):\n\n```\nSummarize change in 50 characters or less\n\nProvide more detail after the first line. Leave one blank line below the\nsummary and wrap all lines at 72 characters or less.\n\nIf the change fixes an issue, leave another blank line after the final\nparagraph and indicate which issue is fixed in the specific format\nbelow.\n\nFix #42\n```\n\nImportant things you should try to include in commit messages include:\n* Motivation for the change\n* Difference from previous behaviour\n* Whether the change alters the public API, or affects existing behaviour significantly\n\n\n\n[code-of-conduct]: http://todogroup.org/opencodeofconduct/#Recastnavigation/b.hymers@gmail.com\n[github]: https://github.com/recastnavigation/recastnavigation\n[github-issues]: https://github.com/recastnavigation/recastnavigation/issues\n[github-pulls]: https://github.com/recastnavigation/recastnavigation/pulls\n[gitter]: https://gitter.im/recastnavigation/chat\n[groups]: https://groups.google.com/forum/?fromgroups#!forum/recastnavigation\n"
  },
  {
    "path": "third_parties/recast/recast/License.txt",
    "content": "Copyright (c) 2009 Mikko Mononen memon@inside.org\n\nThis software is provided 'as-is', without any express or implied\nwarranty.  In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not\nclaim that you wrote the original software. If you use this software\nin a product, an acknowledgment in the product documentation would be\nappreciated but is not required.\n2. Altered source versions must be plainly marked as such, and must not be\nmisrepresented as being the original software.\n3. This notice may not be removed or altered from any source distribution.\n\n"
  },
  {
    "path": "third_parties/recast/recast/README.md",
    "content": "\nRecast & Detour\n===============\n\n[![Travis (Linux) Build Status](https://travis-ci.org/recastnavigation/recastnavigation.svg?branch=master)](https://travis-ci.org/recastnavigation/recastnavigation)\n[![Appveyor (Windows) Build  Status](https://ci.appveyor.com/api/projects/status/20w84u25b3f8h179/branch/master?svg=true)](https://ci.appveyor.com/project/recastnavigation/recastnavigation/branch/master)\n\n[![Issue Stats](http://www.issuestats.com/github/recastnavigation/recastnavigation/badge/pr?style=flat)](http://www.issuestats.com/github/recastnavigation/recastnavigation)\n[![Issue Stats](http://www.issuestats.com/github/recastnavigation/recastnavigation/badge/issue?style=flat)](http://www.issuestats.com/github/recastnavigation/recastnavigation)\n\n![screenshot of a navmesh baked with the sample program](/RecastDemo/screenshot.png?raw=true)\n\n## Recast\n\nRecast is state of the art navigation mesh construction toolset for games.\n\n* It is automatic, which means that you can throw any level geometry at it and you will get robust mesh out\n* It is fast which means swift turnaround times for level designers\n* It is open source so it comes with full source and you can customize it to your heart's content. \n\nThe Recast process starts with constructing a voxel mold from a level geometry \nand then casting a navigation mesh over it. The process consists of three steps, \nbuilding the voxel mold, partitioning the mold into simple regions, peeling off \nthe regions as simple polygons.\n\n1. The voxel mold is built from the input triangle mesh by rasterizing the triangles into a multi-layer heightfield. Some simple filters are  then applied to the mold to prune out locations where the character would not be able to move.\n2. The walkable areas described by the mold are divided into simple overlayed 2D regions. The resulting regions have only one non-overlapping contour, which simplifies the final step of the process tremendously.\n3. The navigation polygons are peeled off from the regions by first tracing the boundaries and then simplifying them. The resulting polygons are finally converted to convex polygons which makes them perfect for pathfinding and spatial reasoning about the level. \n\n\n## Detour\n\nRecast is accompanied with Detour, path-finding and spatial reasoning toolkit. You can use any navigation mesh with Detour, but of course the data generated with Recast fits perfectly.\n\nDetour offers simple static navigation mesh which is suitable for many simple cases, as well as tiled navigation mesh which allows you to plug in and out pieces of the mesh. The tiled mesh allows you to create systems where you stream new navigation data in and out as the player progresses the level, or you may regenerate tiles as the world changes. \n\n\n## Recast Demo\n\nYou can find a comprehensive demo project in RecastDemo folder. It is a kitchen sink demo containing all the functionality of the library. If you are new to Recast & Detour, check out [Sample_SoloMesh.cpp](/RecastDemo/Source/Sample_SoloMesh.cpp) to get started with building navmeshes and [NavMeshTesterTool.cpp](/RecastDemo/Source/NavMeshTesterTool.cpp) to see how Detour can be used to find paths.\n\n### Building RecastDemo\n\nRecastDemo uses [premake5](http://premake.github.io/) to build platform specific projects. Download it and make sure it's available on your path, or specify the path to it.\n\n#### Linux\n\n- Install SDL2 and its dependencies according to your distro's guidelines.\n- run `premake5 gmake` from the `RecastDemo` folder.\n- `cd Build/gmake` then `make`\n- Run `RecastDemo\\Bin\\RecastDemo`\n\n#### OSX\n\n- Grab the latest SDL2 development library dmg from [here](https://www.libsdl.org/download-2.0.php) and place `SDL2.framework` in `/Library/Frameworks/`\n- Navigate to the `RecastDemo` folder and run `premake5 xcode4`\n- Open `Build/xcode4/recastnavigation.xcworkspace`\n- Select the \"RecastDemo\" project in the left pane, go to the \"BuildPhases\" tab and expand \"Link Binary With Libraries\"\n- Remove the existing entry for SDL2 (it should have a white box icon) and re-add it by hitting the plus, selecting \"Add Other\", and selecting `/Library/Frameworks/SDL2.framework`.  It should now have a suitcase icon.\n- Set the RecastDemo project as the target and build.\n\n#### Windows\n\n- Grab the latest SDL2 development library release from [here](https://www.libsdl.org/download-2.0.php) and unzip it `RecastDemo\\Contrib`.  Rename the SDL folder such that the path `RecastDemo\\Contrib\\SDL\\lib\\x86` is valid.\n- Run `\"premake5\" vs2015` from the `RecastDemo` folder\n- Open the solution, build, and run.\n\n### Running Unit tests\n\n- Follow the instructions to build RecastDemo above.  Premake should generate another build target called \"Tests\".\n- Build the \"Tests\" project.  This will generate an executable named \"Tests\" in `RecastDemo/Bin/`\n- Run the \"Tests\" executable.  It will execute all the unit tests, indicate those that failed, and display a count of those that succeeded.\n\n## Integrating with your own project\n\nIt is recommended to add the source directories `DebugUtils`, `Detour`, `DetourCrowd`, `DetourTileCache`, and `Recast` into your own project depending on which parts of the project you need. For example your level building tool could include `DebugUtils`, `Recast`, and `Detour`, and your game runtime could just include `Detour`.\n\n## Contributing\n\nSee the [Contributing document](CONTRIBUTING.md) for guidelines for making contributions.\n\n## Discuss\n\n- Discuss Recast & Detour: http://groups.google.com/group/recastnavigation\n- Development blog: http://digestingduck.blogspot.com/\n\n## License\n\nRecast & Detour is licensed under ZLib license, see License.txt for more information.\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/CMakeLists.txt",
    "content": "file(GLOB SOURCES Source/*.cpp)\n\nif (RECASTNAVIGATION_STATIC)\n    add_library(Recast STATIC ${SOURCES})\nelse ()\n    add_library(Recast SHARED ${SOURCES})\nendif ()\n\nadd_library(RecastNavigation::Recast ALIAS Recast)\n\nset(Recast_INCLUDE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}/Include\")\n\ntarget_include_directories(Recast PUBLIC\n    \"$<BUILD_INTERFACE:${Recast_INCLUDE_DIR}>\"\n)\n\nset_target_properties(Recast PROPERTIES\n        SOVERSION ${SOVERSION}\n        VERSION ${VERSION}\n        )\n\ninstall(TARGETS Recast\n        ARCHIVE DESTINATION lib\n        LIBRARY DESTINATION lib\n        COMPONENT library\n        )\n\nfile(GLOB INCLUDES Include/*.h)\ninstall(FILES ${INCLUDES} DESTINATION include)\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Include/Recast.h",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n \n#ifndef RECAST_H\n#define RECAST_H\n\n/// The value of PI used by Recast.\nstatic const float RC_PI = 3.14159265f;\n\n/// Recast log categories.\n/// @see rcContext\nenum rcLogCategory\n{\n\tRC_LOG_PROGRESS = 1,\t///< A progress log entry.\n\tRC_LOG_WARNING,\t\t\t///< A warning log entry.\n\tRC_LOG_ERROR,\t\t\t///< An error log entry.\n};\n\n/// Recast performance timer categories.\n/// @see rcContext\nenum rcTimerLabel\n{\n\t/// The user defined total time of the build.\n\tRC_TIMER_TOTAL,\n\t/// A user defined build time.\n\tRC_TIMER_TEMP,\n\t/// The time to rasterize the triangles. (See: #rcRasterizeTriangle)\n\tRC_TIMER_RASTERIZE_TRIANGLES,\n\t/// The time to build the compact heightfield. (See: #rcBuildCompactHeightfield)\n\tRC_TIMER_BUILD_COMPACTHEIGHTFIELD,\n\t/// The total time to build the contours. (See: #rcBuildContours)\n\tRC_TIMER_BUILD_CONTOURS,\n\t/// The time to trace the boundaries of the contours. (See: #rcBuildContours)\n\tRC_TIMER_BUILD_CONTOURS_TRACE,\n\t/// The time to simplify the contours. (See: #rcBuildContours)\n\tRC_TIMER_BUILD_CONTOURS_SIMPLIFY,\n\t/// The time to filter ledge spans. (See: #rcFilterLedgeSpans)\n\tRC_TIMER_FILTER_BORDER,\n\t/// The time to filter low height spans. (See: #rcFilterWalkableLowHeightSpans)\n\tRC_TIMER_FILTER_WALKABLE,\n\t/// The time to apply the median filter. (See: #rcMedianFilterWalkableArea)\n\tRC_TIMER_MEDIAN_AREA,\n\t/// The time to filter low obstacles. (See: #rcFilterLowHangingWalkableObstacles)\n\tRC_TIMER_FILTER_LOW_OBSTACLES,\n\t/// The time to build the polygon mesh. (See: #rcBuildPolyMesh)\n\tRC_TIMER_BUILD_POLYMESH,\n\t/// The time to merge polygon meshes. (See: #rcMergePolyMeshes)\n\tRC_TIMER_MERGE_POLYMESH,\n\t/// The time to erode the walkable area. (See: #rcErodeWalkableArea)\n\tRC_TIMER_ERODE_AREA,\n\t/// The time to mark a box area. (See: #rcMarkBoxArea)\n\tRC_TIMER_MARK_BOX_AREA,\n\t/// The time to mark a cylinder area. (See: #rcMarkCylinderArea)\n\tRC_TIMER_MARK_CYLINDER_AREA,\n\t/// The time to mark a convex polygon area. (See: #rcMarkConvexPolyArea)\n\tRC_TIMER_MARK_CONVEXPOLY_AREA,\n\t/// The total time to build the distance field. (See: #rcBuildDistanceField)\n\tRC_TIMER_BUILD_DISTANCEFIELD,\n\t/// The time to build the distances of the distance field. (See: #rcBuildDistanceField)\n\tRC_TIMER_BUILD_DISTANCEFIELD_DIST,\n\t/// The time to blur the distance field. (See: #rcBuildDistanceField)\n\tRC_TIMER_BUILD_DISTANCEFIELD_BLUR,\n\t/// The total time to build the regions. (See: #rcBuildRegions, #rcBuildRegionsMonotone)\n\tRC_TIMER_BUILD_REGIONS,\n\t/// The total time to apply the watershed algorithm. (See: #rcBuildRegions)\n\tRC_TIMER_BUILD_REGIONS_WATERSHED,\n\t/// The time to expand regions while applying the watershed algorithm. (See: #rcBuildRegions)\n\tRC_TIMER_BUILD_REGIONS_EXPAND,\n\t/// The time to flood regions while applying the watershed algorithm. (See: #rcBuildRegions)\n\tRC_TIMER_BUILD_REGIONS_FLOOD,\n\t/// The time to filter out small regions. (See: #rcBuildRegions, #rcBuildRegionsMonotone)\n\tRC_TIMER_BUILD_REGIONS_FILTER,\n\t/// The time to build heightfield layers. (See: #rcBuildHeightfieldLayers)\n\tRC_TIMER_BUILD_LAYERS, \n\t/// The time to build the polygon mesh detail. (See: #rcBuildPolyMeshDetail)\n\tRC_TIMER_BUILD_POLYMESHDETAIL,\n\t/// The time to merge polygon mesh details. (See: #rcMergePolyMeshDetails)\n\tRC_TIMER_MERGE_POLYMESHDETAIL,\n\t/// The maximum number of timers.  (Used for iterating timers.)\n\tRC_MAX_TIMERS\n};\n\n/// Provides an interface for optional logging and performance tracking of the Recast \n/// build process.\n/// @ingroup recast\nclass rcContext\n{\npublic:\n\n\t/// Contructor.\n\t///  @param[in]\t\tstate\tTRUE if the logging and performance timers should be enabled.  [Default: true]\n\tinline rcContext(bool state = true) : m_logEnabled(state), m_timerEnabled(state) {}\n\tvirtual ~rcContext() {}\n\n\t/// Enables or disables logging.\n\t///  @param[in]\t\tstate\tTRUE if logging should be enabled.\n\tinline void enableLog(bool state) { m_logEnabled = state; }\n\n\t/// Clears all log entries.\n\tinline void resetLog() { if (m_logEnabled) doResetLog(); }\n\n\t/// Logs a message.\n\t///  @param[in]\t\tcategory\tThe category of the message.\n\t///  @param[in]\t\tformat\t\tThe message.\n\tvoid log(const rcLogCategory category, const char* format, ...);\n\n\t/// Enables or disables the performance timers.\n\t///  @param[in]\t\tstate\tTRUE if timers should be enabled.\n\tinline void enableTimer(bool state) { m_timerEnabled = state; }\n\n\t/// Clears all peformance timers. (Resets all to unused.)\n\tinline void resetTimers() { if (m_timerEnabled) doResetTimers(); }\n\n\t/// Starts the specified performance timer.\n\t///  @param\tlabel\tThe category of the timer.\n\tinline void startTimer(const rcTimerLabel label) { if (m_timerEnabled) doStartTimer(label); }\n\n\t/// Stops the specified performance timer.\n\t///  @param\tlabel\tThe category of the timer.\n\tinline void stopTimer(const rcTimerLabel label) { if (m_timerEnabled) doStopTimer(label); }\n\n\t/// Returns the total accumulated time of the specified performance timer.\n\t///  @param\tlabel\tThe category of the timer.\n\t///  @return The accumulated time of the timer, or -1 if timers are disabled or the timer has never been started.\n\tinline int getAccumulatedTime(const rcTimerLabel label) const { return m_timerEnabled ? doGetAccumulatedTime(label) : -1; }\n\nprotected:\n\n\t/// Clears all log entries.\n\tvirtual void doResetLog() {}\n\n\t/// Logs a message.\n\t///  @param[in]\t\tcategory\tThe category of the message.\n\t///  @param[in]\t\tmsg\t\t\tThe formatted message.\n\t///  @param[in]\t\tlen\t\t\tThe length of the formatted message.\n\tvirtual void doLog(const rcLogCategory /*category*/, const char* /*msg*/, const int /*len*/) {}\n\n\t/// Clears all timers. (Resets all to unused.)\n\tvirtual void doResetTimers() {}\n\n\t/// Starts the specified performance timer.\n\t///  @param[in]\t\tlabel\tThe category of timer.\n\tvirtual void doStartTimer(const rcTimerLabel /*label*/) {}\n\n\t/// Stops the specified performance timer.\n\t///  @param[in]\t\tlabel\tThe category of the timer.\n\tvirtual void doStopTimer(const rcTimerLabel /*label*/) {}\n\n\t/// Returns the total accumulated time of the specified performance timer.\n\t///  @param[in]\t\tlabel\tThe category of the timer.\n\t///  @return The accumulated time of the timer, or -1 if timers are disabled or the timer has never been started.\n\tvirtual int doGetAccumulatedTime(const rcTimerLabel /*label*/) const { return -1; }\n\t\n\t/// True if logging is enabled.\n\tbool m_logEnabled;\n\n\t/// True if the performance timers are enabled.\n\tbool m_timerEnabled;\n};\n\n/// A helper to first start a timer and then stop it when this helper goes out of scope.\n/// @see rcContext\nclass rcScopedTimer\n{\npublic:\n\t/// Constructs an instance and starts the timer.\n\t///  @param[in]\t\tctx\t\tThe context to use.\n\t///  @param[in]\t\tlabel\tThe category of the timer.\n\tinline rcScopedTimer(rcContext* ctx, const rcTimerLabel label) : m_ctx(ctx), m_label(label) { m_ctx->startTimer(m_label); }\n\tinline ~rcScopedTimer() { m_ctx->stopTimer(m_label); }\n\nprivate:\n\t// Explicitly disabled copy constructor and copy assignment operator.\n\trcScopedTimer(const rcScopedTimer&);\n\trcScopedTimer& operator=(const rcScopedTimer&);\n\t\n\trcContext* const m_ctx;\n\tconst rcTimerLabel m_label;\n};\n\n/// Specifies a configuration to use when performing Recast builds.\n/// @ingroup recast\nstruct rcConfig\n{\n\t/// The width of the field along the x-axis. [Limit: >= 0] [Units: vx]\n\tint width;\n\n\t/// The height of the field along the z-axis. [Limit: >= 0] [Units: vx]\n\tint height;\n\t\n\t/// The width/height size of tile's on the xz-plane. [Limit: >= 0] [Units: vx]\n\tint tileSize;\n\t\n\t/// The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx]\n\tint borderSize;\n\n\t/// The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu] \n\tfloat cs;\n\n\t/// The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]\n\tfloat ch;\n\n\t/// The minimum bounds of the field's AABB. [(x, y, z)] [Units: wu]\n\tfloat bmin[3]; \n\n\t/// The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu]\n\tfloat bmax[3];\n\n\t/// The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees] \n\tfloat walkableSlopeAngle;\n\n\t/// Minimum floor to 'ceiling' height that will still allow the floor area to \n\t/// be considered walkable. [Limit: >= 3] [Units: vx] \n\tint walkableHeight;\n\t\n\t/// Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx] \n\tint walkableClimb;\n\t\n\t/// The distance to erode/shrink the walkable area of the heightfield away from \n\t/// obstructions.  [Limit: >=0] [Units: vx] \n\tint walkableRadius;\n\t\n\t/// The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx] \n\tint maxEdgeLen;\n\t\n\t/// The maximum distance a simplfied contour's border edges should deviate \n\t/// the original raw contour. [Limit: >=0] [Units: vx]\n\tfloat maxSimplificationError;\n\t\n\t/// The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx] \n\tint minRegionArea;\n\t\n\t/// Any regions with a span count smaller than this value will, if possible, \n\t/// be merged with larger regions. [Limit: >=0] [Units: vx] \n\tint mergeRegionArea;\n\t\n\t/// The maximum number of vertices allowed for polygons generated during the \n\t/// contour to polygon conversion process. [Limit: >= 3] \n\tint maxVertsPerPoly;\n\t\n\t/// Sets the sampling distance to use when generating the detail mesh.\n\t/// (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu] \n\tfloat detailSampleDist;\n\t\n\t/// The maximum distance the detail mesh surface should deviate from heightfield\n\t/// data. (For height detail only.) [Limit: >=0] [Units: wu] \n\tfloat detailSampleMaxError;\n};\n\n/// Defines the number of bits allocated to rcSpan::smin and rcSpan::smax.\nstatic const int RC_SPAN_HEIGHT_BITS = 13;\n/// Defines the maximum value for rcSpan::smin and rcSpan::smax.\nstatic const int RC_SPAN_MAX_HEIGHT = (1 << RC_SPAN_HEIGHT_BITS) - 1;\n\n/// The number of spans allocated per span spool.\n/// @see rcSpanPool\nstatic const int RC_SPANS_PER_POOL = 2048;\n\n/// Represents a span in a heightfield.\n/// @see rcHeightfield\nstruct rcSpan\n{\n\tunsigned int smin : RC_SPAN_HEIGHT_BITS; ///< The lower limit of the span. [Limit: < #smax]\n\tunsigned int smax : RC_SPAN_HEIGHT_BITS; ///< The upper limit of the span. [Limit: <= #RC_SPAN_MAX_HEIGHT]\n\tunsigned int area : 6;                   ///< The area id assigned to the span.\n\trcSpan* next;                            ///< The next span higher up in column.\n};\n\n/// A memory pool used for quick allocation of spans within a heightfield.\n/// @see rcHeightfield\nstruct rcSpanPool\n{\n\trcSpanPool* next;\t\t\t\t\t///< The next span pool.\n\trcSpan items[RC_SPANS_PER_POOL];\t///< Array of spans in the pool.\n};\n\n/// A dynamic heightfield representing obstructed space.\n/// @ingroup recast\nstruct rcHeightfield\n{\n\trcHeightfield();\n\t~rcHeightfield();\n\n\tint width;\t\t\t///< The width of the heightfield. (Along the x-axis in cell units.)\n\tint height;\t\t\t///< The height of the heightfield. (Along the z-axis in cell units.)\n\tfloat bmin[3];  \t///< The minimum bounds in world space. [(x, y, z)]\n\tfloat bmax[3];\t\t///< The maximum bounds in world space. [(x, y, z)]\n\tfloat cs;\t\t\t///< The size of each cell. (On the xz-plane.)\n\tfloat ch;\t\t\t///< The height of each cell. (The minimum increment along the y-axis.)\n\trcSpan** spans;\t\t///< Heightfield of spans (width*height).\n\trcSpanPool* pools;\t///< Linked list of span pools.\n\trcSpan* freelist;\t///< The next free span.\n\nprivate:\n\t// Explicitly-disabled copy constructor and copy assignment operator.\n\trcHeightfield(const rcHeightfield&);\n\trcHeightfield& operator=(const rcHeightfield&);\n};\n\n/// Provides information on the content of a cell column in a compact heightfield. \nstruct rcCompactCell\n{\n\tunsigned int index : 24;\t///< Index to the first span in the column.\n\tunsigned int count : 8;\t\t///< Number of spans in the column.\n};\n\n/// Represents a span of unobstructed space within a compact heightfield.\nstruct rcCompactSpan\n{\n\tunsigned short y;\t\t\t///< The lower extent of the span. (Measured from the heightfield's base.)\n\tunsigned short reg;\t\t\t///< The id of the region the span belongs to. (Or zero if not in a region.)\n\tunsigned int con : 24;\t\t///< Packed neighbor connection data.\n\tunsigned int h : 8;\t\t\t///< The height of the span.  (Measured from #y.)\n};\n\n/// A compact, static heightfield representing unobstructed space.\n/// @ingroup recast\nstruct rcCompactHeightfield\n{\n\trcCompactHeightfield();\n\t~rcCompactHeightfield();\n\tint width;\t\t\t\t\t///< The width of the heightfield. (Along the x-axis in cell units.)\n\tint height;\t\t\t\t\t///< The height of the heightfield. (Along the z-axis in cell units.)\n\tint spanCount;\t\t\t\t///< The number of spans in the heightfield.\n\tint walkableHeight;\t\t\t///< The walkable height used during the build of the field.  (See: rcConfig::walkableHeight)\n\tint walkableClimb;\t\t\t///< The walkable climb used during the build of the field. (See: rcConfig::walkableClimb)\n\tint borderSize;\t\t\t\t///< The AABB border size used during the build of the field. (See: rcConfig::borderSize)\n\tunsigned short maxDistance;\t///< The maximum distance value of any span within the field. \n\tunsigned short maxRegions;\t///< The maximum region id of any span within the field. \n\tfloat bmin[3];\t\t\t\t///< The minimum bounds in world space. [(x, y, z)]\n\tfloat bmax[3];\t\t\t\t///< The maximum bounds in world space. [(x, y, z)]\n\tfloat cs;\t\t\t\t\t///< The size of each cell. (On the xz-plane.)\n\tfloat ch;\t\t\t\t\t///< The height of each cell. (The minimum increment along the y-axis.)\n\trcCompactCell* cells;\t\t///< Array of cells. [Size: #width*#height]\n\trcCompactSpan* spans;\t\t///< Array of spans. [Size: #spanCount]\n\tunsigned short* dist;\t\t///< Array containing border distance data. [Size: #spanCount]\n\tunsigned char* areas;\t\t///< Array containing area id data. [Size: #spanCount]\n};\n\n/// Represents a heightfield layer within a layer set.\n/// @see rcHeightfieldLayerSet\nstruct rcHeightfieldLayer\n{\n\tfloat bmin[3];\t\t\t\t///< The minimum bounds in world space. [(x, y, z)]\n\tfloat bmax[3];\t\t\t\t///< The maximum bounds in world space. [(x, y, z)]\n\tfloat cs;\t\t\t\t\t///< The size of each cell. (On the xz-plane.)\n\tfloat ch;\t\t\t\t\t///< The height of each cell. (The minimum increment along the y-axis.)\n\tint width;\t\t\t\t\t///< The width of the heightfield. (Along the x-axis in cell units.)\n\tint height;\t\t\t\t\t///< The height of the heightfield. (Along the z-axis in cell units.)\n\tint minx;\t\t\t\t\t///< The minimum x-bounds of usable data.\n\tint maxx;\t\t\t\t\t///< The maximum x-bounds of usable data.\n\tint miny;\t\t\t\t\t///< The minimum y-bounds of usable data. (Along the z-axis.)\n\tint maxy;\t\t\t\t\t///< The maximum y-bounds of usable data. (Along the z-axis.)\n\tint hmin;\t\t\t\t\t///< The minimum height bounds of usable data. (Along the y-axis.)\n\tint hmax;\t\t\t\t\t///< The maximum height bounds of usable data. (Along the y-axis.)\n\tunsigned char* heights;\t\t///< The heightfield. [Size: width * height]\n\tunsigned char* areas;\t\t///< Area ids. [Size: Same as #heights]\n\tunsigned char* cons;\t\t///< Packed neighbor connection information. [Size: Same as #heights]\n};\n\n/// Represents a set of heightfield layers.\n/// @ingroup recast\n/// @see rcAllocHeightfieldLayerSet, rcFreeHeightfieldLayerSet \nstruct rcHeightfieldLayerSet\n{\n\trcHeightfieldLayerSet();\n\t~rcHeightfieldLayerSet();\n\trcHeightfieldLayer* layers;\t\t\t///< The layers in the set. [Size: #nlayers]\n\tint nlayers;\t\t\t\t\t\t///< The number of layers in the set.\n};\n\n/// Represents a simple, non-overlapping contour in field space.\nstruct rcContour\n{\n\tint* verts;\t\t\t///< Simplified contour vertex and connection data. [Size: 4 * #nverts]\n\tint nverts;\t\t\t///< The number of vertices in the simplified contour. \n\tint* rverts;\t\t///< Raw contour vertex and connection data. [Size: 4 * #nrverts]\n\tint nrverts;\t\t///< The number of vertices in the raw contour. \n\tunsigned short reg;\t///< The region id of the contour.\n\tunsigned char area;\t///< The area id of the contour.\n};\n\n/// Represents a group of related contours.\n/// @ingroup recast\nstruct rcContourSet\n{\n\trcContourSet();\n\t~rcContourSet();\n\trcContour* conts;\t///< An array of the contours in the set. [Size: #nconts]\n\tint nconts;\t\t\t///< The number of contours in the set.\n\tfloat bmin[3];  \t///< The minimum bounds in world space. [(x, y, z)]\n\tfloat bmax[3];\t\t///< The maximum bounds in world space. [(x, y, z)]\n\tfloat cs;\t\t\t///< The size of each cell. (On the xz-plane.)\n\tfloat ch;\t\t\t///< The height of each cell. (The minimum increment along the y-axis.)\n\tint width;\t\t\t///< The width of the set. (Along the x-axis in cell units.) \n\tint height;\t\t\t///< The height of the set. (Along the z-axis in cell units.) \n\tint borderSize;\t\t///< The AABB border size used to generate the source data from which the contours were derived.\n\tfloat maxError;\t\t///< The max edge error that this contour set was simplified with.\n};\n\n/// Represents a polygon mesh suitable for use in building a navigation mesh. \n/// @ingroup recast\nstruct rcPolyMesh\n{\n\trcPolyMesh();\n\t~rcPolyMesh();\n\tunsigned short* verts;\t///< The mesh vertices. [Form: (x, y, z) * #nverts]\n\tunsigned short* polys;\t///< Polygon and neighbor data. [Length: #maxpolys * 2 * #nvp]\n\tunsigned short* regs;\t///< The region id assigned to each polygon. [Length: #maxpolys]\n\tunsigned short* flags;\t///< The user defined flags for each polygon. [Length: #maxpolys]\n\tunsigned char* areas;\t///< The area id assigned to each polygon. [Length: #maxpolys]\n\tint nverts;\t\t\t\t///< The number of vertices.\n\tint npolys;\t\t\t\t///< The number of polygons.\n\tint maxpolys;\t\t\t///< The number of allocated polygons.\n\tint nvp;\t\t\t\t///< The maximum number of vertices per polygon.\n\tfloat bmin[3];\t\t\t///< The minimum bounds in world space. [(x, y, z)]\n\tfloat bmax[3];\t\t\t///< The maximum bounds in world space. [(x, y, z)]\n\tfloat cs;\t\t\t\t///< The size of each cell. (On the xz-plane.)\n\tfloat ch;\t\t\t\t///< The height of each cell. (The minimum increment along the y-axis.)\n\tint borderSize;\t\t\t///< The AABB border size used to generate the source data from which the mesh was derived.\n\tfloat maxEdgeError;\t\t///< The max error of the polygon edges in the mesh.\n};\n\n/// Contains triangle meshes that represent detailed height data associated \n/// with the polygons in its associated polygon mesh object.\n/// @ingroup recast\nstruct rcPolyMeshDetail\n{\n\tunsigned int* meshes;\t///< The sub-mesh data. [Size: 4*#nmeshes] \n\tfloat* verts;\t\t\t///< The mesh vertices. [Size: 3*#nverts] \n\tunsigned char* tris;\t///< The mesh triangles. [Size: 4*#ntris] \n\tint nmeshes;\t\t\t///< The number of sub-meshes defined by #meshes.\n\tint nverts;\t\t\t\t///< The number of vertices in #verts.\n\tint ntris;\t\t\t\t///< The number of triangles in #tris.\n};\n\n/// @name Allocation Functions\n/// Functions used to allocate and de-allocate Recast objects.\n/// @see rcAllocSetCustom\n/// @{\n\n/// Allocates a heightfield object using the Recast allocator.\n///  @return A heightfield that is ready for initialization, or null on failure.\n///  @ingroup recast\n///  @see rcCreateHeightfield, rcFreeHeightField\nrcHeightfield* rcAllocHeightfield();\n\n/// Frees the specified heightfield object using the Recast allocator.\n///  @param[in]\t\thf\tA heightfield allocated using #rcAllocHeightfield\n///  @ingroup recast\n///  @see rcAllocHeightfield\nvoid rcFreeHeightField(rcHeightfield* hf);\n\n/// Allocates a compact heightfield object using the Recast allocator.\n///  @return A compact heightfield that is ready for initialization, or null on failure.\n///  @ingroup recast\n///  @see rcBuildCompactHeightfield, rcFreeCompactHeightfield\nrcCompactHeightfield* rcAllocCompactHeightfield();\n\n/// Frees the specified compact heightfield object using the Recast allocator.\n///  @param[in]\t\tchf\t\tA compact heightfield allocated using #rcAllocCompactHeightfield\n///  @ingroup recast\n///  @see rcAllocCompactHeightfield\nvoid rcFreeCompactHeightfield(rcCompactHeightfield* chf);\n\n/// Allocates a heightfield layer set using the Recast allocator.\n///  @return A heightfield layer set that is ready for initialization, or null on failure.\n///  @ingroup recast\n///  @see rcBuildHeightfieldLayers, rcFreeHeightfieldLayerSet\nrcHeightfieldLayerSet* rcAllocHeightfieldLayerSet();\n\n/// Frees the specified heightfield layer set using the Recast allocator.\n///  @param[in]\t\tlset\tA heightfield layer set allocated using #rcAllocHeightfieldLayerSet\n///  @ingroup recast\n///  @see rcAllocHeightfieldLayerSet\nvoid rcFreeHeightfieldLayerSet(rcHeightfieldLayerSet* lset);\n\n/// Allocates a contour set object using the Recast allocator.\n///  @return A contour set that is ready for initialization, or null on failure.\n///  @ingroup recast\n///  @see rcBuildContours, rcFreeContourSet\nrcContourSet* rcAllocContourSet();\n\n/// Frees the specified contour set using the Recast allocator.\n///  @param[in]\t\tcset\tA contour set allocated using #rcAllocContourSet\n///  @ingroup recast\n///  @see rcAllocContourSet\nvoid rcFreeContourSet(rcContourSet* cset);\n\n/// Allocates a polygon mesh object using the Recast allocator.\n///  @return A polygon mesh that is ready for initialization, or null on failure.\n///  @ingroup recast\n///  @see rcBuildPolyMesh, rcFreePolyMesh\nrcPolyMesh* rcAllocPolyMesh();\n\n/// Frees the specified polygon mesh using the Recast allocator.\n///  @param[in]\t\tpmesh\tA polygon mesh allocated using #rcAllocPolyMesh\n///  @ingroup recast\n///  @see rcAllocPolyMesh\nvoid rcFreePolyMesh(rcPolyMesh* pmesh);\n\n/// Allocates a detail mesh object using the Recast allocator.\n///  @return A detail mesh that is ready for initialization, or null on failure.\n///  @ingroup recast\n///  @see rcBuildPolyMeshDetail, rcFreePolyMeshDetail\nrcPolyMeshDetail* rcAllocPolyMeshDetail();\n\n/// Frees the specified detail mesh using the Recast allocator.\n///  @param[in]\t\tdmesh\tA detail mesh allocated using #rcAllocPolyMeshDetail\n///  @ingroup recast\n///  @see rcAllocPolyMeshDetail\nvoid rcFreePolyMeshDetail(rcPolyMeshDetail* dmesh);\n\n/// @}\n\n/// Heighfield border flag.\n/// If a heightfield region ID has this bit set, then the region is a border \n/// region and its spans are considered unwalkable.\n/// (Used during the region and contour build process.)\n/// @see rcCompactSpan::reg\nstatic const unsigned short RC_BORDER_REG = 0x8000;\n\n/// Polygon touches multiple regions.\n/// If a polygon has this region ID it was merged with or created\n/// from polygons of different regions during the polymesh\n/// build step that removes redundant border vertices. \n/// (Used during the polymesh and detail polymesh build processes)\n/// @see rcPolyMesh::regs\nstatic const unsigned short RC_MULTIPLE_REGS = 0;\n\n/// Border vertex flag.\n/// If a region ID has this bit set, then the associated element lies on\n/// a tile border. If a contour vertex's region ID has this bit set, the \n/// vertex will later be removed in order to match the segments and vertices \n/// at tile boundaries.\n/// (Used during the build process.)\n/// @see rcCompactSpan::reg, #rcContour::verts, #rcContour::rverts\nstatic const int RC_BORDER_VERTEX = 0x10000;\n\n/// Area border flag.\n/// If a region ID has this bit set, then the associated element lies on\n/// the border of an area.\n/// (Used during the region and contour build process.)\n/// @see rcCompactSpan::reg, #rcContour::verts, #rcContour::rverts\nstatic const int RC_AREA_BORDER = 0x20000;\n\n/// Contour build flags.\n/// @see rcBuildContours\nenum rcBuildContoursFlags\n{\n\tRC_CONTOUR_TESS_WALL_EDGES = 0x01,\t///< Tessellate solid (impassable) edges during contour simplification.\n\tRC_CONTOUR_TESS_AREA_EDGES = 0x02,\t///< Tessellate edges between areas during contour simplification.\n};\n\n/// Applied to the region id field of contour vertices in order to extract the region id.\n/// The region id field of a vertex may have several flags applied to it.  So the\n/// fields value can't be used directly.\n/// @see rcContour::verts, rcContour::rverts\nstatic const int RC_CONTOUR_REG_MASK = 0xffff;\n\n/// An value which indicates an invalid index within a mesh.\n/// @note This does not necessarily indicate an error.\n/// @see rcPolyMesh::polys\nstatic const unsigned short RC_MESH_NULL_IDX = 0xffff;\n\n/// Represents the null area.\n/// When a data element is given this value it is considered to no longer be \n/// assigned to a usable area.  (E.g. It is unwalkable.)\nstatic const unsigned char RC_NULL_AREA = 0;\n\n/// The default area id used to indicate a walkable polygon. \n/// This is also the maximum allowed area id, and the only non-null area id \n/// recognized by some steps in the build process. \nstatic const unsigned char RC_WALKABLE_AREA = 63;\n\n/// The value returned by #rcGetCon if the specified direction is not connected\n/// to another span. (Has no neighbor.)\nstatic const int RC_NOT_CONNECTED = 0x3f;\n\n/// @name General helper functions\n/// @{\n\n/// Used to ignore a function parameter.  VS complains about unused parameters\n/// and this silences the warning.\n///  @param [in] _ Unused parameter\ntemplate<class T> void rcIgnoreUnused(const T&) { }\n\n/// Swaps the values of the two parameters.\n///  @param[in,out]\ta\tValue A\n///  @param[in,out]\tb\tValue B\ntemplate<class T> inline void rcSwap(T& a, T& b) { T t = a; a = b; b = t; }\n\n/// Returns the minimum of two values.\n///  @param[in]\t\ta\tValue A\n///  @param[in]\t\tb\tValue B\n///  @return The minimum of the two values.\ntemplate<class T> inline T rcMin(T a, T b) { return a < b ? a : b; }\n\n/// Returns the maximum of two values.\n///  @param[in]\t\ta\tValue A\n///  @param[in]\t\tb\tValue B\n///  @return The maximum of the two values.\ntemplate<class T> inline T rcMax(T a, T b) { return a > b ? a : b; }\n\n/// Returns the absolute value.\n///  @param[in]\t\ta\tThe value.\n///  @return The absolute value of the specified value.\ntemplate<class T> inline T rcAbs(T a) { return a < 0 ? -a : a; }\n\n/// Returns the square of the value.\n///  @param[in]\t\ta\tThe value.\n///  @return The square of the value.\ntemplate<class T> inline T rcSqr(T a) { return a*a; }\n\n/// Clamps the value to the specified range.\n///  @param[in]\t\tv\tThe value to clamp.\n///  @param[in]\t\tmn\tThe minimum permitted return value.\n///  @param[in]\t\tmx\tThe maximum permitted return value.\n///  @return The value, clamped to the specified range.\ntemplate<class T> inline T rcClamp(T v, T mn, T mx) { return v < mn ? mn : (v > mx ? mx : v); }\n\n/// Returns the square root of the value.\n///  @param[in]\t\tx\tThe value.\n///  @return The square root of the vlaue.\nfloat rcSqrt(float x);\n\n/// @}\n/// @name Vector helper functions.\n/// @{\n\n/// Derives the cross product of two vectors. (@p v1 x @p v2)\n///  @param[out]\tdest\tThe cross product. [(x, y, z)]\n///  @param[in]\t\tv1\t\tA Vector [(x, y, z)]\n///  @param[in]\t\tv2\t\tA vector [(x, y, z)]\ninline void rcVcross(float* dest, const float* v1, const float* v2)\n{\n\tdest[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\tdest[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\tdest[2] = v1[0]*v2[1] - v1[1]*v2[0];\n}\n\n/// Derives the dot product of two vectors. (@p v1 . @p v2)\n///  @param[in]\t\tv1\tA Vector [(x, y, z)]\n///  @param[in]\t\tv2\tA vector [(x, y, z)]\n/// @return The dot product.\ninline float rcVdot(const float* v1, const float* v2)\n{\n\treturn v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];\n}\n\n/// Performs a scaled vector addition. (@p v1 + (@p v2 * @p s))\n///  @param[out]\tdest\tThe result vector. [(x, y, z)]\n///  @param[in]\t\tv1\t\tThe base vector. [(x, y, z)]\n///  @param[in]\t\tv2\t\tThe vector to scale and add to @p v1. [(x, y, z)]\n///  @param[in]\t\ts\t\tThe amount to scale @p v2 by before adding to @p v1.\ninline void rcVmad(float* dest, const float* v1, const float* v2, const float s)\n{\n\tdest[0] = v1[0]+v2[0]*s;\n\tdest[1] = v1[1]+v2[1]*s;\n\tdest[2] = v1[2]+v2[2]*s;\n}\n\n/// Performs a vector addition. (@p v1 + @p v2)\n///  @param[out]\tdest\tThe result vector. [(x, y, z)]\n///  @param[in]\t\tv1\t\tThe base vector. [(x, y, z)]\n///  @param[in]\t\tv2\t\tThe vector to add to @p v1. [(x, y, z)]\ninline void rcVadd(float* dest, const float* v1, const float* v2)\n{\n\tdest[0] = v1[0]+v2[0];\n\tdest[1] = v1[1]+v2[1];\n\tdest[2] = v1[2]+v2[2];\n}\n\n/// Performs a vector subtraction. (@p v1 - @p v2)\n///  @param[out]\tdest\tThe result vector. [(x, y, z)]\n///  @param[in]\t\tv1\t\tThe base vector. [(x, y, z)]\n///  @param[in]\t\tv2\t\tThe vector to subtract from @p v1. [(x, y, z)]\ninline void rcVsub(float* dest, const float* v1, const float* v2)\n{\n\tdest[0] = v1[0]-v2[0];\n\tdest[1] = v1[1]-v2[1];\n\tdest[2] = v1[2]-v2[2];\n}\n\n/// Selects the minimum value of each element from the specified vectors.\n///  @param[in,out]\tmn\tA vector.  (Will be updated with the result.) [(x, y, z)]\n///  @param[in]\t\tv\tA vector. [(x, y, z)]\ninline void rcVmin(float* mn, const float* v)\n{\n\tmn[0] = rcMin(mn[0], v[0]);\n\tmn[1] = rcMin(mn[1], v[1]);\n\tmn[2] = rcMin(mn[2], v[2]);\n}\n\n/// Selects the maximum value of each element from the specified vectors.\n///  @param[in,out]\tmx\tA vector.  (Will be updated with the result.) [(x, y, z)]\n///  @param[in]\t\tv\tA vector. [(x, y, z)]\ninline void rcVmax(float* mx, const float* v)\n{\n\tmx[0] = rcMax(mx[0], v[0]);\n\tmx[1] = rcMax(mx[1], v[1]);\n\tmx[2] = rcMax(mx[2], v[2]);\n}\n\n/// Performs a vector copy.\n///  @param[out]\tdest\tThe result. [(x, y, z)]\n///  @param[in]\t\tv\t\tThe vector to copy. [(x, y, z)]\ninline void rcVcopy(float* dest, const float* v)\n{\n\tdest[0] = v[0];\n\tdest[1] = v[1];\n\tdest[2] = v[2];\n}\n\n/// Returns the distance between two points.\n///  @param[in]\t\tv1\tA point. [(x, y, z)]\n///  @param[in]\t\tv2\tA point. [(x, y, z)]\n/// @return The distance between the two points.\ninline float rcVdist(const float* v1, const float* v2)\n{\n\tfloat dx = v2[0] - v1[0];\n\tfloat dy = v2[1] - v1[1];\n\tfloat dz = v2[2] - v1[2];\n\treturn rcSqrt(dx*dx + dy*dy + dz*dz);\n}\n\n/// Returns the square of the distance between two points.\n///  @param[in]\t\tv1\tA point. [(x, y, z)]\n///  @param[in]\t\tv2\tA point. [(x, y, z)]\n/// @return The square of the distance between the two points.\ninline float rcVdistSqr(const float* v1, const float* v2)\n{\n\tfloat dx = v2[0] - v1[0];\n\tfloat dy = v2[1] - v1[1];\n\tfloat dz = v2[2] - v1[2];\n\treturn dx*dx + dy*dy + dz*dz;\n}\n\n/// Normalizes the vector.\n///  @param[in,out]\tv\tThe vector to normalize. [(x, y, z)]\ninline void rcVnormalize(float* v)\n{\n\tfloat d = 1.0f / rcSqrt(rcSqr(v[0]) + rcSqr(v[1]) + rcSqr(v[2]));\n\tv[0] *= d;\n\tv[1] *= d;\n\tv[2] *= d;\n}\n\n/// @}\n/// @name Heightfield Functions\n/// @see rcHeightfield\n/// @{\n\n/// Calculates the bounding box of an array of vertices.\n///  @ingroup recast\n///  @param[in]\t\tverts\tAn array of vertices. [(x, y, z) * @p nv]\n///  @param[in]\t\tnv\t\tThe number of vertices in the @p verts array.\n///  @param[out]\tbmin\tThe minimum bounds of the AABB. [(x, y, z)] [Units: wu]\n///  @param[out]\tbmax\tThe maximum bounds of the AABB. [(x, y, z)] [Units: wu]\nvoid rcCalcBounds(const float* verts, int nv, float* bmin, float* bmax);\n\n/// Calculates the grid size based on the bounding box and grid cell size.\n///  @ingroup recast\n///  @param[in]\t\tbmin\tThe minimum bounds of the AABB. [(x, y, z)] [Units: wu]\n///  @param[in]\t\tbmax\tThe maximum bounds of the AABB. [(x, y, z)] [Units: wu]\n///  @param[in]\t\tcs\t\tThe xz-plane cell size. [Limit: > 0] [Units: wu]\n///  @param[out]\tw\t\tThe width along the x-axis. [Limit: >= 0] [Units: vx]\n///  @param[out]\th\t\tThe height along the z-axis. [Limit: >= 0] [Units: vx]\nvoid rcCalcGridSize(const float* bmin, const float* bmax, float cs, int* w, int* h);\n\n/// Initializes a new heightfield.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in,out]\thf\t\tThe allocated heightfield to initialize.\n///  @param[in]\t\twidth\tThe width of the field along the x-axis. [Limit: >= 0] [Units: vx]\n///  @param[in]\t\theight\tThe height of the field along the z-axis. [Limit: >= 0] [Units: vx]\n///  @param[in]\t\tbmin\tThe minimum bounds of the field's AABB. [(x, y, z)] [Units: wu]\n///  @param[in]\t\tbmax\tThe maximum bounds of the field's AABB. [(x, y, z)] [Units: wu]\n///  @param[in]\t\tcs\t\tThe xz-plane cell size to use for the field. [Limit: > 0] [Units: wu]\n///  @param[in]\t\tch\t\tThe y-axis cell size to use for field. [Limit: > 0] [Units: wu]\n///  @returns True if the operation completed successfully.\nbool rcCreateHeightfield(rcContext* ctx, rcHeightfield& hf, int width, int height,\n\t\t\t\t\t\t const float* bmin, const float* bmax,\n\t\t\t\t\t\t float cs, float ch);\n\n/// Sets the area id of all triangles with a slope below the specified value\n/// to #RC_WALKABLE_AREA.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\twalkableSlopeAngle\tThe maximum slope that is considered walkable.\n///  \t\t\t\t\t\t\t\t\t[Limits: 0 <= value < 90] [Units: Degrees]\n///  @param[in]\t\tverts\t\t\t\tThe vertices. [(x, y, z) * @p nv]\n///  @param[in]\t\tnv\t\t\t\t\tThe number of vertices.\n///  @param[in]\t\ttris\t\t\t\tThe triangle vertex indices. [(vertA, vertB, vertC) * @p nt]\n///  @param[in]\t\tnt\t\t\t\t\tThe number of triangles.\n///  @param[out]\tareas\t\t\t\tThe triangle area ids. [Length: >= @p nt]\nvoid rcMarkWalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, const float* verts, int nv,\n\t\t\t\t\t\t\t const int* tris, int nt, unsigned char* areas); \n\n/// Sets the area id of all triangles with a slope greater than or equal to the specified value to #RC_NULL_AREA.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\twalkableSlopeAngle\tThe maximum slope that is considered walkable.\n///  \t\t\t\t\t\t\t\t\t[Limits: 0 <= value < 90] [Units: Degrees]\n///  @param[in]\t\tverts\t\t\t\tThe vertices. [(x, y, z) * @p nv]\n///  @param[in]\t\tnv\t\t\t\t\tThe number of vertices.\n///  @param[in]\t\ttris\t\t\t\tThe triangle vertex indices. [(vertA, vertB, vertC) * @p nt]\n///  @param[in]\t\tnt\t\t\t\t\tThe number of triangles.\n///  @param[out]\tareas\t\t\t\tThe triangle area ids. [Length: >= @p nt]\nvoid rcClearUnwalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, const float* verts, int nv,\n\t\t\t\t\t\t\t\tconst int* tris, int nt, unsigned char* areas); \n\n/// Adds a span to the specified heightfield.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in,out]\thf\t\t\t\tAn initialized heightfield.\n///  @param[in]\t\tx\t\t\t\tThe width index where the span is to be added.\n///  \t\t\t\t\t\t\t\t[Limits: 0 <= value < rcHeightfield::width]\n///  @param[in]\t\ty\t\t\t\tThe height index where the span is to be added.\n///  \t\t\t\t\t\t\t\t[Limits: 0 <= value < rcHeightfield::height]\n///  @param[in]\t\tsmin\t\t\tThe minimum height of the span. [Limit: < @p smax] [Units: vx]\n///  @param[in]\t\tsmax\t\t\tThe maximum height of the span. [Limit: <= #RC_SPAN_MAX_HEIGHT] [Units: vx]\n///  @param[in]\t\tarea\t\t\tThe area id of the span. [Limit: <= #RC_WALKABLE_AREA)\n///  @param[in]\t\tflagMergeThr\tThe merge theshold. [Limit: >= 0] [Units: vx]\n///  @returns True if the operation completed successfully.\nbool rcAddSpan(rcContext* ctx, rcHeightfield& hf, const int x, const int y,\n\t\t\t   const unsigned short smin, const unsigned short smax,\n\t\t\t   const unsigned char area, const int flagMergeThr);\n\n/// Rasterizes a triangle into the specified heightfield.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\tv0\t\t\t\tTriangle vertex 0 [(x, y, z)]\n///  @param[in]\t\tv1\t\t\t\tTriangle vertex 1 [(x, y, z)]\n///  @param[in]\t\tv2\t\t\t\tTriangle vertex 2 [(x, y, z)]\n///  @param[in]\t\tarea\t\t\tThe area id of the triangle. [Limit: <= #RC_WALKABLE_AREA]\n///  @param[in,out]\tsolid\t\t\tAn initialized heightfield.\n///  @param[in]\t\tflagMergeThr\tThe distance where the walkable flag is favored over the non-walkable flag.\n///  \t\t\t\t\t\t\t\t[Limit: >= 0] [Units: vx]\n///  @returns True if the operation completed successfully.\nbool rcRasterizeTriangle(rcContext* ctx, const float* v0, const float* v1, const float* v2,\n\t\t\t\t\t\t const unsigned char area, rcHeightfield& solid,\n\t\t\t\t\t\t const int flagMergeThr = 1);\n\n/// Rasterizes an indexed triangle mesh into the specified heightfield.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\tverts\t\t\tThe vertices. [(x, y, z) * @p nv]\n///  @param[in]\t\tnv\t\t\t\tThe number of vertices.\n///  @param[in]\t\ttris\t\t\tThe triangle indices. [(vertA, vertB, vertC) * @p nt]\n///  @param[in]\t\tareas\t\t\tThe area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]\n///  @param[in]\t\tnt\t\t\t\tThe number of triangles.\n///  @param[in,out]\tsolid\t\t\tAn initialized heightfield.\n///  @param[in]\t\tflagMergeThr\tThe distance where the walkable flag is favored over the non-walkable flag. \n///  \t\t\t\t\t\t\t\t[Limit: >= 0] [Units: vx]\n///  @returns True if the operation completed successfully.\nbool rcRasterizeTriangles(rcContext* ctx, const float* verts, const int nv,\n\t\t\t\t\t\t  const int* tris, const unsigned char* areas, const int nt,\n\t\t\t\t\t\t  rcHeightfield& solid, const int flagMergeThr = 1);\n\n/// Rasterizes an indexed triangle mesh into the specified heightfield.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\tThe build context to use during the operation.\n///  @param[in]\t\tverts\t\tThe vertices. [(x, y, z) * @p nv]\n///  @param[in]\t\tnv\t\t\tThe number of vertices.\n///  @param[in]\t\ttris\t\tThe triangle indices. [(vertA, vertB, vertC) * @p nt]\n///  @param[in]\t\tareas\t\tThe area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]\n///  @param[in]\t\tnt\t\t\tThe number of triangles.\n///  @param[in,out]\tsolid\t\tAn initialized heightfield.\n///  @param[in]\t\tflagMergeThr\tThe distance where the walkable flag is favored over the non-walkable flag. \n///  \t\t\t\t\t\t\t[Limit: >= 0] [Units: vx]\n///  @returns True if the operation completed successfully.\nbool rcRasterizeTriangles(rcContext* ctx, const float* verts, const int nv,\n\t\t\t\t\t\t  const unsigned short* tris, const unsigned char* areas, const int nt,\n\t\t\t\t\t\t  rcHeightfield& solid, const int flagMergeThr = 1);\n\n/// Rasterizes triangles into the specified heightfield.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\tverts\t\t\tThe triangle vertices. [(ax, ay, az, bx, by, bz, cx, by, cx) * @p nt]\n///  @param[in]\t\tareas\t\t\tThe area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]\n///  @param[in]\t\tnt\t\t\t\tThe number of triangles.\n///  @param[in,out]\tsolid\t\t\tAn initialized heightfield.\n///  @param[in]\t\tflagMergeThr\tThe distance where the walkable flag is favored over the non-walkable flag. \n///  \t\t\t\t\t\t\t\t[Limit: >= 0] [Units: vx]\n///  @returns True if the operation completed successfully.\nbool rcRasterizeTriangles(rcContext* ctx, const float* verts, const unsigned char* areas, const int nt,\n\t\t\t\t\t\t  rcHeightfield& solid, const int flagMergeThr = 1);\n\n/// Marks non-walkable spans as walkable if their maximum is within @p walkableClimp of a walkable neighbor. \n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\twalkableClimb\tMaximum ledge height that is considered to still be traversable. \n///  \t\t\t\t\t\t\t\t[Limit: >=0] [Units: vx]\n///  @param[in,out]\tsolid\t\t\tA fully built heightfield.  (All spans have been added.)\nvoid rcFilterLowHangingWalkableObstacles(rcContext* ctx, const int walkableClimb, rcHeightfield& solid);\n\n/// Marks spans that are ledges as not-walkable. \n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\twalkableHeight\tMinimum floor to 'ceiling' height that will still allow the floor area to \n///  \t\t\t\t\t\t\t\tbe considered walkable. [Limit: >= 3] [Units: vx]\n///  @param[in]\t\twalkableClimb\tMaximum ledge height that is considered to still be traversable. \n///  \t\t\t\t\t\t\t\t[Limit: >=0] [Units: vx]\n///  @param[in,out]\tsolid\t\t\tA fully built heightfield.  (All spans have been added.)\nvoid rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight,\n\t\t\t\t\t\tconst int walkableClimb, rcHeightfield& solid);\n\n/// Marks walkable spans as not walkable if the clearence above the span is less than the specified height. \n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\twalkableHeight\tMinimum floor to 'ceiling' height that will still allow the floor area to \n///  \t\t\t\t\t\t\t\tbe considered walkable. [Limit: >= 3] [Units: vx]\n///  @param[in,out]\tsolid\t\t\tA fully built heightfield.  (All spans have been added.)\nvoid rcFilterWalkableLowHeightSpans(rcContext* ctx, int walkableHeight, rcHeightfield& solid);\n\n/// Returns the number of spans contained in the specified heightfield.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in]\t\thf\t\tAn initialized heightfield.\n///  @returns The number of spans in the heightfield.\nint rcGetHeightFieldSpanCount(rcContext* ctx, rcHeightfield& hf);\n\n/// @}\n/// @name Compact Heightfield Functions\n/// @see rcCompactHeightfield\n/// @{\n\n/// Builds a compact heightfield representing open space, from a heightfield representing solid space.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\twalkableHeight\tMinimum floor to 'ceiling' height that will still allow the floor area \n///  \t\t\t\t\t\t\t\tto be considered walkable. [Limit: >= 3] [Units: vx]\n///  @param[in]\t\twalkableClimb\tMaximum ledge height that is considered to still be traversable. \n///  \t\t\t\t\t\t\t\t[Limit: >=0] [Units: vx]\n///  @param[in]\t\thf\t\t\t\tThe heightfield to be compacted.\n///  @param[out]\tchf\t\t\t\tThe resulting compact heightfield. (Must be pre-allocated.)\n///  @returns True if the operation completed successfully.\nbool rcBuildCompactHeightfield(rcContext* ctx, const int walkableHeight, const int walkableClimb,\n\t\t\t\t\t\t\t   rcHeightfield& hf, rcCompactHeightfield& chf);\n\n/// Erodes the walkable area within the heightfield by the specified radius. \n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in]\t\tradius\tThe radius of erosion. [Limits: 0 < value < 255] [Units: vx]\n///  @param[in,out]\tchf\t\tThe populated compact heightfield to erode.\n///  @returns True if the operation completed successfully.\nbool rcErodeWalkableArea(rcContext* ctx, int radius, rcCompactHeightfield& chf);\n\n/// Applies a median filter to walkable area types (based on area id), removing noise.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in,out]\tchf\t\tA populated compact heightfield.\n///  @returns True if the operation completed successfully.\nbool rcMedianFilterWalkableArea(rcContext* ctx, rcCompactHeightfield& chf);\n\n/// Applies an area id to all spans within the specified bounding box. (AABB) \n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in]\t\tbmin\tThe minimum of the bounding box. [(x, y, z)]\n///  @param[in]\t\tbmax\tThe maximum of the bounding box. [(x, y, z)]\n///  @param[in]\t\tareaId\tThe area id to apply. [Limit: <= #RC_WALKABLE_AREA]\n///  @param[in,out]\tchf\t\tA populated compact heightfield.\nvoid rcMarkBoxArea(rcContext* ctx, const float* bmin, const float* bmax, unsigned char areaId,\n\t\t\t\t   rcCompactHeightfield& chf);\n\n/// Applies the area id to the all spans within the specified convex polygon. \n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in]\t\tverts\tThe vertices of the polygon [Fomr: (x, y, z) * @p nverts]\n///  @param[in]\t\tnverts\tThe number of vertices in the polygon.\n///  @param[in]\t\thmin\tThe height of the base of the polygon.\n///  @param[in]\t\thmax\tThe height of the top of the polygon.\n///  @param[in]\t\tareaId\tThe area id to apply. [Limit: <= #RC_WALKABLE_AREA]\n///  @param[in,out]\tchf\t\tA populated compact heightfield.\nvoid rcMarkConvexPolyArea(rcContext* ctx, const float* verts, const int nverts,\n\t\t\t\t\t\t  const float hmin, const float hmax, unsigned char areaId,\n\t\t\t\t\t\t  rcCompactHeightfield& chf);\n\n/// Helper function to offset voncex polygons for rcMarkConvexPolyArea.\n///  @ingroup recast\n///  @param[in]\t\tverts\t\tThe vertices of the polygon [Form: (x, y, z) * @p nverts]\n///  @param[in]\t\tnverts\t\tThe number of vertices in the polygon.\n///  @param[out]\toutVerts\tThe offset vertices (should hold up to 2 * @p nverts) [Form: (x, y, z) * return value]\n///  @param[in]\t\tmaxOutVerts\tThe max number of vertices that can be stored to @p outVerts.\n///  @returns Number of vertices in the offset polygon or 0 if too few vertices in @p outVerts.\nint rcOffsetPoly(const float* verts, const int nverts, const float offset,\n\t\t\t\t float* outVerts, const int maxOutVerts);\n\n/// Applies the area id to all spans within the specified cylinder.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in]\t\tpos\t\tThe center of the base of the cylinder. [Form: (x, y, z)] \n///  @param[in]\t\tr\t\tThe radius of the cylinder.\n///  @param[in]\t\th\t\tThe height of the cylinder.\n///  @param[in]\t\tareaId\tThe area id to apply. [Limit: <= #RC_WALKABLE_AREA]\n///  @param[in,out]\tchf\tA populated compact heightfield.\nvoid rcMarkCylinderArea(rcContext* ctx, const float* pos,\n\t\t\t\t\t\tconst float r, const float h, unsigned char areaId,\n\t\t\t\t\t\trcCompactHeightfield& chf);\n\n/// Builds the distance field for the specified compact heightfield. \n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in,out]\tchf\t\tA populated compact heightfield.\n///  @returns True if the operation completed successfully.\nbool rcBuildDistanceField(rcContext* ctx, rcCompactHeightfield& chf);\n\n/// Builds region data for the heightfield using watershed partitioning.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in,out]\tchf\t\t\t\tA populated compact heightfield.\n///  @param[in]\t\tborderSize\t\tThe size of the non-navigable border around the heightfield.\n///  \t\t\t\t\t\t\t\t[Limit: >=0] [Units: vx]\n///  @param[in]\t\tminRegionArea\tThe minimum number of cells allowed to form isolated island areas.\n///  \t\t\t\t\t\t\t\t[Limit: >=0] [Units: vx].\n///  @param[in]\t\tmergeRegionArea\t\tAny regions with a span count smaller than this value will, if possible,\n///  \t\t\t\t\t\t\t\tbe merged with larger regions. [Limit: >=0] [Units: vx] \n///  @returns True if the operation completed successfully.\nbool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,\n\t\t\t\t\tconst int borderSize, const int minRegionArea, const int mergeRegionArea);\n\n/// Builds region data for the heightfield by partitioning the heightfield in non-overlapping layers.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in,out]\tchf\t\t\t\tA populated compact heightfield.\n///  @param[in]\t\tborderSize\t\tThe size of the non-navigable border around the heightfield.\n///  \t\t\t\t\t\t\t\t[Limit: >=0] [Units: vx]\n///  @param[in]\t\tminRegionArea\tThe minimum number of cells allowed to form isolated island areas.\n///  \t\t\t\t\t\t\t\t[Limit: >=0] [Units: vx].\n///  @returns True if the operation completed successfully.\nbool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,\n\t\t\t\t\t\t const int borderSize, const int minRegionArea);\n\n/// Builds region data for the heightfield using simple monotone partitioning.\n///  @ingroup recast \n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in,out]\tchf\t\t\t\tA populated compact heightfield.\n///  @param[in]\t\tborderSize\t\tThe size of the non-navigable border around the heightfield.\n///  \t\t\t\t\t\t\t\t[Limit: >=0] [Units: vx]\n///  @param[in]\t\tminRegionArea\tThe minimum number of cells allowed to form isolated island areas.\n///  \t\t\t\t\t\t\t\t[Limit: >=0] [Units: vx].\n///  @param[in]\t\tmergeRegionArea\tAny regions with a span count smaller than this value will, if possible, \n///  \t\t\t\t\t\t\t\tbe merged with larger regions. [Limit: >=0] [Units: vx] \n///  @returns True if the operation completed successfully.\nbool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,\n\t\t\t\t\t\t\tconst int borderSize, const int minRegionArea, const int mergeRegionArea);\n\n/// Sets the neighbor connection data for the specified direction.\n///  @param[in]\t\ts\t\tThe span to update.\n///  @param[in]\t\tdir\t\tThe direction to set. [Limits: 0 <= value < 4]\n///  @param[in]\t\ti\t\tThe index of the neighbor span.\ninline void rcSetCon(rcCompactSpan& s, int dir, int i)\n{\n\tconst unsigned int shift = (unsigned int)dir*6;\n\tunsigned int con = s.con;\n\ts.con = (con & ~(0x3f << shift)) | (((unsigned int)i & 0x3f) << shift);\n}\n\n/// Gets neighbor connection data for the specified direction.\n///  @param[in]\t\ts\t\tThe span to check.\n///  @param[in]\t\tdir\t\tThe direction to check. [Limits: 0 <= value < 4]\n///  @return The neighbor connection data for the specified direction,\n///  \tor #RC_NOT_CONNECTED if there is no connection.\ninline int rcGetCon(const rcCompactSpan& s, int dir)\n{\n\tconst unsigned int shift = (unsigned int)dir*6;\n\treturn (s.con >> shift) & 0x3f;\n}\n\n/// Gets the standard width (x-axis) offset for the specified direction.\n///  @param[in]\t\tdir\t\tThe direction. [Limits: 0 <= value < 4]\n///  @return The width offset to apply to the current cell position to move\n///  \tin the direction.\ninline int rcGetDirOffsetX(int dir)\n{\n\tstatic const int offset[4] = { -1, 0, 1, 0, };\n\treturn offset[dir&0x03];\n}\n\n/// Gets the standard height (z-axis) offset for the specified direction.\n///  @param[in]\t\tdir\t\tThe direction. [Limits: 0 <= value < 4]\n///  @return The height offset to apply to the current cell position to move\n///  \tin the direction.\ninline int rcGetDirOffsetY(int dir)\n{\n\tstatic const int offset[4] = { 0, 1, 0, -1 };\n\treturn offset[dir&0x03];\n}\n\n/// Gets the direction for the specified offset. One of x and y should be 0.\n///  @param[in]\t\tx\t\tThe x offset. [Limits: -1 <= value <= 1]\n///  @param[in]\t\ty\t\tThe y offset. [Limits: -1 <= value <= 1]\n///  @return The direction that represents the offset.\ninline int rcGetDirForOffset(int x, int y)\n{\n\tstatic const int dirs[5] = { 3, 0, -1, 2, 1 };\n\treturn dirs[((y+1)<<1)+x];\n}\n\n/// @}\n/// @name Layer, Contour, Polymesh, and Detail Mesh Functions\n/// @see rcHeightfieldLayer, rcContourSet, rcPolyMesh, rcPolyMeshDetail\n/// @{\n\n/// Builds a layer set from the specified compact heightfield.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\tThe build context to use during the operation.\n///  @param[in]\t\tchf\t\t\tA fully built compact heightfield.\n///  @param[in]\t\tborderSize\tThe size of the non-navigable border around the heightfield. [Limit: >=0] \n///  \t\t\t\t\t\t\t[Units: vx]\n///  @param[in]\t\twalkableHeight\tMinimum floor to 'ceiling' height that will still allow the floor area \n///  \t\t\t\t\t\t\tto be considered walkable. [Limit: >= 3] [Units: vx]\n///  @param[out]\tlset\t\tThe resulting layer set. (Must be pre-allocated.)\n///  @returns True if the operation completed successfully.\nbool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, \n\t\t\t\t\t\t\t  const int borderSize, const int walkableHeight,\n\t\t\t\t\t\t\t  rcHeightfieldLayerSet& lset);\n\n/// Builds a contour set from the region outlines in the provided compact heightfield.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\tThe build context to use during the operation.\n///  @param[in]\t\tchf\t\t\tA fully built compact heightfield.\n///  @param[in]\t\tmaxError\tThe maximum distance a simplfied contour's border edges should deviate \n///  \t\t\t\t\t\t\tthe original raw contour. [Limit: >=0] [Units: wu]\n///  @param[in]\t\tmaxEdgeLen\tThe maximum allowed length for contour edges along the border of the mesh. \n///  \t\t\t\t\t\t\t[Limit: >=0] [Units: vx]\n///  @param[out]\tcset\t\tThe resulting contour set. (Must be pre-allocated.)\n///  @param[in]\t\tbuildFlags\tThe build flags. (See: #rcBuildContoursFlags)\n///  @returns True if the operation completed successfully.\nbool rcBuildContours(rcContext* ctx, rcCompactHeightfield& chf,\n\t\t\t\t\t const float maxError, const int maxEdgeLen,\n\t\t\t\t\t rcContourSet& cset, const int buildFlags = RC_CONTOUR_TESS_WALL_EDGES);\n\n/// Builds a polygon mesh from the provided contours.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in]\t\tcset\tA fully built contour set.\n///  @param[in]\t\tnvp\t\tThe maximum number of vertices allowed for polygons generated during the \n///  \t\t\t\t\t\tcontour to polygon conversion process. [Limit: >= 3] \n///  @param[out]\tmesh\tThe resulting polygon mesh. (Must be re-allocated.)\n///  @returns True if the operation completed successfully.\nbool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMesh& mesh);\n\n/// Merges multiple polygon meshes into a single mesh.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in]\t\tmeshes\tAn array of polygon meshes to merge. [Size: @p nmeshes]\n///  @param[in]\t\tnmeshes\tThe number of polygon meshes in the meshes array.\n///  @param[in]\t\tmesh\tThe resulting polygon mesh. (Must be pre-allocated.)\n///  @returns True if the operation completed successfully.\nbool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, rcPolyMesh& mesh);\n\n/// Builds a detail mesh from the provided polygon mesh.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\t\t\tThe build context to use during the operation.\n///  @param[in]\t\tmesh\t\t\tA fully built polygon mesh.\n///  @param[in]\t\tchf\t\t\t\tThe compact heightfield used to build the polygon mesh.\n///  @param[in]\t\tsampleDist\t\tSets the distance to use when samping the heightfield. [Limit: >=0] [Units: wu]\n///  @param[in]\t\tsampleMaxError\tThe maximum distance the detail mesh surface should deviate from \n///  \t\t\t\t\t\t\t\theightfield data. [Limit: >=0] [Units: wu]\n///  @param[out]\tdmesh\t\t\tThe resulting detail mesh.  (Must be pre-allocated.)\n///  @returns True if the operation completed successfully.\nbool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompactHeightfield& chf,\n\t\t\t\t\t\t   const float sampleDist, const float sampleMaxError,\n\t\t\t\t\t\t   rcPolyMeshDetail& dmesh);\n\n/// Copies the poly mesh data from src to dst.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in]\t\tsrc\t\tThe source mesh to copy from.\n///  @param[out]\tdst\t\tThe resulting detail mesh. (Must be pre-allocated, must be empty mesh.)\n///  @returns True if the operation completed successfully.\nbool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst);\n\n/// Merges multiple detail meshes into a single detail mesh.\n///  @ingroup recast\n///  @param[in,out]\tctx\t\tThe build context to use during the operation.\n///  @param[in]\t\tmeshes\tAn array of detail meshes to merge. [Size: @p nmeshes]\n///  @param[in]\t\tnmeshes\tThe number of detail meshes in the meshes array.\n///  @param[out]\tmesh\tThe resulting detail mesh. (Must be pre-allocated.)\n///  @returns True if the operation completed successfully.\nbool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int nmeshes, rcPolyMeshDetail& mesh);\n\n/// @}\n\n#endif // RECAST_H\n\n///////////////////////////////////////////////////////////////////////////\n\n// Due to the large amount of detail documentation for this file, \n// the content normally located at the end of the header file has been separated\n// out to a file in /Docs/Extern.\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Include/RecastAlloc.h",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#ifndef RECASTALLOC_H\n#define RECASTALLOC_H\n\n#include <stddef.h>\n#include <stdint.h>\n\n#include <RecastAssert.h>\n\n/// Provides hint values to the memory allocator on how long the\n/// memory is expected to be used.\nenum rcAllocHint\n{\n\tRC_ALLOC_PERM,\t\t///< Memory will persist after a function call.\n\tRC_ALLOC_TEMP\t\t///< Memory used temporarily within a function.\n};\n\n/// A memory allocation function.\n//  @param[in]\t\tsize\t\t\tThe size, in bytes of memory, to allocate.\n//  @param[in]\t\trcAllocHint\tA hint to the allocator on how long the memory is expected to be in use.\n//  @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.\n///  @see rcAllocSetCustom\ntypedef void* (rcAllocFunc)(size_t size, rcAllocHint hint);\n\n/// A memory deallocation function.\n///  @param[in]\t\tptr\t\tA pointer to a memory block previously allocated using #rcAllocFunc.\n/// @see rcAllocSetCustom\ntypedef void (rcFreeFunc)(void* ptr);\n\n/// Sets the base custom allocation functions to be used by Recast.\n///  @param[in]\t\tallocFunc\tThe memory allocation function to be used by #rcAlloc\n///  @param[in]\t\tfreeFunc\tThe memory de-allocation function to be used by #rcFree\nvoid rcAllocSetCustom(rcAllocFunc *allocFunc, rcFreeFunc *freeFunc);\n\n/// Allocates a memory block.\n///  @param[in]\t\tsize\tThe size, in bytes of memory, to allocate.\n///  @param[in]\t\thint\tA hint to the allocator on how long the memory is expected to be in use.\n///  @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.\n/// @see rcFree\nvoid* rcAlloc(size_t size, rcAllocHint hint);\n\n/// Deallocates a memory block.\n///  @param[in]\t\tptr\t\tA pointer to a memory block previously allocated using #rcAlloc.\n/// @see rcAlloc\nvoid rcFree(void* ptr);\n\n/// An implementation of operator new usable for placement new. The default one is part of STL (which we don't use).\n/// rcNewTag is a dummy type used to differentiate our operator from the STL one, in case users import both Recast\n/// and STL.\nstruct rcNewTag {};\ninline void* operator new(size_t, const rcNewTag&, void* p) { return p; }\ninline void operator delete(void*, const rcNewTag&, void*) {}\n\n/// Signed to avoid warnnings when comparing to int loop indexes, and common error with comparing to zero.\n/// MSVC2010 has a bug where ssize_t is unsigned (!!!).\ntypedef intptr_t rcSizeType;\n#define RC_SIZE_MAX INTPTR_MAX\n\n/// Macros to hint to the compiler about the likeliest branch. Please add a benchmark that demonstrates a performance\n/// improvement before introducing use cases.\n#if defined(__GNUC__) || defined(__clang__)\n#define rcLikely(x) __builtin_expect((x), true)\n#define rcUnlikely(x) __builtin_expect((x), false)\n#else\n#define rcLikely(x) (x)\n#define rcUnlikely(x) (x)\n#endif\n\n/// Variable-sized storage type. Mimics the interface of std::vector<T> with some notable differences:\n///  * Uses rcAlloc()/rcFree() to handle storage.\n///  * No support for a custom allocator.\n///  * Uses signed size instead of size_t to avoid warnings in for loops: \"for (int i = 0; i < foo.size(); i++)\"\n///  * Omits methods of limited utility: insert/erase, (bad performance), at (we don't use exceptions), operator=.\n///  * assign() and the pre-sizing constructor follow C++11 semantics -- they don't construct a temporary if no value is provided.\n///  * push_back() and resize() support adding values from the current vector. Range-based constructors and assign(begin, end) do not.\n///  * No specialization for bool.\ntemplate <typename T, rcAllocHint H>\nclass rcVectorBase {\n\trcSizeType m_size;\n\trcSizeType m_cap;\n\tT* m_data;\n\t// Constructs a T at the give address with either the copy constructor or the default.\n\tstatic void construct(T* p, const T& v) { ::new(rcNewTag(), (void*)p) T(v); }\n\tstatic void construct(T* p) { ::new(rcNewTag(), (void*)p) T; }\n\tstatic void construct_range(T* begin, T* end);\n\tstatic void construct_range(T* begin, T* end, const T& value);\n\tstatic void copy_range(T* dst, const T* begin, const T* end);\n\tvoid destroy_range(rcSizeType begin, rcSizeType end);\n\t// Creates an array of the given size, copies all of this vector's data into it, and returns it.\n\tT* allocate_and_copy(rcSizeType size);\n\tvoid resize_impl(rcSizeType size, const T* value);\n public:\n\ttypedef rcSizeType size_type;\n\ttypedef T value_type;\n\n\trcVectorBase() : m_size(0), m_cap(0), m_data(0) {};\n\trcVectorBase(const rcVectorBase<T, H>& other) : m_size(0), m_cap(0), m_data(0) { assign(other.begin(), other.end()); }\n\texplicit rcVectorBase(rcSizeType count) : m_size(0), m_cap(0), m_data(0) { resize(count); }\n\trcVectorBase(rcSizeType count, const T& value) : m_size(0), m_cap(0), m_data(0) { resize(count, value); }\n\trcVectorBase(const T* begin, const T* end) : m_size(0), m_cap(0), m_data(0) { assign(begin, end); }\n\t~rcVectorBase() { destroy_range(0, m_size); rcFree(m_data); }\n\n\t// Unlike in std::vector, we return a bool to indicate whether the alloc was successful.\n\tbool reserve(rcSizeType size);\n\n\tvoid assign(rcSizeType count, const T& value) { clear(); resize(count, value); }\n\tvoid assign(const T* begin, const T* end);\n\n\tvoid resize(rcSizeType size) { resize_impl(size, NULL); }\n\tvoid resize(rcSizeType size, const T& value) { resize_impl(size, &value); }\n\t// Not implemented as resize(0) because resize requires T to be default-constructible.\n\tvoid clear() { destroy_range(0, m_size); m_size = 0; }\n\n\tvoid push_back(const T& value);\n\tvoid pop_back() { rcAssert(m_size > 0); back().~T(); m_size--; }\n\n\trcSizeType size() const { return m_size; }\n\trcSizeType capacity() const { return m_cap; }\n\tbool empty() const { return size() == 0; }\n\n\tconst T& operator[](rcSizeType i) const { rcAssert(i >= 0 && i < m_size); return m_data[i]; }\n\tT& operator[](rcSizeType i) { rcAssert(i >= 0 && i < m_size); return m_data[i]; }\n\n\tconst T& front() const { rcAssert(m_size); return m_data[0]; }\n\tT& front() { rcAssert(m_size); return m_data[0]; }\n\tconst T& back() const { rcAssert(m_size); return m_data[m_size - 1]; };\n\tT& back() { rcAssert(m_size); return m_data[m_size - 1]; };\n\tconst T* data() const { return m_data; }\n\tT* data() { return m_data; }\n\n\tT* begin() { return m_data; }\n\tT* end() { return m_data + m_size; }\n\tconst T* begin() const { return m_data; }\n\tconst T* end() const { return m_data + m_size; }\n\n\tvoid swap(rcVectorBase<T, H>& other);\n\n\t// Explicitly deleted.\n\trcVectorBase& operator=(const rcVectorBase<T, H>& other);\n};\n\ntemplate<typename T, rcAllocHint H>\nbool rcVectorBase<T, H>::reserve(rcSizeType count) {\n\tif (count <= m_cap) {\n\t\treturn true;\n\t}\n\tT* new_data = allocate_and_copy(count);\n\tif (!new_data) {\n\t  return false;\n\t}\n\tdestroy_range(0, m_size);\n\trcFree(m_data);\n\tm_data = new_data;\n\tm_cap = count;\n\treturn true;\n}\ntemplate <typename T, rcAllocHint H>\nT* rcVectorBase<T, H>::allocate_and_copy(rcSizeType size) {\n\trcAssert(RC_SIZE_MAX / static_cast<rcSizeType>(sizeof(T)) >= size);\n\tT* new_data = static_cast<T*>(rcAlloc(sizeof(T) * size, H));\n\tif (new_data) {\n\t\tcopy_range(new_data, m_data, m_data + m_size);\n\t}\n\treturn new_data;\n}\ntemplate <typename T, rcAllocHint H>\nvoid rcVectorBase<T, H>::assign(const T* begin, const T* end) {\n\tclear();\n\treserve(end - begin);\n\tm_size = end - begin;\n\tcopy_range(m_data, begin, end);\n}\ntemplate <typename T, rcAllocHint H>\nvoid rcVectorBase<T, H>::push_back(const T& value) {\n\t// rcLikely increases performance by ~50% on BM_rcVector_PushPreallocated,\n\t// and by ~2-5% on BM_rcVector_Push.\n\tif (rcLikely(m_size < m_cap)) {\n\t\tconstruct(m_data + m_size++, value);\n\t\treturn;\n\t}\n\n\trcAssert(RC_SIZE_MAX / 2 >= m_size);\n\trcSizeType new_cap = m_size ? 2*m_size : 1;\n\tT* data = allocate_and_copy(new_cap);\n\t// construct between allocate and destroy+free in case value is\n\t// in this vector.\n\tconstruct(data + m_size, value);\n\tdestroy_range(0, m_size);\n\tm_size++;\n\tm_cap = new_cap;\n\trcFree(m_data);\n\tm_data = data;\n}\ntemplate <typename T, rcAllocHint H>\nvoid rcVectorBase<T, H>::resize_impl(rcSizeType size, const T* value) {\n\tif (size < m_size) {\n\t\tdestroy_range(size, m_size);\n\t\tm_size = size;\n\t} else if (size > m_size) {\n\t\tT* new_data = allocate_and_copy(size);\n\t\t// We defer deconstructing/freeing old data until after constructing\n\t\t// new elements in case \"value\" is there.\n\t\tif (value) {\n\t\t\tconstruct_range(new_data + m_size, new_data + size, *value);\n\t\t} else {\n\t\t\tconstruct_range(new_data + m_size, new_data + size);\n\t\t}\n\t\tdestroy_range(0, m_size);\n\t\trcFree(m_data);\n\t\tm_data = new_data;\n\t\tm_cap = size;\n\t\tm_size = size;\n\t}\n}\ntemplate <typename T, rcAllocHint H>\nvoid rcVectorBase<T, H>::swap(rcVectorBase<T, H>& other) {\n\t// TODO: Reorganize headers so we can use rcSwap here.\n\trcSizeType tmp_cap = other.m_cap;\n\trcSizeType tmp_size = other.m_size;\n\tT* tmp_data = other.m_data;\n\n\tother.m_cap = m_cap;\n\tother.m_size = m_size;\n\tother.m_data = m_data;\n\n\tm_cap = tmp_cap;\n\tm_size = tmp_size;\n\tm_data = tmp_data;\n}\n// static\ntemplate <typename T, rcAllocHint H>\nvoid rcVectorBase<T, H>::construct_range(T* begin, T* end) {\n\tfor (T* p = begin; p < end; p++) {\n\t\tconstruct(p);\n\t}\n}\n// static\ntemplate <typename T, rcAllocHint H>\nvoid rcVectorBase<T, H>::construct_range(T* begin, T* end, const T& value) {\n\tfor (T* p = begin; p < end; p++) {\n\t\tconstruct(p, value);\n\t}\n}\n// static\ntemplate <typename T, rcAllocHint H>\nvoid rcVectorBase<T, H>::copy_range(T* dst, const T* begin, const T* end) {\n\tfor (rcSizeType i = 0 ; i < end - begin; i++) {\n\t\tconstruct(dst + i, begin[i]);\n\t}\n}\ntemplate <typename T, rcAllocHint H>\nvoid rcVectorBase<T, H>::destroy_range(rcSizeType begin, rcSizeType end) {\n\tfor (rcSizeType i = begin; i < end; i++) {\n\t\tm_data[i].~T();\n\t}\n}\n\ntemplate <typename T>\nclass rcTempVector : public rcVectorBase<T, RC_ALLOC_TEMP> {\n\ttypedef rcVectorBase<T, RC_ALLOC_TEMP> Base;\npublic:\n\trcTempVector() : Base() {}\n\texplicit rcTempVector(rcSizeType size) : Base(size) {}\n\trcTempVector(rcSizeType size, const T& value) : Base(size, value) {}\n\trcTempVector(const rcTempVector<T>& other) : Base(other) {}\n\trcTempVector(const T* begin, const T* end) : Base(begin, end) {}\n};\ntemplate <typename T>\nclass rcPermVector : public rcVectorBase<T, RC_ALLOC_PERM> {\n\ttypedef rcVectorBase<T, RC_ALLOC_PERM> Base;\npublic:\n\trcPermVector() : Base() {}\n\texplicit rcPermVector(rcSizeType size) : Base(size) {}\n\trcPermVector(rcSizeType size, const T& value) : Base(size, value) {}\n\trcPermVector(const rcPermVector<T>& other) : Base(other) {}\n\trcPermVector(const T* begin, const T* end) : Base(begin, end) {}\n};\n\n\n/// Legacy class. Prefer rcVector<int>.\nclass rcIntArray\n{\n\trcTempVector<int> m_impl;\npublic:\n\trcIntArray() {}\n\trcIntArray(int n) : m_impl(n, 0) {}\n\tvoid push(int item) { m_impl.push_back(item); }\n\tvoid resize(int size) { m_impl.resize(size); }\n\tint pop()\n\t{\n\t\tint v = m_impl.back();\n\t\tm_impl.pop_back();\n\t\treturn v;\n\t}\n\tint size() const { return static_cast<int>(m_impl.size()); }\n\tint& operator[](int index) { return m_impl[index]; }\n\tint operator[](int index) const { return m_impl[index]; }\n};\n\n/// A simple helper class used to delete an array when it goes out of scope.\n/// @note This class is rarely if ever used by the end user.\ntemplate<class T> class rcScopedDelete\n{\n\tT* ptr;\npublic:\n\n\t/// Constructs an instance with a null pointer.\n\tinline rcScopedDelete() : ptr(0) {}\n\n\t/// Constructs an instance with the specified pointer.\n\t///  @param[in]\t\tp\tAn pointer to an allocated array.\n\tinline rcScopedDelete(T* p) : ptr(p) {}\n\tinline ~rcScopedDelete() { rcFree(ptr); }\n\n\t/// The root array pointer.\n\t///  @return The root array pointer.\n\tinline operator T*() { return ptr; }\n\t\nprivate:\n\t// Explicitly disabled copy constructor and copy assignment operator.\n\trcScopedDelete(const rcScopedDelete&);\n\trcScopedDelete& operator=(const rcScopedDelete&);\n};\n\n#endif\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Include/RecastAssert.h",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#ifndef RECASTASSERT_H\n#define RECASTASSERT_H\n\n// Note: This header file's only purpose is to include define assert.\n// Feel free to change the file and include your own implementation instead.\n\n#ifdef NDEBUG\n\n// From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/\n#\tdefine rcAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)\n\n#else\n\n/// An assertion failure function.\n//  @param[in]\t\texpression  asserted expression.\n//  @param[in]\t\tfile  Filename of the failed assertion.\n//  @param[in]\t\tline  Line number of the failed assertion.\n///  @see rcAssertFailSetCustom\ntypedef void (rcAssertFailFunc)(const char* expression, const char* file, int line);\n\n/// Sets the base custom assertion failure function to be used by Recast.\n///  @param[in]\t\tassertFailFunc\tThe function to be used in case of failure of #dtAssert\nvoid rcAssertFailSetCustom(rcAssertFailFunc *assertFailFunc);\n\n/// Gets the base custom assertion failure function to be used by Recast.\nrcAssertFailFunc* rcAssertFailGetCustom();\n\n#\tinclude <assert.h> \n#\tdefine rcAssert(expression) \\\n\t\t{ \\\n\t\t\trcAssertFailFunc* failFunc = rcAssertFailGetCustom(); \\\n\t\t\tif(failFunc == NULL) { assert(expression); } \\\n\t\t\telse if(!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \\\n\t\t}\n\n#endif\n\n#endif // RECASTASSERT_H\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/Recast.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#include <float.h>\n#define _USE_MATH_DEFINES\n#include <math.h>\n#include <string.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include \"Recast.h\"\n#include \"RecastAlloc.h\"\n#include \"RecastAssert.h\"\n\nnamespace\n{\n/// Allocates and constructs an object of the given type, returning a pointer.\n/// TODO: Support constructor args.\n/// @param[in]\t\thint\tHint to the allocator.\ntemplate <typename T>\nT* rcNew(rcAllocHint hint) {\n\tT* ptr = (T*)rcAlloc(sizeof(T), hint);\n\t::new(rcNewTag(), (void*)ptr) T();\n\treturn ptr;\n}\n\n/// Destroys and frees an object allocated with rcNew.\n/// @param[in]     ptr    The object pointer to delete.\ntemplate <typename T>\nvoid rcDelete(T* ptr) {\n\tif (ptr) {\n\t\tptr->~T();\n\t\trcFree((void*)ptr);\n\t}\n}\n}  // namespace\n\n\nfloat rcSqrt(float x)\n{\n\treturn sqrtf(x);\n}\n\n/// @class rcContext\n/// @par\n///\n/// This class does not provide logging or timer functionality on its \n/// own.  Both must be provided by a concrete implementation \n/// by overriding the protected member functions.  Also, this class does not \n/// provide an interface for extracting log messages. (Only adding them.) \n/// So concrete implementations must provide one.\n///\n/// If no logging or timers are required, just pass an instance of this \n/// class through the Recast build process.\n///\n\n/// @par\n///\n/// Example:\n/// @code\n/// // Where ctx is an instance of rcContext and filepath is a char array.\n/// ctx->log(RC_LOG_ERROR, \"buildTiledNavigation: Could not load '%s'\", filepath);\n/// @endcode\nvoid rcContext::log(const rcLogCategory category, const char* format, ...)\n{\n\tif (!m_logEnabled)\n\t\treturn;\n\tstatic const int MSG_SIZE = 512;\n\tchar msg[MSG_SIZE];\n\tva_list ap;\n\tva_start(ap, format);\n\tint len = vsnprintf(msg, MSG_SIZE, format, ap);\n\tif (len >= MSG_SIZE)\n\t{\n\t\tlen = MSG_SIZE-1;\n\t\tmsg[MSG_SIZE-1] = '\\0';\n\t}\n\tva_end(ap);\n\tdoLog(category, msg, len);\n}\n\nrcHeightfield* rcAllocHeightfield()\n{\n\treturn rcNew<rcHeightfield>(RC_ALLOC_PERM);\n}\nrcHeightfield::rcHeightfield()\n\t: width()\n\t, height()\n\t, bmin()\n\t, bmax()\n\t, cs()\n\t, ch()\n\t, spans()\n\t, pools()\n\t, freelist()\n{\n}\n\nrcHeightfield::~rcHeightfield()\n{\n\t// Delete span array.\n\trcFree(spans);\n\t// Delete span pools.\n\twhile (pools)\n\t{\n\t\trcSpanPool* next = pools->next;\n\t\trcFree(pools);\n\t\tpools = next;\n\t}\n}\n\nvoid rcFreeHeightField(rcHeightfield* hf)\n{\n\trcDelete(hf);\n}\n\nrcCompactHeightfield* rcAllocCompactHeightfield()\n{\n\treturn rcNew<rcCompactHeightfield>(RC_ALLOC_PERM);\n}\n\nvoid rcFreeCompactHeightfield(rcCompactHeightfield* chf)\n{\n\trcDelete(chf);\n}\n\nrcCompactHeightfield::rcCompactHeightfield()\n\t: width(),\n\theight(),\n\tspanCount(),\n\twalkableHeight(),\n\twalkableClimb(),\n\tborderSize(),\n\tmaxDistance(),\n\tmaxRegions(),\n\tbmin(),\n\tbmax(),\n\tcs(),\n\tch(),\n\tcells(),\n\tspans(),\n\tdist(),\n\tareas()\n{\n}\nrcCompactHeightfield::~rcCompactHeightfield()\n{\n\trcFree(cells);\n\trcFree(spans);\n\trcFree(dist);\n\trcFree(areas);\n}\n\nrcHeightfieldLayerSet* rcAllocHeightfieldLayerSet()\n{\n\treturn rcNew<rcHeightfieldLayerSet>(RC_ALLOC_PERM);\n}\nvoid rcFreeHeightfieldLayerSet(rcHeightfieldLayerSet* lset)\n{\n\trcDelete(lset);\n}\n\nrcHeightfieldLayerSet::rcHeightfieldLayerSet()\n\t: layers(),\tnlayers() {}\nrcHeightfieldLayerSet::~rcHeightfieldLayerSet()\n{\n\tfor (int i = 0; i < nlayers; ++i)\n\t{\n\t\trcFree(layers[i].heights);\n\t\trcFree(layers[i].areas);\n\t\trcFree(layers[i].cons);\n\t}\n\trcFree(layers);\n}\n\n\nrcContourSet* rcAllocContourSet()\n{\n\treturn rcNew<rcContourSet>(RC_ALLOC_PERM);\n}\nvoid rcFreeContourSet(rcContourSet* cset)\n{\n\trcDelete(cset);\n}\n\nrcContourSet::rcContourSet()\n\t: conts(),\n\tnconts(),\n\tbmin(),\n\tbmax(),\n\tcs(),\n\tch(),\n\twidth(),\n\theight(),\n\tborderSize(),\n\tmaxError() {}\nrcContourSet::~rcContourSet()\n{\n\tfor (int i = 0; i < nconts; ++i)\n\t{\n\t\trcFree(conts[i].verts);\n\t\trcFree(conts[i].rverts);\n\t}\n\trcFree(conts);\n}\n\n\nrcPolyMesh* rcAllocPolyMesh()\n{\n\treturn rcNew<rcPolyMesh>(RC_ALLOC_PERM);\n}\nvoid rcFreePolyMesh(rcPolyMesh* pmesh)\n{\n\trcDelete(pmesh);\n}\n\nrcPolyMesh::rcPolyMesh()\n\t: verts(),\n\tpolys(),\n\tregs(),\n\tflags(),\n\tareas(),\n\tnverts(),\n\tnpolys(),\n\tmaxpolys(),\n\tnvp(),\n\tbmin(),\n\tbmax(),\n\tcs(),\n\tch(),\n\tborderSize(),\n\tmaxEdgeError() {}\n\nrcPolyMesh::~rcPolyMesh()\n{\n\trcFree(verts);\n\trcFree(polys);\n\trcFree(regs);\n\trcFree(flags);\n\trcFree(areas);\n}\n\nrcPolyMeshDetail* rcAllocPolyMeshDetail()\n{\n\trcPolyMeshDetail* dmesh = (rcPolyMeshDetail*)rcAlloc(sizeof(rcPolyMeshDetail), RC_ALLOC_PERM);\n\tmemset(dmesh, 0, sizeof(rcPolyMeshDetail));\n\treturn dmesh;\n}\n\nvoid rcFreePolyMeshDetail(rcPolyMeshDetail* dmesh)\n{\n\tif (!dmesh) return;\n\trcFree(dmesh->meshes);\n\trcFree(dmesh->verts);\n\trcFree(dmesh->tris);\n\trcFree(dmesh);\n}\n\nvoid rcCalcBounds(const float* verts, int nv, float* bmin, float* bmax)\n{\n\t// Calculate bounding box.\n\trcVcopy(bmin, verts);\n\trcVcopy(bmax, verts);\n\tfor (int i = 1; i < nv; ++i)\n\t{\n\t\tconst float* v = &verts[i*3];\n\t\trcVmin(bmin, v);\n\t\trcVmax(bmax, v);\n\t}\n}\n\nvoid rcCalcGridSize(const float* bmin, const float* bmax, float cs, int* w, int* h)\n{\n\t*w = (int)((bmax[0] - bmin[0])/cs+0.5f);\n\t*h = (int)((bmax[2] - bmin[2])/cs+0.5f);\n}\n\n/// @par\n///\n/// See the #rcConfig documentation for more information on the configuration parameters.\n/// \n/// @see rcAllocHeightfield, rcHeightfield \nbool rcCreateHeightfield(rcContext* ctx, rcHeightfield& hf, int width, int height,\n\t\t\t\t\t\t const float* bmin, const float* bmax,\n\t\t\t\t\t\t float cs, float ch)\n{\n\trcIgnoreUnused(ctx);\n\t\n\thf.width = width;\n\thf.height = height;\n\trcVcopy(hf.bmin, bmin);\n\trcVcopy(hf.bmax, bmax);\n\thf.cs = cs;\n\thf.ch = ch;\n\thf.spans = (rcSpan**)rcAlloc(sizeof(rcSpan*)*hf.width*hf.height, RC_ALLOC_PERM);\n\tif (!hf.spans)\n\t\treturn false;\n\tmemset(hf.spans, 0, sizeof(rcSpan*)*hf.width*hf.height);\n\treturn true;\n}\n\nstatic void calcTriNormal(const float* v0, const float* v1, const float* v2, float* norm)\n{\n\tfloat e0[3], e1[3];\n\trcVsub(e0, v1, v0);\n\trcVsub(e1, v2, v0);\n\trcVcross(norm, e0, e1);\n\trcVnormalize(norm);\n}\n\n/// @par\n///\n/// Only sets the area id's for the walkable triangles.  Does not alter the\n/// area id's for unwalkable triangles.\n/// \n/// See the #rcConfig documentation for more information on the configuration parameters.\n/// \n/// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles\nvoid rcMarkWalkableTriangles(rcContext* ctx, const float walkableSlopeAngle,\n\t\t\t\t\t\t\t const float* verts, int nv,\n\t\t\t\t\t\t\t const int* tris, int nt,\n\t\t\t\t\t\t\t unsigned char* areas)\n{\n\trcIgnoreUnused(ctx);\n\trcIgnoreUnused(nv);\n\t\n\tconst float walkableThr = cosf(walkableSlopeAngle/180.0f*RC_PI);\n\n\tfloat norm[3];\n\t\n\tfor (int i = 0; i < nt; ++i)\n\t{\n\t\tconst int* tri = &tris[i*3];\n\t\tcalcTriNormal(&verts[tri[0]*3], &verts[tri[1]*3], &verts[tri[2]*3], norm);\n\t\t// Check if the face is walkable.\n\t\tif (norm[1] > walkableThr)\n\t\t\tareas[i] = RC_WALKABLE_AREA;\n\t}\n}\n\n/// @par\n///\n/// Only sets the area id's for the unwalkable triangles.  Does not alter the\n/// area id's for walkable triangles.\n/// \n/// See the #rcConfig documentation for more information on the configuration parameters.\n/// \n/// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles\nvoid rcClearUnwalkableTriangles(rcContext* ctx, const float walkableSlopeAngle,\n\t\t\t\t\t\t\t\tconst float* verts, int /*nv*/,\n\t\t\t\t\t\t\t\tconst int* tris, int nt,\n\t\t\t\t\t\t\t\tunsigned char* areas)\n{\n\trcIgnoreUnused(ctx);\n\t\n\tconst float walkableThr = cosf(walkableSlopeAngle/180.0f*RC_PI);\n\t\n\tfloat norm[3];\n\t\n\tfor (int i = 0; i < nt; ++i)\n\t{\n\t\tconst int* tri = &tris[i*3];\n\t\tcalcTriNormal(&verts[tri[0]*3], &verts[tri[1]*3], &verts[tri[2]*3], norm);\n\t\t// Check if the face is walkable.\n\t\tif (norm[1] <= walkableThr)\n\t\t\tareas[i] = RC_NULL_AREA;\n\t}\n}\n\nint rcGetHeightFieldSpanCount(rcContext* ctx, rcHeightfield& hf)\n{\n\trcIgnoreUnused(ctx);\n\t\n\tconst int w = hf.width;\n\tconst int h = hf.height;\n\tint spanCount = 0;\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tfor (rcSpan* s = hf.spans[x + y*w]; s; s = s->next)\n\t\t\t{\n\t\t\t\tif (s->area != RC_NULL_AREA)\n\t\t\t\t\tspanCount++;\n\t\t\t}\n\t\t}\n\t}\n\treturn spanCount;\n}\n\n/// @par\n///\n/// This is just the beginning of the process of fully building a compact heightfield.\n/// Various filters may be applied, then the distance field and regions built.\n/// E.g: #rcBuildDistanceField and #rcBuildRegions\n///\n/// See the #rcConfig documentation for more information on the configuration parameters.\n///\n/// @see rcAllocCompactHeightfield, rcHeightfield, rcCompactHeightfield, rcConfig\nbool rcBuildCompactHeightfield(rcContext* ctx, const int walkableHeight, const int walkableClimb,\n\t\t\t\t\t\t\t   rcHeightfield& hf, rcCompactHeightfield& chf)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_BUILD_COMPACTHEIGHTFIELD);\n\t\n\tconst int w = hf.width;\n\tconst int h = hf.height;\n\tconst int spanCount = rcGetHeightFieldSpanCount(ctx, hf);\n\n\t// Fill in header.\n\tchf.width = w;\n\tchf.height = h;\n\tchf.spanCount = spanCount;\n\tchf.walkableHeight = walkableHeight;\n\tchf.walkableClimb = walkableClimb;\n\tchf.maxRegions = 0;\n\trcVcopy(chf.bmin, hf.bmin);\n\trcVcopy(chf.bmax, hf.bmax);\n\tchf.bmax[1] += walkableHeight*hf.ch;\n\tchf.cs = hf.cs;\n\tchf.ch = hf.ch;\n\tchf.cells = (rcCompactCell*)rcAlloc(sizeof(rcCompactCell)*w*h, RC_ALLOC_PERM);\n\tif (!chf.cells)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildCompactHeightfield: Out of memory 'chf.cells' (%d)\", w*h);\n\t\treturn false;\n\t}\n\tmemset(chf.cells, 0, sizeof(rcCompactCell)*w*h);\n\tchf.spans = (rcCompactSpan*)rcAlloc(sizeof(rcCompactSpan)*spanCount, RC_ALLOC_PERM);\n\tif (!chf.spans)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildCompactHeightfield: Out of memory 'chf.spans' (%d)\", spanCount);\n\t\treturn false;\n\t}\n\tmemset(chf.spans, 0, sizeof(rcCompactSpan)*spanCount);\n\tchf.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*spanCount, RC_ALLOC_PERM);\n\tif (!chf.areas)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildCompactHeightfield: Out of memory 'chf.areas' (%d)\", spanCount);\n\t\treturn false;\n\t}\n\tmemset(chf.areas, RC_NULL_AREA, sizeof(unsigned char)*spanCount);\n\t\n\tconst int MAX_HEIGHT = 0xffff;\n\t\n\t// Fill in cells and spans.\n\tint idx = 0;\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcSpan* s = hf.spans[x + y*w];\n\t\t\t// If there are no spans at this cell, just leave the data to index=0, count=0.\n\t\t\tif (!s) continue;\n\t\t\trcCompactCell& c = chf.cells[x+y*w];\n\t\t\tc.index = idx;\n\t\t\tc.count = 0;\n\t\t\twhile (s)\n\t\t\t{\n\t\t\t\tif (s->area != RC_NULL_AREA)\n\t\t\t\t{\n\t\t\t\t\tconst int bot = (int)s->smax;\n\t\t\t\t\tconst int top = s->next ? (int)s->next->smin : MAX_HEIGHT;\n\t\t\t\t\tchf.spans[idx].y = (unsigned short)rcClamp(bot, 0, 0xffff);\n\t\t\t\t\tchf.spans[idx].h = (unsigned char)rcClamp(top - bot, 0, 0xff);\n\t\t\t\t\tchf.areas[idx] = s->area;\n\t\t\t\t\tidx++;\n\t\t\t\t\tc.count++;\n\t\t\t\t}\n\t\t\t\ts = s->next;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Find neighbour connections.\n\tconst int MAX_LAYERS = RC_NOT_CONNECTED-1;\n\tint tooHighNeighbour = 0;\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\trcCompactSpan& s = chf.spans[i];\n\t\t\t\t\n\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t{\n\t\t\t\t\trcSetCon(s, dir, RC_NOT_CONNECTED);\n\t\t\t\t\tconst int nx = x + rcGetDirOffsetX(dir);\n\t\t\t\t\tconst int ny = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t// First check that the neighbour cell is in bounds.\n\t\t\t\t\tif (nx < 0 || ny < 0 || nx >= w || ny >= h)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\n\t\t\t\t\t// Iterate over all neighbour spans and check if any of the is\n\t\t\t\t\t// accessible from current cell.\n\t\t\t\t\tconst rcCompactCell& nc = chf.cells[nx+ny*w];\n\t\t\t\t\tfor (int k = (int)nc.index, nk = (int)(nc.index+nc.count); k < nk; ++k)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst rcCompactSpan& ns = chf.spans[k];\n\t\t\t\t\t\tconst int bot = rcMax(s.y, ns.y);\n\t\t\t\t\t\tconst int top = rcMin(s.y+s.h, ns.y+ns.h);\n\n\t\t\t\t\t\t// Check that the gap between the spans is walkable,\n\t\t\t\t\t\t// and that the climb height between the gaps is not too high.\n\t\t\t\t\t\tif ((top - bot) >= walkableHeight && rcAbs((int)ns.y - (int)s.y) <= walkableClimb)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Mark direction as walkable.\n\t\t\t\t\t\t\tconst int lidx = k - (int)nc.index;\n\t\t\t\t\t\t\tif (lidx < 0 || lidx > MAX_LAYERS)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttooHighNeighbour = rcMax(tooHighNeighbour, lidx);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trcSetCon(s, dir, lidx);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif (tooHighNeighbour > MAX_LAYERS)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildCompactHeightfield: Heightfield has too many layers %d (max: %d)\",\n\t\t\t\t tooHighNeighbour, MAX_LAYERS);\n\t}\n\t\n\treturn true;\n}\n\n/*\nstatic int getHeightfieldMemoryUsage(const rcHeightfield& hf)\n{\n\tint size = 0;\n\tsize += sizeof(hf);\n\tsize += hf.width * hf.height * sizeof(rcSpan*);\n\t\n\trcSpanPool* pool = hf.pools;\n\twhile (pool)\n\t{\n\t\tsize += (sizeof(rcSpanPool) - sizeof(rcSpan)) + sizeof(rcSpan)*RC_SPANS_PER_POOL;\n\t\tpool = pool->next;\n\t}\n\treturn size;\n}\n\nstatic int getCompactHeightFieldMemoryusage(const rcCompactHeightfield& chf)\n{\n\tint size = 0;\n\tsize += sizeof(rcCompactHeightfield);\n\tsize += sizeof(rcCompactSpan) * chf.spanCount;\n\tsize += sizeof(rcCompactCell) * chf.width * chf.height;\n\treturn size;\n}\n*/\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastAlloc.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#include <stdlib.h>\n#include <string.h>\n#include \"RecastAlloc.h\"\n#include \"RecastAssert.h\"\n\nstatic void *rcAllocDefault(size_t size, rcAllocHint)\n{\n\treturn malloc(size);\n}\n\nstatic void rcFreeDefault(void *ptr)\n{\n\tfree(ptr);\n}\n\nstatic rcAllocFunc* sRecastAllocFunc = rcAllocDefault;\nstatic rcFreeFunc* sRecastFreeFunc = rcFreeDefault;\n\n/// @see rcAlloc, rcFree\nvoid rcAllocSetCustom(rcAllocFunc *allocFunc, rcFreeFunc *freeFunc)\n{\n\tsRecastAllocFunc = allocFunc ? allocFunc : rcAllocDefault;\n\tsRecastFreeFunc = freeFunc ? freeFunc : rcFreeDefault;\n}\n\n/// @see rcAllocSetCustom\nvoid* rcAlloc(size_t size, rcAllocHint hint)\n{\n\treturn sRecastAllocFunc(size, hint);\n}\n\n/// @par\n///\n/// @warning This function leaves the value of @p ptr unchanged.  So it still\n/// points to the same (now invalid) location, and not to null.\n/// \n/// @see rcAllocSetCustom\nvoid rcFree(void* ptr)\n{\n\tif (ptr)\n\t\tsRecastFreeFunc(ptr);\n}\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastArea.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#include <float.h>\n#define _USE_MATH_DEFINES\n#include <math.h>\n#include <string.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include \"Recast.h\"\n#include \"RecastAlloc.h\"\n#include \"RecastAssert.h\"\n\n/// @par \n/// \n/// Basically, any spans that are closer to a boundary or obstruction than the specified radius \n/// are marked as unwalkable.\n///\n/// This method is usually called immediately after the heightfield has been built.\n///\n/// @see rcCompactHeightfield, rcBuildCompactHeightfield, rcConfig::walkableRadius\nbool rcErodeWalkableArea(rcContext* ctx, int radius, rcCompactHeightfield& chf)\n{\n\trcAssert(ctx);\n\t\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_ERODE_AREA);\n\t\n\tunsigned char* dist = (unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP);\n\tif (!dist)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"erodeWalkableArea: Out of memory 'dist' (%d).\", chf.spanCount);\n\t\treturn false;\n\t}\n\t\n\t// Init distance.\n\tmemset(dist, 0xff, sizeof(unsigned char)*chf.spanCount);\n\t\n\t// Mark boundary cells.\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tif (chf.areas[i] == RC_NULL_AREA)\n\t\t\t\t{\n\t\t\t\t\tdist[i] = 0;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\t\tint nc = 0;\n\t\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst int nx = x + rcGetDirOffsetX(dir);\n\t\t\t\t\t\t\tconst int ny = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t\t\tconst int nidx = (int)chf.cells[nx+ny*w].index + rcGetCon(s, dir);\n\t\t\t\t\t\t\tif (chf.areas[nidx] != RC_NULL_AREA)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tnc++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// At least one missing neighbour.\n\t\t\t\t\tif (nc != 4)\n\t\t\t\t\t\tdist[i] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tunsigned char nd;\n\t\n\t// Pass 1\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\t\n\t\t\t\tif (rcGetCon(s, 0) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\t// (-1,0)\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(0);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(0);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);\n\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\tnd = (unsigned char)rcMin((int)dist[ai]+2, 255);\n\t\t\t\t\tif (nd < dist[i])\n\t\t\t\t\t\tdist[i] = nd;\n\t\t\t\t\t\n\t\t\t\t\t// (-1,-1)\n\t\t\t\t\tif (rcGetCon(as, 3) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int aax = ax + rcGetDirOffsetX(3);\n\t\t\t\t\t\tconst int aay = ay + rcGetDirOffsetY(3);\n\t\t\t\t\t\tconst int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 3);\n\t\t\t\t\t\tnd = (unsigned char)rcMin((int)dist[aai]+3, 255);\n\t\t\t\t\t\tif (nd < dist[i])\n\t\t\t\t\t\t\tdist[i] = nd;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (rcGetCon(s, 3) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\t// (0,-1)\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(3);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(3);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);\n\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\tnd = (unsigned char)rcMin((int)dist[ai]+2, 255);\n\t\t\t\t\tif (nd < dist[i])\n\t\t\t\t\t\tdist[i] = nd;\n\t\t\t\t\t\n\t\t\t\t\t// (1,-1)\n\t\t\t\t\tif (rcGetCon(as, 2) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int aax = ax + rcGetDirOffsetX(2);\n\t\t\t\t\t\tconst int aay = ay + rcGetDirOffsetY(2);\n\t\t\t\t\t\tconst int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 2);\n\t\t\t\t\t\tnd = (unsigned char)rcMin((int)dist[aai]+3, 255);\n\t\t\t\t\t\tif (nd < dist[i])\n\t\t\t\t\t\t\tdist[i] = nd;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Pass 2\n\tfor (int y = h-1; y >= 0; --y)\n\t{\n\t\tfor (int x = w-1; x >= 0; --x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\t\n\t\t\t\tif (rcGetCon(s, 2) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\t// (1,0)\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(2);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(2);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 2);\n\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\tnd = (unsigned char)rcMin((int)dist[ai]+2, 255);\n\t\t\t\t\tif (nd < dist[i])\n\t\t\t\t\t\tdist[i] = nd;\n\t\t\t\t\t\n\t\t\t\t\t// (1,1)\n\t\t\t\t\tif (rcGetCon(as, 1) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int aax = ax + rcGetDirOffsetX(1);\n\t\t\t\t\t\tconst int aay = ay + rcGetDirOffsetY(1);\n\t\t\t\t\t\tconst int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 1);\n\t\t\t\t\t\tnd = (unsigned char)rcMin((int)dist[aai]+3, 255);\n\t\t\t\t\t\tif (nd < dist[i])\n\t\t\t\t\t\t\tdist[i] = nd;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (rcGetCon(s, 1) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\t// (0,1)\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(1);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(1);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 1);\n\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\tnd = (unsigned char)rcMin((int)dist[ai]+2, 255);\n\t\t\t\t\tif (nd < dist[i])\n\t\t\t\t\t\tdist[i] = nd;\n\t\t\t\t\t\n\t\t\t\t\t// (-1,1)\n\t\t\t\t\tif (rcGetCon(as, 0) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int aax = ax + rcGetDirOffsetX(0);\n\t\t\t\t\t\tconst int aay = ay + rcGetDirOffsetY(0);\n\t\t\t\t\t\tconst int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 0);\n\t\t\t\t\t\tnd = (unsigned char)rcMin((int)dist[aai]+3, 255);\n\t\t\t\t\t\tif (nd < dist[i])\n\t\t\t\t\t\t\tdist[i] = nd;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tconst unsigned char thr = (unsigned char)(radius*2);\n\tfor (int i = 0; i < chf.spanCount; ++i)\n\t\tif (dist[i] < thr)\n\t\t\tchf.areas[i] = RC_NULL_AREA;\n\t\n\trcFree(dist);\n\t\n\treturn true;\n}\n\nstatic void insertSort(unsigned char* a, const int n)\n{\n\tint i, j;\n\tfor (i = 1; i < n; i++)\n\t{\n\t\tconst unsigned char value = a[i];\n\t\tfor (j = i - 1; j >= 0 && a[j] > value; j--)\n\t\t\ta[j+1] = a[j];\n\t\ta[j+1] = value;\n\t}\n}\n\n/// @par\n///\n/// This filter is usually applied after applying area id's using functions\n/// such as #rcMarkBoxArea, #rcMarkConvexPolyArea, and #rcMarkCylinderArea.\n/// \n/// @see rcCompactHeightfield\nbool rcMedianFilterWalkableArea(rcContext* ctx, rcCompactHeightfield& chf)\n{\n\trcAssert(ctx);\n\t\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_MEDIAN_AREA);\n\t\n\tunsigned char* areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP);\n\tif (!areas)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"medianFilterWalkableArea: Out of memory 'areas' (%d).\", chf.spanCount);\n\t\treturn false;\n\t}\n\t\n\t// Init distance.\n\tmemset(areas, 0xff, sizeof(unsigned char)*chf.spanCount);\n\t\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tif (chf.areas[i] == RC_NULL_AREA)\n\t\t\t\t{\n\t\t\t\t\tareas[i] = chf.areas[i];\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tunsigned char nei[9];\n\t\t\t\tfor (int j = 0; j < 9; ++j)\n\t\t\t\t\tnei[j] = chf.areas[i];\n\t\t\t\t\n\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t{\n\t\t\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);\n\t\t\t\t\t\tif (chf.areas[ai] != RC_NULL_AREA)\n\t\t\t\t\t\t\tnei[dir*2+0] = chf.areas[ai];\n\t\t\t\t\t\t\n\t\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\t\tconst int dir2 = (dir+1) & 0x3;\n\t\t\t\t\t\tif (rcGetCon(as, dir2) != RC_NOT_CONNECTED)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst int ax2 = ax + rcGetDirOffsetX(dir2);\n\t\t\t\t\t\t\tconst int ay2 = ay + rcGetDirOffsetY(dir2);\n\t\t\t\t\t\t\tconst int ai2 = (int)chf.cells[ax2+ay2*w].index + rcGetCon(as, dir2);\n\t\t\t\t\t\t\tif (chf.areas[ai2] != RC_NULL_AREA)\n\t\t\t\t\t\t\t\tnei[dir*2+1] = chf.areas[ai2];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tinsertSort(nei, 9);\n\t\t\t\tareas[i] = nei[4];\n\t\t\t}\n\t\t}\n\t}\n\t\n\tmemcpy(chf.areas, areas, sizeof(unsigned char)*chf.spanCount);\n\t\n\trcFree(areas);\n\t\n\treturn true;\n}\n\n/// @par\n///\n/// The value of spacial parameters are in world units.\n/// \n/// @see rcCompactHeightfield, rcMedianFilterWalkableArea\nvoid rcMarkBoxArea(rcContext* ctx, const float* bmin, const float* bmax, unsigned char areaId,\n\t\t\t\t   rcCompactHeightfield& chf)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_MARK_BOX_AREA);\n\n\tint minx = (int)((bmin[0]-chf.bmin[0])/chf.cs);\n\tint miny = (int)((bmin[1]-chf.bmin[1])/chf.ch);\n\tint minz = (int)((bmin[2]-chf.bmin[2])/chf.cs);\n\tint maxx = (int)((bmax[0]-chf.bmin[0])/chf.cs);\n\tint maxy = (int)((bmax[1]-chf.bmin[1])/chf.ch);\n\tint maxz = (int)((bmax[2]-chf.bmin[2])/chf.cs);\n\t\n\tif (maxx < 0) return;\n\tif (minx >= chf.width) return;\n\tif (maxz < 0) return;\n\tif (minz >= chf.height) return;\n\n\tif (minx < 0) minx = 0;\n\tif (maxx >= chf.width) maxx = chf.width-1;\n\tif (minz < 0) minz = 0;\n\tif (maxz >= chf.height) maxz = chf.height-1;\t\n\t\n\tfor (int z = minz; z <= maxz; ++z)\n\t{\n\t\tfor (int x = minx; x <= maxx; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+z*chf.width];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\trcCompactSpan& s = chf.spans[i];\n\t\t\t\tif ((int)s.y >= miny && (int)s.y <= maxy)\n\t\t\t\t{\n\t\t\t\t\tif (chf.areas[i] != RC_NULL_AREA)\n\t\t\t\t\t\tchf.areas[i] = areaId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\nstatic int pointInPoly(int nvert, const float* verts, const float* p)\n{\n\tint i, j, c = 0;\n\tfor (i = 0, j = nvert-1; i < nvert; j = i++)\n\t{\n\t\tconst float* vi = &verts[i*3];\n\t\tconst float* vj = &verts[j*3];\n\t\tif (((vi[2] > p[2]) != (vj[2] > p[2])) &&\n\t\t\t(p[0] < (vj[0]-vi[0]) * (p[2]-vi[2]) / (vj[2]-vi[2]) + vi[0]) )\n\t\t\tc = !c;\n\t}\n\treturn c;\n}\n\n/// @par\n///\n/// The value of spacial parameters are in world units.\n/// \n/// The y-values of the polygon vertices are ignored. So the polygon is effectively \n/// projected onto the xz-plane at @p hmin, then extruded to @p hmax.\n/// \n/// @see rcCompactHeightfield, rcMedianFilterWalkableArea\nvoid rcMarkConvexPolyArea(rcContext* ctx, const float* verts, const int nverts,\n\t\t\t\t\t\t  const float hmin, const float hmax, unsigned char areaId,\n\t\t\t\t\t\t  rcCompactHeightfield& chf)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_MARK_CONVEXPOLY_AREA);\n\n\tfloat bmin[3], bmax[3];\n\trcVcopy(bmin, verts);\n\trcVcopy(bmax, verts);\n\tfor (int i = 1; i < nverts; ++i)\n\t{\n\t\trcVmin(bmin, &verts[i*3]);\n\t\trcVmax(bmax, &verts[i*3]);\n\t}\n\tbmin[1] = hmin;\n\tbmax[1] = hmax;\n\n\tint minx = (int)((bmin[0]-chf.bmin[0])/chf.cs);\n\tint miny = (int)((bmin[1]-chf.bmin[1])/chf.ch);\n\tint minz = (int)((bmin[2]-chf.bmin[2])/chf.cs);\n\tint maxx = (int)((bmax[0]-chf.bmin[0])/chf.cs);\n\tint maxy = (int)((bmax[1]-chf.bmin[1])/chf.ch);\n\tint maxz = (int)((bmax[2]-chf.bmin[2])/chf.cs);\n\t\n\tif (maxx < 0) return;\n\tif (minx >= chf.width) return;\n\tif (maxz < 0) return;\n\tif (minz >= chf.height) return;\n\t\n\tif (minx < 0) minx = 0;\n\tif (maxx >= chf.width) maxx = chf.width-1;\n\tif (minz < 0) minz = 0;\n\tif (maxz >= chf.height) maxz = chf.height-1;\t\n\t\n\t\n\t// TODO: Optimize.\n\tfor (int z = minz; z <= maxz; ++z)\n\t{\n\t\tfor (int x = minx; x <= maxx; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+z*chf.width];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\trcCompactSpan& s = chf.spans[i];\n\t\t\t\tif (chf.areas[i] == RC_NULL_AREA)\n\t\t\t\t\tcontinue;\n\t\t\t\tif ((int)s.y >= miny && (int)s.y <= maxy)\n\t\t\t\t{\n\t\t\t\t\tfloat p[3];\n\t\t\t\t\tp[0] = chf.bmin[0] + (x+0.5f)*chf.cs; \n\t\t\t\t\tp[1] = 0;\n\t\t\t\t\tp[2] = chf.bmin[2] + (z+0.5f)*chf.cs; \n\n\t\t\t\t\tif (pointInPoly(nverts, verts, p))\n\t\t\t\t\t{\n\t\t\t\t\t\tchf.areas[i] = areaId;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nint rcOffsetPoly(const float* verts, const int nverts, const float offset,\n\t\t\t\t float* outVerts, const int maxOutVerts)\n{\n\tconst float\tMITER_LIMIT = 1.20f;\n\n\tint n = 0;\n\n\tfor (int i = 0; i < nverts; i++)\n\t{\n\t\tconst int a = (i+nverts-1) % nverts;\n\t\tconst int b = i;\n\t\tconst int c = (i+1) % nverts;\n\t\tconst float* va = &verts[a*3];\n\t\tconst float* vb = &verts[b*3];\n\t\tconst float* vc = &verts[c*3];\n\t\tfloat dx0 = vb[0] - va[0];\n\t\tfloat dy0 = vb[2] - va[2];\n\t\tfloat d0 = dx0*dx0 + dy0*dy0;\n\t\tif (d0 > 1e-6f)\n\t\t{\n\t\t\td0 = 1.0f/rcSqrt(d0);\n\t\t\tdx0 *= d0;\n\t\t\tdy0 *= d0;\n\t\t}\n\t\tfloat dx1 = vc[0] - vb[0];\n\t\tfloat dy1 = vc[2] - vb[2];\n\t\tfloat d1 = dx1*dx1 + dy1*dy1;\n\t\tif (d1 > 1e-6f)\n\t\t{\n\t\t\td1 = 1.0f/rcSqrt(d1);\n\t\t\tdx1 *= d1;\n\t\t\tdy1 *= d1;\n\t\t}\n\t\tconst float dlx0 = -dy0;\n\t\tconst float dly0 = dx0;\n\t\tconst float dlx1 = -dy1;\n\t\tconst float dly1 = dx1;\n\t\tfloat cross = dx1*dy0 - dx0*dy1;\n\t\tfloat dmx = (dlx0 + dlx1) * 0.5f;\n\t\tfloat dmy = (dly0 + dly1) * 0.5f;\n\t\tfloat dmr2 = dmx*dmx + dmy*dmy;\n\t\tbool bevel = dmr2 * MITER_LIMIT*MITER_LIMIT < 1.0f;\n\t\tif (dmr2 > 1e-6f)\n\t\t{\n\t\t\tconst float scale = 1.0f / dmr2;\n\t\t\tdmx *= scale;\n\t\t\tdmy *= scale;\n\t\t}\n\n\t\tif (bevel && cross < 0.0f)\n\t\t{\n\t\t\tif (n+2 >= maxOutVerts)\n\t\t\t\treturn 0;\n\t\t\tfloat d = (1.0f - (dx0*dx1 + dy0*dy1))*0.5f;\n\t\t\toutVerts[n*3+0] = vb[0] + (-dlx0+dx0*d)*offset;\n\t\t\toutVerts[n*3+1] = vb[1];\n\t\t\toutVerts[n*3+2] = vb[2] + (-dly0+dy0*d)*offset;\n\t\t\tn++;\n\t\t\toutVerts[n*3+0] = vb[0] + (-dlx1-dx1*d)*offset;\n\t\t\toutVerts[n*3+1] = vb[1];\n\t\t\toutVerts[n*3+2] = vb[2] + (-dly1-dy1*d)*offset;\n\t\t\tn++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (n+1 >= maxOutVerts)\n\t\t\t\treturn 0;\n\t\t\toutVerts[n*3+0] = vb[0] - dmx*offset;\n\t\t\toutVerts[n*3+1] = vb[1];\n\t\t\toutVerts[n*3+2] = vb[2] - dmy*offset;\n\t\t\tn++;\n\t\t}\n\t}\n\t\n\treturn n;\n}\n\n\n/// @par\n///\n/// The value of spacial parameters are in world units.\n/// \n/// @see rcCompactHeightfield, rcMedianFilterWalkableArea\nvoid rcMarkCylinderArea(rcContext* ctx, const float* pos,\n\t\t\t\t\t\tconst float r, const float h, unsigned char areaId,\n\t\t\t\t\t\trcCompactHeightfield& chf)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_MARK_CYLINDER_AREA);\n\t\n\tfloat bmin[3], bmax[3];\n\tbmin[0] = pos[0] - r;\n\tbmin[1] = pos[1];\n\tbmin[2] = pos[2] - r;\n\tbmax[0] = pos[0] + r;\n\tbmax[1] = pos[1] + h;\n\tbmax[2] = pos[2] + r;\n\tconst float r2 = r*r;\n\t\n\tint minx = (int)((bmin[0]-chf.bmin[0])/chf.cs);\n\tint miny = (int)((bmin[1]-chf.bmin[1])/chf.ch);\n\tint minz = (int)((bmin[2]-chf.bmin[2])/chf.cs);\n\tint maxx = (int)((bmax[0]-chf.bmin[0])/chf.cs);\n\tint maxy = (int)((bmax[1]-chf.bmin[1])/chf.ch);\n\tint maxz = (int)((bmax[2]-chf.bmin[2])/chf.cs);\n\t\n\tif (maxx < 0) return;\n\tif (minx >= chf.width) return;\n\tif (maxz < 0) return;\n\tif (minz >= chf.height) return;\n\t\n\tif (minx < 0) minx = 0;\n\tif (maxx >= chf.width) maxx = chf.width-1;\n\tif (minz < 0) minz = 0;\n\tif (maxz >= chf.height) maxz = chf.height-1;\t\n\t\n\t\n\tfor (int z = minz; z <= maxz; ++z)\n\t{\n\t\tfor (int x = minx; x <= maxx; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+z*chf.width];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\trcCompactSpan& s = chf.spans[i];\n\t\t\t\t\n\t\t\t\tif (chf.areas[i] == RC_NULL_AREA)\n\t\t\t\t\tcontinue;\n\t\t\t\t\n\t\t\t\tif ((int)s.y >= miny && (int)s.y <= maxy)\n\t\t\t\t{\n\t\t\t\t\tconst float sx = chf.bmin[0] + (x+0.5f)*chf.cs; \n\t\t\t\t\tconst float sz = chf.bmin[2] + (z+0.5f)*chf.cs; \n\t\t\t\t\tconst float dx = sx - pos[0];\n\t\t\t\t\tconst float dz = sz - pos[2];\n\t\t\t\t\t\n\t\t\t\t\tif (dx*dx + dz*dz < r2)\n\t\t\t\t\t{\n\t\t\t\t\t\tchf.areas[i] = areaId;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastAssert.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#include \"RecastAssert.h\"\n\n#ifndef NDEBUG\n\nstatic rcAssertFailFunc* sRecastAssertFailFunc = 0;\n\nvoid rcAssertFailSetCustom(rcAssertFailFunc *assertFailFunc)\n{\n\tsRecastAssertFailFunc = assertFailFunc;\n}\n\nrcAssertFailFunc* rcAssertFailGetCustom()\n{\n\treturn sRecastAssertFailFunc;\n}\n\n#endif\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastContour.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#define _USE_MATH_DEFINES\n#include <math.h>\n#include <string.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include \"Recast.h\"\n#include \"RecastAlloc.h\"\n#include \"RecastAssert.h\"\n\n\nstatic int getCornerHeight(int x, int y, int i, int dir,\n\t\t\t\t\t\t   const rcCompactHeightfield& chf,\n\t\t\t\t\t\t   bool& isBorderVertex)\n{\n\tconst rcCompactSpan& s = chf.spans[i];\n\tint ch = (int)s.y;\n\tint dirp = (dir+1) & 0x3;\n\t\n\tunsigned int regs[4] = {0,0,0,0};\n\t\n\t// Combine region and area codes in order to prevent\n\t// border vertices which are in between two areas to be removed.\n\tregs[0] = chf.spans[i].reg | (chf.areas[i] << 16);\n\t\n\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t{\n\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\tconst int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);\n\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\tch = rcMax(ch, (int)as.y);\n\t\tregs[1] = chf.spans[ai].reg | (chf.areas[ai] << 16);\n\t\tif (rcGetCon(as, dirp) != RC_NOT_CONNECTED)\n\t\t{\n\t\t\tconst int ax2 = ax + rcGetDirOffsetX(dirp);\n\t\t\tconst int ay2 = ay + rcGetDirOffsetY(dirp);\n\t\t\tconst int ai2 = (int)chf.cells[ax2+ay2*chf.width].index + rcGetCon(as, dirp);\n\t\t\tconst rcCompactSpan& as2 = chf.spans[ai2];\n\t\t\tch = rcMax(ch, (int)as2.y);\n\t\t\tregs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16);\n\t\t}\n\t}\n\tif (rcGetCon(s, dirp) != RC_NOT_CONNECTED)\n\t{\n\t\tconst int ax = x + rcGetDirOffsetX(dirp);\n\t\tconst int ay = y + rcGetDirOffsetY(dirp);\n\t\tconst int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dirp);\n\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\tch = rcMax(ch, (int)as.y);\n\t\tregs[3] = chf.spans[ai].reg | (chf.areas[ai] << 16);\n\t\tif (rcGetCon(as, dir) != RC_NOT_CONNECTED)\n\t\t{\n\t\t\tconst int ax2 = ax + rcGetDirOffsetX(dir);\n\t\t\tconst int ay2 = ay + rcGetDirOffsetY(dir);\n\t\t\tconst int ai2 = (int)chf.cells[ax2+ay2*chf.width].index + rcGetCon(as, dir);\n\t\t\tconst rcCompactSpan& as2 = chf.spans[ai2];\n\t\t\tch = rcMax(ch, (int)as2.y);\n\t\t\tregs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16);\n\t\t}\n\t}\n\n\t// Check if the vertex is special edge vertex, these vertices will be removed later.\n\tfor (int j = 0; j < 4; ++j)\n\t{\n\t\tconst int a = j;\n\t\tconst int b = (j+1) & 0x3;\n\t\tconst int c = (j+2) & 0x3;\n\t\tconst int d = (j+3) & 0x3;\n\t\t\n\t\t// The vertex is a border vertex there are two same exterior cells in a row,\n\t\t// followed by two interior cells and none of the regions are out of bounds.\n\t\tconst bool twoSameExts = (regs[a] & regs[b] & RC_BORDER_REG) != 0 && regs[a] == regs[b];\n\t\tconst bool twoInts = ((regs[c] | regs[d]) & RC_BORDER_REG) == 0;\n\t\tconst bool intsSameArea = (regs[c]>>16) == (regs[d]>>16);\n\t\tconst bool noZeros = regs[a] != 0 && regs[b] != 0 && regs[c] != 0 && regs[d] != 0;\n\t\tif (twoSameExts && twoInts && intsSameArea && noZeros)\n\t\t{\n\t\t\tisBorderVertex = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\treturn ch;\n}\n\nstatic void walkContour(int x, int y, int i,\n\t\t\t\t\t\trcCompactHeightfield& chf,\n\t\t\t\t\t\tunsigned char* flags, rcIntArray& points)\n{\n\t// Choose the first non-connected edge\n\tunsigned char dir = 0;\n\twhile ((flags[i] & (1 << dir)) == 0)\n\t\tdir++;\n\t\n\tunsigned char startDir = dir;\n\tint starti = i;\n\t\n\tconst unsigned char area = chf.areas[i];\n\t\n\tint iter = 0;\n\twhile (++iter < 40000)\n\t{\n\t\tif (flags[i] & (1 << dir))\n\t\t{\n\t\t\t// Choose the edge corner\n\t\t\tbool isBorderVertex = false;\n\t\t\tbool isAreaBorder = false;\n\t\t\tint px = x;\n\t\t\tint py = getCornerHeight(x, y, i, dir, chf, isBorderVertex);\n\t\t\tint pz = y;\n\t\t\tswitch(dir)\n\t\t\t{\n\t\t\t\tcase 0: pz++; break;\n\t\t\t\tcase 1: px++; pz++; break;\n\t\t\t\tcase 2: px++; break;\n\t\t\t}\n\t\t\tint r = 0;\n\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t{\n\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\tconst int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);\n\t\t\t\tr = (int)chf.spans[ai].reg;\n\t\t\t\tif (area != chf.areas[ai])\n\t\t\t\t\tisAreaBorder = true;\n\t\t\t}\n\t\t\tif (isBorderVertex)\n\t\t\t\tr |= RC_BORDER_VERTEX;\n\t\t\tif (isAreaBorder)\n\t\t\t\tr |= RC_AREA_BORDER;\n\t\t\tpoints.push(px);\n\t\t\tpoints.push(py);\n\t\t\tpoints.push(pz);\n\t\t\tpoints.push(r);\n\t\t\t\n\t\t\tflags[i] &= ~(1 << dir); // Remove visited edges\n\t\t\tdir = (dir+1) & 0x3;  // Rotate CW\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint ni = -1;\n\t\t\tconst int nx = x + rcGetDirOffsetX(dir);\n\t\t\tconst int ny = y + rcGetDirOffsetY(dir);\n\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t{\n\t\t\t\tconst rcCompactCell& nc = chf.cells[nx+ny*chf.width];\n\t\t\t\tni = (int)nc.index + rcGetCon(s, dir);\n\t\t\t}\n\t\t\tif (ni == -1)\n\t\t\t{\n\t\t\t\t// Should not happen.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tx = nx;\n\t\t\ty = ny;\n\t\t\ti = ni;\n\t\t\tdir = (dir+3) & 0x3;\t// Rotate CCW\n\t\t}\n\t\t\n\t\tif (starti == i && startDir == dir)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nstatic float distancePtSeg(const int x, const int z,\n\t\t\t\t\t\t   const int px, const int pz,\n\t\t\t\t\t\t   const int qx, const int qz)\n{\n\tfloat pqx = (float)(qx - px);\n\tfloat pqz = (float)(qz - pz);\n\tfloat dx = (float)(x - px);\n\tfloat dz = (float)(z - pz);\n\tfloat d = pqx*pqx + pqz*pqz;\n\tfloat t = pqx*dx + pqz*dz;\n\tif (d > 0)\n\t\tt /= d;\n\tif (t < 0)\n\t\tt = 0;\n\telse if (t > 1)\n\t\tt = 1;\n\t\n\tdx = px + t*pqx - x;\n\tdz = pz + t*pqz - z;\n\t\n\treturn dx*dx + dz*dz;\n}\n\nstatic void simplifyContour(rcIntArray& points, rcIntArray& simplified,\n\t\t\t\t\t\t\tconst float maxError, const int maxEdgeLen, const int buildFlags)\n{\n\t// Add initial points.\n\tbool hasConnections = false;\n\tfor (int i = 0; i < points.size(); i += 4)\n\t{\n\t\tif ((points[i+3] & RC_CONTOUR_REG_MASK) != 0)\n\t\t{\n\t\t\thasConnections = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tif (hasConnections)\n\t{\n\t\t// The contour has some portals to other regions.\n\t\t// Add a new point to every location where the region changes.\n\t\tfor (int i = 0, ni = points.size()/4; i < ni; ++i)\n\t\t{\n\t\t\tint ii = (i+1) % ni;\n\t\t\tconst bool differentRegs = (points[i*4+3] & RC_CONTOUR_REG_MASK) != (points[ii*4+3] & RC_CONTOUR_REG_MASK);\n\t\t\tconst bool areaBorders = (points[i*4+3] & RC_AREA_BORDER) != (points[ii*4+3] & RC_AREA_BORDER);\n\t\t\tif (differentRegs || areaBorders)\n\t\t\t{\n\t\t\t\tsimplified.push(points[i*4+0]);\n\t\t\t\tsimplified.push(points[i*4+1]);\n\t\t\t\tsimplified.push(points[i*4+2]);\n\t\t\t\tsimplified.push(i);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif (simplified.size() == 0)\n\t{\n\t\t// If there is no connections at all,\n\t\t// create some initial points for the simplification process.\n\t\t// Find lower-left and upper-right vertices of the contour.\n\t\tint llx = points[0];\n\t\tint lly = points[1];\n\t\tint llz = points[2];\n\t\tint lli = 0;\n\t\tint urx = points[0];\n\t\tint ury = points[1];\n\t\tint urz = points[2];\n\t\tint uri = 0;\n\t\tfor (int i = 0; i < points.size(); i += 4)\n\t\t{\n\t\t\tint x = points[i+0];\n\t\t\tint y = points[i+1];\n\t\t\tint z = points[i+2];\n\t\t\tif (x < llx || (x == llx && z < llz))\n\t\t\t{\n\t\t\t\tllx = x;\n\t\t\t\tlly = y;\n\t\t\t\tllz = z;\n\t\t\t\tlli = i/4;\n\t\t\t}\n\t\t\tif (x > urx || (x == urx && z > urz))\n\t\t\t{\n\t\t\t\turx = x;\n\t\t\t\tury = y;\n\t\t\t\turz = z;\n\t\t\t\turi = i/4;\n\t\t\t}\n\t\t}\n\t\tsimplified.push(llx);\n\t\tsimplified.push(lly);\n\t\tsimplified.push(llz);\n\t\tsimplified.push(lli);\n\t\t\n\t\tsimplified.push(urx);\n\t\tsimplified.push(ury);\n\t\tsimplified.push(urz);\n\t\tsimplified.push(uri);\n\t}\n\t\n\t// Add points until all raw points are within\n\t// error tolerance to the simplified shape.\n\tconst int pn = points.size()/4;\n\tfor (int i = 0; i < simplified.size()/4; )\n\t{\n\t\tint ii = (i+1) % (simplified.size()/4);\n\t\t\n\t\tint ax = simplified[i*4+0];\n\t\tint az = simplified[i*4+2];\n\t\tint ai = simplified[i*4+3];\n\n\t\tint bx = simplified[ii*4+0];\n\t\tint bz = simplified[ii*4+2];\n\t\tint bi = simplified[ii*4+3];\n\n\t\t// Find maximum deviation from the segment.\n\t\tfloat maxd = 0;\n\t\tint maxi = -1;\n\t\tint ci, cinc, endi;\n\n\t\t// Traverse the segment in lexilogical order so that the\n\t\t// max deviation is calculated similarly when traversing\n\t\t// opposite segments.\n\t\tif (bx > ax || (bx == ax && bz > az))\n\t\t{\n\t\t\tcinc = 1;\n\t\t\tci = (ai+cinc) % pn;\n\t\t\tendi = bi;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcinc = pn-1;\n\t\t\tci = (bi+cinc) % pn;\n\t\t\tendi = ai;\n\t\t\trcSwap(ax, bx);\n\t\t\trcSwap(az, bz);\n\t\t}\n\t\t\n\t\t// Tessellate only outer edges or edges between areas.\n\t\tif ((points[ci*4+3] & RC_CONTOUR_REG_MASK) == 0 ||\n\t\t\t(points[ci*4+3] & RC_AREA_BORDER))\n\t\t{\n\t\t\twhile (ci != endi)\n\t\t\t{\n\t\t\t\tfloat d = distancePtSeg(points[ci*4+0], points[ci*4+2], ax, az, bx, bz);\n\t\t\t\tif (d > maxd)\n\t\t\t\t{\n\t\t\t\t\tmaxd = d;\n\t\t\t\t\tmaxi = ci;\n\t\t\t\t}\n\t\t\t\tci = (ci+cinc) % pn;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t// If the max deviation is larger than accepted error,\n\t\t// add new point, else continue to next segment.\n\t\tif (maxi != -1 && maxd > (maxError*maxError))\n\t\t{\n\t\t\t// Add space for the new point.\n\t\t\tsimplified.resize(simplified.size()+4);\n\t\t\tconst int n = simplified.size()/4;\n\t\t\tfor (int j = n-1; j > i; --j)\n\t\t\t{\n\t\t\t\tsimplified[j*4+0] = simplified[(j-1)*4+0];\n\t\t\t\tsimplified[j*4+1] = simplified[(j-1)*4+1];\n\t\t\t\tsimplified[j*4+2] = simplified[(j-1)*4+2];\n\t\t\t\tsimplified[j*4+3] = simplified[(j-1)*4+3];\n\t\t\t}\n\t\t\t// Add the point.\n\t\t\tsimplified[(i+1)*4+0] = points[maxi*4+0];\n\t\t\tsimplified[(i+1)*4+1] = points[maxi*4+1];\n\t\t\tsimplified[(i+1)*4+2] = points[maxi*4+2];\n\t\t\tsimplified[(i+1)*4+3] = maxi;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t++i;\n\t\t}\n\t}\n\t\n\t// Split too long edges.\n\tif (maxEdgeLen > 0 && (buildFlags & (RC_CONTOUR_TESS_WALL_EDGES|RC_CONTOUR_TESS_AREA_EDGES)) != 0)\n\t{\n\t\tfor (int i = 0; i < simplified.size()/4; )\n\t\t{\n\t\t\tconst int ii = (i+1) % (simplified.size()/4);\n\t\t\t\n\t\t\tconst int ax = simplified[i*4+0];\n\t\t\tconst int az = simplified[i*4+2];\n\t\t\tconst int ai = simplified[i*4+3];\n\t\t\t\n\t\t\tconst int bx = simplified[ii*4+0];\n\t\t\tconst int bz = simplified[ii*4+2];\n\t\t\tconst int bi = simplified[ii*4+3];\n\t\t\t\n\t\t\t// Find maximum deviation from the segment.\n\t\t\tint maxi = -1;\n\t\t\tint ci = (ai+1) % pn;\n\t\t\t\n\t\t\t// Tessellate only outer edges or edges between areas.\n\t\t\tbool tess = false;\n\t\t\t// Wall edges.\n\t\t\tif ((buildFlags & RC_CONTOUR_TESS_WALL_EDGES) && (points[ci*4+3] & RC_CONTOUR_REG_MASK) == 0)\n\t\t\t\ttess = true;\n\t\t\t// Edges between areas.\n\t\t\tif ((buildFlags & RC_CONTOUR_TESS_AREA_EDGES) && (points[ci*4+3] & RC_AREA_BORDER))\n\t\t\t\ttess = true;\n\t\t\t\n\t\t\tif (tess)\n\t\t\t{\n\t\t\t\tint dx = bx - ax;\n\t\t\t\tint dz = bz - az;\n\t\t\t\tif (dx*dx + dz*dz > maxEdgeLen*maxEdgeLen)\n\t\t\t\t{\n\t\t\t\t\t// Round based on the segments in lexilogical order so that the\n\t\t\t\t\t// max tesselation is consistent regardles in which direction\n\t\t\t\t\t// segments are traversed.\n\t\t\t\t\tconst int n = bi < ai ? (bi+pn - ai) : (bi - ai);\n\t\t\t\t\tif (n > 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (bx > ax || (bx == ax && bz > az))\n\t\t\t\t\t\t\tmaxi = (ai + n/2) % pn;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tmaxi = (ai + (n+1)/2) % pn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t// If the max deviation is larger than accepted error,\n\t\t\t// add new point, else continue to next segment.\n\t\t\tif (maxi != -1)\n\t\t\t{\n\t\t\t\t// Add space for the new point.\n\t\t\t\tsimplified.resize(simplified.size()+4);\n\t\t\t\tconst int n = simplified.size()/4;\n\t\t\t\tfor (int j = n-1; j > i; --j)\n\t\t\t\t{\n\t\t\t\t\tsimplified[j*4+0] = simplified[(j-1)*4+0];\n\t\t\t\t\tsimplified[j*4+1] = simplified[(j-1)*4+1];\n\t\t\t\t\tsimplified[j*4+2] = simplified[(j-1)*4+2];\n\t\t\t\t\tsimplified[j*4+3] = simplified[(j-1)*4+3];\n\t\t\t\t}\n\t\t\t\t// Add the point.\n\t\t\t\tsimplified[(i+1)*4+0] = points[maxi*4+0];\n\t\t\t\tsimplified[(i+1)*4+1] = points[maxi*4+1];\n\t\t\t\tsimplified[(i+1)*4+2] = points[maxi*4+2];\n\t\t\t\tsimplified[(i+1)*4+3] = maxi;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t++i;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfor (int i = 0; i < simplified.size()/4; ++i)\n\t{\n\t\t// The edge vertex flag is take from the current raw point,\n\t\t// and the neighbour region is take from the next raw point.\n\t\tconst int ai = (simplified[i*4+3]+1) % pn;\n\t\tconst int bi = simplified[i*4+3];\n\t\tsimplified[i*4+3] = (points[ai*4+3] & (RC_CONTOUR_REG_MASK|RC_AREA_BORDER)) | (points[bi*4+3] & RC_BORDER_VERTEX);\n\t}\n\t\n}\n\nstatic int calcAreaOfPolygon2D(const int* verts, const int nverts)\n{\n\tint area = 0;\n\tfor (int i = 0, j = nverts-1; i < nverts; j=i++)\n\t{\n\t\tconst int* vi = &verts[i*4];\n\t\tconst int* vj = &verts[j*4];\n\t\tarea += vi[0] * vj[2] - vj[0] * vi[2];\n\t}\n\treturn (area+1) / 2;\n}\n\n// TODO: these are the same as in RecastMesh.cpp, consider using the same.\n// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).\ninline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }\ninline int next(int i, int n) { return i+1 < n ? i+1 : 0; }\n\ninline int area2(const int* a, const int* b, const int* c)\n{\n\treturn (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]);\n}\n\n//\tExclusive or: true iff exactly one argument is true.\n//\tThe arguments are negated to ensure that they are 0/1\n//\tvalues.  Then the bitwise Xor operator may apply.\n//\t(This idea is due to Michael Baldwin.)\ninline bool xorb(bool x, bool y)\n{\n\treturn !x ^ !y;\n}\n\n// Returns true iff c is strictly to the left of the directed\n// line through a to b.\ninline bool left(const int* a, const int* b, const int* c)\n{\n\treturn area2(a, b, c) < 0;\n}\n\ninline bool leftOn(const int* a, const int* b, const int* c)\n{\n\treturn area2(a, b, c) <= 0;\n}\n\ninline bool collinear(const int* a, const int* b, const int* c)\n{\n\treturn area2(a, b, c) == 0;\n}\n\n//\tReturns true iff ab properly intersects cd: they share\n//\ta point interior to both segments.  The properness of the\n//\tintersection is ensured by using strict leftness.\nstatic bool intersectProp(const int* a, const int* b, const int* c, const int* d)\n{\n\t// Eliminate improper cases.\n\tif (collinear(a,b,c) || collinear(a,b,d) ||\n\t\tcollinear(c,d,a) || collinear(c,d,b))\n\t\treturn false;\n\t\n\treturn xorb(left(a,b,c), left(a,b,d)) && xorb(left(c,d,a), left(c,d,b));\n}\n\n// Returns T iff (a,b,c) are collinear and point c lies\n// on the closed segement ab.\nstatic bool between(const int* a, const int* b, const int* c)\n{\n\tif (!collinear(a, b, c))\n\t\treturn false;\n\t// If ab not vertical, check betweenness on x; else on y.\n\tif (a[0] != b[0])\n\t\treturn\t((a[0] <= c[0]) && (c[0] <= b[0])) || ((a[0] >= c[0]) && (c[0] >= b[0]));\n\telse\n\t\treturn\t((a[2] <= c[2]) && (c[2] <= b[2])) || ((a[2] >= c[2]) && (c[2] >= b[2]));\n}\n\n// Returns true iff segments ab and cd intersect, properly or improperly.\nstatic bool intersect(const int* a, const int* b, const int* c, const int* d)\n{\n\tif (intersectProp(a, b, c, d))\n\t\treturn true;\n\telse if (between(a, b, c) || between(a, b, d) ||\n\t\t\t between(c, d, a) || between(c, d, b))\n\t\treturn true;\n\telse\n\t\treturn false;\n}\n\nstatic bool vequal(const int* a, const int* b)\n{\n\treturn a[0] == b[0] && a[2] == b[2];\n}\n\nstatic bool intersectSegCountour(const int* d0, const int* d1, int i, int n, const int* verts)\n{\n\t// For each edge (k,k+1) of P\n\tfor (int k = 0; k < n; k++)\n\t{\n\t\tint k1 = next(k, n);\n\t\t// Skip edges incident to i.\n\t\tif (i == k || i == k1)\n\t\t\tcontinue;\n\t\tconst int* p0 = &verts[k * 4];\n\t\tconst int* p1 = &verts[k1 * 4];\n\t\tif (vequal(d0, p0) || vequal(d1, p0) || vequal(d0, p1) || vequal(d1, p1))\n\t\t\tcontinue;\n\t\t\n\t\tif (intersect(d0, d1, p0, p1))\n\t\t\treturn true;\n\t}\n\treturn false;\n}\n\nstatic bool\tinCone(int i, int n, const int* verts, const int* pj)\n{\n\tconst int* pi = &verts[i * 4];\n\tconst int* pi1 = &verts[next(i, n) * 4];\n\tconst int* pin1 = &verts[prev(i, n) * 4];\n\t\n\t// If P[i] is a convex vertex [ i+1 left or on (i-1,i) ].\n\tif (leftOn(pin1, pi, pi1))\n\t\treturn left(pi, pj, pin1) && left(pj, pi, pi1);\n\t// Assume (i-1,i,i+1) not collinear.\n\t// else P[i] is reflex.\n\treturn !(leftOn(pi, pj, pi1) && leftOn(pj, pi, pin1));\n}\n\n\nstatic void removeDegenerateSegments(rcIntArray& simplified)\n{\n\t// Remove adjacent vertices which are equal on xz-plane,\n\t// or else the triangulator will get confused.\n\tint npts = simplified.size()/4;\n\tfor (int i = 0; i < npts; ++i)\n\t{\n\t\tint ni = next(i, npts);\n\t\t\n\t\tif (vequal(&simplified[i*4], &simplified[ni*4]))\n\t\t{\n\t\t\t// Degenerate segment, remove.\n\t\t\tfor (int j = i; j < simplified.size()/4-1; ++j)\n\t\t\t{\n\t\t\t\tsimplified[j*4+0] = simplified[(j+1)*4+0];\n\t\t\t\tsimplified[j*4+1] = simplified[(j+1)*4+1];\n\t\t\t\tsimplified[j*4+2] = simplified[(j+1)*4+2];\n\t\t\t\tsimplified[j*4+3] = simplified[(j+1)*4+3];\n\t\t\t}\n\t\t\tsimplified.resize(simplified.size()-4);\n\t\t\tnpts--;\n\t\t}\n\t}\n}\n\n\nstatic bool mergeContours(rcContour& ca, rcContour& cb, int ia, int ib)\n{\n\tconst int maxVerts = ca.nverts + cb.nverts + 2;\n\tint* verts = (int*)rcAlloc(sizeof(int)*maxVerts*4, RC_ALLOC_PERM);\n\tif (!verts)\n\t\treturn false;\n\t\n\tint nv = 0;\n\t\n\t// Copy contour A.\n\tfor (int i = 0; i <= ca.nverts; ++i)\n\t{\n\t\tint* dst = &verts[nv*4];\n\t\tconst int* src = &ca.verts[((ia+i)%ca.nverts)*4];\n\t\tdst[0] = src[0];\n\t\tdst[1] = src[1];\n\t\tdst[2] = src[2];\n\t\tdst[3] = src[3];\n\t\tnv++;\n\t}\n\n\t// Copy contour B\n\tfor (int i = 0; i <= cb.nverts; ++i)\n\t{\n\t\tint* dst = &verts[nv*4];\n\t\tconst int* src = &cb.verts[((ib+i)%cb.nverts)*4];\n\t\tdst[0] = src[0];\n\t\tdst[1] = src[1];\n\t\tdst[2] = src[2];\n\t\tdst[3] = src[3];\n\t\tnv++;\n\t}\n\t\n\trcFree(ca.verts);\n\tca.verts = verts;\n\tca.nverts = nv;\n\t\n\trcFree(cb.verts);\n\tcb.verts = 0;\n\tcb.nverts = 0;\n\t\n\treturn true;\n}\n\nstruct rcContourHole\n{\n\trcContour* contour;\n\tint minx, minz, leftmost;\n};\n\nstruct rcContourRegion\n{\n\trcContour* outline;\n\trcContourHole* holes;\n\tint nholes;\n};\n\nstruct rcPotentialDiagonal\n{\n\tint vert;\n\tint dist;\n};\n\n// Finds the lowest leftmost vertex of a contour.\nstatic void findLeftMostVertex(rcContour* contour, int* minx, int* minz, int* leftmost)\n{\n\t*minx = contour->verts[0];\n\t*minz = contour->verts[2];\n\t*leftmost = 0;\n\tfor (int i = 1; i < contour->nverts; i++)\n\t{\n\t\tconst int x = contour->verts[i*4+0];\n\t\tconst int z = contour->verts[i*4+2];\n\t\tif (x < *minx || (x == *minx && z < *minz))\n\t\t{\n\t\t\t*minx = x;\n\t\t\t*minz = z;\n\t\t\t*leftmost = i;\n\t\t}\n\t}\n}\n\nstatic int compareHoles(const void* va, const void* vb)\n{\n\tconst rcContourHole* a = (const rcContourHole*)va;\n\tconst rcContourHole* b = (const rcContourHole*)vb;\n\tif (a->minx == b->minx)\n\t{\n\t\tif (a->minz < b->minz)\n\t\t\treturn -1;\n\t\tif (a->minz > b->minz)\n\t\t\treturn 1;\n\t}\n\telse\n\t{\n\t\tif (a->minx < b->minx)\n\t\t\treturn -1;\n\t\tif (a->minx > b->minx)\n\t\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n\nstatic int compareDiagDist(const void* va, const void* vb)\n{\n\tconst rcPotentialDiagonal* a = (const rcPotentialDiagonal*)va;\n\tconst rcPotentialDiagonal* b = (const rcPotentialDiagonal*)vb;\n\tif (a->dist < b->dist)\n\t\treturn -1;\n\tif (a->dist > b->dist)\n\t\treturn 1;\n\treturn 0;\n}\n\n\nstatic void mergeRegionHoles(rcContext* ctx, rcContourRegion& region)\n{\n\t// Sort holes from left to right.\n\tfor (int i = 0; i < region.nholes; i++)\n\t\tfindLeftMostVertex(region.holes[i].contour, &region.holes[i].minx, &region.holes[i].minz, &region.holes[i].leftmost);\n\t\n\tqsort(region.holes, region.nholes, sizeof(rcContourHole), compareHoles);\n\t\n\tint maxVerts = region.outline->nverts;\n\tfor (int i = 0; i < region.nholes; i++)\n\t\tmaxVerts += region.holes[i].contour->nverts;\n\t\n\trcScopedDelete<rcPotentialDiagonal> diags((rcPotentialDiagonal*)rcAlloc(sizeof(rcPotentialDiagonal)*maxVerts, RC_ALLOC_TEMP));\n\tif (!diags)\n\t{\n\t\tctx->log(RC_LOG_WARNING, \"mergeRegionHoles: Failed to allocated diags %d.\", maxVerts);\n\t\treturn;\n\t}\n\t\n\trcContour* outline = region.outline;\n\t\n\t// Merge holes into the outline one by one.\n\tfor (int i = 0; i < region.nholes; i++)\n\t{\n\t\trcContour* hole = region.holes[i].contour;\n\t\t\n\t\tint index = -1;\n\t\tint bestVertex = region.holes[i].leftmost;\n\t\tfor (int iter = 0; iter < hole->nverts; iter++)\n\t\t{\n\t\t\t// Find potential diagonals.\n\t\t\t// The 'best' vertex must be in the cone described by 3 cosequtive vertices of the outline.\n\t\t\t// ..o j-1\n\t\t\t//   |\n\t\t\t//   |   * best\n\t\t\t//   |\n\t\t\t// j o-----o j+1\n\t\t\t//         :\n\t\t\tint ndiags = 0;\n\t\t\tconst int* corner = &hole->verts[bestVertex*4];\n\t\t\tfor (int j = 0; j < outline->nverts; j++)\n\t\t\t{\n\t\t\t\tif (inCone(j, outline->nverts, outline->verts, corner))\n\t\t\t\t{\n\t\t\t\t\tint dx = outline->verts[j*4+0] - corner[0];\n\t\t\t\t\tint dz = outline->verts[j*4+2] - corner[2];\n\t\t\t\t\tdiags[ndiags].vert = j;\n\t\t\t\t\tdiags[ndiags].dist = dx*dx + dz*dz;\n\t\t\t\t\tndiags++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Sort potential diagonals by distance, we want to make the connection as short as possible.\n\t\t\tqsort(diags, ndiags, sizeof(rcPotentialDiagonal), compareDiagDist);\n\t\t\t\n\t\t\t// Find a diagonal that is not intersecting the outline not the remaining holes.\n\t\t\tindex = -1;\n\t\t\tfor (int j = 0; j < ndiags; j++)\n\t\t\t{\n\t\t\t\tconst int* pt = &outline->verts[diags[j].vert*4];\n\t\t\t\tbool intersect = intersectSegCountour(pt, corner, diags[i].vert, outline->nverts, outline->verts);\n\t\t\t\tfor (int k = i; k < region.nholes && !intersect; k++)\n\t\t\t\t\tintersect |= intersectSegCountour(pt, corner, -1, region.holes[k].contour->nverts, region.holes[k].contour->verts);\n\t\t\t\tif (!intersect)\n\t\t\t\t{\n\t\t\t\t\tindex = diags[j].vert;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If found non-intersecting diagonal, stop looking.\n\t\t\tif (index != -1)\n\t\t\t\tbreak;\n\t\t\t// All the potential diagonals for the current vertex were intersecting, try next vertex.\n\t\t\tbestVertex = (bestVertex + 1) % hole->nverts;\n\t\t}\n\t\t\n\t\tif (index == -1)\n\t\t{\n\t\t\tctx->log(RC_LOG_WARNING, \"mergeHoles: Failed to find merge points for %p and %p.\", region.outline, hole);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!mergeContours(*region.outline, *hole, index, bestVertex))\n\t\t{\n\t\t\tctx->log(RC_LOG_WARNING, \"mergeHoles: Failed to merge contours %p and %p.\", region.outline, hole);\n\t\t\tcontinue;\n\t\t}\n\t}\n}\n\n\n/// @par\n///\n/// The raw contours will match the region outlines exactly. The @p maxError and @p maxEdgeLen\n/// parameters control how closely the simplified contours will match the raw contours.\n///\n/// Simplified contours are generated such that the vertices for portals between areas match up.\n/// (They are considered mandatory vertices.)\n///\n/// Setting @p maxEdgeLength to zero will disabled the edge length feature.\n///\n/// See the #rcConfig documentation for more information on the configuration parameters.\n///\n/// @see rcAllocContourSet, rcCompactHeightfield, rcContourSet, rcConfig\nbool rcBuildContours(rcContext* ctx, rcCompactHeightfield& chf,\n\t\t\t\t\t const float maxError, const int maxEdgeLen,\n\t\t\t\t\t rcContourSet& cset, const int buildFlags)\n{\n\trcAssert(ctx);\n\t\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\tconst int borderSize = chf.borderSize;\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_BUILD_CONTOURS);\n\t\n\trcVcopy(cset.bmin, chf.bmin);\n\trcVcopy(cset.bmax, chf.bmax);\n\tif (borderSize > 0)\n\t{\n\t\t// If the heightfield was build with bordersize, remove the offset.\n\t\tconst float pad = borderSize*chf.cs;\n\t\tcset.bmin[0] += pad;\n\t\tcset.bmin[2] += pad;\n\t\tcset.bmax[0] -= pad;\n\t\tcset.bmax[2] -= pad;\n\t}\n\tcset.cs = chf.cs;\n\tcset.ch = chf.ch;\n\tcset.width = chf.width - chf.borderSize*2;\n\tcset.height = chf.height - chf.borderSize*2;\n\tcset.borderSize = chf.borderSize;\n\tcset.maxError = maxError;\n\t\n\tint maxContours = rcMax((int)chf.maxRegions, 8);\n\tcset.conts = (rcContour*)rcAlloc(sizeof(rcContour)*maxContours, RC_ALLOC_PERM);\n\tif (!cset.conts)\n\t\treturn false;\n\tcset.nconts = 0;\n\t\n\trcScopedDelete<unsigned char> flags((unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP));\n\tif (!flags)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildContours: Out of memory 'flags' (%d).\", chf.spanCount);\n\t\treturn false;\n\t}\n\t\n\tctx->startTimer(RC_TIMER_BUILD_CONTOURS_TRACE);\n\t\n\t// Mark boundaries.\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tunsigned char res = 0;\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tif (!chf.spans[i].reg || (chf.spans[i].reg & RC_BORDER_REG))\n\t\t\t\t{\n\t\t\t\t\tflags[i] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t{\n\t\t\t\t\tunsigned short r = 0;\n\t\t\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);\n\t\t\t\t\t\tr = chf.spans[ai].reg;\n\t\t\t\t\t}\n\t\t\t\t\tif (r == chf.spans[i].reg)\n\t\t\t\t\t\tres |= (1 << dir);\n\t\t\t\t}\n\t\t\t\tflags[i] = res ^ 0xf; // Inverse, mark non connected edges.\n\t\t\t}\n\t\t}\n\t}\n\t\n\tctx->stopTimer(RC_TIMER_BUILD_CONTOURS_TRACE);\n\t\n\trcIntArray verts(256);\n\trcIntArray simplified(64);\n\t\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tif (flags[i] == 0 || flags[i] == 0xf)\n\t\t\t\t{\n\t\t\t\t\tflags[i] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst unsigned short reg = chf.spans[i].reg;\n\t\t\t\tif (!reg || (reg & RC_BORDER_REG))\n\t\t\t\t\tcontinue;\n\t\t\t\tconst unsigned char area = chf.areas[i];\n\t\t\t\t\n\t\t\t\tverts.resize(0);\n\t\t\t\tsimplified.resize(0);\n\t\t\t\t\n\t\t\t\tctx->startTimer(RC_TIMER_BUILD_CONTOURS_TRACE);\n\t\t\t\twalkContour(x, y, i, chf, flags, verts);\n\t\t\t\tctx->stopTimer(RC_TIMER_BUILD_CONTOURS_TRACE);\n\t\t\t\t\n\t\t\t\tctx->startTimer(RC_TIMER_BUILD_CONTOURS_SIMPLIFY);\n\t\t\t\tsimplifyContour(verts, simplified, maxError, maxEdgeLen, buildFlags);\n\t\t\t\tremoveDegenerateSegments(simplified);\n\t\t\t\tctx->stopTimer(RC_TIMER_BUILD_CONTOURS_SIMPLIFY);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t// Store region->contour remap info.\n\t\t\t\t// Create contour.\n\t\t\t\tif (simplified.size()/4 >= 3)\n\t\t\t\t{\n\t\t\t\t\tif (cset.nconts >= maxContours)\n\t\t\t\t\t{\n\t\t\t\t\t\t// Allocate more contours.\n\t\t\t\t\t\t// This happens when a region has holes.\n\t\t\t\t\t\tconst int oldMax = maxContours;\n\t\t\t\t\t\tmaxContours *= 2;\n\t\t\t\t\t\trcContour* newConts = (rcContour*)rcAlloc(sizeof(rcContour)*maxContours, RC_ALLOC_PERM);\n\t\t\t\t\t\tfor (int j = 0; j < cset.nconts; ++j)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tnewConts[j] = cset.conts[j];\n\t\t\t\t\t\t\t// Reset source pointers to prevent data deletion.\n\t\t\t\t\t\t\tcset.conts[j].verts = 0;\n\t\t\t\t\t\t\tcset.conts[j].rverts = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\trcFree(cset.conts);\n\t\t\t\t\t\tcset.conts = newConts;\n\t\t\t\t\t\t\n\t\t\t\t\t\tctx->log(RC_LOG_WARNING, \"rcBuildContours: Expanding max contours from %d to %d.\", oldMax, maxContours);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\trcContour* cont = &cset.conts[cset.nconts++];\n\t\t\t\t\t\n\t\t\t\t\tcont->nverts = simplified.size()/4;\n\t\t\t\t\tcont->verts = (int*)rcAlloc(sizeof(int)*cont->nverts*4, RC_ALLOC_PERM);\n\t\t\t\t\tif (!cont->verts)\n\t\t\t\t\t{\n\t\t\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildContours: Out of memory 'verts' (%d).\", cont->nverts);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tmemcpy(cont->verts, &simplified[0], sizeof(int)*cont->nverts*4);\n\t\t\t\t\tif (borderSize > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t// If the heightfield was build with bordersize, remove the offset.\n\t\t\t\t\t\tfor (int j = 0; j < cont->nverts; ++j)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tint* v = &cont->verts[j*4];\n\t\t\t\t\t\t\tv[0] -= borderSize;\n\t\t\t\t\t\t\tv[2] -= borderSize;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcont->nrverts = verts.size()/4;\n\t\t\t\t\tcont->rverts = (int*)rcAlloc(sizeof(int)*cont->nrverts*4, RC_ALLOC_PERM);\n\t\t\t\t\tif (!cont->rverts)\n\t\t\t\t\t{\n\t\t\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildContours: Out of memory 'rverts' (%d).\", cont->nrverts);\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tmemcpy(cont->rverts, &verts[0], sizeof(int)*cont->nrverts*4);\n\t\t\t\t\tif (borderSize > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t// If the heightfield was build with bordersize, remove the offset.\n\t\t\t\t\t\tfor (int j = 0; j < cont->nrverts; ++j)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tint* v = &cont->rverts[j*4];\n\t\t\t\t\t\t\tv[0] -= borderSize;\n\t\t\t\t\t\t\tv[2] -= borderSize;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcont->reg = reg;\n\t\t\t\t\tcont->area = area;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Merge holes if needed.\n\tif (cset.nconts > 0)\n\t{\n\t\t// Calculate winding of all polygons.\n\t\trcScopedDelete<signed char> winding((signed char*)rcAlloc(sizeof(signed char)*cset.nconts, RC_ALLOC_TEMP));\n\t\tif (!winding)\n\t\t{\n\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildContours: Out of memory 'hole' (%d).\", cset.nconts);\n\t\t\treturn false;\n\t\t}\n\t\tint nholes = 0;\n\t\tfor (int i = 0; i < cset.nconts; ++i)\n\t\t{\n\t\t\trcContour& cont = cset.conts[i];\n\t\t\t// If the contour is wound backwards, it is a hole.\n\t\t\twinding[i] = calcAreaOfPolygon2D(cont.verts, cont.nverts) < 0 ? -1 : 1;\n\t\t\tif (winding[i] < 0)\n\t\t\t\tnholes++;\n\t\t}\n\t\t\n\t\tif (nholes > 0)\n\t\t{\n\t\t\t// Collect outline contour and holes contours per region.\n\t\t\t// We assume that there is one outline and multiple holes.\n\t\t\tconst int nregions = chf.maxRegions+1;\n\t\t\trcScopedDelete<rcContourRegion> regions((rcContourRegion*)rcAlloc(sizeof(rcContourRegion)*nregions, RC_ALLOC_TEMP));\n\t\t\tif (!regions)\n\t\t\t{\n\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildContours: Out of memory 'regions' (%d).\", nregions);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tmemset(regions, 0, sizeof(rcContourRegion)*nregions);\n\t\t\t\n\t\t\trcScopedDelete<rcContourHole> holes((rcContourHole*)rcAlloc(sizeof(rcContourHole)*cset.nconts, RC_ALLOC_TEMP));\n\t\t\tif (!holes)\n\t\t\t{\n\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildContours: Out of memory 'holes' (%d).\", cset.nconts);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tmemset(holes, 0, sizeof(rcContourHole)*cset.nconts);\n\t\t\t\n\t\t\tfor (int i = 0; i < cset.nconts; ++i)\n\t\t\t{\n\t\t\t\trcContour& cont = cset.conts[i];\n\t\t\t\t// Positively would contours are outlines, negative holes.\n\t\t\t\tif (winding[i] > 0)\n\t\t\t\t{\n\t\t\t\t\tif (regions[cont.reg].outline)\n\t\t\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildContours: Multiple outlines for region %d.\", cont.reg);\n\t\t\t\t\tregions[cont.reg].outline = &cont;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tregions[cont.reg].nholes++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tint index = 0;\n\t\t\tfor (int i = 0; i < nregions; i++)\n\t\t\t{\n\t\t\t\tif (regions[i].nholes > 0)\n\t\t\t\t{\n\t\t\t\t\tregions[i].holes = &holes[index];\n\t\t\t\t\tindex += regions[i].nholes;\n\t\t\t\t\tregions[i].nholes = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int i = 0; i < cset.nconts; ++i)\n\t\t\t{\n\t\t\t\trcContour& cont = cset.conts[i];\n\t\t\t\trcContourRegion& reg = regions[cont.reg];\n\t\t\t\tif (winding[i] < 0)\n\t\t\t\t\treg.holes[reg.nholes++].contour = &cont;\n\t\t\t}\n\t\t\t\n\t\t\t// Finally merge each regions holes into the outline.\n\t\t\tfor (int i = 0; i < nregions; i++)\n\t\t\t{\n\t\t\t\trcContourRegion& reg = regions[i];\n\t\t\t\tif (!reg.nholes) continue;\n\t\t\t\t\n\t\t\t\tif (reg.outline)\n\t\t\t\t{\n\t\t\t\t\tmergeRegionHoles(ctx, reg);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// The region does not have an outline.\n\t\t\t\t\t// This can happen if the contour becaomes selfoverlapping because of\n\t\t\t\t\t// too aggressive simplification settings.\n\t\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildContours: Bad outline for region %d, contour simplification is likely too aggressive.\", i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\treturn true;\n}\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastFilter.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#define _USE_MATH_DEFINES\n#include <math.h>\n#include <stdio.h>\n#include \"Recast.h\"\n#include \"RecastAssert.h\"\n\n/// @par\n///\n/// Allows the formation of walkable regions that will flow over low lying \n/// objects such as curbs, and up structures such as stairways. \n/// \n/// Two neighboring spans are walkable if: <tt>rcAbs(currentSpan.smax - neighborSpan.smax) < waklableClimb</tt>\n/// \n/// @warning Will override the effect of #rcFilterLedgeSpans.  So if both filters are used, call\n/// #rcFilterLedgeSpans after calling this filter. \n///\n/// @see rcHeightfield, rcConfig\nvoid rcFilterLowHangingWalkableObstacles(rcContext* ctx, const int walkableClimb, rcHeightfield& solid)\n{\n\trcAssert(ctx);\n\n\trcScopedTimer timer(ctx, RC_TIMER_FILTER_LOW_OBSTACLES);\n\t\n\tconst int w = solid.width;\n\tconst int h = solid.height;\n\t\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\trcSpan* ps = 0;\n\t\t\tbool previousWalkable = false;\n\t\t\tunsigned char previousArea = RC_NULL_AREA;\n\t\t\t\n\t\t\tfor (rcSpan* s = solid.spans[x + y*w]; s; ps = s, s = s->next)\n\t\t\t{\n\t\t\t\tconst bool walkable = s->area != RC_NULL_AREA;\n\t\t\t\t// If current span is not walkable, but there is walkable\n\t\t\t\t// span just below it, mark the span above it walkable too.\n\t\t\t\tif (!walkable && previousWalkable)\n\t\t\t\t{\n\t\t\t\t\tif (rcAbs((int)s->smax - (int)ps->smax) <= walkableClimb)\n\t\t\t\t\t\ts->area = previousArea;\n\t\t\t\t}\n\t\t\t\t// Copy walkable flag so that it cannot propagate\n\t\t\t\t// past multiple non-walkable objects.\n\t\t\t\tpreviousWalkable = walkable;\n\t\t\t\tpreviousArea = s->area;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/// @par\n///\n/// A ledge is a span with one or more neighbors whose maximum is further away than @p walkableClimb\n/// from the current span's maximum.\n/// This method removes the impact of the overestimation of conservative voxelization \n/// so the resulting mesh will not have regions hanging in the air over ledges.\n/// \n/// A span is a ledge if: <tt>rcAbs(currentSpan.smax - neighborSpan.smax) > walkableClimb</tt>\n/// \n/// @see rcHeightfield, rcConfig\nvoid rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight, const int walkableClimb,\n\t\t\t\t\t\trcHeightfield& solid)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_FILTER_BORDER);\n\n\tconst int w = solid.width;\n\tconst int h = solid.height;\n\tconst int MAX_HEIGHT = 0xffff;\n\t\n\t// Mark border spans.\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tfor (rcSpan* s = solid.spans[x + y*w]; s; s = s->next)\n\t\t\t{\n\t\t\t\t// Skip non walkable spans.\n\t\t\t\tif (s->area == RC_NULL_AREA)\n\t\t\t\t\tcontinue;\n\t\t\t\t\n\t\t\t\tconst int bot = (int)(s->smax);\n\t\t\t\tconst int top = s->next ? (int)(s->next->smin) : MAX_HEIGHT;\n\t\t\t\t\n\t\t\t\t// Find neighbours minimum height.\n\t\t\t\tint minh = MAX_HEIGHT;\n\n\t\t\t\t// Min and max height of accessible neighbours.\n\t\t\t\tint asmin = s->smax;\n\t\t\t\tint asmax = s->smax;\n\n\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t{\n\t\t\t\t\tint dx = x + rcGetDirOffsetX(dir);\n\t\t\t\t\tint dy = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t// Skip neighbours which are out of bounds.\n\t\t\t\t\tif (dx < 0 || dy < 0 || dx >= w || dy >= h)\n\t\t\t\t\t{\n\t\t\t\t\t\tminh = rcMin(minh, -walkableClimb - bot);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// From minus infinity to the first span.\n\t\t\t\t\trcSpan* ns = solid.spans[dx + dy*w];\n\t\t\t\t\tint nbot = -walkableClimb;\n\t\t\t\t\tint ntop = ns ? (int)ns->smin : MAX_HEIGHT;\n\t\t\t\t\t// Skip neightbour if the gap between the spans is too small.\n\t\t\t\t\tif (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)\n\t\t\t\t\t\tminh = rcMin(minh, nbot - bot);\n\t\t\t\t\t\n\t\t\t\t\t// Rest of the spans.\n\t\t\t\t\tfor (ns = solid.spans[dx + dy*w]; ns; ns = ns->next)\n\t\t\t\t\t{\n\t\t\t\t\t\tnbot = (int)ns->smax;\n\t\t\t\t\t\tntop = ns->next ? (int)ns->next->smin : MAX_HEIGHT;\n\t\t\t\t\t\t// Skip neightbour if the gap between the spans is too small.\n\t\t\t\t\t\tif (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tminh = rcMin(minh, nbot - bot);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Find min/max accessible neighbour height. \n\t\t\t\t\t\t\tif (rcAbs(nbot - bot) <= walkableClimb)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (nbot < asmin) asmin = nbot;\n\t\t\t\t\t\t\t\tif (nbot > asmax) asmax = nbot;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// The current span is close to a ledge if the drop to any\n\t\t\t\t// neighbour span is less than the walkableClimb.\n\t\t\t\tif (minh < -walkableClimb)\n\t\t\t\t{\n\t\t\t\t\ts->area = RC_NULL_AREA;\n\t\t\t\t}\n\t\t\t\t// If the difference between all neighbours is too large,\n\t\t\t\t// we are at steep slope, mark the span as ledge.\n\t\t\t\telse if ((asmax - asmin) > walkableClimb)\n\t\t\t\t{\n\t\t\t\t\ts->area = RC_NULL_AREA;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/// @par\n///\n/// For this filter, the clearance above the span is the distance from the span's \n/// maximum to the next higher span's minimum. (Same grid column.)\n/// \n/// @see rcHeightfield, rcConfig\nvoid rcFilterWalkableLowHeightSpans(rcContext* ctx, int walkableHeight, rcHeightfield& solid)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_FILTER_WALKABLE);\n\t\n\tconst int w = solid.width;\n\tconst int h = solid.height;\n\tconst int MAX_HEIGHT = 0xffff;\n\t\n\t// Remove walkable flag from spans which do not have enough\n\t// space above them for the agent to stand there.\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tfor (rcSpan* s = solid.spans[x + y*w]; s; s = s->next)\n\t\t\t{\n\t\t\t\tconst int bot = (int)(s->smax);\n\t\t\t\tconst int top = s->next ? (int)(s->next->smin) : MAX_HEIGHT;\n\t\t\t\tif ((top - bot) <= walkableHeight)\n\t\t\t\t\ts->area = RC_NULL_AREA;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastLayers.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#include <float.h>\n#define _USE_MATH_DEFINES\n#include <math.h>\n#include <string.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include \"Recast.h\"\n#include \"RecastAlloc.h\"\n#include \"RecastAssert.h\"\n\n\n// Must be 255 or smaller (not 256) because layer IDs are stored as\n// a byte where 255 is a special value.\nstatic const int RC_MAX_LAYERS = 63;\nstatic const int RC_MAX_NEIS = 16;\n\nstruct rcLayerRegion\n{\n\tunsigned char layers[RC_MAX_LAYERS];\n\tunsigned char neis[RC_MAX_NEIS];\n\tunsigned short ymin, ymax;\n\tunsigned char layerId;\t\t// Layer ID\n\tunsigned char nlayers;\t\t// Layer count\n\tunsigned char nneis;\t\t// Neighbour count\n\tunsigned char base;\t\t// Flag indicating if the region is the base of merged regions.\n};\n\n\nstatic bool contains(const unsigned char* a, const unsigned char an, const unsigned char v)\n{\n\tconst int n = (int)an;\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tif (a[i] == v)\n\t\t\treturn true;\n\t}\n\treturn false;\n}\n\nstatic bool addUnique(unsigned char* a, unsigned char& an, int anMax, unsigned char v)\n{\n\tif (contains(a, an, v))\n\t\treturn true;\n\n\tif ((int)an >= anMax)\n\t\treturn false;\n\n\ta[an] = v;\n\tan++;\n\treturn true;\n}\n\n\ninline bool overlapRange(const unsigned short amin, const unsigned short amax,\n\t\t\t\t\t\t const unsigned short bmin, const unsigned short bmax)\n{\n\treturn (amin > bmax || amax < bmin) ? false : true;\n}\n\n\n\nstruct rcLayerSweepSpan\n{\n\tunsigned short ns;\t// number samples\n\tunsigned char id;\t// region id\n\tunsigned char nei;\t// neighbour id\n};\n\n/// @par\n/// \n/// See the #rcConfig documentation for more information on the configuration parameters.\n/// \n/// @see rcAllocHeightfieldLayerSet, rcCompactHeightfield, rcHeightfieldLayerSet, rcConfig\nbool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,\n\t\t\t\t\t\t\t  const int borderSize, const int walkableHeight,\n\t\t\t\t\t\t\t  rcHeightfieldLayerSet& lset)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_BUILD_LAYERS);\n\t\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\t\n\trcScopedDelete<unsigned char> srcReg((unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP));\n\tif (!srcReg)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: Out of memory 'srcReg' (%d).\", chf.spanCount);\n\t\treturn false;\n\t}\n\tmemset(srcReg,0xff,sizeof(unsigned char)*chf.spanCount);\n\t\n\tconst int nsweeps = chf.width;\n\trcScopedDelete<rcLayerSweepSpan> sweeps((rcLayerSweepSpan*)rcAlloc(sizeof(rcLayerSweepSpan)*nsweeps, RC_ALLOC_TEMP));\n\tif (!sweeps)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: Out of memory 'sweeps' (%d).\", nsweeps);\n\t\treturn false;\n\t}\n\t\n\t\n\t// Partition walkable area into monotone regions.\n\tint prevCount[256];\n\tunsigned char regId = 0;\n\n\tfor (int y = borderSize; y < h-borderSize; ++y)\n\t{\n\t\tmemset(prevCount,0,sizeof(int)*regId);\n\t\tunsigned char sweepId = 0;\n\t\t\n\t\tfor (int x = borderSize; x < w-borderSize; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\t\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tif (chf.areas[i] == RC_NULL_AREA) continue;\n\n\t\t\t\tunsigned char sid = 0xff;\n\n\t\t\t\t// -x\n\t\t\t\tif (rcGetCon(s, 0) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(0);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(0);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);\n\t\t\t\t\tif (chf.areas[ai] != RC_NULL_AREA && srcReg[ai] != 0xff)\n\t\t\t\t\t\tsid = srcReg[ai];\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (sid == 0xff)\n\t\t\t\t{\n\t\t\t\t\tsid = sweepId++;\n\t\t\t\t\tsweeps[sid].nei = 0xff;\n\t\t\t\t\tsweeps[sid].ns = 0;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// -y\n\t\t\t\tif (rcGetCon(s,3) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(3);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(3);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);\n\t\t\t\t\tconst unsigned char nr = srcReg[ai];\n\t\t\t\t\tif (nr != 0xff)\n\t\t\t\t\t{\n\t\t\t\t\t\t// Set neighbour when first valid neighbour is encoutered.\n\t\t\t\t\t\tif (sweeps[sid].ns == 0)\n\t\t\t\t\t\t\tsweeps[sid].nei = nr;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (sweeps[sid].nei == nr)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Update existing neighbour\n\t\t\t\t\t\t\tsweeps[sid].ns++;\n\t\t\t\t\t\t\tprevCount[nr]++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// This is hit if there is nore than one neighbour.\n\t\t\t\t\t\t\t// Invalidate the neighbour.\n\t\t\t\t\t\t\tsweeps[sid].nei = 0xff;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tsrcReg[i] = sid;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Create unique ID.\n\t\tfor (int i = 0; i < sweepId; ++i)\n\t\t{\n\t\t\t// If the neighbour is set and there is only one continuous connection to it,\n\t\t\t// the sweep will be merged with the previous one, else new region is created.\n\t\t\tif (sweeps[i].nei != 0xff && prevCount[sweeps[i].nei] == (int)sweeps[i].ns)\n\t\t\t{\n\t\t\t\tsweeps[i].id = sweeps[i].nei;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (regId == 255)\n\t\t\t\t{\n\t\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: Region ID overflow.\");\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tsweeps[i].id = regId++;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Remap local sweep ids to region ids.\n\t\tfor (int x = borderSize; x < w-borderSize; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tif (srcReg[i] != 0xff)\n\t\t\t\t\tsrcReg[i] = sweeps[srcReg[i]].id;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Allocate and init layer regions.\n\tconst int nregs = (int)regId;\n\trcScopedDelete<rcLayerRegion> regs((rcLayerRegion*)rcAlloc(sizeof(rcLayerRegion)*nregs, RC_ALLOC_TEMP));\n\tif (!regs)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: Out of memory 'regs' (%d).\", nregs);\n\t\treturn false;\n\t}\n\tmemset(regs, 0, sizeof(rcLayerRegion)*nregs);\n\tfor (int i = 0; i < nregs; ++i)\n\t{\n\t\tregs[i].layerId = 0xff;\n\t\tregs[i].ymin = 0xffff;\n\t\tregs[i].ymax = 0;\n\t}\n\t\n\t// Find region neighbours and overlapping regions.\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\t\n\t\t\tunsigned char lregs[RC_MAX_LAYERS];\n\t\t\tint nlregs = 0;\n\t\t\t\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tconst unsigned char ri = srcReg[i];\n\t\t\t\tif (ri == 0xff) continue;\n\t\t\t\t\n\t\t\t\tregs[ri].ymin = rcMin(regs[ri].ymin, s.y);\n\t\t\t\tregs[ri].ymax = rcMax(regs[ri].ymax, s.y);\n\t\t\t\t\n\t\t\t\t// Collect all region layers.\n\t\t\t\tif (nlregs < RC_MAX_LAYERS)\n\t\t\t\t\tlregs[nlregs++] = ri;\n\t\t\t\t\n\t\t\t\t// Update neighbours\n\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t{\n\t\t\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);\n\t\t\t\t\t\tconst unsigned char rai = srcReg[ai];\n\t\t\t\t\t\tif (rai != 0xff && rai != ri)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Don't check return value -- if we cannot add the neighbor\n\t\t\t\t\t\t\t// it will just cause a few more regions to be created, which\n\t\t\t\t\t\t\t// is fine.\n\t\t\t\t\t\t\taddUnique(regs[ri].neis, regs[ri].nneis, RC_MAX_NEIS, rai);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t// Update overlapping regions.\n\t\t\tfor (int i = 0; i < nlregs-1; ++i)\n\t\t\t{\n\t\t\t\tfor (int j = i+1; j < nlregs; ++j)\n\t\t\t\t{\n\t\t\t\t\tif (lregs[i] != lregs[j])\n\t\t\t\t\t{\n\t\t\t\t\t\trcLayerRegion& ri = regs[lregs[i]];\n\t\t\t\t\t\trcLayerRegion& rj = regs[lregs[j]];\n\n\t\t\t\t\t\tif (!addUnique(ri.layers, ri.nlayers, RC_MAX_LAYERS, lregs[j]) ||\n\t\t\t\t\t\t\t!addUnique(rj.layers, rj.nlayers, RC_MAX_LAYERS, lregs[i]))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: layer overflow (too many overlapping walkable platforms). Try increasing RC_MAX_LAYERS.\");\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\t\n\t// Create 2D layers from regions.\n\tunsigned char layerId = 0;\n\t\n\tstatic const int MAX_STACK = 64;\n\tunsigned char stack[MAX_STACK];\n\tint nstack = 0;\n\t\n\tfor (int i = 0; i < nregs; ++i)\n\t{\n\t\trcLayerRegion& root = regs[i];\n\t\t// Skip already visited.\n\t\tif (root.layerId != 0xff)\n\t\t\tcontinue;\n\n\t\t// Start search.\n\t\troot.layerId = layerId;\n\t\troot.base = 1;\n\t\t\n\t\tnstack = 0;\n\t\tstack[nstack++] = (unsigned char)i;\n\t\t\n\t\twhile (nstack)\n\t\t{\n\t\t\t// Pop front\n\t\t\trcLayerRegion& reg = regs[stack[0]];\n\t\t\tnstack--;\n\t\t\tfor (int j = 0; j < nstack; ++j)\n\t\t\t\tstack[j] = stack[j+1];\n\t\t\t\n\t\t\tconst int nneis = (int)reg.nneis;\n\t\t\tfor (int j = 0; j < nneis; ++j)\n\t\t\t{\n\t\t\t\tconst unsigned char nei = reg.neis[j];\n\t\t\t\trcLayerRegion& regn = regs[nei];\n\t\t\t\t// Skip already visited.\n\t\t\t\tif (regn.layerId != 0xff)\n\t\t\t\t\tcontinue;\n\t\t\t\t// Skip if the neighbour is overlapping root region.\n\t\t\t\tif (contains(root.layers, root.nlayers, nei))\n\t\t\t\t\tcontinue;\n\t\t\t\t// Skip if the height range would become too large.\n\t\t\t\tconst int ymin = rcMin(root.ymin, regn.ymin);\n\t\t\t\tconst int ymax = rcMax(root.ymax, regn.ymax);\n\t\t\t\tif ((ymax - ymin) >= 255)\n\t\t\t\t\t continue;\n\n\t\t\t\tif (nstack < MAX_STACK)\n\t\t\t\t{\n\t\t\t\t\t// Deepen\n\t\t\t\t\tstack[nstack++] = (unsigned char)nei;\n\t\t\t\t\t\n\t\t\t\t\t// Mark layer id\n\t\t\t\t\tregn.layerId = layerId;\n\t\t\t\t\t// Merge current layers to root.\n\t\t\t\t\tfor (int k = 0; k < regn.nlayers; ++k)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!addUnique(root.layers, root.nlayers, RC_MAX_LAYERS, regn.layers[k]))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: layer overflow (too many overlapping walkable platforms). Try increasing RC_MAX_LAYERS.\");\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\troot.ymin = rcMin(root.ymin, regn.ymin);\n\t\t\t\t\troot.ymax = rcMax(root.ymax, regn.ymax);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tlayerId++;\n\t}\n\t\n\t// Merge non-overlapping regions that are close in height.\n\tconst unsigned short mergeHeight = (unsigned short)walkableHeight * 4;\n\t\n\tfor (int i = 0; i < nregs; ++i)\n\t{\n\t\trcLayerRegion& ri = regs[i];\n\t\tif (!ri.base) continue;\n\t\t\n\t\tunsigned char newId = ri.layerId;\n\t\t\n\t\tfor (;;)\n\t\t{\n\t\t\tunsigned char oldId = 0xff;\n\t\t\t\n\t\t\tfor (int j = 0; j < nregs; ++j)\n\t\t\t{\n\t\t\t\tif (i == j) continue;\n\t\t\t\trcLayerRegion& rj = regs[j];\n\t\t\t\tif (!rj.base) continue;\n\t\t\t\t\n\t\t\t\t// Skip if the regions are not close to each other.\n\t\t\t\tif (!overlapRange(ri.ymin,ri.ymax+mergeHeight, rj.ymin,rj.ymax+mergeHeight))\n\t\t\t\t\tcontinue;\n\t\t\t\t// Skip if the height range would become too large.\n\t\t\t\tconst int ymin = rcMin(ri.ymin, rj.ymin);\n\t\t\t\tconst int ymax = rcMax(ri.ymax, rj.ymax);\n\t\t\t\tif ((ymax - ymin) >= 255)\n\t\t\t\t  continue;\n\t\t\t\t\t\t  \n\t\t\t\t// Make sure that there is no overlap when merging 'ri' and 'rj'.\n\t\t\t\tbool overlap = false;\n\t\t\t\t// Iterate over all regions which have the same layerId as 'rj'\n\t\t\t\tfor (int k = 0; k < nregs; ++k)\n\t\t\t\t{\n\t\t\t\t\tif (regs[k].layerId != rj.layerId)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t// Check if region 'k' is overlapping region 'ri'\n\t\t\t\t\t// Index to 'regs' is the same as region id.\n\t\t\t\t\tif (contains(ri.layers,ri.nlayers, (unsigned char)k))\n\t\t\t\t\t{\n\t\t\t\t\t\toverlap = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Cannot merge of regions overlap.\n\t\t\t\tif (overlap)\n\t\t\t\t\tcontinue;\n\t\t\t\t\n\t\t\t\t// Can merge i and j.\n\t\t\t\toldId = rj.layerId;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\t// Could not find anything to merge with, stop.\n\t\t\tif (oldId == 0xff)\n\t\t\t\tbreak;\n\t\t\t\n\t\t\t// Merge\n\t\t\tfor (int j = 0; j < nregs; ++j)\n\t\t\t{\n\t\t\t\trcLayerRegion& rj = regs[j];\n\t\t\t\tif (rj.layerId == oldId)\n\t\t\t\t{\n\t\t\t\t\trj.base = 0;\n\t\t\t\t\t// Remap layerIds.\n\t\t\t\t\trj.layerId = newId;\n\t\t\t\t\t// Add overlaid layers from 'rj' to 'ri'.\n\t\t\t\t\tfor (int k = 0; k < rj.nlayers; ++k)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!addUnique(ri.layers, ri.nlayers, RC_MAX_LAYERS, rj.layers[k]))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: layer overflow (too many overlapping walkable platforms). Try increasing RC_MAX_LAYERS.\");\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update height bounds.\n\t\t\t\t\tri.ymin = rcMin(ri.ymin, rj.ymin);\n\t\t\t\t\tri.ymax = rcMax(ri.ymax, rj.ymax);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Compact layerIds\n\tunsigned char remap[256];\n\tmemset(remap, 0, 256);\n\n\t// Find number of unique layers.\n\tlayerId = 0;\n\tfor (int i = 0; i < nregs; ++i)\n\t\tremap[regs[i].layerId] = 1;\n\tfor (int i = 0; i < 256; ++i)\n\t{\n\t\tif (remap[i])\n\t\t\tremap[i] = layerId++;\n\t\telse\n\t\t\tremap[i] = 0xff;\n\t}\n\t// Remap ids.\n\tfor (int i = 0; i < nregs; ++i)\n\t\tregs[i].layerId = remap[regs[i].layerId];\n\t\n\t// No layers, return empty.\n\tif (layerId == 0)\n\t\treturn true;\n\t\n\t// Create layers.\n\trcAssert(lset.layers == 0);\n\t\n\tconst int lw = w - borderSize*2;\n\tconst int lh = h - borderSize*2;\n\n\t// Build contracted bbox for layers.\n\tfloat bmin[3], bmax[3];\n\trcVcopy(bmin, chf.bmin);\n\trcVcopy(bmax, chf.bmax);\n\tbmin[0] += borderSize*chf.cs;\n\tbmin[2] += borderSize*chf.cs;\n\tbmax[0] -= borderSize*chf.cs;\n\tbmax[2] -= borderSize*chf.cs;\n\t\n\tlset.nlayers = (int)layerId;\n\t\n\tlset.layers = (rcHeightfieldLayer*)rcAlloc(sizeof(rcHeightfieldLayer)*lset.nlayers, RC_ALLOC_PERM);\n\tif (!lset.layers)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: Out of memory 'layers' (%d).\", lset.nlayers);\n\t\treturn false;\n\t}\n\tmemset(lset.layers, 0, sizeof(rcHeightfieldLayer)*lset.nlayers);\n\n\t\n\t// Store layers.\n\tfor (int i = 0; i < lset.nlayers; ++i)\n\t{\n\t\tunsigned char curId = (unsigned char)i;\n\n\t\trcHeightfieldLayer* layer = &lset.layers[i];\n\n\t\tconst int gridSize = sizeof(unsigned char)*lw*lh;\n\n\t\tlayer->heights = (unsigned char*)rcAlloc(gridSize, RC_ALLOC_PERM);\n\t\tif (!layer->heights)\n\t\t{\n\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: Out of memory 'heights' (%d).\", gridSize);\n\t\t\treturn false;\n\t\t}\n\t\tmemset(layer->heights, 0xff, gridSize);\n\n\t\tlayer->areas = (unsigned char*)rcAlloc(gridSize, RC_ALLOC_PERM);\n\t\tif (!layer->areas)\n\t\t{\n\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: Out of memory 'areas' (%d).\", gridSize);\n\t\t\treturn false;\n\t\t}\n\t\tmemset(layer->areas, 0, gridSize);\n\n\t\tlayer->cons = (unsigned char*)rcAlloc(gridSize, RC_ALLOC_PERM);\n\t\tif (!layer->cons)\n\t\t{\n\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildHeightfieldLayers: Out of memory 'cons' (%d).\", gridSize);\n\t\t\treturn false;\n\t\t}\n\t\tmemset(layer->cons, 0, gridSize);\n\t\t\n\t\t// Find layer height bounds.\n\t\tint hmin = 0, hmax = 0;\n\t\tfor (int j = 0; j < nregs; ++j)\n\t\t{\n\t\t\tif (regs[j].base && regs[j].layerId == curId)\n\t\t\t{\n\t\t\t\thmin = (int)regs[j].ymin;\n\t\t\t\thmax = (int)regs[j].ymax;\n\t\t\t}\n\t\t}\n\n\t\tlayer->width = lw;\n\t\tlayer->height = lh;\n\t\tlayer->cs = chf.cs;\n\t\tlayer->ch = chf.ch;\n\t\t\n\t\t// Adjust the bbox to fit the heightfield.\n\t\trcVcopy(layer->bmin, bmin);\n\t\trcVcopy(layer->bmax, bmax);\n\t\tlayer->bmin[1] = bmin[1] + hmin*chf.ch;\n\t\tlayer->bmax[1] = bmin[1] + hmax*chf.ch;\n\t\tlayer->hmin = hmin;\n\t\tlayer->hmax = hmax;\n\n\t\t// Update usable data region.\n\t\tlayer->minx = layer->width;\n\t\tlayer->maxx = 0;\n\t\tlayer->miny = layer->height;\n\t\tlayer->maxy = 0;\n\t\t\n\t\t// Copy height and area from compact heightfield. \n\t\tfor (int y = 0; y < lh; ++y)\n\t\t{\n\t\t\tfor (int x = 0; x < lw; ++x)\n\t\t\t{\n\t\t\t\tconst int cx = borderSize+x;\n\t\t\t\tconst int cy = borderSize+y;\n\t\t\t\tconst rcCompactCell& c = chf.cells[cx+cy*w];\n\t\t\t\tfor (int j = (int)c.index, nj = (int)(c.index+c.count); j < nj; ++j)\n\t\t\t\t{\n\t\t\t\t\tconst rcCompactSpan& s = chf.spans[j];\n\t\t\t\t\t// Skip unassigned regions.\n\t\t\t\t\tif (srcReg[j] == 0xff)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t// Skip of does nto belong to current layer.\n\t\t\t\t\tunsigned char lid = regs[srcReg[j]].layerId;\n\t\t\t\t\tif (lid != curId)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\n\t\t\t\t\t// Update data bounds.\n\t\t\t\t\tlayer->minx = rcMin(layer->minx, x);\n\t\t\t\t\tlayer->maxx = rcMax(layer->maxx, x);\n\t\t\t\t\tlayer->miny = rcMin(layer->miny, y);\n\t\t\t\t\tlayer->maxy = rcMax(layer->maxy, y);\n\t\t\t\t\t\n\t\t\t\t\t// Store height and area type.\n\t\t\t\t\tconst int idx = x+y*lw;\n\t\t\t\t\tlayer->heights[idx] = (unsigned char)(s.y - hmin);\n\t\t\t\t\tlayer->areas[idx] = chf.areas[j];\n\t\t\t\t\t\n\t\t\t\t\t// Check connection.\n\t\t\t\t\tunsigned char portal = 0;\n\t\t\t\t\tunsigned char con = 0;\n\t\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst int ax = cx + rcGetDirOffsetX(dir);\n\t\t\t\t\t\t\tconst int ay = cy + rcGetDirOffsetY(dir);\n\t\t\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);\n\t\t\t\t\t\t\tunsigned char alid = srcReg[ai] != 0xff ? regs[srcReg[ai]].layerId : 0xff;\n\t\t\t\t\t\t\t// Portal mask\n\t\t\t\t\t\t\tif (chf.areas[ai] != RC_NULL_AREA && lid != alid)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tportal |= (unsigned char)(1<<dir);\n\t\t\t\t\t\t\t\t// Update height so that it matches on both sides of the portal.\n\t\t\t\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\t\t\t\tif (as.y > hmin)\n\t\t\t\t\t\t\t\t\tlayer->heights[idx] = rcMax(layer->heights[idx], (unsigned char)(as.y - hmin));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Valid connection mask\n\t\t\t\t\t\t\tif (chf.areas[ai] != RC_NULL_AREA && lid == alid)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tconst int nx = ax - borderSize;\n\t\t\t\t\t\t\t\tconst int ny = ay - borderSize;\n\t\t\t\t\t\t\t\tif (nx >= 0 && ny >= 0 && nx < lw && ny < lh)\n\t\t\t\t\t\t\t\t\tcon |= (unsigned char)(1<<dir);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tlayer->cons[idx] = (portal << 4) | con;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (layer->minx > layer->maxx)\n\t\t\tlayer->minx = layer->maxx = 0;\n\t\tif (layer->miny > layer->maxy)\n\t\t\tlayer->miny = layer->maxy = 0;\n\t}\n\t\n\treturn true;\n}\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastMesh.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#define _USE_MATH_DEFINES\n#include <math.h>\n#include <string.h>\n#include <stdio.h>\n#include \"Recast.h\"\n#include \"RecastAlloc.h\"\n#include \"RecastAssert.h\"\n\nstruct rcEdge\n{\n\tunsigned short vert[2];\n\tunsigned short polyEdge[2];\n\tunsigned short poly[2];\n};\n\nstatic bool buildMeshAdjacency(unsigned short* polys, const int npolys,\n\t\t\t\t\t\t\t   const int nverts, const int vertsPerPoly)\n{\n\t// Based on code by Eric Lengyel from:\n\t// http://www.terathon.com/code/edges.php\n\t\n\tint maxEdgeCount = npolys*vertsPerPoly;\n\tunsigned short* firstEdge = (unsigned short*)rcAlloc(sizeof(unsigned short)*(nverts + maxEdgeCount), RC_ALLOC_TEMP);\n\tif (!firstEdge)\n\t\treturn false;\n\tunsigned short* nextEdge = firstEdge + nverts;\n\tint edgeCount = 0;\n\t\n\trcEdge* edges = (rcEdge*)rcAlloc(sizeof(rcEdge)*maxEdgeCount, RC_ALLOC_TEMP);\n\tif (!edges)\n\t{\n\t\trcFree(firstEdge);\n\t\treturn false;\n\t}\n\t\n\tfor (int i = 0; i < nverts; i++)\n\t\tfirstEdge[i] = RC_MESH_NULL_IDX;\n\t\n\tfor (int i = 0; i < npolys; ++i)\n\t{\n\t\tunsigned short* t = &polys[i*vertsPerPoly*2];\n\t\tfor (int j = 0; j < vertsPerPoly; ++j)\n\t\t{\n\t\t\tif (t[j] == RC_MESH_NULL_IDX) break;\n\t\t\tunsigned short v0 = t[j];\n\t\t\tunsigned short v1 = (j+1 >= vertsPerPoly || t[j+1] == RC_MESH_NULL_IDX) ? t[0] : t[j+1];\n\t\t\tif (v0 < v1)\n\t\t\t{\n\t\t\t\trcEdge& edge = edges[edgeCount];\n\t\t\t\tedge.vert[0] = v0;\n\t\t\t\tedge.vert[1] = v1;\n\t\t\t\tedge.poly[0] = (unsigned short)i;\n\t\t\t\tedge.polyEdge[0] = (unsigned short)j;\n\t\t\t\tedge.poly[1] = (unsigned short)i;\n\t\t\t\tedge.polyEdge[1] = 0;\n\t\t\t\t// Insert edge\n\t\t\t\tnextEdge[edgeCount] = firstEdge[v0];\n\t\t\t\tfirstEdge[v0] = (unsigned short)edgeCount;\n\t\t\t\tedgeCount++;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfor (int i = 0; i < npolys; ++i)\n\t{\n\t\tunsigned short* t = &polys[i*vertsPerPoly*2];\n\t\tfor (int j = 0; j < vertsPerPoly; ++j)\n\t\t{\n\t\t\tif (t[j] == RC_MESH_NULL_IDX) break;\n\t\t\tunsigned short v0 = t[j];\n\t\t\tunsigned short v1 = (j+1 >= vertsPerPoly || t[j+1] == RC_MESH_NULL_IDX) ? t[0] : t[j+1];\n\t\t\tif (v0 > v1)\n\t\t\t{\n\t\t\t\tfor (unsigned short e = firstEdge[v1]; e != RC_MESH_NULL_IDX; e = nextEdge[e])\n\t\t\t\t{\n\t\t\t\t\trcEdge& edge = edges[e];\n\t\t\t\t\tif (edge.vert[1] == v0 && edge.poly[0] == edge.poly[1])\n\t\t\t\t\t{\n\t\t\t\t\t\tedge.poly[1] = (unsigned short)i;\n\t\t\t\t\t\tedge.polyEdge[1] = (unsigned short)j;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Store adjacency\n\tfor (int i = 0; i < edgeCount; ++i)\n\t{\n\t\tconst rcEdge& e = edges[i];\n\t\tif (e.poly[0] != e.poly[1])\n\t\t{\n\t\t\tunsigned short* p0 = &polys[e.poly[0]*vertsPerPoly*2];\n\t\t\tunsigned short* p1 = &polys[e.poly[1]*vertsPerPoly*2];\n\t\t\tp0[vertsPerPoly + e.polyEdge[0]] = e.poly[1];\n\t\t\tp1[vertsPerPoly + e.polyEdge[1]] = e.poly[0];\n\t\t}\n\t}\n\t\n\trcFree(firstEdge);\n\trcFree(edges);\n\t\n\treturn true;\n}\n\n\nstatic const int VERTEX_BUCKET_COUNT = (1<<12);\n\ninline int computeVertexHash(int x, int y, int z)\n{\n\tconst unsigned int h1 = 0x8da6b343; // Large multiplicative constants;\n\tconst unsigned int h2 = 0xd8163841; // here arbitrarily chosen primes\n\tconst unsigned int h3 = 0xcb1ab31f;\n\tunsigned int n = h1 * x + h2 * y + h3 * z;\n\treturn (int)(n & (VERTEX_BUCKET_COUNT-1));\n}\n\nstatic unsigned short addVertex(unsigned short x, unsigned short y, unsigned short z,\n\t\t\t\t\t\t\t\tunsigned short* verts, int* firstVert, int* nextVert, int& nv)\n{\n\tint bucket = computeVertexHash(x, 0, z);\n\tint i = firstVert[bucket];\n\t\n\twhile (i != -1)\n\t{\n\t\tconst unsigned short* v = &verts[i*3];\n\t\tif (v[0] == x && (rcAbs(v[1] - y) <= 2) && v[2] == z)\n\t\t\treturn (unsigned short)i;\n\t\ti = nextVert[i]; // next\n\t}\n\t\n\t// Could not find, create new.\n\ti = nv; nv++;\n\tunsigned short* v = &verts[i*3];\n\tv[0] = x;\n\tv[1] = y;\n\tv[2] = z;\n\tnextVert[i] = firstVert[bucket];\n\tfirstVert[bucket] = i;\n\t\n\treturn (unsigned short)i;\n}\n\n// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).\ninline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }\ninline int next(int i, int n) { return i+1 < n ? i+1 : 0; }\n\ninline int area2(const int* a, const int* b, const int* c)\n{\n\treturn (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]);\n}\n\n//\tExclusive or: true iff exactly one argument is true.\n//\tThe arguments are negated to ensure that they are 0/1\n//\tvalues.  Then the bitwise Xor operator may apply.\n//\t(This idea is due to Michael Baldwin.)\ninline bool xorb(bool x, bool y)\n{\n\treturn !x ^ !y;\n}\n\n// Returns true iff c is strictly to the left of the directed\n// line through a to b.\ninline bool left(const int* a, const int* b, const int* c)\n{\n\treturn area2(a, b, c) < 0;\n}\n\ninline bool leftOn(const int* a, const int* b, const int* c)\n{\n\treturn area2(a, b, c) <= 0;\n}\n\ninline bool collinear(const int* a, const int* b, const int* c)\n{\n\treturn area2(a, b, c) == 0;\n}\n\n//\tReturns true iff ab properly intersects cd: they share\n//\ta point interior to both segments.  The properness of the\n//\tintersection is ensured by using strict leftness.\nstatic bool intersectProp(const int* a, const int* b, const int* c, const int* d)\n{\n\t// Eliminate improper cases.\n\tif (collinear(a,b,c) || collinear(a,b,d) ||\n\t\tcollinear(c,d,a) || collinear(c,d,b))\n\t\treturn false;\n\t\n\treturn xorb(left(a,b,c), left(a,b,d)) && xorb(left(c,d,a), left(c,d,b));\n}\n\n// Returns T iff (a,b,c) are collinear and point c lies \n// on the closed segement ab.\nstatic bool between(const int* a, const int* b, const int* c)\n{\n\tif (!collinear(a, b, c))\n\t\treturn false;\n\t// If ab not vertical, check betweenness on x; else on y.\n\tif (a[0] != b[0])\n\t\treturn\t((a[0] <= c[0]) && (c[0] <= b[0])) || ((a[0] >= c[0]) && (c[0] >= b[0]));\n\telse\n\t\treturn\t((a[2] <= c[2]) && (c[2] <= b[2])) || ((a[2] >= c[2]) && (c[2] >= b[2]));\n}\n\n// Returns true iff segments ab and cd intersect, properly or improperly.\nstatic bool intersect(const int* a, const int* b, const int* c, const int* d)\n{\n\tif (intersectProp(a, b, c, d))\n\t\treturn true;\n\telse if (between(a, b, c) || between(a, b, d) ||\n\t\t\t between(c, d, a) || between(c, d, b))\n\t\treturn true;\n\telse\n\t\treturn false;\n}\n\nstatic bool vequal(const int* a, const int* b)\n{\n\treturn a[0] == b[0] && a[2] == b[2];\n}\n\n// Returns T iff (v_i, v_j) is a proper internal *or* external\n// diagonal of P, *ignoring edges incident to v_i and v_j*.\nstatic bool diagonalie(int i, int j, int n, const int* verts, int* indices)\n{\n\tconst int* d0 = &verts[(indices[i] & 0x0fffffff) * 4];\n\tconst int* d1 = &verts[(indices[j] & 0x0fffffff) * 4];\n\t\n\t// For each edge (k,k+1) of P\n\tfor (int k = 0; k < n; k++)\n\t{\n\t\tint k1 = next(k, n);\n\t\t// Skip edges incident to i or j\n\t\tif (!((k == i) || (k1 == i) || (k == j) || (k1 == j)))\n\t\t{\n\t\t\tconst int* p0 = &verts[(indices[k] & 0x0fffffff) * 4];\n\t\t\tconst int* p1 = &verts[(indices[k1] & 0x0fffffff) * 4];\n\n\t\t\tif (vequal(d0, p0) || vequal(d1, p0) || vequal(d0, p1) || vequal(d1, p1))\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\tif (intersect(d0, d1, p0, p1))\n\t\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n// Returns true iff the diagonal (i,j) is strictly internal to the \n// polygon P in the neighborhood of the i endpoint.\nstatic bool\tinCone(int i, int j, int n, const int* verts, int* indices)\n{\n\tconst int* pi = &verts[(indices[i] & 0x0fffffff) * 4];\n\tconst int* pj = &verts[(indices[j] & 0x0fffffff) * 4];\n\tconst int* pi1 = &verts[(indices[next(i, n)] & 0x0fffffff) * 4];\n\tconst int* pin1 = &verts[(indices[prev(i, n)] & 0x0fffffff) * 4];\n\n\t// If P[i] is a convex vertex [ i+1 left or on (i-1,i) ].\n\tif (leftOn(pin1, pi, pi1))\n\t\treturn left(pi, pj, pin1) && left(pj, pi, pi1);\n\t// Assume (i-1,i,i+1) not collinear.\n\t// else P[i] is reflex.\n\treturn !(leftOn(pi, pj, pi1) && leftOn(pj, pi, pin1));\n}\n\n// Returns T iff (v_i, v_j) is a proper internal\n// diagonal of P.\nstatic bool diagonal(int i, int j, int n, const int* verts, int* indices)\n{\n\treturn inCone(i, j, n, verts, indices) && diagonalie(i, j, n, verts, indices);\n}\n\n\nstatic bool diagonalieLoose(int i, int j, int n, const int* verts, int* indices)\n{\n\tconst int* d0 = &verts[(indices[i] & 0x0fffffff) * 4];\n\tconst int* d1 = &verts[(indices[j] & 0x0fffffff) * 4];\n\t\n\t// For each edge (k,k+1) of P\n\tfor (int k = 0; k < n; k++)\n\t{\n\t\tint k1 = next(k, n);\n\t\t// Skip edges incident to i or j\n\t\tif (!((k == i) || (k1 == i) || (k == j) || (k1 == j)))\n\t\t{\n\t\t\tconst int* p0 = &verts[(indices[k] & 0x0fffffff) * 4];\n\t\t\tconst int* p1 = &verts[(indices[k1] & 0x0fffffff) * 4];\n\t\t\t\n\t\t\tif (vequal(d0, p0) || vequal(d1, p0) || vequal(d0, p1) || vequal(d1, p1))\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\tif (intersectProp(d0, d1, p0, p1))\n\t\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nstatic bool\tinConeLoose(int i, int j, int n, const int* verts, int* indices)\n{\n\tconst int* pi = &verts[(indices[i] & 0x0fffffff) * 4];\n\tconst int* pj = &verts[(indices[j] & 0x0fffffff) * 4];\n\tconst int* pi1 = &verts[(indices[next(i, n)] & 0x0fffffff) * 4];\n\tconst int* pin1 = &verts[(indices[prev(i, n)] & 0x0fffffff) * 4];\n\t\n\t// If P[i] is a convex vertex [ i+1 left or on (i-1,i) ].\n\tif (leftOn(pin1, pi, pi1))\n\t\treturn leftOn(pi, pj, pin1) && leftOn(pj, pi, pi1);\n\t// Assume (i-1,i,i+1) not collinear.\n\t// else P[i] is reflex.\n\treturn !(leftOn(pi, pj, pi1) && leftOn(pj, pi, pin1));\n}\n\nstatic bool diagonalLoose(int i, int j, int n, const int* verts, int* indices)\n{\n\treturn inConeLoose(i, j, n, verts, indices) && diagonalieLoose(i, j, n, verts, indices);\n}\n\n\nstatic int triangulate(int n, const int* verts, int* indices, int* tris)\n{\n\tint ntris = 0;\n\tint* dst = tris;\n\t\n\t// The last bit of the index is used to indicate if the vertex can be removed.\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tint i1 = next(i, n);\n\t\tint i2 = next(i1, n);\n\t\tif (diagonal(i, i2, n, verts, indices))\n\t\t\tindices[i1] |= 0x80000000;\n\t}\n\t\n\twhile (n > 3)\n\t{\n\t\tint minLen = -1;\n\t\tint mini = -1;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tint i1 = next(i, n);\n\t\t\tif (indices[i1] & 0x80000000)\n\t\t\t{\n\t\t\t\tconst int* p0 = &verts[(indices[i] & 0x0fffffff) * 4];\n\t\t\t\tconst int* p2 = &verts[(indices[next(i1, n)] & 0x0fffffff) * 4];\n\t\t\t\t\n\t\t\t\tint dx = p2[0] - p0[0];\n\t\t\t\tint dy = p2[2] - p0[2];\n\t\t\t\tint len = dx*dx + dy*dy;\n\t\t\t\t\n\t\t\t\tif (minLen < 0 || len < minLen)\n\t\t\t\t{\n\t\t\t\t\tminLen = len;\n\t\t\t\t\tmini = i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (mini == -1)\n\t\t{\n\t\t\t// We might get here because the contour has overlapping segments, like this:\n\t\t\t//\n\t\t\t//  A o-o=====o---o B\n\t\t\t//   /  |C   D|    \\.\n\t\t\t//  o   o     o     o\n\t\t\t//  :   :     :     :\n\t\t\t// We'll try to recover by loosing up the inCone test a bit so that a diagonal\n\t\t\t// like A-B or C-D can be found and we can continue.\n\t\t\tminLen = -1;\n\t\t\tmini = -1;\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t{\n\t\t\t\tint i1 = next(i, n);\n\t\t\t\tint i2 = next(i1, n);\n\t\t\t\tif (diagonalLoose(i, i2, n, verts, indices))\n\t\t\t\t{\n\t\t\t\t\tconst int* p0 = &verts[(indices[i] & 0x0fffffff) * 4];\n\t\t\t\t\tconst int* p2 = &verts[(indices[next(i2, n)] & 0x0fffffff) * 4];\n\t\t\t\t\tint dx = p2[0] - p0[0];\n\t\t\t\t\tint dy = p2[2] - p0[2];\n\t\t\t\t\tint len = dx*dx + dy*dy;\n\t\t\t\t\t\n\t\t\t\t\tif (minLen < 0 || len < minLen)\n\t\t\t\t\t{\n\t\t\t\t\t\tminLen = len;\n\t\t\t\t\t\tmini = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (mini == -1)\n\t\t\t{\n\t\t\t\t// The contour is messed up. This sometimes happens\n\t\t\t\t// if the contour simplification is too aggressive.\n\t\t\t\treturn -ntris;\n\t\t\t}\n\t\t}\n\t\t\n\t\tint i = mini;\n\t\tint i1 = next(i, n);\n\t\tint i2 = next(i1, n);\n\t\t\n\t\t*dst++ = indices[i] & 0x0fffffff;\n\t\t*dst++ = indices[i1] & 0x0fffffff;\n\t\t*dst++ = indices[i2] & 0x0fffffff;\n\t\tntris++;\n\t\t\n\t\t// Removes P[i1] by copying P[i+1]...P[n-1] left one index.\n\t\tn--;\n\t\tfor (int k = i1; k < n; k++)\n\t\t\tindices[k] = indices[k+1];\n\t\t\n\t\tif (i1 >= n) i1 = 0;\n\t\ti = prev(i1,n);\n\t\t// Update diagonal flags.\n\t\tif (diagonal(prev(i, n), i1, n, verts, indices))\n\t\t\tindices[i] |= 0x80000000;\n\t\telse\n\t\t\tindices[i] &= 0x0fffffff;\n\t\t\n\t\tif (diagonal(i, next(i1, n), n, verts, indices))\n\t\t\tindices[i1] |= 0x80000000;\n\t\telse\n\t\t\tindices[i1] &= 0x0fffffff;\n\t}\n\t\n\t// Append the remaining triangle.\n\t*dst++ = indices[0] & 0x0fffffff;\n\t*dst++ = indices[1] & 0x0fffffff;\n\t*dst++ = indices[2] & 0x0fffffff;\n\tntris++;\n\t\n\treturn ntris;\n}\n\nstatic int countPolyVerts(const unsigned short* p, const int nvp)\n{\n\tfor (int i = 0; i < nvp; ++i)\n\t\tif (p[i] == RC_MESH_NULL_IDX)\n\t\t\treturn i;\n\treturn nvp;\n}\n\ninline bool uleft(const unsigned short* a, const unsigned short* b, const unsigned short* c)\n{\n\treturn ((int)b[0] - (int)a[0]) * ((int)c[2] - (int)a[2]) -\n\t\t   ((int)c[0] - (int)a[0]) * ((int)b[2] - (int)a[2]) < 0;\n}\n\nstatic int getPolyMergeValue(unsigned short* pa, unsigned short* pb,\n\t\t\t\t\t\t\t const unsigned short* verts, int& ea, int& eb,\n\t\t\t\t\t\t\t const int nvp)\n{\n\tconst int na = countPolyVerts(pa, nvp);\n\tconst int nb = countPolyVerts(pb, nvp);\n\t\n\t// If the merged polygon would be too big, do not merge.\n\tif (na+nb-2 > nvp)\n\t\treturn -1;\n\t\n\t// Check if the polygons share an edge.\n\tea = -1;\n\teb = -1;\n\t\n\tfor (int i = 0; i < na; ++i)\n\t{\n\t\tunsigned short va0 = pa[i];\n\t\tunsigned short va1 = pa[(i+1) % na];\n\t\tif (va0 > va1)\n\t\t\trcSwap(va0, va1);\n\t\tfor (int j = 0; j < nb; ++j)\n\t\t{\n\t\t\tunsigned short vb0 = pb[j];\n\t\t\tunsigned short vb1 = pb[(j+1) % nb];\n\t\t\tif (vb0 > vb1)\n\t\t\t\trcSwap(vb0, vb1);\n\t\t\tif (va0 == vb0 && va1 == vb1)\n\t\t\t{\n\t\t\t\tea = i;\n\t\t\t\teb = j;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// No common edge, cannot merge.\n\tif (ea == -1 || eb == -1)\n\t\treturn -1;\n\t\n\t// Check to see if the merged polygon would be convex.\n\tunsigned short va, vb, vc;\n\t\n\tva = pa[(ea+na-1) % na];\n\tvb = pa[ea];\n\tvc = pb[(eb+2) % nb];\n\tif (!uleft(&verts[va*3], &verts[vb*3], &verts[vc*3]))\n\t\treturn -1;\n\t\n\tva = pb[(eb+nb-1) % nb];\n\tvb = pb[eb];\n\tvc = pa[(ea+2) % na];\n\tif (!uleft(&verts[va*3], &verts[vb*3], &verts[vc*3]))\n\t\treturn -1;\n\t\n\tva = pa[ea];\n\tvb = pa[(ea+1)%na];\n\t\n\tint dx = (int)verts[va*3+0] - (int)verts[vb*3+0];\n\tint dy = (int)verts[va*3+2] - (int)verts[vb*3+2];\n\t\n\treturn dx*dx + dy*dy;\n}\n\nstatic void mergePolyVerts(unsigned short* pa, unsigned short* pb, int ea, int eb,\n\t\t\t\t\t\t   unsigned short* tmp, const int nvp)\n{\n\tconst int na = countPolyVerts(pa, nvp);\n\tconst int nb = countPolyVerts(pb, nvp);\n\t\n\t// Merge polygons.\n\tmemset(tmp, 0xff, sizeof(unsigned short)*nvp);\n\tint n = 0;\n\t// Add pa\n\tfor (int i = 0; i < na-1; ++i)\n\t\ttmp[n++] = pa[(ea+1+i) % na];\n\t// Add pb\n\tfor (int i = 0; i < nb-1; ++i)\n\t\ttmp[n++] = pb[(eb+1+i) % nb];\n\t\n\tmemcpy(pa, tmp, sizeof(unsigned short)*nvp);\n}\n\n\nstatic void pushFront(int v, int* arr, int& an)\n{\n\tan++;\n\tfor (int i = an-1; i > 0; --i) arr[i] = arr[i-1];\n\tarr[0] = v;\n}\n\nstatic void pushBack(int v, int* arr, int& an)\n{\n\tarr[an] = v;\n\tan++;\n}\n\nstatic bool canRemoveVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short rem)\n{\n\tconst int nvp = mesh.nvp;\n\t\n\t// Count number of polygons to remove.\n\tint numRemovedVerts = 0;\n\tint numTouchedVerts = 0;\n\tint numRemainingEdges = 0;\n\tfor (int i = 0; i < mesh.npolys; ++i)\n\t{\n\t\tunsigned short* p = &mesh.polys[i*nvp*2];\n\t\tconst int nv = countPolyVerts(p, nvp);\n\t\tint numRemoved = 0;\n\t\tint numVerts = 0;\n\t\tfor (int j = 0; j < nv; ++j)\n\t\t{\n\t\t\tif (p[j] == rem)\n\t\t\t{\n\t\t\t\tnumTouchedVerts++;\n\t\t\t\tnumRemoved++;\n\t\t\t}\n\t\t\tnumVerts++;\n\t\t}\n\t\tif (numRemoved)\n\t\t{\n\t\t\tnumRemovedVerts += numRemoved;\n\t\t\tnumRemainingEdges += numVerts-(numRemoved+1);\n\t\t}\n\t}\n\t\n\t// There would be too few edges remaining to create a polygon.\n\t// This can happen for example when a tip of a triangle is marked\n\t// as deletion, but there are no other polys that share the vertex.\n\t// In this case, the vertex should not be removed.\n\tif (numRemainingEdges <= 2)\n\t\treturn false;\n\t\n\t// Find edges which share the removed vertex.\n\tconst int maxEdges = numTouchedVerts*2;\n\tint nedges = 0;\n\trcScopedDelete<int> edges((int*)rcAlloc(sizeof(int)*maxEdges*3, RC_ALLOC_TEMP));\n\tif (!edges)\n\t{\n\t\tctx->log(RC_LOG_WARNING, \"canRemoveVertex: Out of memory 'edges' (%d).\", maxEdges*3);\n\t\treturn false;\n\t}\n\t\t\n\tfor (int i = 0; i < mesh.npolys; ++i)\n\t{\n\t\tunsigned short* p = &mesh.polys[i*nvp*2];\n\t\tconst int nv = countPolyVerts(p, nvp);\n\n\t\t// Collect edges which touches the removed vertex.\n\t\tfor (int j = 0, k = nv-1; j < nv; k = j++)\n\t\t{\n\t\t\tif (p[j] == rem || p[k] == rem)\n\t\t\t{\n\t\t\t\t// Arrange edge so that a=rem.\n\t\t\t\tint a = p[j], b = p[k];\n\t\t\t\tif (b == rem)\n\t\t\t\t\trcSwap(a,b);\n\t\t\t\t\t\n\t\t\t\t// Check if the edge exists\n\t\t\t\tbool exists = false;\n\t\t\t\tfor (int m = 0; m < nedges; ++m)\n\t\t\t\t{\n\t\t\t\t\tint* e = &edges[m*3];\n\t\t\t\t\tif (e[1] == b)\n\t\t\t\t\t{\n\t\t\t\t\t\t// Exists, increment vertex share count.\n\t\t\t\t\t\te[2]++;\n\t\t\t\t\t\texists = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Add new edge.\n\t\t\t\tif (!exists)\n\t\t\t\t{\n\t\t\t\t\tint* e = &edges[nedges*3];\n\t\t\t\t\te[0] = a;\n\t\t\t\t\te[1] = b;\n\t\t\t\t\te[2] = 1;\n\t\t\t\t\tnedges++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// There should be no more than 2 open edges.\n\t// This catches the case that two non-adjacent polygons\n\t// share the removed vertex. In that case, do not remove the vertex.\n\tint numOpenEdges = 0;\n\tfor (int i = 0; i < nedges; ++i)\n\t{\n\t\tif (edges[i*3+2] < 2)\n\t\t\tnumOpenEdges++;\n\t}\n\tif (numOpenEdges > 2)\n\t\treturn false;\n\t\n\treturn true;\n}\n\nstatic bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short rem, const int maxTris)\n{\n\tconst int nvp = mesh.nvp;\n\n\t// Count number of polygons to remove.\n\tint numRemovedVerts = 0;\n\tfor (int i = 0; i < mesh.npolys; ++i)\n\t{\n\t\tunsigned short* p = &mesh.polys[i*nvp*2];\n\t\tconst int nv = countPolyVerts(p, nvp);\n\t\tfor (int j = 0; j < nv; ++j)\n\t\t{\n\t\t\tif (p[j] == rem)\n\t\t\t\tnumRemovedVerts++;\n\t\t}\n\t}\n\t\n\tint nedges = 0;\n\trcScopedDelete<int> edges((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp*4, RC_ALLOC_TEMP));\n\tif (!edges)\n\t{\n\t\tctx->log(RC_LOG_WARNING, \"removeVertex: Out of memory 'edges' (%d).\", numRemovedVerts*nvp*4);\n\t\treturn false;\n\t}\n\n\tint nhole = 0;\n\trcScopedDelete<int> hole((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));\n\tif (!hole)\n\t{\n\t\tctx->log(RC_LOG_WARNING, \"removeVertex: Out of memory 'hole' (%d).\", numRemovedVerts*nvp);\n\t\treturn false;\n\t}\n\n\tint nhreg = 0;\n\trcScopedDelete<int> hreg((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));\n\tif (!hreg)\n\t{\n\t\tctx->log(RC_LOG_WARNING, \"removeVertex: Out of memory 'hreg' (%d).\", numRemovedVerts*nvp);\n\t\treturn false;\n\t}\n\n\tint nharea = 0;\n\trcScopedDelete<int> harea((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));\n\tif (!harea)\n\t{\n\t\tctx->log(RC_LOG_WARNING, \"removeVertex: Out of memory 'harea' (%d).\", numRemovedVerts*nvp);\n\t\treturn false;\n\t}\n\t\n\tfor (int i = 0; i < mesh.npolys; ++i)\n\t{\n\t\tunsigned short* p = &mesh.polys[i*nvp*2];\n\t\tconst int nv = countPolyVerts(p, nvp);\n\t\tbool hasRem = false;\n\t\tfor (int j = 0; j < nv; ++j)\n\t\t\tif (p[j] == rem) hasRem = true;\n\t\tif (hasRem)\n\t\t{\n\t\t\t// Collect edges which does not touch the removed vertex.\n\t\t\tfor (int j = 0, k = nv-1; j < nv; k = j++)\n\t\t\t{\n\t\t\t\tif (p[j] != rem && p[k] != rem)\n\t\t\t\t{\n\t\t\t\t\tint* e = &edges[nedges*4];\n\t\t\t\t\te[0] = p[k];\n\t\t\t\t\te[1] = p[j];\n\t\t\t\t\te[2] = mesh.regs[i];\n\t\t\t\t\te[3] = mesh.areas[i];\n\t\t\t\t\tnedges++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Remove the polygon.\n\t\t\tunsigned short* p2 = &mesh.polys[(mesh.npolys-1)*nvp*2];\n\t\t\tif (p != p2)\n\t\t\t\tmemcpy(p,p2,sizeof(unsigned short)*nvp);\n\t\t\tmemset(p+nvp,0xff,sizeof(unsigned short)*nvp);\n\t\t\tmesh.regs[i] = mesh.regs[mesh.npolys-1];\n\t\t\tmesh.areas[i] = mesh.areas[mesh.npolys-1];\n\t\t\tmesh.npolys--;\n\t\t\t--i;\n\t\t}\n\t}\n\t\n\t// Remove vertex.\n\tfor (int i = (int)rem; i < mesh.nverts - 1; ++i)\n\t{\n\t\tmesh.verts[i*3+0] = mesh.verts[(i+1)*3+0];\n\t\tmesh.verts[i*3+1] = mesh.verts[(i+1)*3+1];\n\t\tmesh.verts[i*3+2] = mesh.verts[(i+1)*3+2];\n\t}\n\tmesh.nverts--;\n\n\t// Adjust indices to match the removed vertex layout.\n\tfor (int i = 0; i < mesh.npolys; ++i)\n\t{\n\t\tunsigned short* p = &mesh.polys[i*nvp*2];\n\t\tconst int nv = countPolyVerts(p, nvp);\n\t\tfor (int j = 0; j < nv; ++j)\n\t\t\tif (p[j] > rem) p[j]--;\n\t}\n\tfor (int i = 0; i < nedges; ++i)\n\t{\n\t\tif (edges[i*4+0] > rem) edges[i*4+0]--;\n\t\tif (edges[i*4+1] > rem) edges[i*4+1]--;\n\t}\n\n\tif (nedges == 0)\n\t\treturn true;\n\n\t// Start with one vertex, keep appending connected\n\t// segments to the start and end of the hole.\n\tpushBack(edges[0], hole, nhole);\n\tpushBack(edges[2], hreg, nhreg);\n\tpushBack(edges[3], harea, nharea);\n\t\n\twhile (nedges)\n\t{\n\t\tbool match = false;\n\t\t\n\t\tfor (int i = 0; i < nedges; ++i)\n\t\t{\n\t\t\tconst int ea = edges[i*4+0];\n\t\t\tconst int eb = edges[i*4+1];\n\t\t\tconst int r = edges[i*4+2];\n\t\t\tconst int a = edges[i*4+3];\n\t\t\tbool add = false;\n\t\t\tif (hole[0] == eb)\n\t\t\t{\n\t\t\t\t// The segment matches the beginning of the hole boundary.\n\t\t\t\tpushFront(ea, hole, nhole);\n\t\t\t\tpushFront(r, hreg, nhreg);\n\t\t\t\tpushFront(a, harea, nharea);\n\t\t\t\tadd = true;\n\t\t\t}\n\t\t\telse if (hole[nhole-1] == ea)\n\t\t\t{\n\t\t\t\t// The segment matches the end of the hole boundary.\n\t\t\t\tpushBack(eb, hole, nhole);\n\t\t\t\tpushBack(r, hreg, nhreg);\n\t\t\t\tpushBack(a, harea, nharea);\n\t\t\t\tadd = true;\n\t\t\t}\n\t\t\tif (add)\n\t\t\t{\n\t\t\t\t// The edge segment was added, remove it.\n\t\t\t\tedges[i*4+0] = edges[(nedges-1)*4+0];\n\t\t\t\tedges[i*4+1] = edges[(nedges-1)*4+1];\n\t\t\t\tedges[i*4+2] = edges[(nedges-1)*4+2];\n\t\t\t\tedges[i*4+3] = edges[(nedges-1)*4+3];\n\t\t\t\t--nedges;\n\t\t\t\tmatch = true;\n\t\t\t\t--i;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (!match)\n\t\t\tbreak;\n\t}\n\n\trcScopedDelete<int> tris((int*)rcAlloc(sizeof(int)*nhole*3, RC_ALLOC_TEMP));\n\tif (!tris)\n\t{\n\t\tctx->log(RC_LOG_WARNING, \"removeVertex: Out of memory 'tris' (%d).\", nhole*3);\n\t\treturn false;\n\t}\n\n\trcScopedDelete<int> tverts((int*)rcAlloc(sizeof(int)*nhole*4, RC_ALLOC_TEMP));\n\tif (!tverts)\n\t{\n\t\tctx->log(RC_LOG_WARNING, \"removeVertex: Out of memory 'tverts' (%d).\", nhole*4);\n\t\treturn false;\n\t}\n\n\trcScopedDelete<int> thole((int*)rcAlloc(sizeof(int)*nhole, RC_ALLOC_TEMP));\n\tif (!thole)\n\t{\n\t\tctx->log(RC_LOG_WARNING, \"removeVertex: Out of memory 'thole' (%d).\", nhole);\n\t\treturn false;\n\t}\n\n\t// Generate temp vertex array for triangulation.\n\tfor (int i = 0; i < nhole; ++i)\n\t{\n\t\tconst int pi = hole[i];\n\t\ttverts[i*4+0] = mesh.verts[pi*3+0];\n\t\ttverts[i*4+1] = mesh.verts[pi*3+1];\n\t\ttverts[i*4+2] = mesh.verts[pi*3+2];\n\t\ttverts[i*4+3] = 0;\n\t\tthole[i] = i;\n\t}\n\n\t// Triangulate the hole.\n\tint ntris = triangulate(nhole, &tverts[0], &thole[0], tris);\n\tif (ntris < 0)\n\t{\n\t\tntris = -ntris;\n\t\tctx->log(RC_LOG_WARNING, \"removeVertex: triangulate() returned bad results.\");\n\t}\n\t\n\t// Merge the hole triangles back to polygons.\n\trcScopedDelete<unsigned short> polys((unsigned short*)rcAlloc(sizeof(unsigned short)*(ntris+1)*nvp, RC_ALLOC_TEMP));\n\tif (!polys)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"removeVertex: Out of memory 'polys' (%d).\", (ntris+1)*nvp);\n\t\treturn false;\n\t}\n\trcScopedDelete<unsigned short> pregs((unsigned short*)rcAlloc(sizeof(unsigned short)*ntris, RC_ALLOC_TEMP));\n\tif (!pregs)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"removeVertex: Out of memory 'pregs' (%d).\", ntris);\n\t\treturn false;\n\t}\n\trcScopedDelete<unsigned char> pareas((unsigned char*)rcAlloc(sizeof(unsigned char)*ntris, RC_ALLOC_TEMP));\n\tif (!pareas)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"removeVertex: Out of memory 'pareas' (%d).\", ntris);\n\t\treturn false;\n\t}\n\t\n\tunsigned short* tmpPoly = &polys[ntris*nvp];\n\t\t\t\n\t// Build initial polygons.\n\tint npolys = 0;\n\tmemset(polys, 0xff, ntris*nvp*sizeof(unsigned short));\n\tfor (int j = 0; j < ntris; ++j)\n\t{\n\t\tint* t = &tris[j*3];\n\t\tif (t[0] != t[1] && t[0] != t[2] && t[1] != t[2])\n\t\t{\n\t\t\tpolys[npolys*nvp+0] = (unsigned short)hole[t[0]];\n\t\t\tpolys[npolys*nvp+1] = (unsigned short)hole[t[1]];\n\t\t\tpolys[npolys*nvp+2] = (unsigned short)hole[t[2]];\n\n\t\t\t// If this polygon covers multiple region types then\n\t\t\t// mark it as such\n\t\t\tif (hreg[t[0]] != hreg[t[1]] || hreg[t[1]] != hreg[t[2]])\n\t\t\t\tpregs[npolys] = RC_MULTIPLE_REGS;\n\t\t\telse\n\t\t\t\tpregs[npolys] = (unsigned short)hreg[t[0]];\n\n\t\t\tpareas[npolys] = (unsigned char)harea[t[0]];\n\t\t\tnpolys++;\n\t\t}\n\t}\n\tif (!npolys)\n\t\treturn true;\n\t\n\t// Merge polygons.\n\tif (nvp > 3)\n\t{\n\t\tfor (;;)\n\t\t{\n\t\t\t// Find best polygons to merge.\n\t\t\tint bestMergeVal = 0;\n\t\t\tint bestPa = 0, bestPb = 0, bestEa = 0, bestEb = 0;\n\t\t\t\n\t\t\tfor (int j = 0; j < npolys-1; ++j)\n\t\t\t{\n\t\t\t\tunsigned short* pj = &polys[j*nvp];\n\t\t\t\tfor (int k = j+1; k < npolys; ++k)\n\t\t\t\t{\n\t\t\t\t\tunsigned short* pk = &polys[k*nvp];\n\t\t\t\t\tint ea, eb;\n\t\t\t\t\tint v = getPolyMergeValue(pj, pk, mesh.verts, ea, eb, nvp);\n\t\t\t\t\tif (v > bestMergeVal)\n\t\t\t\t\t{\n\t\t\t\t\t\tbestMergeVal = v;\n\t\t\t\t\t\tbestPa = j;\n\t\t\t\t\t\tbestPb = k;\n\t\t\t\t\t\tbestEa = ea;\n\t\t\t\t\t\tbestEb = eb;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (bestMergeVal > 0)\n\t\t\t{\n\t\t\t\t// Found best, merge.\n\t\t\t\tunsigned short* pa = &polys[bestPa*nvp];\n\t\t\t\tunsigned short* pb = &polys[bestPb*nvp];\n\t\t\t\tmergePolyVerts(pa, pb, bestEa, bestEb, tmpPoly, nvp);\n\t\t\t\tif (pregs[bestPa] != pregs[bestPb])\n\t\t\t\t\tpregs[bestPa] = RC_MULTIPLE_REGS;\n\n\t\t\t\tunsigned short* last = &polys[(npolys-1)*nvp];\n\t\t\t\tif (pb != last)\n\t\t\t\t\tmemcpy(pb, last, sizeof(unsigned short)*nvp);\n\t\t\t\tpregs[bestPb] = pregs[npolys-1];\n\t\t\t\tpareas[bestPb] = pareas[npolys-1];\n\t\t\t\tnpolys--;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// Could not merge any polygons, stop.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Store polygons.\n\tfor (int i = 0; i < npolys; ++i)\n\t{\n\t\tif (mesh.npolys >= maxTris) break;\n\t\tunsigned short* p = &mesh.polys[mesh.npolys*nvp*2];\n\t\tmemset(p,0xff,sizeof(unsigned short)*nvp*2);\n\t\tfor (int j = 0; j < nvp; ++j)\n\t\t\tp[j] = polys[i*nvp+j];\n\t\tmesh.regs[mesh.npolys] = pregs[i];\n\t\tmesh.areas[mesh.npolys] = pareas[i];\n\t\tmesh.npolys++;\n\t\tif (mesh.npolys > maxTris)\n\t\t{\n\t\t\tctx->log(RC_LOG_ERROR, \"removeVertex: Too many polygons %d (max:%d).\", mesh.npolys, maxTris);\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\treturn true;\n}\n\n/// @par\n///\n/// @note If the mesh data is to be used to construct a Detour navigation mesh, then the upper \n/// limit must be retricted to <= #DT_VERTS_PER_POLYGON.\n///\n/// @see rcAllocPolyMesh, rcContourSet, rcPolyMesh, rcConfig\nbool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMesh& mesh)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_BUILD_POLYMESH);\n\n\trcVcopy(mesh.bmin, cset.bmin);\n\trcVcopy(mesh.bmax, cset.bmax);\n\tmesh.cs = cset.cs;\n\tmesh.ch = cset.ch;\n\tmesh.borderSize = cset.borderSize;\n\tmesh.maxEdgeError = cset.maxError;\n\t\n\tint maxVertices = 0;\n\tint maxTris = 0;\n\tint maxVertsPerCont = 0;\n\tfor (int i = 0; i < cset.nconts; ++i)\n\t{\n\t\t// Skip null contours.\n\t\tif (cset.conts[i].nverts < 3) continue;\n\t\tmaxVertices += cset.conts[i].nverts;\n\t\tmaxTris += cset.conts[i].nverts - 2;\n\t\tmaxVertsPerCont = rcMax(maxVertsPerCont, cset.conts[i].nverts);\n\t}\n\t\n\tif (maxVertices >= 0xfffe)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Too many vertices %d.\", maxVertices);\n\t\treturn false;\n\t}\n\t\t\n\trcScopedDelete<unsigned char> vflags((unsigned char*)rcAlloc(sizeof(unsigned char)*maxVertices, RC_ALLOC_TEMP));\n\tif (!vflags)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'vflags' (%d).\", maxVertices);\n\t\treturn false;\n\t}\n\tmemset(vflags, 0, maxVertices);\n\t\n\tmesh.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxVertices*3, RC_ALLOC_PERM);\n\tif (!mesh.verts)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'mesh.verts' (%d).\", maxVertices);\n\t\treturn false;\n\t}\n\tmesh.polys = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxTris*nvp*2, RC_ALLOC_PERM);\n\tif (!mesh.polys)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'mesh.polys' (%d).\", maxTris*nvp*2);\n\t\treturn false;\n\t}\n\tmesh.regs = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxTris, RC_ALLOC_PERM);\n\tif (!mesh.regs)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'mesh.regs' (%d).\", maxTris);\n\t\treturn false;\n\t}\n\tmesh.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*maxTris, RC_ALLOC_PERM);\n\tif (!mesh.areas)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'mesh.areas' (%d).\", maxTris);\n\t\treturn false;\n\t}\n\t\n\tmesh.nverts = 0;\n\tmesh.npolys = 0;\n\tmesh.nvp = nvp;\n\tmesh.maxpolys = maxTris;\n\t\n\tmemset(mesh.verts, 0, sizeof(unsigned short)*maxVertices*3);\n\tmemset(mesh.polys, 0xff, sizeof(unsigned short)*maxTris*nvp*2);\n\tmemset(mesh.regs, 0, sizeof(unsigned short)*maxTris);\n\tmemset(mesh.areas, 0, sizeof(unsigned char)*maxTris);\n\t\n\trcScopedDelete<int> nextVert((int*)rcAlloc(sizeof(int)*maxVertices, RC_ALLOC_TEMP));\n\tif (!nextVert)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'nextVert' (%d).\", maxVertices);\n\t\treturn false;\n\t}\n\tmemset(nextVert, 0, sizeof(int)*maxVertices);\n\t\n\trcScopedDelete<int> firstVert((int*)rcAlloc(sizeof(int)*VERTEX_BUCKET_COUNT, RC_ALLOC_TEMP));\n\tif (!firstVert)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'firstVert' (%d).\", VERTEX_BUCKET_COUNT);\n\t\treturn false;\n\t}\n\tfor (int i = 0; i < VERTEX_BUCKET_COUNT; ++i)\n\t\tfirstVert[i] = -1;\n\t\n\trcScopedDelete<int> indices((int*)rcAlloc(sizeof(int)*maxVertsPerCont, RC_ALLOC_TEMP));\n\tif (!indices)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'indices' (%d).\", maxVertsPerCont);\n\t\treturn false;\n\t}\n\trcScopedDelete<int> tris((int*)rcAlloc(sizeof(int)*maxVertsPerCont*3, RC_ALLOC_TEMP));\n\tif (!tris)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'tris' (%d).\", maxVertsPerCont*3);\n\t\treturn false;\n\t}\n\trcScopedDelete<unsigned short> polys((unsigned short*)rcAlloc(sizeof(unsigned short)*(maxVertsPerCont+1)*nvp, RC_ALLOC_TEMP));\n\tif (!polys)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'polys' (%d).\", maxVertsPerCont*nvp);\n\t\treturn false;\n\t}\n\tunsigned short* tmpPoly = &polys[maxVertsPerCont*nvp];\n\n\tfor (int i = 0; i < cset.nconts; ++i)\n\t{\n\t\trcContour& cont = cset.conts[i];\n\t\t\n\t\t// Skip null contours.\n\t\tif (cont.nverts < 3)\n\t\t\tcontinue;\n\t\t\n\t\t// Triangulate contour\n\t\tfor (int j = 0; j < cont.nverts; ++j)\n\t\t\tindices[j] = j;\n\t\t\t\n\t\tint ntris = triangulate(cont.nverts, cont.verts, &indices[0], &tris[0]);\n\t\tif (ntris <= 0)\n\t\t{\n\t\t\t// Bad triangulation, should not happen.\n/*\t\t\tprintf(\"\\tconst float bmin[3] = {%ff,%ff,%ff};\\n\", cset.bmin[0], cset.bmin[1], cset.bmin[2]);\n\t\t\tprintf(\"\\tconst float cs = %ff;\\n\", cset.cs);\n\t\t\tprintf(\"\\tconst float ch = %ff;\\n\", cset.ch);\n\t\t\tprintf(\"\\tconst int verts[] = {\\n\");\n\t\t\tfor (int k = 0; k < cont.nverts; ++k)\n\t\t\t{\n\t\t\t\tconst int* v = &cont.verts[k*4];\n\t\t\t\tprintf(\"\\t\\t%d,%d,%d,%d,\\n\", v[0], v[1], v[2], v[3]);\n\t\t\t}\n\t\t\tprintf(\"\\t};\\n\\tconst int nverts = sizeof(verts)/(sizeof(int)*4);\\n\");*/\n\t\t\tctx->log(RC_LOG_WARNING, \"rcBuildPolyMesh: Bad triangulation Contour %d.\", i);\n\t\t\tntris = -ntris;\n\t\t}\n\t\t\t\t\n\t\t// Add and merge vertices.\n\t\tfor (int j = 0; j < cont.nverts; ++j)\n\t\t{\n\t\t\tconst int* v = &cont.verts[j*4];\n\t\t\tindices[j] = addVertex((unsigned short)v[0], (unsigned short)v[1], (unsigned short)v[2],\n\t\t\t\t\t\t\t\t   mesh.verts, firstVert, nextVert, mesh.nverts);\n\t\t\tif (v[3] & RC_BORDER_VERTEX)\n\t\t\t{\n\t\t\t\t// This vertex should be removed.\n\t\t\t\tvflags[indices[j]] = 1;\n\t\t\t}\n\t\t}\n\n\t\t// Build initial polygons.\n\t\tint npolys = 0;\n\t\tmemset(polys, 0xff, maxVertsPerCont*nvp*sizeof(unsigned short));\n\t\tfor (int j = 0; j < ntris; ++j)\n\t\t{\n\t\t\tint* t = &tris[j*3];\n\t\t\tif (t[0] != t[1] && t[0] != t[2] && t[1] != t[2])\n\t\t\t{\n\t\t\t\tpolys[npolys*nvp+0] = (unsigned short)indices[t[0]];\n\t\t\t\tpolys[npolys*nvp+1] = (unsigned short)indices[t[1]];\n\t\t\t\tpolys[npolys*nvp+2] = (unsigned short)indices[t[2]];\n\t\t\t\tnpolys++;\n\t\t\t}\n\t\t}\n\t\tif (!npolys)\n\t\t\tcontinue;\n\t\t\n\t\t// Merge polygons.\n\t\tif (nvp > 3)\n\t\t{\n\t\t\tfor(;;)\n\t\t\t{\n\t\t\t\t// Find best polygons to merge.\n\t\t\t\tint bestMergeVal = 0;\n\t\t\t\tint bestPa = 0, bestPb = 0, bestEa = 0, bestEb = 0;\n\t\t\t\t\n\t\t\t\tfor (int j = 0; j < npolys-1; ++j)\n\t\t\t\t{\n\t\t\t\t\tunsigned short* pj = &polys[j*nvp];\n\t\t\t\t\tfor (int k = j+1; k < npolys; ++k)\n\t\t\t\t\t{\n\t\t\t\t\t\tunsigned short* pk = &polys[k*nvp];\n\t\t\t\t\t\tint ea, eb;\n\t\t\t\t\t\tint v = getPolyMergeValue(pj, pk, mesh.verts, ea, eb, nvp);\n\t\t\t\t\t\tif (v > bestMergeVal)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbestMergeVal = v;\n\t\t\t\t\t\t\tbestPa = j;\n\t\t\t\t\t\t\tbestPb = k;\n\t\t\t\t\t\t\tbestEa = ea;\n\t\t\t\t\t\t\tbestEb = eb;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (bestMergeVal > 0)\n\t\t\t\t{\n\t\t\t\t\t// Found best, merge.\n\t\t\t\t\tunsigned short* pa = &polys[bestPa*nvp];\n\t\t\t\t\tunsigned short* pb = &polys[bestPb*nvp];\n\t\t\t\t\tmergePolyVerts(pa, pb, bestEa, bestEb, tmpPoly, nvp);\n\t\t\t\t\tunsigned short* lastPoly = &polys[(npolys-1)*nvp];\n\t\t\t\t\tif (pb != lastPoly)\n\t\t\t\t\t\tmemcpy(pb, lastPoly, sizeof(unsigned short)*nvp);\n\t\t\t\t\tnpolys--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// Could not merge any polygons, stop.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Store polygons.\n\t\tfor (int j = 0; j < npolys; ++j)\n\t\t{\n\t\t\tunsigned short* p = &mesh.polys[mesh.npolys*nvp*2];\n\t\t\tunsigned short* q = &polys[j*nvp];\n\t\t\tfor (int k = 0; k < nvp; ++k)\n\t\t\t\tp[k] = q[k];\n\t\t\tmesh.regs[mesh.npolys] = cont.reg;\n\t\t\tmesh.areas[mesh.npolys] = cont.area;\n\t\t\tmesh.npolys++;\n\t\t\tif (mesh.npolys > maxTris)\n\t\t\t{\n\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Too many polygons %d (max:%d).\", mesh.npolys, maxTris);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t\n\t// Remove edge vertices.\n\tfor (int i = 0; i < mesh.nverts; ++i)\n\t{\n\t\tif (vflags[i])\n\t\t{\n\t\t\tif (!canRemoveVertex(ctx, mesh, (unsigned short)i))\n\t\t\t\tcontinue;\n\t\t\tif (!removeVertex(ctx, mesh, (unsigned short)i, maxTris))\n\t\t\t{\n\t\t\t\t// Failed to remove vertex\n\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Failed to remove edge vertex %d.\", i);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// Remove vertex\n\t\t\t// Note: mesh.nverts is already decremented inside removeVertex()!\n\t\t\t// Fixup vertex flags\n\t\t\tfor (int j = i; j < mesh.nverts; ++j)\n\t\t\t\tvflags[j] = vflags[j+1];\n\t\t\t--i;\n\t\t}\n\t}\n\t\n\t// Calculate adjacency.\n\tif (!buildMeshAdjacency(mesh.polys, mesh.npolys, mesh.nverts, nvp))\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Adjacency failed.\");\n\t\treturn false;\n\t}\n\t\n\t// Find portal edges\n\tif (mesh.borderSize > 0)\n\t{\n\t\tconst int w = cset.width;\n\t\tconst int h = cset.height;\n\t\tfor (int i = 0; i < mesh.npolys; ++i)\n\t\t{\n\t\t\tunsigned short* p = &mesh.polys[i*2*nvp];\n\t\t\tfor (int j = 0; j < nvp; ++j)\n\t\t\t{\n\t\t\t\tif (p[j] == RC_MESH_NULL_IDX) break;\n\t\t\t\t// Skip connected edges.\n\t\t\t\tif (p[nvp+j] != RC_MESH_NULL_IDX)\n\t\t\t\t\tcontinue;\n\t\t\t\tint nj = j+1;\n\t\t\t\tif (nj >= nvp || p[nj] == RC_MESH_NULL_IDX) nj = 0;\n\t\t\t\tconst unsigned short* va = &mesh.verts[p[j]*3];\n\t\t\t\tconst unsigned short* vb = &mesh.verts[p[nj]*3];\n\n\t\t\t\tif ((int)va[0] == 0 && (int)vb[0] == 0)\n\t\t\t\t\tp[nvp+j] = 0x8000 | 0;\n\t\t\t\telse if ((int)va[2] == h && (int)vb[2] == h)\n\t\t\t\t\tp[nvp+j] = 0x8000 | 1;\n\t\t\t\telse if ((int)va[0] == w && (int)vb[0] == w)\n\t\t\t\t\tp[nvp+j] = 0x8000 | 2;\n\t\t\t\telse if ((int)va[2] == 0 && (int)vb[2] == 0)\n\t\t\t\t\tp[nvp+j] = 0x8000 | 3;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Just allocate the mesh flags array. The user is resposible to fill it.\n\tmesh.flags = (unsigned short*)rcAlloc(sizeof(unsigned short)*mesh.npolys, RC_ALLOC_PERM);\n\tif (!mesh.flags)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: Out of memory 'mesh.flags' (%d).\", mesh.npolys);\n\t\treturn false;\n\t}\n\tmemset(mesh.flags, 0, sizeof(unsigned short) * mesh.npolys);\n\t\n\tif (mesh.nverts > 0xffff)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: The resulting mesh has too many vertices %d (max %d). Data can be corrupted.\", mesh.nverts, 0xffff);\n\t}\n\tif (mesh.npolys > 0xffff)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMesh: The resulting mesh has too many polygons %d (max %d). Data can be corrupted.\", mesh.npolys, 0xffff);\n\t}\n\t\n\treturn true;\n}\n\n/// @see rcAllocPolyMesh, rcPolyMesh\nbool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, rcPolyMesh& mesh)\n{\n\trcAssert(ctx);\n\t\n\tif (!nmeshes || !meshes)\n\t\treturn true;\n\n\trcScopedTimer timer(ctx, RC_TIMER_MERGE_POLYMESH);\n\n\tmesh.nvp = meshes[0]->nvp;\n\tmesh.cs = meshes[0]->cs;\n\tmesh.ch = meshes[0]->ch;\n\trcVcopy(mesh.bmin, meshes[0]->bmin);\n\trcVcopy(mesh.bmax, meshes[0]->bmax);\n\n\tint maxVerts = 0;\n\tint maxPolys = 0;\n\tint maxVertsPerMesh = 0;\n\tfor (int i = 0; i < nmeshes; ++i)\n\t{\n\t\trcVmin(mesh.bmin, meshes[i]->bmin);\n\t\trcVmax(mesh.bmax, meshes[i]->bmax);\n\t\tmaxVertsPerMesh = rcMax(maxVertsPerMesh, meshes[i]->nverts);\n\t\tmaxVerts += meshes[i]->nverts;\n\t\tmaxPolys += meshes[i]->npolys;\n\t}\n\t\n\tmesh.nverts = 0;\n\tmesh.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxVerts*3, RC_ALLOC_PERM);\n\tif (!mesh.verts)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: Out of memory 'mesh.verts' (%d).\", maxVerts*3);\n\t\treturn false;\n\t}\n\n\tmesh.npolys = 0;\n\tmesh.polys = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxPolys*2*mesh.nvp, RC_ALLOC_PERM);\n\tif (!mesh.polys)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: Out of memory 'mesh.polys' (%d).\", maxPolys*2*mesh.nvp);\n\t\treturn false;\n\t}\n\tmemset(mesh.polys, 0xff, sizeof(unsigned short)*maxPolys*2*mesh.nvp);\n\n\tmesh.regs = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxPolys, RC_ALLOC_PERM);\n\tif (!mesh.regs)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: Out of memory 'mesh.regs' (%d).\", maxPolys);\n\t\treturn false;\n\t}\n\tmemset(mesh.regs, 0, sizeof(unsigned short)*maxPolys);\n\n\tmesh.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*maxPolys, RC_ALLOC_PERM);\n\tif (!mesh.areas)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: Out of memory 'mesh.areas' (%d).\", maxPolys);\n\t\treturn false;\n\t}\n\tmemset(mesh.areas, 0, sizeof(unsigned char)*maxPolys);\n\n\tmesh.flags = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxPolys, RC_ALLOC_PERM);\n\tif (!mesh.flags)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: Out of memory 'mesh.flags' (%d).\", maxPolys);\n\t\treturn false;\n\t}\n\tmemset(mesh.flags, 0, sizeof(unsigned short)*maxPolys);\n\t\n\trcScopedDelete<int> nextVert((int*)rcAlloc(sizeof(int)*maxVerts, RC_ALLOC_TEMP));\n\tif (!nextVert)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: Out of memory 'nextVert' (%d).\", maxVerts);\n\t\treturn false;\n\t}\n\tmemset(nextVert, 0, sizeof(int)*maxVerts);\n\t\n\trcScopedDelete<int> firstVert((int*)rcAlloc(sizeof(int)*VERTEX_BUCKET_COUNT, RC_ALLOC_TEMP));\n\tif (!firstVert)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: Out of memory 'firstVert' (%d).\", VERTEX_BUCKET_COUNT);\n\t\treturn false;\n\t}\n\tfor (int i = 0; i < VERTEX_BUCKET_COUNT; ++i)\n\t\tfirstVert[i] = -1;\n\n\trcScopedDelete<unsigned short> vremap((unsigned short*)rcAlloc(sizeof(unsigned short)*maxVertsPerMesh, RC_ALLOC_PERM));\n\tif (!vremap)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: Out of memory 'vremap' (%d).\", maxVertsPerMesh);\n\t\treturn false;\n\t}\n\tmemset(vremap, 0, sizeof(unsigned short)*maxVertsPerMesh);\n\t\n\tfor (int i = 0; i < nmeshes; ++i)\n\t{\n\t\tconst rcPolyMesh* pmesh = meshes[i];\n\t\t\n\t\tconst unsigned short ox = (unsigned short)floorf((pmesh->bmin[0]-mesh.bmin[0])/mesh.cs+0.5f);\n\t\tconst unsigned short oz = (unsigned short)floorf((pmesh->bmin[2]-mesh.bmin[2])/mesh.cs+0.5f);\n\t\t\n\t\tbool isMinX = (ox == 0);\n\t\tbool isMinZ = (oz == 0);\n\t\tbool isMaxX = ((unsigned short)floorf((mesh.bmax[0] - pmesh->bmax[0]) / mesh.cs + 0.5f)) == 0;\n\t\tbool isMaxZ = ((unsigned short)floorf((mesh.bmax[2] - pmesh->bmax[2]) / mesh.cs + 0.5f)) == 0;\n\t\tbool isOnBorder = (isMinX || isMinZ || isMaxX || isMaxZ);\n\n\t\tfor (int j = 0; j < pmesh->nverts; ++j)\n\t\t{\n\t\t\tunsigned short* v = &pmesh->verts[j*3];\n\t\t\tvremap[j] = addVertex(v[0]+ox, v[1], v[2]+oz,\n\t\t\t\t\t\t\t\t  mesh.verts, firstVert, nextVert, mesh.nverts);\n\t\t}\n\t\t\n\t\tfor (int j = 0; j < pmesh->npolys; ++j)\n\t\t{\n\t\t\tunsigned short* tgt = &mesh.polys[mesh.npolys*2*mesh.nvp];\n\t\t\tunsigned short* src = &pmesh->polys[j*2*mesh.nvp];\n\t\t\tmesh.regs[mesh.npolys] = pmesh->regs[j];\n\t\t\tmesh.areas[mesh.npolys] = pmesh->areas[j];\n\t\t\tmesh.flags[mesh.npolys] = pmesh->flags[j];\n\t\t\tmesh.npolys++;\n\t\t\tfor (int k = 0; k < mesh.nvp; ++k)\n\t\t\t{\n\t\t\t\tif (src[k] == RC_MESH_NULL_IDX) break;\n\t\t\t\ttgt[k] = vremap[src[k]];\n\t\t\t}\n\n\t\t\tif (isOnBorder)\n\t\t\t{\n\t\t\t\tfor (int k = mesh.nvp; k < mesh.nvp * 2; ++k)\n\t\t\t\t{\n\t\t\t\t\tif (src[k] & 0x8000 && src[k] != 0xffff)\n\t\t\t\t\t{\n\t\t\t\t\t\tunsigned short dir = src[k] & 0xf;\n\t\t\t\t\t\tswitch (dir)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase 0: // Portal x-\n\t\t\t\t\t\t\t\tif (isMinX)\n\t\t\t\t\t\t\t\t\ttgt[k] = src[k];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 1: // Portal z+\n\t\t\t\t\t\t\t\tif (isMaxZ)\n\t\t\t\t\t\t\t\t\ttgt[k] = src[k];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 2: // Portal x+\n\t\t\t\t\t\t\t\tif (isMaxX)\n\t\t\t\t\t\t\t\t\ttgt[k] = src[k];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 3: // Portal z-\n\t\t\t\t\t\t\t\tif (isMinZ)\n\t\t\t\t\t\t\t\t\ttgt[k] = src[k];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Calculate adjacency.\n\tif (!buildMeshAdjacency(mesh.polys, mesh.npolys, mesh.nverts, mesh.nvp))\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: Adjacency failed.\");\n\t\treturn false;\n\t}\n\n\tif (mesh.nverts > 0xffff)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: The resulting mesh has too many vertices %d (max %d). Data can be corrupted.\", mesh.nverts, 0xffff);\n\t}\n\tif (mesh.npolys > 0xffff)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcMergePolyMeshes: The resulting mesh has too many polygons %d (max %d). Data can be corrupted.\", mesh.npolys, 0xffff);\n\t}\n\t\n\treturn true;\n}\n\nbool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst)\n{\n\trcAssert(ctx);\n\t\n\t// Destination must be empty.\n\trcAssert(dst.verts == 0);\n\trcAssert(dst.polys == 0);\n\trcAssert(dst.regs == 0);\n\trcAssert(dst.areas == 0);\n\trcAssert(dst.flags == 0);\n\t\n\tdst.nverts = src.nverts;\n\tdst.npolys = src.npolys;\n\tdst.maxpolys = src.npolys;\n\tdst.nvp = src.nvp;\n\trcVcopy(dst.bmin, src.bmin);\n\trcVcopy(dst.bmax, src.bmax);\n\tdst.cs = src.cs;\n\tdst.ch = src.ch;\n\tdst.borderSize = src.borderSize;\n\tdst.maxEdgeError = src.maxEdgeError;\n\t\n\tdst.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.nverts*3, RC_ALLOC_PERM);\n\tif (!dst.verts)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcCopyPolyMesh: Out of memory 'dst.verts' (%d).\", src.nverts*3);\n\t\treturn false;\n\t}\n\tmemcpy(dst.verts, src.verts, sizeof(unsigned short)*src.nverts*3);\n\t\n\tdst.polys = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.npolys*2*src.nvp, RC_ALLOC_PERM);\n\tif (!dst.polys)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcCopyPolyMesh: Out of memory 'dst.polys' (%d).\", src.npolys*2*src.nvp);\n\t\treturn false;\n\t}\n\tmemcpy(dst.polys, src.polys, sizeof(unsigned short)*src.npolys*2*src.nvp);\n\t\n\tdst.regs = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.npolys, RC_ALLOC_PERM);\n\tif (!dst.regs)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcCopyPolyMesh: Out of memory 'dst.regs' (%d).\", src.npolys);\n\t\treturn false;\n\t}\n\tmemcpy(dst.regs, src.regs, sizeof(unsigned short)*src.npolys);\n\t\n\tdst.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*src.npolys, RC_ALLOC_PERM);\n\tif (!dst.areas)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcCopyPolyMesh: Out of memory 'dst.areas' (%d).\", src.npolys);\n\t\treturn false;\n\t}\n\tmemcpy(dst.areas, src.areas, sizeof(unsigned char)*src.npolys);\n\t\n\tdst.flags = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.npolys, RC_ALLOC_PERM);\n\tif (!dst.flags)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcCopyPolyMesh: Out of memory 'dst.flags' (%d).\", src.npolys);\n\t\treturn false;\n\t}\n\tmemcpy(dst.flags, src.flags, sizeof(unsigned short)*src.npolys);\n\t\n\treturn true;\n}\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastMeshDetail.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#include <float.h>\n#define _USE_MATH_DEFINES\n#include <math.h>\n#include <string.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include \"Recast.h\"\n#include \"RecastAlloc.h\"\n#include \"RecastAssert.h\"\n\n\nstatic const unsigned RC_UNSET_HEIGHT = 0xffff;\n\nstruct rcHeightPatch\n{\n\tinline rcHeightPatch() : data(0), xmin(0), ymin(0), width(0), height(0) {}\n\tinline ~rcHeightPatch() { rcFree(data); }\n\tunsigned short* data;\n\tint xmin, ymin, width, height;\n};\n\n\ninline float vdot2(const float* a, const float* b)\n{\n\treturn a[0]*b[0] + a[2]*b[2];\n}\n\ninline float vdistSq2(const float* p, const float* q)\n{\n\tconst float dx = q[0] - p[0];\n\tconst float dy = q[2] - p[2];\n\treturn dx*dx + dy*dy;\n}\n\ninline float vdist2(const float* p, const float* q)\n{\n\treturn sqrtf(vdistSq2(p,q));\n}\n\ninline float vcross2(const float* p1, const float* p2, const float* p3)\n{\n\tconst float u1 = p2[0] - p1[0];\n\tconst float v1 = p2[2] - p1[2];\n\tconst float u2 = p3[0] - p1[0];\n\tconst float v2 = p3[2] - p1[2];\n\treturn u1 * v2 - v1 * u2;\n}\n\nstatic bool circumCircle(const float* p1, const float* p2, const float* p3,\n\t\t\t\t\t\t float* c, float& r)\n{\n\tstatic const float EPS = 1e-6f;\n\t// Calculate the circle relative to p1, to avoid some precision issues.\n\tconst float v1[3] = {0,0,0};\n\tfloat v2[3], v3[3];\n\trcVsub(v2, p2,p1);\n\trcVsub(v3, p3,p1);\n\t\n\tconst float cp = vcross2(v1, v2, v3);\n\tif (fabsf(cp) > EPS)\n\t{\n\t\tconst float v1Sq = vdot2(v1,v1);\n\t\tconst float v2Sq = vdot2(v2,v2);\n\t\tconst float v3Sq = vdot2(v3,v3);\n\t\tc[0] = (v1Sq*(v2[2]-v3[2]) + v2Sq*(v3[2]-v1[2]) + v3Sq*(v1[2]-v2[2])) / (2*cp);\n\t\tc[1] = 0;\n\t\tc[2] = (v1Sq*(v3[0]-v2[0]) + v2Sq*(v1[0]-v3[0]) + v3Sq*(v2[0]-v1[0])) / (2*cp);\n\t\tr = vdist2(c, v1);\n\t\trcVadd(c, c, p1);\n\t\treturn true;\n\t}\n\t\n\trcVcopy(c, p1);\n\tr = 0;\n\treturn false;\n}\n\nstatic float distPtTri(const float* p, const float* a, const float* b, const float* c)\n{\n\tfloat v0[3], v1[3], v2[3];\n\trcVsub(v0, c,a);\n\trcVsub(v1, b,a);\n\trcVsub(v2, p,a);\n\t\n\tconst float dot00 = vdot2(v0, v0);\n\tconst float dot01 = vdot2(v0, v1);\n\tconst float dot02 = vdot2(v0, v2);\n\tconst float dot11 = vdot2(v1, v1);\n\tconst float dot12 = vdot2(v1, v2);\n\t\n\t// Compute barycentric coordinates\n\tconst float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01);\n\tconst float u = (dot11 * dot02 - dot01 * dot12) * invDenom;\n\tfloat v = (dot00 * dot12 - dot01 * dot02) * invDenom;\n\t\n\t// If point lies inside the triangle, return interpolated y-coord.\n\tstatic const float EPS = 1e-4f;\n\tif (u >= -EPS && v >= -EPS && (u+v) <= 1+EPS)\n\t{\n\t\tconst float y = a[1] + v0[1]*u + v1[1]*v;\n\t\treturn fabsf(y-p[1]);\n\t}\n\treturn FLT_MAX;\n}\n\nstatic float distancePtSeg(const float* pt, const float* p, const float* q)\n{\n\tfloat pqx = q[0] - p[0];\n\tfloat pqy = q[1] - p[1];\n\tfloat pqz = q[2] - p[2];\n\tfloat dx = pt[0] - p[0];\n\tfloat dy = pt[1] - p[1];\n\tfloat dz = pt[2] - p[2];\n\tfloat d = pqx*pqx + pqy*pqy + pqz*pqz;\n\tfloat t = pqx*dx + pqy*dy + pqz*dz;\n\tif (d > 0)\n\t\tt /= d;\n\tif (t < 0)\n\t\tt = 0;\n\telse if (t > 1)\n\t\tt = 1;\n\t\n\tdx = p[0] + t*pqx - pt[0];\n\tdy = p[1] + t*pqy - pt[1];\n\tdz = p[2] + t*pqz - pt[2];\n\t\n\treturn dx*dx + dy*dy + dz*dz;\n}\n\nstatic float distancePtSeg2d(const float* pt, const float* p, const float* q)\n{\n\tfloat pqx = q[0] - p[0];\n\tfloat pqz = q[2] - p[2];\n\tfloat dx = pt[0] - p[0];\n\tfloat dz = pt[2] - p[2];\n\tfloat d = pqx*pqx + pqz*pqz;\n\tfloat t = pqx*dx + pqz*dz;\n\tif (d > 0)\n\t\tt /= d;\n\tif (t < 0)\n\t\tt = 0;\n\telse if (t > 1)\n\t\tt = 1;\n\t\n\tdx = p[0] + t*pqx - pt[0];\n\tdz = p[2] + t*pqz - pt[2];\n\t\n\treturn dx*dx + dz*dz;\n}\n\nstatic float distToTriMesh(const float* p, const float* verts, const int /*nverts*/, const int* tris, const int ntris)\n{\n\tfloat dmin = FLT_MAX;\n\tfor (int i = 0; i < ntris; ++i)\n\t{\n\t\tconst float* va = &verts[tris[i*4+0]*3];\n\t\tconst float* vb = &verts[tris[i*4+1]*3];\n\t\tconst float* vc = &verts[tris[i*4+2]*3];\n\t\tfloat d = distPtTri(p, va,vb,vc);\n\t\tif (d < dmin)\n\t\t\tdmin = d;\n\t}\n\tif (dmin == FLT_MAX) return -1;\n\treturn dmin;\n}\n\nstatic float distToPoly(int nvert, const float* verts, const float* p)\n{\n\t\n\tfloat dmin = FLT_MAX;\n\tint i, j, c = 0;\n\tfor (i = 0, j = nvert-1; i < nvert; j = i++)\n\t{\n\t\tconst float* vi = &verts[i*3];\n\t\tconst float* vj = &verts[j*3];\n\t\tif (((vi[2] > p[2]) != (vj[2] > p[2])) &&\n\t\t\t(p[0] < (vj[0]-vi[0]) * (p[2]-vi[2]) / (vj[2]-vi[2]) + vi[0]) )\n\t\t\tc = !c;\n\t\tdmin = rcMin(dmin, distancePtSeg2d(p, vj, vi));\n\t}\n\treturn c ? -dmin : dmin;\n}\n\n\nstatic unsigned short getHeight(const float fx, const float fy, const float fz,\n\t\t\t\t\t\t\t\tconst float /*cs*/, const float ics, const float ch,\n\t\t\t\t\t\t\t\tconst int radius, const rcHeightPatch& hp)\n{\n\tint ix = (int)floorf(fx*ics + 0.01f);\n\tint iz = (int)floorf(fz*ics + 0.01f);\n\tix = rcClamp(ix-hp.xmin, 0, hp.width - 1);\n\tiz = rcClamp(iz-hp.ymin, 0, hp.height - 1);\n\tunsigned short h = hp.data[ix+iz*hp.width];\n\tif (h == RC_UNSET_HEIGHT)\n\t{\n\t\t// Special case when data might be bad.\n\t\t// Walk adjacent cells in a spiral up to 'radius', and look\n\t\t// for a pixel which has a valid height.\n\t\tint x = 1, z = 0, dx = 1, dz = 0;\n\t\tint maxSize = radius * 2 + 1;\n\t\tint maxIter = maxSize * maxSize - 1;\n\n\t\tint nextRingIterStart = 8;\n\t\tint nextRingIters = 16;\n\n\t\tfloat dmin = FLT_MAX;\n\t\tfor (int i = 0; i < maxIter; i++)\n\t\t{\n\t\t\tconst int nx = ix + x;\n\t\t\tconst int nz = iz + z;\n\n\t\t\tif (nx >= 0 && nz >= 0 && nx < hp.width && nz < hp.height)\n\t\t\t{\n\t\t\t\tconst unsigned short nh = hp.data[nx + nz*hp.width];\n\t\t\t\tif (nh != RC_UNSET_HEIGHT)\n\t\t\t\t{\n\t\t\t\t\tconst float d = fabsf(nh*ch - fy);\n\t\t\t\t\tif (d < dmin)\n\t\t\t\t\t{\n\t\t\t\t\t\th = nh;\n\t\t\t\t\t\tdmin = d;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// We are searching in a grid which looks approximately like this:\n\t\t\t//  __________\n\t\t\t// |2 ______ 2|\n\t\t\t// | |1 __ 1| |\n\t\t\t// | | |__| | |\n\t\t\t// | |______| |\n\t\t\t// |__________|\n\t\t\t// We want to find the best height as close to the center cell as possible. This means that\n\t\t\t// if we find a height in one of the neighbor cells to the center, we don't want to\n\t\t\t// expand further out than the 8 neighbors - we want to limit our search to the closest\n\t\t\t// of these \"rings\", but the best height in the ring.\n\t\t\t// For example, the center is just 1 cell. We checked that at the entrance to the function.\n\t\t\t// The next \"ring\" contains 8 cells (marked 1 above). Those are all the neighbors to the center cell.\n\t\t\t// The next one again contains 16 cells (marked 2). In general each ring has 8 additional cells, which\n\t\t\t// can be thought of as adding 2 cells around the \"center\" of each side when we expand the ring.\n\t\t\t// Here we detect if we are about to enter the next ring, and if we are and we have found\n\t\t\t// a height, we abort the search.\n\t\t\tif (i + 1 == nextRingIterStart)\n\t\t\t{\n\t\t\t\tif (h != RC_UNSET_HEIGHT)\n\t\t\t\t\tbreak;\n\n\t\t\t\tnextRingIterStart += nextRingIters;\n\t\t\t\tnextRingIters += 8;\n\t\t\t}\n\n\t\t\tif ((x == z) || ((x < 0) && (x == -z)) || ((x > 0) && (x == 1 - z)))\n\t\t\t{\n\t\t\t\tint tmp = dx;\n\t\t\t\tdx = -dz;\n\t\t\t\tdz = tmp;\n\t\t\t}\n\t\t\tx += dx;\n\t\t\tz += dz;\n\t\t}\n\t}\n\treturn h;\n}\n\n\nenum EdgeValues\n{\n\tEV_UNDEF = -1,\n\tEV_HULL = -2,\n};\n\nstatic int findEdge(const int* edges, int nedges, int s, int t)\n{\n\tfor (int i = 0; i < nedges; i++)\n\t{\n\t\tconst int* e = &edges[i*4];\n\t\tif ((e[0] == s && e[1] == t) || (e[0] == t && e[1] == s))\n\t\t\treturn i;\n\t}\n\treturn EV_UNDEF;\n}\n\nstatic int addEdge(rcContext* ctx, int* edges, int& nedges, const int maxEdges, int s, int t, int l, int r)\n{\n\tif (nedges >= maxEdges)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"addEdge: Too many edges (%d/%d).\", nedges, maxEdges);\n\t\treturn EV_UNDEF;\n\t}\n\t\n\t// Add edge if not already in the triangulation.\n\tint e = findEdge(edges, nedges, s, t);\n\tif (e == EV_UNDEF)\n\t{\n\t\tint* edge = &edges[nedges*4];\n\t\tedge[0] = s;\n\t\tedge[1] = t;\n\t\tedge[2] = l;\n\t\tedge[3] = r;\n\t\treturn nedges++;\n\t}\n\telse\n\t{\n\t\treturn EV_UNDEF;\n\t}\n}\n\nstatic void updateLeftFace(int* e, int s, int t, int f)\n{\n\tif (e[0] == s && e[1] == t && e[2] == EV_UNDEF)\n\t\te[2] = f;\n\telse if (e[1] == s && e[0] == t && e[3] == EV_UNDEF)\n\t\te[3] = f;\n}\n\nstatic int overlapSegSeg2d(const float* a, const float* b, const float* c, const float* d)\n{\n\tconst float a1 = vcross2(a, b, d);\n\tconst float a2 = vcross2(a, b, c);\n\tif (a1*a2 < 0.0f)\n\t{\n\t\tfloat a3 = vcross2(c, d, a);\n\t\tfloat a4 = a3 + a2 - a1;\n\t\tif (a3 * a4 < 0.0f)\n\t\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nstatic bool overlapEdges(const float* pts, const int* edges, int nedges, int s1, int t1)\n{\n\tfor (int i = 0; i < nedges; ++i)\n\t{\n\t\tconst int s0 = edges[i*4+0];\n\t\tconst int t0 = edges[i*4+1];\n\t\t// Same or connected edges do not overlap.\n\t\tif (s0 == s1 || s0 == t1 || t0 == s1 || t0 == t1)\n\t\t\tcontinue;\n\t\tif (overlapSegSeg2d(&pts[s0*3],&pts[t0*3], &pts[s1*3],&pts[t1*3]))\n\t\t\treturn true;\n\t}\n\treturn false;\n}\n\nstatic void completeFacet(rcContext* ctx, const float* pts, int npts, int* edges, int& nedges, const int maxEdges, int& nfaces, int e)\n{\n\tstatic const float EPS = 1e-5f;\n\t\n\tint* edge = &edges[e*4];\n\t\n\t// Cache s and t.\n\tint s,t;\n\tif (edge[2] == EV_UNDEF)\n\t{\n\t\ts = edge[0];\n\t\tt = edge[1];\n\t}\n\telse if (edge[3] == EV_UNDEF)\n\t{\n\t\ts = edge[1];\n\t\tt = edge[0];\n\t}\n\telse\n\t{\n\t    // Edge already completed.\n\t    return;\n\t}\n    \n\t// Find best point on left of edge.\n\tint pt = npts;\n\tfloat c[3] = {0,0,0};\n\tfloat r = -1;\n\tfor (int u = 0; u < npts; ++u)\n\t{\n\t\tif (u == s || u == t) continue;\n\t\tif (vcross2(&pts[s*3], &pts[t*3], &pts[u*3]) > EPS)\n\t\t{\n\t\t\tif (r < 0)\n\t\t\t{\n\t\t\t\t// The circle is not updated yet, do it now.\n\t\t\t\tpt = u;\n\t\t\t\tcircumCircle(&pts[s*3], &pts[t*3], &pts[u*3], c, r);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst float d = vdist2(c, &pts[u*3]);\n\t\t\tconst float tol = 0.001f;\n\t\t\tif (d > r*(1+tol))\n\t\t\t{\n\t\t\t\t// Outside current circumcircle, skip.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if (d < r*(1-tol))\n\t\t\t{\n\t\t\t\t// Inside safe circumcircle, update circle.\n\t\t\t\tpt = u;\n\t\t\t\tcircumCircle(&pts[s*3], &pts[t*3], &pts[u*3], c, r);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// Inside epsilon circum circle, do extra tests to make sure the edge is valid.\n\t\t\t\t// s-u and t-u cannot overlap with s-pt nor t-pt if they exists.\n\t\t\t\tif (overlapEdges(pts, edges, nedges, s,u))\n\t\t\t\t\tcontinue;\n\t\t\t\tif (overlapEdges(pts, edges, nedges, t,u))\n\t\t\t\t\tcontinue;\n\t\t\t\t// Edge is valid.\n\t\t\t\tpt = u;\n\t\t\t\tcircumCircle(&pts[s*3], &pts[t*3], &pts[u*3], c, r);\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Add new triangle or update edge info if s-t is on hull.\n\tif (pt < npts)\n\t{\n\t\t// Update face information of edge being completed.\n\t\tupdateLeftFace(&edges[e*4], s, t, nfaces);\n\t\t\n\t\t// Add new edge or update face info of old edge.\n\t\te = findEdge(edges, nedges, pt, s);\n\t\tif (e == EV_UNDEF)\n\t\t    addEdge(ctx, edges, nedges, maxEdges, pt, s, nfaces, EV_UNDEF);\n\t\telse\n\t\t    updateLeftFace(&edges[e*4], pt, s, nfaces);\n\t\t\n\t\t// Add new edge or update face info of old edge.\n\t\te = findEdge(edges, nedges, t, pt);\n\t\tif (e == EV_UNDEF)\n\t\t    addEdge(ctx, edges, nedges, maxEdges, t, pt, nfaces, EV_UNDEF);\n\t\telse\n\t\t    updateLeftFace(&edges[e*4], t, pt, nfaces);\n\t\t\n\t\tnfaces++;\n\t}\n\telse\n\t{\n\t\tupdateLeftFace(&edges[e*4], s, t, EV_HULL);\n\t}\n}\n\nstatic void delaunayHull(rcContext* ctx, const int npts, const float* pts,\n\t\t\t\t\t\t const int nhull, const int* hull,\n\t\t\t\t\t\t rcIntArray& tris, rcIntArray& edges)\n{\n\tint nfaces = 0;\n\tint nedges = 0;\n\tconst int maxEdges = npts*10;\n\tedges.resize(maxEdges*4);\n\t\n\tfor (int i = 0, j = nhull-1; i < nhull; j=i++)\n\t\taddEdge(ctx, &edges[0], nedges, maxEdges, hull[j],hull[i], EV_HULL, EV_UNDEF);\n\t\n\tint currentEdge = 0;\n\twhile (currentEdge < nedges)\n\t{\n\t\tif (edges[currentEdge*4+2] == EV_UNDEF)\n\t\t\tcompleteFacet(ctx, pts, npts, &edges[0], nedges, maxEdges, nfaces, currentEdge);\n\t\tif (edges[currentEdge*4+3] == EV_UNDEF)\n\t\t\tcompleteFacet(ctx, pts, npts, &edges[0], nedges, maxEdges, nfaces, currentEdge);\n\t\tcurrentEdge++;\n\t}\n\t\n\t// Create tris\n\ttris.resize(nfaces*4);\n\tfor (int i = 0; i < nfaces*4; ++i)\n\t\ttris[i] = -1;\n\t\n\tfor (int i = 0; i < nedges; ++i)\n\t{\n\t\tconst int* e = &edges[i*4];\n\t\tif (e[3] >= 0)\n\t\t{\n\t\t\t// Left face\n\t\t\tint* t = &tris[e[3]*4];\n\t\t\tif (t[0] == -1)\n\t\t\t{\n\t\t\t\tt[0] = e[0];\n\t\t\t\tt[1] = e[1];\n\t\t\t}\n\t\t\telse if (t[0] == e[1])\n\t\t\t\tt[2] = e[0];\n\t\t\telse if (t[1] == e[0])\n\t\t\t\tt[2] = e[1];\n\t\t}\n\t\tif (e[2] >= 0)\n\t\t{\n\t\t\t// Right\n\t\t\tint* t = &tris[e[2]*4];\n\t\t\tif (t[0] == -1)\n\t\t\t{\n\t\t\t\tt[0] = e[1];\n\t\t\t\tt[1] = e[0];\n\t\t\t}\n\t\t\telse if (t[0] == e[0])\n\t\t\t\tt[2] = e[1];\n\t\t\telse if (t[1] == e[1])\n\t\t\t\tt[2] = e[0];\n\t\t}\n\t}\n\t\n\tfor (int i = 0; i < tris.size()/4; ++i)\n\t{\n\t\tint* t = &tris[i*4];\n\t\tif (t[0] == -1 || t[1] == -1 || t[2] == -1)\n\t\t{\n\t\t\tctx->log(RC_LOG_WARNING, \"delaunayHull: Removing dangling face %d [%d,%d,%d].\", i, t[0],t[1],t[2]);\n\t\t\tt[0] = tris[tris.size()-4];\n\t\t\tt[1] = tris[tris.size()-3];\n\t\t\tt[2] = tris[tris.size()-2];\n\t\t\tt[3] = tris[tris.size()-1];\n\t\t\ttris.resize(tris.size()-4);\n\t\t\t--i;\n\t\t}\n\t}\n}\n\n// Calculate minimum extend of the polygon.\nstatic float polyMinExtent(const float* verts, const int nverts)\n{\n\tfloat minDist = FLT_MAX;\n\tfor (int i = 0; i < nverts; i++)\n\t{\n\t\tconst int ni = (i+1) % nverts;\n\t\tconst float* p1 = &verts[i*3];\n\t\tconst float* p2 = &verts[ni*3];\n\t\tfloat maxEdgeDist = 0;\n\t\tfor (int j = 0; j < nverts; j++)\n\t\t{\n\t\t\tif (j == i || j == ni) continue;\n\t\t\tfloat d = distancePtSeg2d(&verts[j*3], p1,p2);\n\t\t\tmaxEdgeDist = rcMax(maxEdgeDist, d);\n\t\t}\n\t\tminDist = rcMin(minDist, maxEdgeDist);\n\t}\n\treturn rcSqrt(minDist);\n}\n\n// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).\ninline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }\ninline int next(int i, int n) { return i+1 < n ? i+1 : 0; }\n\nstatic void triangulateHull(const int /*nverts*/, const float* verts, const int nhull, const int* hull, const int nin, rcIntArray& tris)\n{\n\tint start = 0, left = 1, right = nhull-1;\n\t\n\t// Start from an ear with shortest perimeter.\n\t// This tends to favor well formed triangles as starting point.\n\tfloat dmin = FLT_MAX;\n\tfor (int i = 0; i < nhull; i++)\n\t{\n\t\tif (hull[i] >= nin) continue; // Ears are triangles with original vertices as middle vertex while others are actually line segments on edges\n\t\tint pi = prev(i, nhull);\n\t\tint ni = next(i, nhull);\n\t\tconst float* pv = &verts[hull[pi]*3];\n\t\tconst float* cv = &verts[hull[i]*3];\n\t\tconst float* nv = &verts[hull[ni]*3];\n\t\tconst float d = vdist2(pv,cv) + vdist2(cv,nv) + vdist2(nv,pv);\n\t\tif (d < dmin)\n\t\t{\n\t\t\tstart = i;\n\t\t\tleft = ni;\n\t\t\tright = pi;\n\t\t\tdmin = d;\n\t\t}\n\t}\n\t\n\t// Add first triangle\n\ttris.push(hull[start]);\n\ttris.push(hull[left]);\n\ttris.push(hull[right]);\n\ttris.push(0);\n\t\n\t// Triangulate the polygon by moving left or right,\n\t// depending on which triangle has shorter perimeter.\n\t// This heuristic was chose emprically, since it seems\n\t// handle tesselated straight edges well.\n\twhile (next(left, nhull) != right)\n\t{\n\t\t// Check to see if se should advance left or right.\n\t\tint nleft = next(left, nhull);\n\t\tint nright = prev(right, nhull);\n\t\t\n\t\tconst float* cvleft = &verts[hull[left]*3];\n\t\tconst float* nvleft = &verts[hull[nleft]*3];\n\t\tconst float* cvright = &verts[hull[right]*3];\n\t\tconst float* nvright = &verts[hull[nright]*3];\n\t\tconst float dleft = vdist2(cvleft, nvleft) + vdist2(nvleft, cvright);\n\t\tconst float dright = vdist2(cvright, nvright) + vdist2(cvleft, nvright);\n\t\t\n\t\tif (dleft < dright)\n\t\t{\n\t\t\ttris.push(hull[left]);\n\t\t\ttris.push(hull[nleft]);\n\t\t\ttris.push(hull[right]);\n\t\t\ttris.push(0);\n\t\t\tleft = nleft;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ttris.push(hull[left]);\n\t\t\ttris.push(hull[nright]);\n\t\t\ttris.push(hull[right]);\n\t\t\ttris.push(0);\n\t\t\tright = nright;\n\t\t}\n\t}\n}\n\n\ninline float getJitterX(const int i)\n{\n\treturn (((i * 0x8da6b343) & 0xffff) / 65535.0f * 2.0f) - 1.0f;\n}\n\ninline float getJitterY(const int i)\n{\n\treturn (((i * 0xd8163841) & 0xffff) / 65535.0f * 2.0f) - 1.0f;\n}\n\nstatic bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,\n\t\t\t\t\t\t\tconst float sampleDist, const float sampleMaxError,\n\t\t\t\t\t\t\tconst int heightSearchRadius, const rcCompactHeightfield& chf,\n\t\t\t\t\t\t\tconst rcHeightPatch& hp, float* verts, int& nverts,\n\t\t\t\t\t\t\trcIntArray& tris, rcIntArray& edges, rcIntArray& samples)\n{\n\tstatic const int MAX_VERTS = 127;\n\tstatic const int MAX_TRIS = 255;\t// Max tris for delaunay is 2n-2-k (n=num verts, k=num hull verts).\n\tstatic const int MAX_VERTS_PER_EDGE = 32;\n\tfloat edge[(MAX_VERTS_PER_EDGE+1)*3];\n\tint hull[MAX_VERTS];\n\tint nhull = 0;\n\t\n\tnverts = nin;\n\t\n\tfor (int i = 0; i < nin; ++i)\n\t\trcVcopy(&verts[i*3], &in[i*3]);\n\t\n\tedges.resize(0);\n\ttris.resize(0);\n\t\n\tconst float cs = chf.cs;\n\tconst float ics = 1.0f/cs;\n\t\n\t// Calculate minimum extents of the polygon based on input data.\n\tfloat minExtent = polyMinExtent(verts, nverts);\n\t\n\t// Tessellate outlines.\n\t// This is done in separate pass in order to ensure\n\t// seamless height values across the ply boundaries.\n\tif (sampleDist > 0)\n\t{\n\t\tfor (int i = 0, j = nin-1; i < nin; j=i++)\n\t\t{\n\t\t\tconst float* vj = &in[j*3];\n\t\t\tconst float* vi = &in[i*3];\n\t\t\tbool swapped = false;\n\t\t\t// Make sure the segments are always handled in same order\n\t\t\t// using lexological sort or else there will be seams.\n\t\t\tif (fabsf(vj[0]-vi[0]) < 1e-6f)\n\t\t\t{\n\t\t\t\tif (vj[2] > vi[2])\n\t\t\t\t{\n\t\t\t\t\trcSwap(vj,vi);\n\t\t\t\t\tswapped = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (vj[0] > vi[0])\n\t\t\t\t{\n\t\t\t\t\trcSwap(vj,vi);\n\t\t\t\t\tswapped = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Create samples along the edge.\n\t\t\tfloat dx = vi[0] - vj[0];\n\t\t\tfloat dy = vi[1] - vj[1];\n\t\t\tfloat dz = vi[2] - vj[2];\n\t\t\tfloat d = sqrtf(dx*dx + dz*dz);\n\t\t\tint nn = 1 + (int)floorf(d/sampleDist);\n\t\t\tif (nn >= MAX_VERTS_PER_EDGE) nn = MAX_VERTS_PER_EDGE-1;\n\t\t\tif (nverts+nn >= MAX_VERTS)\n\t\t\t\tnn = MAX_VERTS-1-nverts;\n\t\t\t\n\t\t\tfor (int k = 0; k <= nn; ++k)\n\t\t\t{\n\t\t\t\tfloat u = (float)k/(float)nn;\n\t\t\t\tfloat* pos = &edge[k*3];\n\t\t\t\tpos[0] = vj[0] + dx*u;\n\t\t\t\tpos[1] = vj[1] + dy*u;\n\t\t\t\tpos[2] = vj[2] + dz*u;\n\t\t\t\tpos[1] = getHeight(pos[0],pos[1],pos[2], cs, ics, chf.ch, heightSearchRadius, hp)*chf.ch;\n\t\t\t}\n\t\t\t// Simplify samples.\n\t\t\tint idx[MAX_VERTS_PER_EDGE] = {0,nn};\n\t\t\tint nidx = 2;\n\t\t\tfor (int k = 0; k < nidx-1; )\n\t\t\t{\n\t\t\t\tconst int a = idx[k];\n\t\t\t\tconst int b = idx[k+1];\n\t\t\t\tconst float* va = &edge[a*3];\n\t\t\t\tconst float* vb = &edge[b*3];\n\t\t\t\t// Find maximum deviation along the segment.\n\t\t\t\tfloat maxd = 0;\n\t\t\t\tint maxi = -1;\n\t\t\t\tfor (int m = a+1; m < b; ++m)\n\t\t\t\t{\n\t\t\t\t\tfloat dev = distancePtSeg(&edge[m*3],va,vb);\n\t\t\t\t\tif (dev > maxd)\n\t\t\t\t\t{\n\t\t\t\t\t\tmaxd = dev;\n\t\t\t\t\t\tmaxi = m;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If the max deviation is larger than accepted error,\n\t\t\t\t// add new point, else continue to next segment.\n\t\t\t\tif (maxi != -1 && maxd > rcSqr(sampleMaxError))\n\t\t\t\t{\n\t\t\t\t\tfor (int m = nidx; m > k; --m)\n\t\t\t\t\t\tidx[m] = idx[m-1];\n\t\t\t\t\tidx[k+1] = maxi;\n\t\t\t\t\tnidx++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t++k;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\thull[nhull++] = j;\n\t\t\t// Add new vertices.\n\t\t\tif (swapped)\n\t\t\t{\n\t\t\t\tfor (int k = nidx-2; k > 0; --k)\n\t\t\t\t{\n\t\t\t\t\trcVcopy(&verts[nverts*3], &edge[idx[k]*3]);\n\t\t\t\t\thull[nhull++] = nverts;\n\t\t\t\t\tnverts++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor (int k = 1; k < nidx-1; ++k)\n\t\t\t\t{\n\t\t\t\t\trcVcopy(&verts[nverts*3], &edge[idx[k]*3]);\n\t\t\t\t\thull[nhull++] = nverts;\n\t\t\t\t\tnverts++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// If the polygon minimum extent is small (sliver or small triangle), do not try to add internal points.\n\tif (minExtent < sampleDist*2)\n\t{\n\t\ttriangulateHull(nverts, verts, nhull, hull, nin, tris);\n\t\treturn true;\n\t}\n\t\n\t// Tessellate the base mesh.\n\t// We're using the triangulateHull instead of delaunayHull as it tends to\n\t// create a bit better triangulation for long thin triangles when there\n\t// are no internal points.\n\ttriangulateHull(nverts, verts, nhull, hull, nin, tris);\n\t\n\tif (tris.size() == 0)\n\t{\n\t\t// Could not triangulate the poly, make sure there is some valid data there.\n\t\tctx->log(RC_LOG_WARNING, \"buildPolyDetail: Could not triangulate polygon (%d verts).\", nverts);\n\t\treturn true;\n\t}\n\t\n\tif (sampleDist > 0)\n\t{\n\t\t// Create sample locations in a grid.\n\t\tfloat bmin[3], bmax[3];\n\t\trcVcopy(bmin, in);\n\t\trcVcopy(bmax, in);\n\t\tfor (int i = 1; i < nin; ++i)\n\t\t{\n\t\t\trcVmin(bmin, &in[i*3]);\n\t\t\trcVmax(bmax, &in[i*3]);\n\t\t}\n\t\tint x0 = (int)floorf(bmin[0]/sampleDist);\n\t\tint x1 = (int)ceilf(bmax[0]/sampleDist);\n\t\tint z0 = (int)floorf(bmin[2]/sampleDist);\n\t\tint z1 = (int)ceilf(bmax[2]/sampleDist);\n\t\tsamples.resize(0);\n\t\tfor (int z = z0; z < z1; ++z)\n\t\t{\n\t\t\tfor (int x = x0; x < x1; ++x)\n\t\t\t{\n\t\t\t\tfloat pt[3];\n\t\t\t\tpt[0] = x*sampleDist;\n\t\t\t\tpt[1] = (bmax[1]+bmin[1])*0.5f;\n\t\t\t\tpt[2] = z*sampleDist;\n\t\t\t\t// Make sure the samples are not too close to the edges.\n\t\t\t\tif (distToPoly(nin,in,pt) > -sampleDist/2) continue;\n\t\t\t\tsamples.push(x);\n\t\t\t\tsamples.push(getHeight(pt[0], pt[1], pt[2], cs, ics, chf.ch, heightSearchRadius, hp));\n\t\t\t\tsamples.push(z);\n\t\t\t\tsamples.push(0); // Not added\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Add the samples starting from the one that has the most\n\t\t// error. The procedure stops when all samples are added\n\t\t// or when the max error is within treshold.\n\t\tconst int nsamples = samples.size()/4;\n\t\tfor (int iter = 0; iter < nsamples; ++iter)\n\t\t{\n\t\t\tif (nverts >= MAX_VERTS)\n\t\t\t\tbreak;\n\t\t\t\n\t\t\t// Find sample with most error.\n\t\t\tfloat bestpt[3] = {0,0,0};\n\t\t\tfloat bestd = 0;\n\t\t\tint besti = -1;\n\t\t\tfor (int i = 0; i < nsamples; ++i)\n\t\t\t{\n\t\t\t\tconst int* s = &samples[i*4];\n\t\t\t\tif (s[3]) continue; // skip added.\n\t\t\t\tfloat pt[3];\n\t\t\t\t// The sample location is jittered to get rid of some bad triangulations\n\t\t\t\t// which are cause by symmetrical data from the grid structure.\n\t\t\t\tpt[0] = s[0]*sampleDist + getJitterX(i)*cs*0.1f;\n\t\t\t\tpt[1] = s[1]*chf.ch;\n\t\t\t\tpt[2] = s[2]*sampleDist + getJitterY(i)*cs*0.1f;\n\t\t\t\tfloat d = distToTriMesh(pt, verts, nverts, &tris[0], tris.size()/4);\n\t\t\t\tif (d < 0) continue; // did not hit the mesh.\n\t\t\t\tif (d > bestd)\n\t\t\t\t{\n\t\t\t\t\tbestd = d;\n\t\t\t\t\tbesti = i;\n\t\t\t\t\trcVcopy(bestpt,pt);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If the max error is within accepted threshold, stop tesselating.\n\t\t\tif (bestd <= sampleMaxError || besti == -1)\n\t\t\t\tbreak;\n\t\t\t// Mark sample as added.\n\t\t\tsamples[besti*4+3] = 1;\n\t\t\t// Add the new sample point.\n\t\t\trcVcopy(&verts[nverts*3],bestpt);\n\t\t\tnverts++;\n\t\t\t\n\t\t\t// Create new triangulation.\n\t\t\t// TODO: Incremental add instead of full rebuild.\n\t\t\tedges.resize(0);\n\t\t\ttris.resize(0);\n\t\t\tdelaunayHull(ctx, nverts, verts, nhull, hull, tris, edges);\n\t\t}\n\t}\n\t\n\tconst int ntris = tris.size()/4;\n\tif (ntris > MAX_TRIS)\n\t{\n\t\ttris.resize(MAX_TRIS*4);\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Shrinking triangle count from %d to max %d.\", ntris, MAX_TRIS);\n\t}\n\t\n\treturn true;\n}\n\nstatic void seedArrayWithPolyCenter(rcContext* ctx, const rcCompactHeightfield& chf,\n\t\t\t\t\t\t\t\t\tconst unsigned short* poly, const int npoly,\n\t\t\t\t\t\t\t\t\tconst unsigned short* verts, const int bs,\n\t\t\t\t\t\t\t\t\trcHeightPatch& hp, rcIntArray& array)\n{\n\t// Note: Reads to the compact heightfield are offset by border size (bs)\n\t// since border size offset is already removed from the polymesh vertices.\n\t\n\tstatic const int offset[9*2] =\n\t{\n\t\t0,0, -1,-1, 0,-1, 1,-1, 1,0, 1,1, 0,1, -1,1, -1,0,\n\t};\n\t\n\t// Find cell closest to a poly vertex\n\tint startCellX = 0, startCellY = 0, startSpanIndex = -1;\n\tint dmin = RC_UNSET_HEIGHT;\n\tfor (int j = 0; j < npoly && dmin > 0; ++j)\n\t{\n\t\tfor (int k = 0; k < 9 && dmin > 0; ++k)\n\t\t{\n\t\t\tconst int ax = (int)verts[poly[j]*3+0] + offset[k*2+0];\n\t\t\tconst int ay = (int)verts[poly[j]*3+1];\n\t\t\tconst int az = (int)verts[poly[j]*3+2] + offset[k*2+1];\n\t\t\tif (ax < hp.xmin || ax >= hp.xmin+hp.width ||\n\t\t\t\taz < hp.ymin || az >= hp.ymin+hp.height)\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\tconst rcCompactCell& c = chf.cells[(ax+bs)+(az+bs)*chf.width];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni && dmin > 0; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tint d = rcAbs(ay - (int)s.y);\n\t\t\t\tif (d < dmin)\n\t\t\t\t{\n\t\t\t\t\tstartCellX = ax;\n\t\t\t\t\tstartCellY = az;\n\t\t\t\t\tstartSpanIndex = i;\n\t\t\t\t\tdmin = d;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\trcAssert(startSpanIndex != -1);\n\t// Find center of the polygon\n\tint pcx = 0, pcy = 0;\n\tfor (int j = 0; j < npoly; ++j)\n\t{\n\t\tpcx += (int)verts[poly[j]*3+0];\n\t\tpcy += (int)verts[poly[j]*3+2];\n\t}\n\tpcx /= npoly;\n\tpcy /= npoly;\n\t\n\t// Use seeds array as a stack for DFS\n\tarray.resize(0);\n\tarray.push(startCellX);\n\tarray.push(startCellY);\n\tarray.push(startSpanIndex);\n\n\tint dirs[] = { 0, 1, 2, 3 };\n\tmemset(hp.data, 0, sizeof(unsigned short)*hp.width*hp.height);\n\t// DFS to move to the center. Note that we need a DFS here and can not just move\n\t// directly towards the center without recording intermediate nodes, even though the polygons\n\t// are convex. In very rare we can get stuck due to contour simplification if we do not\n\t// record nodes.\n\tint cx = -1, cy = -1, ci = -1;\n\twhile (true)\n\t{\n\t\tif (array.size() < 3)\n\t\t{\n\t\t\tctx->log(RC_LOG_WARNING, \"Walk towards polygon center failed to reach center\");\n\t\t\tbreak;\n\t\t}\n\n\t\tci = array.pop();\n\t\tcy = array.pop();\n\t\tcx = array.pop();\n\n\t\tif (cx == pcx && cy == pcy)\n\t\t\tbreak;\n\n\t\t// If we are already at the correct X-position, prefer direction\n\t\t// directly towards the center in the Y-axis; otherwise prefer\n\t\t// direction in the X-axis\n\t\tint directDir;\n\t\tif (cx == pcx)\n\t\t\tdirectDir = rcGetDirForOffset(0, pcy > cy ? 1 : -1);\n\t\telse\n\t\t\tdirectDir = rcGetDirForOffset(pcx > cx ? 1 : -1, 0);\n\n\t\t// Push the direct dir last so we start with this on next iteration\n\t\trcSwap(dirs[directDir], dirs[3]);\n\n\t\tconst rcCompactSpan& cs = chf.spans[ci];\n\t\tfor (int i = 0; i < 4; i++)\n\t\t{\n\t\t\tint dir = dirs[i];\n\t\t\tif (rcGetCon(cs, dir) == RC_NOT_CONNECTED)\n\t\t\t\tcontinue;\n\n\t\t\tint newX = cx + rcGetDirOffsetX(dir);\n\t\t\tint newY = cy + rcGetDirOffsetY(dir);\n\n\t\t\tint hpx = newX - hp.xmin;\n\t\t\tint hpy = newY - hp.ymin;\n\t\t\tif (hpx < 0 || hpx >= hp.width || hpy < 0 || hpy >= hp.height)\n\t\t\t\tcontinue;\n\n\t\t\tif (hp.data[hpx+hpy*hp.width] != 0)\n\t\t\t\tcontinue;\n\n\t\t\thp.data[hpx+hpy*hp.width] = 1;\n\t\t\tarray.push(newX);\n\t\t\tarray.push(newY);\n\t\t\tarray.push((int)chf.cells[(newX+bs)+(newY+bs)*chf.width].index + rcGetCon(cs, dir));\n\t\t}\n\n\t\trcSwap(dirs[directDir], dirs[3]);\n\t}\n\n\tarray.resize(0);\n\t// getHeightData seeds are given in coordinates with borders\n\tarray.push(cx+bs);\n\tarray.push(cy+bs);\n\tarray.push(ci);\n\n\tmemset(hp.data, 0xff, sizeof(unsigned short)*hp.width*hp.height);\n\tconst rcCompactSpan& cs = chf.spans[ci];\n\thp.data[cx-hp.xmin+(cy-hp.ymin)*hp.width] = cs.y;\n}\n\n\nstatic void push3(rcIntArray& queue, int v1, int v2, int v3)\n{\n\tqueue.resize(queue.size() + 3);\n\tqueue[queue.size() - 3] = v1;\n\tqueue[queue.size() - 2] = v2;\n\tqueue[queue.size() - 1] = v3;\n}\n\nstatic void getHeightData(rcContext* ctx, const rcCompactHeightfield& chf,\n\t\t\t\t\t\t  const unsigned short* poly, const int npoly,\n\t\t\t\t\t\t  const unsigned short* verts, const int bs,\n\t\t\t\t\t\t  rcHeightPatch& hp, rcIntArray& queue,\n\t\t\t\t\t\t  int region)\n{\n\t// Note: Reads to the compact heightfield are offset by border size (bs)\n\t// since border size offset is already removed from the polymesh vertices.\n\t\n\tqueue.resize(0);\n\t// Set all heights to RC_UNSET_HEIGHT.\n\tmemset(hp.data, 0xff, sizeof(unsigned short)*hp.width*hp.height);\n\n\tbool empty = true;\n\t\n\t// We cannot sample from this poly if it was created from polys\n\t// of different regions. If it was then it could potentially be overlapping\n\t// with polys of that region and the heights sampled here could be wrong.\n\tif (region != RC_MULTIPLE_REGS)\n\t{\n\t\t// Copy the height from the same region, and mark region borders\n\t\t// as seed points to fill the rest.\n\t\tfor (int hy = 0; hy < hp.height; hy++)\n\t\t{\n\t\t\tint y = hp.ymin + hy + bs;\n\t\t\tfor (int hx = 0; hx < hp.width; hx++)\n\t\t\t{\n\t\t\t\tint x = hp.xmin + hx + bs;\n\t\t\t\tconst rcCompactCell& c = chf.cells[x + y*chf.width];\n\t\t\t\tfor (int i = (int)c.index, ni = (int)(c.index + c.count); i < ni; ++i)\n\t\t\t\t{\n\t\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\t\tif (s.reg == region)\n\t\t\t\t\t{\n\t\t\t\t\t\t// Store height\n\t\t\t\t\t\thp.data[hx + hy*hp.width] = s.y;\n\t\t\t\t\t\tempty = false;\n\n\t\t\t\t\t\t// If any of the neighbours is not in same region,\n\t\t\t\t\t\t// add the current location as flood fill start\n\t\t\t\t\t\tbool border = false;\n\t\t\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t\t\t\tconst int ai = (int)chf.cells[ax + ay*chf.width].index + rcGetCon(s, dir);\n\t\t\t\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\t\t\t\tif (as.reg != region)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tborder = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (border)\n\t\t\t\t\t\t\tpush3(queue, x, y, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// if the polygon does not contain any points from the current region (rare, but happens)\n\t// or if it could potentially be overlapping polygons of the same region,\n\t// then use the center as the seed point.\n\tif (empty)\n\t\tseedArrayWithPolyCenter(ctx, chf, poly, npoly, verts, bs, hp, queue);\n\t\n\tstatic const int RETRACT_SIZE = 256;\n\tint head = 0;\n\t\n\t// We assume the seed is centered in the polygon, so a BFS to collect\n\t// height data will ensure we do not move onto overlapping polygons and\n\t// sample wrong heights.\n\twhile (head*3 < queue.size())\n\t{\n\t\tint cx = queue[head*3+0];\n\t\tint cy = queue[head*3+1];\n\t\tint ci = queue[head*3+2];\n\t\thead++;\n\t\tif (head >= RETRACT_SIZE)\n\t\t{\n\t\t\thead = 0;\n\t\t\tif (queue.size() > RETRACT_SIZE*3)\n\t\t\t\tmemmove(&queue[0], &queue[RETRACT_SIZE*3], sizeof(int)*(queue.size()-RETRACT_SIZE*3));\n\t\t\tqueue.resize(queue.size()-RETRACT_SIZE*3);\n\t\t}\n\t\t\n\t\tconst rcCompactSpan& cs = chf.spans[ci];\n\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t{\n\t\t\tif (rcGetCon(cs, dir) == RC_NOT_CONNECTED) continue;\n\t\t\t\n\t\t\tconst int ax = cx + rcGetDirOffsetX(dir);\n\t\t\tconst int ay = cy + rcGetDirOffsetY(dir);\n\t\t\tconst int hx = ax - hp.xmin - bs;\n\t\t\tconst int hy = ay - hp.ymin - bs;\n\t\t\t\n\t\t\tif ((unsigned int)hx >= (unsigned int)hp.width || (unsigned int)hy >= (unsigned int)hp.height)\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\tif (hp.data[hx + hy*hp.width] != RC_UNSET_HEIGHT)\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\tconst int ai = (int)chf.cells[ax + ay*chf.width].index + rcGetCon(cs, dir);\n\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\n\t\t\thp.data[hx + hy*hp.width] = as.y;\n\t\t\t\n\t\t\tpush3(queue, ax, ay, ai);\n\t\t}\n\t}\n}\n\nstatic unsigned char getEdgeFlags(const float* va, const float* vb,\n\t\t\t\t\t\t\t\t  const float* vpoly, const int npoly)\n{\n\t// The flag returned by this function matches dtDetailTriEdgeFlags in Detour.\n\t// Figure out if edge (va,vb) is part of the polygon boundary.\n\tstatic const float thrSqr = rcSqr(0.001f);\n\tfor (int i = 0, j = npoly-1; i < npoly; j=i++)\n\t{\n\t\tif (distancePtSeg2d(va, &vpoly[j*3], &vpoly[i*3]) < thrSqr &&\n\t\t\tdistancePtSeg2d(vb, &vpoly[j*3], &vpoly[i*3]) < thrSqr)\n\t\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nstatic unsigned char getTriFlags(const float* va, const float* vb, const float* vc,\n\t\t\t\t\t\t\t\t const float* vpoly, const int npoly)\n{\n\tunsigned char flags = 0;\n\tflags |= getEdgeFlags(va,vb,vpoly,npoly) << 0;\n\tflags |= getEdgeFlags(vb,vc,vpoly,npoly) << 2;\n\tflags |= getEdgeFlags(vc,va,vpoly,npoly) << 4;\n\treturn flags;\n}\n\n/// @par\n///\n/// See the #rcConfig documentation for more information on the configuration parameters.\n///\n/// @see rcAllocPolyMeshDetail, rcPolyMesh, rcCompactHeightfield, rcPolyMeshDetail, rcConfig\nbool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompactHeightfield& chf,\n\t\t\t\t\t\t   const float sampleDist, const float sampleMaxError,\n\t\t\t\t\t\t   rcPolyMeshDetail& dmesh)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_BUILD_POLYMESHDETAIL);\n\t\n\tif (mesh.nverts == 0 || mesh.npolys == 0)\n\t\treturn true;\n\t\n\tconst int nvp = mesh.nvp;\n\tconst float cs = mesh.cs;\n\tconst float ch = mesh.ch;\n\tconst float* orig = mesh.bmin;\n\tconst int borderSize = mesh.borderSize;\n\tconst int heightSearchRadius = rcMax(1, (int)ceilf(mesh.maxEdgeError));\n\t\n\trcIntArray edges(64);\n\trcIntArray tris(512);\n\trcIntArray arr(512);\n\trcIntArray samples(512);\n\tfloat verts[256*3];\n\trcHeightPatch hp;\n\tint nPolyVerts = 0;\n\tint maxhw = 0, maxhh = 0;\n\t\n\trcScopedDelete<int> bounds((int*)rcAlloc(sizeof(int)*mesh.npolys*4, RC_ALLOC_TEMP));\n\tif (!bounds)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'bounds' (%d).\", mesh.npolys*4);\n\t\treturn false;\n\t}\n\trcScopedDelete<float> poly((float*)rcAlloc(sizeof(float)*nvp*3, RC_ALLOC_TEMP));\n\tif (!poly)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'poly' (%d).\", nvp*3);\n\t\treturn false;\n\t}\n\t\n\t// Find max size for a polygon area.\n\tfor (int i = 0; i < mesh.npolys; ++i)\n\t{\n\t\tconst unsigned short* p = &mesh.polys[i*nvp*2];\n\t\tint& xmin = bounds[i*4+0];\n\t\tint& xmax = bounds[i*4+1];\n\t\tint& ymin = bounds[i*4+2];\n\t\tint& ymax = bounds[i*4+3];\n\t\txmin = chf.width;\n\t\txmax = 0;\n\t\tymin = chf.height;\n\t\tymax = 0;\n\t\tfor (int j = 0; j < nvp; ++j)\n\t\t{\n\t\t\tif(p[j] == RC_MESH_NULL_IDX) break;\n\t\t\tconst unsigned short* v = &mesh.verts[p[j]*3];\n\t\t\txmin = rcMin(xmin, (int)v[0]);\n\t\t\txmax = rcMax(xmax, (int)v[0]);\n\t\t\tymin = rcMin(ymin, (int)v[2]);\n\t\t\tymax = rcMax(ymax, (int)v[2]);\n\t\t\tnPolyVerts++;\n\t\t}\n\t\txmin = rcMax(0,xmin-1);\n\t\txmax = rcMin(chf.width,xmax+1);\n\t\tymin = rcMax(0,ymin-1);\n\t\tymax = rcMin(chf.height,ymax+1);\n\t\tif (xmin >= xmax || ymin >= ymax) continue;\n\t\tmaxhw = rcMax(maxhw, xmax-xmin);\n\t\tmaxhh = rcMax(maxhh, ymax-ymin);\n\t}\n\t\n\thp.data = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxhw*maxhh, RC_ALLOC_TEMP);\n\tif (!hp.data)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'hp.data' (%d).\", maxhw*maxhh);\n\t\treturn false;\n\t}\n\t\n\tdmesh.nmeshes = mesh.npolys;\n\tdmesh.nverts = 0;\n\tdmesh.ntris = 0;\n\tdmesh.meshes = (unsigned int*)rcAlloc(sizeof(unsigned int)*dmesh.nmeshes*4, RC_ALLOC_PERM);\n\tif (!dmesh.meshes)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'dmesh.meshes' (%d).\", dmesh.nmeshes*4);\n\t\treturn false;\n\t}\n\t\n\tint vcap = nPolyVerts+nPolyVerts/2;\n\tint tcap = vcap*2;\n\t\n\tdmesh.nverts = 0;\n\tdmesh.verts = (float*)rcAlloc(sizeof(float)*vcap*3, RC_ALLOC_PERM);\n\tif (!dmesh.verts)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'dmesh.verts' (%d).\", vcap*3);\n\t\treturn false;\n\t}\n\tdmesh.ntris = 0;\n\tdmesh.tris = (unsigned char*)rcAlloc(sizeof(unsigned char)*tcap*4, RC_ALLOC_PERM);\n\tif (!dmesh.tris)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'dmesh.tris' (%d).\", tcap*4);\n\t\treturn false;\n\t}\n\t\n\tfor (int i = 0; i < mesh.npolys; ++i)\n\t{\n\t\tconst unsigned short* p = &mesh.polys[i*nvp*2];\n\t\t\n\t\t// Store polygon vertices for processing.\n\t\tint npoly = 0;\n\t\tfor (int j = 0; j < nvp; ++j)\n\t\t{\n\t\t\tif(p[j] == RC_MESH_NULL_IDX) break;\n\t\t\tconst unsigned short* v = &mesh.verts[p[j]*3];\n\t\t\tpoly[j*3+0] = v[0]*cs;\n\t\t\tpoly[j*3+1] = v[1]*ch;\n\t\t\tpoly[j*3+2] = v[2]*cs;\n\t\t\tnpoly++;\n\t\t}\n\t\t\n\t\t// Get the height data from the area of the polygon.\n\t\thp.xmin = bounds[i*4+0];\n\t\thp.ymin = bounds[i*4+2];\n\t\thp.width = bounds[i*4+1]-bounds[i*4+0];\n\t\thp.height = bounds[i*4+3]-bounds[i*4+2];\n\t\tgetHeightData(ctx, chf, p, npoly, mesh.verts, borderSize, hp, arr, mesh.regs[i]);\n\t\t\n\t\t// Build detail mesh.\n\t\tint nverts = 0;\n\t\tif (!buildPolyDetail(ctx, poly, npoly,\n\t\t\t\t\t\t\t sampleDist, sampleMaxError,\n\t\t\t\t\t\t\t heightSearchRadius, chf, hp,\n\t\t\t\t\t\t\t verts, nverts, tris,\n\t\t\t\t\t\t\t edges, samples))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t// Move detail verts to world space.\n\t\tfor (int j = 0; j < nverts; ++j)\n\t\t{\n\t\t\tverts[j*3+0] += orig[0];\n\t\t\tverts[j*3+1] += orig[1] + chf.ch; // Is this offset necessary?\n\t\t\tverts[j*3+2] += orig[2];\n\t\t}\n\t\t// Offset poly too, will be used to flag checking.\n\t\tfor (int j = 0; j < npoly; ++j)\n\t\t{\n\t\t\tpoly[j*3+0] += orig[0];\n\t\t\tpoly[j*3+1] += orig[1];\n\t\t\tpoly[j*3+2] += orig[2];\n\t\t}\n\t\t\n\t\t// Store detail submesh.\n\t\tconst int ntris = tris.size()/4;\n\t\t\n\t\tdmesh.meshes[i*4+0] = (unsigned int)dmesh.nverts;\n\t\tdmesh.meshes[i*4+1] = (unsigned int)nverts;\n\t\tdmesh.meshes[i*4+2] = (unsigned int)dmesh.ntris;\n\t\tdmesh.meshes[i*4+3] = (unsigned int)ntris;\n\t\t\n\t\t// Store vertices, allocate more memory if necessary.\n\t\tif (dmesh.nverts+nverts > vcap)\n\t\t{\n\t\t\twhile (dmesh.nverts+nverts > vcap)\n\t\t\t\tvcap += 256;\n\t\t\t\n\t\t\tfloat* newv = (float*)rcAlloc(sizeof(float)*vcap*3, RC_ALLOC_PERM);\n\t\t\tif (!newv)\n\t\t\t{\n\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'newv' (%d).\", vcap*3);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (dmesh.nverts)\n\t\t\t\tmemcpy(newv, dmesh.verts, sizeof(float)*3*dmesh.nverts);\n\t\t\trcFree(dmesh.verts);\n\t\t\tdmesh.verts = newv;\n\t\t}\n\t\tfor (int j = 0; j < nverts; ++j)\n\t\t{\n\t\t\tdmesh.verts[dmesh.nverts*3+0] = verts[j*3+0];\n\t\t\tdmesh.verts[dmesh.nverts*3+1] = verts[j*3+1];\n\t\t\tdmesh.verts[dmesh.nverts*3+2] = verts[j*3+2];\n\t\t\tdmesh.nverts++;\n\t\t}\n\t\t\n\t\t// Store triangles, allocate more memory if necessary.\n\t\tif (dmesh.ntris+ntris > tcap)\n\t\t{\n\t\t\twhile (dmesh.ntris+ntris > tcap)\n\t\t\t\ttcap += 256;\n\t\t\tunsigned char* newt = (unsigned char*)rcAlloc(sizeof(unsigned char)*tcap*4, RC_ALLOC_PERM);\n\t\t\tif (!newt)\n\t\t\t{\n\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'newt' (%d).\", tcap*4);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (dmesh.ntris)\n\t\t\t\tmemcpy(newt, dmesh.tris, sizeof(unsigned char)*4*dmesh.ntris);\n\t\t\trcFree(dmesh.tris);\n\t\t\tdmesh.tris = newt;\n\t\t}\n\t\tfor (int j = 0; j < ntris; ++j)\n\t\t{\n\t\t\tconst int* t = &tris[j*4];\n\t\t\tdmesh.tris[dmesh.ntris*4+0] = (unsigned char)t[0];\n\t\t\tdmesh.tris[dmesh.ntris*4+1] = (unsigned char)t[1];\n\t\t\tdmesh.tris[dmesh.ntris*4+2] = (unsigned char)t[2];\n\t\t\tdmesh.tris[dmesh.ntris*4+3] = getTriFlags(&verts[t[0]*3], &verts[t[1]*3], &verts[t[2]*3], poly, npoly);\n\t\t\tdmesh.ntris++;\n\t\t}\n\t}\n\t\n\treturn true;\n}\n\n/// @see rcAllocPolyMeshDetail, rcPolyMeshDetail\nbool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int nmeshes, rcPolyMeshDetail& mesh)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_MERGE_POLYMESHDETAIL);\n\t\n\tint maxVerts = 0;\n\tint maxTris = 0;\n\tint maxMeshes = 0;\n\t\n\tfor (int i = 0; i < nmeshes; ++i)\n\t{\n\t\tif (!meshes[i]) continue;\n\t\tmaxVerts += meshes[i]->nverts;\n\t\tmaxTris += meshes[i]->ntris;\n\t\tmaxMeshes += meshes[i]->nmeshes;\n\t}\n\t\n\tmesh.nmeshes = 0;\n\tmesh.meshes = (unsigned int*)rcAlloc(sizeof(unsigned int)*maxMeshes*4, RC_ALLOC_PERM);\n\tif (!mesh.meshes)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'pmdtl.meshes' (%d).\", maxMeshes*4);\n\t\treturn false;\n\t}\n\t\n\tmesh.ntris = 0;\n\tmesh.tris = (unsigned char*)rcAlloc(sizeof(unsigned char)*maxTris*4, RC_ALLOC_PERM);\n\tif (!mesh.tris)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'dmesh.tris' (%d).\", maxTris*4);\n\t\treturn false;\n\t}\n\t\n\tmesh.nverts = 0;\n\tmesh.verts = (float*)rcAlloc(sizeof(float)*maxVerts*3, RC_ALLOC_PERM);\n\tif (!mesh.verts)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildPolyMeshDetail: Out of memory 'dmesh.verts' (%d).\", maxVerts*3);\n\t\treturn false;\n\t}\n\t\n\t// Merge datas.\n\tfor (int i = 0; i < nmeshes; ++i)\n\t{\n\t\trcPolyMeshDetail* dm = meshes[i];\n\t\tif (!dm) continue;\n\t\tfor (int j = 0; j < dm->nmeshes; ++j)\n\t\t{\n\t\t\tunsigned int* dst = &mesh.meshes[mesh.nmeshes*4];\n\t\t\tunsigned int* src = &dm->meshes[j*4];\n\t\t\tdst[0] = (unsigned int)mesh.nverts+src[0];\n\t\t\tdst[1] = src[1];\n\t\t\tdst[2] = (unsigned int)mesh.ntris+src[2];\n\t\t\tdst[3] = src[3];\n\t\t\tmesh.nmeshes++;\n\t\t}\n\t\t\n\t\tfor (int k = 0; k < dm->nverts; ++k)\n\t\t{\n\t\t\trcVcopy(&mesh.verts[mesh.nverts*3], &dm->verts[k*3]);\n\t\t\tmesh.nverts++;\n\t\t}\n\t\tfor (int k = 0; k < dm->ntris; ++k)\n\t\t{\n\t\t\tmesh.tris[mesh.ntris*4+0] = dm->tris[k*4+0];\n\t\t\tmesh.tris[mesh.ntris*4+1] = dm->tris[k*4+1];\n\t\t\tmesh.tris[mesh.ntris*4+2] = dm->tris[k*4+2];\n\t\t\tmesh.tris[mesh.ntris*4+3] = dm->tris[k*4+3];\n\t\t\tmesh.ntris++;\n\t\t}\n\t}\n\t\n\treturn true;\n}\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastRasterization.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#define _USE_MATH_DEFINES\n#include <math.h>\n#include <stdio.h>\n#include \"Recast.h\"\n#include \"RecastAlloc.h\"\n#include \"RecastAssert.h\"\n\ninline bool overlapBounds(const float* amin, const float* amax, const float* bmin, const float* bmax)\n{\n\tbool overlap = true;\n\toverlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;\n\toverlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;\n\toverlap = (amin[2] > bmax[2] || amax[2] < bmin[2]) ? false : overlap;\n\treturn overlap;\n}\n\ninline bool overlapInterval(unsigned short amin, unsigned short amax,\n\t\t\t\t\t\t\tunsigned short bmin, unsigned short bmax)\n{\n\tif (amax < bmin) return false;\n\tif (amin > bmax) return false;\n\treturn true;\n}\n\n\nstatic rcSpan* allocSpan(rcHeightfield& hf)\n{\n\t// If running out of memory, allocate new page and update the freelist.\n\tif (!hf.freelist || !hf.freelist->next)\n\t{\n\t\t// Create new page.\n\t\t// Allocate memory for the new pool.\n\t\trcSpanPool* pool = (rcSpanPool*)rcAlloc(sizeof(rcSpanPool), RC_ALLOC_PERM);\n\t\tif (!pool) return 0;\n\n\t\t// Add the pool into the list of pools.\n\t\tpool->next = hf.pools;\n\t\thf.pools = pool;\n\t\t// Add new items to the free list.\n\t\trcSpan* freelist = hf.freelist;\n\t\trcSpan* head = &pool->items[0];\n\t\trcSpan* it = &pool->items[RC_SPANS_PER_POOL];\n\t\tdo\n\t\t{\n\t\t\t--it;\n\t\t\tit->next = freelist;\n\t\t\tfreelist = it;\n\t\t}\n\t\twhile (it != head);\n\t\thf.freelist = it;\n\t}\n\t\n\t// Pop item from in front of the free list.\n\trcSpan* it = hf.freelist;\n\thf.freelist = hf.freelist->next;\n\treturn it;\n}\n\nstatic void freeSpan(rcHeightfield& hf, rcSpan* ptr)\n{\n\tif (!ptr) return;\n\t// Add the node in front of the free list.\n\tptr->next = hf.freelist;\n\thf.freelist = ptr;\n}\n\nstatic bool addSpan(rcHeightfield& hf, const int x, const int y,\n\t\t\t\t\tconst unsigned short smin, const unsigned short smax,\n\t\t\t\t\tconst unsigned char area, const int flagMergeThr)\n{\n\t\n\tint idx = x + y*hf.width;\n\t\n\trcSpan* s = allocSpan(hf);\n\tif (!s)\n\t\treturn false;\n\ts->smin = smin;\n\ts->smax = smax;\n\ts->area = area;\n\ts->next = 0;\n\t\n\t// Empty cell, add the first span.\n\tif (!hf.spans[idx])\n\t{\n\t\thf.spans[idx] = s;\n\t\treturn true;\n\t}\n\trcSpan* prev = 0;\n\trcSpan* cur = hf.spans[idx];\n\t\n\t// Insert and merge spans.\n\twhile (cur)\n\t{\n\t\tif (cur->smin > s->smax)\n\t\t{\n\t\t\t// Current span is further than the new span, break.\n\t\t\tbreak;\n\t\t}\n\t\telse if (cur->smax < s->smin)\n\t\t{\n\t\t\t// Current span is before the new span advance.\n\t\t\tprev = cur;\n\t\t\tcur = cur->next;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// Merge spans.\n\t\t\tif (cur->smin < s->smin)\n\t\t\t\ts->smin = cur->smin;\n\t\t\tif (cur->smax > s->smax)\n\t\t\t\ts->smax = cur->smax;\n\t\t\t\n\t\t\t// Merge flags.\n\t\t\tif (rcAbs((int)s->smax - (int)cur->smax) <= flagMergeThr)\n\t\t\t\ts->area = rcMax(s->area, cur->area);\n\t\t\t\n\t\t\t// Remove current span.\n\t\t\trcSpan* next = cur->next;\n\t\t\tfreeSpan(hf, cur);\n\t\t\tif (prev)\n\t\t\t\tprev->next = next;\n\t\t\telse\n\t\t\t\thf.spans[idx] = next;\n\t\t\tcur = next;\n\t\t}\n\t}\n\t\n\t// Insert new span.\n\tif (prev)\n\t{\n\t\ts->next = prev->next;\n\t\tprev->next = s;\n\t}\n\telse\n\t{\n\t\ts->next = hf.spans[idx];\n\t\thf.spans[idx] = s;\n\t}\n\n\treturn true;\n}\n\n/// @par\n///\n/// The span addition can be set to favor flags. If the span is merged to\n/// another span and the new @p smax is within @p flagMergeThr units\n/// from the existing span, the span flags are merged.\n///\n/// @see rcHeightfield, rcSpan.\nbool rcAddSpan(rcContext* ctx, rcHeightfield& hf, const int x, const int y,\n\t\t\t   const unsigned short smin, const unsigned short smax,\n\t\t\t   const unsigned char area, const int flagMergeThr)\n{\n\trcAssert(ctx);\n\n\tif (!addSpan(hf, x, y, smin, smax, area, flagMergeThr))\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcAddSpan: Out of memory.\");\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n// divides a convex polygons into two convex polygons on both sides of a line\nstatic void dividePoly(const float* in, int nin,\n\t\t\t\t\t  float* out1, int* nout1,\n\t\t\t\t\t  float* out2, int* nout2,\n\t\t\t\t\t  float x, int axis)\n{\n\tfloat d[12];\n\tfor (int i = 0; i < nin; ++i)\n\t\td[i] = x - in[i*3+axis];\n\n\tint m = 0, n = 0;\n\tfor (int i = 0, j = nin-1; i < nin; j=i, ++i)\n\t{\n\t\tbool ina = d[j] >= 0;\n\t\tbool inb = d[i] >= 0;\n\t\tif (ina != inb)\n\t\t{\n\t\t\tfloat s = d[j] / (d[j] - d[i]);\n\t\t\tout1[m*3+0] = in[j*3+0] + (in[i*3+0] - in[j*3+0])*s;\n\t\t\tout1[m*3+1] = in[j*3+1] + (in[i*3+1] - in[j*3+1])*s;\n\t\t\tout1[m*3+2] = in[j*3+2] + (in[i*3+2] - in[j*3+2])*s;\n\t\t\trcVcopy(out2 + n*3, out1 + m*3);\n\t\t\tm++;\n\t\t\tn++;\n\t\t\t// add the i'th point to the right polygon. Do NOT add points that are on the dividing line\n\t\t\t// since these were already added above\n\t\t\tif (d[i] > 0)\n\t\t\t{\n\t\t\t\trcVcopy(out1 + m*3, in + i*3);\n\t\t\t\tm++;\n\t\t\t}\n\t\t\telse if (d[i] < 0)\n\t\t\t{\n\t\t\t\trcVcopy(out2 + n*3, in + i*3);\n\t\t\t\tn++;\n\t\t\t}\n\t\t}\n\t\telse // same side\n\t\t{\n\t\t\t// add the i'th point to the right polygon. Addition is done even for points on the dividing line\n\t\t\tif (d[i] >= 0)\n\t\t\t{\n\t\t\t\trcVcopy(out1 + m*3, in + i*3);\n\t\t\t\tm++;\n\t\t\t\tif (d[i] != 0)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t\trcVcopy(out2 + n*3, in + i*3);\n\t\t\tn++;\n\t\t}\n\t}\n\n\t*nout1 = m;\n\t*nout2 = n;\n}\n\n\n\nstatic bool rasterizeTri(const float* v0, const float* v1, const float* v2,\n\t\t\t\t\t\t const unsigned char area, rcHeightfield& hf,\n\t\t\t\t\t\t const float* bmin, const float* bmax,\n\t\t\t\t\t\t const float cs, const float ics, const float ich,\n\t\t\t\t\t\t const int flagMergeThr)\n{\n\tconst int w = hf.width;\n\tconst int h = hf.height;\n\tfloat tmin[3], tmax[3];\n\tconst float by = bmax[1] - bmin[1];\n\t\n\t// Calculate the bounding box of the triangle.\n\trcVcopy(tmin, v0);\n\trcVcopy(tmax, v0);\n\trcVmin(tmin, v1);\n\trcVmin(tmin, v2);\n\trcVmax(tmax, v1);\n\trcVmax(tmax, v2);\n\t\n\t// If the triangle does not touch the bbox of the heightfield, skip the triagle.\n\tif (!overlapBounds(bmin, bmax, tmin, tmax))\n\t\treturn true;\n\t\n\t// Calculate the footprint of the triangle on the grid's y-axis\n\tint y0 = (int)((tmin[2] - bmin[2])*ics);\n\tint y1 = (int)((tmax[2] - bmin[2])*ics);\n\ty0 = rcClamp(y0, 0, h-1);\n\ty1 = rcClamp(y1, 0, h-1);\n\t\n\t// Clip the triangle into all grid cells it touches.\n\tfloat buf[7*3*4];\n\tfloat *in = buf, *inrow = buf+7*3, *p1 = inrow+7*3, *p2 = p1+7*3;\n\n\trcVcopy(&in[0], v0);\n\trcVcopy(&in[1*3], v1);\n\trcVcopy(&in[2*3], v2);\n\tint nvrow, nvIn = 3;\n\t\n\tfor (int y = y0; y <= y1; ++y)\n\t{\n\t\t// Clip polygon to row. Store the remaining polygon as well\n\t\tconst float cz = bmin[2] + y*cs;\n\t\tdividePoly(in, nvIn, inrow, &nvrow, p1, &nvIn, cz+cs, 2);\n\t\trcSwap(in, p1);\n\t\tif (nvrow < 3) continue;\n\t\t\n\t\t// find the horizontal bounds in the row\n\t\tfloat minX = inrow[0], maxX = inrow[0];\n\t\tfor (int i=1; i<nvrow; ++i)\n\t\t{\n\t\t\tif (minX > inrow[i*3])\tminX = inrow[i*3];\n\t\t\tif (maxX < inrow[i*3])\tmaxX = inrow[i*3];\n\t\t}\n\t\tint x0 = (int)((minX - bmin[0])*ics);\n\t\tint x1 = (int)((maxX - bmin[0])*ics);\n\t\tx0 = rcClamp(x0, 0, w-1);\n\t\tx1 = rcClamp(x1, 0, w-1);\n\n\t\tint nv, nv2 = nvrow;\n\n\t\tfor (int x = x0; x <= x1; ++x)\n\t\t{\n\t\t\t// Clip polygon to column. store the remaining polygon as well\n\t\t\tconst float cx = bmin[0] + x*cs;\n\t\t\tdividePoly(inrow, nv2, p1, &nv, p2, &nv2, cx+cs, 0);\n\t\t\trcSwap(inrow, p2);\n\t\t\tif (nv < 3) continue;\n\t\t\t\n\t\t\t// Calculate min and max of the span.\n\t\t\tfloat smin = p1[1], smax = p1[1];\n\t\t\tfor (int i = 1; i < nv; ++i)\n\t\t\t{\n\t\t\t\tsmin = rcMin(smin, p1[i*3+1]);\n\t\t\t\tsmax = rcMax(smax, p1[i*3+1]);\n\t\t\t}\n\t\t\tsmin -= bmin[1];\n\t\t\tsmax -= bmin[1];\n\t\t\t// Skip the span if it is outside the heightfield bbox\n\t\t\tif (smax < 0.0f) continue;\n\t\t\tif (smin > by) continue;\n\t\t\t// Clamp the span to the heightfield bbox.\n\t\t\tif (smin < 0.0f) smin = 0;\n\t\t\tif (smax > by) smax = by;\n\t\t\t\n\t\t\t// Snap the span to the heightfield height grid.\n\t\t\tunsigned short ismin = (unsigned short)rcClamp((int)floorf(smin * ich), 0, RC_SPAN_MAX_HEIGHT);\n\t\t\tunsigned short ismax = (unsigned short)rcClamp((int)ceilf(smax * ich), (int)ismin+1, RC_SPAN_MAX_HEIGHT);\n\t\t\t\n\t\t\tif (!addSpan(hf, x, y, ismin, ismax, area, flagMergeThr))\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/// @par\n///\n/// No spans will be added if the triangle does not overlap the heightfield grid.\n///\n/// @see rcHeightfield\nbool rcRasterizeTriangle(rcContext* ctx, const float* v0, const float* v1, const float* v2,\n\t\t\t\t\t\t const unsigned char area, rcHeightfield& solid,\n\t\t\t\t\t\t const int flagMergeThr)\n{\n\trcAssert(ctx);\n\n\trcScopedTimer timer(ctx, RC_TIMER_RASTERIZE_TRIANGLES);\n\n\tconst float ics = 1.0f/solid.cs;\n\tconst float ich = 1.0f/solid.ch;\n\tif (!rasterizeTri(v0, v1, v2, area, solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr))\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcRasterizeTriangle: Out of memory.\");\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/// @par\n///\n/// Spans will only be added for triangles that overlap the heightfield grid.\n///\n/// @see rcHeightfield\nbool rcRasterizeTriangles(rcContext* ctx, const float* verts, const int /*nv*/,\n\t\t\t\t\t\t  const int* tris, const unsigned char* areas, const int nt,\n\t\t\t\t\t\t  rcHeightfield& solid, const int flagMergeThr)\n{\n\trcAssert(ctx);\n\n\trcScopedTimer timer(ctx, RC_TIMER_RASTERIZE_TRIANGLES);\n\t\n\tconst float ics = 1.0f/solid.cs;\n\tconst float ich = 1.0f/solid.ch;\n\t// Rasterize triangles.\n\tfor (int i = 0; i < nt; ++i)\n\t{\n\t\tconst float* v0 = &verts[tris[i*3+0]*3];\n\t\tconst float* v1 = &verts[tris[i*3+1]*3];\n\t\tconst float* v2 = &verts[tris[i*3+2]*3];\n\t\t// Rasterize.\n\t\tif (!rasterizeTri(v0, v1, v2, areas[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr))\n\t\t{\n\t\t\tctx->log(RC_LOG_ERROR, \"rcRasterizeTriangles: Out of memory.\");\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/// @par\n///\n/// Spans will only be added for triangles that overlap the heightfield grid.\n///\n/// @see rcHeightfield\nbool rcRasterizeTriangles(rcContext* ctx, const float* verts, const int /*nv*/,\n\t\t\t\t\t\t  const unsigned short* tris, const unsigned char* areas, const int nt,\n\t\t\t\t\t\t  rcHeightfield& solid, const int flagMergeThr)\n{\n\trcAssert(ctx);\n\n\trcScopedTimer timer(ctx, RC_TIMER_RASTERIZE_TRIANGLES);\n\t\n\tconst float ics = 1.0f/solid.cs;\n\tconst float ich = 1.0f/solid.ch;\n\t// Rasterize triangles.\n\tfor (int i = 0; i < nt; ++i)\n\t{\n\t\tconst float* v0 = &verts[tris[i*3+0]*3];\n\t\tconst float* v1 = &verts[tris[i*3+1]*3];\n\t\tconst float* v2 = &verts[tris[i*3+2]*3];\n\t\t// Rasterize.\n\t\tif (!rasterizeTri(v0, v1, v2, areas[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr))\n\t\t{\n\t\t\tctx->log(RC_LOG_ERROR, \"rcRasterizeTriangles: Out of memory.\");\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/// @par\n///\n/// Spans will only be added for triangles that overlap the heightfield grid.\n///\n/// @see rcHeightfield\nbool rcRasterizeTriangles(rcContext* ctx, const float* verts, const unsigned char* areas, const int nt,\n\t\t\t\t\t\t  rcHeightfield& solid, const int flagMergeThr)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_RASTERIZE_TRIANGLES);\n\t\n\tconst float ics = 1.0f/solid.cs;\n\tconst float ich = 1.0f/solid.ch;\n\t// Rasterize triangles.\n\tfor (int i = 0; i < nt; ++i)\n\t{\n\t\tconst float* v0 = &verts[(i*3+0)*3];\n\t\tconst float* v1 = &verts[(i*3+1)*3];\n\t\tconst float* v2 = &verts[(i*3+2)*3];\n\t\t// Rasterize.\n\t\tif (!rasterizeTri(v0, v1, v2, areas[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr))\n\t\t{\n\t\t\tctx->log(RC_LOG_ERROR, \"rcRasterizeTriangles: Out of memory.\");\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"
  },
  {
    "path": "third_parties/recast/recast/Recast/Source/RecastRegion.cpp",
    "content": "//\n// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org\n//\n// This software is provided 'as-is', without any express or implied\n// warranty.  In no event will the authors be held liable for any damages\n// arising from the use of this software.\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would be\n//    appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//    misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n//\n\n#include <float.h>\n#define _USE_MATH_DEFINES\n#include <math.h>\n#include <string.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include \"Recast.h\"\n#include \"RecastAlloc.h\"\n#include \"RecastAssert.h\"\n\nnamespace\n{\nstruct LevelStackEntry\n{\n\tLevelStackEntry(int x_, int y_, int index_) : x(x_), y(y_), index(index_) {}\n\tint x;\n\tint y;\n\tint index;\n};\n}  // namespace\n\nstatic void calculateDistanceField(rcCompactHeightfield& chf, unsigned short* src, unsigned short& maxDist)\n{\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\t\n\t// Init distance and points.\n\tfor (int i = 0; i < chf.spanCount; ++i)\n\t\tsrc[i] = 0xffff;\n\t\n\t// Mark boundary cells.\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tconst unsigned char area = chf.areas[i];\n\t\t\t\t\n\t\t\t\tint nc = 0;\n\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t{\n\t\t\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);\n\t\t\t\t\t\tif (area == chf.areas[ai])\n\t\t\t\t\t\t\tnc++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (nc != 4)\n\t\t\t\t\tsrc[i] = 0;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t\t\t\n\t// Pass 1\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\t\n\t\t\t\tif (rcGetCon(s, 0) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\t// (-1,0)\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(0);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(0);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);\n\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\tif (src[ai]+2 < src[i])\n\t\t\t\t\t\tsrc[i] = src[ai]+2;\n\t\t\t\t\t\n\t\t\t\t\t// (-1,-1)\n\t\t\t\t\tif (rcGetCon(as, 3) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int aax = ax + rcGetDirOffsetX(3);\n\t\t\t\t\t\tconst int aay = ay + rcGetDirOffsetY(3);\n\t\t\t\t\t\tconst int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 3);\n\t\t\t\t\t\tif (src[aai]+3 < src[i])\n\t\t\t\t\t\t\tsrc[i] = src[aai]+3;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (rcGetCon(s, 3) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\t// (0,-1)\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(3);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(3);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);\n\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\tif (src[ai]+2 < src[i])\n\t\t\t\t\t\tsrc[i] = src[ai]+2;\n\t\t\t\t\t\n\t\t\t\t\t// (1,-1)\n\t\t\t\t\tif (rcGetCon(as, 2) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int aax = ax + rcGetDirOffsetX(2);\n\t\t\t\t\t\tconst int aay = ay + rcGetDirOffsetY(2);\n\t\t\t\t\t\tconst int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 2);\n\t\t\t\t\t\tif (src[aai]+3 < src[i])\n\t\t\t\t\t\t\tsrc[i] = src[aai]+3;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Pass 2\n\tfor (int y = h-1; y >= 0; --y)\n\t{\n\t\tfor (int x = w-1; x >= 0; --x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\t\n\t\t\t\tif (rcGetCon(s, 2) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\t// (1,0)\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(2);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(2);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 2);\n\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\tif (src[ai]+2 < src[i])\n\t\t\t\t\t\tsrc[i] = src[ai]+2;\n\t\t\t\t\t\n\t\t\t\t\t// (1,1)\n\t\t\t\t\tif (rcGetCon(as, 1) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int aax = ax + rcGetDirOffsetX(1);\n\t\t\t\t\t\tconst int aay = ay + rcGetDirOffsetY(1);\n\t\t\t\t\t\tconst int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 1);\n\t\t\t\t\t\tif (src[aai]+3 < src[i])\n\t\t\t\t\t\t\tsrc[i] = src[aai]+3;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (rcGetCon(s, 1) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\t// (0,1)\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(1);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(1);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 1);\n\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\tif (src[ai]+2 < src[i])\n\t\t\t\t\t\tsrc[i] = src[ai]+2;\n\t\t\t\t\t\n\t\t\t\t\t// (-1,1)\n\t\t\t\t\tif (rcGetCon(as, 0) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int aax = ax + rcGetDirOffsetX(0);\n\t\t\t\t\t\tconst int aay = ay + rcGetDirOffsetY(0);\n\t\t\t\t\t\tconst int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 0);\n\t\t\t\t\t\tif (src[aai]+3 < src[i])\n\t\t\t\t\t\t\tsrc[i] = src[aai]+3;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\t\n\t\n\tmaxDist = 0;\n\tfor (int i = 0; i < chf.spanCount; ++i)\n\t\tmaxDist = rcMax(src[i], maxDist);\n\t\n}\n\nstatic unsigned short* boxBlur(rcCompactHeightfield& chf, int thr,\n\t\t\t\t\t\t\t   unsigned short* src, unsigned short* dst)\n{\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\t\n\tthr *= 2;\n\t\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tconst unsigned short cd = src[i];\n\t\t\t\tif (cd <= thr)\n\t\t\t\t{\n\t\t\t\t\tdst[i] = cd;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tint d = (int)cd;\n\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t{\n\t\t\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);\n\t\t\t\t\t\td += (int)src[ai];\n\t\t\t\t\t\t\n\t\t\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\t\tconst int dir2 = (dir+1) & 0x3;\n\t\t\t\t\t\tif (rcGetCon(as, dir2) != RC_NOT_CONNECTED)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst int ax2 = ax + rcGetDirOffsetX(dir2);\n\t\t\t\t\t\t\tconst int ay2 = ay + rcGetDirOffsetY(dir2);\n\t\t\t\t\t\t\tconst int ai2 = (int)chf.cells[ax2+ay2*w].index + rcGetCon(as, dir2);\n\t\t\t\t\t\t\td += (int)src[ai2];\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\td += cd;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\td += cd*2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdst[i] = (unsigned short)((d+5)/9);\n\t\t\t}\n\t\t}\n\t}\n\treturn dst;\n}\n\n\nstatic bool floodRegion(int x, int y, int i,\n\t\t\t\t\t\tunsigned short level, unsigned short r,\n\t\t\t\t\t\trcCompactHeightfield& chf,\n\t\t\t\t\t\tunsigned short* srcReg, unsigned short* srcDist,\n\t\t\t\t\t\trcTempVector<LevelStackEntry>& stack)\n{\n\tconst int w = chf.width;\n\t\n\tconst unsigned char area = chf.areas[i];\n\t\n\t// Flood fill mark region.\n\tstack.clear();\n\tstack.push_back(LevelStackEntry(x, y, i));\n\tsrcReg[i] = r;\n\tsrcDist[i] = 0;\n\t\n\tunsigned short lev = level >= 2 ? level-2 : 0;\n\tint count = 0;\n\t\n\twhile (stack.size() > 0)\n\t{\n\t\tLevelStackEntry& back = stack.back();\n\t\tint cx = back.x;\n\t\tint cy = back.y;\n\t\tint ci = back.index;\n\t\tstack.pop_back();\n\t\t\n\t\tconst rcCompactSpan& cs = chf.spans[ci];\n\t\t\n\t\t// Check if any of the neighbours already have a valid region set.\n\t\tunsigned short ar = 0;\n\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t{\n\t\t\t// 8 connected\n\t\t\tif (rcGetCon(cs, dir) != RC_NOT_CONNECTED)\n\t\t\t{\n\t\t\t\tconst int ax = cx + rcGetDirOffsetX(dir);\n\t\t\t\tconst int ay = cy + rcGetDirOffsetY(dir);\n\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(cs, dir);\n\t\t\t\tif (chf.areas[ai] != area)\n\t\t\t\t\tcontinue;\n\t\t\t\tunsigned short nr = srcReg[ai];\n\t\t\t\tif (nr & RC_BORDER_REG) // Do not take borders into account.\n\t\t\t\t\tcontinue;\n\t\t\t\tif (nr != 0 && nr != r)\n\t\t\t\t{\n\t\t\t\t\tar = nr;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tconst rcCompactSpan& as = chf.spans[ai];\n\t\t\t\t\n\t\t\t\tconst int dir2 = (dir+1) & 0x3;\n\t\t\t\tif (rcGetCon(as, dir2) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\tconst int ax2 = ax + rcGetDirOffsetX(dir2);\n\t\t\t\t\tconst int ay2 = ay + rcGetDirOffsetY(dir2);\n\t\t\t\t\tconst int ai2 = (int)chf.cells[ax2+ay2*w].index + rcGetCon(as, dir2);\n\t\t\t\t\tif (chf.areas[ai2] != area)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tunsigned short nr2 = srcReg[ai2];\n\t\t\t\t\tif (nr2 != 0 && nr2 != r)\n\t\t\t\t\t{\n\t\t\t\t\t\tar = nr2;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tif (ar != 0)\n\t\t{\n\t\t\tsrcReg[ci] = 0;\n\t\t\tcontinue;\n\t\t}\n\t\t\n\t\tcount++;\n\t\t\n\t\t// Expand neighbours.\n\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t{\n\t\t\tif (rcGetCon(cs, dir) != RC_NOT_CONNECTED)\n\t\t\t{\n\t\t\t\tconst int ax = cx + rcGetDirOffsetX(dir);\n\t\t\t\tconst int ay = cy + rcGetDirOffsetY(dir);\n\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(cs, dir);\n\t\t\t\tif (chf.areas[ai] != area)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (chf.dist[ai] >= lev && srcReg[ai] == 0)\n\t\t\t\t{\n\t\t\t\t\tsrcReg[ai] = r;\n\t\t\t\t\tsrcDist[ai] = 0;\n\t\t\t\t\tstack.push_back(LevelStackEntry(ax, ay, ai));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn count > 0;\n}\n\n// Struct to keep track of entries in the region table that have been changed.\nstruct DirtyEntry\n{\n\tDirtyEntry(int index_, unsigned short region_, unsigned short distance2_)\n\t\t: index(index_), region(region_), distance2(distance2_) {}\n\tint index;\n\tunsigned short region;\n\tunsigned short distance2;\n};\nstatic void expandRegions(int maxIter, unsigned short level,\n\t\t\t\t\t      rcCompactHeightfield& chf,\n\t\t\t\t\t      unsigned short* srcReg, unsigned short* srcDist,\n\t\t\t\t\t      rcTempVector<LevelStackEntry>& stack,\n\t\t\t\t\t      bool fillStack)\n{\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\n\tif (fillStack)\n\t{\n\t\t// Find cells revealed by the raised level.\n\t\tstack.clear();\n\t\tfor (int y = 0; y < h; ++y)\n\t\t{\n\t\t\tfor (int x = 0; x < w; ++x)\n\t\t\t{\n\t\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t\t{\n\t\t\t\t\tif (chf.dist[i] >= level && srcReg[i] == 0 && chf.areas[i] != RC_NULL_AREA)\n\t\t\t\t\t{\n\t\t\t\t\t\tstack.push_back(LevelStackEntry(x, y, i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse // use cells in the input stack\n\t{\n\t\t// mark all cells which already have a region\n\t\tfor (int j=0; j<stack.size(); j++)\n\t\t{\n\t\t\tint i = stack[j].index;\n\t\t\tif (srcReg[i] != 0)\n\t\t\t\tstack[j].index = -1;\n\t\t}\n\t}\n\n\trcTempVector<DirtyEntry> dirtyEntries;\n\tint iter = 0;\n\twhile (stack.size() > 0)\n\t{\n\t\tint failed = 0;\n\t\tdirtyEntries.clear();\n\t\t\n\t\tfor (int j = 0; j < stack.size(); j++)\n\t\t{\n\t\t\tint x = stack[j].x;\n\t\t\tint y = stack[j].y;\n\t\t\tint i = stack[j].index;\n\t\t\tif (i < 0)\n\t\t\t{\n\t\t\t\tfailed++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tunsigned short r = srcReg[i];\n\t\t\tunsigned short d2 = 0xffff;\n\t\t\tconst unsigned char area = chf.areas[i];\n\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t{\n\t\t\t\tif (rcGetCon(s, dir) == RC_NOT_CONNECTED) continue;\n\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);\n\t\t\t\tif (chf.areas[ai] != area) continue;\n\t\t\t\tif (srcReg[ai] > 0 && (srcReg[ai] & RC_BORDER_REG) == 0)\n\t\t\t\t{\n\t\t\t\t\tif ((int)srcDist[ai]+2 < (int)d2)\n\t\t\t\t\t{\n\t\t\t\t\t\tr = srcReg[ai];\n\t\t\t\t\t\td2 = srcDist[ai]+2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (r)\n\t\t\t{\n\t\t\t\tstack[j].index = -1; // mark as used\n\t\t\t\tdirtyEntries.push_back(DirtyEntry(i, r, d2));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfailed++;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Copy entries that differ between src and dst to keep them in sync.\n\t\tfor (int i = 0; i < dirtyEntries.size(); i++) {\n\t\t\tint idx = dirtyEntries[i].index;\n\t\t\tsrcReg[idx] = dirtyEntries[i].region;\n\t\t\tsrcDist[idx] = dirtyEntries[i].distance2;\n\t\t}\n\t\t\n\t\tif (failed == stack.size())\n\t\t\tbreak;\n\t\t\n\t\tif (level > 0)\n\t\t{\n\t\t\t++iter;\n\t\t\tif (iter >= maxIter)\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n\nstatic void sortCellsByLevel(unsigned short startLevel,\n\t\t\t\t\t\t\t  rcCompactHeightfield& chf,\n\t\t\t\t\t\t\t  const unsigned short* srcReg,\n\t\t\t\t\t\t\t  unsigned int nbStacks, rcTempVector<LevelStackEntry>* stacks,\n\t\t\t\t\t\t\t  unsigned short loglevelsPerStack) // the levels per stack (2 in our case) as a bit shift\n{\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\tstartLevel = startLevel >> loglevelsPerStack;\n\n\tfor (unsigned int j=0; j<nbStacks; ++j)\n\t\tstacks[j].clear();\n\n\t// put all cells in the level range into the appropriate stacks\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tif (chf.areas[i] == RC_NULL_AREA || srcReg[i] != 0)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tint level = chf.dist[i] >> loglevelsPerStack;\n\t\t\t\tint sId = startLevel - level;\n\t\t\t\tif (sId >= (int)nbStacks)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (sId < 0)\n\t\t\t\t\tsId = 0;\n\n\t\t\t\tstacks[sId].push_back(LevelStackEntry(x, y, i));\n\t\t\t}\n\t\t}\n\t}\n}\n\n\nstatic void appendStacks(const rcTempVector<LevelStackEntry>& srcStack,\n\t\t\t\t\t\t rcTempVector<LevelStackEntry>& dstStack,\n\t\t\t\t\t\t const unsigned short* srcReg)\n{\n\tfor (int j=0; j<srcStack.size(); j++)\n\t{\n\t\tint i = srcStack[j].index;\n\t\tif ((i < 0) || (srcReg[i] != 0))\n\t\t\tcontinue;\n\t\tdstStack.push_back(srcStack[j]);\n\t}\n}\n\nstruct rcRegion\n{\n\tinline rcRegion(unsigned short i) :\n\t\tspanCount(0),\n\t\tid(i),\n\t\tareaType(0),\n\t\tremap(false),\n\t\tvisited(false),\n\t\toverlap(false),\n\t\tconnectsToBorder(false),\n\t\tymin(0xffff),\n\t\tymax(0)\n\t{}\n\t\n\tint spanCount;\t\t\t\t\t// Number of spans belonging to this region\n\tunsigned short id;\t\t\t\t// ID of the region\n\tunsigned char areaType;\t\t\t// Are type.\n\tbool remap;\n\tbool visited;\n\tbool overlap;\n\tbool connectsToBorder;\n\tunsigned short ymin, ymax;\n\trcIntArray connections;\n\trcIntArray floors;\n};\n\nstatic void removeAdjacentNeighbours(rcRegion& reg)\n{\n\t// Remove adjacent duplicates.\n\tfor (int i = 0; i < reg.connections.size() && reg.connections.size() > 1; )\n\t{\n\t\tint ni = (i+1) % reg.connections.size();\n\t\tif (reg.connections[i] == reg.connections[ni])\n\t\t{\n\t\t\t// Remove duplicate\n\t\t\tfor (int j = i; j < reg.connections.size()-1; ++j)\n\t\t\t\treg.connections[j] = reg.connections[j+1];\n\t\t\treg.connections.pop();\n\t\t}\n\t\telse\n\t\t\t++i;\n\t}\n}\n\nstatic void replaceNeighbour(rcRegion& reg, unsigned short oldId, unsigned short newId)\n{\n\tbool neiChanged = false;\n\tfor (int i = 0; i < reg.connections.size(); ++i)\n\t{\n\t\tif (reg.connections[i] == oldId)\n\t\t{\n\t\t\treg.connections[i] = newId;\n\t\t\tneiChanged = true;\n\t\t}\n\t}\n\tfor (int i = 0; i < reg.floors.size(); ++i)\n\t{\n\t\tif (reg.floors[i] == oldId)\n\t\t\treg.floors[i] = newId;\n\t}\n\tif (neiChanged)\n\t\tremoveAdjacentNeighbours(reg);\n}\n\nstatic bool canMergeWithRegion(const rcRegion& rega, const rcRegion& regb)\n{\n\tif (rega.areaType != regb.areaType)\n\t\treturn false;\n\tint n = 0;\n\tfor (int i = 0; i < rega.connections.size(); ++i)\n\t{\n\t\tif (rega.connections[i] == regb.id)\n\t\t\tn++;\n\t}\n\tif (n > 1)\n\t\treturn false;\n\tfor (int i = 0; i < rega.floors.size(); ++i)\n\t{\n\t\tif (rega.floors[i] == regb.id)\n\t\t\treturn false;\n\t}\n\treturn true;\n}\n\nstatic void addUniqueFloorRegion(rcRegion& reg, int n)\n{\n\tfor (int i = 0; i < reg.floors.size(); ++i)\n\t\tif (reg.floors[i] == n)\n\t\t\treturn;\n\treg.floors.push(n);\n}\n\nstatic bool mergeRegions(rcRegion& rega, rcRegion& regb)\n{\n\tunsigned short aid = rega.id;\n\tunsigned short bid = regb.id;\n\t\n\t// Duplicate current neighbourhood.\n\trcIntArray acon;\n\tacon.resize(rega.connections.size());\n\tfor (int i = 0; i < rega.connections.size(); ++i)\n\t\tacon[i] = rega.connections[i];\n\trcIntArray& bcon = regb.connections;\n\t\n\t// Find insertion point on A.\n\tint insa = -1;\n\tfor (int i = 0; i < acon.size(); ++i)\n\t{\n\t\tif (acon[i] == bid)\n\t\t{\n\t\t\tinsa = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (insa == -1)\n\t\treturn false;\n\t\n\t// Find insertion point on B.\n\tint insb = -1;\n\tfor (int i = 0; i < bcon.size(); ++i)\n\t{\n\t\tif (bcon[i] == aid)\n\t\t{\n\t\t\tinsb = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (insb == -1)\n\t\treturn false;\n\t\n\t// Merge neighbours.\n\trega.connections.resize(0);\n\tfor (int i = 0, ni = acon.size(); i < ni-1; ++i)\n\t\trega.connections.push(acon[(insa+1+i) % ni]);\n\t\t\n\tfor (int i = 0, ni = bcon.size(); i < ni-1; ++i)\n\t\trega.connections.push(bcon[(insb+1+i) % ni]);\n\t\n\tremoveAdjacentNeighbours(rega);\n\t\n\tfor (int j = 0; j < regb.floors.size(); ++j)\n\t\taddUniqueFloorRegion(rega, regb.floors[j]);\n\trega.spanCount += regb.spanCount;\n\tregb.spanCount = 0;\n\tregb.connections.resize(0);\n\n\treturn true;\n}\n\nstatic bool isRegionConnectedToBorder(const rcRegion& reg)\n{\n\t// Region is connected to border if\n\t// one of the neighbours is null id.\n\tfor (int i = 0; i < reg.connections.size(); ++i)\n\t{\n\t\tif (reg.connections[i] == 0)\n\t\t\treturn true;\n\t}\n\treturn false;\n}\n\nstatic bool isSolidEdge(rcCompactHeightfield& chf, const unsigned short* srcReg,\n\t\t\t\t\t\tint x, int y, int i, int dir)\n{\n\tconst rcCompactSpan& s = chf.spans[i];\n\tunsigned short r = 0;\n\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t{\n\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\tconst int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);\n\t\tr = srcReg[ai];\n\t}\n\tif (r == srcReg[i])\n\t\treturn false;\n\treturn true;\n}\n\nstatic void walkContour(int x, int y, int i, int dir,\n\t\t\t\t\t\trcCompactHeightfield& chf,\n\t\t\t\t\t\tconst unsigned short* srcReg,\n\t\t\t\t\t\trcIntArray& cont)\n{\n\tint startDir = dir;\n\tint starti = i;\n\n\tconst rcCompactSpan& ss = chf.spans[i];\n\tunsigned short curReg = 0;\n\tif (rcGetCon(ss, dir) != RC_NOT_CONNECTED)\n\t{\n\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\tconst int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(ss, dir);\n\t\tcurReg = srcReg[ai];\n\t}\n\tcont.push(curReg);\n\t\t\t\n\tint iter = 0;\n\twhile (++iter < 40000)\n\t{\n\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\n\t\tif (isSolidEdge(chf, srcReg, x, y, i, dir))\n\t\t{\n\t\t\t// Choose the edge corner\n\t\t\tunsigned short r = 0;\n\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t{\n\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\tconst int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);\n\t\t\t\tr = srcReg[ai];\n\t\t\t}\n\t\t\tif (r != curReg)\n\t\t\t{\n\t\t\t\tcurReg = r;\n\t\t\t\tcont.push(curReg);\n\t\t\t}\n\t\t\t\n\t\t\tdir = (dir+1) & 0x3;  // Rotate CW\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint ni = -1;\n\t\t\tconst int nx = x + rcGetDirOffsetX(dir);\n\t\t\tconst int ny = y + rcGetDirOffsetY(dir);\n\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t{\n\t\t\t\tconst rcCompactCell& nc = chf.cells[nx+ny*chf.width];\n\t\t\t\tni = (int)nc.index + rcGetCon(s, dir);\n\t\t\t}\n\t\t\tif (ni == -1)\n\t\t\t{\n\t\t\t\t// Should not happen.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tx = nx;\n\t\t\ty = ny;\n\t\t\ti = ni;\n\t\t\tdir = (dir+3) & 0x3;\t// Rotate CCW\n\t\t}\n\t\t\n\t\tif (starti == i && startDir == dir)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Remove adjacent duplicates.\n\tif (cont.size() > 1)\n\t{\n\t\tfor (int j = 0; j < cont.size(); )\n\t\t{\n\t\t\tint nj = (j+1) % cont.size();\n\t\t\tif (cont[j] == cont[nj])\n\t\t\t{\n\t\t\t\tfor (int k = j; k < cont.size()-1; ++k)\n\t\t\t\t\tcont[k] = cont[k+1];\n\t\t\t\tcont.pop();\n\t\t\t}\n\t\t\telse\n\t\t\t\t++j;\n\t\t}\n\t}\n}\n\n\nstatic bool mergeAndFilterRegions(rcContext* ctx, int minRegionArea, int mergeRegionSize,\n\t\t\t\t\t\t\t\t  unsigned short& maxRegionId,\n\t\t\t\t\t\t\t\t  rcCompactHeightfield& chf,\n\t\t\t\t\t\t\t\t  unsigned short* srcReg, rcIntArray& overlaps)\n{\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\t\n\tconst int nreg = maxRegionId+1;\n\trcTempVector<rcRegion> regions;\n\tif (!regions.reserve(nreg)) {\n\t\tctx->log(RC_LOG_ERROR, \"mergeAndFilterRegions: Out of memory 'regions' (%d).\", nreg);\n\t\treturn false;\n\t}\n\n\t// Construct regions\n\tfor (int i = 0; i < nreg; ++i)\n\t\tregions.push_back(rcRegion((unsigned short) i));\n\t\n\t// Find edge of a region and find connections around the contour.\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tunsigned short r = srcReg[i];\n\t\t\t\tif (r == 0 || r >= nreg)\n\t\t\t\t\tcontinue;\n\t\t\t\t\n\t\t\t\trcRegion& reg = regions[r];\n\t\t\t\treg.spanCount++;\n\t\t\t\t\n\t\t\t\t// Update floors.\n\t\t\t\tfor (int j = (int)c.index; j < ni; ++j)\n\t\t\t\t{\n\t\t\t\t\tif (i == j) continue;\n\t\t\t\t\tunsigned short floorId = srcReg[j];\n\t\t\t\t\tif (floorId == 0 || floorId >= nreg)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (floorId == r)\n\t\t\t\t\t\treg.overlap = true;\n\t\t\t\t\taddUniqueFloorRegion(reg, floorId);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Have found contour\n\t\t\t\tif (reg.connections.size() > 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t\n\t\t\t\treg.areaType = chf.areas[i];\n\t\t\t\t\n\t\t\t\t// Check if this cell is next to a border.\n\t\t\t\tint ndir = -1;\n\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t{\n\t\t\t\t\tif (isSolidEdge(chf, srcReg, x, y, i, dir))\n\t\t\t\t\t{\n\t\t\t\t\t\tndir = dir;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (ndir != -1)\n\t\t\t\t{\n\t\t\t\t\t// The cell is at border.\n\t\t\t\t\t// Walk around the contour to find all the neighbours.\n\t\t\t\t\twalkContour(x, y, i, ndir, chf, srcReg, reg.connections);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Remove too small regions.\n\trcIntArray stack(32);\n\trcIntArray trace(32);\n\tfor (int i = 0; i < nreg; ++i)\n\t{\n\t\trcRegion& reg = regions[i];\n\t\tif (reg.id == 0 || (reg.id & RC_BORDER_REG))\n\t\t\tcontinue;                       \n\t\tif (reg.spanCount == 0)\n\t\t\tcontinue;\n\t\tif (reg.visited)\n\t\t\tcontinue;\n\t\t\n\t\t// Count the total size of all the connected regions.\n\t\t// Also keep track of the regions connects to a tile border.\n\t\tbool connectsToBorder = false;\n\t\tint spanCount = 0;\n\t\tstack.resize(0);\n\t\ttrace.resize(0);\n\n\t\treg.visited = true;\n\t\tstack.push(i);\n\t\t\n\t\twhile (stack.size())\n\t\t{\n\t\t\t// Pop\n\t\t\tint ri = stack.pop();\n\t\t\t\n\t\t\trcRegion& creg = regions[ri];\n\n\t\t\tspanCount += creg.spanCount;\n\t\t\ttrace.push(ri);\n\n\t\t\tfor (int j = 0; j < creg.connections.size(); ++j)\n\t\t\t{\n\t\t\t\tif (creg.connections[j] & RC_BORDER_REG)\n\t\t\t\t{\n\t\t\t\t\tconnectsToBorder = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\trcRegion& neireg = regions[creg.connections[j]];\n\t\t\t\tif (neireg.visited)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (neireg.id == 0 || (neireg.id & RC_BORDER_REG))\n\t\t\t\t\tcontinue;\n\t\t\t\t// Visit\n\t\t\t\tstack.push(neireg.id);\n\t\t\t\tneireg.visited = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// If the accumulated regions size is too small, remove it.\n\t\t// Do not remove areas which connect to tile borders\n\t\t// as their size cannot be estimated correctly and removing them\n\t\t// can potentially remove necessary areas.\n\t\tif (spanCount < minRegionArea && !connectsToBorder)\n\t\t{\n\t\t\t// Kill all visited regions.\n\t\t\tfor (int j = 0; j < trace.size(); ++j)\n\t\t\t{\n\t\t\t\tregions[trace[j]].spanCount = 0;\n\t\t\t\tregions[trace[j]].id = 0;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Merge too small regions to neighbour regions.\n\tint mergeCount = 0 ;\n\tdo\n\t{\n\t\tmergeCount = 0;\n\t\tfor (int i = 0; i < nreg; ++i)\n\t\t{\n\t\t\trcRegion& reg = regions[i];\n\t\t\tif (reg.id == 0 || (reg.id & RC_BORDER_REG))\n\t\t\t\tcontinue;\n\t\t\tif (reg.overlap)\n\t\t\t\tcontinue;\n\t\t\tif (reg.spanCount == 0)\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\t// Check to see if the region should be merged.\n\t\t\tif (reg.spanCount > mergeRegionSize && isRegionConnectedToBorder(reg))\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\t// Small region with more than 1 connection.\n\t\t\t// Or region which is not connected to a border at all.\n\t\t\t// Find smallest neighbour region that connects to this one.\n\t\t\tint smallest = 0xfffffff;\n\t\t\tunsigned short mergeId = reg.id;\n\t\t\tfor (int j = 0; j < reg.connections.size(); ++j)\n\t\t\t{\n\t\t\t\tif (reg.connections[j] & RC_BORDER_REG) continue;\n\t\t\t\trcRegion& mreg = regions[reg.connections[j]];\n\t\t\t\tif (mreg.id == 0 || (mreg.id & RC_BORDER_REG) || mreg.overlap) continue;\n\t\t\t\tif (mreg.spanCount < smallest &&\n\t\t\t\t\tcanMergeWithRegion(reg, mreg) &&\n\t\t\t\t\tcanMergeWithRegion(mreg, reg))\n\t\t\t\t{\n\t\t\t\t\tsmallest = mreg.spanCount;\n\t\t\t\t\tmergeId = mreg.id;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Found new id.\n\t\t\tif (mergeId != reg.id)\n\t\t\t{\n\t\t\t\tunsigned short oldId = reg.id;\n\t\t\t\trcRegion& target = regions[mergeId];\n\t\t\t\t\n\t\t\t\t// Merge neighbours.\n\t\t\t\tif (mergeRegions(target, reg))\n\t\t\t\t{\n\t\t\t\t\t// Fixup regions pointing to current region.\n\t\t\t\t\tfor (int j = 0; j < nreg; ++j)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (regions[j].id == 0 || (regions[j].id & RC_BORDER_REG)) continue;\n\t\t\t\t\t\t// If another region was already merged into current region\n\t\t\t\t\t\t// change the nid of the previous region too.\n\t\t\t\t\t\tif (regions[j].id == oldId)\n\t\t\t\t\t\t\tregions[j].id = mergeId;\n\t\t\t\t\t\t// Replace the current region with the new one if the\n\t\t\t\t\t\t// current regions is neighbour.\n\t\t\t\t\t\treplaceNeighbour(regions[j], oldId, mergeId);\n\t\t\t\t\t}\n\t\t\t\t\tmergeCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\twhile (mergeCount > 0);\n\t\n\t// Compress region Ids.\n\tfor (int i = 0; i < nreg; ++i)\n\t{\n\t\tregions[i].remap = false;\n\t\tif (regions[i].id == 0) continue;       // Skip nil regions.\n\t\tif (regions[i].id & RC_BORDER_REG) continue;    // Skip external regions.\n\t\tregions[i].remap = true;\n\t}\n\t\n\tunsigned short regIdGen = 0;\n\tfor (int i = 0; i < nreg; ++i)\n\t{\n\t\tif (!regions[i].remap)\n\t\t\tcontinue;\n\t\tunsigned short oldId = regions[i].id;\n\t\tunsigned short newId = ++regIdGen;\n\t\tfor (int j = i; j < nreg; ++j)\n\t\t{\n\t\t\tif (regions[j].id == oldId)\n\t\t\t{\n\t\t\t\tregions[j].id = newId;\n\t\t\t\tregions[j].remap = false;\n\t\t\t}\n\t\t}\n\t}\n\tmaxRegionId = regIdGen;\n\t\n\t// Remap regions.\n\tfor (int i = 0; i < chf.spanCount; ++i)\n\t{\n\t\tif ((srcReg[i] & RC_BORDER_REG) == 0)\n\t\t\tsrcReg[i] = regions[srcReg[i]].id;\n\t}\n\n\t// Return regions that we found to be overlapping.\n\tfor (int i = 0; i < nreg; ++i)\n\t\tif (regions[i].overlap)\n\t\t\toverlaps.push(regions[i].id);\n\n\treturn true;\n}\n\n\nstatic void addUniqueConnection(rcRegion& reg, int n)\n{\n\tfor (int i = 0; i < reg.connections.size(); ++i)\n\t\tif (reg.connections[i] == n)\n\t\t\treturn;\n\treg.connections.push(n);\n}\n\nstatic bool mergeAndFilterLayerRegions(rcContext* ctx, int minRegionArea,\n\t\t\t\t\t\t\t\t\t   unsigned short& maxRegionId,\n\t\t\t\t\t\t\t\t\t   rcCompactHeightfield& chf,\n\t\t\t\t\t\t\t\t\t   unsigned short* srcReg)\n{\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\t\n\tconst int nreg = maxRegionId+1;\n\trcTempVector<rcRegion> regions;\n\t\n\t// Construct regions\n\tif (!regions.reserve(nreg)) {\n\t\tctx->log(RC_LOG_ERROR, \"mergeAndFilterLayerRegions: Out of memory 'regions' (%d).\", nreg);\n\t\treturn false;\n\t}\n\tfor (int i = 0; i < nreg; ++i)\n\t\tregions.push_back(rcRegion((unsigned short) i));\n\t\n\t// Find region neighbours and overlapping regions.\n\trcIntArray lregs(32);\n\tfor (int y = 0; y < h; ++y)\n\t{\n\t\tfor (int x = 0; x < w; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\n\t\t\tlregs.resize(0);\n\t\t\t\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tconst unsigned short ri = srcReg[i];\n\t\t\t\tif (ri == 0 || ri >= nreg) continue;\n\t\t\t\trcRegion& reg = regions[ri];\n\t\t\t\t\n\t\t\t\treg.spanCount++;\n\t\t\t\t\n\t\t\t\treg.ymin = rcMin(reg.ymin, s.y);\n\t\t\t\treg.ymax = rcMax(reg.ymax, s.y);\n\t\t\t\t\n\t\t\t\t// Collect all region layers.\n\t\t\t\tlregs.push(ri);\n\t\t\t\t\n\t\t\t\t// Update neighbours\n\t\t\t\tfor (int dir = 0; dir < 4; ++dir)\n\t\t\t\t{\n\t\t\t\t\tif (rcGetCon(s, dir) != RC_NOT_CONNECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(dir);\n\t\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(dir);\n\t\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);\n\t\t\t\t\t\tconst unsigned short rai = srcReg[ai];\n\t\t\t\t\t\tif (rai > 0 && rai < nreg && rai != ri)\n\t\t\t\t\t\t\taddUniqueConnection(reg, rai);\n\t\t\t\t\t\tif (rai & RC_BORDER_REG)\n\t\t\t\t\t\t\treg.connectsToBorder = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t// Update overlapping regions.\n\t\t\tfor (int i = 0; i < lregs.size()-1; ++i)\n\t\t\t{\n\t\t\t\tfor (int j = i+1; j < lregs.size(); ++j)\n\t\t\t\t{\n\t\t\t\t\tif (lregs[i] != lregs[j])\n\t\t\t\t\t{\n\t\t\t\t\t\trcRegion& ri = regions[lregs[i]];\n\t\t\t\t\t\trcRegion& rj = regions[lregs[j]];\n\t\t\t\t\t\taddUniqueFloorRegion(ri, lregs[j]);\n\t\t\t\t\t\taddUniqueFloorRegion(rj, lregs[i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n\t// Create 2D layers from regions.\n\tunsigned short layerId = 1;\n\n\tfor (int i = 0; i < nreg; ++i)\n\t\tregions[i].id = 0;\n\n\t// Merge montone regions to create non-overlapping areas.\n\trcIntArray stack(32);\n\tfor (int i = 1; i < nreg; ++i)\n\t{\n\t\trcRegion& root = regions[i];\n\t\t// Skip already visited.\n\t\tif (root.id != 0)\n\t\t\tcontinue;\n\t\t\n\t\t// Start search.\n\t\troot.id = layerId;\n\n\t\tstack.resize(0);\n\t\tstack.push(i);\n\t\t\n\t\twhile (stack.size() > 0)\n\t\t{\n\t\t\t// Pop front\n\t\t\trcRegion& reg = regions[stack[0]];\n\t\t\tfor (int j = 0; j < stack.size()-1; ++j)\n\t\t\t\tstack[j] = stack[j+1];\n\t\t\tstack.resize(stack.size()-1);\n\t\t\t\n\t\t\tconst int ncons = (int)reg.connections.size();\n\t\t\tfor (int j = 0; j < ncons; ++j)\n\t\t\t{\n\t\t\t\tconst int nei = reg.connections[j];\n\t\t\t\trcRegion& regn = regions[nei];\n\t\t\t\t// Skip already visited.\n\t\t\t\tif (regn.id != 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t// Skip if the neighbour is overlapping root region.\n\t\t\t\tbool overlap = false;\n\t\t\t\tfor (int k = 0; k < root.floors.size(); k++)\n\t\t\t\t{\n\t\t\t\t\tif (root.floors[k] == nei)\n\t\t\t\t\t{\n\t\t\t\t\t\toverlap = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (overlap)\n\t\t\t\t\tcontinue;\n\t\t\t\t\t\n\t\t\t\t// Deepen\n\t\t\t\tstack.push(nei);\n\t\t\t\t\t\n\t\t\t\t// Mark layer id\n\t\t\t\tregn.id = layerId;\n\t\t\t\t// Merge current layers to root.\n\t\t\t\tfor (int k = 0; k < regn.floors.size(); ++k)\n\t\t\t\t\taddUniqueFloorRegion(root, regn.floors[k]);\n\t\t\t\troot.ymin = rcMin(root.ymin, regn.ymin);\n\t\t\t\troot.ymax = rcMax(root.ymax, regn.ymax);\n\t\t\t\troot.spanCount += regn.spanCount;\n\t\t\t\tregn.spanCount = 0;\n\t\t\t\troot.connectsToBorder = root.connectsToBorder || regn.connectsToBorder;\n\t\t\t}\n\t\t}\n\t\t\n\t\tlayerId++;\n\t}\n\t\n\t// Remove small regions\n\tfor (int i = 0; i < nreg; ++i)\n\t{\n\t\tif (regions[i].spanCount > 0 && regions[i].spanCount < minRegionArea && !regions[i].connectsToBorder)\n\t\t{\n\t\t\tunsigned short reg = regions[i].id;\n\t\t\tfor (int j = 0; j < nreg; ++j)\n\t\t\t\tif (regions[j].id == reg)\n\t\t\t\t\tregions[j].id = 0;\n\t\t}\n\t}\n\t\n\t// Compress region Ids.\n\tfor (int i = 0; i < nreg; ++i)\n\t{\n\t\tregions[i].remap = false;\n\t\tif (regions[i].id == 0) continue;\t\t\t\t// Skip nil regions.\n\t\tif (regions[i].id & RC_BORDER_REG) continue;    // Skip external regions.\n\t\tregions[i].remap = true;\n\t}\n\t\n\tunsigned short regIdGen = 0;\n\tfor (int i = 0; i < nreg; ++i)\n\t{\n\t\tif (!regions[i].remap)\n\t\t\tcontinue;\n\t\tunsigned short oldId = regions[i].id;\n\t\tunsigned short newId = ++regIdGen;\n\t\tfor (int j = i; j < nreg; ++j)\n\t\t{\n\t\t\tif (regions[j].id == oldId)\n\t\t\t{\n\t\t\t\tregions[j].id = newId;\n\t\t\t\tregions[j].remap = false;\n\t\t\t}\n\t\t}\n\t}\n\tmaxRegionId = regIdGen;\n\t\n\t// Remap regions.\n\tfor (int i = 0; i < chf.spanCount; ++i)\n\t{\n\t\tif ((srcReg[i] & RC_BORDER_REG) == 0)\n\t\t\tsrcReg[i] = regions[srcReg[i]].id;\n\t}\n\t\n\treturn true;\n}\n\n\n\n/// @par\n/// \n/// This is usually the second to the last step in creating a fully built\n/// compact heightfield.  This step is required before regions are built\n/// using #rcBuildRegions or #rcBuildRegionsMonotone.\n/// \n/// After this step, the distance data is available via the rcCompactHeightfield::maxDistance\n/// and rcCompactHeightfield::dist fields.\n///\n/// @see rcCompactHeightfield, rcBuildRegions, rcBuildRegionsMonotone\nbool rcBuildDistanceField(rcContext* ctx, rcCompactHeightfield& chf)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_BUILD_DISTANCEFIELD);\n\t\n\tif (chf.dist)\n\t{\n\t\trcFree(chf.dist);\n\t\tchf.dist = 0;\n\t}\n\t\n\tunsigned short* src = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP);\n\tif (!src)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildDistanceField: Out of memory 'src' (%d).\", chf.spanCount);\n\t\treturn false;\n\t}\n\tunsigned short* dst = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP);\n\tif (!dst)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildDistanceField: Out of memory 'dst' (%d).\", chf.spanCount);\n\t\trcFree(src);\n\t\treturn false;\n\t}\n\t\n\tunsigned short maxDist = 0;\n\n\t{\n\t\trcScopedTimer timerDist(ctx, RC_TIMER_BUILD_DISTANCEFIELD_DIST);\n\n\t\tcalculateDistanceField(chf, src, maxDist);\n\t\tchf.maxDistance = maxDist;\n\t}\n\n\t{\n\t\trcScopedTimer timerBlur(ctx, RC_TIMER_BUILD_DISTANCEFIELD_BLUR);\n\n\t\t// Blur\n\t\tif (boxBlur(chf, 1, src, dst) != src)\n\t\t\trcSwap(src, dst);\n\n\t\t// Store distance.\n\t\tchf.dist = src;\n\t}\n\t\n\trcFree(dst);\n\t\n\treturn true;\n}\n\nstatic void paintRectRegion(int minx, int maxx, int miny, int maxy, unsigned short regId,\n\t\t\t\t\t\t\trcCompactHeightfield& chf, unsigned short* srcReg)\n{\n\tconst int w = chf.width;\t\n\tfor (int y = miny; y < maxy; ++y)\n\t{\n\t\tfor (int x = minx; x < maxx; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tif (chf.areas[i] != RC_NULL_AREA)\n\t\t\t\t\tsrcReg[i] = regId;\n\t\t\t}\n\t\t}\n\t}\n}\n\n\nstatic const unsigned short RC_NULL_NEI = 0xffff;\n\nstruct rcSweepSpan\n{\n\tunsigned short rid;\t// row id\n\tunsigned short id;\t// region id\n\tunsigned short ns;\t// number samples\n\tunsigned short nei;\t// neighbour id\n};\n\n/// @par\n/// \n/// Non-null regions will consist of connected, non-overlapping walkable spans that form a single contour.\n/// Contours will form simple polygons.\n/// \n/// If multiple regions form an area that is smaller than @p minRegionArea, then all spans will be\n/// re-assigned to the zero (null) region.\n/// \n/// Partitioning can result in smaller than necessary regions. @p mergeRegionArea helps \n/// reduce unecessarily small regions.\n/// \n/// See the #rcConfig documentation for more information on the configuration parameters.\n/// \n/// The region data will be available via the rcCompactHeightfield::maxRegions\n/// and rcCompactSpan::reg fields.\n/// \n/// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions.\n/// \n/// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig\nbool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,\n\t\t\t\t\t\t\tconst int borderSize, const int minRegionArea, const int mergeRegionArea)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_BUILD_REGIONS);\n\t\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\tunsigned short id = 1;\n\t\n\trcScopedDelete<unsigned short> srcReg((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP));\n\tif (!srcReg)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildRegionsMonotone: Out of memory 'src' (%d).\", chf.spanCount);\n\t\treturn false;\n\t}\n\tmemset(srcReg,0,sizeof(unsigned short)*chf.spanCount);\n\n\tconst int nsweeps = rcMax(chf.width,chf.height);\n\trcScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rcAlloc(sizeof(rcSweepSpan)*nsweeps, RC_ALLOC_TEMP));\n\tif (!sweeps)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildRegionsMonotone: Out of memory 'sweeps' (%d).\", nsweeps);\n\t\treturn false;\n\t}\n\t\n\t\n\t// Mark border regions.\n\tif (borderSize > 0)\n\t{\n\t\t// Make sure border will not overflow.\n\t\tconst int bw = rcMin(w, borderSize);\n\t\tconst int bh = rcMin(h, borderSize);\n\t\t// Paint regions\n\t\tpaintRectRegion(0, bw, 0, h, id|RC_BORDER_REG, chf, srcReg); id++;\n\t\tpaintRectRegion(w-bw, w, 0, h, id|RC_BORDER_REG, chf, srcReg); id++;\n\t\tpaintRectRegion(0, w, 0, bh, id|RC_BORDER_REG, chf, srcReg); id++;\n\t\tpaintRectRegion(0, w, h-bh, h, id|RC_BORDER_REG, chf, srcReg); id++;\n\t}\n\n\tchf.borderSize = borderSize;\n\t\n\trcIntArray prev(256);\n\n\t// Sweep one line at a time.\n\tfor (int y = borderSize; y < h-borderSize; ++y)\n\t{\n\t\t// Collect spans from this row.\n\t\tprev.resize(id+1);\n\t\tmemset(&prev[0],0,sizeof(int)*id);\n\t\tunsigned short rid = 1;\n\t\t\n\t\tfor (int x = borderSize; x < w-borderSize; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\t\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tif (chf.areas[i] == RC_NULL_AREA) continue;\n\t\t\t\t\n\t\t\t\t// -x\n\t\t\t\tunsigned short previd = 0;\n\t\t\t\tif (rcGetCon(s, 0) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(0);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(0);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);\n\t\t\t\t\tif ((srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai])\n\t\t\t\t\t\tprevid = srcReg[ai];\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!previd)\n\t\t\t\t{\n\t\t\t\t\tprevid = rid++;\n\t\t\t\t\tsweeps[previd].rid = previd;\n\t\t\t\t\tsweeps[previd].ns = 0;\n\t\t\t\t\tsweeps[previd].nei = 0;\n\t\t\t\t}\n\n\t\t\t\t// -y\n\t\t\t\tif (rcGetCon(s,3) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(3);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(3);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);\n\t\t\t\t\tif (srcReg[ai] && (srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai])\n\t\t\t\t\t{\n\t\t\t\t\t\tunsigned short nr = srcReg[ai];\n\t\t\t\t\t\tif (!sweeps[previd].nei || sweeps[previd].nei == nr)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsweeps[previd].nei = nr;\n\t\t\t\t\t\t\tsweeps[previd].ns++;\n\t\t\t\t\t\t\tprev[nr]++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsweeps[previd].nei = RC_NULL_NEI;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tsrcReg[i] = previd;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Create unique ID.\n\t\tfor (int i = 1; i < rid; ++i)\n\t\t{\n\t\t\tif (sweeps[i].nei != RC_NULL_NEI && sweeps[i].nei != 0 &&\n\t\t\t\tprev[sweeps[i].nei] == (int)sweeps[i].ns)\n\t\t\t{\n\t\t\t\tsweeps[i].id = sweeps[i].nei;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsweeps[i].id = id++;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Remap IDs\n\t\tfor (int x = borderSize; x < w-borderSize; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\t\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tif (srcReg[i] > 0 && srcReg[i] < rid)\n\t\t\t\t\tsrcReg[i] = sweeps[srcReg[i]].id;\n\t\t\t}\n\t\t}\n\t}\n\n\n\t{\n\t\trcScopedTimer timerFilter(ctx, RC_TIMER_BUILD_REGIONS_FILTER);\n\n\t\t// Merge regions and filter out small regions.\n\t\trcIntArray overlaps;\n\t\tchf.maxRegions = id;\n\t\tif (!mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, chf.maxRegions, chf, srcReg, overlaps))\n\t\t\treturn false;\n\n\t\t// Monotone partitioning does not generate overlapping regions.\n\t}\n\t\n\t// Store the result out.\n\tfor (int i = 0; i < chf.spanCount; ++i)\n\t\tchf.spans[i].reg = srcReg[i];\n\n\treturn true;\n}\n\n/// @par\n/// \n/// Non-null regions will consist of connected, non-overlapping walkable spans that form a single contour.\n/// Contours will form simple polygons.\n/// \n/// If multiple regions form an area that is smaller than @p minRegionArea, then all spans will be\n/// re-assigned to the zero (null) region.\n/// \n/// Watershed partitioning can result in smaller than necessary regions, especially in diagonal corridors. \n/// @p mergeRegionArea helps reduce unecessarily small regions.\n/// \n/// See the #rcConfig documentation for more information on the configuration parameters.\n/// \n/// The region data will be available via the rcCompactHeightfield::maxRegions\n/// and rcCompactSpan::reg fields.\n/// \n/// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions.\n/// \n/// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig\nbool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,\n\t\t\t\t\tconst int borderSize, const int minRegionArea, const int mergeRegionArea)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_BUILD_REGIONS);\n\t\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\t\n\trcScopedDelete<unsigned short> buf((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount*2, RC_ALLOC_TEMP));\n\tif (!buf)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildRegions: Out of memory 'tmp' (%d).\", chf.spanCount*4);\n\t\treturn false;\n\t}\n\t\n\tctx->startTimer(RC_TIMER_BUILD_REGIONS_WATERSHED);\n\n\tconst int LOG_NB_STACKS = 3;\n\tconst int NB_STACKS = 1 << LOG_NB_STACKS;\n\trcTempVector<LevelStackEntry> lvlStacks[NB_STACKS];\n\tfor (int i=0; i<NB_STACKS; ++i)\n\t\tlvlStacks[i].reserve(256);\n\n\trcTempVector<LevelStackEntry> stack;\n\tstack.reserve(256);\n\t\n\tunsigned short* srcReg = buf;\n\tunsigned short* srcDist = buf+chf.spanCount;\n\t\n\tmemset(srcReg, 0, sizeof(unsigned short)*chf.spanCount);\n\tmemset(srcDist, 0, sizeof(unsigned short)*chf.spanCount);\n\t\n\tunsigned short regionId = 1;\n\tunsigned short level = (chf.maxDistance+1) & ~1;\n\n\t// TODO: Figure better formula, expandIters defines how much the \n\t// watershed \"overflows\" and simplifies the regions. Tying it to\n\t// agent radius was usually good indication how greedy it could be.\n//\tconst int expandIters = 4 + walkableRadius * 2;\n\tconst int expandIters = 8;\n\n\tif (borderSize > 0)\n\t{\n\t\t// Make sure border will not overflow.\n\t\tconst int bw = rcMin(w, borderSize);\n\t\tconst int bh = rcMin(h, borderSize);\n\t\t\n\t\t// Paint regions\n\t\tpaintRectRegion(0, bw, 0, h, regionId|RC_BORDER_REG, chf, srcReg); regionId++;\n\t\tpaintRectRegion(w-bw, w, 0, h, regionId|RC_BORDER_REG, chf, srcReg); regionId++;\n\t\tpaintRectRegion(0, w, 0, bh, regionId|RC_BORDER_REG, chf, srcReg); regionId++;\n\t\tpaintRectRegion(0, w, h-bh, h, regionId|RC_BORDER_REG, chf, srcReg); regionId++;\n\t}\n\n\tchf.borderSize = borderSize;\n\t\n\tint sId = -1;\n\twhile (level > 0)\n\t{\n\t\tlevel = level >= 2 ? level-2 : 0;\n\t\tsId = (sId+1) & (NB_STACKS-1);\n\n//\t\tctx->startTimer(RC_TIMER_DIVIDE_TO_LEVELS);\n\n\t\tif (sId == 0)\n\t\t\tsortCellsByLevel(level, chf, srcReg, NB_STACKS, lvlStacks, 1);\n\t\telse \n\t\t\tappendStacks(lvlStacks[sId-1], lvlStacks[sId], srcReg); // copy left overs from last level\n\n//\t\tctx->stopTimer(RC_TIMER_DIVIDE_TO_LEVELS);\n\n\t\t{\n\t\t\trcScopedTimer timerExpand(ctx, RC_TIMER_BUILD_REGIONS_EXPAND);\n\n\t\t\t// Expand current regions until no empty connected cells found.\n\t\t\texpandRegions(expandIters, level, chf, srcReg, srcDist, lvlStacks[sId], false);\n\t\t}\n\t\t\n\t\t{\n\t\t\trcScopedTimer timerFloor(ctx, RC_TIMER_BUILD_REGIONS_FLOOD);\n\n\t\t\t// Mark new regions with IDs.\n\t\t\tfor (int j = 0; j<lvlStacks[sId].size(); j++)\n\t\t\t{\n\t\t\t\tLevelStackEntry current = lvlStacks[sId][j];\n\t\t\t\tint x = current.x;\n\t\t\t\tint y = current.y;\n\t\t\t\tint i = current.index;\n\t\t\t\tif (i >= 0 && srcReg[i] == 0)\n\t\t\t\t{\n\t\t\t\t\tif (floodRegion(x, y, i, level, regionId, chf, srcReg, srcDist, stack))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (regionId == 0xFFFF)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildRegions: Region ID overflow\");\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tregionId++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Expand current regions until no empty connected cells found.\n\texpandRegions(expandIters*8, 0, chf, srcReg, srcDist, stack, true);\n\t\n\tctx->stopTimer(RC_TIMER_BUILD_REGIONS_WATERSHED);\n\t\n\t{\n\t\trcScopedTimer timerFilter(ctx, RC_TIMER_BUILD_REGIONS_FILTER);\n\n\t\t// Merge regions and filter out smalle regions.\n\t\trcIntArray overlaps;\n\t\tchf.maxRegions = regionId;\n\t\tif (!mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, chf.maxRegions, chf, srcReg, overlaps))\n\t\t\treturn false;\n\n\t\t// If overlapping regions were found during merging, split those regions.\n\t\tif (overlaps.size() > 0)\n\t\t{\n\t\t\tctx->log(RC_LOG_ERROR, \"rcBuildRegions: %d overlapping regions.\", overlaps.size());\n\t\t}\n\t}\n\t\t\n\t// Write the result out.\n\tfor (int i = 0; i < chf.spanCount; ++i)\n\t\tchf.spans[i].reg = srcReg[i];\n\t\n\treturn true;\n}\n\n\nbool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,\n\t\t\t\t\t\t const int borderSize, const int minRegionArea)\n{\n\trcAssert(ctx);\n\t\n\trcScopedTimer timer(ctx, RC_TIMER_BUILD_REGIONS);\n\t\n\tconst int w = chf.width;\n\tconst int h = chf.height;\n\tunsigned short id = 1;\n\t\n\trcScopedDelete<unsigned short> srcReg((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP));\n\tif (!srcReg)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildLayerRegions: Out of memory 'src' (%d).\", chf.spanCount);\n\t\treturn false;\n\t}\n\tmemset(srcReg,0,sizeof(unsigned short)*chf.spanCount);\n\t\n\tconst int nsweeps = rcMax(chf.width,chf.height);\n\trcScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rcAlloc(sizeof(rcSweepSpan)*nsweeps, RC_ALLOC_TEMP));\n\tif (!sweeps)\n\t{\n\t\tctx->log(RC_LOG_ERROR, \"rcBuildLayerRegions: Out of memory 'sweeps' (%d).\", nsweeps);\n\t\treturn false;\n\t}\n\t\n\t\n\t// Mark border regions.\n\tif (borderSize > 0)\n\t{\n\t\t// Make sure border will not overflow.\n\t\tconst int bw = rcMin(w, borderSize);\n\t\tconst int bh = rcMin(h, borderSize);\n\t\t// Paint regions\n\t\tpaintRectRegion(0, bw, 0, h, id|RC_BORDER_REG, chf, srcReg); id++;\n\t\tpaintRectRegion(w-bw, w, 0, h, id|RC_BORDER_REG, chf, srcReg); id++;\n\t\tpaintRectRegion(0, w, 0, bh, id|RC_BORDER_REG, chf, srcReg); id++;\n\t\tpaintRectRegion(0, w, h-bh, h, id|RC_BORDER_REG, chf, srcReg); id++;\n\t}\n\n\tchf.borderSize = borderSize;\n\t\n\trcIntArray prev(256);\n\t\n\t// Sweep one line at a time.\n\tfor (int y = borderSize; y < h-borderSize; ++y)\n\t{\n\t\t// Collect spans from this row.\n\t\tprev.resize(id+1);\n\t\tmemset(&prev[0],0,sizeof(int)*id);\n\t\tunsigned short rid = 1;\n\t\t\n\t\tfor (int x = borderSize; x < w-borderSize; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\t\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tconst rcCompactSpan& s = chf.spans[i];\n\t\t\t\tif (chf.areas[i] == RC_NULL_AREA) continue;\n\t\t\t\t\n\t\t\t\t// -x\n\t\t\t\tunsigned short previd = 0;\n\t\t\t\tif (rcGetCon(s, 0) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(0);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(0);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);\n\t\t\t\t\tif ((srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai])\n\t\t\t\t\t\tprevid = srcReg[ai];\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!previd)\n\t\t\t\t{\n\t\t\t\t\tprevid = rid++;\n\t\t\t\t\tsweeps[previd].rid = previd;\n\t\t\t\t\tsweeps[previd].ns = 0;\n\t\t\t\t\tsweeps[previd].nei = 0;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// -y\n\t\t\t\tif (rcGetCon(s,3) != RC_NOT_CONNECTED)\n\t\t\t\t{\n\t\t\t\t\tconst int ax = x + rcGetDirOffsetX(3);\n\t\t\t\t\tconst int ay = y + rcGetDirOffsetY(3);\n\t\t\t\t\tconst int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);\n\t\t\t\t\tif (srcReg[ai] && (srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai])\n\t\t\t\t\t{\n\t\t\t\t\t\tunsigned short nr = srcReg[ai];\n\t\t\t\t\t\tif (!sweeps[previd].nei || sweeps[previd].nei == nr)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsweeps[previd].nei = nr;\n\t\t\t\t\t\t\tsweeps[previd].ns++;\n\t\t\t\t\t\t\tprev[nr]++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsweeps[previd].nei = RC_NULL_NEI;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tsrcReg[i] = previd;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Create unique ID.\n\t\tfor (int i = 1; i < rid; ++i)\n\t\t{\n\t\t\tif (sweeps[i].nei != RC_NULL_NEI && sweeps[i].nei != 0 &&\n\t\t\t\tprev[sweeps[i].nei] == (int)sweeps[i].ns)\n\t\t\t{\n\t\t\t\tsweeps[i].id = sweeps[i].nei;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsweeps[i].id = id++;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Remap IDs\n\t\tfor (int x = borderSize; x < w-borderSize; ++x)\n\t\t{\n\t\t\tconst rcCompactCell& c = chf.cells[x+y*w];\n\t\t\t\n\t\t\tfor (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)\n\t\t\t{\n\t\t\t\tif (srcReg[i] > 0 && srcReg[i] < rid)\n\t\t\t\t\tsrcReg[i] = sweeps[srcReg[i]].id;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t\n\t{\n\t\trcScopedTimer timerFilter(ctx, RC_TIMER_BUILD_REGIONS_FILTER);\n\n\t\t// Merge monotone regions to layers and remove small regions.\n\t\tchf.maxRegions = id;\n\t\tif (!mergeAndFilterLayerRegions(ctx, minRegionArea, chf.maxRegions, chf, srcReg))\n\t\t\treturn false;\n\t}\n\t\n\t\n\t// Store the result out.\n\tfor (int i = 0; i < chf.spanCount; ++i)\n\t\tchf.spans[i].reg = srcReg[i];\n\t\n\treturn true;\n}\n"
  },
  {
    "path": "third_parties/recast/recast/readme-addon.txt",
    "content": "\nThe version of Recast is based on commit 57610fa6ef31b39020231906f8c5d40eaa8294ae (date: 21 Oct 2019) from repository\nhttps://github.com/recastnavigation/recastnavigation\nOnly 'Recast' folder is necessary. File CMakeLists.txt has been modified.\n\nLibrary was copied directly from recastnavigation repository therefore modifications stated in \"extern/recastnavigation/readme-blender.txt\" in blender's source were lost.\n"
  }
]