diff --git a/physx/CHANGELOG.md b/physx/CHANGELOG.md
index 62118932d..23fc42828 100644
--- a/physx/CHANGELOG.md
+++ b/physx/CHANGELOG.md
@@ -1,4 +1,87 @@
-# v5.3.0
+# v5.3.1-105.1
+
+## General
+
+### Changed
+
+* PxgDynamicsMemoryConfig::tempBufferCapacity will now be interpreted as a user-provided initial size, and will resize automatically if more memory is needed.
+
+### Fixed
+
+* A bug that led to phantom collisions for convex-heightfield interactions on GPU has been fixed.
+* A bug that caused velocity and impulse updates of the GPU articulation solver (PGS and TGS) not to be propagated to subsequent iterations, causing slower convergence and potentially unstable collision responses between rigids and articulations.
+* Fixed binary serialization for GPU enabled triangle meshes and meshes with SDF support.
+* Several bugs with GPU aggregates have been fixed that could have led to missed and phantom collisions. The issues were mostly related to additions/removals of aggregate contents.
+* Gpu accelerated SDF cooking is now deterministic.
+* SDF snippet shows how to optionally store cooked data into files.
+* Small improvements to SDF collisions, especially when objects with wildly different size collide.
+* Creating objects from a PxInputData containing invalid data could lead to a confusing (and incorrect) error message about a "double deletion". This has been fixed.
+* Bugs in island management related to actors other than rigid bodies.
+* A bug that could lead to a crash when calling the PxTetMaker::validateTriangleMesh function with a mesh referencing more vertices than passed into the function. That defect is now reported as eTRIANGLE_INDEX_OUT_OF_RANGE.
+* A crash bug that appeared when releasing actors with externally-provided forces and torques has been fixed. [Issue #211](https://github.com/NVIDIA-Omniverse/PhysX/issues/211)
+* A bug that caused a memory corruption in the GPU solver when using D6 joints with rigid bodies and articulations has been fixed.
+
+## Rigid Body
+
+### Added
+
+* The extraction of an isosurface from a SDF can now use multiple CPU cores.
+
+### Fixed
+
+* A crash happening when using contact report thresholds with point-friction (PxFrictionType::eONE_DIRECTIONAL / PxFrictionType::eTWO_DIRECTIONAL) has been fixed.
+* A "fear of the wireframe" issue in Sphere vs TriangleMesh collision when simulating on GPU is fixed.
+
+## Articulations
+
+### Fixed
+
+* Articulation joint velocity limits are respected when articulation joint drives are configured to push past the limit.
+* Spherical articulation joints could sometimes flip their position by 2 pi causing problems with joint limits. This has been fixed.
+
+## Joints
+
+### Fixed
+
+* The PxConstraintFlag::eENABLE_EXTENDED_LIMITS flag now works properly for D6 based revolute joints when the GPU pipeline with the TGS solver is active.
+
+## Character controller
+
+### Fixed
+
+* You can now only create one PxCreateControllerManager per PxScene. This avoids filtering-related issues when multiple controller managers are created for the same PxScene.
+
+## Particles
+
+### Added
+
+* PxParticleSystem::getParticleMaterials() to query materials that have been registered with phases.
+
+### Fixed
+
+* PxParticleSystem::getNbParticleMaterials() always returned 1, instead of the materials referenced by phases.
+* Particle - Convex Shape collisions failing with spread out particles.
+* Particle phase references to PxPBDMaterial were broken when releasing (an unreferenced) PxPBDMaterial.
+
+## Pvd
+
+### Added
+
+* A way to get a thread safe OmniPvd writer from the PxOmniPvd interface through using acquireExclusiveWriterAccess() and releaseExclusiveWriterAccess().
+
+### Fixed
+
+* OmniPVD no longer breaks when running and recording multiple scenes in parallel.
+* Corrected mirroring of the inbountJoinDOF attribute of PxArticulationLink
+
+## Extensions
+
+### Fixed
+
+* A bug in custom cone/cylinder collision with triangle meshes. There was a gap between a cone/cylinder and a mesh, noticeable for centimeter-scale shapes. Note that the last position argument of e.g.: PxCustomGeometryExt::CylinderCallbacks::useSubstituteGeometry was removed from the API.
+
+
+# v5.3.0-105.1
## Supported Platforms
diff --git a/physx/buildtools/packman/bootstrap/configure.bat b/physx/buildtools/packman/bootstrap/configure.bat
index 8c502b3f7..8f8aa66d6 100644
--- a/physx/buildtools/packman/bootstrap/configure.bat
+++ b/physx/buildtools/packman/bootstrap/configure.bat
@@ -1,4 +1,4 @@
-:: Copyright 2019 NVIDIA CORPORATION
+:: Copyright 2019-2023 NVIDIA CORPORATION
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
:: See the License for the specific language governing permissions and
:: limitations under the License.
-set PM_PACKMAN_VERSION=6.33.2
+set PM_PACKMAN_VERSION=7.15.1
:: Specify where packman command is rooted
set PM_INSTALL_PATH=%~dp0..
@@ -48,7 +48,7 @@ echo.
:: that may be needed in the path
:ENSURE_DIR
if not exist "%PM_PACKAGES_ROOT%" (
- echo Creating directory %PM_PACKAGES_ROOT%
+ echo Creating packman packages cache at %PM_PACKAGES_ROOT%
mkdir "%PM_PACKAGES_ROOT%"
)
if %errorlevel% neq 0 ( goto ERROR_MKDIR_PACKAGES_ROOT )
@@ -59,7 +59,7 @@ if defined PM_PYTHON_EXT (
goto PACKMAN
)
-set PM_PYTHON_VERSION=3.7.9-windows-x86_64
+set PM_PYTHON_VERSION=3.10.5-1-windows-x86_64
set PM_PYTHON_BASE_DIR=%PM_PACKAGES_ROOT%\python
set PM_PYTHON_DIR=%PM_PYTHON_BASE_DIR%\%PM_PYTHON_VERSION%
set PM_PYTHON=%PM_PYTHON_DIR%\python.exe
@@ -95,11 +95,16 @@ if exist "%PM_PYTHON%" (
if exist "%PM_PYTHON_DIR%" ( rd /s /q "%PM_PYTHON_DIR%" > nul )
)
-:: Perform atomic rename
-rename "%TEMP_FOLDER_NAME%" "%PM_PYTHON_VERSION%" 1> nul
-:: Failure during move, need to clean up and abort
+:: Perform atomic move (allowing overwrite, /y)
+move /y "%TEMP_FOLDER_NAME%" "%PM_PYTHON_DIR%" 1> nul
+:: Verify that python.exe is now where we expect
+if exist "%PM_PYTHON%" goto PACKMAN
+
+:: Wait a second and try again (can help with access denied weirdness)
+timeout /t 1 /nobreak 1> nul
+move /y "%TEMP_FOLDER_NAME%" "%PM_PYTHON_DIR%" 1> nul
if %errorlevel% neq 0 (
- echo !!! Error renaming python !!!
+ echo !!! Error moving python %TEMP_FOLDER_NAME% -> %PM_PYTHON_DIR% !!!
call :CLEAN_UP_TEMP_FOLDER
goto ERROR
)
@@ -112,9 +117,12 @@ if defined PM_MODULE_DIR_EXT (
set PM_MODULE_DIR=%PM_PACKAGES_ROOT%\packman-common\%PM_PACKMAN_VERSION%
)
-set PM_MODULE=%PM_MODULE_DIR%\packman.py
+set PM_MODULE=%PM_MODULE_DIR%\run.py
-if exist "%PM_MODULE%" goto ENSURE_7ZA
+if exist "%PM_MODULE%" goto END
+
+:: Clean out broken PM_MODULE_DIR if it exists
+if exist "%PM_MODULE_DIR%" ( rd /s /q "%PM_MODULE_DIR%" > nul )
set PM_MODULE_PACKAGE=packman-common@%PM_PACKMAN_VERSION%.zip
for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do set TEMP_FILE_NAME=%%a
@@ -134,19 +142,6 @@ if %errorlevel% neq 0 (
del "%TARGET%"
-:ENSURE_7ZA
-set PM_7Za_VERSION=16.02.4
-set PM_7Za_PATH=%PM_PACKAGES_ROOT%\7za\%PM_7ZA_VERSION%
-if exist "%PM_7Za_PATH%" goto END
-set PM_7Za_PATH=%PM_PACKAGES_ROOT%\chk\7za\%PM_7ZA_VERSION%
-if exist "%PM_7Za_PATH%" goto END
-
-"%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" pull "%PM_MODULE_DIR%\deps.packman.xml"
-if %errorlevel% neq 0 (
- echo !!! Error fetching packman dependencies !!!
- goto ERROR
-)
-
goto END
:ERROR_MKDIR_PACKAGES_ROOT
diff --git a/physx/buildtools/packman/bootstrap/download_file_from_url.ps1 b/physx/buildtools/packman/bootstrap/download_file_from_url.ps1
index 5a3e2ede8..df5574560 100644
--- a/physx/buildtools/packman/bootstrap/download_file_from_url.ps1
+++ b/physx/buildtools/packman/bootstrap/download_file_from_url.ps1
@@ -20,8 +20,8 @@ param(
)
$filename = $output
-$triesLeft = 3
-
+$triesLeft = 4
+$delay = 2
do
{
$triesLeft -= 1
@@ -31,12 +31,23 @@ do
Write-Host "Downloading from bootstrap.packman.nvidia.com ..."
$wc = New-Object net.webclient
$wc.Downloadfile($source, $fileName)
- $triesLeft = 0
+ exit 0
}
catch
{
Write-Host "Error downloading $source!"
Write-Host $_.Exception|format-list -force
+ if ($triesLeft)
+ {
+ Write-Host "Retrying in $delay seconds ..."
+ Start-Sleep -seconds $delay
+ }
+ $delay = $delay * $delay
}
} while ($triesLeft -gt 0)
-
+# We only get here if the retries have been exhausted, remove any left-overs:
+if (Test-Path $fileName)
+{
+ Remove-Item $fileName
+}
+exit 1
\ No newline at end of file
diff --git a/physx/buildtools/packman/bootstrap/fetch_file_from_packman_bootstrap.cmd b/physx/buildtools/packman/bootstrap/fetch_file_from_packman_bootstrap.cmd
index 4339bdc34..bf3a88d50 100644
--- a/physx/buildtools/packman/bootstrap/fetch_file_from_packman_bootstrap.cmd
+++ b/physx/buildtools/packman/bootstrap/fetch_file_from_packman_bootstrap.cmd
@@ -22,9 +22,8 @@
@powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0download_file_from_url.ps1" ^
-source "http://bootstrap.packman.nvidia.com/%PACKAGE_NAME%" -output %TARGET_PATH%
:: A bug in powershell prevents the errorlevel code from being set when using the -File execution option
-:: We must therefore do our own failure analysis, basically make sure the file exists and is larger than 0 bytes:
+:: We must therefore do our own failure analysis, basically make sure the file exists:
@if not exist %TARGET_PATH% goto ERROR_DOWNLOAD_FAILED
-@if %~z2==0 goto ERROR_DOWNLOAD_FAILED
@endlocal
@exit /b 0
diff --git a/physx/buildtools/packman/bootstrap/install_package.py b/physx/buildtools/packman/bootstrap/install_package.py
index 5b56a705f..b8ae7f642 100644
--- a/physx/buildtools/packman/bootstrap/install_package.py
+++ b/physx/buildtools/packman/bootstrap/install_package.py
@@ -16,42 +16,139 @@
import zipfile
import tempfile
import sys
-import shutil
+import os
+import stat
+import time
+from typing import Any, Callable
+
+
+RENAME_RETRY_COUNT = 100
+RENAME_RETRY_DELAY = 0.1
-__author__ = "hfannar"
logging.basicConfig(level=logging.WARNING, format="%(message)s")
logger = logging.getLogger("install_package")
-class TemporaryDirectory:
- def __init__(self):
- self.path = None
+def remove_directory_item(path):
+ if os.path.islink(path) or os.path.isfile(path):
+ try:
+ os.remove(path)
+ except PermissionError:
+ # make sure we have access and try again:
+ os.chmod(path, stat.S_IRWXU)
+ os.remove(path)
+ else:
+ # try first to delete the dir because this will work for folder junctions, otherwise we would follow the junctions and cause destruction!
+ clean_out_folder = False
+ try:
+ # make sure we have access preemptively - this is necessary because recursing into a directory without permissions
+ # will only lead to heart ache
+ os.chmod(path, stat.S_IRWXU)
+ os.rmdir(path)
+ except OSError:
+ clean_out_folder = True
+
+ if clean_out_folder:
+ # we should make sure the directory is empty
+ names = os.listdir(path)
+ for name in names:
+ fullname = os.path.join(path, name)
+ remove_directory_item(fullname)
+ # now try to again get rid of the folder - and not catch if it raises:
+ os.rmdir(path)
+
+
+class StagingDirectory:
+ def __init__(self, staging_path):
+ self.staging_path = staging_path
+ self.temp_folder_path = None
+ os.makedirs(staging_path, exist_ok=True)
def __enter__(self):
- self.path = tempfile.mkdtemp()
- return self.path
+ self.temp_folder_path = tempfile.mkdtemp(prefix="ver-", dir=self.staging_path)
+ return self
+
+ def get_temp_folder_path(self):
+ return self.temp_folder_path
+
+ # this function renames the temp staging folder to folder_name, it is required that the parent path exists!
+ def promote_and_rename(self, folder_name):
+ abs_dst_folder_name = os.path.join(self.staging_path, folder_name)
+ os.rename(self.temp_folder_path, abs_dst_folder_name)
def __exit__(self, type, value, traceback):
- # Remove temporary data created
- shutil.rmtree(self.path)
+ # Remove temp staging folder if it's still there (something went wrong):
+ path = self.temp_folder_path
+ if os.path.isdir(path):
+ remove_directory_item(path)
-def install_package(package_src_path, package_dst_path):
- with zipfile.ZipFile(
- package_src_path, allowZip64=True
- ) as zip_file, TemporaryDirectory() as temp_dir:
- zip_file.extractall(temp_dir)
- # Recursively copy (temp_dir will be automatically cleaned up on exit)
- try:
- # Recursive copy is needed because both package name and version folder could be missing in
- # target directory:
- shutil.copytree(temp_dir, package_dst_path)
- except OSError as exc:
+def rename_folder(staging_dir: StagingDirectory, folder_name: str):
+ try:
+ staging_dir.promote_and_rename(folder_name)
+ except OSError as exc:
+ # if we failed to rename because the folder now exists we can assume that another packman process
+ # has managed to update the package before us - in all other cases we re-raise the exception
+ abs_dst_folder_name = os.path.join(staging_dir.staging_path, folder_name)
+ if os.path.exists(abs_dst_folder_name):
logger.warning(
- "Directory %s already present, packaged installation aborted" % package_dst_path
+ f"Directory {abs_dst_folder_name} already present, package installation already completed"
)
else:
- logger.info("Package successfully installed to %s" % package_dst_path)
+ raise
+
+
+def call_with_retry(
+ op_name: str, func: Callable, retry_count: int = 3, retry_delay: float = 20
+) -> Any:
+ retries_left = retry_count
+ while True:
+ try:
+ return func()
+ except (OSError, IOError) as exc:
+ logger.warning(f"Failure while executing {op_name} [{str(exc)}]")
+ if retries_left:
+ retry_str = "retry" if retries_left == 1 else "retries"
+ logger.warning(
+ f"Retrying after {retry_delay} seconds"
+ f" ({retries_left} {retry_str} left) ..."
+ )
+ time.sleep(retry_delay)
+ else:
+ logger.error("Maximum retries exceeded, giving up")
+ raise
+ retries_left -= 1
+
+
+def rename_folder_with_retry(staging_dir: StagingDirectory, folder_name):
+ dst_path = os.path.join(staging_dir.staging_path, folder_name)
+ call_with_retry(
+ f"rename {staging_dir.get_temp_folder_path()} -> {dst_path}",
+ lambda: rename_folder(staging_dir, folder_name),
+ RENAME_RETRY_COUNT,
+ RENAME_RETRY_DELAY,
+ )
+
+
+def install_package(package_path, install_path):
+ staging_path, version = os.path.split(install_path)
+ with StagingDirectory(staging_path) as staging_dir:
+ output_folder = staging_dir.get_temp_folder_path()
+ with zipfile.ZipFile(package_path, allowZip64=True) as zip_file:
+ zip_file.extractall(output_folder)
+
+ # attempt the rename operation
+ rename_folder_with_retry(staging_dir, version)
+
+ print(f"Package successfully installed to {install_path}")
-install_package(sys.argv[1], sys.argv[2])
+if __name__ == "__main__":
+ executable_paths = os.getenv("PATH")
+ paths_list = executable_paths.split(os.path.pathsep) if executable_paths else []
+ target_path_np = os.path.normpath(sys.argv[2])
+ target_path_np_nc = os.path.normcase(target_path_np)
+ for exec_path in paths_list:
+ if os.path.normcase(os.path.normpath(exec_path)) == target_path_np_nc:
+ raise RuntimeError(f"packman will not install to executable path '{exec_path}'")
+ install_package(sys.argv[1], target_path_np)
diff --git a/physx/buildtools/packman/packman b/physx/buildtools/packman/packman
index f481b87fe..d93d80ebd 100755
--- a/physx/buildtools/packman/packman
+++ b/physx/buildtools/packman/packman
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright 2019-2020 NVIDIA CORPORATION
+# Copyright 2019-2023 NVIDIA CORPORATION
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,11 +18,13 @@ set -eu
if echo ${PM_VERBOSITY-} | grep -i "debug" > /dev/null ; then
set -x
+ PM_CURL_SILENT=""
+ PM_WGET_QUIET=""
else
PM_CURL_SILENT="-s -S"
PM_WGET_QUIET="--quiet"
fi
-PM_PACKMAN_VERSION=6.33.2
+PM_PACKMAN_VERSION=7.15.1
# This is necessary for newer macOS
if [ `uname` == 'Darwin' ]; then
@@ -30,33 +32,32 @@ if [ `uname` == 'Darwin' ]; then
export LANG=en_US.UTF-8
fi
-# Specify where packman command exists
-export PM_INSTALL_PATH="$(realpath "$(dirname "${BASH_SOURCE}")")"
-
-add_packages_root_to_file()
-{
- FILE_PATH=$1
- if [ -f "$FILE_PATH" ]; then
- if ! grep -Fq "PM_PACKAGES_ROOT" $FILE_PATH ; then
- echo "Adjusting $FILE_PATH"
- echo -e "export PM_PACKAGES_ROOT=\$HOME/packman-repo\n" >> $FILE_PATH
- fi
- fi
+# We cannot rely on realpath, it isn't installed on macOS and some Linux distros
+get_abs_filename() {
+ echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
}
+# Specify where packman command exists
+export PM_INSTALL_PATH="$(get_abs_filename "$(dirname "${BASH_SOURCE}")")"
+
# The packages root may already be configured by the user
if [ -z "${PM_PACKAGES_ROOT:-}" ]; then
- # Set variable permanently using .profile for this user (if exists)
- add_packages_root_to_file ~/.profile
- add_packages_root_to_file ~/.bashrc
# Set variable temporarily in this process so that the following execution will work
- export PM_PACKAGES_ROOT="${HOME}/packman-repo"
+ if [ `uname` == 'Darwin' ]; then
+ export PM_PACKAGES_ROOT="${HOME}/Library/Application Support/packman-cache"
+ else
+ if [ -z "${XDG_CACHE_HOME:-}" ]; then
+ export PM_PACKAGES_ROOT="${HOME}/.cache/packman"
+ else
+ export PM_PACKAGES_ROOT="${XDG_CACHE_HOME}/packman"
+ fi
+ fi
fi
# Ensure the packages root path exists:
if [ ! -d "$PM_PACKAGES_ROOT" ]; then
- echo "Creating packman packages repository at $PM_PACKAGES_ROOT"
- mkdir -p "$PM_PACKAGES_ROOT"
+ echo "Creating packman packages cache at $PM_PACKAGES_ROOT"
+ mkdir -p -m a+rwx "$PM_PACKAGES_ROOT"
fi
fetch_file_from_s3()
@@ -72,18 +73,28 @@ fetch_file_from_s3()
fi
}
+generate_temp_file_name()
+{
+ if [ `uname` == "Darwin" ]; then
+ local tmpfile=`mktemp -t packman`
+ else
+ local tmpfile=`mktemp -t packman.XXXXXXXX`
+ fi
+ echo "$tmpfile"
+}
+
install_python()
{
PLATFORM=`uname`
PROCESSOR=`uname -m`
- PYTHON_VERSION=3.7.9
+ PYTHON_VERSION=3.10.5-1
if [ $PLATFORM == 'Darwin' ]; then
PYTHON_PACKAGE=$PYTHON_VERSION-macos-x86_64
elif [ $PLATFORM == 'Linux' ] && [ $PROCESSOR == 'x86_64' ]; then
PYTHON_PACKAGE=$PYTHON_VERSION-linux-x86_64
elif [ $PLATFORM == 'Linux' ] && [ $PROCESSOR == 'aarch64' ]; then
- PYTHON_PACKAGE=$PYTHON_VERSION-177-linux-aarch64
+ PYTHON_PACKAGE=$PYTHON_VERSION-linux-aarch64
else
echo "Operating system not supported"
exit 1
@@ -97,10 +108,12 @@ install_python()
export PM_PYTHON="$PYTHON_INSTALL_FOLDER/python"
if [ ! -f "$PM_PYTHON" ]; then
- fetch_file_from_s3 "python@$PYTHON_PACKAGE.tar.gz" "/tmp/python@$PYTHON_PACKAGE.tar.gz"
+ PYTHON_PACKAGE_TMP=$(generate_temp_file_name)
+ fetch_file_from_s3 "python@$PYTHON_PACKAGE.tar.gz" "$PYTHON_PACKAGE_TMP"
if [ "$?" -eq "0" ]; then
echo "Unpacking python"
- tar -xf "/tmp/python@$PYTHON_PACKAGE.tar.gz" -C "$PYTHON_INSTALL_FOLDER"
+ tar -xf "$PYTHON_PACKAGE_TMP" -C "$PYTHON_INSTALL_FOLDER"
+ rm "$PYTHON_PACKAGE_TMP"
else
echo "Failed downloading the Python interpreter"
exit $?
@@ -121,38 +134,28 @@ if [ -z "${PM_MODULE_DIR_EXT:-}" ]; then
else
PM_MODULE_DIR="$PM_MODULE_DIR_EXT"
fi
-export PM_MODULE="$PM_MODULE_DIR/packman.py"
+export PM_MODULE="$PM_MODULE_DIR/run.py"
# Ensure the packman package exists:
if [ ! -f "$PM_MODULE" ]; then
+ # Remove a previously corrupt packman-common if it's there
+ if [ -d "$PM_MODULE_DIR" ]; then
+ rm -rf "$PM_MODULE_DIR"
+ fi
PM_MODULE_PACKAGE="packman-common@$PM_PACKMAN_VERSION.zip"
- TARGET="/tmp/$PM_MODULE_PACKAGE"
+ TARGET=$(generate_temp_file_name)
# We always fetch packman from S3:
- fetch_file_from_s3 $PM_MODULE_PACKAGE $TARGET
+ fetch_file_from_s3 "$PM_MODULE_PACKAGE" "$TARGET"
if [ "$?" -eq "0" ]; then
echo "Unpacking ..."
"$PM_PYTHON" -S -s -u -E "$PM_INSTALL_PATH/bootstrap/install_package.py" "$TARGET" "$PM_MODULE_DIR"
- rm $TARGET
+ rm "$TARGET"
else
echo "Failure while fetching packman module from S3!"
exit 1
fi
fi
-# Ensure 7za package exists:
-PM_7za_VERSION=16.02.4
-export PM_7za_PATH="$PM_PACKAGES_ROOT/7za/$PM_7za_VERSION"
-if [ ! -d "$PM_7za_PATH" ]; then
- export PM_7za_PATH="$PM_PACKAGES_ROOT/chk/7za/$PM_7za_VERSION"
- if [ ! -d "$PM_7za_PATH" ]; then
- "$PM_PYTHON" -S -s -u -E "$PM_MODULE" pull "$PM_MODULE_DIR/deps.packman.xml"
- if [ "$?" -ne 0 ]; then
- echo "Failure while installing required 7za package"
- exit 1
- fi
- fi
-fi
-
# Generate temporary file name for environment variables:
PM_VAR_PATH=`mktemp -u -t tmp.$$.pmvars.XXXXXX`
@@ -174,11 +177,6 @@ if [ -f "$PM_VAR_PATH" ]; then
rm -f "$PM_VAR_PATH"
fi
-# Return the exit code from python
-if [ "$exit_code" != 0 ]; then
- exit "$exit_code"
-fi
-
# avoid leaking -e and -u into the host script if they weren't originally set
if [[ ! ( "$SAVED_SETTINGS" =~ e ) ]]; then
set +e
@@ -188,3 +186,7 @@ if [[ ! ( "$SAVED_SETTINGS" =~ u ) ]]; then
set +u
fi
+# Return the exit code from python
+if [ "$exit_code" != 0 ]; then
+ exit "$exit_code"
+fi
diff --git a/physx/buildtools/packman/packman.cmd b/physx/buildtools/packman/packman.cmd
index c7bf3dcfa..e55b2f0e1 100644
--- a/physx/buildtools/packman/packman.cmd
+++ b/physx/buildtools/packman/packman.cmd
@@ -1,23 +1,22 @@
-:: Reset errorlevel status (don't inherit from caller) [xxxxxxxxxxx]
+:: RUN_PM_MODULE must always be at the same spot for packman update to work (batch reloads file during update!)
+:: [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
+:: Reset errorlevel status (don't inherit from caller)
@call :ECHO_AND_RESET_ERROR
-:: You can remove the call below if you do your own manual configuration of the dev machines
-call "%~dp0\bootstrap\configure.bat"
+:: You can remove this section if you do your own manual configuration of the dev machines
+call :CONFIGURE
if %errorlevel% neq 0 ( exit /b %errorlevel% )
+
:: Everything below is mandatory
if not defined PM_PYTHON goto :PYTHON_ENV_ERROR
if not defined PM_MODULE goto :MODULE_ENV_ERROR
-:: Generate temporary path for variable file
-for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile ^
--File "%~dp0bootstrap\generate_temp_file_name.ps1"') do set PM_VAR_PATH=%%a
+set PM_VAR_PATH_ARG=
-if %1.==. (
- set PM_VAR_PATH_ARG=
-) else (
- set PM_VAR_PATH_ARG=--var-path="%PM_VAR_PATH%"
-)
+if "%1"=="pull" goto :SET_VAR_PATH
+if "%1"=="install" goto :SET_VAR_PATH
+:RUN_PM_MODULE
"%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" %* %PM_VAR_PATH_ARG%
if %errorlevel% neq 0 ( exit /b %errorlevel% )
@@ -48,9 +47,43 @@ exit /b 1
@echo Error while processing and setting environment variables!
exit /b 1
+:: pad [xxxx]
:ECHO_AND_RESET_ERROR
@echo off
if /I "%PM_VERBOSITY%"=="debug" (
@echo on
)
exit /b 0
+
+:SET_VAR_PATH
+:: Generate temporary path for variable file
+for /f "delims=" %%a in ('%PM_PYTHON% -S -s -u -E -c "import tempfile;file = tempfile.NamedTemporaryFile(mode='w+t', delete=False);print(file.name)"') do (set PM_VAR_PATH=%%a)
+set PM_VAR_PATH_ARG=--var-path="%PM_VAR_PATH%"
+goto :RUN_PM_MODULE
+
+:CONFIGURE
+:: Must capture and set code page to work around issue #279, powershell invocation mutates console font
+:: This issue only happens in Windows CMD shell when using 65001 code page. Some Git Bash implementations
+:: don't support chcp so this workaround is a bit convoluted.
+:: Test for chcp:
+chcp > nul 2>&1
+if %errorlevel% equ 0 (
+ for /f "tokens=2 delims=:" %%a in ('chcp') do (set PM_OLD_CODE_PAGE=%%a)
+) else (
+ call :ECHO_AND_RESET_ERROR
+)
+:: trim leading space (this is safe even when PM_OLD_CODE_PAGE has not been set)
+set PM_OLD_CODE_PAGE=%PM_OLD_CODE_PAGE:~1%
+if "%PM_OLD_CODE_PAGE%" equ "65001" (
+ chcp 437 > nul
+ set PM_RESTORE_CODE_PAGE=1
+)
+call "%~dp0\bootstrap\configure.bat"
+set PM_CONFIG_ERRORLEVEL=%errorlevel%
+if defined PM_RESTORE_CODE_PAGE (
+ :: Restore code page
+ chcp %PM_OLD_CODE_PAGE% > nul
+)
+set PM_OLD_CODE_PAGE=
+set PM_RESTORE_CODE_PAGE=
+exit /b %PM_CONFIG_ERRORLEVEL%
diff --git a/physx/buildtools/packman/python.bat b/physx/buildtools/packman/python.bat
index ef37691b2..08df74f8a 100644
--- a/physx/buildtools/packman/python.bat
+++ b/physx/buildtools/packman/python.bat
@@ -13,9 +13,20 @@
:: limitations under the License.
@echo off
-setlocal
+setlocal enableextensions
call "%~dp0\packman" init
set "PYTHONPATH=%PM_MODULE_DIR%;%PYTHONPATH%"
-set PYTHONNOUSERSITE=1
-"%PM_PYTHON%" -u %*
+
+if not defined PYTHONNOUSERSITE (
+ set PYTHONNOUSERSITE=1
+)
+
+REM For performance, default to unbuffered; however, allow overriding via
+REM PYTHONUNBUFFERED=0 since PYTHONUNBUFFERED on windows can truncate output
+REM when printing long strings
+if not defined PYTHONUNBUFFERED (
+ set PYTHONUNBUFFERED=1
+)
+
+"%PM_PYTHON%" %*
\ No newline at end of file
diff --git a/physx/buildtools/packman/python.sh b/physx/buildtools/packman/python.sh
index 37c9f1b89..74328bf0d 100755
--- a/physx/buildtools/packman/python.sh
+++ b/physx/buildtools/packman/python.sh
@@ -22,11 +22,21 @@ if [ ! -f "$PACKMAN_CMD" ]; then
fi
source "$PACKMAN_CMD" init
export PYTHONPATH="${PM_MODULE_DIR}:${PYTHONPATH}"
-export PYTHONNOUSERSITE=1
+
+if [ -z "${PYTHONNOUSERSITE:-}" ]; then
+ export PYTHONNOUSERSITE=1
+fi
+
+# For performance, default to unbuffered; however, allow overriding via
+# PYTHONUNBUFFERED=0 since PYTHONUNBUFFERED on windows can truncate output
+# when printing long strings
+if [ -z "${PYTHONUNBUFFERED:-}" ]; then
+ export PYTHONUNBUFFERED=1
+fi
# workaround for our python not shipping with certs
if [[ -z ${SSL_CERT_DIR:-} ]]; then
export SSL_CERT_DIR=/etc/ssl/certs/
fi
-"${PM_PYTHON}" -u "$@"
+"${PM_PYTHON}" "$@"
diff --git a/physx/dependencies.xml b/physx/dependencies.xml
index 980da1b51..be975e73e 100644
--- a/physx/dependencies.xml
+++ b/physx/dependencies.xml
@@ -8,7 +8,7 @@
-
+
@@ -16,9 +16,9 @@
-
-
-
+
+
+
diff --git a/physx/include/PxParticleSystem.h b/physx/include/PxParticleSystem.h
index b4b3b5edc..077a70368 100644
--- a/physx/include/PxParticleSystem.h
+++ b/physx/include/PxParticleSystem.h
@@ -428,11 +428,16 @@ class PxParticleSystem : public PxActor
/**
- \brief Returns number of particle materials
+ \brief Returns number of particle materials referenced by particle phases
\return The number of particle materials
*/
virtual PxU32 getNbParticleMaterials() const = 0;
+ /**
+ \brief Returns particle materials referenced by particle phases
+ \return The particle materials
+ */
+ virtual PxU32 getParticleMaterials(PxParticleMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
/**
\brief Sets a user notify object which receives special simulation events when they occur.
diff --git a/physx/include/PxSceneDesc.h b/physx/include/PxSceneDesc.h
index 15f1173b8..fad96f857 100644
--- a/physx/include/PxSceneDesc.h
+++ b/physx/include/PxSceneDesc.h
@@ -377,7 +377,7 @@ PX_INLINE bool PxSceneLimits::isValid() const
struct PxgDynamicsMemoryConfig
{
- PxU32 tempBufferCapacity; //!< Capacity of temp buffer allocated in pinned host memory.
+ PxU32 tempBufferCapacity; //!< Initial capacity of temp solver buffer allocated in pinned host memory. This buffer will grow if more memory is needed than specified here.
PxU32 maxRigidContactCount; //!< Size of contact stream buffer allocated in pinned host memory. This is double-buffered so total allocation size = 2* contactStreamCapacity * sizeof(PxContact).
PxU32 maxRigidPatchCount; //!< Size of the contact patch stream buffer allocated in pinned host memory. This is double-buffered so total allocation size = 2 * patchStreamCapacity * sizeof(PxContactPatch).
PxU32 heapCapacity; //!< Initial capacity of the GPU and pinned host memory heaps. Additional memory will be allocated if more memory is required.
diff --git a/physx/include/characterkinematic/PxControllerManager.h b/physx/include/characterkinematic/PxControllerManager.h
index 76c30e775..8177e4399 100644
--- a/physx/include/characterkinematic/PxControllerManager.h
+++ b/physx/include/characterkinematic/PxControllerManager.h
@@ -278,8 +278,10 @@ class PxControllerManager
/**
\brief Creates the controller manager.
- \param[in] scene PhysX scene.
- \param[in] lockingEnabled Enables/disables internal locking.
+ \param[in] scene PhysX scene. You can only create one PxControllerManager per scene.
+ \param[in] lockingEnabled Enables/disables internal locking.
+
+ \return New controller manager, or NULL in case of failure (e.g. when a manager has already been created for that scene)
The character controller is informed by #PxDeletionListener::onRelease() when actors or shapes are released, and updates its internal
caches accordingly. If character controller movement or a call to #PxControllerManager::shiftOrigin() may overlap with actor/shape releases,
diff --git a/physx/include/cudamanager/PxCudaContextManager.h b/physx/include/cudamanager/PxCudaContextManager.h
index 3159d4ebc..d715262c1 100644
--- a/physx/include/cudamanager/PxCudaContextManager.h
+++ b/physx/include/cudamanager/PxCudaContextManager.h
@@ -260,7 +260,7 @@ class PxCudaContextManager
template
void allocDeviceBuffer(T*& deviceBuffer, PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__)
{
- void* ptr = allocDeviceBufferInternal(numElements * sizeof(T), filename, line);
+ void* ptr = allocDeviceBufferInternal(PxU64(numElements) * sizeof(T), filename, line);
deviceBuffer = reinterpret_cast(ptr);
}
@@ -272,7 +272,7 @@ class PxCudaContextManager
template
T* allocDeviceBuffer(PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__)
{
- void* ptr = allocDeviceBufferInternal(numElements * sizeof(T), filename, line);
+ void* ptr = allocDeviceBufferInternal(PxU64(numElements) * sizeof(T), filename, line);
return reinterpret_cast(ptr);
}
@@ -298,7 +298,7 @@ class PxCudaContextManager
template
void allocPinnedHostBuffer(T*& pinnedHostBuffer, PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__)
{
- void* ptr = allocPinnedHostBufferInternal(numElements * sizeof(T), filename, line);
+ void* ptr = allocPinnedHostBufferInternal(PxU64(numElements) * sizeof(T), filename, line);
pinnedHostBuffer = reinterpret_cast(ptr);
}
@@ -312,7 +312,7 @@ class PxCudaContextManager
template
T* allocPinnedHostBuffer(PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__)
{
- void* ptr = allocPinnedHostBufferInternal(numElements * sizeof(T), filename, line);
+ void* ptr = allocPinnedHostBufferInternal(PxU64(numElements) * sizeof(T), filename, line);
return reinterpret_cast(ptr);
}
@@ -439,8 +439,8 @@ class PxCudaContextManager
*/
virtual ~PxCudaContextManager() {}
- virtual void* allocDeviceBufferInternal(PxU32 numBytes, const char* filename = NULL, PxI32 line = -1) = 0;
- virtual void* allocPinnedHostBufferInternal(PxU32 numBytes, const char* filename = NULL, PxI32 line = -1) = 0;
+ virtual void* allocDeviceBufferInternal(PxU64 numBytes, const char* filename = NULL, PxI32 line = -1) = 0;
+ virtual void* allocPinnedHostBufferInternal(PxU64 numBytes, const char* filename = NULL, PxI32 line = -1) = 0;
virtual void freeDeviceBufferInternal(void* deviceBuffer) = 0;
virtual void freePinnedHostBufferInternal(void* pinnedHostBuffer) = 0;
diff --git a/physx/include/extensions/PxCustomGeometryExt.h b/physx/include/extensions/PxCustomGeometryExt.h
index dc0024080..3280fb80c 100644
--- a/physx/include/extensions/PxCustomGeometryExt.h
+++ b/physx/include/extensions/PxCustomGeometryExt.h
@@ -81,7 +81,7 @@ class PxCustomGeometryExt
float margin;
// Substitute geometry
- virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0, const PxVec3& pos1) const = 0;
+ virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0) const = 0;
};
/// \endcond
@@ -140,7 +140,7 @@ class PxCustomGeometryExt
int axis;
// Substitute geometry
- virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0, const PxVec3& pos1) const;
+ virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0) const;
// Radius at height
float getRadiusAtHeight(float height) const;
@@ -202,7 +202,7 @@ class PxCustomGeometryExt
int axis;
// Substitute geometry
- virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0, const PxVec3& pos1) const;
+ virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0) const;
// Radius at height
float getRadiusAtHeight(float height) const;
diff --git a/physx/include/extensions/PxGearJoint.h b/physx/include/extensions/PxGearJoint.h
index 9500f9985..cc6b55931 100644
--- a/physx/include/extensions/PxGearJoint.h
+++ b/physx/include/extensions/PxGearJoint.h
@@ -67,7 +67,7 @@ namespace physx
\brief Set the hinge/revolute joints connected by the gear joint.
The passed joints can be either PxRevoluteJoint, PxD6Joint or PxArticulationJointReducedCoordinate.
- The joints must define degrees of freedom around the twist axis. They cannot be null.
+ The joints must define degrees of freedom around the twist axis.
Note that these joints are only used to compute the positional error correction term,
used to adjust potential drift between jointed actors. The gear joint can run without
diff --git a/physx/include/extensions/PxRackAndPinionJoint.h b/physx/include/extensions/PxRackAndPinionJoint.h
index 72558815c..ce5d4fc9b 100644
--- a/physx/include/extensions/PxRackAndPinionJoint.h
+++ b/physx/include/extensions/PxRackAndPinionJoint.h
@@ -67,8 +67,8 @@ namespace physx
/**
\brief Set the hinge & prismatic joints connected by the rack & pinion joint.
- The passed hinge joint can be either PxRevoluteJoint, PxD6Joint or PxArticulationJointReducedCoordinate. It cannot be null.
- The passed prismatic joint can be either PxPrismaticJoint or PxD6Joint. It cannot be null.
+ The passed hinge joint can be either PxRevoluteJoint, PxD6Joint or PxArticulationJointReducedCoordinate.
+ The passed prismatic joint can be either PxPrismaticJoint or PxD6Joint.
Note that these joints are only used to compute the positional error correction term,
used to adjust potential drift between jointed actors. The rack & pinion joint can run without
diff --git a/physx/include/extensions/PxRemeshingExt.h b/physx/include/extensions/PxRemeshingExt.h
index 556a859c7..aa9e2cb2f 100644
--- a/physx/include/extensions/PxRemeshingExt.h
+++ b/physx/include/extensions/PxRemeshingExt.h
@@ -63,6 +63,24 @@ namespace physx
*/
static bool limitMaxEdgeLength(PxArray& triangles, PxArray& points, PxReal maxEdgeLength,
PxU32 maxIterations = 100, PxArray* triangleMap = NULL, PxU32 triangleCountThreshold = 0xFFFFFFFF);
+
+ /**
+ \brief Processes a triangle mesh and makes sure that no triangle edge is longer than the maximal edge length specified
+
+ To shorten edges that are too long, additional points get inserted at their center leading to a subdivision of the input mesh.
+ This process is executed repeatedly until the maximum edge length criterion is satisfied
+
+ \param[in,out] triangles The triangles of the mesh where a maximum edge length should be enforced. They will be modified in place during the process.
+ \param[in,out] points The vertices of the mesh where a maximum edge length should be enforced. They will be modified in place during the process.
+ \param[in] maxEdgeLength The maximum edge length allowed after processing the input
+ \param[in] maxIterations The maximum number of subdivision iterations
+ \param[out] triangleMap An optional map that provides the index of the original triangle for every triangle after the subdivision
+ \param[in] triangleCountThreshold Optional limit to the number of triangles. Not guaranteed to match exactly, the algorithm will just stop as soon as possible after reaching the limit.
+
+ \return True if any remeshing was applied
+ */
+ static bool reduceSliverTriangles(PxArray& triangles, PxArray& points, PxReal maxEdgeLength,
+ PxU32 maxIterations = 3, PxArray* triangleMap = NULL, PxU32 triangleCountThreshold = 0xFFFFFFFF);
};
#if !PX_DOXYGEN
diff --git a/physx/include/extensions/PxSerialization.h b/physx/include/extensions/PxSerialization.h
index 3283822f7..c72cd022d 100644
--- a/physx/include/extensions/PxSerialization.h
+++ b/physx/include/extensions/PxSerialization.h
@@ -44,7 +44,7 @@
PX_BINARY_SERIAL_VERSION is used to version the PhysX binary data and meta data. The global unique identifier of the PhysX SDK needs to match
the one in the data and meta data, otherwise they are considered incompatible. A 32 character wide GUID can be generated with https://www.guidgenerator.com/ for example.
*/
-#define PX_BINARY_SERIAL_VERSION "C56A614AFD62406E944726BDD9A5E900"
+#define PX_BINARY_SERIAL_VERSION "F57A6B4570DF49E38116AB1E0284A98B"
#if !PX_DOXYGEN
diff --git a/physx/include/extensions/PxTriangleMeshAnalysisResult.h b/physx/include/extensions/PxTriangleMeshAnalysisResult.h
index e84bcf95c..e7833066e 100644
--- a/physx/include/extensions/PxTriangleMeshAnalysisResult.h
+++ b/physx/include/extensions/PxTriangleMeshAnalysisResult.h
@@ -54,9 +54,10 @@ namespace physx
eCONTAINS_DUPLICATE_POINTS = (1 << 6), //!< ok: Duplicate points can be handled by the mesher without problems. The resulting tetmesh will only make use of first unique point that is found, duplicate points will get mapped to that unique point in the tetmesh. Therefore the tetmesh can contain points that are not accessed by a tet.
eCONTAINS_INVALID_POINTS = (1 << 7), //!< invalid: Points contain NAN, infinity or similar values that will lead to an invalid mesh
eREQUIRES_32BIT_INDEX_BUFFER = (1 << 8), //!< invalid: Mesh contains more indices than a 16bit index buffer can address
+ eTRIANGLE_INDEX_OUT_OF_RANGE = (1 << 9), //!< invalid: A mesh triangle index is negative or lager than the size of the vertex buffer
- eMESH_IS_PROBLEMATIC = (1 << 9), //!< flag is set if the mesh is categorized as problematic
- eMESH_IS_INVALID = (1 << 10) //!< flag is set if the mesh is categorized as invalid
+ eMESH_IS_PROBLEMATIC = (1 << 10), //!< flag is set if the mesh is categorized as problematic
+ eMESH_IS_INVALID = (1 << 11) //!< flag is set if the mesh is categorized as invalid
};
};
typedef PxFlags PxTriangleMeshAnalysisResults;
diff --git a/physx/include/foundation/PxPhysicsVersion.h b/physx/include/foundation/PxPhysicsVersion.h
index d975ab55e..0db1ba0a5 100644
--- a/physx/include/foundation/PxPhysicsVersion.h
+++ b/physx/include/foundation/PxPhysicsVersion.h
@@ -50,7 +50,7 @@ sometimes they are stored in a byte.
#define PX_PHYSICS_VERSION_MAJOR 5
#define PX_PHYSICS_VERSION_MINOR 3
-#define PX_PHYSICS_VERSION_BUGFIX 0
+#define PX_PHYSICS_VERSION_BUGFIX 1
/**
The constant PX_PHYSICS_VERSION is used when creating certain PhysX module objects.
diff --git a/physx/include/foundation/PxPinnedArray.h b/physx/include/foundation/PxPinnedArray.h
index 020fb4383..82fe9a3b6 100644
--- a/physx/include/foundation/PxPinnedArray.h
+++ b/physx/include/foundation/PxPinnedArray.h
@@ -43,6 +43,7 @@ namespace physx
typedef PxArray PxBoundsArrayPinned;
typedef PxArray PxFloatArrayPinned;
typedef PxArray PxInt32ArrayPinned;
+ typedef PxArray PxInt16ArrayPinned;
typedef PxArray PxInt8ArrayPinned;
#if !PX_DOXYGEN
diff --git a/physx/include/foundation/PxPreprocessor.h b/physx/include/foundation/PxPreprocessor.h
index 2c9e7a1b3..5ea63bb32 100644
--- a/physx/include/foundation/PxPreprocessor.h
+++ b/physx/include/foundation/PxPreprocessor.h
@@ -30,9 +30,7 @@
#define PX_PREPROCESSOR_H
#include
-#if !defined(PX_GENERATE_META_DATA)
-#include
-#endif
+
/** \addtogroup foundation
@{
*/
@@ -370,6 +368,15 @@ Final macro
*/
#define PX_FINAL final
+/**
+Unused attribute macro. Only on GCC for now.
+ */
+#if PX_GCC_FAMILY
+ #define PX_UNUSED_ATTRIBUTE __attribute__((unused))
+#else
+ #define PX_UNUSED_ATTRIBUTE
+#endif
+
/**
Alignment macros
diff --git a/physx/include/geomutils/PxContactPoint.h b/physx/include/geomutils/PxContactPoint.h
index 9630bf255..c6e363ab9 100644
--- a/physx/include/geomutils/PxContactPoint.h
+++ b/physx/include/geomutils/PxContactPoint.h
@@ -76,7 +76,6 @@ namespace physx
\brief The surface index of shape 1 at the contact point. This is used to identify the surface material.
\note This field is only supported by triangle meshes and heightfields, else it will be set to PXC_CONTACT_NO_FACE_INDEX.
- \note This value must be directly after internalFaceIndex0 in memory
*/
PxU32 internalFaceIndex1;
@@ -90,6 +89,9 @@ namespace physx
*/
PxReal restitution;
+ /**
+ \brief Damping coefficient (for compliant contacts)
+ */
PxReal damping;
};
diff --git a/physx/include/omnipvd/PxOmniPvd.h b/physx/include/omnipvd/PxOmniPvd.h
index cc7b8420b..63224d6c5 100644
--- a/physx/include/omnipvd/PxOmniPvd.h
+++ b/physx/include/omnipvd/PxOmniPvd.h
@@ -44,16 +44,72 @@ class PxFoundation;
class PxOmniPvd
{
public:
+ class ScopedExclusiveWriter
+ {
+ public:
+ PX_FORCE_INLINE ScopedExclusiveWriter(PxOmniPvd* omniPvd)
+ {
+ mOmniPvd = omniPvd;
+ mWriter = NULL;
+ if (mOmniPvd) {
+ mWriter = mOmniPvd->acquireExclusiveWriterAccess();
+ }
+ }
+
+ PX_FORCE_INLINE ~ScopedExclusiveWriter()
+ {
+ if (mOmniPvd && mWriter) {
+ mOmniPvd->releaseExclusiveWriterAccess();
+ }
+ }
+
+ PX_FORCE_INLINE OmniPvdWriter* operator-> ()
+ {
+ return mWriter;
+ }
+
+ PX_FORCE_INLINE OmniPvdWriter* getWriter()
+ {
+ return mWriter;
+ }
+ private:
+ OmniPvdWriter* mWriter;
+ PxOmniPvd* mOmniPvd;
+ };
+
virtual ~PxOmniPvd()
{
}
/**
- \brief Gets an instance of the OmniPvd writer
+ \brief Get the OmniPvd writer.
+
+ Gets an instance of the OmniPvd writer. The writer access will not be thread safe since the OmniPVD API is not thread safe itself. Writing concurrently and simultaneously using the OmniPVD API is undefined.
+
+ For thread safe exlcusive access use the mechanism acquireExclusiveWriterAccess/releaseExclusiveWriterAccess.
\return OmniPvdWriter instance on succes, NULL otherwise.
*/
virtual OmniPvdWriter* getWriter() = 0;
+ /**
+ \brief Acquires an exclusive writer access.
+
+ This call blocks until exclusive access to the writer can be acquired. Once access has been granted, it is guaranteed that no other caller can access the writer through this method until releaseExclusiveWriterAccess() has been called.
+
+ This allows to safely write PVD data in environments with concurrent processing workflows.
+
+ \return OmniPvdWriter instance on succes, NULL otherwise.
+ */
+ virtual OmniPvdWriter* acquireExclusiveWriterAccess() = 0;
+
+ /**
+ \brief Releases the exclusive writer access
+
+ Releases the access to the writer that was previously acquired using acquireExclusiveWriterAccess.
+
+ */
+ virtual void releaseExclusiveWriterAccess() = 0;
+
/**
\brief Gets an instance to the OmniPvd file write stream
@@ -73,6 +129,7 @@ class PxOmniPvd
*/
virtual void release() = 0;
+
};
#if !PX_DOXYGEN
} // namespace physx
diff --git a/physx/include/solver/PxSolverDefs.h b/physx/include/solver/PxSolverDefs.h
index 105f584df..db96cf876 100644
--- a/physx/include/solver/PxSolverDefs.h
+++ b/physx/include/solver/PxSolverDefs.h
@@ -130,14 +130,14 @@ struct PxSolverConstraintDesc
PxU32 bodyADataIndex; //!< Body A's index into the SolverBodyData array
PxU32 bodyBDataIndex; //!< Body B's index into the SolverBodyData array
- PxU32 linkIndexA; //!< Link index defining which link in Articulation A this constraint affects. If not an articulation, must be NO_LINK
- PxU32 linkIndexB; //!< Link index defining which link in Articulation B this constraint affects. If not an articulation, must be NO_LINK
+ PxU32 linkIndexA; //!< Link index defining which link in Articulation A this constraint affects. If not an articulation, must be PxSolverConstraintDesc::RIGID_BODY
+ PxU32 linkIndexB; //!< Link index defining which link in Articulation B this constraint affects. If not an articulation, must be PxSolverConstraintDesc::RIGID_BODY
PxU8* constraint; //!< Pointer to the constraint rows to be solved
void* writeBack; //!< Pointer to the writeback structure results for this given constraint are to be written to
PxU16 progressA; //!< Internal progress counter
PxU16 progressB; //!< Internal progress counter
- PxU16 constraintLengthOver16; //!< constraintLength/16, max constraint length is 1MB, allows PxSolverConstraintDesc to fit in 32 bytes
+ PxU16 constraintLengthOver16; //!< constraintLength/16, max constraint length is 1MB
PxU8 padding[10];
};
diff --git a/physx/snippets/snippetsdf/SnippetSDF.cpp b/physx/snippets/snippetsdf/SnippetSDF.cpp
index 472aebb65..5589fafb5 100644
--- a/physx/snippets/snippetsdf/SnippetSDF.cpp
+++ b/physx/snippets/snippetsdf/SnippetSDF.cpp
@@ -79,7 +79,35 @@ static PxTriangleMesh* createMesh(PxCookingParams& params, const PxArray
meshDesc.sdfDesc = &sdfDesc;
}
- return PxCreateTriangleMesh(params, meshDesc, gPhysics->getPhysicsInsertionCallback());
+ bool enableCaching = false;
+
+ if (enableCaching)
+ {
+ const char* path = "C:\\tmp\\PhysXSDFSnippetData.dat";
+ bool ok = false;
+ FILE* fp = fopen(path, "rb");
+ if (fp)
+ {
+ fclose(fp);
+ ok = true;
+ }
+
+ if (!ok)
+ {
+ PxDefaultFileOutputStream stream(path);
+ ok = PxCookTriangleMesh(params, meshDesc, stream);
+ }
+
+ if (ok)
+ {
+ PxDefaultFileInputData stream(path);
+ PxTriangleMesh* triangleMesh = gPhysics->createTriangleMesh(stream);
+ return triangleMesh;
+ }
+ return NULL;
+ }
+ else
+ return PxCreateTriangleMesh(params, meshDesc, gPhysics->getPhysicsInsertionCallback());
}
static void addInstance(const PxTransform& transform, PxTriangleMesh* mesh)
diff --git a/physx/source/compiler/cmake/linux/CMakeLists.txt b/physx/source/compiler/cmake/linux/CMakeLists.txt
index 73529f8c6..e85352e8c 100644
--- a/physx/source/compiler/cmake/linux/CMakeLists.txt
+++ b/physx/source/compiler/cmake/linux/CMakeLists.txt
@@ -142,7 +142,7 @@ ELSE()
SET(PX_SUPPORT_OMNI_PVD_FLAG "PX_SUPPORT_OMNI_PVD=1")
ENDIF()
SET(PHYSX_LINUX_COMPILE_DEFS "${PHYSX_AUTOBUILD};${PUBLIC_RELEASE_FLAG};${FEATURES_UNDER_CONSTRUCTION_FLAG}" CACHE INTERNAL "Base PhysX preprocessor definitions")
-SET(PHYSX_LINUX_DEBUG_COMPILE_DEFS "NDEBUG;PX_DEBUG=1;PX_CHECKED=1;${NVTX_FLAG};PX_SUPPORT_PVD=1;${PX_SUPPORT_OMNI_PVD_FLAG}" CACHE INTERNAL "Debug PhysX preprocessor definitions")
+SET(PHYSX_LINUX_DEBUG_COMPILE_DEFS "PX_DEBUG=1;PX_CHECKED=1;${NVTX_FLAG};PX_SUPPORT_PVD=1;${PX_SUPPORT_OMNI_PVD_FLAG}" CACHE INTERNAL "Debug PhysX preprocessor definitions")
SET(PHYSX_LINUX_CHECKED_COMPILE_DEFS "NDEBUG;PX_CHECKED=1;${NVTX_FLAG};PX_SUPPORT_PVD=1;${PX_SUPPORT_OMNI_PVD_FLAG}" CACHE INTERNAL "Checked PhysX preprocessor definitions")
SET(PHYSX_LINUX_PROFILE_COMPILE_DEFS "NDEBUG;PX_PROFILE=1;${NVTX_FLAG};PX_SUPPORT_PVD=1;${PX_SUPPORT_OMNI_PVD_FLAG}" CACHE INTERNAL "Profile PhysX preprocessor definitions")
SET(PHYSX_LINUX_RELEASE_COMPILE_DEFS "NDEBUG;PX_SUPPORT_PVD=0;PX_SUPPORT_OMNI_PVD=0" CACHE INTERNAL "Release PhysX preprocessor definitions")
diff --git a/physx/source/compiler/cmake/modules/NvidiaBuildOptions.cmake b/physx/source/compiler/cmake/modules/NvidiaBuildOptions.cmake
index bf5c840e8..40ff7c796 100644
--- a/physx/source/compiler/cmake/modules/NvidiaBuildOptions.cmake
+++ b/physx/source/compiler/cmake/modules/NvidiaBuildOptions.cmake
@@ -84,7 +84,7 @@ SET(CRT_DEBUG_FLAG "/D \"_DEBUG\"")
SET(CRT_NDEBUG_FLAG "/D \"NDEBUG\"")
# Need a different format for CUDA
-SET(CUDA_DEBUG_FLAG "-DNDEBUG ${DISABLE_ITERATOR_DEBUGGING_CUDA}")
+SET(CUDA_DEBUG_FLAG "${DISABLE_ITERATOR_DEBUGGING_CUDA}")
SET(CUDA_NDEBUG_FLAG "-DNDEBUG")
SET(CUDA_CRT_COMPILE_OPTIONS_NDEBUG "")
diff --git a/physx/source/geomutils/src/GuGeometryQuery.cpp b/physx/source/geomutils/src/GuGeometryQuery.cpp
index 10808e53b..df304caa9 100644
--- a/physx/source/geomutils/src/GuGeometryQuery.cpp
+++ b/physx/source/geomutils/src/GuGeometryQuery.cpp
@@ -416,7 +416,7 @@ bool PxGeometryQuery::generateTriangleContacts(const PxGeometry& geom, const PxT
Gu::PCMConvexVsMeshContactGeneration contactGeneration(contactDist, replaceBreakingThreshold, boxTransform, meshTransform, multiManifold, contactBuffer0, polyData, &boxMap, &deferredContacts, idtScaling, true, true, NULL);
contactGeneration.processTriangle(triangleVertices, triangleIndex, Gu::ETD_CONVEX_EDGE_ALL, triangleIndices);
- contactGeneration.processContacts(GU_CAPSULE_MANIFOLD_CACHE_SIZE, false);
+ contactGeneration.processContacts(GU_SINGLE_MANIFOLD_CACHE_SIZE, false);
break;
}
@@ -446,7 +446,7 @@ bool PxGeometryQuery::generateTriangleContacts(const PxGeometry& geom, const PxT
Gu::PCMConvexVsMeshContactGeneration contactGeneration(contactDist, replaceBreakingThreshold, convexTransform, meshTransform, multiManifold, contactBuffer0, polyData, &convexMap, &deferredContacts, convexScaling, idtConvexScale, true, NULL);
contactGeneration.processTriangle(triangleVertices, triangleIndex, Gu::ETD_CONVEX_EDGE_ALL, triangleIndices);
- contactGeneration.processContacts(GU_CAPSULE_MANIFOLD_CACHE_SIZE, false);
+ contactGeneration.processContacts(GU_SINGLE_MANIFOLD_CACHE_SIZE, false);
break;
}
diff --git a/physx/source/geomutils/src/GuMeshFactory.cpp b/physx/source/geomutils/src/GuMeshFactory.cpp
index 4ee1b3513..fcca54058 100644
--- a/physx/source/geomutils/src/GuMeshFactory.cpp
+++ b/physx/source/geomutils/src/GuMeshFactory.cpp
@@ -830,7 +830,6 @@ PxSoftBodyMesh* MeshFactory::createSoftBodyMesh(PxInputStream& desc)
if (!::loadSoftBodyMeshData(desc, data))
return NULL;
PxSoftBodyMesh* m = createSoftBodyMesh(data);
- //PX_DELETE(data);
return m;
}
@@ -848,8 +847,6 @@ PxTetrahedronMesh* MeshFactory::createTetrahedronMesh(TetrahedronMeshData& data)
{
TetrahedronMesh* np = NULL;
PX_NEW_SERIALIZED(np, TetrahedronMesh)(this, data);
- //PX_ASSERT(false);
- //PX_UNUSED(data);
if (np)
addTetrahedronMesh(np);
@@ -955,7 +952,7 @@ PxConvexMesh* MeshFactory::createConvexMesh(PxInputStream& desc)
if(!np->load(desc))
{
- RefCountable_decRefCount(*np);
+ Cm::deletePxBase(np);
return NULL;
}
@@ -1011,7 +1008,7 @@ PxHeightField* MeshFactory::createHeightField(PxInputStream& stream)
if(!np->load(stream))
{
- RefCountable_decRefCount(*np);
+ Cm::deletePxBase(np);
return NULL;
}
@@ -1114,7 +1111,7 @@ PxBVH* MeshFactory::createBVH(PxInputStream& desc)
if(!np->load(desc))
{
- np->decRefCount();
+ Cm::deletePxBase(np);
return NULL;
}
diff --git a/physx/source/geomutils/src/GuMetaData.cpp b/physx/source/geomutils/src/GuMetaData.cpp
index 7c1409958..9fb0c0df5 100644
--- a/physx/source/geomutils/src/GuMetaData.cpp
+++ b/physx/source/geomutils/src/GuMetaData.cpp
@@ -64,22 +64,30 @@ static void getBinaryMetaData_BigConvexRawData(PxOutputStream& stream)
void SDF::getBinaryMetaData(PxOutputStream& stream)
{
+ PX_DEF_BIN_METADATA_CLASS(stream, Dim3)
+ PX_DEF_BIN_METADATA_ITEM(stream, Dim3, PxU32, x, 0)
+ PX_DEF_BIN_METADATA_ITEM(stream, Dim3, PxU32, y, 0)
+ PX_DEF_BIN_METADATA_ITEM(stream, Dim3, PxU32, z, 0)
+
PX_DEF_BIN_METADATA_CLASS(stream, SDF)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxVec3, mMeshLower, 0)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxReal, mSpacing, 0)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, Dim3, mDims, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxReal, mNumSdfs, 0)
+ PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxU32, mNumSdfs, 0)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxReal, mSdf, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxU32, mSubgridSize, 0)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxU32, mNumStartSlots, 0)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxU32, mSubgridStartSlots, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxU32, mNumSubgridSdfs, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxU8, mSubgridSdf, PxMetaDataFlag::ePTR)
+ PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxU8, mSubgridSdf, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, Dim3, mSdfSubgrids3DTexBlockDim, 0)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxReal, mSubgridsMinSdfValue, 0)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxReal, mSubgridsMaxSdfValue, 0)
PX_DEF_BIN_METADATA_ITEM(stream, SDF, PxU32, mBytesPerSparsePixel, 0)
+ PX_DEF_BIN_METADATA_ITEM(stream, SDF, bool, mOwnsMemory, 0)
+
+
}
void BigConvexData::getBinaryMetaData(PxOutputStream& stream)
@@ -145,6 +153,7 @@ void Gu::ConvexMesh::getBinaryMetaData(PxOutputStream& stream)
getBinaryMetaData_InternalObjectsData(stream);
getBinaryMetaData_HullPolygonData(stream);
getBinaryMetaData_ConvexHullData(stream);
+ SDF::getBinaryMetaData(stream);
BigConvexData::getBinaryMetaData(stream);
PX_DEF_BIN_METADATA_VCLASS(stream,ConvexMesh)
@@ -174,6 +183,12 @@ void Gu::ConvexMesh::getBinaryMetaData(PxOutputStream& stream)
PX_DEF_BIN_METADATA_EXTRA_ARRAY(stream, Gu::ConvexMesh, PxU8, mNb, 0, PxMetaDataFlag::eCOUNT_MASK_MSB)
PX_DEF_BIN_METADATA_EXTRA_ALIGN(stream, ConvexMesh, 4)
+
+ //mSdfData this is currently broken
+ //PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, Gu::SDF, PxReal, mSdf, mNumSdfs, 0, PX_SERIAL_ALIGN)
+ //PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, Gu::SDF, PxU32, mSubgridStartSlots, mNumStartSlots, 0, PX_SERIAL_ALIGN)
+ //PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, Gu::SDF, PxU8, mSubgridSdf, mNumSubgridSdfs, 0, PX_SERIAL_ALIGN)
+
// mBigConvexData
PX_DEF_BIN_METADATA_EXTRA_ITEM(stream, Gu::ConvexMesh, BigConvexData, mBigConvexData, PX_SERIAL_ALIGN)
}
@@ -357,6 +372,8 @@ void BV4Tree::getBinaryMetaData(PxOutputStream& stream)
void Gu::TriangleMesh::getBinaryMetaData(PxOutputStream& stream)
{
+ SDF::getBinaryMetaData(stream);
+
PX_DEF_BIN_METADATA_VCLASS(stream, TriangleMesh)
PX_DEF_BIN_METADATA_BASE_CLASS(stream, TriangleMesh, PxBase)
@@ -384,27 +401,9 @@ void Gu::TriangleMesh::getBinaryMetaData(PxOutputStream& stream)
PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, void, mGRB_triAdjacencies, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mGRB_faceRemap, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mGRB_faceRemapInverse, PxMetaDataFlag::ePTR)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, void, mGRB_BV32Tree, PxMetaDataFlag::ePTR)
-
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxVec3, mSdfData.mMeshLower, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxReal, mSdfData.mSpacing, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mDims.x, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mDims.y, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mDims.z, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mNumSdfs, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxReal, mSdfData.mSdf, PxMetaDataFlag::ePTR)
-
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mSubgridSize, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mNumStartSlots, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mSubgridStartSlots, PxMetaDataFlag::ePTR)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mNumSubgridSdfs, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU8, mSdfData.mSubgridSdf, PxMetaDataFlag::ePTR)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mSdfSubgrids3DTexBlockDim.x, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mSdfSubgrids3DTexBlockDim.y, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mSdfSubgrids3DTexBlockDim.z, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxReal, mSdfData.mSubgridsMinSdfValue, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxReal, mSdfData.mSubgridsMaxSdfValue, 0)
- PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mSdfData.mBytesPerSparsePixel, 0)
+ PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, Gu::BV32Tree, mGRB_BV32Tree, PxMetaDataFlag::ePTR)
+
+ PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, SDF, mSdfData, 0)
PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mAccumulatedTrianglesRef, PxMetaDataFlag::ePTR)
PX_DEF_BIN_METADATA_ITEM(stream, TriangleMesh, PxU32, mTrianglesReferences, PxMetaDataFlag::ePTR)
@@ -442,10 +441,12 @@ void Gu::TriangleMesh::getBinaryMetaData(PxOutputStream& stream)
PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, TriangleMesh, PxU32, mAdjacencies, mNbTriangles, 0, 0)
PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, TriangleMesh, PxU32, mAdjacencies, mNbTriangles, 0, 0)
- // mSdf
- PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, TriangleMesh, PxReal, mSdfData.mSdf, mSdfData.mNumSdfs, 0, PX_SERIAL_ALIGN)
- PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, TriangleMesh, PxU32, mSdfData.mSubgridStartSlots, mSdfData.mNumStartSlots, 0, PX_SERIAL_ALIGN)
- PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, TriangleMesh, PxU8, mSdfData.mSubgridSdf, mSdfData.mNumSubgridSdfs, 0, PX_SERIAL_ALIGN)
+ // GPU data missing!
+
+ // mSdf, this is currently broken
+ //PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, TriangleMesh, PxReal, mSdfData.mSdf, mSdfData.mNumSdfs, 0, PX_SERIAL_ALIGN)
+ //PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, TriangleMesh, PxU32, mSdfData.mSubgridStartSlots, mSdfData.mNumStartSlots, 0, PX_SERIAL_ALIGN)
+ //PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, TriangleMesh, PxU8, mSdfData.mSubgridSdf, mSdfData.mNumSubgridSdfs, 0, PX_SERIAL_ALIGN)
// mAccumulatedTrianglesRef
// PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, TriangleMesh, PxU32, mAccumulatedTrianglesRef, mNbTrianglesReferences, 0, PX_SERIAL_ALIGN)
diff --git a/physx/source/geomutils/src/GuSDF.cpp b/physx/source/geomutils/src/GuSDF.cpp
index db0aa4fbd..938536068 100644
--- a/physx/source/geomutils/src/GuSDF.cpp
+++ b/physx/source/geomutils/src/GuSDF.cpp
@@ -47,6 +47,7 @@
#include "PxSDFBuilder.h"
#include "GuDistancePointSegment.h"
+#include "common/PxSerialFramework.h"
#define EXTENDED_DEBUG 0
@@ -56,9 +57,12 @@ namespace Gu
{
SDF::~SDF()
{
- PX_FREE(mSdf);
- PX_FREE(mSubgridStartSlots);
- PX_FREE(mSubgridSdf);
+ if(mOwnsMemory)
+ {
+ PX_FREE(mSdf);
+ PX_FREE(mSubgridStartSlots);
+ PX_FREE(mSubgridSdf);
+ }
}
PxReal* SDF::allocateSdfs(const PxVec3& meshLower, const PxReal& spacing, const PxU32 dimX, const PxU32 dimY, const PxU32 dimZ,
@@ -119,7 +123,38 @@ namespace Gu
return mSdf;
}
+ void SDF::exportExtraData(PxSerializationContext& context)
+ {
+ if (mSdf)
+ {
+ context.alignData(PX_SERIAL_ALIGN);
+ context.writeData(mSdf, mNumSdfs * sizeof(PxReal));
+ }
+
+ if (mNumStartSlots)
+ {
+ context.alignData(PX_SERIAL_ALIGN);
+ context.writeData(mSubgridStartSlots, mNumStartSlots * sizeof(PxU32));
+ }
+
+ if (mSubgridSdf)
+ {
+ context.alignData(PX_SERIAL_ALIGN);
+ context.writeData(mSubgridSdf, mNumSubgridSdfs * sizeof(PxU8));
+ }
+ }
+
+ void SDF::importExtraData(PxDeserializationContext& context)
+ {
+ if (mSdf)
+ mSdf = context.readExtraData(mNumSdfs);
+
+ if (mSubgridStartSlots)
+ mSubgridStartSlots = context.readExtraData(mNumStartSlots);
+ if (mSubgridSdf)
+ mSubgridSdf = context.readExtraData(mNumSubgridSdfs);
+ }
void buildTree(const PxU32* triangles, const PxU32 numTriangles, const PxVec3* points, PxArray& tree, PxF32 enlargement = 1e-4f)
{
@@ -1432,45 +1467,45 @@ namespace Gu
}
}
}
- }
+ }
- PxReal SDF::decodeSparse(PxI32 xx, PxI32 yy, PxI32 zz) const
+ PX_INLINE PxReal decodeSparse2(const SDF& sdf, PxI32 xx, PxI32 yy, PxI32 zz)
{
- if (xx < 0 || yy < 0 || zz < 0 || xx > PxI32(mDims.x) || yy > PxI32(mDims.y) || zz > PxI32(mDims.z))
+ if (xx < 0 || yy < 0 || zz < 0 || xx > PxI32(sdf.mDims.x) || yy > PxI32(sdf.mDims.y) || zz > PxI32(sdf.mDims.z))
return 1.0f; //Return a value >0 that counts as outside
- const PxU32 nbX = mDims.x / mSubgridSize;
- const PxU32 nbY = mDims.y / mSubgridSize;
- const PxU32 nbZ = mDims.z / mSubgridSize;
-
- PxU32 xBase = xx / mSubgridSize;
- PxU32 yBase = yy / mSubgridSize;
- PxU32 zBase = zz / mSubgridSize;
+ const PxU32 nbX = sdf.mDims.x / sdf.mSubgridSize;
+ const PxU32 nbY = sdf.mDims.y / sdf.mSubgridSize;
+ const PxU32 nbZ = sdf.mDims.z / sdf.mSubgridSize;
+
+ PxU32 xBase = xx / sdf.mSubgridSize;
+ PxU32 yBase = yy / sdf.mSubgridSize;
+ PxU32 zBase = zz / sdf.mSubgridSize;
- PxU32 x = xx % mSubgridSize;
- PxU32 y = yy % mSubgridSize;
- PxU32 z = zz % mSubgridSize;
+ PxU32 x = xx % sdf.mSubgridSize;
+ PxU32 y = yy % sdf.mSubgridSize;
+ PxU32 z = zz % sdf.mSubgridSize;
if (xBase == nbX)
{
--xBase;
- x = mSubgridSize;
+ x = sdf.mSubgridSize;
}
if (yBase == nbY)
{
--yBase;
- y = mSubgridSize;
+ y = sdf.mSubgridSize;
}
if (zBase == nbZ)
{
--zBase;
- z = mSubgridSize;
+ z = sdf.mSubgridSize;
}
- PxU32 startId = mSubgridStartSlots[zBase * (nbX) * (nbY)+yBase * (nbX)+xBase];
+ PxU32 startId = sdf.mSubgridStartSlots[zBase * (nbX) * (nbY)+yBase * (nbX)+xBase];
if (startId != 0xFFFFFFFFu)
{
- decodeTriple(startId, xBase, yBase, zBase);
+ SDF::decodeTriple(startId, xBase, yBase, zBase);
/*if (xBase >= mSdfSubgrids3DTexBlockDim.x || yBase >= mSdfSubgrids3DTexBlockDim.y || zBase >= mSdfSubgrids3DTexBlockDim.z)
{
@@ -1478,29 +1513,37 @@ namespace Gu
//printf("%i %i %i %i\n", PxI32(startId), PxI32(xBase), PxI32(yBase), PxI32(zBase));
}*/
- xBase *= (mSubgridSize + 1);
- yBase *= (mSubgridSize + 1);
- zBase *= (mSubgridSize + 1);
+ xBase *= (sdf.mSubgridSize + 1);
+ yBase *= (sdf.mSubgridSize + 1);
+ zBase *= (sdf.mSubgridSize + 1);
- const PxU32 w = mSdfSubgrids3DTexBlockDim.x * (mSubgridSize + 1);
- const PxU32 h = mSdfSubgrids3DTexBlockDim.y * (mSubgridSize + 1);
+ const PxU32 w = sdf.mSdfSubgrids3DTexBlockDim.x * (sdf.mSubgridSize + 1);
+ const PxU32 h = sdf.mSdfSubgrids3DTexBlockDim.y * (sdf.mSubgridSize + 1);
const PxU32 index = idx3D(xBase + x, yBase + y, zBase + z, w, h);
//if (mBytesPerSparsePixel * index >= mNumSubgridSdfs)
// PxGetFoundation().error(::physx::PxErrorCode::eINTERNAL_ERROR, PX_FL, "Out of bounds sdf subgrid access\n");
-
- return decodeSample(&mSubgridSdf[mBytesPerSparsePixel * index],
- mBytesPerSparsePixel, mSubgridsMinSdfValue, mSubgridsMaxSdfValue);
+
+ return SDF::decodeSample(sdf.mSubgridSdf, index,
+ sdf.mBytesPerSparsePixel, sdf.mSubgridsMinSdfValue, sdf.mSubgridsMaxSdfValue);
}
else
{
- DenseSDF coarseEval(nbX + 1, nbY + 1, nbZ + 1, mSdf);
- PxReal s = 1.0f / mSubgridSize;
- return coarseEval.sampleSDFDirect(PxVec3(xBase + x * s, yBase + y * s, zBase + z * s));
+ DenseSDF coarseEval(nbX + 1, nbY + 1, nbZ + 1, sdf.mSdf);
+
+ PxReal s = 1.0f / sdf.mSubgridSize;
+ PxReal result = coarseEval.sampleSDFDirect(PxVec3(xBase + x * s, yBase + y * s, zBase + z * s));
+
+ return result;
}
}
+ PxReal SDF::decodeSparse(PxI32 xx, PxI32 yy, PxI32 zz) const
+ {
+ return decodeSparse2(*this, xx, yy, zz);
+ }
+
PX_FORCE_INLINE PxU64 key(PxI32 xId, PxI32 yId, PxI32 zId)
{
const PxI32 offset = 1 << 19;
@@ -1640,10 +1683,11 @@ namespace Gu
PX_FORCE_INLINE bool generatePointInCellUsingCache(const Gu::SDF& sdf, PxI32 xBase, PxI32 yBase, PxI32 zBase, PxI32 x, PxI32 y, PxI32 z, PxVec3& point, const PxArray& cache)
{
+ const PxU32 s = sdf.mSubgridSize + 1;
PxReal corners[2][2][2];
for (PxI32 xx = 0; xx <= 1; ++xx) for (PxI32 yy = 0; yy <= 1; ++yy) for (PxI32 zz = 0; zz <= 1; ++zz)
{
- PxReal v = cache[idx3D(x + xx, y + yy, z + zz, sdf.mSubgridSize + 1, sdf.mSubgridSize + 1)];
+ PxReal v = cache[idx3D(x + xx, y + yy, z + zz, s, s)];
corners[xx][yy][zz] = v;
}
return generatePointInCell(sdf, xBase * sdf.mSubgridSize + x, yBase * sdf.mSubgridSize + y, zBase * sdf.mSubgridSize + z, point, corners);
@@ -1684,7 +1728,7 @@ namespace Gu
PxU32 negativeCounter = 0;
for (PxI32 xx = 0; xx <= 1; ++xx) for (PxI32 yy = 0; yy <= 1; ++yy) for (PxI32 zz = 0; zz <= 1; ++zz)
{
- PxReal v = sdf.decodeSparse((i + xx)* sdf.mSubgridSize, (j + yy) * sdf.mSubgridSize, (k + zz) * sdf.mSubgridSize);
+ PxReal v = decodeSparse2(sdf, (i + xx)* sdf.mSubgridSize, (j + yy) * sdf.mSubgridSize, (k + zz) * sdf.mSubgridSize);
if (v > t)
++positiveCounter;
if (v < t)
@@ -1696,7 +1740,54 @@ namespace Gu
return false;
}
- void createTriangles(PxI32 xId, PxI32 yId, PxI32 zId, PxReal d0, PxReal ds[3], const PxHashMap& cellToPoint, const PxArray& points, PxArray& triangleIndices)
+ struct Map : public PxHashMap, public PxUserAllocated
+ {
+ Map()
+ {
+
+ }
+ };
+
+ struct CellToPoint
+ {
+ PxArray