From b9d2a77a0feb2abc4358748e20b84809d1ca65e1 Mon Sep 17 00:00:00 2001 From: Tyler Fox Date: Thu, 22 Aug 2024 16:10:56 -0700 Subject: [PATCH 1/4] Add an euler filter to the cv-orient twists so we don't get unintended flipping --- src/twistSpline.h | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) 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); From f2ef9b124c5adf264717a52422c8000c34f94cd6 Mon Sep 17 00:00:00 2001 From: Tyler Fox Date: Thu, 22 Aug 2024 17:30:52 -0700 Subject: [PATCH 2/4] Set up automatic version bumping from git tags --- .github/workflows/main.yml | 7 +++++-- TwistSpline.mod | 24 ++++++++++++------------ meson.build | 8 ++++++-- src/pluginMain.cpp | 2 +- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 300f00f..4ecf915 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -71,6 +71,7 @@ jobs: uses: actions/checkout@v4 with: submodules: true + fetch-depth: 0 - name : Install ninja uses: seanmiddleditch/gha-setup-ninja@v5 @@ -167,6 +168,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Download artifacts uses: actions/download-artifact@v4 @@ -187,7 +190,7 @@ jobs: with: path: modules/TwistSpline - - name: Set env + - name: Get Latest Tag run: | LATEST_TAG=$(git describe --tags --abbrev=0 || echo "NOTAG") echo "LatestTag: ${LATEST_TAG}" @@ -195,7 +198,7 @@ jobs: - name: Create distribution run: | - cp ./TwistSpline.mod modules/ + sed "s/DEVELOP/${{env.RELEASE_VERSION}}/" TwistSpline.mod > modules/TwistSpline.mod mkdir -p modules/TwistSpline/scripts cp -r ./scripts modules/TwistSpline mkdir -p modules/TwistSpline/icons diff --git a/TwistSpline.mod b/TwistSpline.mod index 25864f1..87025d4 100644 --- a/TwistSpline.mod +++ b/TwistSpline.mod @@ -1,59 +1,59 @@ -+ PLATFORM:win64 MAYAVERSION:2022 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:win64 MAYAVERSION:2022 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: windows-2022 [r] scripts: scripts -+ PLATFORM:linux MAYAVERSION:2022 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:linux MAYAVERSION:2022 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: linux-2022 [r] scripts: scripts -+ PLATFORM:mac MAYAVERSION:2022 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:mac MAYAVERSION:2022 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: mac-2022 [r] scripts: scripts -+ PLATFORM:win64 MAYAVERSION:2023 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:win64 MAYAVERSION:2023 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: windows-2023 [r] scripts: scripts -+ PLATFORM:linux MAYAVERSION:2023 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:linux MAYAVERSION:2023 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: linux-2023 [r] scripts: scripts -+ PLATFORM:mac MAYAVERSION:2023 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:mac MAYAVERSION:2023 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: mac-2023 [r] scripts: scripts -+ PLATFORM:win64 MAYAVERSION:2024 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:win64 MAYAVERSION:2024 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: windows-2024 [r] scripts: scripts -+ PLATFORM:linux MAYAVERSION:2024 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:linux MAYAVERSION:2024 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: linux-2024 [r] scripts: scripts -+ PLATFORM:mac MAYAVERSION:2024 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:mac MAYAVERSION:2024 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: mac-2024 [r] scripts: scripts -+ PLATFORM:win64 MAYAVERSION:2025 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:win64 MAYAVERSION:2025 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: windows-2025 [r] scripts: scripts -+ PLATFORM:linux MAYAVERSION:2025 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:linux MAYAVERSION:2025 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: linux-2025 [r] scripts: scripts -+ PLATFORM:mac MAYAVERSION:2025 TwistSpline 1.2.1 TwistSpline ++ PLATFORM:mac MAYAVERSION:2025 TwistSpline DEVELOP TwistSpline [r] icons: icons plug-ins: mac-2025 [r] scripts: scripts diff --git a/meson.build b/meson.build index 852de80..379f6d2 100644 --- a/meson.build +++ b/meson.build @@ -14,14 +14,18 @@ source_files = [ 'src/twistMultiTangentNode.cpp', ] -harm_inc = include_directories(['src']) +latest_tag = run_command('git', 'describe', '--tags', '--abbrev=0').stdout().strip() +if latest_tag == '' + latest_tag = 'NOTAG' +endif +add_project_arguments('-DVERSION_STRING="' + latest_tag + '"', language: 'cpp') 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/src/pluginMain.cpp b/src/pluginMain.cpp index 06f0d6c..8476ef8 100644 --- a/src/pluginMain.cpp +++ b/src/pluginMain.cpp @@ -32,7 +32,7 @@ SOFTWARE. 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) { From 8c84de681a4e097b7600df7e0316158f0dd41ddf Mon Sep 17 00:00:00 2001 From: Tyler Fox Date: Mon, 26 Aug 2024 16:46:27 -0700 Subject: [PATCH 3/4] Switch to the new github actions --- .github/workflows/main.yml | 192 +++++++------------------------------ TwistSpline.mod | 59 ------------ meson.build | 4 +- quick_compile.bat | 2 +- 4 files changed, 39 insertions(+), 218 deletions(-) delete mode 100644 TwistSpline.mod diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ecf915..7952588 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,156 +47,50 @@ 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: - - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + - name: Get Maya Devkit + id: get-devkit + uses: blurstudio/mayaModuleActions/getMayaDevkit@v1 with: - submodules: true - fetch-depth: 0 - - - name : Install ninja - uses: seanmiddleditch/gha-setup-ninja@v5 + maya: ${{ matrix.maya }} + update: ${{ matrix.update }} - - name : Install Python - uses: actions/setup-python@v5 + - name: Build + uses: blurstudio/mayaModuleActions/mesonBuild@v1 with: - python-version: '3.10' - - - name : install meson - run : pip install meson - - - name: Restore Devkit Cache - id: cache-devkit - uses: actions/cache/restore@v4 - 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 }} - - - name: Save Devkit Cache - if: ${{ steps.cache-devkit.outputs.cache-hit != 'true' }} - id: cache-devkit-save - uses: actions/cache/save@v4 - 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 + - uses: actions/checkout@v4 + - run: git fetch --tags origin + - name: 'Get Previous tag' + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" with: - fetch-depth: 0 - - - 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 + fallback: 0.0.1 - with: - path: modules/TwistSpline - - - name: Get Latest Tag - 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: | - sed "s/DEVELOP/${{env.RELEASE_VERSION}}/" TwistSpline.mod > modules/TwistSpline.mod - 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/ - - - 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/TwistSpline.mod b/TwistSpline.mod deleted file mode 100644 index 87025d4..0000000 --- a/TwistSpline.mod +++ /dev/null @@ -1,59 +0,0 @@ -+ PLATFORM:win64 MAYAVERSION:2022 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: windows-2022 -[r] scripts: scripts - -+ PLATFORM:linux MAYAVERSION:2022 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: linux-2022 -[r] scripts: scripts - -+ PLATFORM:mac MAYAVERSION:2022 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: mac-2022 -[r] scripts: scripts - -+ PLATFORM:win64 MAYAVERSION:2023 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: windows-2023 -[r] scripts: scripts - -+ PLATFORM:linux MAYAVERSION:2023 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: linux-2023 -[r] scripts: scripts - -+ PLATFORM:mac MAYAVERSION:2023 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: mac-2023 -[r] scripts: scripts - -+ PLATFORM:win64 MAYAVERSION:2024 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: windows-2024 -[r] scripts: scripts - -+ PLATFORM:linux MAYAVERSION:2024 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: linux-2024 -[r] scripts: scripts - -+ PLATFORM:mac MAYAVERSION:2024 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: mac-2024 -[r] scripts: scripts - -+ PLATFORM:win64 MAYAVERSION:2025 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: windows-2025 -[r] scripts: scripts - -+ PLATFORM:linux MAYAVERSION:2025 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: linux-2025 -[r] scripts: scripts - -+ PLATFORM:mac MAYAVERSION:2025 TwistSpline DEVELOP TwistSpline -[r] icons: icons -plug-ins: mac-2025 -[r] scripts: scripts diff --git a/meson.build b/meson.build index 379f6d2..807f87a 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,7 @@ maya_dep = dependency('maya') maya_name_suffix = maya_dep.get_variable('name_suffix') maya_version = maya_dep.get_variable('maya_version') -source_files = [ +source_files = files([ 'src/pluginMain.cpp', 'src/drawOverride.cpp', 'src/twistSplineData.cpp', @@ -12,7 +12,7 @@ source_files = [ 'src/riderConstraint.cpp', 'src/twistTangentNode.cpp', 'src/twistMultiTangentNode.cpp', -] +]) latest_tag = run_command('git', 'describe', '--tags', '--abbrev=0').stdout().strip() if latest_tag == '' 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%\ ( From 3949154a19a1e58ad6840fdcd30b574dc46b4f5d Mon Sep 17 00:00:00 2001 From: Tyler Fox Date: Tue, 3 Sep 2024 11:10:14 -0700 Subject: [PATCH 4/4] Automatically set the version number by the latest tag --- .github/workflows/main.yml | 2 ++ .gitignore | 3 +++ meson.build | 36 +++++++++++++++++++++++------------- src/pluginMain.cpp | 1 + src/version.h.in | 3 +++ 5 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 src/version.h.in diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7952588..869dd0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,6 +49,8 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 + - run: git fetch --tags origin + - name: Get Maya Devkit id: get-devkit uses: blurstudio/mayaModuleActions/getMayaDevkit@v1 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/meson.build b/meson.build index 807f87a..49b65fc 100644 --- a/meson.build +++ b/meson.build @@ -4,21 +4,31 @@ maya_dep = dependency('maya') maya_name_suffix = maya_dep.get_variable('name_suffix') maya_version = maya_dep.get_variable('maya_version') -source_files = files([ - 'src/pluginMain.cpp', - 'src/drawOverride.cpp', - 'src/twistSplineData.cpp', - 'src/twistSplineNode.cpp', - 'src/riderConstraint.cpp', - 'src/twistTangentNode.cpp', - 'src/twistMultiTangentNode.cpp', -]) +source_files = [ + 'src/pluginMain.cpp', + 'src/drawOverride.cpp', + 'src/twistSplineData.cpp', + 'src/twistSplineNode.cpp', + 'src/riderConstraint.cpp', + 'src/twistTangentNode.cpp', + 'src/twistMultiTangentNode.cpp', +] -latest_tag = run_command('git', 'describe', '--tags', '--abbrev=0').stdout().strip() -if latest_tag == '' - latest_tag = 'NOTAG' +# 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 -add_project_arguments('-DVERSION_STRING="' + latest_tag + '"', language: 'cpp') outlib = shared_library( meson.project_name(), diff --git a/src/pluginMain.cpp b/src/pluginMain.cpp index 8476ef8..7ca32e0 100644 --- a/src/pluginMain.cpp +++ b/src/pluginMain.cpp @@ -29,6 +29,7 @@ SOFTWARE. #include "twistMultiTangentNode.h" #include "drawOverride.h" #include +#include "version.h" MStatus initializePlugin( MObject obj ) { MStatus status; 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@" +