diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 300f00f..869dd0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,3 +1,4 @@ + name: build on: @@ -8,6 +9,13 @@ on: pull_request: branches: [ master ] +# matrix: +# maya: [2024] +# os: [macos-latest, ubuntu-latest, windows-latest] +# include: +# - maya: 2024 +# update: 2 + jobs: compile_plugin: strategy: @@ -25,28 +33,6 @@ jobs: - maya: 2025 update: 1 - # OS specific vars - - os: macos-latest - os_name_u: Mac - os_name: mac - ext: bundle - zip: dmg - - os: macos-13 - os_name_u: Mac - os_name: mac - ext: bundle - zip: dmg - - os: windows-latest - os_name_u: Windows - os_name: windows - ext: mll - zip: zip - - os: ubuntu-latest - os_name_u: Linux - os_name: linux - ext: so - zip: tgz - # cross-compiling is annoying so just fall back to macos-13 exclude: - os: macos-latest @@ -61,153 +47,52 @@ jobs: fail-fast: false runs-on: ${{ matrix.os }} - - env: - DEVKIT_URL: https://autodesk-adn-transfer.s3-us-west-2.amazonaws.com/ADN+Extranet/M%26E/Maya/devkit+${{ matrix.maya }}/Autodesk_Maya_${{ matrix.maya }}_${{ matrix.update }}_Update_DEVKIT_${{ matrix.os_name_u }}.${{ matrix.zip }} - steps: + - uses: actions/checkout@v4 + - run: git fetch --tags origin - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - - - name : Install ninja - uses: seanmiddleditch/gha-setup-ninja@v5 - - - name : Install Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - - name : install meson - run : pip install meson - - - name: Restore Devkit Cache - id: cache-devkit - uses: actions/cache/restore@v4 + - name: Get Maya Devkit + id: get-devkit + uses: blurstudio/mayaModuleActions/getMayaDevkit@v1 with: - path: ${{ runner.temp }}/devkit/devkit.${{ matrix.zip }} - key: ${{ matrix.os }}-Maya${{ matrix.maya }}-Update${{ matrix.update }} - - - name: Download Devkit - if: ${{ steps.cache-devkit.outputs.cache-hit != 'true' }} - run: | - mkdir ${{ runner.temp }}/devkit - curl -o ${{ runner.temp }}/devkit/devkit.${{ matrix.zip }} ${{ env.DEVKIT_URL }} + maya: ${{ matrix.maya }} + update: ${{ matrix.update }} - - name: Save Devkit Cache - if: ${{ steps.cache-devkit.outputs.cache-hit != 'true' }} - id: cache-devkit-save - uses: actions/cache/save@v4 + - name: Build + uses: blurstudio/mayaModuleActions/mesonBuild@v1 with: - path: ${{ runner.temp }}/devkit/devkit.${{ matrix.zip }} - key: ${{ matrix.os }}-Maya${{ matrix.maya }}-Update${{ matrix.update }} - - - name: Install OpenGL libraries Linux - if: ${{ matrix.os_name == 'linux' }} - run: | - sudo apt install libglu1-mesa-dev - - - name : Unpack Devkit Windows - if: ${{ matrix.os_name == 'windows' }} - run: Expand-Archive -LiteralPath "${{ runner.temp }}/devkit/devkit.zip" -DestinationPath "${{ runner.temp }}/devkit" - - name : Unpack Devkit Mac - if: ${{ matrix.os_name == 'mac' }} - run: hdiutil attach ${{ runner.temp }}/devkit/devkit.dmg -mountroot ${{ runner.temp }}/devkit - - name : Unpack Devkit Linux - if: ${{ matrix.os_name == 'linux' }} - run: tar xvzf ${{ runner.temp }}/devkit/devkit.tgz -C ${{ runner.temp }}/devkit - - - name: Setup - run: > - meson - setup - -Dmaya:maya_version="${{ matrix.maya }}" - -Dmaya:maya_devkit_base="${{ runner.temp }}/devkit/devkitBase" - --buildtype debugoptimized - --vsenv - --backend ninja - ${{ github.workspace }}/build - - - name: Compile - run: | - meson compile -C ${{ github.workspace }}/build - - - name: Package - run: | - mkdir artifacts - mkdir artifacts/plug-ins - cp ${{ github.workspace }}/build/TwistSpline.${{ matrix.ext }} artifacts/plug-ins + setup-args: > + -Dmaya:maya_version=${{ matrix.maya }} + -Dmaya:maya_devkit_base=${{ steps.get-devkit.outputs.devkit-path }} + --buildtype release + --backend ninja - name: Upload Artifacts uses: actions/upload-artifact@v4 with: - name: ${{ matrix.os_name }}-${{ matrix.maya }} - path: | - artifacts/plug-ins/TwistSpline.${{ matrix.ext }} + name: ${{ runner.os }}-${{ matrix.maya }}-plugin + path: build/*.${{ steps.get-devkit.outputs.plugin-ext }} + if-no-files-found: error - - -# Shipping -# -# _________ -# |\ _ _ _ _\ -# | \________\ -# | | | -# | | | -# \|________| -# -# upload_release: name: Upload release needs: compile_plugin runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Download artifacts - uses: actions/download-artifact@v4 - - # Omitting name: means "download all artifacts" - # Destination directory structure: - # ~/modules - # /TwistSpline - # /- - # /icons - # /plug-ins - # TwistSpline.mll - # /scripts - # *.py - # *.mel - # /TwistSpline.mod - + - uses: actions/checkout@v4 + - run: git fetch --tags origin + - name: 'Get Previous tag' + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" with: - path: modules/TwistSpline - - - name: Set env - run: | - LATEST_TAG=$(git describe --tags --abbrev=0 || echo "NOTAG") - echo "LatestTag: ${LATEST_TAG}" - echo "RELEASE_VERSION=${LATEST_TAG}" >> $GITHUB_ENV - - - name: Create distribution - run: | - cp ./TwistSpline.mod modules/ - mkdir -p modules/TwistSpline/scripts - cp -r ./scripts modules/TwistSpline - mkdir -p modules/TwistSpline/icons - cp ./icons/*.png modules/TwistSpline/icons - cp ./icons/*.xpm modules/TwistSpline/icons - zip -r TwistSpline-${{env.RELEASE_VERSION}}.zip modules/ + fallback: 0.0.1 - - name: Upload Artifacts - uses: actions/upload-artifact@v4 - with: - name: TwistSpline-module - path: TwistSpline-${{env.RELEASE_VERSION}}.zip + - name: Package + uses: blurstudio/mayaModuleActions/packageMayaModule@v1 + with: + module-name: TwistSpline + folder-list: scripts icons + version: ${{ steps.previoustag.outputs.tag }} - name: Upload distribution if: ${{ startsWith(github.ref, 'refs/tags/v') }} diff --git a/.gitignore b/.gitignore index 99f03d6..bac292a 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,6 @@ $RECYCLE.BIN/ Network Trash Folder Temporary Items .apdisk + +# Auto-created version files +version.h diff --git a/TwistSpline.mod b/TwistSpline.mod deleted file mode 100644 index 25864f1..0000000 --- a/TwistSpline.mod +++ /dev/null @@ -1,59 +0,0 @@ -+ PLATFORM:win64 MAYAVERSION:2022 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: windows-2022 -[r] scripts: scripts - -+ PLATFORM:linux MAYAVERSION:2022 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: linux-2022 -[r] scripts: scripts - -+ PLATFORM:mac MAYAVERSION:2022 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: mac-2022 -[r] scripts: scripts - -+ PLATFORM:win64 MAYAVERSION:2023 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: windows-2023 -[r] scripts: scripts - -+ PLATFORM:linux MAYAVERSION:2023 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: linux-2023 -[r] scripts: scripts - -+ PLATFORM:mac MAYAVERSION:2023 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: mac-2023 -[r] scripts: scripts - -+ PLATFORM:win64 MAYAVERSION:2024 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: windows-2024 -[r] scripts: scripts - -+ PLATFORM:linux MAYAVERSION:2024 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: linux-2024 -[r] scripts: scripts - -+ PLATFORM:mac MAYAVERSION:2024 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: mac-2024 -[r] scripts: scripts - -+ PLATFORM:win64 MAYAVERSION:2025 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: windows-2025 -[r] scripts: scripts - -+ PLATFORM:linux MAYAVERSION:2025 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: linux-2025 -[r] scripts: scripts - -+ PLATFORM:mac MAYAVERSION:2025 TwistSpline 1.2.1 TwistSpline -[r] icons: icons -plug-ins: mac-2025 -[r] scripts: scripts diff --git a/meson.build b/meson.build index 852de80..49b65fc 100644 --- a/meson.build +++ b/meson.build @@ -5,23 +5,37 @@ maya_name_suffix = maya_dep.get_variable('name_suffix') maya_version = maya_dep.get_variable('maya_version') source_files = [ - 'src/pluginMain.cpp', - 'src/drawOverride.cpp', - 'src/twistSplineData.cpp', - 'src/twistSplineNode.cpp', - 'src/riderConstraint.cpp', - 'src/twistTangentNode.cpp', - 'src/twistMultiTangentNode.cpp', + 'src/pluginMain.cpp', + 'src/drawOverride.cpp', + 'src/twistSplineData.cpp', + 'src/twistSplineNode.cpp', + 'src/riderConstraint.cpp', + 'src/twistTangentNode.cpp', + 'src/twistMultiTangentNode.cpp', ] -harm_inc = include_directories(['src']) +# If a user-built version file exists, then just use that +# Otherwise grab the latest tag from git +fs = import('fs') +if fs.is_file('src/version.h') + message('Using existing version.h') +else + git = find_program('git', native: true, required: true) + version_h = vcs_tag( + command: [git, 'describe', '--tags', '--match', 'v[0-9]*', '--dirty=+'], + fallback: 'v0.0.1', + input: 'src/version.h.in', + output: 'version.h', + ) + source_files = source_files + version_h +endif outlib = shared_library( meson.project_name(), source_files, install: true, install_dir : meson.global_source_root() / 'output_Maya' + maya_version, - include_directories : harm_inc, + include_directories : include_directories(['src']), dependencies : maya_dep, name_prefix : '', name_suffix : maya_name_suffix, diff --git a/quick_compile.bat b/quick_compile.bat index 2c6af36..d7767b1 100644 --- a/quick_compile.bat +++ b/quick_compile.bat @@ -10,7 +10,7 @@ SET BUILDTYPE=debug SET BUILDDIR=mayabuild_%BUILDTYPE%_%MAYA_VERSION%_%BACKEND% if not exist %BUILDDIR%\ ( - meson setup -Dmaya:maya_version=%MAYA_VERSION% --buildtype %BUILDTYPE% --vsenv %BUILDDIR% --backend %BACKEND% + meson setup %BUILDDIR% -Dmaya:maya_version=%MAYA_VERSION% --buildtype %BUILDTYPE% --vsenv --backend %BACKEND% ) if exist %BUILDDIR%\ ( diff --git a/src/pluginMain.cpp b/src/pluginMain.cpp index 06f0d6c..7ca32e0 100644 --- a/src/pluginMain.cpp +++ b/src/pluginMain.cpp @@ -29,10 +29,11 @@ SOFTWARE. #include "twistMultiTangentNode.h" #include "drawOverride.h" #include +#include "version.h" MStatus initializePlugin( MObject obj ) { MStatus status; - MFnPlugin plugin( obj, "BlurStudio", "1.2.1", "Any"); + MFnPlugin plugin( obj, "BlurStudio", VERSION_STRING, "Any"); status = plugin.registerData("twistSplineData", TwistSplineData::id, TwistSplineData::creator); if (!status) { diff --git a/src/twistSpline.h b/src/twistSpline.h index 2d7840c..5f90d05 100644 --- a/src/twistSpline.h +++ b/src/twistSpline.h @@ -32,7 +32,6 @@ SOFTWARE. #include #include "twistSplineUtils.h" - /** * A helper function for quickly finding a single index and segment percentage for an input tValue * @@ -118,12 +117,6 @@ void multiLinearIndexes(const std::vector ¶ms, const std::vector getRemap() const { return remap; } Float getTotalLength() const { return totalLength; } - - /// Copy constructor TwistSpline(TwistSpline const &old){ this->verts = old.verts; @@ -884,7 +865,6 @@ class TwistSpline { solveTwist(); } - /** * Solve the locks of a parameter of the spline * Build a tridiagonal matrix that represents each vertex param as a relation to its neighbor params @@ -973,7 +953,6 @@ class TwistSpline { solveTridiagonalMatrix(mat, res); } - /** * Solve a tridiagonal matrix in linear time * If you set up parameter values in a specific way, they can be thought of as a matrix @@ -1062,6 +1041,26 @@ class TwistSpline { std::vector oriMap; solveTwistParamMatrix(orientVals, segLens, orientLocks, oriMap); + // Add an euler filter to the ori map. + Float tau = 6.283185307179586477; + Float pi = 3.141592653589793238; + for (size_t i = 1; i < oriMap.size(); ++i){ + Float diff = oriMap[i] - oriMap[i - 1]; + Float sign = 1.0; + if (diff < 0.0){ + diff *= -1.0; + sign = -1.0; + } + + int count = 0; + for (; count < 10; ++count){ + if (diff < pi){ + break; + } + diff -= tau; + } + oriMap[i] -= count * sign * tau; + } std::vector twistMap; solveTwistParamMatrix(userTwists, segLens, twistLocks, twistMap); diff --git a/src/version.h.in b/src/version.h.in new file mode 100644 index 0000000..b7f88a8 --- /dev/null +++ b/src/version.h.in @@ -0,0 +1,3 @@ +#pragma once +#define VERSION_STRING "@VCS_TAG@" +