Cramming PhysX in there
More PhysX work More PhysX work
This commit is contained in:
233
modules/PhysX/physx/physx-sys/CHANGELOG.md
Normal file
233
modules/PhysX/physx/physx-sys/CHANGELOG.md
Normal file
@@ -0,0 +1,233 @@
|
||||
# `physx-sys` Changelog
|
||||
|
||||
<!-- markdownlint-disable no-duplicate-heading blanks-around-headers blanks-around-lists -->
|
||||
|
||||
<!-- next-header -->
|
||||
## [Unreleased] - ReleaseDate
|
||||
## [0.11.5] - 2023-10-11
|
||||
### Added
|
||||
- [PR#216](https://github.com/EmbarkStudios/physx-rs/pull/216) Support building for Android on aarch64 macOS hosts
|
||||
|
||||
## [0.11.4] - 2023-09-18
|
||||
### Added
|
||||
- [PR#212](https://github.com/EmbarkStudios/physx-rs/pull/212) Build physx with -fno-strict-aliasing.
|
||||
- [PR#209](https://github.com/EmbarkStudios/physx-rs/pull/209) Add support for `x86_64-linux-android`
|
||||
|
||||
## [0.11.3] - 2023-07-07
|
||||
### Fixed
|
||||
- 0.11.2 release was broken (wrong case in path names).
|
||||
|
||||
## [0.11.2] - 2023-07-07
|
||||
- [PR#201](https://github.com/EmbarkStudios/physx-rs/pull/201) Added `create_pre_and_post_raycast_filter_callback_func`, allowing custom pre and post filtering of query hits.
|
||||
|
||||
## [0.11.1] - 2023-04-18
|
||||
### Fixed
|
||||
- [PR#193](https://github.com/EmbarkStudios/physx-rs/pull/193) fixed an issue where `physx-sys` would be needlessly recompiled due to an incorrect filepath.
|
||||
|
||||
## [0.11.0] - 2023-03-03
|
||||
### Changed
|
||||
- [PR#191](https://github.com/EmbarkStudios/physx-rs/pull/191) resolved [#187](https://github.com/EmbarkStudios/physx-rs/issues/187) by replacing the deprecated `PxCooking` class with the non-deprecated free functions that implement the same functionality.
|
||||
- phys_PxCreateCooking -> **removed**
|
||||
- PxCooking_cookBVH -> phys_PxCookBVH
|
||||
- PxCooking_createBVH -> phys_PxCreateBVH
|
||||
- PxCooking_cookConvexMesh -> phys_PxCookConvexMesh
|
||||
- PxCooking_createConvexMesh -> phys_PxCreateConvexMesh
|
||||
- PxCooking_validateConvexMesh -> phys_PxValidateConvexMesh
|
||||
- PxCooking_cookHeightField -> phys_PxCookHeightField
|
||||
- PxCooking_cookTriangleMesh -> phys_PxCookTriangleMesh
|
||||
- PxCooking_createTriangleMesh -> phys_PxCreateTriangleMesh
|
||||
- PxCooking_validateTriangleMesh -> phys_PxValidateTriangleMesh
|
||||
- PxCooking* -> **removed**
|
||||
|
||||
### Removed
|
||||
- [PR#191](https://github.com/EmbarkStudios/physx-rs/pull/191) removed the cooking functions for soft bodies and tetrahedron meshes, these are only used when targeting Cuda, which this crate explicitly doesn't support.
|
||||
|
||||
## [0.10.0] - 2023-03-03
|
||||
### Changed
|
||||
- [PR#183](https://github.com/EmbarkStudios/physx-rs/pull/183) resolved [#175](https://github.com/EmbarkStudios/physx-rs/issues/175) by upgrading from PhysX 4.1 to PhysX 5.1.3. See the [physx-sys](migration-4-5.md) migration guide for more information for updating your code to work with this big breaking change.
|
||||
|
||||
## [0.8.2] - 2023-02-17
|
||||
### Added
|
||||
- [PR#181](https://github.com/EmbarkStudios/physx-rs/pull/181) add raycast, sweep and overlap buffer and callback create and delete methods, and update example to show how to use them for scene raycasting
|
||||
|
||||
### Fixed
|
||||
- [PR#182](https://github.com/EmbarkStudios/physx-rs/pull/176) fixed a clippy lint that triggers in 1.66.0.
|
||||
|
||||
## [0.8.1] - 2022-11-22
|
||||
### Fixed
|
||||
- [PR#176](https://github.com/EmbarkStudios/physx-rs/pull/176) removed warnings as errors when building the C++ code. This is not useful for end users and just results in sadness when eg. using newer compiler versions that introduce new/improved warnings.
|
||||
|
||||
## [0.8.0] - 2022-10-20
|
||||
- add new `create_assert_handler` function which uses the trampoline pattern to send asserts to Rust
|
||||
|
||||
## [0.7.0] - 2022-10-19
|
||||
|
||||
- add new `create_error_callback` which uses the trampoline pattern to send Physx logging to Rust
|
||||
|
||||
## [0.6.0] - 2022-10-03
|
||||
|
||||
- add new `create_profiler_callback` which uses the trampoline pattern to send profiling events to Rust.
|
||||
- add new feature `profile` which will enable profiling in PhysX
|
||||
|
||||
## [0.5.0] - 2022-08-10
|
||||
|
||||
- [PR#157](https://github.com/EmbarkStudios/physx-rs/pull/157) Remove cmake support
|
||||
- [PR#154](https://github.com/EmbarkStudios/physx-rs/pull/154) Add support for `aarch64-unknown-linux-gnu`
|
||||
- [PR#158](https://github.com/EmbarkStudios/physx-rs/pull/158) Update pre generated `aarch64-linux-android` files
|
||||
- `PxRepXObject` typename field changed from `*const u8` to `*const i8`
|
||||
- `PxDebugText` typename field changed from `*const u8` to `*const i8`
|
||||
- `PxProfileScoped` typename field changed from `*const u8` to `*const i8`
|
||||
- `PxVehicleGraphChannelDesc` typename field changed from `*mut u8` to `*mut i8`
|
||||
- [PR#156](https://github.com/EmbarkStudios/physx-rs/pull/156) Update pre generated `aarch64-apple-darwin` files
|
||||
- Adds `PxSpatialVelocity` to the `PxArticulationRootLinkData` struct as `linkVelocity` and `linkAcceleration` fields.
|
||||
- [PR#153](https://github.com/EmbarkStudios/physx-rs/pull/153) Update clang/llvm lib used by `pxbind` and update `x86_64-apple-darwin`, `x86_64-pc-windows-msvc`, `x86_64-unknown-linux` pre generated files.
|
||||
- Mostly an internal change but adds `PxSpatialVelocity` to the `PxArticulationRootLinkData` struct as `linkVelocity` and `linkAcceleration` fields.
|
||||
|
||||
## [0.4.16] - 2021-12-21
|
||||
### Fixed
|
||||
|
||||
- [PR#142](https://github.com/EmbarkStudios/physx-rs/pull/141) added the license texts to the crate, and added a note in the README about how to clarify the licenses in cargo deny until crates.io supports parentheses in license expressions.
|
||||
- [PR#144](https://github.com/EmbarkStudios/physx-rs/pull/144) fixed a few clang warnings about set but unused variables.
|
||||
|
||||
## [0.4.15] - 2021-08-22
|
||||
|
||||
### Changed
|
||||
|
||||
- [PR#140](https://github.com/EmbarkStudios/physx-rs/pull/140) updated to Embark lint v0.4, though we allow several clippy lints at the moment due to how endemic a few of them are.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [PR#140](https://github.com/EmbarkStudios/physx-rs/pull/140) updated the C++ code to fix several `unused-but-set-variable` errors when compiling with clang-13.
|
||||
|
||||
## [0.4.14] - 2021-07-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- [PR#138](https://github.com/EmbarkStudios/physx-rs/pull/138) silenced the `dtor-name`, `suggest-overrides`, and `suggest-override-destructor` warnings in the cmake build to silence warnings causing [build failures in clang-11+](https://github.com/NVIDIAGameWorks/PhysX/issues/417).
|
||||
|
||||
## [0.4.13] - 2021-05-03
|
||||
|
||||
### Fixed
|
||||
|
||||
- [PR#135](https://github.com/EmbarkStudios/physx-rs/pull/135) Update PhysX submodule with ARM64 buildfix for Xcode 14.5
|
||||
|
||||
## [0.4.12] - 2020-12-03
|
||||
|
||||
### Added
|
||||
|
||||
- [PR#123](https://github.com/EmbarkStudios/physx-rs/pull/123) Initial `aarch64-apple-darwin` support
|
||||
|
||||
## [0.4.11] - 2020-12-03
|
||||
|
||||
### Added
|
||||
|
||||
- [PR#198](https://github.com/EmbarkStudios/physx-rs/pull/98) Major refactor of
|
||||
the high-level `physx` crate exposed the following low-level calls:
|
||||
- `pub fn get_simulation_event_info(callback: *mut PxSimulationEventCallback,) -> *mut SimulationEventCallbackInfo;`
|
||||
- `pub fn get_alloc_callback_user_data(alloc_callback: *mut PxAllocatorCallback) -> *mut c_void;`
|
||||
|
||||
## [0.4.10] - 2020-10-20
|
||||
|
||||
### Added
|
||||
|
||||
- [PR#94](https://github.com/EmbarkStudios/physx-rs/pull/94) Allow overriding the PxAllocatorCallback with a pair of custom callback functions
|
||||
|
||||
## [0.4.9] - 2020-08-13
|
||||
|
||||
### Added
|
||||
|
||||
- [PR#80](https://github.com/EmbarkStudios/physx-rs/pull/80) New way to register simulation event callbacks, supporting all callback types this time.
|
||||
|
||||
## [0.4.8] - 2020-07-02
|
||||
|
||||
### Fixed
|
||||
|
||||
- [PR#77](https://github.com/EmbarkStudios/physx-rs/pull/77) Ignore potential PhysX C++ compile warnings
|
||||
|
||||
## [0.4.7] - 2020-07-02
|
||||
|
||||
### Fixed
|
||||
|
||||
- [PR#76](https://github.com/EmbarkStudios/physx-rs/pull/76) Use proper `ANDROID_NDK_ROOT` env var instead of `NDK_HOME`
|
||||
|
||||
## [0.4.6] - 2020-07-01
|
||||
|
||||
### Added
|
||||
|
||||
- [PR#73](https://github.com/EmbarkStudios/physx-rs/pull/73) Added `create_raycast_filter_callback_func`, allowing custom filtering of raycast hits
|
||||
|
||||
### Fixed
|
||||
|
||||
- [PR#74](https://github.com/EmbarkStudios/physx-rs/pull/74) Fix Android NDK toolchain path selection on Mac & Windows
|
||||
|
||||
## [0.4.4] - 2020-06-02
|
||||
|
||||
### Added
|
||||
|
||||
- [PR#66](https://github.com/EmbarkStudios/physx-rs/pull/66) Added support for android (`aarch64`) to the build system and to `pxbind`.
|
||||
|
||||
## [0.4.3] - 2020-05-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- [PR#70](https://github.com/EmbarkStudios/physx-rs/pull/70) cleaned up some build script problems for Windows.
|
||||
|
||||
## [0.4.2] - 2020-05-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- [PR#67](https://github.com/EmbarkStudios/physx-rs/pull/67) Reduce crate size from 10 MB to 2.7 MB by removing unused PhysX binary files
|
||||
|
||||
## [0.4.1] - 2020-05-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- [PR#62](https://github.com/EmbarkStudios/physx-rs/pull/62) fixed C++ compile warnings/errors when compiling with clang 10.0.0.
|
||||
|
||||
## [0.4.0] - 2020-05-07
|
||||
|
||||
### Changed
|
||||
|
||||
- Use `SetThreadDescription` inside PhysX on Windows 10 to get worker thread names in profilers, instead of just the debugger.
|
||||
- [PR#59](https://github.com/EmbarkStudios/physx-rs/pull/59) made `cmake` into an optional, non-default, dependency for building the C++ code, in favor of just using the `cc` crate. CMake can be enabled via the `use-cmake` feature.
|
||||
- [PR#59](https://github.com/EmbarkStudios/physx-rs/pull/59) updated the fork of the PhysX repository to include various changes to the C++ code to allow it to be cross-compiled for Windows via clang from Linux or Mac.
|
||||
- [PR#59](https://github.com/EmbarkStudios/physx-rs/pull/59) added a `structgen` feature flag, to make the creation of the C++ executable that generates the Rust bindings for the C++ code optional, as the generated code is now checked in and should only need to be updated when PhysX itself is updated.
|
||||
|
||||
## [0.3.0] - 2020-03-04
|
||||
|
||||
### Added
|
||||
|
||||
- Ability to not run the default filter shader before the callback.
|
||||
|
||||
<!-- next-url -->
|
||||
[Unreleased]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.11.5...HEAD
|
||||
[0.11.5]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.11.4...physx-sys-v0.11.5
|
||||
[0.11.4]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.11.3...physx-sys-v0.11.4
|
||||
[0.11.3]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.11.2...physx-sys-v0.11.3
|
||||
[0.11.2]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.11.1...physx-sys-v0.11.2
|
||||
[0.11.1]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.11.0...physx-sys-v0.11.1
|
||||
[0.11.0]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.10.0...physx-sys-v0.11.0
|
||||
[0.10.0]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.8.2...physx-sys-v0.10.0
|
||||
[0.8.2]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.8.1...physx-sys-v0.8.2
|
||||
[0.8.1]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.8.0...physx-sys-v0.8.1
|
||||
[0.8.0]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.7.0...physx-sys-v0.8.0
|
||||
[0.7.0]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.6.0...physx-sys-v0.7.0
|
||||
[0.6.0]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.5.0...physx-sys-v0.6.0
|
||||
[0.5.0]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.16...physx-sys-v0.5.0
|
||||
[0.4.16]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.15...physx-sys-v0.4.16
|
||||
[0.4.15]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.14...physx-sys-v0.4.15
|
||||
[0.4.14]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.13...physx-sys-v0.4.14
|
||||
[0.4.13]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.12...physx-sys-v0.4.13
|
||||
[0.4.12]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.11...physx-sys-v0.4.12
|
||||
[0.4.11]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.10...physx-sys-v0.4.11
|
||||
[0.4.10]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.9...physx-sys-v0.4.10
|
||||
[0.4.9]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.8...physx-sys-v0.4.9
|
||||
[0.4.8]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.7...physx-sys-v0.4.8
|
||||
[0.4.7]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.6...physx-sys-v0.4.7
|
||||
[0.4.6]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.4...physx-sys-v0.4.6
|
||||
[0.4.4]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.3...physx-sys-v0.4.4
|
||||
[0.4.3]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.2...physx-sys-v0.4.3
|
||||
[0.4.2]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.1...physx-sys-v0.4.2
|
||||
[0.4.1]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.4.0...physx-sys-v0.4.1
|
||||
[0.4.0]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.3.0...physx-sys-v0.4.0
|
||||
[0.3.0]: https://github.com/EmbarkStudios/physx-rs/compare/physx-sys-v0.2.4...physx-sys-v0.3.0
|
||||
49
modules/PhysX/physx/physx-sys/Cargo.lock
generated
Normal file
49
modules/PhysX/physx/physx-sys/Cargo.lock
generated
Normal file
@@ -0,0 +1,49 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.99"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.155"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[package]]
|
||||
name = "physx-sys"
|
||||
version = "0.11.5"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
]
|
||||
58
modules/PhysX/physx/physx-sys/Cargo.toml
Normal file
58
modules/PhysX/physx/physx-sys/Cargo.toml
Normal file
@@ -0,0 +1,58 @@
|
||||
[package]
|
||||
name = "physx-sys"
|
||||
description = "Unsafe bindings for NVIDIA PhysX C++ SDK"
|
||||
version = "0.11.5"
|
||||
authors = [
|
||||
"Embark <opensource@embark-studios.com>",
|
||||
"Tomasz Stachowiak <h3@h3.gd>",
|
||||
]
|
||||
license = "(MIT OR Apache-2.0) AND BSD-3-Clause"
|
||||
repository = "https://github.com/EmbarkStudios/physx-rs"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
readme = "README.md"
|
||||
keywords = ["physics"]
|
||||
categories = ["external-ffi-bindings", "simulation", "game-engines"]
|
||||
exclude = [
|
||||
"PhysX/**/*.bat",
|
||||
"PhysX/**/*.html",
|
||||
"PhysX/**/*.sh",
|
||||
"PhysX/*demo/**/*",
|
||||
"PhysX/externals/cg-linux/**/*",
|
||||
"PhysX/externals/clang-physxmetadata/**/*",
|
||||
"PhysX/externals/glew-linux/**/*",
|
||||
"PhysX/externals/glew/**/*",
|
||||
"PhysX/externals/opengl-linux/**/*",
|
||||
"PhysX/externals/targa/**/*",
|
||||
"PhysX/externals/vswhere/**/*",
|
||||
"PhysX/physx/bin/**/*",
|
||||
"PhysX/physx/buildtools/**/*",
|
||||
"PhysX/physx/documentation/**/*",
|
||||
"PhysX/physx/samples/**/*",
|
||||
"PhysX/physx/snippets/**/*",
|
||||
"PhysX/physx/tools/**/*",
|
||||
]
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
[features]
|
||||
# This feature will build and run the structgen program, generating C++ and Rust
|
||||
# code to ensure the record types used in FFI match exactly and can be transparently
|
||||
# memcopied. This feature is not normally needed for tier 1 platforms and Android
|
||||
# as the crate includes pre-generated ones
|
||||
structgen = []
|
||||
profile = []
|
||||
# Enables `Debug` derivations for the FFI structures, which can be useful for
|
||||
# print debugging
|
||||
debug-structs = []
|
||||
# Enables warnings in when compiling the C++ code. This is not something you should care about
|
||||
cpp-warnings = []
|
||||
|
||||
[dependencies]
|
||||
# The PhysX API exposes several enums used as flags
|
||||
bitflags = "1.3"
|
||||
|
||||
[build-dependencies]
|
||||
cc = { version = "1.0", features = ["parallel"] }
|
||||
1
modules/PhysX/physx/physx-sys/LICENSE
Normal file
1
modules/PhysX/physx/physx-sys/LICENSE
Normal file
@@ -0,0 +1 @@
|
||||
# SPDX-License-Identifier: (MIT OR Apache-2.0) AND BSD-3-Clause
|
||||
201
modules/PhysX/physx/physx-sys/LICENSE-APACHE
Normal file
201
modules/PhysX/physx/physx-sys/LICENSE-APACHE
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
31
modules/PhysX/physx/physx-sys/LICENSE-BSD
Normal file
31
modules/PhysX/physx/physx-sys/LICENSE-BSD
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2023, NVIDIA Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
25
modules/PhysX/physx/physx-sys/LICENSE-MIT
Normal file
25
modules/PhysX/physx/physx-sys/LICENSE-MIT
Normal file
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2021 Embark Studios
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
113
modules/PhysX/physx/physx-sys/README.md
Normal file
113
modules/PhysX/physx/physx-sys/README.md
Normal file
@@ -0,0 +1,113 @@
|
||||
<div align="center">
|
||||
|
||||
# 🎳 physx-sys
|
||||
|
||||
**Unsafe automatically-generated Rust bindings for [NVIDIA PhysX 5.1](https://github.com/NVIDIA-Omniverse/PhysX) C++ API.**
|
||||
|
||||

|
||||
[](https://crates.io/crates/physx-sys)
|
||||
[](https://docs.rs/physx-sys)
|
||||
[](../CODE_OF_CONDUCT.md)
|
||||
[](http://embark.games)
|
||||
[](https://discord.gg/dAuKfZS)
|
||||
|
||||
</div>
|
||||
|
||||
Please also see the [repository](https://github.com/EmbarkStudios/physx-rs) containing a work-in-progress safe wrapper.
|
||||
|
||||
## Presentation
|
||||
|
||||
[Tomasz Stachowiak](https://github.com/h3r2tic) did a presentation at the Stockholm Rust Meetup on October 2019 about this project that goes through the technical details of how C++ to Rust bindings of `physx-sys` works:
|
||||
|
||||
[](http://www.youtube.com/watch?v=RxtXGeDHu0w)
|
||||
|
||||
## Basic usage
|
||||
|
||||
```rust
|
||||
unsafe {
|
||||
let foundation = physx_create_foundation();
|
||||
let physics = physx_create_physics(foundation);
|
||||
|
||||
let mut scene_desc = PxSceneDesc_new(PxPhysics_getTolerancesScale(physics));
|
||||
scene_desc.gravity = PxVec3 {
|
||||
x: 0.0,
|
||||
y: -9.81,
|
||||
z: 0.0,
|
||||
};
|
||||
|
||||
let dispatcher = phys_PxDefaultCpuDispatcherCreate(
|
||||
1,
|
||||
null_mut(),
|
||||
PxDefaultCpuDispatcherWaitForWorkMode::WaitForWork,
|
||||
0,
|
||||
);
|
||||
scene_desc.cpuDispatcher = dispatcher.cast();
|
||||
scene_desc.filterShader = get_default_simulation_filter_shader();
|
||||
|
||||
let scene = PxPhysics_createScene_mut(physics, &scene_desc);
|
||||
|
||||
// Your physics simulation goes here
|
||||
}
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### [Ball](examples/ball.rs)
|
||||
|
||||
A simple example to showcase how to use physx-sys. It can be run with `cargo run --examples ball`.
|
||||
|
||||
```txt
|
||||
o
|
||||
|
||||
o
|
||||
o
|
||||
|
||||
o
|
||||
ooooooooo
|
||||
o oo oo
|
||||
o o
|
||||
o o o
|
||||
o oo
|
||||
o o o
|
||||
o ooooooo
|
||||
o o oo oo
|
||||
o o o oo oo
|
||||
o o o o ooooooooo
|
||||
o o o oo oooooooooo oo
|
||||
|
||||
```
|
||||
|
||||
## How it works
|
||||
|
||||
The binding is generated using a custom Rust app that parses the abstract syntax tree of the SDK, and maps the C++ PhysX functions and types to Rust using heuristics chosen specifically for this SDK. It is not a general C++ <-> Rust binding generator, and using it on other projects *will* likely crash and burn.
|
||||
|
||||
Since C++ does not have a standardized and stable ABI, it's generally not safe to call it from Rust code; since PhysX exposes a C++ interface, we can't use it directly. That's why `physx-sys` generates both a Rust interface as well as a plain C wrapper. The C code is compiled into a static library at build time, and Rust then talks to C.
|
||||
|
||||
In order to minimize the amount of work required to marshall data between the C wrapper and the original C++ API, we generate a **bespoke C wrapper for each build target**. The wrapper is based on metadata about structure layout extracted directly from compiling and running a tiny program against the PhysX SDK using the specific C++ compiler used in the build process.
|
||||
|
||||
The build process comprises a few steps:
|
||||
|
||||
1. The `pxbind` utility uses `clang` to extract metadata about PhysX functions and types, and generates partial Rust and C bindings as `physx_generated.hpp` and `physx_generated.rs`. Those contain all function definitions, and a small subset of types. It also generates a C++ utility called `structgen` by emitting `structgen.cpp`.
|
||||
2. `structgen` is compiled against the PhysX SDK, and generates all the remaining type wrappers. For each struct, it queries the size and offset of its members, and generates `structgen_out.hpp` and `structgen_out.rs`. The types are "plain old data" structs which will perfectly match the memory layout of the C++ types.
|
||||
3. All the generated C types are compiled together to form `physx_api`, a static library for Rust to link with.
|
||||
4. The Rust wrapper is compiled, and linked with PhysX and the C wrapper.
|
||||
|
||||
Steps *2..4* are performed completely automatically from within `build.rs`, while step *1* is only necessary when upgrading the PhysX SDK or modifying the generator. As such, building and running `pxbind` is a manual task, and is currently only supported on \*nix systems.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under either of
|
||||
|
||||
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
|
||||
* MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
|
||||
|
||||
at your option.
|
||||
|
||||
Note that the [PhysX C++ SDK](https://github.com/NVIDIA-Omniverse/PhysX) has its [own BSD 3 license](LICENSE-BSD).
|
||||
|
||||
### Contribution
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally
|
||||
submitted for inclusion in the work by you, as defined in the Apache-2.0
|
||||
license, shall be dual licensed as above, without any additional terms or
|
||||
conditions.
|
||||
654
modules/PhysX/physx/physx-sys/build.rs
Normal file
654
modules/PhysX/physx/physx-sys/build.rs
Normal file
@@ -0,0 +1,654 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
struct Environment {
|
||||
host: String,
|
||||
emit_debug_info: bool,
|
||||
target_compiler: Option<String>,
|
||||
target_os: String,
|
||||
target_env: Option<String>,
|
||||
mode: String,
|
||||
static_crt: bool,
|
||||
}
|
||||
|
||||
struct Context {
|
||||
root: PathBuf,
|
||||
builder: cc::Build,
|
||||
env: Environment,
|
||||
includes: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
impl Context {
|
||||
fn add_includes(&mut self, rel_root: &str, includes: &[&str]) -> &mut Self {
|
||||
let root = self.root.join(rel_root);
|
||||
self.includes
|
||||
.extend(includes.iter().map(|inc| root.join(inc)));
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
fn add_sources(&mut self, rel_root: &str, files: &[&str]) -> &mut Self {
|
||||
let root = self.root.join(rel_root);
|
||||
self.builder.files(files.iter().map(|src| {
|
||||
let mut p = root.join(src);
|
||||
p.set_extension("cpp");
|
||||
p
|
||||
}));
|
||||
|
||||
// Always add the src directory as an include as well
|
||||
self.includes.push(root);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
fn add_component(&mut self, name: &str, rel: Option<&str>, sources: &[&str]) -> &mut Self {
|
||||
let mut src_dir = format!("source/{name}");
|
||||
if let Some(rel) = rel {
|
||||
src_dir.push('/');
|
||||
src_dir.push_str(rel);
|
||||
}
|
||||
self.add_sources(&src_dir, sources);
|
||||
|
||||
let mut comproot = self.root.join("include");
|
||||
comproot.push(name);
|
||||
|
||||
if comproot.exists() {
|
||||
self.includes.push(comproot);
|
||||
}
|
||||
|
||||
let mut comproot = self.root.join("source");
|
||||
comproot.push(name);
|
||||
comproot.push("include");
|
||||
|
||||
if comproot.exists() {
|
||||
self.includes.push(comproot);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! component {
|
||||
($name:ident) => {
|
||||
fn $name(ctx: &mut Context) {
|
||||
let sources = include!(concat!("sources/", stringify!($name)));
|
||||
ctx.add_component(stringify!($name), Some("src"), &sources);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
component! {common}
|
||||
component! {fastxml}
|
||||
component! {lowlevelaabb}
|
||||
component! {lowleveldynamics}
|
||||
component! {pvd}
|
||||
component! {scenequery}
|
||||
component! {simulationcontroller}
|
||||
component! {task}
|
||||
|
||||
// The foundation component is really the only one that references platform
|
||||
// specific compilands, so just calculate them here
|
||||
fn foundation(ctx: &mut Context) {
|
||||
let sources = include!("sources/foundation");
|
||||
ctx.add_component("foundation", None, &sources);
|
||||
|
||||
let target_family = env::var("CARGO_CFG_TARGET_FAMILY").expect("TARGET_FAMILY not specified");
|
||||
let sources = match target_family.as_str() {
|
||||
"unix" => &include!("sources/foundation_unix"),
|
||||
"windows" => &include!("sources/foundation_windows"),
|
||||
other => panic!("unknown TARGET_FAMILY '{}'", other),
|
||||
};
|
||||
|
||||
ctx.add_sources(&format!("source/foundation/{target_family}"), sources);
|
||||
}
|
||||
|
||||
fn lowlevel(ctx: &mut Context) {
|
||||
// API
|
||||
ctx.builder
|
||||
.file(ctx.root.join("source/lowlevel/api/src/px_globals.cpp"));
|
||||
|
||||
// pipeline
|
||||
{
|
||||
let sources = include!("sources/lowlevel_pipeline");
|
||||
ctx.add_sources("source/lowlevel/common/src/pipeline", &sources);
|
||||
}
|
||||
|
||||
// software, otherwise known as non-gpu
|
||||
{
|
||||
let sources = include!("sources/lowlevel_software");
|
||||
ctx.add_sources("source/lowlevel/software/src", &sources);
|
||||
}
|
||||
|
||||
ctx.add_includes(
|
||||
"source/lowlevel",
|
||||
&[
|
||||
"api/include",
|
||||
"common/include/collision",
|
||||
"common/include/pipeline",
|
||||
"common/include/utils",
|
||||
"software/include",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
fn vehicle(ctx: &mut Context) {
|
||||
let sources = include!("sources/vehicle");
|
||||
ctx.add_component("physxvehicle", Some("src"), &sources);
|
||||
|
||||
let sources = include!("sources/vehicle_metadata");
|
||||
ctx.add_sources("source/physxvehicle/src/physxmetadata/src", &sources);
|
||||
|
||||
ctx.add_includes("source/physxvehicle/src/physxmetadata", &["include"]);
|
||||
}
|
||||
|
||||
fn extensions(ctx: &mut Context) {
|
||||
let sources = include!("sources/extensions");
|
||||
ctx.add_component("physxextensions", Some("src"), &sources);
|
||||
|
||||
// metadata
|
||||
ctx.add_sources(
|
||||
"source/physxmetadata/extensions/src",
|
||||
&["PxExtensionAutoGeneratedMetaDataObjects"],
|
||||
);
|
||||
|
||||
// serialization
|
||||
let sources = include!("sources/extensions_serialization");
|
||||
ctx.add_sources("source/physxextensions/src/serialization", &sources);
|
||||
ctx.add_includes("source/physxextensions/src/serialization", &["File"]);
|
||||
|
||||
// xml
|
||||
let sources = include!("sources/extensions_xml");
|
||||
ctx.add_sources("source/physxextensions/src/serialization/Xml", &sources);
|
||||
|
||||
// binary
|
||||
let sources = include!("sources/extensions_binary");
|
||||
ctx.add_sources("source/physxextensions/src/serialization/Binary", &sources);
|
||||
|
||||
// tet
|
||||
let sources = include!("sources/extensions_tet");
|
||||
ctx.add_sources("source/physxextensions/src/tet", &sources);
|
||||
|
||||
ctx.add_includes("source/physxmetadata/extensions", &["include"]);
|
||||
}
|
||||
|
||||
fn physxcharacterkinematic(ctx: &mut Context) {
|
||||
// root
|
||||
let sources = include!("sources/physxcharacterkinematic");
|
||||
ctx.add_sources("source/physxcharacterkinematic/src", &sources);
|
||||
ctx.add_includes("source/include", &["characterkinematic"]);
|
||||
}
|
||||
|
||||
fn geomutils(ctx: &mut Context) {
|
||||
// root
|
||||
let sources = include!("sources/geomutils");
|
||||
ctx.add_sources("source/geomutils/src", &sources);
|
||||
ctx.add_includes("source/geomutils", &["include"]);
|
||||
|
||||
// ccd
|
||||
let sources = include!("sources/geomutils_ccd");
|
||||
ctx.add_sources("source/geomutils/src/ccd", &sources);
|
||||
|
||||
// common
|
||||
let sources = include!("sources/geomutils_common");
|
||||
ctx.add_sources("source/geomutils/src/common", &sources);
|
||||
|
||||
// contact
|
||||
let sources = include!("sources/geomutils_contact");
|
||||
ctx.add_sources("source/geomutils/src/contact", &sources);
|
||||
|
||||
// convex
|
||||
let sources = include!("sources/geomutils_convex");
|
||||
ctx.add_sources("source/geomutils/src/convex", &sources);
|
||||
|
||||
// cooking
|
||||
let sources = include!("sources/geomutils_cooking");
|
||||
ctx.add_sources("source/geomutils/src/cooking", &sources);
|
||||
|
||||
// distance
|
||||
let sources = include!("sources/geomutils_distance");
|
||||
ctx.add_sources("source/geomutils/src/distance", &sources);
|
||||
|
||||
// gjk
|
||||
let sources = include!("sources/geomutils_gjk");
|
||||
ctx.add_sources("source/geomutils/src/gjk", &sources);
|
||||
|
||||
// hf
|
||||
let sources = include!("sources/geomutils_hf");
|
||||
ctx.add_sources("source/geomutils/src/hf", &sources);
|
||||
|
||||
// intersection
|
||||
let sources = include!("sources/geomutils_intersection");
|
||||
ctx.add_sources("source/geomutils/src/intersection", &sources);
|
||||
|
||||
// mesh
|
||||
let sources = include!("sources/geomutils_mesh");
|
||||
ctx.add_sources("source/geomutils/src/mesh", &sources);
|
||||
|
||||
// pcm
|
||||
let sources = include!("sources/geomutils_pcm");
|
||||
ctx.add_sources("source/geomutils/src/pcm", &sources);
|
||||
|
||||
// sweep
|
||||
let sources = include!("sources/geomutils_sweep");
|
||||
ctx.add_sources("source/geomutils/src/sweep", &sources);
|
||||
}
|
||||
|
||||
fn cooking(ctx: &mut Context) {
|
||||
// root
|
||||
let sources = include!("sources/cooking");
|
||||
ctx.add_sources("source/physxcooking/src", &sources);
|
||||
ctx.add_includes("source/include", &["cooking"]);
|
||||
}
|
||||
|
||||
fn physx(ctx: &mut Context) {
|
||||
// metadata
|
||||
{
|
||||
let sources = ["PxAutoGeneratedMetaDataObjects", "PxMetaDataObjects"];
|
||||
ctx.add_sources("source/physxmetadata/core/src", &sources);
|
||||
ctx.add_includes("source", &["physxmetadata/core/include"]);
|
||||
}
|
||||
|
||||
// immediate mode
|
||||
ctx.builder.file(
|
||||
ctx.root
|
||||
.join("source/immediatemode/src/NpImmediateMode.cpp"),
|
||||
);
|
||||
|
||||
// there's always a "core"
|
||||
let sources = include!("sources/core");
|
||||
ctx.add_sources("source/physx/src", &sources);
|
||||
}
|
||||
|
||||
fn add_common(ctx: &mut Context) {
|
||||
let shared_root = ctx.root.parent().unwrap().join("pxshared");
|
||||
|
||||
let builder = &mut ctx.builder;
|
||||
let ccenv = &ctx.env;
|
||||
let root = &ctx.root;
|
||||
builder.cpp(true);
|
||||
|
||||
// These includes are used by pretty much everything so just add them first
|
||||
if ccenv.target_os == "android" {
|
||||
builder.define("ANDROID", None);
|
||||
let ndk_path = PathBuf::from(
|
||||
env::var("ANDROID_NDK_ROOT")
|
||||
.expect("environment variable \"ANDROID_NDK_ROOT\" has not been set"),
|
||||
);
|
||||
let host_str = ccenv.host.as_str();
|
||||
let ndk_toolchain = match host_str {
|
||||
"x86_64-pc-windows-msvc" => "windows-x86_64",
|
||||
"x86_64-unknown-linux-gnu" => "linux-x86_64",
|
||||
"x86_64-apple-darwin" | "aarch64-apple-darwin" => "darwin-x86_64",
|
||||
_ => panic!(
|
||||
"Host triple {} is unsupported for cross-compilation to Android",
|
||||
host_str
|
||||
),
|
||||
};
|
||||
let sysroot_path = ndk_path
|
||||
.join("toolchains/llvm/prebuilt")
|
||||
.join(ndk_toolchain)
|
||||
.join("sysroot");
|
||||
if !sysroot_path.exists() {
|
||||
panic!(
|
||||
"Can't find Android NDK sysroot path \"{}\"",
|
||||
sysroot_path.to_str().unwrap()
|
||||
);
|
||||
}
|
||||
builder.flag(&format!("--sysroot={}", &sysroot_path.to_str().unwrap()));
|
||||
builder.cpp_link_stdlib("c++");
|
||||
}
|
||||
|
||||
ctx.includes.push(shared_root.join("include"));
|
||||
ctx.includes.extend(
|
||||
[
|
||||
"include",
|
||||
"source/foundation/include",
|
||||
"source/common/src",
|
||||
"source/filebuf/include", // only used by pvd
|
||||
]
|
||||
.iter()
|
||||
.map(|inc| root.join(inc)),
|
||||
);
|
||||
|
||||
// If we're targetting msvc, just silence all the annoying warnings
|
||||
if ccenv.target_env.as_deref() == Some("msvc") {
|
||||
builder
|
||||
.define("_CRT_SECURE_NO_WARNINGS", None)
|
||||
.define("_WINSOCK_DEPRECATED_NO_WARNINGS", None)
|
||||
.define("_ITERATOR_DEBUG_LEVEL", "0");
|
||||
}
|
||||
|
||||
// Always build as a static library
|
||||
builder.define("PX_PHYSX_STATIC_LIB", None);
|
||||
// Always disable GPU features, at least for now
|
||||
builder.define("DISABLE_CUDA_PHYSX", None);
|
||||
|
||||
if ccenv.emit_debug_info {
|
||||
builder.define("PX_DEBUG", None).define("PX_CHECKED", None);
|
||||
}
|
||||
|
||||
builder.define("PX_SUPPORT_PVD", "1");
|
||||
|
||||
if cfg!(feature = "profile") {
|
||||
builder.define("PX_PROFILE", "1");
|
||||
}
|
||||
|
||||
// If we're on linux, we already require clang++ for structgen, for reasons,
|
||||
// so just force clang++ for the normal compile as well...except in the case
|
||||
// where a user has expliclity set CXX....
|
||||
// We _also_ set it explicitly for mac hosts, due to cc-rs's current
|
||||
// compiler detection, as macos uses cc still, but it's actually a symlink
|
||||
// to clang++, but that means that cc rs will by default think the compiler
|
||||
// is gcc
|
||||
if (ccenv.host.contains("-linux-") || ccenv.host == "x86_64-apple-darwin")
|
||||
&& ccenv.target_compiler.is_none()
|
||||
{
|
||||
builder.compiler("clang++");
|
||||
}
|
||||
|
||||
let flags = if builder.get_compiler().is_like_clang() || builder.get_compiler().is_like_gnu() {
|
||||
vec![
|
||||
"-std=c++14",
|
||||
// Disable all warnings
|
||||
"-w",
|
||||
// Many reinterpret_cast tricks in physx break down if we do not disable strict-aliasing
|
||||
"-fno-strict-aliasing",
|
||||
]
|
||||
} else if builder.get_compiler().is_like_msvc() {
|
||||
// Disable defaults since we disagree with cc in some cases, this
|
||||
// means we have to manually set eg profile and debug flags that
|
||||
// would normally be set by default
|
||||
builder.no_default_flags(true);
|
||||
|
||||
// We don't care about logos, but we absolutley care about not having
|
||||
// long compile times
|
||||
let mut flags = vec!["-nologo", "/MP"];
|
||||
|
||||
if ccenv.static_crt {
|
||||
flags.push("/MT");
|
||||
} else {
|
||||
flags.push("/MD");
|
||||
}
|
||||
|
||||
if ccenv.emit_debug_info {
|
||||
flags.push("/Z7");
|
||||
}
|
||||
|
||||
if ccenv.mode.as_str() == "profile" {
|
||||
flags.push("/O2");
|
||||
}
|
||||
|
||||
flags.push("/std:c++14");
|
||||
|
||||
flags
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
for flag in flags {
|
||||
builder.flag(flag);
|
||||
}
|
||||
|
||||
// Physx requires either _DEBUG or NDEBUG be set, fine. Except, NEVER set
|
||||
// _DEBUG on windows, or at least for clang-cl, because it will then think
|
||||
// it should link the debug version of the CRT, which will _never_ work
|
||||
// for rust because rust _always_ links the release version of the CRT
|
||||
// (either static or dynamic depending on the crt-static target feature),
|
||||
// there is some internal code in physx that uses _DEBUG but I don't know
|
||||
// if we will ever actually care. That being said, this is all terrible.
|
||||
builder.define("NDEBUG", "1");
|
||||
|
||||
// cc sets PIC by default for most targets, but if we're compiling with
|
||||
// clang for windows, we need to unset it, as clang (at least as of 9)
|
||||
// doesn't support it
|
||||
if builder.get_compiler().is_like_clang() && ccenv.target_os == "windows" {
|
||||
builder.pic(false);
|
||||
}
|
||||
}
|
||||
|
||||
fn cc_compile(target_env: Environment) {
|
||||
let root = env::current_dir().unwrap().join("physx/physx");
|
||||
|
||||
let ccenv = target_env;
|
||||
|
||||
let mut ctx = Context {
|
||||
builder: cc::Build::new(),
|
||||
root,
|
||||
env: ccenv,
|
||||
includes: Vec::with_capacity(1000),
|
||||
};
|
||||
|
||||
add_common(&mut ctx);
|
||||
|
||||
// Add the sources and includes for each major physx component
|
||||
fastxml(&mut ctx);
|
||||
task(&mut ctx);
|
||||
foundation(&mut ctx);
|
||||
lowlevel(&mut ctx);
|
||||
lowlevelaabb(&mut ctx);
|
||||
lowleveldynamics(&mut ctx);
|
||||
vehicle(&mut ctx);
|
||||
extensions(&mut ctx);
|
||||
physxcharacterkinematic(&mut ctx);
|
||||
common(&mut ctx);
|
||||
geomutils(&mut ctx);
|
||||
cooking(&mut ctx);
|
||||
pvd(&mut ctx);
|
||||
physx(&mut ctx);
|
||||
scenequery(&mut ctx);
|
||||
simulationcontroller(&mut ctx);
|
||||
|
||||
ctx.includes.push(ctx.root.join("source/pvd/include"));
|
||||
|
||||
// Strip out duplicate include paths, C++ already has it hard enough as it is
|
||||
ctx.includes.sort();
|
||||
ctx.includes.dedup();
|
||||
|
||||
for dir in ctx.includes {
|
||||
ctx.builder.include(dir);
|
||||
}
|
||||
|
||||
ctx.builder.compile("physx");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Use the optimization level to determine the build profile to pass, we
|
||||
// don't use cfg!(debug_assertions) here because I'm not sure what happens
|
||||
// with that when build dependencies are configured to be debug and the
|
||||
// actual target is meant to be release, so this seems safer
|
||||
let build_mode = match env::var("OPT_LEVEL")
|
||||
.ok()
|
||||
.and_then(|s| s.parse::<i32>().ok())
|
||||
.unwrap_or(1)
|
||||
{
|
||||
0 => "debug",
|
||||
_ => "profile",
|
||||
};
|
||||
|
||||
let target = env::var("TARGET").expect("TARGET not specified");
|
||||
let host = env::var("HOST").expect("HOST not specified");
|
||||
|
||||
// Acquire the user-specified c++ compiler if one has been set, in the same
|
||||
// order and manner that cc-rs will do it
|
||||
let compiler = {
|
||||
env::var(format!("CXX_{target}"))
|
||||
.or_else(|_| {
|
||||
let target_under = target.replace('-', "_");
|
||||
env::var(format!("CXX_{target_under}"))
|
||||
})
|
||||
.or_else(|_| env::var("TARGET_CXX"))
|
||||
.or_else(|_| env::var("CXX"))
|
||||
.ok()
|
||||
};
|
||||
|
||||
{
|
||||
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("target os not specified");
|
||||
let target_env = env::var("CARGO_CFG_TARGET_ENV").ok();
|
||||
let static_crt = env::var("CARGO_CFG_TARGET_FEATURE")
|
||||
.unwrap_or_default()
|
||||
.contains("crt-static");
|
||||
|
||||
let environment = Environment {
|
||||
emit_debug_info: env::var("DEBUG")
|
||||
.ok()
|
||||
.and_then(|s| s.parse::<bool>().ok())
|
||||
.unwrap_or(false),
|
||||
target_compiler: compiler.clone(),
|
||||
target_os,
|
||||
target_env,
|
||||
mode: build_mode.to_owned(),
|
||||
host: host.clone(),
|
||||
static_crt,
|
||||
};
|
||||
|
||||
cc_compile(environment);
|
||||
}
|
||||
|
||||
let mut cc_builder = cc::Build::new();
|
||||
let physx_cc = cc_builder
|
||||
.cpp(true)
|
||||
.opt_level(3)
|
||||
.debug(false)
|
||||
.use_plt(false)
|
||||
.warnings(false)
|
||||
.extra_warnings(false)
|
||||
.define("NDEBUG", None)
|
||||
.define("PX_PHYSX_STATIC_LIB", None)
|
||||
.include("physx/physx/include")
|
||||
.include("physx/pxshared/include")
|
||||
.include("physx/physx/source/foundation/include");
|
||||
|
||||
if cfg!(feature = "profile") {
|
||||
physx_cc.define("PX_PROFILE", Some("1"));
|
||||
}
|
||||
|
||||
if compiler.is_none() && host.contains("-linux-") {
|
||||
physx_cc.compiler("clang++");
|
||||
}
|
||||
|
||||
physx_cc.flag(if physx_cc.get_compiler().is_like_msvc() {
|
||||
"/std:c++14"
|
||||
} else {
|
||||
"-std=c++14"
|
||||
});
|
||||
|
||||
use std::ffi::OsString;
|
||||
let output_dir_path =
|
||||
PathBuf::from(env::var("OUT_DIR").expect("output directory not specified"));
|
||||
|
||||
let include_path = if env::var("CARGO_FEATURE_STRUCTGEN").is_ok() {
|
||||
let mut structgen_path = output_dir_path.join("structgen");
|
||||
|
||||
// A bit hacky and might not work in all scenarios but qemu-aarch64 is not always
|
||||
// available or even needed. If you are cross compiling to android then you need
|
||||
// to remember to set CXX and CC to the respective toolchain compilers found in
|
||||
// the ANDROID_NDK_ROOT as well.
|
||||
let is_cross_compiling_aarch64 = target != host && target.starts_with("aarch64-");
|
||||
|
||||
let structgen_compiler = physx_cc.get_compiler();
|
||||
let mut cmd = structgen_compiler.to_command();
|
||||
|
||||
if env::var("CARGO_FEATURE_CPP_WARNINGS").is_err() {
|
||||
let dw = if physx_cc.get_compiler().is_like_clang()
|
||||
|| physx_cc.get_compiler().is_like_gnu()
|
||||
{
|
||||
"-w"
|
||||
} else if physx_cc.get_compiler().is_like_msvc() {
|
||||
"/w"
|
||||
} else {
|
||||
panic!("unknown compiler");
|
||||
};
|
||||
|
||||
cmd.arg(dw);
|
||||
}
|
||||
|
||||
if structgen_compiler.is_like_msvc() {
|
||||
let mut s = OsString::from("/Fe");
|
||||
s.push(&structgen_path);
|
||||
cmd.arg(s);
|
||||
|
||||
let mut s = OsString::from("/Fo");
|
||||
s.push(&structgen_path);
|
||||
s.push(".obj");
|
||||
cmd.arg(s);
|
||||
} else {
|
||||
if is_cross_compiling_aarch64 {
|
||||
// statically linking is just much easier to deal
|
||||
// with when using qemu-aarch64
|
||||
cmd.arg("-static");
|
||||
}
|
||||
cmd.arg("-o").arg(&structgen_path);
|
||||
}
|
||||
|
||||
cmd.arg("src/structgen/structgen.cpp");
|
||||
cmd.status().expect("c++ compiler failed to execute");
|
||||
|
||||
// The above status check has been shown to fail, ie, the compiler
|
||||
// fails to output a binary, but reports success anyway
|
||||
if host.contains("-windows-") {
|
||||
structgen_path.set_extension("exe");
|
||||
}
|
||||
|
||||
std::fs::metadata(&structgen_path)
|
||||
.expect("failed to compile structgen even though compiler reported no failures");
|
||||
|
||||
let mut structgen = if is_cross_compiling_aarch64 {
|
||||
let mut structgen = std::process::Command::new("qemu-aarch64");
|
||||
structgen.arg(&structgen_path);
|
||||
structgen
|
||||
} else {
|
||||
std::process::Command::new(&structgen_path)
|
||||
};
|
||||
|
||||
structgen.current_dir(&output_dir_path);
|
||||
structgen.status().expect("structgen failed to execute, if you are cross compiling to aarch64 you need to have qemu-aarch64 installed");
|
||||
|
||||
println!("cargo:rerun-if-changed=src/structgen/structgen.cpp");
|
||||
println!("cargo:rerun-if-changed=src/structgen/structgen.hpp");
|
||||
|
||||
output_dir_path
|
||||
} else {
|
||||
let mut include = PathBuf::from("src/generated");
|
||||
|
||||
if target == "x86_64-pc-windows-msvc" {
|
||||
include.push(target);
|
||||
} else if target.contains("-linux-") || target.ends_with("apple-darwin") {
|
||||
// Note that (currently) the x86_64 and aarch64 structures we bind
|
||||
// are the exact same for linux/android and MacOS (unsure about iOS, but also don't care)
|
||||
include.push("unix");
|
||||
} else {
|
||||
panic!("unknown TARGET triple '{}'", target);
|
||||
}
|
||||
|
||||
include
|
||||
};
|
||||
|
||||
// Disable all warnings. The rationale for this is that end users don't care
|
||||
// and the physx code is incredibly sloppy with warnings since it's mostly
|
||||
// developed on windows
|
||||
if env::var("CARGO_FEATURE_CPP_WARNINGS").is_err() {
|
||||
let dw = if physx_cc.get_compiler().is_like_clang() || physx_cc.get_compiler().is_like_gnu()
|
||||
{
|
||||
"-w"
|
||||
} else if physx_cc.get_compiler().is_like_msvc() {
|
||||
"/w"
|
||||
} else {
|
||||
panic!("unknown compiler");
|
||||
};
|
||||
|
||||
physx_cc.flag(dw);
|
||||
}
|
||||
|
||||
physx_cc
|
||||
.include(include_path)
|
||||
.file("src/physx_api.cpp")
|
||||
.compile("physx_api");
|
||||
|
||||
println!("cargo:rerun-if-changed=src/physx_generated.hpp");
|
||||
println!("cargo:rerun-if-changed=src/physx_generated.rs");
|
||||
println!("cargo:rerun-if-changed=src/physx_api.cpp");
|
||||
|
||||
// TODO: use the cloned git revision number instead
|
||||
println!("cargo:rerun-if-changed=physx/physx/include/foundation/PxPhysicsVersion.h");
|
||||
}
|
||||
110
modules/PhysX/physx/physx-sys/examples/ball.rs
Normal file
110
modules/PhysX/physx/physx-sys/examples/ball.rs
Normal file
@@ -0,0 +1,110 @@
|
||||
use physx_sys::*;
|
||||
use std::ptr::null_mut;
|
||||
|
||||
fn main() {
|
||||
#[allow(unsafe_code)]
|
||||
// SAFETY: It works...but is it safe? :D
|
||||
unsafe {
|
||||
let foundation = physx_create_foundation();
|
||||
let physics = physx_create_physics(foundation);
|
||||
|
||||
let mut scene_desc = PxSceneDesc_new(PxPhysics_getTolerancesScale(physics));
|
||||
scene_desc.gravity = PxVec3 {
|
||||
x: 0.0,
|
||||
y: -9.81,
|
||||
z: 0.0,
|
||||
};
|
||||
|
||||
let dispatcher = phys_PxDefaultCpuDispatcherCreate(
|
||||
1,
|
||||
null_mut(),
|
||||
PxDefaultCpuDispatcherWaitForWorkMode::WaitForWork,
|
||||
0,
|
||||
);
|
||||
scene_desc.cpuDispatcher = dispatcher.cast();
|
||||
scene_desc.filterShader = get_default_simulation_filter_shader();
|
||||
|
||||
let scene = PxPhysics_createScene_mut(physics, &scene_desc);
|
||||
|
||||
let material = PxPhysics_createMaterial_mut(physics, 0.5, 0.5, 0.6);
|
||||
let ground_plane =
|
||||
phys_PxCreatePlane(physics, &PxPlane_new_1(0.0, 1.0, 0.0, 0.0), material);
|
||||
PxScene_addActor_mut(scene, ground_plane.cast(), null_mut());
|
||||
|
||||
let sphere_geo = PxSphereGeometry_new(10.0);
|
||||
let sphere = phys_PxCreateDynamic(
|
||||
physics,
|
||||
&PxTransform_new_1(&PxVec3 {
|
||||
x: 0.0,
|
||||
y: 40.0,
|
||||
z: 100.0,
|
||||
}),
|
||||
(&sphere_geo as *const PxSphereGeometry).cast(),
|
||||
material,
|
||||
10.0,
|
||||
&PxTransform_new_2(PxIDENTITY::PxIdentity),
|
||||
);
|
||||
PxRigidBody_setAngularDamping_mut(sphere.cast(), 0.5);
|
||||
PxScene_addActor_mut(scene, sphere.cast(), null_mut());
|
||||
|
||||
let filter_data = PxQueryFilterData_new();
|
||||
let mut raycast_hits = Vec::new();
|
||||
|
||||
let heights_over_time = (0..100)
|
||||
.map(|_| {
|
||||
PxScene_simulate_mut(scene, 0.1, null_mut(), null_mut(), 0, true);
|
||||
let mut error: u32 = 0;
|
||||
PxScene_fetchResults_mut(scene, true, &mut error);
|
||||
assert!(error == 0, "fetchResults has failed");
|
||||
|
||||
let mut hit = std::mem::MaybeUninit::uninit();
|
||||
|
||||
if physx_sys::PxSceneQueryExt_raycastSingle(
|
||||
scene,
|
||||
&PxVec3 {
|
||||
x: 0.0,
|
||||
y: 100.0,
|
||||
z: 100.0,
|
||||
}, // origin
|
||||
&PxVec3 {
|
||||
x: 0.0,
|
||||
y: -1.0,
|
||||
z: 0.0,
|
||||
}, // dir
|
||||
1000.0, // max distance
|
||||
PxHitFlags::Default,
|
||||
hit.as_mut_ptr(),
|
||||
&filter_data,
|
||||
null_mut(),
|
||||
null_mut(),
|
||||
) {
|
||||
let hit = hit.assume_init();
|
||||
raycast_hits.push(hit);
|
||||
}
|
||||
|
||||
let pose = PxRigidActor_getGlobalPose(sphere.cast());
|
||||
(pose.p.y) as i32 - 10
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let max_h = 18;
|
||||
(0..max_h)
|
||||
.map(|h| {
|
||||
let h = max_h - 1 - h;
|
||||
heights_over_time
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(_t, p)| if h == *p { 'o' } else { ' ' })
|
||||
.collect::<String>()
|
||||
})
|
||||
.for_each(|line| {
|
||||
println!("{line}");
|
||||
});
|
||||
PxScene_release_mut(scene);
|
||||
PxDefaultCpuDispatcher_release_mut(dispatcher);
|
||||
PxPhysics_release_mut(physics);
|
||||
|
||||
for hit in raycast_hits {
|
||||
eprintln!("Raycast hit object {:.02}m away", hit.distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
modules/PhysX/physx/physx-sys/make-sources.sh
Normal file
19
modules/PhysX/physx/physx-sys/make-sources.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# This script finds all of the cpp files in a <directory> and generates a rust
|
||||
# array of strings into physx-sys/sources/<name> that is used by the build script
|
||||
# to compile all of the source files when compiling physx-sys
|
||||
#
|
||||
# usage: make-sources.sh <physx c++ source directory path> <name>
|
||||
dir=$1
|
||||
file="$(dirname "$0")/sources/$2"
|
||||
|
||||
printf "[\n" > "$file"
|
||||
|
||||
for entry in "$dir"/*.cpp
|
||||
do
|
||||
printf " \"%s\",\n" "$(echo "$entry" | sed -r "s/.+\/(.+)\..+/\1/")" >> "$file"
|
||||
done
|
||||
|
||||
printf "]\n" >> "$file"
|
||||
272
modules/PhysX/physx/physx-sys/migration-4-5.md
Normal file
272
modules/PhysX/physx/physx-sys/migration-4-5.md
Normal file
@@ -0,0 +1,272 @@
|
||||
# physx-sys 4.1 -> 5.1 migration guide
|
||||
|
||||
This is a migration guide for the physx-sys crate from the version (0.8.*) that was wrapping PhysX SDK 4.1, and the version (0.10) that transition to PhysX SDK 5.1.3. (see [PR#183] for the PR that actually made a bulk of the transition)
|
||||
|
||||
Note that there is a migration guide from NVidia for the C++ code [here](https://nvidia-omniverse.github.io/PhysX/physx/5.1.3/docs/MigrationTo51.html).
|
||||
|
||||
## General Changes
|
||||
|
||||
### `pxbind`
|
||||
|
||||
The pxbind program, used to query the C++ AST and generate both the FFI binding functions in Rust and their C++ implementation, as well as the structgen program used to generate the POD types used on both sides of the FFI boundary, has been rewritten from C++ to Rust. This was done to get rid of the annoying dependency on libclang and just...not have C++ code that had bitrotted since the original implementation. Transitioning to Rust means it should be easier for contributors to make changes to the binding generation and just iterate on and improve the generated binding code. This change is not directly visible to end users of the crate, it is just mentioned since it makes up a large part of the new code in [PR#183].
|
||||
|
||||
### Enums
|
||||
|
||||
Enums exposed by physx-sys have been changed to be more Rust like. We'll use [`PxShapeFlag`](https://github.com/EmbarkStudios/PhysX-5/blob/main/physx/include/PxShape.h#L62-L119) to illustrate the changes.
|
||||
|
||||
#### Old enum output
|
||||
|
||||
```rust
|
||||
pub mod PxShapeFlag{
|
||||
pub type Enum = u32;
|
||||
pub const eSIMULATION_SHAPE: Enum = 1u64 as u32;
|
||||
pub const eSCENE_QUERY_SHAPE: Enum = 2u64 as u32;
|
||||
pub const eTRIGGER_SHAPE: Enum = 4u64 as u32;
|
||||
pub const eVISUALIZATION: Enum = 8u64 as u32;
|
||||
}
|
||||
```
|
||||
|
||||
#### New enum output
|
||||
|
||||
```rust
|
||||
/// Flags which affect the behavior of PxShapes.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(i32)]
|
||||
pub enum PxShapeFlag {
|
||||
/// The shape will partake in collision in the physical simulation.
|
||||
///
|
||||
/// It is illegal to raise the eSIMULATION_SHAPE and eTRIGGER_SHAPE flags.
|
||||
/// In the event that one of these flags is already raised the sdk will reject any
|
||||
/// attempt to raise the other. To raise the eSIMULATION_SHAPE first ensure that
|
||||
/// eTRIGGER_SHAPE is already lowered.
|
||||
///
|
||||
/// This flag has no effect if simulation is disabled for the corresponding actor (see [`PxActorFlag::eDISABLE_SIMULATION`]).
|
||||
SimulationShape = 1,
|
||||
/// The shape will partake in scene queries (ray casts, overlap tests, sweeps, ...).
|
||||
SceneQueryShape = 2,
|
||||
/// The shape is a trigger which can send reports whenever other shapes enter/leave its volume.
|
||||
///
|
||||
/// Triangle meshes and heightfields can not be triggers. Shape creation will fail in these cases.
|
||||
///
|
||||
/// Shapes marked as triggers do not collide with other objects. If an object should act both
|
||||
/// as a trigger shape and a collision shape then create a rigid body with two shapes, one being a
|
||||
/// trigger shape and the other a collision shape. It is illegal to raise the eTRIGGER_SHAPE and
|
||||
/// eSIMULATION_SHAPE flags on a single PxShape instance. In the event that one of these flags is already
|
||||
/// raised the sdk will reject any attempt to raise the other. To raise the eTRIGGER_SHAPE flag first
|
||||
/// ensure that eSIMULATION_SHAPE flag is already lowered.
|
||||
///
|
||||
/// Trigger shapes will no longer send notification events for interactions with other trigger shapes.
|
||||
///
|
||||
/// Shapes marked as triggers are allowed to participate in scene queries, provided the eSCENE_QUERY_SHAPE flag is set.
|
||||
///
|
||||
/// This flag has no effect if simulation is disabled for the corresponding actor (see [`PxActorFlag::eDISABLE_SIMULATION`]).
|
||||
TriggerShape = 4,
|
||||
/// Enable debug renderer for this shape
|
||||
Visualization = 8,
|
||||
}
|
||||
```
|
||||
|
||||
#### Enum differences
|
||||
|
||||
1. Enums are now regular Rust enums, rather than modules.
|
||||
1. Enum variants now named in `UpperCamelCase` like standard Rust enum variants (minus the `e` suffix)
|
||||
1. Enums now have the documentation for the enum itself, as well as each variant, pulled from the C++ declaration
|
||||
|
||||
#### Migrating enums
|
||||
|
||||
Migrating enums is trivial in most cases as it is just a matter of renaming the variant from the C++ name to the new form. In the case the type itself is used, it's just a matter of removing the `::Enum` from the type.
|
||||
|
||||
```diff
|
||||
PxShape_setFlag_mut(
|
||||
shape,
|
||||
- PxShapeFlag::eVISUALIZATION,
|
||||
+ PxShapeFlag::Visualization,
|
||||
enable_physics_shape_debug_rendering,
|
||||
);
|
||||
|
||||
-fn is_flag_enabled(shape: *const PxShape, flag: PxShapeFlag::Enum) -> bool {
|
||||
+fn is_flag_enabled(shape: *const PxShape, flag: PxShapeFlag) -> bool {
|
||||
```
|
||||
|
||||
One wrinkle with this new form is that converting to and from integer types is not as easy. If this is problematic we can add generation of `From` for 1 or more integer types for enums.
|
||||
|
||||
### Flags
|
||||
|
||||
PhysX uses bitsets fairly heavily in the API, using `PxFlags<_enum_type_, _integer_type_>` to create wrappers for an enum. We'll use [`PxShapeFlags`](https://github.com/EmbarkStudios/PhysX-5/blob/6efb3c60eb7869e8f9d694a674aafb58127b7173/physx/include/PxShape.h#L121-L127), the flags version of `PxShapeFlag`.
|
||||
|
||||
#### Old flags output
|
||||
|
||||
```rust
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct PxShapeFlags{
|
||||
pub mBits: u8,
|
||||
}
|
||||
```
|
||||
|
||||
#### New flags output
|
||||
|
||||
```rust
|
||||
bitflags::bitflags! {
|
||||
/// Flags for [`PxShapeFlag`]
|
||||
#[derive(Default)]
|
||||
#[repr(transparent)]
|
||||
pub struct PxShapeFlags: u8 {
|
||||
const SimulationShape = 1 << 0;
|
||||
const SceneQueryShape = 1 << 1;
|
||||
const TriggerShape = 1 << 2;
|
||||
const Visualization = 1 << 3;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Flags differences
|
||||
|
||||
1. Flags now create a [`bitflags`](https://crates.io/crates/bitflags) backed bitset, using a transparent repr using the same sized integer as in C++, allowing for transparent usage across the FFI boundary.
|
||||
1. Normal bitset operations are now generated by `bitflags`
|
||||
1. As with enums, each flag variant is named in `UpperCamelCase`
|
||||
|
||||
#### Migrating flags
|
||||
|
||||
Since the generated `*Flags` bitset has all of the bitset operations the migrated code should be much cleaner as there is no longer a need to convert to the underlying integer type.
|
||||
|
||||
```diff
|
||||
-let mut shape_flags = PxShapeFlags {
|
||||
- mBits: (PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eVISUALIZATION) as u8,
|
||||
-};
|
||||
+let mut shape_flags = PxShapeFlags::SceneQueryShape | PxShapeFlags::Visualization;
|
||||
|
||||
if config.trigger_volume {
|
||||
- shape_flags.mBits |= PxShapeFlag::eTRIGGER_SHAPE as u8;
|
||||
+ shape_flags |= PxShapeFlags::TriggerShape;
|
||||
} else {
|
||||
- shape_flags.mBits |= PxShapeFlag::eSIMULATION_SHAPE as u8;
|
||||
+ shape_flags |= PxShapeFlags::SimulationShape;
|
||||
}
|
||||
|
||||
PxPhysics_createShape_mut(
|
||||
px_physics.as_mut_ptr(),
|
||||
geom.geometry.as_ptr(),
|
||||
config.material,
|
||||
is_exclusive,
|
||||
shape_flags,
|
||||
)
|
||||
```
|
||||
|
||||
### Structs
|
||||
|
||||
The only difference, other than actual changes in the C++ classes/structs themselves, is that we now expose the `debug-structs` feature, which enables `Debug` to be derived for all of the generated POD structs. This is not enabled by default as the compile time and binary size increases are generally not going to be worthwhile in normal usage.
|
||||
|
||||
```rust
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(feature = "debug-structs", derive(Debug))]
|
||||
#[repr(C)]
|
||||
pub struct PxActorShape {
|
||||
pub actor: *mut PxRigidActor,
|
||||
pub shape: *mut PxShape,
|
||||
}
|
||||
```
|
||||
|
||||
### Functions
|
||||
|
||||
Static methods are now no longer suffixed with `_mut`.
|
||||
|
||||
```diff
|
||||
-fn PxArticulationReducedCoordinate_setSolverIterationCounts_mut();
|
||||
+fn PxArticulationReducedCoordinate_setSolverIterationCounts();
|
||||
```
|
||||
|
||||
All generated Rust functions now include the comments from the C++ code, for convenience.
|
||||
|
||||
```diff
|
||||
-pub fn PxRigidDynamic_getKinematicTarget(self_: *const PxRigidDynamic, target: *mut PxTransform, ) -> bool;
|
||||
+/// Get target pose of a kinematically controlled dynamic actor.
|
||||
+///
|
||||
+/// True if the actor is a kinematically controlled dynamic and the target has been set, else False.
|
||||
+pub fn PxRigidDynamic_getKinematicTarget(self_: *const PxRigidDynamic, target: *mut PxTransform) -> bool;
|
||||
```
|
||||
|
||||
### Other
|
||||
|
||||
One other change of note is that the old pxbind was incorrectly binding `unsigned long long/uint64_t` to `usize`. It is now bound to `u64`. This would also apply to `i64`, but there are no instances of this in the public PhysX API.
|
||||
|
||||
Functions that don't return anything no longer specify the return type as `-> ()`.
|
||||
|
||||
## API Changes
|
||||
|
||||
This section contains API changes in the C++ code that are reflected in the API exposed by this crate. This is **not exhaustive**, as there are frankly too many changes both trivial and large to document here. That being said, please submit PRs to improve this section if you run up against issues when migrating from the 4.1 based crate to the 5.1 based crate that you think make sense to document.
|
||||
|
||||
If you want an exhaustive listing of API changes you can use [cargo public-api](https://crates.io/crates/cargo-public-api)
|
||||
|
||||
```sh
|
||||
cargo install --locked cargo-public-api
|
||||
cd physx-rs/physx-sys
|
||||
cargo public-api --simplified diff 0.8.2
|
||||
```
|
||||
|
||||
It's also recommended to checkout the [PhysX CHANGELOG](https://github.com/EmbarkStudios/PhysX-5/blob/main/physx/CHANGELOG.md) though note that this is **also not exhaustive**!
|
||||
|
||||
### Embark Changes
|
||||
|
||||
While most of the API changes are just reflecting the changes in the underlying C++ code, we've also made a few changes to how we generate bindings.
|
||||
|
||||
- We no longer bind the math functions from `PxMath.h`, there is no functionality there that cannot be done in pure Rust, without crossing the FFI boundary
|
||||
- We no longer bind the functions from `PxString.h`, `PxUtilities.h`, `PxAtomic.h` or `PxHash.h`, these are all APIs that though "public" are really only used inside C++ itself
|
||||
|
||||
### Deprecated
|
||||
|
||||
One major change from the old bindings is that deprecated items (classes/structs/typedefs/enum variants/fields/functions/methods) are now **not generated**. This means some items that were already deprecated in the 4.1 SDK or no longer present, in addition to items that were deprecated in the transition from 4.1 -> 5.1.
|
||||
|
||||
We also abuse the `PX_DEPRECATED` macro to remove items that we intentionally don't expose in this crate, notably some of the new features added in 5.1 like soft bodies and cloth which are only available on NVidia GPUs and whose source is not part of the open source SDK.
|
||||
|
||||
If you were using an API in the former crate that is now deprecated (check [here](https://github.com/search?q=repo%3AEmbarkStudios%2FPhysX-5%20PX_DEPRECATED&type=code)) you can open a [PR](https://github.com/EmbarkStudios/PhysX-5/pulls) to un-deprecate the item (if it makes sense).
|
||||
|
||||
#### Notable Deprecations
|
||||
|
||||
- [**Vehicles**](https://nvidia-omniverse.github.io/PhysX/physx/5.1.3/docs/MigrationTo51.html#vehicles): All of the former Vehicle SDK components were deprecated and replaced with new APIs. These are not bound yet, see [#186](https://github.com/EmbarkStudios/physx-rs/issues/186)
|
||||
- [**PxCooking**](https://nvidia-omniverse.github.io/PhysX/physx/5.1.3/docs/MigrationTo51.html#cooking): Deprecated and replaced with lower level individual functions/classes. This is temporarily [un-deprecated](https://github.com/EmbarkStudios/PhysX-5/commit/5cdbcf6c0ff9c9ff60397c909227243ea0fd8177) but will be replaced later, see [#187](https://github.com/EmbarkStudios/physx-rs/issues/187)
|
||||
- [**Joint Projections**](https://github.com/EmbarkStudios/PhysX-5/blob/main/physx/CHANGELOG.md#deprecated-1): get/setProjectionAngular/LinearTolerance have been deprecated in all joints
|
||||
|
||||
### `PxRefCounted`
|
||||
|
||||
In PhysX 4 many classes had their own `release`, `getReferenceCount` and `acquireReference` methods. These methods have now all been moved to `PxRefCounted`, a new base class in PhysX 5. So now you will use those `PxRefCounted_*` methods instead of the former class methods, casting the pointer to a `PxRefCounted`.
|
||||
|
||||
```diff
|
||||
-PxMaterial_release(material);
|
||||
+PxRefCounted_release(material.cast());
|
||||
```
|
||||
|
||||
- `PxMaterial`
|
||||
- `PxShape`
|
||||
- `PxConvexMesh`
|
||||
- `PxHeightField`
|
||||
- `PxTriangleMesh`
|
||||
|
||||
### Removed
|
||||
|
||||
Several APIs were completely removed, with their functionality either going away, or being absorbed into other classes.
|
||||
|
||||
- `PxArticulationBase` and `PxArticulation` were completely removed, most functionality was moved to `PxArticulationReducedCoordinate`
|
||||
- `PxArticulationJointBase` and `PxArticulationJoint` were completely removed, most functionality was moved to `PxArticulationJointReducedCoordinate`
|
||||
- `PxBatchQueryDesc` has been removed
|
||||
- `PxBatchQueryMemory` has been removed
|
||||
|
||||
### Renamed
|
||||
|
||||
- `PxBVHStructure` was renamed to [`PxBVH`](https://nvidia-omniverse.github.io/PhysX/physx/5.1.3/docs/MigrationTo51.html#pxbvhstructure)
|
||||
- `PxBVHStructureDesc` was renamed to [`PxBVHDesc`](https://nvidia-omniverse.github.io/PhysX/physx/5.1.3/docs/MigrationTo51.html#pxbvhstructure)
|
||||
- `PxPhysicsInsertionCallback` was renamed to [`PxInsertionCallback`](https://nvidia-omniverse.github.io/PhysX/physx/5.1.3/docs/MigrationTo51.html#cooking)
|
||||
|
||||
### Replaced/Moved
|
||||
|
||||
- `PxBatchQuery` has been replaced by [`PxBatchQueryExt`](https://nvidia-omniverse.github.io/PhysX/physx/5.1.3/docs/MigrationTo51.html#scene-queries)
|
||||
- `PxScene` queries have _mostly_ been moved to [`PxSceneQueryExt`](https://github.com/EmbarkStudios/PhysX-5/blob/4d33492253ab64c2246d80257ac4ce0f37b40b22/physx/include/extensions/PxSceneQueryExt.h#L60)
|
||||
- `PxRigidBody_setAngularVelocity_mut` and `PxRigidBody_setLinearVelocity_mut` have been moved to [`PxRigidDynamic`](https://github.com/EmbarkStudios/PhysX-5/blob/main/physx/CHANGELOG.md#changed-3)
|
||||
- Many class constructors have been consolidated, so instead of having, for example, a default constructor and a constructor that takes two `f32` parameters, there will now be single constructor that takes two `f32` parameters, both having default values that used to be set in the default constructor. If you were calling a `_new` function (a wrapper for a constructor) that now fails since the signature is different, you can look at the code to determine what arguments to pass to retain the default constructor behavior.
|
||||
|
||||
```diff
|
||||
-pub fn PxCapsuleGeometry_new() -> PxCapsuleGeometry;
|
||||
+pub fn PxCapsuleGeometry_new(radius_: f32, halfHeight_: f32) -> PxCapsuleGeometry;
|
||||
```
|
||||
|
||||
[PR#183]: https://github.com/EmbarkStudios/physx-rs/pull/183
|
||||
49
modules/PhysX/physx/physx-sys/physx/.github/ISSUE_TEMPLATE/Bug_report.md
vendored
Normal file
49
modules/PhysX/physx/physx-sys/physx/.github/ISSUE_TEMPLATE/Bug_report.md
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report a bug
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
Thanks for taking the time to open an Issue.
|
||||
|
||||
Issues should be used for bug reports.
|
||||
|
||||
If you have a question, please use the GitHub Discussions page or ask in Discord.
|
||||
-->
|
||||
|
||||
### Library and Version
|
||||
|
||||
<!--
|
||||
Example: PhysX v5.1.0
|
||||
-->
|
||||
|
||||
### Operating System
|
||||
|
||||
<!--
|
||||
Example: Windows 10
|
||||
-->
|
||||
|
||||
### Steps to Trigger Behavior
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### Code Snippet to Reproduce Behavior
|
||||
|
||||
```
|
||||
<your-snippet>
|
||||
```
|
||||
|
||||
### Expected Behavior
|
||||
|
||||
<!--
|
||||
Example: Detects collisions
|
||||
-->
|
||||
|
||||
### Actual Behavior
|
||||
|
||||
<!--
|
||||
Example: Some collisions are not detected
|
||||
-->
|
||||
5
modules/PhysX/physx/physx-sys/physx/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
5
modules/PhysX/physx/physx-sys/physx/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<!--
|
||||
Thanks for taking the time to open a Pull Request.
|
||||
|
||||
Please write a bug report in the GitHub Issues if you Pull Request fixes a bug and add a link to the Issue.
|
||||
-->
|
||||
36
modules/PhysX/physx/physx-sys/physx/CONTRIBUTING.md
Normal file
36
modules/PhysX/physx/physx-sys/physx/CONTRIBUTING.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Contributing to PhysX
|
||||
|
||||
## Did you find a bug?
|
||||
|
||||
* Check in the GitHub [Issues](https://github.com/NVIDIA-Omniverse/PhysX/issues) if a report for your bug already exists.
|
||||
* If the bug has not been reported yet, open a new Issue.
|
||||
* Use a short and descriptive title which contains relevant keywords.
|
||||
* Write a clear description of the bug.
|
||||
* Document the environment including your operating system, compiler version, and hardware specifications.
|
||||
* Add code samples and executable test cases with instructions for reproducing the bug.
|
||||
|
||||
## Did you find an issue in the documentation?
|
||||
|
||||
* Please create an [Issue](https://github.com/NVIDIA-Omniverse/PhysX/issues/) if you find a documentation issue.
|
||||
|
||||
## Did you write a bug fix?
|
||||
|
||||
* Open a new [Pull Request](https://github.com/NVIDIA-Omniverse/PhysX/pulls) with your bug fix.
|
||||
* Write a description of the bug which is fixed by your patch or link to related Issues.
|
||||
* If your patch fixes for example Issue #33, write `Fixes #33`.
|
||||
* Explain your solution with a few words.
|
||||
|
||||
## Did you write a cosmetic patch?
|
||||
|
||||
* Patches that are purely cosmetic will not be considered and associated Pull Requests will be closed.
|
||||
* Cosmetic are patches which do not improve stability, performance, functionality, etc.
|
||||
* Examples for cosmetic patches: code formatting, fixing whitespaces.
|
||||
|
||||
## Do you have a question?
|
||||
|
||||
* Search the GitHub [Discussions](https://github.com/NVIDIA-Omniverse/PhysX/discussions/) for your question.
|
||||
* If nobody asked your question before, feel free to open a new discussion.
|
||||
* Once somebody shares a satisfying answer to your question, click "Mark as answer".
|
||||
* GitHub Issues should only be used for bug reports.
|
||||
* If you open an Issue with a question, we may convert it into a discussion.
|
||||
* You can also ask in the NVIDIA Omniverse #physics Discord Channel. Get an invite here: [https://discord.com/invite/XWQNJDNuaC](https://discord.com/invite/XWQNJDNuaC).
|
||||
31
modules/PhysX/physx/physx-sys/physx/LICENSE.md
Normal file
31
modules/PhysX/physx/physx-sys/physx/LICENSE.md
Normal file
@@ -0,0 +1,31 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2023, NVIDIA Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
46
modules/PhysX/physx/physx-sys/physx/README.md
Normal file
46
modules/PhysX/physx/physx-sys/physx/README.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# NVIDIA PhysX
|
||||
|
||||
Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
## Introduction
|
||||
|
||||
This is Embark's fork of PhysX, which is used as the source for the C++ code backing our [Rust wrapper](https://github.com/EmbarkStudios/physx-rs).
|
||||
|
||||
This is a hard fork as the upstream rarely/never accepts PRs, thus we can get rid of all of the junk in the repo that we don't use in our bindings. You probably want to use the official repo if you aren't using our wrapper.
|
||||
|
||||
## Differences from upstream
|
||||
|
||||
### Fixes
|
||||
|
||||
* [x] Compiling for `aarch64-apple-darwin` [actually works](https://github.com/NVIDIA-Omniverse/PhysX/issues/107). This only worked by [accident](https://github.com/EmbarkStudios/PhysX/blob/1689fbd312f447ac933c3c8023516f1fa57a5563/pxshared/include/foundation/PxPreprocessor.h#L110-L113) in PhysX 4.1
|
||||
* [x] Compiling for `aarch64-linux-android` actually works
|
||||
* [x] Cross compiling for `x86_64-pc-windows-msvc` with clang actually works
|
||||
|
||||
### Deprecations
|
||||
|
||||
We abuse the `PX_DEPRECATED` macro to control which items are exposed in our Rust bindings. So various new items like Particles/Cloth/Soft Bodies which are Cuda-only and therefore completely uninteresting to us are marked as deprecated to avoid them.
|
||||
4
modules/PhysX/physx/physx-sys/physx/physx/.gitignore
vendored
Normal file
4
modules/PhysX/physx/physx-sys/physx/physx/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
bin/
|
||||
compiler/linux-*
|
||||
compiler/vc*
|
||||
include/PxConfig.h
|
||||
4335
modules/PhysX/physx/physx-sys/physx/physx/CHANGELOG.md
Normal file
4335
modules/PhysX/physx/physx-sys/physx/physx/CHANGELOG.md
Normal file
File diff suppressed because it is too large
Load Diff
62
modules/PhysX/physx/physx-sys/physx/physx/README.md
Normal file
62
modules/PhysX/physx/physx-sys/physx/physx/README.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# NVIDIA PhysX SDK 5
|
||||
|
||||
Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
## Introduction
|
||||
|
||||
Welcome to the NVIDIA PhysX SDK source code repository.
|
||||
|
||||
The NVIDIA PhysX SDK is a scalable multi-platform physics solution supporting a wide range of devices, from smartphones to high-end multicore CPUs and GPUs. PhysX is already integrated into some of the most popular game engines, including Unreal Engine, and Unity3D. [PhysX SDK on developer.nvidia.com](https://developer.nvidia.com/physx-sdk).
|
||||
|
||||
Please see [Release Notes](./CHANGELOG.md) for updates pertaining to the latest version.
|
||||
|
||||
## User Guide and API Documentation
|
||||
|
||||
The user guide and API documentation are available on [GitHub Pages](https://nvidia-omniverse.github.io/PhysX/physx/index.html). Please create an [Issue](https://github.com/NVIDIA-Omniverse/PhysX/issues/) if you find a documentation issue.
|
||||
|
||||
## Quick Start Instructions
|
||||
|
||||
Platform specific environment and build information can be found in [documentation/platformreadme](./documentation/platformreadme).
|
||||
|
||||
To begin, clone this repository onto your local drive. Then change directory to physx/, run ./generate_projects.[bat|sh] and follow on-screen prompts. This will let you select a platform specific solution to build. You can then build from the generated solution/make file in the platform- and configuration-specific folders in the ``compiler`` folder.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
This depot references packages of third party open source software copyright their respective owners.
|
||||
For copyright details, please refer to the license files included in the packages.
|
||||
|
||||
| Software | Copyright Holder | Package |
|
||||
|---------------------------|-------------------------------------------------------------------------------------|----------------------------------|
|
||||
| CMake | Kitware, Inc. and Contributors | CMakeModules |
|
||||
| FindCUDA | James Bigler: NVIDIA Corp, Abe Stephens: SCI Institute | CMakeModules |
|
||||
| LLVM | University of Illinois at Urbana-Champaign | clang-physxmetadata |
|
||||
| Visual Studio Locator | Microsoft Corporation | VsWhere |
|
||||
| Freeglut | Pawel W. Olszta | freeglut-windows<br>opengl-linux |
|
||||
| Mesa 3-D graphics library | Brian Paul | opengl-linux |
|
||||
| RapidJSON | THL A29 Limited, a Tencent company, and Milo Yip<br>Alexander Chemeris (msinttypes) | rapidjson |
|
||||
| OpenGL Ext Wrangler Lib | Nigel Stewart, Milan Ikits, Marcelo E. Magallon, Lev Povalahev | [SDK_ROOT]/snippets/graphics |
|
||||
33
modules/PhysX/physx/physx-sys/physx/physx/dependencies.xml
Normal file
33
modules/PhysX/physx/physx-sys/physx/physx/dependencies.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<project toolsVersion="6.4">
|
||||
<dependency name="CMakeModules">
|
||||
<package name="CMakeModules" version="1.28.trunk.32494385" /> <!-- default -->
|
||||
</dependency>
|
||||
|
||||
<dependency name="clangMetadata" tags="requiredForDistro requiredForMetaGen">
|
||||
<package name="clang-physxmetadata" version="4.0.0.32489833_1"/>
|
||||
</dependency>
|
||||
|
||||
<dependency name="vswhere">
|
||||
<package name="VsWhere" version="2.7.3111.17308_1.0" platforms="vc15win64 vc16win64 vc17win64 linux-crosscompile linux-aarch64-crosscompile "/>
|
||||
</dependency>
|
||||
|
||||
<dependency name="PhysXDevice">
|
||||
<package name="PhysXDevice" version="18.12.7.4" platforms="vc15win64 vc16win64 vc17win64"/>
|
||||
</dependency>
|
||||
|
||||
<dependency name="freeglut">
|
||||
<package name="freeglut-windows" version="3.4_1.1" platforms="vc15win64 vc16win64 vc17win64"/>
|
||||
</dependency>
|
||||
|
||||
<dependency name="PhysXGpu">
|
||||
<package name="PhysXGpu" version="104.2-5.1.264.32487460-public" platforms="vc15win64 vc16win64 vc17win64 linux linux-aarch64"/>
|
||||
</dependency>
|
||||
|
||||
<dependency name="opengllinux" tags="requiredForDistro">
|
||||
<package name="opengl-linux" version="2017.5.19.1" platforms="linux"/>
|
||||
</dependency>
|
||||
|
||||
<dependency name="rapidjson">
|
||||
<package name="rapidjson" version="1.1.0-67fac85-073453e1" />
|
||||
</dependency>
|
||||
</project>
|
||||
378
modules/PhysX/physx/physx-sys/physx/physx/include/PxActor.h
Normal file
378
modules/PhysX/physx/physx-sys/physx/physx/include/PxActor.h
Normal file
@@ -0,0 +1,378 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_ACTOR_H
|
||||
#define PX_ACTOR_H
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxBounds3.h"
|
||||
#include "PxClient.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxRigidActor;
|
||||
class PxRigidBody;
|
||||
class PxRigidStatic;
|
||||
class PxRigidDynamic;
|
||||
class PxArticulationLink;
|
||||
class PxScene;
|
||||
|
||||
/**
|
||||
\brief Group index which allows to specify 1- or 2-way interaction
|
||||
*/
|
||||
typedef PxU8 PxDominanceGroup; // Must be < 32, PxU8.
|
||||
|
||||
/**
|
||||
\brief Flags which control the behavior of an actor.
|
||||
|
||||
@see PxActorFlags PxActor PxActor.setActorFlag() PxActor.getActorFlags()
|
||||
*/
|
||||
struct PxActorFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief Enable debug renderer for this actor
|
||||
|
||||
@see PxScene.getRenderBuffer() PxRenderBuffer PxVisualizationParameter
|
||||
*/
|
||||
eVISUALIZATION = (1<<0),
|
||||
|
||||
/**
|
||||
\brief Disables scene gravity for this actor
|
||||
*/
|
||||
eDISABLE_GRAVITY = (1<<1),
|
||||
|
||||
/**
|
||||
\brief Enables the sending of PxSimulationEventCallback::onWake() and PxSimulationEventCallback::onSleep() notify events
|
||||
|
||||
@see PxSimulationEventCallback::onWake() PxSimulationEventCallback::onSleep()
|
||||
*/
|
||||
eSEND_SLEEP_NOTIFIES = (1<<2),
|
||||
|
||||
/**
|
||||
\brief Disables simulation for the actor.
|
||||
|
||||
\note This is only supported by PxRigidStatic and PxRigidDynamic actors and can be used to reduce the memory footprint when rigid actors are
|
||||
used for scene queries only.
|
||||
|
||||
\note Setting this flag will remove all constraints attached to the actor from the scene.
|
||||
|
||||
\note If this flag is set, the following calls are forbidden:
|
||||
\li PxRigidBody: setLinearVelocity(), setAngularVelocity(), addForce(), addTorque(), clearForce(), clearTorque(), setForceAndTorque()
|
||||
\li PxRigidDynamic: setKinematicTarget(), setWakeCounter(), wakeUp(), putToSleep()
|
||||
|
||||
\par <b>Sleeping:</b>
|
||||
Raising this flag will set all velocities and the wake counter to 0, clear all forces, clear the kinematic target, put the actor
|
||||
to sleep and wake up all touching actors from the previous frame.
|
||||
*/
|
||||
eDISABLE_SIMULATION = (1<<3)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxActorFlag.
|
||||
|
||||
@see PxActorFlag
|
||||
*/
|
||||
typedef PxFlags<PxActorFlag::Enum,PxU8> PxActorFlags;
|
||||
PX_FLAGS_OPERATORS(PxActorFlag::Enum,PxU8)
|
||||
|
||||
/**
|
||||
\brief Identifies each type of actor.
|
||||
@see PxActor
|
||||
*/
|
||||
struct PxActorType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief A static rigid body
|
||||
@see PxRigidStatic
|
||||
*/
|
||||
eRIGID_STATIC,
|
||||
|
||||
/**
|
||||
\brief A dynamic rigid body
|
||||
@see PxRigidDynamic
|
||||
*/
|
||||
eRIGID_DYNAMIC,
|
||||
|
||||
/**
|
||||
\brief An articulation link
|
||||
@see PxArticulationLink
|
||||
*/
|
||||
eARTICULATION_LINK,
|
||||
|
||||
/**
|
||||
\brief A FEM-based soft body
|
||||
@see PxSoftBody
|
||||
*/
|
||||
eSOFTBODY PX_DEPRECATED,
|
||||
|
||||
/**
|
||||
\brief A FEM-based cloth
|
||||
\note In development
|
||||
@see PxFEMCloth
|
||||
*/
|
||||
eFEMCLOTH PX_DEPRECATED,
|
||||
|
||||
/**
|
||||
\brief A PBD ParticleSystem
|
||||
@see PxPBDParticleSystem
|
||||
*/
|
||||
ePBD_PARTICLESYSTEM PX_DEPRECATED,
|
||||
|
||||
/**
|
||||
\brief A FLIP ParticleSystem
|
||||
\note In development
|
||||
@see PxFLIPParticleSystem
|
||||
*/
|
||||
eFLIP_PARTICLESYSTEM PX_DEPRECATED,
|
||||
|
||||
/**
|
||||
\brief A MPM ParticleSystem
|
||||
\note In development
|
||||
@see PxMPMParticleSystem
|
||||
*/
|
||||
eMPM_PARTICLESYSTEM PX_DEPRECATED,
|
||||
|
||||
/**
|
||||
\brief A CUSTOM ParticleSystem
|
||||
\note In development
|
||||
@see PxCUSTOMParticleSystem
|
||||
*/
|
||||
eCUSTOM_PARTICLESYSTEM PX_DEPRECATED,
|
||||
|
||||
/**
|
||||
\brief A HairSystem
|
||||
\note In development
|
||||
@see PxHairSystem
|
||||
*/
|
||||
eHAIRSYSTEM PX_DEPRECATED,
|
||||
|
||||
//! \brief internal use only!
|
||||
eACTOR_COUNT PX_DEPRECATED,
|
||||
|
||||
//! \brief internal use only!
|
||||
eACTOR_FORCE_DWORD PX_DEPRECATED = 0x7fffffff
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief PxActor is the base class for the main simulation objects in the physics SDK.
|
||||
|
||||
The actor is owned by and contained in a PxScene.
|
||||
*/
|
||||
class PxActor : public PxBase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Deletes the actor.
|
||||
|
||||
Do not keep a reference to the deleted instance.
|
||||
|
||||
If the actor belongs to a #PxAggregate object, it is automatically removed from the aggregate.
|
||||
|
||||
@see PxBase.release(), PxAggregate
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the type of actor.
|
||||
|
||||
\return The actor type of the actor.
|
||||
|
||||
@see PxActorType
|
||||
*/
|
||||
virtual PxActorType::Enum getType() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the scene which this actor belongs to.
|
||||
|
||||
\return Owner Scene. NULL if not part of a scene.
|
||||
|
||||
@see PxScene
|
||||
*/
|
||||
virtual PxScene* getScene() const = 0;
|
||||
|
||||
// Runtime modifications
|
||||
|
||||
/**
|
||||
\brief Sets a name string for the object that can be retrieved with getName().
|
||||
|
||||
This is for debugging and is not used by the SDK. The string is not copied by the SDK,
|
||||
only the pointer is stored.
|
||||
|
||||
\param[in] name String to set the objects name to.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
|
||||
@see getName()
|
||||
*/
|
||||
virtual void setName(const char* name) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the name string set with setName().
|
||||
|
||||
\return Name string associated with object.
|
||||
|
||||
@see setName()
|
||||
*/
|
||||
virtual const char* getName() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the axis aligned bounding box enclosing the actor.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running (except during PxScene::collide(),
|
||||
in PxContactModifyCallback or in contact report callbacks).
|
||||
|
||||
\param[in] inflation Scale factor for computed world bounds. Box extents are multiplied by this value.
|
||||
|
||||
\return The actor's bounding box.
|
||||
|
||||
@see PxBounds3
|
||||
*/
|
||||
virtual PxBounds3 getWorldBounds(float inflation=1.01f) const = 0;
|
||||
|
||||
/**
|
||||
\brief Raises or clears a particular actor flag.
|
||||
|
||||
See the list of flags #PxActorFlag
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
|
||||
|
||||
\param[in] flag The PxActor flag to raise(set) or clear. See #PxActorFlag.
|
||||
\param[in] value The boolean value to assign to the flag.
|
||||
|
||||
@see PxActorFlag getActorFlags()
|
||||
*/
|
||||
virtual void setActorFlag(PxActorFlag::Enum flag, bool value) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the actor flags.
|
||||
|
||||
See the list of flags #PxActorFlag
|
||||
@see PxActorFlag setActorFlag()
|
||||
*/
|
||||
virtual void setActorFlags( PxActorFlags inFlags ) = 0;
|
||||
|
||||
/**
|
||||
\brief Reads the PxActor flags.
|
||||
|
||||
See the list of flags #PxActorFlag
|
||||
|
||||
\return The values of the PxActor flags.
|
||||
|
||||
@see PxActorFlag setActorFlag()
|
||||
*/
|
||||
virtual PxActorFlags getActorFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Assigns dynamic actors a dominance group identifier.
|
||||
|
||||
PxDominanceGroup is a 5 bit group identifier (legal range from 0 to 31).
|
||||
|
||||
The PxScene::setDominanceGroupPair() lets you set certain behaviors for pairs of dominance groups.
|
||||
By default every dynamic actor is created in group 0.
|
||||
|
||||
<b>Default:</b> 0
|
||||
|
||||
<b>Sleeping:</b> Changing the dominance group does <b>NOT</b> wake the actor up automatically.
|
||||
|
||||
\param[in] dominanceGroup The dominance group identifier. <b>Range:</b> [0..31]
|
||||
|
||||
@see getDominanceGroup() PxDominanceGroup PxScene::setDominanceGroupPair()
|
||||
*/
|
||||
virtual void setDominanceGroup(PxDominanceGroup dominanceGroup) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the value set with setDominanceGroup().
|
||||
|
||||
\return The dominance group of this actor.
|
||||
|
||||
@see setDominanceGroup() PxDominanceGroup PxScene::setDominanceGroupPair()
|
||||
*/
|
||||
virtual PxDominanceGroup getDominanceGroup() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets the owner client of an actor.
|
||||
|
||||
This cannot be done once the actor has been placed into a scene.
|
||||
|
||||
<b>Default:</b> PX_DEFAULT_CLIENT
|
||||
|
||||
@see PxClientID PxScene::createClient()
|
||||
*/
|
||||
virtual void setOwnerClient( PxClientID inClient ) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the owner client that was specified at creation time.
|
||||
|
||||
This value cannot be changed once the object is placed into the scene.
|
||||
|
||||
@see PxClientID PxScene::createClient()
|
||||
*/
|
||||
virtual PxClientID getOwnerClient() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the aggregate the actor might be a part of.
|
||||
|
||||
\return The aggregate the actor is a part of, or NULL if the actor does not belong to an aggregate.
|
||||
|
||||
@see PxAggregate
|
||||
*/
|
||||
virtual PxAggregate* getAggregate() const = 0;
|
||||
|
||||
//public variables:
|
||||
void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
|
||||
protected:
|
||||
PX_INLINE PxActor(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
|
||||
PX_INLINE PxActor(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
virtual ~PxActor() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxActor", name) || PxBase::isKindOf(name); }
|
||||
|
||||
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
111
modules/PhysX/physx/physx-sys/physx/physx/include/PxActorData.h
Normal file
111
modules/PhysX/physx/physx-sys/physx/physx/include/PxActorData.h
Normal file
@@ -0,0 +1,111 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
|
||||
#ifndef PX_ACTOR_DATA_H
|
||||
#define PX_ACTOR_DATA_H
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "foundation/PxVec4.h"
|
||||
#include "foundation/PxQuat.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "PxNodeIndex.h"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Identifies each type of information for retrieving from actor.
|
||||
@see PxScene::applyActorData
|
||||
*/
|
||||
struct PxActorCacheFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eACTOR_DATA = (1 << 0), //include transform and velocity
|
||||
eFORCE = (1 << 2),
|
||||
eTORQUE = (1 << 3)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Collection of set bits defined in PxActorCacheFlag.
|
||||
|
||||
@see PxActorCacheFlag
|
||||
*/
|
||||
typedef PxFlags<PxActorCacheFlag::Enum, PxU16> PxActorCacheFlags;
|
||||
PX_FLAGS_OPERATORS(PxActorCacheFlag::Enum, PxU16)
|
||||
|
||||
/**
|
||||
\brief State of a body used when interfacing with the GPU rigid body pipeline
|
||||
@see PxScene.copyBodyData()
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxGpuBodyData
|
||||
{
|
||||
PxQuat quat; /*!< actor global pose quaternion in world frame */
|
||||
PxVec4 pos; /*!< (x,y,z members): actor global pose position in world frame */
|
||||
PxVec4 linVel; /*!< (x,y,z members): linear velocity at center of gravity in world frame */
|
||||
PxVec4 angVel; /*!< (x,y,z members): angular velocity in world frame */
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief Pair correspondence used for matching array indices with body node indices
|
||||
*/
|
||||
PX_ALIGN_PREFIX(8)
|
||||
struct PxGpuActorPair
|
||||
{
|
||||
PxU32 srcIndex; //Defines which index in src array we read
|
||||
PxNodeIndex nodeIndex; //Defines which actor this entry in src array is updating
|
||||
}
|
||||
PX_ALIGN_SUFFIX(8);
|
||||
|
||||
/**
|
||||
\brief Maps numeric index to a data pointer.
|
||||
|
||||
@see PxScene::computeDenseJacobians(), PxScene::computeGeneralizedMassMatrices(), PxScene::computeGeneralizedGravityForces(), PxScene::computeCoriolisAndCentrifugalForces()
|
||||
*/
|
||||
struct PxIndexDataPair
|
||||
{
|
||||
PxU32 index;
|
||||
void* data;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
254
modules/PhysX/physx/physx-sys/physx/physx/include/PxAggregate.h
Normal file
254
modules/PhysX/physx/physx-sys/physx/physx/include/PxAggregate.h
Normal file
@@ -0,0 +1,254 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_AGGREGATE_H
|
||||
#define PX_AGGREGATE_H
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxActor;
|
||||
class PxBVH;
|
||||
class PxScene;
|
||||
|
||||
struct PxAggregateType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eGENERIC = 0, //!< Aggregate will contain various actors of unspecified types
|
||||
eSTATIC = 1, //!< Aggregate will only contain static actors
|
||||
eKINEMATIC = 2 //!< Aggregate will only contain kinematic actors
|
||||
};
|
||||
};
|
||||
|
||||
// PxAggregateFilterHint is used for more efficient filtering of aggregates outside of the broadphase.
|
||||
// It is a combination of a PxAggregateType and a self-collision bit.
|
||||
typedef PxU32 PxAggregateFilterHint;
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAggregateFilterHint PxGetAggregateFilterHint(PxAggregateType::Enum type, bool enableSelfCollision)
|
||||
{
|
||||
const PxU32 selfCollisionBit = enableSelfCollision ? 1 : 0;
|
||||
return PxAggregateFilterHint((PxU32(type)<<1)|selfCollisionBit);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 PxGetAggregateSelfCollisionBit(PxAggregateFilterHint hint)
|
||||
{
|
||||
return hint & 1;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAggregateType::Enum PxGetAggregateType(PxAggregateFilterHint hint)
|
||||
{
|
||||
return PxAggregateType::Enum(hint>>1);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Class to aggregate actors into a single broad-phase entry.
|
||||
|
||||
A PxAggregate object is a collection of PxActors, which will exist as a single entry in the
|
||||
broad-phase structures. This has 3 main benefits:
|
||||
|
||||
1) it reduces "broad phase pollution" by allowing a collection of spatially coherent broad-phase
|
||||
entries to be replaced by a single aggregated entry (e.g. a ragdoll or a single actor with a
|
||||
large number of attached shapes).
|
||||
|
||||
2) it reduces broad-phase memory usage
|
||||
|
||||
3) filtering can be optimized a lot if self-collisions within an aggregate are not needed. For
|
||||
example if you don't need collisions between ragdoll bones, it's faster to simply disable
|
||||
filtering once and for all, for the aggregate containing the ragdoll, rather than filtering
|
||||
out each bone-bone collision in the filter shader.
|
||||
|
||||
@see PxActor, PxPhysics.createAggregate
|
||||
*/
|
||||
class PxAggregate : public PxBase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Deletes the aggregate object.
|
||||
|
||||
Deleting the PxAggregate object does not delete the aggregated actors. If the PxAggregate object
|
||||
belongs to a scene, the aggregated actors are automatically re-inserted in that scene. If you intend
|
||||
to delete both the PxAggregate and its actors, it is best to release the actors first, then release
|
||||
the PxAggregate when it is empty.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Adds an actor to the aggregate object.
|
||||
|
||||
A warning is output if the total number of actors is reached, or if the incoming actor already belongs
|
||||
to an aggregate.
|
||||
|
||||
If the aggregate belongs to a scene, adding an actor to the aggregate also adds the actor to that scene.
|
||||
|
||||
If the actor already belongs to a scene, a warning is output and the call is ignored. You need to remove
|
||||
the actor from the scene first, before adding it to the aggregate.
|
||||
|
||||
\note When a BVH is provided the actor shapes are grouped together.
|
||||
The scene query pruning structure inside PhysX SDK will store/update one
|
||||
bound per actor. The scene queries against such an actor will query actor
|
||||
bounds and then make a local space query against the provided BVH, which is in actor's local space.
|
||||
|
||||
\param [in] actor The actor that should be added to the aggregate
|
||||
\param [in] bvh BVH for actor shapes.
|
||||
return true if success
|
||||
*/
|
||||
virtual bool addActor(PxActor& actor, const PxBVH* bvh = NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes an actor from the aggregate object.
|
||||
|
||||
A warning is output if the incoming actor does not belong to the aggregate. Otherwise the actor is
|
||||
removed from the aggregate. If the aggregate belongs to a scene, the actor is reinserted in that
|
||||
scene. If you intend to delete the actor, it is best to call #PxActor::release() directly. That way
|
||||
the actor will be automatically removed from its aggregate (if any) and not reinserted in a scene.
|
||||
|
||||
\param [in] actor The actor that should be removed from the aggregate
|
||||
return true if success
|
||||
*/
|
||||
virtual bool removeActor(PxActor& actor) = 0;
|
||||
|
||||
/**
|
||||
\brief Adds an articulation to the aggregate object.
|
||||
|
||||
A warning is output if the total number of actors is reached (every articulation link counts as an actor),
|
||||
or if the incoming articulation already belongs to an aggregate.
|
||||
|
||||
If the aggregate belongs to a scene, adding an articulation to the aggregate also adds the articulation to that scene.
|
||||
|
||||
If the articulation already belongs to a scene, a warning is output and the call is ignored. You need to remove
|
||||
the articulation from the scene first, before adding it to the aggregate.
|
||||
|
||||
\param [in] articulation The articulation that should be added to the aggregate
|
||||
return true if success
|
||||
*/
|
||||
virtual bool addArticulation(PxArticulationReducedCoordinate& articulation) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes an articulation from the aggregate object.
|
||||
|
||||
A warning is output if the incoming articulation does not belong to the aggregate. Otherwise the articulation is
|
||||
removed from the aggregate. If the aggregate belongs to a scene, the articulation is reinserted in that
|
||||
scene. If you intend to delete the articulation, it is best to call #PxArticulationReducedCoordinate::release() directly. That way
|
||||
the articulation will be automatically removed from its aggregate (if any) and not reinserted in a scene.
|
||||
|
||||
\param [in] articulation The articulation that should be removed from the aggregate
|
||||
return true if success
|
||||
*/
|
||||
virtual bool removeArticulation(PxArticulationReducedCoordinate& articulation) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of actors contained in the aggregate.
|
||||
|
||||
You can use #getActors() to retrieve the actor pointers.
|
||||
|
||||
\return Number of actors contained in the aggregate.
|
||||
|
||||
@see PxActor getActors()
|
||||
*/
|
||||
virtual PxU32 getNbActors() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves max amount of actors that can be contained in the aggregate.
|
||||
|
||||
\note PxAggregate now supports an arbitrary number of actors. This method return PX_MAX_U32 and will be
|
||||
removed in a future release.
|
||||
|
||||
\return Max actor size.
|
||||
|
||||
@see PxPhysics::createAggregate()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED virtual PxU32 getMaxNbActors() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves max amount of shapes that can be contained in the aggregate.
|
||||
|
||||
\return Max shape size.
|
||||
|
||||
@see PxPhysics::createAggregate()
|
||||
*/
|
||||
virtual PxU32 getMaxNbShapes() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve all actors contained in the aggregate.
|
||||
|
||||
You can retrieve the number of actor pointers by calling #getNbActors()
|
||||
|
||||
\param[out] userBuffer The buffer to store the actor pointers.
|
||||
\param[in] bufferSize Size of provided user buffer.
|
||||
\param[in] startIndex Index of first actor pointer to be retrieved
|
||||
\return Number of actor pointers written to the buffer.
|
||||
|
||||
@see PxShape getNbShapes()
|
||||
*/
|
||||
virtual PxU32 getActors(PxActor** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the scene which this aggregate belongs to.
|
||||
|
||||
\return Owner Scene. NULL if not part of a scene.
|
||||
|
||||
@see PxScene
|
||||
*/
|
||||
virtual PxScene* getScene() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves aggregate's self-collision flag.
|
||||
|
||||
\return self-collision flag
|
||||
*/
|
||||
virtual bool getSelfCollision() const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxAggregate"; }
|
||||
|
||||
void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
|
||||
protected:
|
||||
PX_INLINE PxAggregate(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
|
||||
PX_INLINE PxAggregate(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
virtual ~PxAggregate() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxAggregate", name) || PxBase::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,106 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_ARTICULATION_FLAG_H
|
||||
#define PX_ARTICULATION_FLAG_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A description of the types of articulation data that may be directly written to and read from the GPU using the functions
|
||||
PxScene::copyArticulationData() and PxScene::applyArticulationData(). Types that are read-only may only be used in conjunction with
|
||||
PxScene::copyArticulationData(). Types that are write-only may only be used in conjunction with PxScene::applyArticulationData().
|
||||
A subset of data types may be used in conjunction with both PxScene::applyArticulationData() and PxScene::applyArticulationData().
|
||||
|
||||
@see PxArticulationCache, PxScene::copyArticulationData(), PxScene::applyArticulationData()
|
||||
*/
|
||||
class PxArticulationGpuDataType
|
||||
{
|
||||
public:
|
||||
enum Enum
|
||||
{
|
||||
eJOINT_POSITION = 0, //!< The joint positions, read and write, see PxScene::copyArticulationData(), PxScene::applyArticulationData()
|
||||
eJOINT_VELOCITY, //!< The joint velocities, read and write, see PxScene::copyArticulationData(), PxScene::applyArticulationData()
|
||||
eJOINT_ACCELERATION, //!< The joint accelerations, read only, see PxScene::copyArticulationData()
|
||||
eJOINT_FORCE, //!< The applied joint forces, write only, see PxScene::applyArticulationData()
|
||||
eJOINT_SOLVER_FORCE, //!< The computed joint constraint solver forces, read only, see PxScene::copyArticulationData()()
|
||||
eJOINT_TARGET_VELOCITY, //!< The velocity targets for the joint drives, write only, see PxScene::applyArticulationData()
|
||||
eJOINT_TARGET_POSITION, //!< The position targets for the joint drives, write only, see PxScene::applyArticulationData()
|
||||
eSENSOR_FORCE, //!< The spatial sensor forces, read only, see PxScene::copyArticulationData()
|
||||
eROOT_TRANSFORM, //!< The root link transform, read and write, see PxScene::copyArticulationData(), PxScene::applyArticulationData()
|
||||
eROOT_VELOCITY, //!< The root link velocity, read and write, see PxScene::copyArticulationData(), PxScene::applyArticulationData()
|
||||
eLINK_TRANSFORM, //!< The link transforms including root link, read only, see PxScene::copyArticulationData()
|
||||
eLINK_VELOCITY, //!< The link velocities including root link, read only, see PxScene::copyArticulationData()
|
||||
eLINK_FORCE, //!< The forces to apply to links, write only, see PxScene::applyArticulationData()
|
||||
eLINK_TORQUE, //!< The torques to apply to links, write only, see PxScene::applyArticulationData()
|
||||
eFIXED_TENDON, //!< Fixed tendon data, write only, see PxScene::applyArticulationData()
|
||||
eFIXED_TENDON_JOINT, //!< Fixed tendon joint data, write only, see PxScene::applyArticulationData()
|
||||
eSPATIAL_TENDON, //!< Spatial tendon data, write only, see PxScene::applyArticulationData()
|
||||
eSPATIAL_TENDON_ATTACHMENT //!< Spatial tendon attachment data, write only, see PxScene::applyArticulationData()
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief These flags determine what data is read or written to the internal articulation data via cache.
|
||||
|
||||
@see PxArticulationCache PxArticulationReducedCoordinate::copyInternalStateToCache PxArticulationReducedCoordinate::applyCache
|
||||
*/
|
||||
class PxArticulationCacheFlag
|
||||
{
|
||||
public:
|
||||
enum Enum
|
||||
{
|
||||
eVELOCITY = (1 << 0), //!< The joint velocities, see PxArticulationCache::jointVelocity.
|
||||
eACCELERATION = (1 << 1), //!< The joint accelerations, see PxArticulationCache::jointAcceleration.
|
||||
ePOSITION = (1 << 2), //!< The joint positions, see PxArticulationCache::jointPosition.
|
||||
eFORCE = (1 << 3), //!< The joint forces, see PxArticulationCache::jointForce.
|
||||
eLINK_VELOCITY = (1 << 4), //!< The link velocities, see PxArticulationCache::linkVelocity.
|
||||
eLINK_ACCELERATION = (1 << 5), //!< The link accelerations, see PxArticulationCache::linkAcceleration.
|
||||
eROOT_TRANSFORM = (1 << 6), //!< Root link transform, see PxArticulationCache::rootLinkData.
|
||||
eROOT_VELOCITIES = (1 << 7), //!< Root link velocities (read/write) and accelerations (read), see PxArticulationCache::rootLinkData.
|
||||
eSENSOR_FORCES = (1 << 8), //!< The spatial sensor forces, see PxArticulationCache::sensorForces.
|
||||
eJOINT_SOLVER_FORCES = (1 << 9), //!< Solver constraint joint forces, see PxArticulationCache::jointSolverForces.
|
||||
eALL = (eVELOCITY | eACCELERATION | ePOSITION | eLINK_VELOCITY | eLINK_ACCELERATION | eROOT_TRANSFORM | eROOT_VELOCITIES)
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxArticulationCacheFlag::Enum, PxU32> PxArticulationCacheFlags;
|
||||
PX_FLAGS_OPERATORS(PxArticulationCacheFlag::Enum, PxU32)
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,528 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_ARTICULATION_JOINT_RC_H
|
||||
#define PX_ARTICULATION_JOINT_RC_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
#include "solver/PxSolverDefs.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A joint between two links in an articulation.
|
||||
|
||||
@see PxArticulationReducedCoordinate, PxArticulationLink
|
||||
*/
|
||||
class PxArticulationJointReducedCoordinate : public PxBase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Gets the parent articulation link of this joint.
|
||||
|
||||
\return The parent link.
|
||||
*/
|
||||
virtual PxArticulationLink& getParentArticulationLink() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint pose in the parent link actor frame.
|
||||
|
||||
\param[in] pose The joint pose.
|
||||
<b>Default:</b> The identity transform.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
@see getParentPose
|
||||
*/
|
||||
virtual void setParentPose(const PxTransform& pose) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the joint pose in the parent link actor frame.
|
||||
|
||||
\return The joint pose.
|
||||
|
||||
@see setParentPose
|
||||
*/
|
||||
virtual PxTransform getParentPose() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the child articulation link of this joint.
|
||||
|
||||
\return The child link.
|
||||
*/
|
||||
virtual PxArticulationLink& getChildArticulationLink() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint pose in the child link actor frame.
|
||||
|
||||
\param[in] pose The joint pose.
|
||||
<b>Default:</b> The identity transform.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
@see getChildPose
|
||||
*/
|
||||
virtual void setChildPose(const PxTransform& pose) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the joint pose in the child link actor frame.
|
||||
|
||||
\return The joint pose.
|
||||
|
||||
@see setChildPose
|
||||
*/
|
||||
virtual PxTransform getChildPose() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint type (e.g. revolute).
|
||||
|
||||
\param[in] jointType The joint type to set.
|
||||
|
||||
\note Setting the joint type is not allowed while the articulation is in a scene.
|
||||
In order to set the joint type, remove and then re-add the articulation to the scene.
|
||||
|
||||
@see PxArticulationJointType, getJointType
|
||||
*/
|
||||
virtual void setJointType(PxArticulationJointType::Enum jointType) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the joint type.
|
||||
|
||||
\return The joint type.
|
||||
|
||||
@see PxArticulationJointType, setJointType
|
||||
*/
|
||||
virtual PxArticulationJointType::Enum getJointType() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint motion for a given axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] motion The motion type to set.
|
||||
|
||||
\note Setting the motion of joint axes is not allowed while the articulation is in a scene.
|
||||
In order to set the motion, remove and then re-add the articulation to the scene.
|
||||
|
||||
@see PxArticulationAxis, PxArticulationMotion, getMotion
|
||||
*/
|
||||
virtual void setMotion(PxArticulationAxis::Enum axis, PxArticulationMotion::Enum motion) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the joint motion for the given axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
|
||||
\return The joint motion of the given axis.
|
||||
|
||||
@see PxArticulationAxis, PxArticulationMotion, setMotion
|
||||
*/
|
||||
virtual PxArticulationMotion::Enum getMotion(PxArticulationAxis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint limits for a given axis.
|
||||
|
||||
- The motion of the corresponding axis should be set to PxArticulationMotion::eLIMITED in order for the limits to be enforced.
|
||||
- The lower limit should be strictly smaller than the higher limit. If the limits should be equal, use PxArticulationMotion::eLOCKED
|
||||
and an appropriate offset in the parent/child joint frames.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] lowLimit The lower joint limit.<br>
|
||||
<b>Range:</b> [-PX_MAX_F32, highLimit)<br>
|
||||
<b>Default:</b> 0.0
|
||||
\param[in] highLimit The higher joint limit.<br>
|
||||
<b>Range:</b> (lowLimit, PX_MAX_F32]<br>
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
\deprecated Use #setLimitParams instead. Deprecated since PhysX version 5.1.
|
||||
|
||||
@see setLimitParams, PxArticulationAxis
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE void setLimit(PxArticulationAxis::Enum axis, const PxReal lowLimit, const PxReal highLimit)
|
||||
{
|
||||
setLimitParams(axis, PxArticulationLimit(lowLimit, highLimit));
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns the joint limits for a given axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[out] lowLimit The lower joint limit.
|
||||
\param[out] highLimit The higher joint limit.
|
||||
|
||||
\deprecated Use #getLimitParams instead. Deprecated since PhysX version 5.1.
|
||||
|
||||
@see getLimitParams, PxArticulationAxis
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE void getLimit(PxArticulationAxis::Enum axis, PxReal& lowLimit, PxReal& highLimit) const
|
||||
{
|
||||
PxArticulationLimit pair = getLimitParams(axis);
|
||||
lowLimit = pair.low;
|
||||
highLimit = pair.high;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Sets the joint limits for a given axis.
|
||||
|
||||
- The motion of the corresponding axis should be set to PxArticulationMotion::eLIMITED in order for the limits to be enforced.
|
||||
- The lower limit should be strictly smaller than the higher limit. If the limits should be equal, use PxArticulationMotion::eLOCKED
|
||||
and an appropriate offset in the parent/child joint frames.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] limit The joint limits.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
\note For spherical joints, limit.min and limit.max must both be in range [-Pi, Pi].
|
||||
|
||||
@see getLimitParams, PxArticulationAxis, PxArticulationLimit
|
||||
*/
|
||||
virtual void setLimitParams(PxArticulationAxis::Enum axis, const PxArticulationLimit& limit) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the joint limits for a given axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
|
||||
\return The joint limits.
|
||||
|
||||
@see setLimitParams, PxArticulationAxis, PxArticulationLimit
|
||||
*/
|
||||
virtual PxArticulationLimit getLimitParams(PxArticulationAxis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief Configures a joint drive for the given axis.
|
||||
|
||||
See PxArticulationDrive for parameter details; and the manual for further information, and the drives' implicit spring-damper (i.e. PD control) implementation in particular.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] stiffness The drive stiffness, i.e. the proportional gain of the implicit PD controller.<br>
|
||||
<b>Range:</b> [0, PX_MAX_F32]<br>
|
||||
<b>Default:</b> 0.0
|
||||
\param[in] damping The drive damping, i.e. the derivative gain of the implicit PD controller.<br>
|
||||
<b>Range:</b> [0, PX_MAX_F32]<br>
|
||||
<b>Default:</b> 0.0
|
||||
\param[in] maxForce The force limit of the drive (this parameter also limits the force for an acceleration-type drive).<br>
|
||||
<b>Range:</b> [0, PX_MAX_F32]<br>
|
||||
<b>Default:</b> 0.0
|
||||
\param[in] driveType The drive type, @see PxArticulationDriveType.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
\deprecated Use #setDriveParams instead. Deprecated since PhysX version 5.1.
|
||||
|
||||
@see setDriveParams, PxArticulationAxis, PxArticulationDriveType, PxArticulationDrive, PxArticulationFlag::eDRIVE_LIMITS_ARE_FORCES
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE void setDrive(PxArticulationAxis::Enum axis, const PxReal stiffness, const PxReal damping, const PxReal maxForce, PxArticulationDriveType::Enum driveType = PxArticulationDriveType::eFORCE)
|
||||
{
|
||||
setDriveParams(axis, PxArticulationDrive(stiffness, damping, maxForce, driveType));
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the joint drive configuration for the given axis.
|
||||
|
||||
\param[in] axis The motion axis.
|
||||
\param[out] stiffness The drive stiffness.
|
||||
\param[out] damping The drive damping.
|
||||
\param[out] maxForce The force limit.
|
||||
\param[out] driveType The drive type.
|
||||
|
||||
\deprecated Use #getDriveParams instead. Deprecated since PhysX version 5.1.
|
||||
|
||||
@see getDriveParams, PxArticulationAxis, PxArticulationDriveType, PxArticulationDrive
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE void getDrive(PxArticulationAxis::Enum axis, PxReal& stiffness, PxReal& damping, PxReal& maxForce, PxArticulationDriveType::Enum& driveType) const
|
||||
{
|
||||
PxArticulationDrive drive = getDriveParams(axis);
|
||||
stiffness = drive.stiffness;
|
||||
damping = drive.damping;
|
||||
maxForce = drive.maxForce;
|
||||
driveType = drive.driveType;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Configures a joint drive for the given axis.
|
||||
|
||||
See PxArticulationDrive for parameter details; and the manual for further information, and the drives' implicit spring-damper (i.e. PD control) implementation in particular.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] drive The drive parameters
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
@see getDriveParams, PxArticulationAxis, PxArticulationDrive
|
||||
*/
|
||||
virtual void setDriveParams(PxArticulationAxis::Enum axis, const PxArticulationDrive& drive) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the joint drive configuration for the given axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\return The drive parameters.
|
||||
|
||||
@see setDriveParams, PxArticulationAxis, PxArticulationDrive
|
||||
*/
|
||||
virtual PxArticulationDrive getDriveParams(PxArticulationAxis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint drive position target for the given axis.
|
||||
|
||||
The target units are linear units (equivalent to scene units) for a translational axis, or rad for a rotational axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] target The target position.
|
||||
\param[in] autowake If true and the articulation is in a scene, the call wakes up the articulation and increases the wake counter
|
||||
to #PxSceneDesc::wakeCounterResetValue if the counter value is below the reset value.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
\note For spherical joints, target must be in range [-Pi, Pi].
|
||||
|
||||
\note The target is specified in the parent frame of the joint. If Gp, Gc are the parent and child actor poses in the world frame and Lp, Lc are the parent and child joint frames expressed in the parent and child actor frames then the joint will drive the parent and child links to poses that obey Gp * Lp * J = Gc * Lc. For joints restricted to angular motion, J has the form PxTranfsorm(PxVec3(PxZero), PxExp(PxVec3(twistTarget, swing1Target, swing2Target))). For joints restricted to linear motion, J has the form PxTransform(PxVec3(XTarget, YTarget, ZTarget), PxQuat(PxIdentity)).
|
||||
|
||||
\note For spherical joints with more than 1 degree of freedom, the joint target angles taken together can collectively represent a rotation of greater than Pi around a vector. When this happens the rotation that matches the joint drive target is not the shortest path rotation. The joint pose J that is the outcome after driving to the target pose will always be the equivalent of the shortest path rotation.
|
||||
|
||||
@see PxArticulationAxis, getDriveTarget
|
||||
*/
|
||||
virtual void setDriveTarget(PxArticulationAxis::Enum axis, const PxReal target, bool autowake = true) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the joint drive position target for the given axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
|
||||
\return The target position.
|
||||
|
||||
@see PxArticulationAxis, setDriveTarget
|
||||
*/
|
||||
virtual PxReal getDriveTarget(PxArticulationAxis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint drive velocity target for the given axis.
|
||||
|
||||
The target units are linear units (equivalent to scene units) per second for a translational axis, or radians per second for a rotational axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] targetVel The target velocity.
|
||||
\param[in] autowake If true and the articulation is in a scene, the call wakes up the articulation and increases the wake counter
|
||||
to #PxSceneDesc::wakeCounterResetValue if the counter value is below the reset value.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
@see PxArticulationAxis, getDriveVelocity
|
||||
*/
|
||||
virtual void setDriveVelocity(PxArticulationAxis::Enum axis, const PxReal targetVel, bool autowake = true) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the joint drive velocity target for the given axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
|
||||
\return The target velocity.
|
||||
|
||||
@see PxArticulationAxis, setDriveVelocity
|
||||
*/
|
||||
virtual PxReal getDriveVelocity(PxArticulationAxis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint armature for the given axis.
|
||||
|
||||
- The armature is directly added to the joint-space spatial inertia of the corresponding axis.
|
||||
- The armature is in mass units for a prismatic (i.e. linear) joint, and in mass units * (scene linear units)^2 for a rotational joint.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] armature The joint axis armature.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
@see PxArticulationAxis, getArmature
|
||||
*/
|
||||
virtual void setArmature(PxArticulationAxis::Enum axis, const PxReal armature) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the joint armature for the given axis.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\return The armature set on the given axis.
|
||||
|
||||
@see PxArticulationAxis, setArmature
|
||||
*/
|
||||
virtual PxReal getArmature(PxArticulationAxis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint friction coefficient, which applies to all joint axes.
|
||||
|
||||
- The joint friction is unitless and relates the magnitude of the spatial force [F_trans, T_trans] transmitted from parent to child link to
|
||||
the maximal friction force F_resist that may be applied by the solver to resist joint motion, per axis; i.e. |F_resist| <= coefficient * (|F_trans| + |T_trans|),
|
||||
where F_resist may refer to a linear force or torque depending on the joint axis.
|
||||
- The simulated friction effect is therefore similar to static and Coulomb friction. In order to simulate dynamic joint friction, use a joint drive with
|
||||
zero stiffness and zero velocity target, and an appropriately dimensioned damping parameter.
|
||||
|
||||
\param[in] coefficient The joint friction coefficient.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
@see getFrictionCoefficient
|
||||
*/
|
||||
virtual void setFrictionCoefficient(const PxReal coefficient) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the joint friction coefficient.
|
||||
|
||||
\return The joint friction coefficient.
|
||||
|
||||
@see setFrictionCoefficient
|
||||
*/
|
||||
virtual PxReal getFrictionCoefficient() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the maximal joint velocity enforced for all axes.
|
||||
|
||||
- The solver will apply appropriate joint-space impulses in order to enforce the per-axis joint-velocity limit.
|
||||
- The velocity units are linear units (equivalent to scene units) per second for a translational axis, or radians per second for a rotational axis.
|
||||
|
||||
\param[in] maxJointV The maximal per-axis joint velocity.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
@see getMaxJointVelocity
|
||||
*/
|
||||
virtual void setMaxJointVelocity(const PxReal maxJointV) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the maximal joint velocity enforced for all axes.
|
||||
|
||||
\return The maximal per-axis joint velocity.
|
||||
|
||||
@see setMaxJointVelocity
|
||||
*/
|
||||
virtual PxReal getMaxJointVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint position for the given axis.
|
||||
|
||||
- For performance, prefer PxArticulationCache::jointPosition to set joint positions in a batch articulation state update.
|
||||
- Use PxArticulationReducedCoordinate::updateKinematic after all state updates to the articulation via non-cache API such as this method,
|
||||
in order to update link states for the next simulation frame or querying.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] jointPos The joint position in linear units (equivalent to scene units) for a translational axis, or radians for a rotational axis.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
\note For spherical joints, jointPos must be in range [-Pi, Pi].
|
||||
|
||||
\note Joint position is specified in the parent frame of the joint. If Gp, Gc are the parent and child actor poses in the world frame and Lp, Lc are the parent and child joint frames expressed in the parent and child actor frames then the parent and child links will be given poses that obey Gp * Lp * J = Gc * Lc with J denoting the joint pose. For joints restricted to angular motion, J has the form PxTranfsorm(PxVec3(PxZero), PxExp(PxVec3(twistPos, swing1Pos, swing2Pos))). For joints restricted to linear motion, J has the form PxTransform(PxVec3(xPos, yPos, zPos), PxQuat(PxIdentity)).
|
||||
|
||||
\note For spherical joints with more than 1 degree of freedom, the input joint positions taken together can collectively represent a rotation of greater than Pi around a vector. When this happens the rotation that matches the joint positions is not the shortest path rotation. The joint pose J that is the outcome of setting and applying the joint positions will always be the equivalent of the shortest path rotation.
|
||||
|
||||
@see PxArticulationAxis, getJointPosition, PxArticulationCache::jointPosition, PxArticulationReducedCoordinate::updateKinematic
|
||||
*/
|
||||
virtual void setJointPosition(PxArticulationAxis::Enum axis, const PxReal jointPos) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the joint position for the given axis, i.e. joint degree of freedom (DOF).
|
||||
|
||||
For performance, prefer PxArticulationCache::jointPosition to get joint positions in a batch query.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
|
||||
\return The joint position in linear units (equivalent to scene units) for a translational axis, or radians for a rotational axis.
|
||||
|
||||
\note This call is not allowed while the simulation is running except in a split simulation during #PxScene::collide() and up to #PxScene::advance(),
|
||||
and in PxContactModifyCallback or in contact report callbacks.
|
||||
|
||||
@see PxArticulationAxis, setJointPosition, PxArticulationCache::jointPosition
|
||||
*/
|
||||
virtual PxReal getJointPosition(PxArticulationAxis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the joint velocity for the given axis.
|
||||
|
||||
- For performance, prefer PxArticulationCache::jointVelocity to set joint velocities in a batch articulation state update.
|
||||
- Use PxArticulationReducedCoordinate::updateKinematic after all state updates to the articulation via non-cache API such as this method,
|
||||
in order to update link states for the next simulation frame or querying.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
\param[in] jointVel The joint velocity in linear units (equivalent to scene units) per second for a translational axis, or radians per second for a rotational axis.
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
@see PxArticulationAxis, getJointVelocity, PxArticulationCache::jointVelocity, PxArticulationReducedCoordinate::updateKinematic
|
||||
*/
|
||||
virtual void setJointVelocity(PxArticulationAxis::Enum axis, const PxReal jointVel) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the joint velocity for the given axis.
|
||||
|
||||
For performance, prefer PxArticulationCache::jointVelocity to get joint velocities in a batch query.
|
||||
|
||||
\param[in] axis The target axis.
|
||||
|
||||
\return The joint velocity in linear units (equivalent to scene units) per second for a translational axis, or radians per second for a rotational axis.
|
||||
|
||||
\note This call is not allowed while the simulation is running except in a split simulation during #PxScene::collide() and up to #PxScene::advance(),
|
||||
and in PxContactModifyCallback or in contact report callbacks.
|
||||
|
||||
@see PxArticulationAxis, setJointVelocity, PxArticulationCache::jointVelocity
|
||||
*/
|
||||
virtual PxReal getJointVelocity(PxArticulationAxis::Enum axis) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the string name of the dynamic type.
|
||||
|
||||
\return The string name.
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const { return "PxArticulationJointReducedCoordinate"; }
|
||||
|
||||
virtual ~PxArticulationJointReducedCoordinate() {}
|
||||
|
||||
//public variables:
|
||||
void* userData; //!< The user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
|
||||
protected:
|
||||
PX_INLINE PxArticulationJointReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
|
||||
PX_INLINE PxArticulationJointReducedCoordinate(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxArticulationJointReducedCoordinate", name) || PxBase::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,205 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_ARTICULATION_LINK_H
|
||||
#define PX_ARTICULATION_LINK_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxRigidBody.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A component of an articulation that represents a rigid body.
|
||||
|
||||
Articulation links have a restricted subset of the functionality of a PxRigidDynamic:
|
||||
- They may not be kinematic, and do not support contact-force thresholds.
|
||||
- Their velocity or global pose cannot be set directly, but must be set via the articulation-root and joint positions/velocities.
|
||||
- Sleep state and solver iteration counts are properties of the entire articulation rather than the individual links.
|
||||
|
||||
@see PxArticulationReducedCoordinate, PxArticulationReducedCoordinate::createLink, PxArticulationJointReducedCoordinate, PxRigidBody
|
||||
*/
|
||||
|
||||
class PxArticulationLink : public PxRigidBody
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Releases the link from the articulation.
|
||||
|
||||
\note Only a leaf articulation link can be released.
|
||||
\note Releasing a link is not allowed while the articulation link is in a scene. In order to release a link,
|
||||
remove and then re-add the corresponding articulation to the scene.
|
||||
|
||||
@see PxArticulationReducedCoordinate::createLink()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the articulation that the link is a part of.
|
||||
|
||||
\return The articulation.
|
||||
|
||||
@see PxArticulationReducedCoordinate
|
||||
*/
|
||||
virtual PxArticulationReducedCoordinate& getArticulation() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the joint which connects this link to its parent.
|
||||
|
||||
\return The joint connecting the link to the parent. NULL for the root link.
|
||||
|
||||
@see PxArticulationJointReducedCoordinate
|
||||
*/
|
||||
virtual PxArticulationJointReducedCoordinate* getInboundJoint() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the number of degrees of freedom of the joint which connects this link to its parent.
|
||||
|
||||
- The root link DOF-count is defined to be 0 regardless of PxArticulationFlag::eFIX_BASE.
|
||||
- The return value is only valid for articulations that are in a scene.
|
||||
|
||||
\return The number of degrees of freedom, or 0xFFFFFFFF if the articulation is not in a scene.
|
||||
|
||||
@see PxArticulationJointReducedCoordinate
|
||||
*/
|
||||
virtual PxU32 getInboundJointDof() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the number of child links.
|
||||
|
||||
\return The number of child links.
|
||||
|
||||
@see getChildren
|
||||
*/
|
||||
virtual PxU32 getNbChildren() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the low-level link index that may be used to index into members of PxArticulationCache.
|
||||
|
||||
The return value is only valid for articulations that are in a scene.
|
||||
|
||||
\return The low-level index, or 0xFFFFFFFF if the articulation is not in a scene.
|
||||
|
||||
@see PxArticulationCache
|
||||
*/
|
||||
virtual PxU32 getLinkIndex() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the child links.
|
||||
|
||||
\param[out] userBuffer The buffer to receive articulation link pointers.
|
||||
\param[in] bufferSize The size of the provided user buffer, use getNbChildren() for sizing.
|
||||
\param[in] startIndex The index of the first child pointer to be retrieved.
|
||||
|
||||
\return The number of articulation links written to the buffer.
|
||||
|
||||
@see getNbChildren
|
||||
*/
|
||||
virtual PxU32 getChildren(PxArticulationLink** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Set the constraint-force-mixing scale term.
|
||||
|
||||
The cfm scale term is a stabilization term that helps avoid instabilities with over-constrained
|
||||
configurations. It should be a small value that is multiplied by 1/mass internally to produce
|
||||
an additional bias added to the unit response term in the solver.
|
||||
|
||||
\param[in] cfm The constraint-force-mixing scale term.
|
||||
|
||||
<b>Default:</b> 0.025
|
||||
<b>Range:</b> [0, 1]
|
||||
|
||||
\note This call is not allowed while the simulation is running.
|
||||
|
||||
@see getCfmScale
|
||||
*/
|
||||
virtual void setCfmScale(const PxReal cfm) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the constraint-force-mixing scale term.
|
||||
\return The constraint-force-mixing scale term.
|
||||
|
||||
@see setCfmScale
|
||||
*/
|
||||
virtual PxReal getCfmScale() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the linear velocity of the link.
|
||||
|
||||
- The linear velocity is with respect to the link's center of mass and not the actor frame origin.
|
||||
- For performance, prefer PxArticulationCache::linkVelocity to get link spatial velocities in a batch query.
|
||||
- When the articulation state is updated via non-cache API, use PxArticulationReducedCoordinate::updateKinematic before querying velocity.
|
||||
|
||||
\return The linear velocity of the link.
|
||||
|
||||
\note This call is not allowed while the simulation is running except in a split simulation during #PxScene::collide() and up to #PxScene::advance(),
|
||||
and in PxContactModifyCallback or in contact report callbacks.
|
||||
|
||||
@see PxRigidBody::getCMassLocalPose
|
||||
*/
|
||||
virtual PxVec3 getLinearVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the angular velocity of the link.
|
||||
|
||||
- For performance, prefer PxArticulationCache::linkVelocity to get link spatial velocities in a batch query.
|
||||
- When the articulation state is updated via non-cache API, use PxArticulationReducedCoordinate::updateKinematic before querying velocity.
|
||||
|
||||
\return The angular velocity of the link.
|
||||
|
||||
\note This call is not allowed while the simulation is running except in a split simulation during #PxScene::collide() and up to #PxScene::advance(),
|
||||
and in PxContactModifyCallback or in contact report callbacks.
|
||||
*/
|
||||
virtual PxVec3 getAngularVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the string name of the dynamic type.
|
||||
|
||||
\return The string name.
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const { return "PxArticulationLink"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxArticulationLink(PxType concreteType, PxBaseFlags baseFlags) : PxRigidBody(concreteType, baseFlags) {}
|
||||
PX_INLINE PxArticulationLink(PxBaseFlags baseFlags) : PxRigidBody(baseFlags) {}
|
||||
virtual ~PxArticulationLink() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxArticulationLink", name) || PxRigidBody::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,589 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
|
||||
#ifndef PX_ARTICULATION_TENDON_H
|
||||
#define PX_ARTICULATION_TENDON_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
#include "solver/PxSolverDefs.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
class PxArticulationSpatialTendon;
|
||||
class PxArticulationFixedTendon;
|
||||
class PxArticulationLink;
|
||||
/**
|
||||
\brief Defines the low/high limits of the length of a tendon.
|
||||
*/
|
||||
class PxArticulationTendonLimit
|
||||
{
|
||||
public:
|
||||
PxReal lowLimit;
|
||||
PxReal highLimit;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Defines a spatial tendon attachment point on a link.
|
||||
*/
|
||||
class PxArticulationAttachment : public PxBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~PxArticulationAttachment() {}
|
||||
/**
|
||||
\brief Sets the spring rest length for the sub-tendon from the root to this leaf attachment.
|
||||
|
||||
Setting this on non-leaf attachments has no effect.
|
||||
|
||||
\param[in] restLength The rest length of the spring.
|
||||
<b>Default:</b> 0
|
||||
|
||||
@see getRestLength(), isLeaf()
|
||||
*/
|
||||
virtual void setRestLength(const PxReal restLength) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the spring rest length for the sub-tendon from the root to this leaf attachment.
|
||||
|
||||
\return The rest length.
|
||||
|
||||
@see setRestLength()
|
||||
*/
|
||||
virtual PxReal getRestLength() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the low and high limit on the length of the sub-tendon from the root to this leaf attachment.
|
||||
|
||||
Setting this on non-leaf attachments has no effect.
|
||||
|
||||
\param[in] parameters Struct with the low and high limit.
|
||||
<b>Default:</b> (PX_MAX_F32, -PX_MAX_F32) (i.e. an invalid configuration that can only work if stiffness is zero)
|
||||
|
||||
@see PxArticulationTendonLimit, getLimitParameters(), isLeaf()
|
||||
*/
|
||||
virtual void setLimitParameters(const PxArticulationTendonLimit& parameters) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the low and high limit on the length of the sub-tendon from the root to this leaf attachment.
|
||||
|
||||
\return Struct with the low and high limit.
|
||||
|
||||
@see PxArticulationTendonLimit, setLimitParameters()
|
||||
*/
|
||||
virtual PxArticulationTendonLimit getLimitParameters() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the attachment's relative offset in the link actor frame.
|
||||
|
||||
\param[in] offset The relative offset in the link actor frame.
|
||||
|
||||
@see getRelativeOffset()
|
||||
*/
|
||||
virtual void setRelativeOffset(const PxVec3& offset) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the attachment's relative offset in the link actor frame.
|
||||
|
||||
\return The relative offset in the link actor frame.
|
||||
|
||||
@see setRelativeOffset()
|
||||
*/
|
||||
virtual PxVec3 getRelativeOffset() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the attachment coefficient.
|
||||
|
||||
\param[in] coefficient The scale that the distance between this attachment and its parent is multiplied by when summing up the spatial tendon's length.
|
||||
|
||||
@see getCoefficient()
|
||||
*/
|
||||
virtual void setCoefficient(const PxReal coefficient) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the attachment coefficient.
|
||||
|
||||
\return The scale that the distance between this attachment and its parent is multiplied by when summing up the spatial tendon's length.
|
||||
|
||||
@see setCoefficient()
|
||||
*/
|
||||
virtual PxReal getCoefficient() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the articulation link.
|
||||
|
||||
\return The articulation link that this attachment is attached to.
|
||||
*/
|
||||
virtual PxArticulationLink* getLink() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the parent attachment.
|
||||
|
||||
\return The parent attachment.
|
||||
*/
|
||||
virtual PxArticulationAttachment* getParent() const = 0;
|
||||
|
||||
/**
|
||||
\brief Indicates that this attachment is a leaf, and thus defines a sub-tendon from the root to this attachment.
|
||||
|
||||
\return True: This attachment is a leaf and has zero children; False: Not a leaf.
|
||||
*/
|
||||
virtual bool isLeaf() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the spatial tendon that the attachment is a part of.
|
||||
|
||||
\return The tendon.
|
||||
|
||||
@see PxArticulationSpatialTendon
|
||||
*/
|
||||
virtual PxArticulationSpatialTendon* getTendon() const = 0;
|
||||
|
||||
/**
|
||||
\brief Releases the attachment.
|
||||
|
||||
\note Releasing the attachment is not allowed while the articulation is in a scene. In order to
|
||||
release the attachment, remove and then re-add the articulation to the scene.
|
||||
|
||||
@see PxArticulationSpatialTendon::createAttachment()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
|
||||
/**
|
||||
\brief Returns the string name of the dynamic type.
|
||||
|
||||
\return The string name.
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const { return "PxArticulationAttachment"; }
|
||||
|
||||
protected:
|
||||
|
||||
PX_INLINE PxArticulationAttachment(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
|
||||
PX_INLINE PxArticulationAttachment(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Defines a fixed-tendon joint on an articulation joint degree of freedom.
|
||||
*/
|
||||
class PxArticulationTendonJoint : public PxBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~PxArticulationTendonJoint() {}
|
||||
|
||||
/**
|
||||
\brief Sets the tendon joint coefficient.
|
||||
|
||||
\param[in] axis The degree of freedom that the tendon joint operates on (must correspond to a degree of freedom of the associated link's incoming joint).
|
||||
\param[in] coefficient The scale that the axis' joint position is multiplied by when summing up the fixed tendon's length.
|
||||
\param[in] recipCoefficient The scale that the tendon's response is multiplied by when applying to this tendon joint.
|
||||
|
||||
\note RecipCoefficient is commonly expected to be 1/coefficient, but it can be set to different values to tune behavior; for example, zero can be used to
|
||||
have a joint axis only participate in the length computation of the tendon, but not have any tendon force applied to it.
|
||||
|
||||
@see getCoefficient()
|
||||
*/
|
||||
virtual void setCoefficient(const PxArticulationAxis::Enum axis, const PxReal coefficient, const PxReal recipCoefficient) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the tendon joint coefficient.
|
||||
|
||||
\param[out] axis The degree of freedom that the tendon joint operates on.
|
||||
\param[out] coefficient The scale that the axis' joint position is multiplied by when summing up the fixed tendon's length.
|
||||
\param[in] recipCoefficient The scale that the tendon's response is multiplied by when applying to this tendon joint.
|
||||
|
||||
@see setCoefficient()
|
||||
*/
|
||||
virtual void getCoefficient(PxArticulationAxis::Enum& axis, PxReal& coefficient, PxReal& recipCoefficient) const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the articulation link.
|
||||
|
||||
\return The articulation link (and its incoming joint in particular) that this tendon joint is associated with.
|
||||
*/
|
||||
virtual PxArticulationLink* getLink() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the parent tendon joint.
|
||||
|
||||
\return The parent tendon joint.
|
||||
*/
|
||||
virtual PxArticulationTendonJoint* getParent() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the tendon that the joint is a part of.
|
||||
|
||||
\return The tendon.
|
||||
|
||||
@see PxArticulationFixedTendon
|
||||
*/
|
||||
virtual PxArticulationFixedTendon* getTendon() const = 0;
|
||||
|
||||
/**
|
||||
\brief Releases a tendon joint.
|
||||
|
||||
\note Releasing a tendon joint is not allowed while the articulation is in a scene. In order to
|
||||
release the joint, remove and then re-add the articulation to the scene.
|
||||
|
||||
@see PxArticulationFixedTendon::createTendonJoint()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
|
||||
/**
|
||||
\brief Returns the string name of the dynamic type.
|
||||
|
||||
\return The string name.
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const { return "PxArticulationTendonJoint"; }
|
||||
|
||||
protected:
|
||||
|
||||
PX_INLINE PxArticulationTendonJoint(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
|
||||
PX_INLINE PxArticulationTendonJoint(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Common API base class shared by PxArticulationSpatialTendon and PxArticulationFixedTendon.
|
||||
*/
|
||||
class PxArticulationTendon : public PxBase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Sets the spring stiffness term acting on the tendon length.
|
||||
|
||||
\param[in] stiffness The spring stiffness.
|
||||
<b>Default:</b> 0
|
||||
|
||||
@see getStiffness()
|
||||
*/
|
||||
virtual void setStiffness(const PxReal stiffness) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the spring stiffness of the tendon.
|
||||
|
||||
\return The spring stiffness.
|
||||
|
||||
@see setStiffness()
|
||||
*/
|
||||
virtual PxReal getStiffness() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the damping term acting both on the tendon length and tendon-length limits.
|
||||
|
||||
\param[in] damping The damping term.
|
||||
<b>Default:</b> 0
|
||||
|
||||
@see getDamping()
|
||||
*/
|
||||
virtual void setDamping(const PxReal damping) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the damping term acting both on the tendon length and tendon-length limits.
|
||||
|
||||
\return The damping term.
|
||||
|
||||
@see setDamping()
|
||||
*/
|
||||
virtual PxReal getDamping() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the limit stiffness term acting on the tendon's length limits.
|
||||
|
||||
For spatial tendons, this parameter applies to all its leaf attachments / sub-tendons.
|
||||
|
||||
\param[in] stiffness The limit stiffness term.
|
||||
<b>Default:</b> 0
|
||||
|
||||
@see getLimitStiffness()
|
||||
*/
|
||||
virtual void setLimitStiffness(const PxReal stiffness) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the limit stiffness term acting on the tendon's length limits.
|
||||
|
||||
For spatial tendons, this parameter applies to all its leaf attachments / sub-tendons.
|
||||
|
||||
\return The limit stiffness term.
|
||||
|
||||
@see setLimitStiffness()
|
||||
*/
|
||||
virtual PxReal getLimitStiffness() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the length offset term for the tendon.
|
||||
|
||||
An offset defines an amount to be added to the accumulated length computed for the tendon. It allows the
|
||||
application to actuate the tendon by shortening or lengthening it.
|
||||
|
||||
\param[in] offset The offset term. <b>Default:</b> 0
|
||||
\param[in] autowake If true and the articulation is in a scene, the call wakes up the articulation and increases the wake counter
|
||||
to #PxSceneDesc::wakeCounterResetValue if the counter value is below the reset value.
|
||||
|
||||
@see getOffset()
|
||||
*/
|
||||
virtual void setOffset(const PxReal offset, bool autowake = true) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the length offset term for the tendon.
|
||||
|
||||
\return The offset term.
|
||||
|
||||
@see setOffset()
|
||||
*/
|
||||
virtual PxReal getOffset() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the articulation that the tendon is a part of.
|
||||
|
||||
\return The articulation.
|
||||
|
||||
@see PxArticulationReducedCoordinate
|
||||
*/
|
||||
virtual PxArticulationReducedCoordinate* getArticulation() const = 0;
|
||||
|
||||
/**
|
||||
\brief Releases a tendon to remove it from the articulation and free its associated memory.
|
||||
|
||||
When an articulation is released, its attached tendons are automatically released.
|
||||
|
||||
\note Releasing a tendon is not allowed while the articulation is in a scene. In order to
|
||||
release the tendon, remove and then re-add the articulation to the scene.
|
||||
*/
|
||||
|
||||
virtual void release() = 0;
|
||||
|
||||
virtual ~PxArticulationTendon() {}
|
||||
|
||||
void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
|
||||
protected:
|
||||
PX_INLINE PxArticulationTendon(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
|
||||
PX_INLINE PxArticulationTendon(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A spatial tendon that attaches to an articulation.
|
||||
|
||||
A spatial tendon attaches to multiple links in an articulation using a set of PxArticulationAttachments.
|
||||
The tendon is defined as a tree of attachment points, where each attachment can have an arbitrary number of children.
|
||||
Each leaf of the attachment tree defines a subtendon between itself and the root attachment. The subtendon then
|
||||
applies forces at the leaf, and an equal but opposing force at the root, in order to satisfy the spring-damper and limit
|
||||
constraints that the user sets up. Attachments in between the root and leaf do not exert any force on the articulation,
|
||||
but define the geometry of the tendon from which the length is computed together with the attachment coefficients.
|
||||
*/
|
||||
class PxArticulationSpatialTendon : public PxArticulationTendon
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Creates an articulation attachment and adds it to the list of children in the parent attachment.
|
||||
|
||||
Creating an attachment is not allowed while the articulation is in a scene. In order to
|
||||
add the attachment, remove and then re-add the articulation to the scene.
|
||||
|
||||
\param[in] parent The parent attachment. Can be NULL for the root attachment of a tendon.
|
||||
\param[in] coefficient A user-defined scale that the accumulated length is scaled by.
|
||||
\param[in] relativeOffset An offset vector in the link's actor frame to the point where the tendon attachment is attached to the link.
|
||||
\param[in] link The link that this attachment is associated with.
|
||||
|
||||
\return The newly-created attachment if creation was successful, otherwise a null pointer.
|
||||
|
||||
@see releaseAttachment()
|
||||
*/
|
||||
virtual PxArticulationAttachment* createAttachment(PxArticulationAttachment* parent, const PxReal coefficient, const PxVec3 relativeOffset, PxArticulationLink* link) = 0;
|
||||
|
||||
/**
|
||||
\brief Fills a user-provided buffer of attachment pointers with the set of attachments.
|
||||
|
||||
\param[in] userBuffer The user-provided buffer.
|
||||
\param[in] bufferSize The size of the buffer. If this is not large enough to contain all the pointers to attachments,
|
||||
only as many as can fit are written. Use getNbAttachments to size for all attachments.
|
||||
\param[in] startIndex Index of first attachment pointer to be retrieved.
|
||||
|
||||
\return The number of attachments that were filled into the user buffer.
|
||||
|
||||
@see getNbAttachments
|
||||
*/
|
||||
virtual PxU32 getAttachments(PxArticulationAttachment** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of attachments in the tendon.
|
||||
|
||||
\return The number of attachments.
|
||||
*/
|
||||
virtual PxU32 getNbAttachments() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the string name of the dynamic type.
|
||||
|
||||
\return The string name.
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const { return "PxArticulationSpatialTendon"; }
|
||||
|
||||
virtual ~PxArticulationSpatialTendon() {}
|
||||
|
||||
protected:
|
||||
PX_INLINE PxArticulationSpatialTendon(PxType concreteType, PxBaseFlags baseFlags) : PxArticulationTendon(concreteType, baseFlags) {}
|
||||
PX_INLINE PxArticulationSpatialTendon(PxBaseFlags baseFlags) : PxArticulationTendon(baseFlags) {}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A fixed tendon that can be used to link multiple degrees of freedom of multiple articulation joints via length and limit constraints.
|
||||
|
||||
Fixed tendons allow the simulation of coupled relationships between joint degrees of freedom in an articulation. Fixed tendons do not allow
|
||||
linking arbitrary joint axes of the articulation: The respective joints must all be directly connected to each other in the articulation structure,
|
||||
i.e. each of the joints in the tendon must be connected by a single articulation link to another joint in the same tendon. This implies both that
|
||||
1) fixed tendons can branch along a branching articulation; and 2) they cannot be used to create relationships between axes in a spherical joint with
|
||||
more than one degree of freedom. Locked joint axes or fixed joints are currently not supported.
|
||||
*/
|
||||
class PxArticulationFixedTendon : public PxArticulationTendon
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Creates an articulation tendon joint and adds it to the list of children in the parent tendon joint.
|
||||
|
||||
Creating a tendon joint is not allowed while the articulation is in a scene. In order to
|
||||
add the joint, remove and then re-add the articulation to the scene.
|
||||
|
||||
\param[in] parent The parent tendon joint. Can be NULL for the root tendon joint of a tendon.
|
||||
\param[in] axis The degree of freedom that this tendon joint is associated with.
|
||||
\param[in] coefficient A user-defined scale that the accumulated tendon length is scaled by.
|
||||
\param[in] recipCoefficient The scale that the tendon's response is multiplied by when applying to this tendon joint.
|
||||
\param[in] link The link (and the link's incoming joint in particular) that this tendon joint is associated with.
|
||||
|
||||
\return The newly-created tendon joint if creation was successful, otherwise a null pointer.
|
||||
|
||||
\note
|
||||
- The axis motion must not be configured as PxArticulationMotion::eLOCKED.
|
||||
- The axis cannot be part of a fixed joint, i.e. joint configured as PxArticulationJointType::eFIX.
|
||||
|
||||
@see PxArticulationTendonJoint PxArticulationAxis
|
||||
*/
|
||||
virtual PxArticulationTendonJoint* createTendonJoint(PxArticulationTendonJoint* parent, PxArticulationAxis::Enum axis, const PxReal coefficient, const PxReal recipCoefficient, PxArticulationLink* link) = 0;
|
||||
|
||||
/**
|
||||
\brief Fills a user-provided buffer of tendon-joint pointers with the set of tendon joints.
|
||||
|
||||
\param[in] userBuffer The user-provided buffer.
|
||||
\param[in] bufferSize The size of the buffer. If this is not large enough to contain all the pointers to tendon joints,
|
||||
only as many as can fit are written. Use getNbTendonJoints to size for all tendon joints.
|
||||
\param[in] startIndex Index of first tendon joint pointer to be retrieved.
|
||||
|
||||
\return The number of tendon joints filled into the user buffer.
|
||||
|
||||
@see getNbTendonJoints
|
||||
*/
|
||||
virtual PxU32 getTendonJoints(PxArticulationTendonJoint** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of tendon joints in the tendon.
|
||||
|
||||
\return The number of tendon joints.
|
||||
*/
|
||||
virtual PxU32 getNbTendonJoints() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the spring rest length of the tendon.
|
||||
|
||||
The accumulated "length" of a fixed tendon is a linear combination of the joint axis positions that the tendon is
|
||||
associated with, scaled by the respective tendon joints' coefficients. As such, when the joint positions of all
|
||||
joints are zero, the accumulated length of a fixed tendon is zero.
|
||||
|
||||
The spring of the tendon is not exerting any force on the articulation when the rest length is equal to the
|
||||
tendon's accumulated length plus the tendon offset.
|
||||
|
||||
\param[in] restLength The spring rest length of the tendon.
|
||||
|
||||
@see getRestLength()
|
||||
*/
|
||||
virtual void setRestLength(const PxReal restLength) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the spring rest length of the tendon.
|
||||
|
||||
\return The spring rest length of the tendon.
|
||||
|
||||
@see setRestLength()
|
||||
*/
|
||||
virtual PxReal getRestLength() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the low and high limit on the length of the tendon.
|
||||
|
||||
\param[in] parameter Struct with the low and high limit.
|
||||
|
||||
The limits, together with the damping and limit stiffness parameters, act on the accumulated length of the tendon.
|
||||
|
||||
@see PxArticulationTendonLimit getLimitParameters() setRestLength()
|
||||
*/
|
||||
virtual void setLimitParameters(const PxArticulationTendonLimit& parameter) = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Gets the low and high limit on the length of the tendon.
|
||||
|
||||
\return Struct with the low and high limit.
|
||||
|
||||
@see PxArticulationTendonLimit setLimitParameters()
|
||||
*/
|
||||
virtual PxArticulationTendonLimit getLimitParameters() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the string name of the dynamic type.
|
||||
|
||||
\return The string name.
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const { return "PxArticulationFixedTendon"; }
|
||||
|
||||
virtual ~PxArticulationFixedTendon() {}
|
||||
|
||||
protected:
|
||||
PX_INLINE PxArticulationFixedTendon(PxType concreteType, PxBaseFlags baseFlags) : PxArticulationTendon(concreteType, baseFlags) {}
|
||||
PX_INLINE PxArticulationFixedTendon(PxBaseFlags baseFlags) : PxArticulationTendon(baseFlags) {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
|
||||
#ifndef PX_ARTICULATION_TENDON_DATA_H
|
||||
#define PX_ARTICULATION_TENDON_DATA_H
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief PxGpuSpatialTendonData
|
||||
|
||||
This data structure is to be used by the direct GPU API for spatial tendon data updates.
|
||||
|
||||
@see PxArticulationSpatialTendon PxScene::copyArticulationData PxScene::applyArticulationData
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
class PxGpuSpatialTendonData
|
||||
{
|
||||
public:
|
||||
PxReal stiffness;
|
||||
PxReal damping;
|
||||
PxReal limitStiffness;
|
||||
PxReal offset;
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief PxGpuFixedTendonData
|
||||
|
||||
This data structure is to be used by the direct GPU API for fixed tendon data updates.
|
||||
|
||||
@see PxArticulationFixedTendon PxScene::copyArticulationData PxScene::applyArticulationData
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
class PxGpuFixedTendonData : public PxGpuSpatialTendonData
|
||||
{
|
||||
public:
|
||||
PxReal lowLimit;
|
||||
PxReal highLimit;
|
||||
PxReal restLength;
|
||||
PxReal padding;
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief PxGpuTendonJointCoefficientData
|
||||
|
||||
This data structure is to be used by the direct GPU API for fixed tendon joint data updates.
|
||||
|
||||
@see PxArticulationTendonJoint PxScene::copyArticulationData PxScene::applyArticulationData
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
class PxGpuTendonJointCoefficientData
|
||||
{
|
||||
public:
|
||||
PxReal coefficient;
|
||||
PxReal recipCoefficient;
|
||||
PxU32 axis;
|
||||
PxU32 pad;
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief PxGpuTendonAttachmentData
|
||||
|
||||
This data structure is to be used by the direct GPU API for spatial tendon attachment data updates.
|
||||
|
||||
@see PxArticulationAttachment PxScene::copyArticulationData PxScene::applyArticulationData
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
class PxGpuTendonAttachmentData
|
||||
{
|
||||
public:
|
||||
PxVec3 relativeOffset;
|
||||
PxReal restLength;
|
||||
|
||||
PxReal coefficient;
|
||||
PxReal lowLimit;
|
||||
PxReal highLimit;
|
||||
PxReal padding;
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_ATTACHMENT_H
|
||||
#define PX_ATTACHMENT_H
|
||||
|
||||
#include "PxConeLimitedConstraint.h"
|
||||
#include "PxFiltering.h"
|
||||
#include "foundation/PxVec4.h"
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Struct to specify attachment between a particle/vertex and a rigid
|
||||
*/
|
||||
struct PxParticleRigidAttachment : public PxParticleRigidFilterPair
|
||||
{
|
||||
PX_ALIGN(16, PxVec4 mLocalPose0); //!< local pose in body frame - except for statics, these are using world positions.
|
||||
|
||||
PxConeLimitParams mParams; //!< Parameters to specify cone constraints
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_BASE_MATERIAL_H
|
||||
#define PX_BASE_MATERIAL_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Base material class.
|
||||
|
||||
@see PxPhysics.createMaterial PxPhysics.createFEMClothMaterial PxPhysics.createFEMSoftBodyMaterial PxPhysics.createFLIPMaterial PxPhysics.createMPMMaterial PxPhysics.createPBDMaterial
|
||||
*/
|
||||
class PxBaseMaterial : public PxRefCounted
|
||||
{
|
||||
public:
|
||||
PX_INLINE PxBaseMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags), userData(NULL) {}
|
||||
PX_INLINE PxBaseMaterial(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
|
||||
virtual ~PxBaseMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxBaseMaterial", name) || PxRefCounted::isKindOf(name); }
|
||||
|
||||
void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
705
modules/PhysX/physx/physx-sys/physx/physx/include/PxBroadPhase.h
Normal file
705
modules/PhysX/physx/physx-sys/physx/physx/include/PxBroadPhase.h
Normal file
@@ -0,0 +1,705 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_BROAD_PHASE_H
|
||||
#define PX_BROAD_PHASE_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxBounds3.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxBaseTask;
|
||||
class PxCudaContextManager;
|
||||
|
||||
/**
|
||||
\brief Broad phase algorithm used in the simulation
|
||||
|
||||
eSAP is a good generic choice with great performance when many objects are sleeping. Performance
|
||||
can degrade significantly though, when all objects are moving, or when large numbers of objects
|
||||
are added to or removed from the broad phase. This algorithm does not need world bounds to be
|
||||
defined in order to work.
|
||||
|
||||
eMBP is an alternative broad phase algorithm that does not suffer from the same performance
|
||||
issues as eSAP when all objects are moving or when inserting large numbers of objects. However
|
||||
its generic performance when many objects are sleeping might be inferior to eSAP, and it requires
|
||||
users to define world bounds in order to work.
|
||||
|
||||
eABP is a revisited implementation of MBP, which automatically manages broad-phase regions.
|
||||
It offers the convenience of eSAP (no need to define world bounds or regions) and the performance
|
||||
of eMBP when a lot of objects are moving. While eSAP can remain faster when most objects are
|
||||
sleeping and eMBP can remain faster when it uses a large number of properly-defined regions,
|
||||
eABP often gives the best performance on average and the best memory usage.
|
||||
|
||||
ePABP is a parallel implementation of ABP. It can often be the fastest (CPU) broadphase, but it
|
||||
can use more memory than ABP.
|
||||
|
||||
eGPU is a GPU implementation of the incremental sweep and prune approach. Additionally, it uses a ABP-style
|
||||
initial pair generation approach to avoid large spikes when inserting shapes. It not only has the advantage
|
||||
of traditional SAP approch which is good for when many objects are sleeping, but due to being fully parallel,
|
||||
it also is great when lots of shapes are moving or for runtime pair insertion and removal. It can become a
|
||||
performance bottleneck if there are a very large number of shapes roughly projecting to the same values
|
||||
on a given axis. If the scene has a very large number of shapes in an actor, e.g. a humanoid, it is recommended
|
||||
to use an aggregate to represent multi-shape or multi-body actors to minimize stress placed on the broad phase.
|
||||
*/
|
||||
struct PxBroadPhaseType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eSAP, //!< 3-axes sweep-and-prune
|
||||
eMBP, //!< Multi box pruning
|
||||
eABP, //!< Automatic box pruning
|
||||
ePABP, //!< Parallel automatic box pruning
|
||||
eGPU, //!< GPU broad phase
|
||||
eLAST
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief "Region of interest" for the broad-phase.
|
||||
|
||||
This is currently only used for the PxBroadPhaseType::eMBP broad-phase, which requires zones or regions to be defined
|
||||
when the simulation starts in order to work. Regions can overlap and be added or removed at runtime, but at least one
|
||||
region needs to be defined when the scene is created.
|
||||
|
||||
If objects that do no overlap any region are inserted into the scene, they will not be added to the broad-phase and
|
||||
thus collisions will be disabled for them. A PxBroadPhaseCallback out-of-bounds notification will be sent for each one
|
||||
of those objects.
|
||||
|
||||
The total number of regions is limited by PxBroadPhaseCaps::mMaxNbRegions.
|
||||
|
||||
The number of regions has a direct impact on performance and memory usage, so it is recommended to experiment with
|
||||
various settings to find the best combination for your game. A good default setup is to start with global bounds
|
||||
around the whole world, and subdivide these bounds into 4*4 regions. The PxBroadPhaseExt::createRegionsFromWorldBounds
|
||||
function can do that for you.
|
||||
|
||||
@see PxBroadPhaseCallback PxBroadPhaseExt.createRegionsFromWorldBounds
|
||||
*/
|
||||
struct PxBroadPhaseRegion
|
||||
{
|
||||
PxBounds3 mBounds; //!< Region's bounds
|
||||
void* mUserData; //!< Region's user-provided data
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Information & stats structure for a region
|
||||
*/
|
||||
struct PxBroadPhaseRegionInfo
|
||||
{
|
||||
PxBroadPhaseRegion mRegion; //!< User-provided region data
|
||||
PxU32 mNbStaticObjects; //!< Number of static objects in the region
|
||||
PxU32 mNbDynamicObjects; //!< Number of dynamic objects in the region
|
||||
bool mActive; //!< True if region is currently used, i.e. it has not been removed
|
||||
bool mOverlap; //!< True if region overlaps other regions (regions that are just touching are not considering overlapping)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Caps class for broad phase.
|
||||
*/
|
||||
struct PxBroadPhaseCaps
|
||||
{
|
||||
PxU32 mMaxNbRegions; //!< Max number of regions supported by the broad-phase (0 = explicit regions not needed)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Broadphase descriptor.
|
||||
|
||||
This structure is used to create a standalone broadphase. It captures all the parameters needed to
|
||||
initialize a broadphase.
|
||||
|
||||
For the GPU broadphase (PxBroadPhaseType::eGPU) it is necessary to provide a CUDA context manager.
|
||||
|
||||
The kinematic filtering flags are currently not supported by the GPU broadphase. They are used to
|
||||
dismiss pairs that involve kinematic objects directly within the broadphase.
|
||||
|
||||
\see PxCreateBroadPhase
|
||||
*/
|
||||
class PxBroadPhaseDesc
|
||||
{
|
||||
public:
|
||||
PxBroadPhaseDesc(PxBroadPhaseType::Enum type = PxBroadPhaseType::eLAST) :
|
||||
mType (type),
|
||||
mContextID (0),
|
||||
mContextManager (NULL),
|
||||
mFoundLostPairsCapacity (256 * 1024),
|
||||
mDiscardStaticVsKinematic (false),
|
||||
mDiscardKinematicVsKinematic(false)
|
||||
{}
|
||||
|
||||
PxBroadPhaseType::Enum mType; //!< Desired broadphase implementation
|
||||
PxU64 mContextID; //!< Context ID for profiler. See PxProfilerCallback.
|
||||
|
||||
PX_DEPRECATED PxCudaContextManager* mContextManager; //!< (GPU) CUDA context manager, must be provided for PxBroadPhaseType::eGPU.
|
||||
PxU32 mFoundLostPairsCapacity; //!< (GPU) Capacity of found and lost buffers allocated in GPU global memory. This is used for the found/lost pair reports in the BP.
|
||||
|
||||
bool mDiscardStaticVsKinematic; //!< Static-vs-kinematic filtering flag. Not supported by PxBroadPhaseType::eGPU.
|
||||
bool mDiscardKinematicVsKinematic; //!< kinematic-vs-kinematic filtering flag. Not supported by PxBroadPhaseType::eGPU.
|
||||
|
||||
PX_INLINE bool isValid() const
|
||||
{
|
||||
if(PxU32(mType)>=PxBroadPhaseType::eLAST)
|
||||
return false;
|
||||
|
||||
if(mType==PxBroadPhaseType::eGPU && !mContextManager)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
typedef PxU32 PxBpIndex; //!< Broadphase index. Indexes bounds, groups and distance arrays.
|
||||
typedef PxU32 PxBpFilterGroup; //!< Broadphase filter group.
|
||||
#define PX_INVALID_BP_FILTER_GROUP 0xffffffff //!< Invalid broadphase filter group
|
||||
|
||||
/**
|
||||
\brief Retrieves the filter group for static objects.
|
||||
|
||||
Mark static objects with this group when adding them to the broadphase.
|
||||
Overlaps between static objects will not be detected. All static objects
|
||||
should have the same group.
|
||||
|
||||
\return Filter group for static objects.
|
||||
\see PxBpFilterGroup
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxBpFilterGroup PxGetBroadPhaseStaticFilterGroup();
|
||||
|
||||
/**
|
||||
\brief Retrieves a filter group for dynamic objects.
|
||||
|
||||
Mark dynamic objects with this group when adding them to the broadphase.
|
||||
Each dynamic object must have an ID, and overlaps between dynamic objects that have
|
||||
the same ID will not be detected. This is useful to dismiss overlaps between shapes
|
||||
of the same (compound) actor directly within the broadphase.
|
||||
|
||||
\param id [in] ID/Index of dynamic object
|
||||
\return Filter group for the object.
|
||||
\see PxBpFilterGroup
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxBpFilterGroup PxGetBroadPhaseDynamicFilterGroup(PxU32 id);
|
||||
|
||||
/**
|
||||
\brief Retrieves a filter group for kinematic objects.
|
||||
|
||||
Mark kinematic objects with this group when adding them to the broadphase.
|
||||
Each kinematic object must have an ID, and overlaps between kinematic objects that have
|
||||
the same ID will not be detected.
|
||||
|
||||
\param id [in] ID/Index of kinematic object
|
||||
\return Filter group for the object.
|
||||
\see PxBpFilterGroup
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxBpFilterGroup PxGetBroadPhaseKinematicFilterGroup(PxU32 id);
|
||||
|
||||
/**
|
||||
\brief Broadphase data update structure.
|
||||
|
||||
This structure is used to update the low-level broadphase (PxBroadPhase). All added, updated and removed objects
|
||||
must be batched and submitted at once to the broadphase.
|
||||
|
||||
Broadphase objects have bounds, a filtering group, and a distance. With the low-level broadphase the data must be
|
||||
externally managed by the clients of the broadphase API, and passed to the update function.
|
||||
|
||||
The provided bounds are non-inflated "base" bounds that can be further extended by the broadphase using the passed
|
||||
distance value. These can be contact offsets, or dynamically updated distance values for e.g. speculative contacts.
|
||||
Either way they are optional and can be left to zero. The broadphase implementations efficiently combine the base
|
||||
bounds with the per-object distance values at runtime.
|
||||
|
||||
The per-object filtering groups are used to discard some pairs directly within the broadphase, which is more
|
||||
efficient than reporting the pairs and culling them in a second pass.
|
||||
|
||||
\see PxBpFilterGroup PxBpIndex PxBounds3 PxBroadPhase::update
|
||||
*/
|
||||
class PxBroadPhaseUpdateData
|
||||
{
|
||||
public:
|
||||
|
||||
PxBroadPhaseUpdateData( const PxBpIndex* created, PxU32 nbCreated,
|
||||
const PxBpIndex* updated, PxU32 nbUpdated,
|
||||
const PxBpIndex* removed, PxU32 nbRemoved,
|
||||
const PxBounds3* bounds, const PxBpFilterGroup* groups, const float* distances,
|
||||
PxU32 capacity) :
|
||||
mCreated (created), mNbCreated (nbCreated),
|
||||
mUpdated (updated), mNbUpdated (nbUpdated),
|
||||
mRemoved (removed), mNbRemoved (nbRemoved),
|
||||
mBounds (bounds), mGroups (groups), mDistances (distances),
|
||||
mCapacity (capacity)
|
||||
{
|
||||
}
|
||||
|
||||
PxBroadPhaseUpdateData(const PxBroadPhaseUpdateData& other) :
|
||||
mCreated (other.mCreated), mNbCreated (other.mNbCreated),
|
||||
mUpdated (other.mUpdated), mNbUpdated (other.mNbUpdated),
|
||||
mRemoved (other.mRemoved), mNbRemoved (other.mNbRemoved),
|
||||
mBounds (other.mBounds), mGroups (other.mGroups), mDistances (other.mDistances),
|
||||
mCapacity (other.mCapacity)
|
||||
{
|
||||
}
|
||||
|
||||
PxBroadPhaseUpdateData& operator=(const PxBroadPhaseUpdateData& other);
|
||||
|
||||
const PxBpIndex* mCreated; //!< Indices of created objects.
|
||||
const PxU32 mNbCreated; //!< Number of created objects.
|
||||
|
||||
const PxBpIndex* mUpdated; //!< Indices of updated objects.
|
||||
const PxU32 mNbUpdated; //!< Number of updated objects.
|
||||
|
||||
const PxBpIndex* mRemoved; //!< Indices of removed objects.
|
||||
const PxU32 mNbRemoved; //!< Number of removed objects.
|
||||
|
||||
const PxBounds3* mBounds; //!< (Persistent) array of bounds.
|
||||
const PxBpFilterGroup* mGroups; //!< (Persistent) array of groups.
|
||||
const float* mDistances; //!< (Persistent) array of distances.
|
||||
const PxU32 mCapacity; //!< Capacity of bounds / groups / distance buffers.
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Broadphase pair.
|
||||
|
||||
A pair of indices returned by the broadphase for found or lost pairs.
|
||||
|
||||
\see PxBroadPhaseResults
|
||||
*/
|
||||
struct PxBroadPhasePair
|
||||
{
|
||||
PxBpIndex mID0; //!< Index of first object
|
||||
PxBpIndex mID1; //!< Index of second object
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Broadphase results.
|
||||
|
||||
Set of found and lost pairs after a broadphase update.
|
||||
|
||||
\see PxBroadPhasePair PxBroadPhase::fetchResults PxAABBManager::fetchResults
|
||||
*/
|
||||
struct PxBroadPhaseResults
|
||||
{
|
||||
PxBroadPhaseResults() : mNbCreatedPairs(0), mCreatedPairs(NULL), mNbDeletedPairs(0), mDeletedPairs(NULL) {}
|
||||
|
||||
PxU32 mNbCreatedPairs; //!< Number of new/found/created pairs.
|
||||
const PxBroadPhasePair* mCreatedPairs; //!< Array of new/found/created pairs.
|
||||
|
||||
PxU32 mNbDeletedPairs; //!< Number of lost/deleted pairs.
|
||||
const PxBroadPhasePair* mDeletedPairs; //!< Array of lost/deleted pairs.
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Broadphase regions.
|
||||
|
||||
An API to manage broadphase regions. Only needed for the MBP broadphase (PxBroadPhaseType::eMBP).
|
||||
|
||||
\see PxBroadPhase::getRegions()
|
||||
*/
|
||||
class PxBroadPhaseRegions
|
||||
{
|
||||
protected:
|
||||
PxBroadPhaseRegions() {}
|
||||
virtual ~PxBroadPhaseRegions() {}
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Returns number of regions currently registered in the broad-phase.
|
||||
|
||||
\return Number of regions
|
||||
*/
|
||||
virtual PxU32 getNbRegions() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets broad-phase regions.
|
||||
|
||||
\param userBuffer [out] Returned broad-phase regions
|
||||
\param bufferSize [in] Size of provided userBuffer.
|
||||
\param startIndex [in] Index of first desired region, in [0 ; getNbRegions()[
|
||||
\return Number of written out regions.
|
||||
\see PxBroadPhaseRegionInfo
|
||||
*/
|
||||
virtual PxU32 getRegions(PxBroadPhaseRegionInfo* userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Adds a new broad-phase region.
|
||||
|
||||
The total number of regions is limited to PxBroadPhaseCaps::mMaxNbRegions. If that number is exceeded, the call is ignored.
|
||||
|
||||
The newly added region will be automatically populated with already existing objects that touch it, if the
|
||||
'populateRegion' parameter is set to true. Otherwise the newly added region will be empty, and it will only be
|
||||
populated with objects when those objects are added to the simulation, or updated if they already exist.
|
||||
|
||||
Using 'populateRegion=true' has a cost, so it is best to avoid it if possible. In particular it is more efficient
|
||||
to create the empty regions first (with populateRegion=false) and then add the objects afterwards (rather than
|
||||
the opposite).
|
||||
|
||||
Objects automatically move from one region to another during their lifetime. The system keeps tracks of what
|
||||
regions a given object is in. It is legal for an object to be in an arbitrary number of regions. However if an
|
||||
object leaves all regions, or is created outside of all regions, several things happen:
|
||||
- collisions get disabled for this object
|
||||
- the object appears in the getOutOfBoundsObjects() array
|
||||
|
||||
If an out-of-bounds object, whose collisions are disabled, re-enters a valid broadphase region, then collisions
|
||||
are re-enabled for that object.
|
||||
|
||||
\param region [in] User-provided region data
|
||||
\param populateRegion [in] True to automatically populate the newly added region with existing objects touching it
|
||||
\param bounds [in] User-managed array of bounds
|
||||
\param distances [in] User-managed array of distances
|
||||
|
||||
\return Handle for newly created region, or 0xffffffff in case of failure.
|
||||
\see PxBroadPhaseRegion getOutOfBoundsObjects()
|
||||
*/
|
||||
virtual PxU32 addRegion(const PxBroadPhaseRegion& region, bool populateRegion, const PxBounds3* bounds, const float* distances) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes a broad-phase region.
|
||||
|
||||
If the region still contains objects, and if those objects do not overlap any region any more, they are not
|
||||
automatically removed from the simulation. Instead, the PxBroadPhaseCallback::onObjectOutOfBounds notification
|
||||
is used for each object. Users are responsible for removing the objects from the simulation if this is the
|
||||
desired behavior.
|
||||
|
||||
If the handle is invalid, or if a valid handle is removed twice, an error message is sent to the error stream.
|
||||
|
||||
\param handle [in] Region's handle, as returned by addRegion
|
||||
\return True if success
|
||||
*/
|
||||
virtual bool removeRegion(PxU32 handle) = 0;
|
||||
|
||||
/*
|
||||
\brief Return the number of objects that are not in any region.
|
||||
*/
|
||||
virtual PxU32 getNbOutOfBoundsObjects() const = 0;
|
||||
|
||||
/*
|
||||
\brief Return an array of objects that are not in any region.
|
||||
*/
|
||||
virtual const PxU32* getOutOfBoundsObjects() const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Low-level broadphase API.
|
||||
|
||||
This low-level API only supports batched updates and leaves most of the data management to its clients.
|
||||
|
||||
This is useful if you want to use the broadphase with your own memory buffers. Note however that the GPU broadphase
|
||||
works best with buffers allocated in CUDA memory. The getAllocator() function returns an allocator that is compatible
|
||||
with the selected broadphase. It is recommended to allocate and deallocate the broadphase data (bounds, groups, distances)
|
||||
using this allocator.
|
||||
|
||||
Important note: it must be safe to load 4 bytes past the end of the provided bounds array.
|
||||
|
||||
The high-level broadphase API (PxAABBManager) is an easier-to-use interface that automatically deals with these requirements.
|
||||
|
||||
\see PxCreateBroadPhase
|
||||
*/
|
||||
class PxBroadPhase
|
||||
{
|
||||
protected:
|
||||
PxBroadPhase() {}
|
||||
virtual ~PxBroadPhase() {}
|
||||
public:
|
||||
|
||||
/*
|
||||
\brief Releases the broadphase.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the broadphase type.
|
||||
|
||||
\return Broadphase type.
|
||||
\see PxBroadPhaseType::Enum
|
||||
*/
|
||||
virtual PxBroadPhaseType::Enum getType() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets broad-phase caps.
|
||||
|
||||
\param caps [out] Broad-phase caps
|
||||
\see PxBroadPhaseCaps
|
||||
*/
|
||||
virtual void getCaps(PxBroadPhaseCaps& caps) const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the regions API if applicable.
|
||||
|
||||
For broadphases that do not use explicit user-defined regions, this call returns NULL.
|
||||
|
||||
\return Region API, or NULL.
|
||||
\see PxBroadPhaseRegions
|
||||
*/
|
||||
virtual PxBroadPhaseRegions* getRegions() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the broadphase allocator.
|
||||
|
||||
User-provided buffers should ideally be allocated with this allocator, for best performance.
|
||||
This is especially true for the GPU broadphases, whose buffers need to be allocated in CUDA
|
||||
host memory.
|
||||
|
||||
\return The broadphase allocator.
|
||||
\see PxAllocatorCallback
|
||||
*/
|
||||
virtual PxAllocatorCallback* getAllocator() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the profiler's context ID.
|
||||
|
||||
\return The context ID.
|
||||
\see PxBroadPhaseDesc
|
||||
*/
|
||||
virtual PxU64 getContextID() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets a scratch buffer
|
||||
|
||||
Some broadphases might take advantage of a scratch buffer to limit runtime allocations.
|
||||
|
||||
All broadphases still work without providing a scratch buffer, this is an optional function
|
||||
that can potentially reduce runtime allocations.
|
||||
|
||||
\param scratchBlock [in] The scratch buffer
|
||||
\param size [in] Size of the scratch buffer in bytes
|
||||
*/
|
||||
virtual void setScratchBlock(void* scratchBlock, PxU32 size) = 0;
|
||||
|
||||
/**
|
||||
\brief Updates the broadphase and computes the lists of created/deleted pairs.
|
||||
|
||||
The provided update data describes changes to objects since the last broadphase update.
|
||||
|
||||
To benefit from potentially multithreaded implementations, it is necessary to provide a continuation
|
||||
task to the function. It is legal to pass NULL there, but the underlying (CPU) implementations will
|
||||
then run single-threaded.
|
||||
|
||||
\param updateData [in] The update data
|
||||
\param continuation [in] Continuation task to enable multi-threaded implementations, or NULL.
|
||||
\see PxBroadPhaseUpdateData PxBaseTask
|
||||
*/
|
||||
virtual void update(const PxBroadPhaseUpdateData& updateData, PxBaseTask* continuation=NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the broadphase results after an update.
|
||||
|
||||
This should be called once after each update call to retrieve the results of the broadphase. The
|
||||
results are incremental, i.e. the system only returns new and lost pairs, not all current pairs.
|
||||
|
||||
\param results [out] The broadphase results
|
||||
\see PxBroadPhaseResults
|
||||
*/
|
||||
virtual void fetchResults(PxBroadPhaseResults& results) = 0;
|
||||
|
||||
/**
|
||||
\brief Helper for single-threaded updates.
|
||||
|
||||
This short helper function performs a single-theaded update and reports the results in a single call.
|
||||
|
||||
\param results [out] The broadphase results
|
||||
\param updateData [in] The update data
|
||||
\see PxBroadPhaseUpdateData PxBroadPhaseResults
|
||||
*/
|
||||
PX_FORCE_INLINE void update(PxBroadPhaseResults& results, const PxBroadPhaseUpdateData& updateData)
|
||||
{
|
||||
update(updateData);
|
||||
fetchResults(results);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Broadphase factory function.
|
||||
|
||||
Use this function to create a new standalone broadphase.
|
||||
|
||||
\param desc [in] Broadphase descriptor
|
||||
\return Newly created broadphase, or NULL
|
||||
\see PxBroadPhase PxBroadPhaseDesc
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxBroadPhase* PxCreateBroadPhase(const PxBroadPhaseDesc& desc);
|
||||
|
||||
/**
|
||||
\brief High-level broadphase API.
|
||||
|
||||
The low-level broadphase API (PxBroadPhase) only supports batched updates and has a few non-trivial
|
||||
requirements for managing the bounds data.
|
||||
|
||||
The high-level broadphase API (PxAABBManager) is an easier-to-use one-object-at-a-time API that
|
||||
automatically deals with the quirks of the PxBroadPhase data management.
|
||||
|
||||
\see PxCreateAABBManager
|
||||
*/
|
||||
class PxAABBManager
|
||||
{
|
||||
protected:
|
||||
PxAABBManager() {}
|
||||
virtual ~PxAABBManager() {}
|
||||
public:
|
||||
|
||||
/*
|
||||
\brief Releases the AABB manager.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the underlying broadphase.
|
||||
|
||||
\return The managed broadphase.
|
||||
\see PxBroadPhase
|
||||
*/
|
||||
virtual PxBroadPhase& getBroadPhase() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the managed bounds.
|
||||
|
||||
This is needed as input parameters to functions like PxBroadPhaseRegions::addRegion.
|
||||
|
||||
\return The managed object bounds.
|
||||
\see PxBounds3
|
||||
*/
|
||||
virtual const PxBounds3* getBounds() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the managed distances.
|
||||
|
||||
This is needed as input parameters to functions like PxBroadPhaseRegions::addRegion.
|
||||
|
||||
\return The managed object distances.
|
||||
*/
|
||||
virtual const float* getDistances() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the managed filter groups.
|
||||
|
||||
\return The managed object groups.
|
||||
*/
|
||||
virtual const PxBpFilterGroup* getGroups() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the managed buffers' capacity.
|
||||
|
||||
Bounds, distances and groups buffers have the same capacity.
|
||||
|
||||
\return The managed buffers' capacity.
|
||||
*/
|
||||
virtual PxU32 getCapacity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Adds an object to the manager.
|
||||
|
||||
Objects' indices are externally managed, i.e. they must be provided by users (as opposed to handles
|
||||
that could be returned by this manager). The design allows users to identify an object by a single ID,
|
||||
and use the same ID in multiple sub-systems.
|
||||
|
||||
\param index [in] The object's index
|
||||
\param bounds [in] The object's bounds
|
||||
\param group [in] The object's filter group
|
||||
\param distance [in] The object's distance (optional)
|
||||
\see PxBpIndex PxBounds3 PxBpFilterGroup
|
||||
*/
|
||||
virtual void addObject(PxBpIndex index, const PxBounds3& bounds, PxBpFilterGroup group, float distance=0.0f) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes an object from the manager.
|
||||
|
||||
\param index [in] The object's index
|
||||
\see PxBpIndex
|
||||
*/
|
||||
virtual void removeObject(PxBpIndex index) = 0;
|
||||
|
||||
/**
|
||||
\brief Updates an object in the manager.
|
||||
|
||||
This call can update an object's bounds, distance, or both.
|
||||
It is not possible to update an object's filter group.
|
||||
|
||||
\param index [in] The object's index
|
||||
\param bounds [in] The object's updated bounds, or NULL
|
||||
\param distance [in] The object's updated distance, or NULL
|
||||
\see PxBpIndex PxBounds3
|
||||
*/
|
||||
virtual void updateObject(PxBpIndex index, const PxBounds3* bounds=NULL, const float* distance=NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Updates the broadphase and computes the lists of created/deleted pairs.
|
||||
|
||||
The data necessary for updating the broadphase is internally computed by the AABB manager.
|
||||
|
||||
To benefit from potentially multithreaded implementations, it is necessary to provide a continuation
|
||||
task to the function. It is legal to pass NULL there, but the underlying (CPU) implementations will
|
||||
then run single-threaded.
|
||||
|
||||
\param continuation [in] Continuation task to enable multi-threaded implementations, or NULL.
|
||||
\see PxBaseTask
|
||||
*/
|
||||
virtual void update(PxBaseTask* continuation=NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the broadphase results after an update.
|
||||
|
||||
This should be called once after each update call to retrieve the results of the broadphase. The
|
||||
results are incremental, i.e. the system only returns new and lost pairs, not all current pairs.
|
||||
|
||||
\param results [out] The broadphase results
|
||||
\see PxBroadPhaseResults
|
||||
*/
|
||||
virtual void fetchResults(PxBroadPhaseResults& results) = 0;
|
||||
|
||||
/**
|
||||
\brief Helper for single-threaded updates.
|
||||
|
||||
This short helper function performs a single-theaded update and reports the results in a single call.
|
||||
|
||||
\param results [out] The broadphase results
|
||||
\see PxBroadPhaseResults
|
||||
*/
|
||||
PX_FORCE_INLINE void update(PxBroadPhaseResults& results)
|
||||
{
|
||||
update();
|
||||
fetchResults(results);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief AABB manager factory function.
|
||||
|
||||
Use this function to create a new standalone high-level broadphase.
|
||||
|
||||
\param broadphase [in] The broadphase that will be managed by the AABB manager
|
||||
\return Newly created AABB manager, or NULL
|
||||
\see PxAABBManager PxBroadPhase
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxAABBManager* PxCreateAABBManager(PxBroadPhase& broadphase);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
136
modules/PhysX/physx/physx-sys/physx/physx/include/PxBuffer.h
Normal file
136
modules/PhysX/physx/physx-sys/physx/physx/include/PxBuffer.h
Normal file
@@ -0,0 +1,136 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef PX_BUFFER_H
|
||||
#define PX_BUFFER_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4435)
|
||||
#endif
|
||||
|
||||
class PxCudaContextManager;
|
||||
|
||||
/**
|
||||
\brief Specifies memory space for a PxBuffer instance.
|
||||
|
||||
@see PxBuffer
|
||||
*/
|
||||
struct PxBufferType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eHOST,
|
||||
eDEVICE
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Buffer for delayed bulk read and write operations supporting host and GPU device memory spaces.
|
||||
|
||||
@see PxPhysics::createBuffer(), PxParticleSystem
|
||||
*/
|
||||
class PX_DEPRECATED PxBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Deletes the buffer.
|
||||
|
||||
Do not keep a reference to the deleted instance.
|
||||
Unfinished operations will be flushed and synchronized on.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Provides access to internal memory (either device or pinned host memory depending on PxBufferType).
|
||||
|
||||
Unfinished operations will be flushed and synchronized on before returning.
|
||||
*/
|
||||
virtual void* map() = 0;
|
||||
|
||||
/**
|
||||
\brief Releases access to internal memory (either device or pinned host memory depending on PxBufferType).
|
||||
|
||||
\param[in] event Optional pointer to CUevent. Used to synchronize on application side work that needs to be completed before
|
||||
buffer can be accessed again.
|
||||
*/
|
||||
virtual void unmap(void* event = NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Buffer memory space type.
|
||||
|
||||
@see PxBufferType
|
||||
*/
|
||||
virtual PxBufferType::Enum getBufferType() const = 0;
|
||||
|
||||
/**
|
||||
\brief Size of buffer in bytes.
|
||||
*/
|
||||
virtual PxU64 getByteSize() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the associated PxCudaContextManager.
|
||||
|
||||
@see PxCudaContextManager.
|
||||
*/
|
||||
virtual PxCudaContextManager* getCudaContextManager() const = 0;
|
||||
|
||||
/**
|
||||
\brief Helper function to synchronize on all pending operations.
|
||||
|
||||
@see PxCudaContextManager.
|
||||
*/
|
||||
PX_INLINE void sync() { map(); unmap(); }
|
||||
|
||||
virtual void resize(PxU64 size) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~PxBuffer() {}
|
||||
PX_INLINE PxBuffer() {}
|
||||
};
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
57
modules/PhysX/physx/physx-sys/physx/physx/include/PxClient.h
Normal file
57
modules/PhysX/physx/physx-sys/physx/physx/include/PxClient.h
Normal file
@@ -0,0 +1,57 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CLIENT_H
|
||||
#define PX_CLIENT_H
|
||||
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief An ID to identify different clients for multiclient support.
|
||||
|
||||
@see PxScene::createClient()
|
||||
*/
|
||||
typedef PxU8 PxClientID;
|
||||
|
||||
/**
|
||||
\brief The predefined default PxClientID value.
|
||||
|
||||
@see PxClientID PxScene::createClient()
|
||||
*/
|
||||
static const PxClientID PX_DEFAULT_CLIENT = 0;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONE_LIMITED_CONSTRAINT_H
|
||||
#define PX_CONE_LIMITED_CONSTRAINT_H
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxVec4.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A constraint descriptor for limiting movement to a conical region.
|
||||
*/
|
||||
struct PxConeLimitedConstraint
|
||||
{
|
||||
PxConeLimitedConstraint()
|
||||
{
|
||||
mAxis = PxVec3(0.f, 0.f, 0.f);
|
||||
mAngle = 0.f;
|
||||
mLowLimit = 0.f;
|
||||
mHighLimit = 0.f;
|
||||
}
|
||||
|
||||
PxVec3 mAxis; //!< Axis of the cone in the actor space of the rigid body
|
||||
PxReal mAngle; //!< Opening angle in radians
|
||||
PxReal mLowLimit; //!< Minimum distance
|
||||
PxReal mHighLimit; //!< Maximum distance
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Compressed form of cone limit parameters
|
||||
@see PxConeLimitedConstraint
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxConeLimitParams
|
||||
{
|
||||
PxVec4 lowHighLimits; // [lowLimit, highLimit, unused, unused]
|
||||
PxVec4 axisAngle; // [axis.x, axis.y, axis.z, angle]
|
||||
}PX_ALIGN_SUFFIX(16);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
274
modules/PhysX/physx/physx-sys/physx/physx/include/PxConstraint.h
Normal file
274
modules/PhysX/physx/physx-sys/physx/physx/include/PxConstraint.h
Normal file
@@ -0,0 +1,274 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONSTRAINT_H
|
||||
#define PX_CONSTRAINT_H
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxConstraintDesc.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxRigidActor;
|
||||
class PxScene;
|
||||
class PxConstraintConnector;
|
||||
|
||||
/**
|
||||
\brief constraint flags
|
||||
|
||||
\note eBROKEN is a read only flag
|
||||
*/
|
||||
struct PxConstraintFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eBROKEN = 1<<0, //!< whether the constraint is broken
|
||||
ePROJECT_TO_ACTOR0 = 1<<1, //!< @deprecated whether actor1 should get projected to actor0 for this constraint (note: projection of a static/kinematic actor to a dynamic actor will be ignored)
|
||||
ePROJECT_TO_ACTOR1 = 1<<2, //!< @deprecated whether actor0 should get projected to actor1 for this constraint (note: projection of a static/kinematic actor to a dynamic actor will be ignored)
|
||||
ePROJECTION = ePROJECT_TO_ACTOR0 | ePROJECT_TO_ACTOR1, //!< @deprecated whether the actors should get projected for this constraint (the direction will be chosen by PhysX)
|
||||
eCOLLISION_ENABLED = 1<<3, //!< whether contacts should be generated between the objects this constraint constrains
|
||||
eVISUALIZATION = 1<<4, //!< whether this constraint should be visualized, if constraint visualization is turned on
|
||||
eDRIVE_LIMITS_ARE_FORCES = 1<<5, //!< limits for drive strength are forces rather than impulses
|
||||
eIMPROVED_SLERP = 1<<7, //!< perform preprocessing for improved accuracy on D6 Slerp Drive (this flag will be removed in a future release when preprocessing is no longer required)
|
||||
eDISABLE_PREPROCESSING = 1<<8, //!< suppress constraint preprocessing, intended for use with rowResponseThreshold. May result in worse solver accuracy for ill-conditioned constraints.
|
||||
eENABLE_EXTENDED_LIMITS = 1<<9, //!< enables extended limit ranges for angular limits (e.g., limit values > PxPi or < -PxPi)
|
||||
eGPU_COMPATIBLE = 1<<10, //!< the constraint type is supported by gpu dynamics
|
||||
eALWAYS_UPDATE = 1<<11, //!< updates the constraint each frame
|
||||
eDISABLE_CONSTRAINT = 1<<12 //!< disables the constraint. SolverPrep functions won't be called for this constraint.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief constraint flags
|
||||
@see PxConstraintFlag
|
||||
*/
|
||||
typedef PxFlags<PxConstraintFlag::Enum, PxU16> PxConstraintFlags;
|
||||
PX_FLAGS_OPERATORS(PxConstraintFlag::Enum, PxU16)
|
||||
|
||||
/**
|
||||
\brief a table of function pointers for a constraint
|
||||
|
||||
@see PxConstraint
|
||||
*/
|
||||
struct PxConstraintShaderTable
|
||||
{
|
||||
PxConstraintSolverPrep solverPrep; //!< solver constraint generation function
|
||||
PX_DEPRECATED PxConstraintProject project; //!< @deprecated constraint projection function
|
||||
PxConstraintVisualize visualize; //!< constraint visualization function
|
||||
PxConstraintFlag::Enum flag; //!< constraint flags
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A plugin class for implementing constraints
|
||||
|
||||
@see PxPhysics.createConstraint
|
||||
*/
|
||||
class PxConstraint : public PxBase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Releases a PxConstraint instance.
|
||||
|
||||
\note This call does not wake up the connected rigid bodies.
|
||||
|
||||
@see PxPhysics.createConstraint, PxBase.release()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the scene which this constraint belongs to.
|
||||
|
||||
\return Owner Scene. NULL if not part of a scene.
|
||||
|
||||
@see PxScene
|
||||
*/
|
||||
virtual PxScene* getScene() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the actors for this constraint.
|
||||
|
||||
\param[out] actor0 a reference to the pointer for the first actor
|
||||
\param[out] actor1 a reference to the pointer for the second actor
|
||||
|
||||
@see PxActor
|
||||
*/
|
||||
virtual void getActors(PxRigidActor*& actor0, PxRigidActor*& actor1) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the actors for this constraint.
|
||||
|
||||
\param[in] actor0 a reference to the pointer for the first actor
|
||||
\param[in] actor1 a reference to the pointer for the second actor
|
||||
|
||||
@see PxActor
|
||||
*/
|
||||
virtual void setActors(PxRigidActor* actor0, PxRigidActor* actor1) = 0;
|
||||
|
||||
/**
|
||||
\brief Notify the scene that the constraint shader data has been updated by the application
|
||||
*/
|
||||
virtual void markDirty() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the flags for this constraint
|
||||
|
||||
\return the constraint flags
|
||||
@see PxConstraintFlags
|
||||
*/
|
||||
virtual PxConstraintFlags getFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the flags for this constraint
|
||||
|
||||
\param[in] flags the new constraint flags
|
||||
|
||||
default: PxConstraintFlag::eDRIVE_LIMITS_ARE_FORCES
|
||||
|
||||
@see PxConstraintFlags
|
||||
*/
|
||||
virtual void setFlags(PxConstraintFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Set a flag for this constraint
|
||||
|
||||
\param[in] flag the constraint flag
|
||||
\param[in] value the new value of the flag
|
||||
|
||||
@see PxConstraintFlags
|
||||
*/
|
||||
virtual void setFlag(PxConstraintFlag::Enum flag, bool value) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the constraint force most recently applied to maintain this constraint.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running (except during PxScene::collide(),
|
||||
in PxContactModifyCallback or in contact report callbacks).
|
||||
|
||||
\param[out] linear the constraint force
|
||||
\param[out] angular the constraint torque
|
||||
*/
|
||||
virtual void getForce(PxVec3& linear, PxVec3& angular) const = 0;
|
||||
|
||||
/**
|
||||
\brief whether the constraint is valid.
|
||||
|
||||
A constraint is valid if it has at least one dynamic rigid body or articulation link. A constraint that
|
||||
is not valid may not be inserted into a scene, and therefore a static actor to which an invalid constraint
|
||||
is attached may not be inserted into a scene.
|
||||
|
||||
Invalid constraints arise only when an actor to which the constraint is attached has been deleted.
|
||||
*/
|
||||
virtual bool isValid() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the break force and torque thresholds for this constraint.
|
||||
|
||||
If either the force or torque measured at the constraint exceed these thresholds the constraint will break.
|
||||
|
||||
\param[in] linear the linear break threshold
|
||||
\param[in] angular the angular break threshold
|
||||
*/
|
||||
virtual void setBreakForce(PxReal linear, PxReal angular) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the constraint break force and torque thresholds
|
||||
|
||||
\param[out] linear the linear break threshold
|
||||
\param[out] angular the angular break threshold
|
||||
*/
|
||||
virtual void getBreakForce(PxReal& linear, PxReal& angular) const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the minimum response threshold for a constraint row
|
||||
|
||||
When using mass modification for a joint or infinite inertia for a jointed body, very stiff solver constraints can be generated which
|
||||
can destabilize simulation. Setting this value to a small positive value (e.g. 1e-8) will cause constraint rows to be ignored if very
|
||||
large changes in impulses will generate only small changes in velocity. When setting this value, also set
|
||||
PxConstraintFlag::eDISABLE_PREPROCESSING. The solver accuracy for this joint may be reduced.
|
||||
|
||||
\param[in] threshold the minimum response threshold
|
||||
|
||||
@see PxConstraintFlag::eDISABLE_PREPROCESSING
|
||||
*/
|
||||
virtual void setMinResponseThreshold(PxReal threshold) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the constraint break force and torque thresholds
|
||||
|
||||
\return the minimum response threshold for a constraint row
|
||||
*/
|
||||
virtual PxReal getMinResponseThreshold() const = 0;
|
||||
|
||||
/**
|
||||
\brief Fetch external owner of the constraint.
|
||||
|
||||
Provides a reference to the external owner of a constraint and a unique owner type ID.
|
||||
|
||||
\param[out] typeID Unique type identifier of the external object.
|
||||
\return Reference to the external object which owns the constraint.
|
||||
|
||||
@see PxConstraintConnector.getExternalReference()
|
||||
*/
|
||||
virtual void* getExternalReference(PxU32& typeID) = 0;
|
||||
|
||||
/**
|
||||
\brief Set the constraint functions for this constraint
|
||||
|
||||
\param[in] connector the constraint connector object by which the SDK communicates with the constraint.
|
||||
\param[in] shaders the shader table for the constraint
|
||||
|
||||
@see PxConstraintConnector PxConstraintSolverPrep PxConstraintProject PxConstraintVisualize
|
||||
*/
|
||||
virtual void setConstraintFunctions(PxConstraintConnector& connector, const PxConstraintShaderTable& shaders) = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxConstraint"; }
|
||||
|
||||
void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
|
||||
protected:
|
||||
PX_INLINE PxConstraint(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
|
||||
PX_INLINE PxConstraint(PxBaseFlags baseFlags) : PxBase(baseFlags), userData(NULL) {}
|
||||
virtual ~PxConstraint() {}
|
||||
virtual bool isKindOf(const char* name) const PX_OVERRIDE { return !::strcmp("PxConstraint", name) || PxBase::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,468 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONSTRAINT_DESC_H
|
||||
#define PX_CONSTRAINT_DESC_H
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx { namespace pvdsdk {
|
||||
#endif
|
||||
class PvdDataStream;
|
||||
#if !PX_DOXYGEN
|
||||
}}
|
||||
#endif
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Constraint row flags
|
||||
|
||||
These flags configure the post-processing of constraint rows and the behavior of the solver while solving constraints
|
||||
*/
|
||||
struct Px1DConstraintFlag
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
eSPRING = 1<<0, //!< whether the constraint is a spring. Mutually exclusive with eRESTITUTION. If set, eKEEPBIAS is ignored.
|
||||
eACCELERATION_SPRING = 1<<1, //!< whether the constraint is a force or acceleration spring. Only valid if eSPRING is set.
|
||||
eRESTITUTION = 1<<2, //!< whether the restitution model should be applied to generate the target velocity. Mutually exclusive with eSPRING. If restitution causes a bounces, eKEEPBIAS is ignored
|
||||
eKEEPBIAS = 1<<3, //!< whether to keep the error term when solving for velocity. Ignored if restitution generates bounce, or eSPRING is set.
|
||||
eOUTPUT_FORCE = 1<<4, //!< whether to accumulate the force value from this constraint in the force total that is reported for the constraint and tested for breakage
|
||||
eHAS_DRIVE_LIMIT = 1<<5, //!< whether the constraint has a drive force limit (which will be scaled by dt unless PxConstraintFlag::eLIMITS_ARE_FORCES is set)
|
||||
eANGULAR_CONSTRAINT = 1<<6, //!< whether this is an angular or linear constraint
|
||||
eDRIVE_ROW = 1<<7 //!< whether the constraint's geometric error should drive the target velocity
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<Px1DConstraintFlag::Type, PxU16> Px1DConstraintFlags;
|
||||
PX_FLAGS_OPERATORS(Px1DConstraintFlag::Type, PxU16)
|
||||
|
||||
/**
|
||||
\brief Constraint type hints which the solver uses to optimize constraint handling
|
||||
*/
|
||||
struct PxConstraintSolveHint
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE = 0, //!< no special properties
|
||||
eACCELERATION1 = 256, //!< a group of acceleration drive constraints with the same stiffness and drive parameters
|
||||
eSLERP_SPRING = 258, //!< temporary special value to identify SLERP drive rows
|
||||
eACCELERATION2 = 512, //!< a group of acceleration drive constraints with the same stiffness and drive parameters
|
||||
eACCELERATION3 = 768, //!< a group of acceleration drive constraints with the same stiffness and drive parameters
|
||||
eROTATIONAL_EQUALITY = 1024, //!< rotational equality constraints with no force limit and no velocity target
|
||||
eROTATIONAL_INEQUALITY = 1025, //!< rotational inequality constraints with (0, PX_MAX_FLT) force limits
|
||||
eEQUALITY = 2048, //!< equality constraints with no force limit and no velocity target
|
||||
eINEQUALITY = 2049 //!< inequality constraints with (0, PX_MAX_FLT) force limits
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A one-dimensional constraint
|
||||
|
||||
A constraint is expressed as a set of 1-dimensional constraint rows which define the required constraint
|
||||
on the objects' velocities.
|
||||
|
||||
Each constraint is either a hard constraint or a spring. We define the velocity at the constraint to be
|
||||
the quantity
|
||||
|
||||
v = body0vel.dot(lin0,ang0) - body1vel.dot(lin1, ang1)
|
||||
|
||||
For a hard constraint, the solver attempts to generate
|
||||
|
||||
1. a set of velocities for the objects which, when integrated, respect the constraint errors:
|
||||
|
||||
v + (geometricError / timestep) = velocityTarget
|
||||
|
||||
2. a set of velocities for the objects which respect the constraints:
|
||||
|
||||
v = velocityTarget
|
||||
|
||||
Hard constraints support restitution: if the impact velocity exceeds the bounce threshold, then the target velocity
|
||||
of the constraint will be set to restitution * -v
|
||||
|
||||
Alternatively, the solver can attempt to resolve the velocity constraint as an implicit spring:
|
||||
|
||||
F = stiffness * -geometricError + damping * (velocityTarget - v)
|
||||
|
||||
where F is the constraint force or acceleration. Springs are fully implicit: that is, the force or acceleration
|
||||
is a function of the position and velocity after the solve.
|
||||
|
||||
All constraints support limits on the minimum or maximum impulse applied.
|
||||
*/
|
||||
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxSpringModifiers
|
||||
{
|
||||
PxReal stiffness; //!< spring parameter, for spring constraints
|
||||
PxReal damping; //!< damping parameter, for spring constraints
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxRestitutionModifiers
|
||||
{
|
||||
PxReal restitution; //!< restitution parameter for determining additional "bounce"
|
||||
PxReal velocityThreshold; //!< minimum impact velocity for bounce
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
PX_ALIGN_PREFIX(16)
|
||||
union Px1DConstraintMods {
|
||||
PxSpringModifiers spring;
|
||||
PxRestitutionModifiers bounce;
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct Px1DConstraint
|
||||
{
|
||||
PxVec3 linear0; //!< linear component of velocity jacobian in world space
|
||||
PxReal geometricError; //!< geometric error of the constraint along this axis
|
||||
PxVec3 angular0; //!< angular component of velocity jacobian in world space
|
||||
PxReal velocityTarget; //!< velocity target for the constraint along this axis
|
||||
|
||||
PxVec3 linear1; //!< linear component of velocity jacobian in world space
|
||||
PxReal minImpulse; //!< minimum impulse the solver may apply to enforce this constraint
|
||||
PxVec3 angular1; //!< angular component of velocity jacobian in world space
|
||||
PxReal maxImpulse; //!< maximum impulse the solver may apply to enforce this constraint
|
||||
|
||||
Px1DConstraintMods mods;
|
||||
|
||||
PxReal forInternalUse; //!< for internal use only
|
||||
PxU16 flags; //!< a set of Px1DConstraintFlags
|
||||
PxU16 solveHint; //!< constraint optimization hint, should be an element of PxConstraintSolveHint
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief Flags for determining which components of the constraint should be visualized.
|
||||
|
||||
@see PxConstraintVisualize
|
||||
*/
|
||||
struct PxConstraintVisualizationFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eLOCAL_FRAMES = 1, //!< visualize constraint frames
|
||||
eLIMITS = 2 //!< visualize constraint limits
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Struct for specifying mass scaling for a pair of rigids
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxConstraintInvMassScale
|
||||
{
|
||||
//= ATTENTION! =====================================================================================
|
||||
// Changing the data layout of this class breaks the binary serialization format. See comments for
|
||||
// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
|
||||
// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
|
||||
// accordingly.
|
||||
//==================================================================================================
|
||||
|
||||
PxReal linear0; //!< multiplier for inverse mass of body0
|
||||
PxReal angular0; //!< multiplier for inverse MoI of body0
|
||||
PxReal linear1; //!< multiplier for inverse mass of body1
|
||||
PxReal angular1; //!< multiplier for inverse MoI of body1
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale(){}
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxConstraintInvMassScale(PxReal lin0, PxReal ang0, PxReal lin1, PxReal ang1) : linear0(lin0), angular0(ang0), linear1(lin1), angular1(ang1){}
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief Solver constraint generation shader
|
||||
|
||||
This function is called by the constraint solver framework. The function must be reentrant, since it may be called simultaneously
|
||||
from multiple threads, and should access only the arguments passed into it.
|
||||
|
||||
Developers writing custom constraints are encouraged to read the documentation in the user guide and the implementation code in PhysXExtensions.
|
||||
|
||||
\param[out] constraints An array of solver constraint rows to be filled in
|
||||
\param[out] bodyAWorldOffset The origin point (offset from the position vector of bodyA's center of mass) at which the constraint is resolved. This value does not affect how constraints are solved, only the constraint force reported.
|
||||
\param[in] maxConstraints The size of the constraint buffer. At most this many constraints rows may be written
|
||||
\param[out] invMassScale The inverse mass and inertia scales for the constraint
|
||||
\param[in] constantBlock The constant data block
|
||||
\param[in] bodyAToWorld The center of mass frame of the first constrained body (the identity transform if the first actor is static, or if a NULL actor pointer was provided for it)
|
||||
\param[in] bodyBToWorld The center of mass frame of the second constrained body (the identity transform if the second actor is static, or if a NULL actor pointer was provided for it)
|
||||
\param[in] useExtendedLimits Enables limit ranges outside of (-PI, PI)
|
||||
\param[out] cAtW The world space location of body A's joint frame (position only)
|
||||
\param[out] cBtW The world space location of body B's joint frame (position only)
|
||||
|
||||
\return the number of constraint rows written.
|
||||
*/
|
||||
typedef PxU32 (*PxConstraintSolverPrep)(Px1DConstraint* constraints,
|
||||
PxVec3p& bodyAWorldOffset,
|
||||
PxU32 maxConstraints,
|
||||
PxConstraintInvMassScale& invMassScale,
|
||||
const void* constantBlock,
|
||||
const PxTransform& bodyAToWorld,
|
||||
const PxTransform& bodyBToWorld,
|
||||
bool useExtendedLimits,
|
||||
PxVec3p& cAtW,
|
||||
PxVec3p& cBtW);
|
||||
|
||||
/**
|
||||
\brief Solver constraint projection shader
|
||||
|
||||
This function is called by the constraint post-solver framework. The function must be reentrant, since it may be called simultaneously
|
||||
from multiple threads and should access only the arguments passed into it.
|
||||
|
||||
\param[in] constantBlock The constant data block
|
||||
\param[out] bodyAToWorld The center of mass frame of the first constrained body (the identity if the actor is static or a NULL pointer was provided for it)
|
||||
\param[out] bodyBToWorld The center of mass frame of the second constrained body (the identity if the actor is static or a NULL pointer was provided for it)
|
||||
\param[in] projectToA True if the constraint should be projected by moving the second body towards the first, false if the converse
|
||||
|
||||
@deprecated
|
||||
*/
|
||||
typedef PX_DEPRECATED void (*PxConstraintProject)(const void* constantBlock,
|
||||
PxTransform& bodyAToWorld,
|
||||
PxTransform& bodyBToWorld,
|
||||
bool projectToA);
|
||||
|
||||
/**
|
||||
\brief API used to visualize details about a constraint.
|
||||
*/
|
||||
class PxConstraintVisualizer
|
||||
{
|
||||
protected:
|
||||
virtual ~PxConstraintVisualizer(){}
|
||||
public:
|
||||
/** \brief Visualize joint frames
|
||||
|
||||
\param[in] parent Parent transformation
|
||||
\param[in] child Child transformation
|
||||
*/
|
||||
virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) = 0;
|
||||
|
||||
/** \brief Visualize joint linear limit
|
||||
|
||||
\param[in] t0 Base transformation
|
||||
\param[in] t1 End transformation
|
||||
\param[in] value Distance
|
||||
\param[in] active State of the joint - active/inactive
|
||||
*/
|
||||
virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, PxReal value, bool active) = 0;
|
||||
|
||||
/** \brief Visualize joint angular limit
|
||||
|
||||
\param[in] t0 Transformation for the visualization
|
||||
\param[in] lower Lower limit angle
|
||||
\param[in] upper Upper limit angle
|
||||
\param[in] active State of the joint - active/inactive
|
||||
*/
|
||||
virtual void visualizeAngularLimit(const PxTransform& t0, PxReal lower, PxReal upper, bool active) = 0;
|
||||
|
||||
/** \brief Visualize limit cone
|
||||
|
||||
\param[in] t Transformation for the visualization
|
||||
\param[in] tanQSwingY Tangent of the quarter Y angle
|
||||
\param[in] tanQSwingZ Tangent of the quarter Z angle
|
||||
\param[in] active State of the joint - active/inactive
|
||||
*/
|
||||
virtual void visualizeLimitCone(const PxTransform& t, PxReal tanQSwingY, PxReal tanQSwingZ, bool active) = 0;
|
||||
|
||||
/** \brief Visualize joint double cone
|
||||
|
||||
\param[in] t Transformation for the visualization
|
||||
\param[in] angle Limit angle
|
||||
\param[in] active State of the joint - active/inactive
|
||||
*/
|
||||
virtual void visualizeDoubleCone(const PxTransform& t, PxReal angle, bool active) = 0;
|
||||
|
||||
/** \brief Visualize line
|
||||
|
||||
\param[in] p0 Start position
|
||||
\param[in] p1 End postion
|
||||
\param[in] color Color
|
||||
*/
|
||||
virtual void visualizeLine(const PxVec3& p0, const PxVec3& p1, PxU32 color) = 0;
|
||||
};
|
||||
|
||||
/** \brief Solver constraint visualization function
|
||||
|
||||
This function is called by the constraint post-solver framework to visualize the constraint
|
||||
|
||||
\param[out] visualizer The render buffer to render to
|
||||
\param[in] constantBlock The constant data block
|
||||
\param[in] body0Transform The center of mass frame of the first constrained body (the identity if the actor is static, or a NULL pointer was provided for it)
|
||||
\param[in] body1Transform The center of mass frame of the second constrained body (the identity if the actor is static, or a NULL pointer was provided for it)
|
||||
\param[in] flags The visualization flags (PxConstraintVisualizationFlag)
|
||||
|
||||
@see PxRenderBuffer
|
||||
*/
|
||||
typedef void (*PxConstraintVisualize)(PxConstraintVisualizer& visualizer,
|
||||
const void* constantBlock,
|
||||
const PxTransform& body0Transform,
|
||||
const PxTransform& body1Transform,
|
||||
PxU32 flags);
|
||||
|
||||
/**
|
||||
\brief Flags for determining how PVD should serialize a constraint update
|
||||
|
||||
@see PxConstraintConnector::updatePvdProperties, PvdSceneClient::updateConstraint
|
||||
*/
|
||||
struct PxPvdUpdateType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
CREATE_INSTANCE, //!< triggers createPvdInstance call, creates an instance of a constraint
|
||||
RELEASE_INSTANCE, //!< triggers releasePvdInstance call, releases an instance of a constraint
|
||||
UPDATE_ALL_PROPERTIES, //!< triggers updatePvdProperties call, updates all properties of a constraint
|
||||
UPDATE_SIM_PROPERTIES //!< triggers simUpdate call, updates all simulation properties of a constraint
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief This class connects a custom constraint to the SDK
|
||||
|
||||
This class connects a custom constraint to the SDK, and functions are called by the SDK
|
||||
to query the custom implementation for specific information to pass on to the application
|
||||
or inform the constraint when the application makes calls into the SDK which will update
|
||||
the custom constraint's internal implementation
|
||||
*/
|
||||
class PxConstraintConnector
|
||||
{
|
||||
public:
|
||||
/** \brief Pre-simulation data preparation
|
||||
when the constraint is marked dirty, this function is called at the start of the simulation
|
||||
step for the SDK to copy the constraint data block.
|
||||
*/
|
||||
virtual void* prepareData() = 0;
|
||||
|
||||
/**
|
||||
\brief this function is called by the SDK to update PVD's view of it
|
||||
*/
|
||||
PX_DEPRECATED virtual bool updatePvdProperties(physx::pvdsdk::PvdDataStream& pvdConnection,
|
||||
const PxConstraint* c,
|
||||
PxPvdUpdateType::Enum updateType) const = 0;
|
||||
|
||||
/**
|
||||
\brief this function is called by the SDK to update OmniPVD's view of it
|
||||
*/
|
||||
PX_DEPRECATED virtual void updateOmniPvdProperties() const = 0;
|
||||
|
||||
/**
|
||||
\brief Constraint release callback
|
||||
|
||||
When the SDK deletes a PxConstraint object this function is called by the SDK. In general
|
||||
custom constraints should not be deleted directly by applications: rather, the constraint
|
||||
should respond to a release() request by calling PxConstraint::release(), then wait for
|
||||
this call to release its own resources.
|
||||
|
||||
This function is also called when a PxConstraint object is deleted on cleanup due to
|
||||
destruction of the PxPhysics object.
|
||||
*/
|
||||
virtual void onConstraintRelease() = 0;
|
||||
|
||||
/**
|
||||
\brief Center-of-mass shift callback
|
||||
|
||||
This function is called by the SDK when the CoM of one of the actors is moved. Since the
|
||||
API specifies constraint positions relative to actors, and the constraint shader functions
|
||||
are supplied with coordinates relative to bodies, some synchronization is usually required
|
||||
when the application moves an object's center of mass.
|
||||
*/
|
||||
virtual void onComShift(PxU32 actor) = 0;
|
||||
|
||||
/**
|
||||
\brief Origin shift callback
|
||||
|
||||
This function is called by the SDK when the scene origin gets shifted and allows to adjust
|
||||
custom data which contains world space transforms.
|
||||
|
||||
\note If the adjustments affect constraint shader data, it is necessary to call PxConstraint::markDirty()
|
||||
to make sure that the data gets synced at the beginning of the next simulation step.
|
||||
|
||||
\param[in] shift Translation vector the origin is shifted by.
|
||||
|
||||
@see PxScene.shiftOrigin()
|
||||
*/
|
||||
virtual void onOriginShift(const PxVec3& shift) = 0;
|
||||
|
||||
/**
|
||||
\brief Fetches external data for a constraint.
|
||||
|
||||
This function is used by the SDK to acquire a reference to the owner of a constraint and a unique
|
||||
owner type ID. This information will be passed on when a breakable constraint breaks or when
|
||||
#PxConstraint::getExternalReference() is called.
|
||||
|
||||
\param[out] typeID Unique type identifier of the external object. The value 0xffffffff is reserved and should not be used. Furthermore, if the PhysX extensions library is used, some other IDs are reserved already (see PxConstraintExtIDs)
|
||||
\return Reference to the external object which owns the constraint.
|
||||
|
||||
@see PxConstraintInfo PxSimulationEventCallback.onConstraintBreak()
|
||||
*/
|
||||
PX_DEPRECATED virtual void* getExternalReference(PxU32& typeID) = 0;
|
||||
|
||||
/**
|
||||
\brief Obtain a reference to a PxBase interface if the constraint has one.
|
||||
|
||||
If the constraint does not implement the PxBase interface, it should return NULL.
|
||||
*/
|
||||
virtual PxBase* getSerializable() = 0;
|
||||
|
||||
/**
|
||||
\brief Obtain the shader function pointer used to prep rows for this constraint
|
||||
*/
|
||||
PX_DEPRECATED virtual PxConstraintSolverPrep getPrep() const = 0;
|
||||
|
||||
/**
|
||||
\brief Obtain the pointer to the constraint's constant data
|
||||
*/
|
||||
virtual const void* getConstantBlock() const = 0;
|
||||
|
||||
/**
|
||||
\brief Let the connector know it has been connected to a constraint.
|
||||
*/
|
||||
virtual void connectToConstraint(PxConstraint*) {}
|
||||
|
||||
/**
|
||||
\brief virtual destructor
|
||||
*/
|
||||
virtual ~PxConstraintConnector() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
676
modules/PhysX/physx/physx-sys/physx/physx/include/PxContact.h
Normal file
676
modules/PhysX/physx/physx-sys/physx/physx/include/PxContact.h
Normal file
@@ -0,0 +1,676 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTACT_H
|
||||
#define PX_CONTACT_H
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "PxNodeIndex.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4324) // Padding was added at the end of a structure because of a __declspec(align) value.
|
||||
#endif
|
||||
|
||||
#define PXC_CONTACT_NO_FACE_INDEX 0xffffffff
|
||||
|
||||
class PxActor;
|
||||
|
||||
/**
|
||||
\brief Struct for specifying mass modification for a pair of rigids
|
||||
\deprecated Use #PxConstraintInvMassScale instead. Deprecated since PhysX version 5.1.
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxMassModificationProps
|
||||
{
|
||||
PxReal mInvMassScale0;
|
||||
PxReal mInvInertiaScale0;
|
||||
PxReal mInvMassScale1;
|
||||
PxReal mInvInertiaScale1;
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief Header for a contact patch where all points share same material and normal
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxContactPatch
|
||||
{
|
||||
enum PxContactPatchFlags
|
||||
{
|
||||
eHAS_FACE_INDICES = 1, //!< Indicates this contact stream has face indices.
|
||||
eMODIFIABLE = 2, //!< Indicates this contact stream is modifiable.
|
||||
eFORCE_NO_RESPONSE = 4, //!< Indicates this contact stream is notify-only (no contact response).
|
||||
eHAS_MODIFIED_MASS_RATIOS = 8, //!< Indicates this contact stream has modified mass ratios
|
||||
eHAS_TARGET_VELOCITY = 16, //!< Indicates this contact stream has target velocities set
|
||||
eHAS_MAX_IMPULSE = 32, //!< Indicates this contact stream has max impulses set
|
||||
eREGENERATE_PATCHES = 64, //!< Indicates this contact stream needs patches re-generated. This is required if the application modified either the contact normal or the material properties
|
||||
eCOMPRESSED_MODIFIED_CONTACT = 128
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Modifiers for scaling the inertia of the involved bodies
|
||||
*/
|
||||
PX_ALIGN(16, PxMassModificationProps mMassModification); //16
|
||||
|
||||
/**
|
||||
\brief Contact normal
|
||||
*/
|
||||
PX_ALIGN(16, PxVec3 normal); //28
|
||||
|
||||
/**
|
||||
\brief Restitution coefficient
|
||||
*/
|
||||
PxReal restitution; //32
|
||||
|
||||
/**
|
||||
\brief Dynamic friction coefficient
|
||||
*/
|
||||
PxReal dynamicFriction; //36
|
||||
|
||||
/**
|
||||
\brief Static friction coefficient
|
||||
*/
|
||||
PxReal staticFriction; //40
|
||||
|
||||
/**
|
||||
\brief Damping coefficient (for compliant contacts)
|
||||
*/
|
||||
PxReal damping; //44
|
||||
|
||||
/**
|
||||
\brief Index of the first contact in the patch
|
||||
*/
|
||||
PxU16 startContactIndex; //46
|
||||
|
||||
/**
|
||||
\brief The number of contacts in this patch
|
||||
*/
|
||||
PxU8 nbContacts; //47 //Can be a U8
|
||||
|
||||
/**
|
||||
\brief The combined material flag of two actors that come in contact
|
||||
@see PxMaterialFlag, PxCombineMode
|
||||
*/
|
||||
PxU8 materialFlags; //48 //Can be a U16
|
||||
|
||||
/**
|
||||
\brief The PxContactPatchFlags for this patch
|
||||
*/
|
||||
PxU16 internalFlags; //50 //Can be a U16
|
||||
|
||||
/**
|
||||
\brief Material index of first body
|
||||
*/
|
||||
PxU16 materialIndex0; //52 //Can be a U16
|
||||
|
||||
/**
|
||||
\brief Material index of second body
|
||||
*/
|
||||
PxU16 materialIndex1; //54 //Can be a U16
|
||||
|
||||
PxU16 pad[5]; //64
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief Contact point data
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxContact
|
||||
{
|
||||
/**
|
||||
\brief Contact point in world space
|
||||
*/
|
||||
PxVec3 contact; //12
|
||||
/**
|
||||
\brief Separation value (negative implies penetration).
|
||||
*/
|
||||
PxReal separation; //16
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief Contact point data with additional target and max impulse values
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxExtendedContact : public PxContact
|
||||
{
|
||||
/**
|
||||
\brief Target velocity
|
||||
*/
|
||||
PX_ALIGN(16, PxVec3 targetVelocity); //28
|
||||
/**
|
||||
\brief Maximum impulse
|
||||
*/
|
||||
PxReal maxImpulse; //32
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief A modifiable contact point. This has additional fields per-contact to permit modification by user.
|
||||
\note Not all fields are currently exposed to the user.
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxModifiableContact : public PxExtendedContact
|
||||
{
|
||||
/**
|
||||
\brief Contact normal
|
||||
*/
|
||||
PX_ALIGN(16, PxVec3 normal); //44
|
||||
/**
|
||||
\brief Restitution coefficient
|
||||
*/
|
||||
PxReal restitution; //48
|
||||
|
||||
/**
|
||||
\brief Material Flags
|
||||
*/
|
||||
PxU32 materialFlags; //52
|
||||
|
||||
/**
|
||||
\brief Shape A's material index
|
||||
*/
|
||||
PxU16 materialIndex0; //54
|
||||
/**
|
||||
\brief Shape B's material index
|
||||
*/
|
||||
PxU16 materialIndex1; //56
|
||||
/**
|
||||
\brief static friction coefficient
|
||||
*/
|
||||
PxReal staticFriction; //60
|
||||
/**
|
||||
\brief dynamic friction coefficient
|
||||
*/
|
||||
PxReal dynamicFriction; //64
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
/**
|
||||
\brief A class to iterate over a compressed contact stream. This supports read-only access to the various contact formats.
|
||||
*/
|
||||
struct PxContactStreamIterator
|
||||
{
|
||||
enum StreamFormat
|
||||
{
|
||||
eSIMPLE_STREAM,
|
||||
eMODIFIABLE_STREAM,
|
||||
eCOMPRESSED_MODIFIABLE_STREAM
|
||||
};
|
||||
/**
|
||||
\brief Utility zero vector to optimize functions returning zero vectors when a certain flag isn't set.
|
||||
\note This allows us to return by reference instead of having to return by value. Returning by value will go via memory (registers -> stack -> registers), which can
|
||||
cause performance issues on certain platforms.
|
||||
*/
|
||||
PxVec3 zero;
|
||||
|
||||
/**
|
||||
\brief The patch headers.
|
||||
*/
|
||||
const PxContactPatch* patch;
|
||||
|
||||
/**
|
||||
\brief The contacts
|
||||
*/
|
||||
const PxContact* contact;
|
||||
|
||||
/**
|
||||
\brief The contact triangle face index
|
||||
*/
|
||||
const PxU32* faceIndice;
|
||||
|
||||
/**
|
||||
\brief The total number of patches in this contact stream
|
||||
*/
|
||||
PxU32 totalPatches;
|
||||
|
||||
/**
|
||||
\brief The total number of contact points in this stream
|
||||
*/
|
||||
PxU32 totalContacts;
|
||||
|
||||
/**
|
||||
\brief The current contact index
|
||||
*/
|
||||
PxU32 nextContactIndex;
|
||||
|
||||
/**
|
||||
\brief The current patch Index
|
||||
*/
|
||||
PxU32 nextPatchIndex;
|
||||
|
||||
/**
|
||||
\brief Size of contact patch header
|
||||
\note This varies whether the patch is modifiable or not.
|
||||
*/
|
||||
PxU32 contactPatchHeaderSize;
|
||||
|
||||
/**
|
||||
\brief Contact point size
|
||||
\note This varies whether the patch has feature indices or is modifiable.
|
||||
*/
|
||||
PxU32 contactPointSize;
|
||||
|
||||
/**
|
||||
\brief The stream format
|
||||
*/
|
||||
StreamFormat mStreamFormat;
|
||||
|
||||
/**
|
||||
\brief Indicates whether this stream is notify-only or not.
|
||||
*/
|
||||
PxU32 forceNoResponse;
|
||||
|
||||
/**
|
||||
\brief Internal helper for stepping the contact stream iterator
|
||||
*/
|
||||
bool pointStepped;
|
||||
|
||||
/**
|
||||
\brief Specifies if this contactPatch has face indices (handled as bool)
|
||||
@see faceIndice
|
||||
*/
|
||||
PxU32 hasFaceIndices;
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxContactStreamIterator(const PxU8* contactPatches, const PxU8* contactPoints, const PxU32* contactFaceIndices, PxU32 nbPatches, PxU32 nbContacts)
|
||||
: zero(0.f)
|
||||
{
|
||||
bool modify = false;
|
||||
bool compressedModify = false;
|
||||
bool response = false;
|
||||
bool indices = false;
|
||||
|
||||
PxU32 pointSize = 0;
|
||||
PxU32 patchHeaderSize = sizeof(PxContactPatch);
|
||||
|
||||
const PxContactPatch* patches = reinterpret_cast<const PxContactPatch*>(contactPatches);
|
||||
|
||||
if(patches)
|
||||
{
|
||||
modify = (patches->internalFlags & PxContactPatch::eMODIFIABLE) != 0;
|
||||
compressedModify = (patches->internalFlags & PxContactPatch::eCOMPRESSED_MODIFIED_CONTACT) != 0;
|
||||
indices = (patches->internalFlags & PxContactPatch::eHAS_FACE_INDICES) != 0;
|
||||
|
||||
patch = patches;
|
||||
|
||||
contact = reinterpret_cast<const PxContact*>(contactPoints);
|
||||
|
||||
faceIndice = contactFaceIndices;
|
||||
|
||||
pointSize = compressedModify ? sizeof(PxExtendedContact) : modify ? sizeof(PxModifiableContact) : sizeof(PxContact);
|
||||
|
||||
response = (patch->internalFlags & PxContactPatch::eFORCE_NO_RESPONSE) == 0;
|
||||
}
|
||||
|
||||
|
||||
mStreamFormat = compressedModify ? eCOMPRESSED_MODIFIABLE_STREAM : modify ? eMODIFIABLE_STREAM : eSIMPLE_STREAM;
|
||||
hasFaceIndices = PxU32(indices);
|
||||
forceNoResponse = PxU32(!response);
|
||||
|
||||
contactPatchHeaderSize = patchHeaderSize;
|
||||
contactPointSize = pointSize;
|
||||
nextPatchIndex = 0;
|
||||
nextContactIndex = 0;
|
||||
totalContacts = nbContacts;
|
||||
totalPatches = nbPatches;
|
||||
|
||||
pointStepped = false;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns whether there are more patches in this stream.
|
||||
\return Whether there are more patches in this stream.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE bool hasNextPatch() const
|
||||
{
|
||||
return nextPatchIndex < totalPatches;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns the total contact count.
|
||||
\return Total contact count.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getTotalContactCount() const
|
||||
{
|
||||
return totalContacts;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns the total patch count.
|
||||
\return Total patch count.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getTotalPatchCount() const
|
||||
{
|
||||
return totalPatches;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Advances iterator to next contact patch.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_INLINE void nextPatch()
|
||||
{
|
||||
PX_ASSERT(nextPatchIndex < totalPatches);
|
||||
if(nextPatchIndex)
|
||||
{
|
||||
if(nextContactIndex < patch->nbContacts)
|
||||
{
|
||||
PxU32 nbToStep = patch->nbContacts - this->nextContactIndex;
|
||||
contact = reinterpret_cast<const PxContact*>(reinterpret_cast<const PxU8*>(contact) + contactPointSize * nbToStep);
|
||||
}
|
||||
patch = reinterpret_cast<const PxContactPatch*>(reinterpret_cast<const PxU8*>(patch) + contactPatchHeaderSize);
|
||||
}
|
||||
nextPatchIndex++;
|
||||
nextContactIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns if the current patch has more contacts.
|
||||
\return If there are more contacts in the current patch.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE bool hasNextContact() const
|
||||
{
|
||||
return nextContactIndex < (patch->nbContacts);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Advances to the next contact in the patch.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE void nextContact()
|
||||
{
|
||||
PX_ASSERT(nextContactIndex < patch->nbContacts);
|
||||
if(pointStepped)
|
||||
{
|
||||
contact = reinterpret_cast<const PxContact*>(reinterpret_cast<const PxU8*>(contact) + contactPointSize);
|
||||
faceIndice++;
|
||||
}
|
||||
nextContactIndex++;
|
||||
pointStepped = true;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the current contact's normal
|
||||
\return The current contact's normal.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3& getContactNormal() const
|
||||
{
|
||||
return getContactPatch().normal;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the inverse mass scale for body 0.
|
||||
\return The inverse mass scale for body 0.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getInvMassScale0() const
|
||||
{
|
||||
return patch->mMassModification.mInvMassScale0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the inverse mass scale for body 1.
|
||||
\return The inverse mass scale for body 1.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getInvMassScale1() const
|
||||
{
|
||||
return patch->mMassModification.mInvMassScale1;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the inverse inertia scale for body 0.
|
||||
\return The inverse inertia scale for body 0.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getInvInertiaScale0() const
|
||||
{
|
||||
return patch->mMassModification.mInvInertiaScale0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the inverse inertia scale for body 1.
|
||||
\return The inverse inertia scale for body 1.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getInvInertiaScale1() const
|
||||
{
|
||||
return patch->mMassModification.mInvInertiaScale1;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's max impulse.
|
||||
\return The contact's max impulse.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getMaxImpulse() const
|
||||
{
|
||||
return mStreamFormat != eSIMPLE_STREAM ? getExtendedContact().maxImpulse : PX_MAX_REAL;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's target velocity.
|
||||
\return The contact's target velocity.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3& getTargetVel() const
|
||||
{
|
||||
return mStreamFormat != eSIMPLE_STREAM ? getExtendedContact().targetVelocity : zero;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's contact point.
|
||||
\return The contact's contact point.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3& getContactPoint() const
|
||||
{
|
||||
return contact->contact;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's separation.
|
||||
\return The contact's separation.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getSeparation() const
|
||||
{
|
||||
return contact->separation;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's face index for shape 0.
|
||||
\return The contact's face index for shape 0.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getFaceIndex0() const
|
||||
{
|
||||
return PXC_CONTACT_NO_FACE_INDEX;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's face index for shape 1.
|
||||
\return The contact's face index for shape 1.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getFaceIndex1() const
|
||||
{
|
||||
return hasFaceIndices ? *faceIndice : PXC_CONTACT_NO_FACE_INDEX;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's static friction coefficient.
|
||||
\return The contact's static friction coefficient.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getStaticFriction() const
|
||||
{
|
||||
return getContactPatch().staticFriction;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's dynamic friction coefficient.
|
||||
\return The contact's dynamic friction coefficient.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getDynamicFriction() const
|
||||
{
|
||||
return getContactPatch().dynamicFriction;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's restitution coefficient.
|
||||
\return The contact's restitution coefficient.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getRestitution() const
|
||||
{
|
||||
return getContactPatch().restitution;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's damping value.
|
||||
\return The contact's damping value.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getDamping() const
|
||||
{
|
||||
return getContactPatch().damping;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's material flags.
|
||||
\return The contact's material flags.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMaterialFlags() const
|
||||
{
|
||||
return getContactPatch().materialFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's material index for shape 0.
|
||||
\return The contact's material index for shape 0.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU16 getMaterialIndex0() const
|
||||
{
|
||||
return PxU16(getContactPatch().materialIndex0);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Gets the contact's material index for shape 1.
|
||||
\return The contact's material index for shape 1.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU16 getMaterialIndex1() const
|
||||
{
|
||||
return PxU16(getContactPatch().materialIndex1);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Advances the contact stream iterator to a specific contact index.
|
||||
\return True if advancing was possible
|
||||
*/
|
||||
bool advanceToIndex(const PxU32 initialIndex)
|
||||
{
|
||||
PX_ASSERT(this->nextPatchIndex == 0 && this->nextContactIndex == 0);
|
||||
|
||||
PxU32 numToAdvance = initialIndex;
|
||||
|
||||
if(numToAdvance == 0)
|
||||
{
|
||||
PX_ASSERT(hasNextPatch());
|
||||
nextPatch();
|
||||
return true;
|
||||
}
|
||||
|
||||
while(numToAdvance)
|
||||
{
|
||||
while(hasNextPatch())
|
||||
{
|
||||
nextPatch();
|
||||
PxU32 patchSize = patch->nbContacts;
|
||||
if(numToAdvance <= patchSize)
|
||||
{
|
||||
contact = reinterpret_cast<const PxContact*>(reinterpret_cast<const PxU8*>(contact) + contactPointSize * numToAdvance);
|
||||
nextContactIndex += numToAdvance;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
numToAdvance -= patchSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
\brief Internal helper
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxContactPatch& getContactPatch() const
|
||||
{
|
||||
return *static_cast<const PxContactPatch*>(patch);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxExtendedContact& getExtendedContact() const
|
||||
{
|
||||
PX_ASSERT(mStreamFormat == eMODIFIABLE_STREAM || mStreamFormat == eCOMPRESSED_MODIFIABLE_STREAM);
|
||||
return *static_cast<const PxExtendedContact*>(contact);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Contains contact information for a contact reported by the direct-GPU contact report API. See PxScene::copyContactData().
|
||||
*/
|
||||
struct PxGpuContactPair
|
||||
{
|
||||
PxU8* contactPatches; //!< Ptr to contact patches. Type: PxContactPatch*, size: nbPatches.
|
||||
PxU8* contactPoints; //!< Ptr to contact points. Type: PxContact*, size: nbContacts.
|
||||
PxReal* contactForces; //!< Ptr to contact forces. Size: nbContacts.
|
||||
PxU32 transformCacheRef0; //!< Ref to shape0's transform in transform cache.
|
||||
PxU32 transformCacheRef1; //!< Ref to shape1's transform in transform cache.
|
||||
PxNodeIndex nodeIndex0; //!< Unique Id for actor0 if the actor is dynamic.
|
||||
PxNodeIndex nodeIndex1; //!< Unique Id for actor1 if the actor is dynamic.
|
||||
PxActor* actor0; //!< Ptr to PxActor for actor0.
|
||||
PxActor* actor1; //!< Ptr to PxActor for actor1.
|
||||
|
||||
PxU16 nbContacts; //!< Num contacts.
|
||||
PxU16 nbPatches; //!< Num patches.
|
||||
};
|
||||
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,526 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTACT_MODIFY_CALLBACK_H
|
||||
#define PX_CONTACT_MODIFY_CALLBACK_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxShape.h"
|
||||
#include "PxContact.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxShape;
|
||||
|
||||
/**
|
||||
\brief An array of contact points, as passed to contact modification.
|
||||
|
||||
The word 'set' in the name does not imply that duplicates are filtered in any
|
||||
way. This initial set of contacts does potentially get reduced to a smaller
|
||||
set before being passed to the solver.
|
||||
|
||||
You can use the accessors to read and write contact properties. The number of
|
||||
contacts is immutable, other than being able to disable contacts using ignore().
|
||||
|
||||
@see PxContactModifyCallback, PxModifiableContact
|
||||
*/
|
||||
class PxContactSet
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Get the position of a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return Position to the requested point in world space
|
||||
|
||||
@see PxModifiableContact.point
|
||||
*/
|
||||
PX_FORCE_INLINE const PxVec3& getPoint(PxU32 i) const { return mContacts[i].contact; }
|
||||
|
||||
/**
|
||||
\brief Alter the position of a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\param[in] p The new position in world space
|
||||
|
||||
@see PxModifiableContact.point
|
||||
*/
|
||||
PX_FORCE_INLINE void setPoint(PxU32 i, const PxVec3& p) { mContacts[i].contact = p; }
|
||||
|
||||
/**
|
||||
\brief Get the contact normal of a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return The requested normal in world space
|
||||
|
||||
@see PxModifiableContact.normal
|
||||
*/
|
||||
PX_FORCE_INLINE const PxVec3& getNormal(PxU32 i) const { return mContacts[i].normal; }
|
||||
|
||||
/**
|
||||
\brief Alter the contact normal of a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\param[in] n The new normal in world space
|
||||
|
||||
\note Changing the normal can cause contact points to be ignored.
|
||||
|
||||
@see PxModifiableContact.normal
|
||||
*/
|
||||
PX_FORCE_INLINE void setNormal(PxU32 i, const PxVec3& n)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->internalFlags |= PxContactPatch::eREGENERATE_PATCHES;
|
||||
mContacts[i].normal = n;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get the separation distance of a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return The separation. Negative implies penetration.
|
||||
|
||||
@see PxModifiableContact.separation
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getSeparation(PxU32 i) const { return mContacts[i].separation; }
|
||||
|
||||
/**
|
||||
\brief Alter the separation of a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\param[in] s The new separation
|
||||
|
||||
@see PxModifiableContact.separation
|
||||
*/
|
||||
PX_FORCE_INLINE void setSeparation(PxU32 i, PxReal s) { mContacts[i].separation = s; }
|
||||
|
||||
/**
|
||||
\brief Get the target velocity of a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return The target velocity in world frame
|
||||
|
||||
@see PxModifiableContact.targetVelocity
|
||||
|
||||
*/
|
||||
PX_FORCE_INLINE const PxVec3& getTargetVelocity(PxU32 i) const { return mContacts[i].targetVelocity; }
|
||||
|
||||
/**
|
||||
\brief Alter the target velocity of a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\param[in] v The new velocity in world frame
|
||||
|
||||
@see PxModifiableContact.targetVelocity
|
||||
*/
|
||||
PX_FORCE_INLINE void setTargetVelocity(PxU32 i, const PxVec3& v)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->internalFlags |= PxContactPatch::eHAS_TARGET_VELOCITY;
|
||||
mContacts[i].targetVelocity = v;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get the face index with respect to the first shape of the pair for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return The face index of the first shape
|
||||
\note At the moment, the first shape is never a tri-mesh, therefore this function always returns PXC_CONTACT_NO_FACE_INDEX
|
||||
|
||||
@see PxModifiableContact.internalFaceIndex0
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getInternalFaceIndex0(PxU32 i) const { PX_UNUSED(i); return PXC_CONTACT_NO_FACE_INDEX; }
|
||||
|
||||
/**
|
||||
\brief Get the face index with respect to the second shape of the pair for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return The face index of the second shape
|
||||
|
||||
@see PxModifiableContact.internalFaceIndex1
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getInternalFaceIndex1(PxU32 i) const
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
if (patch->internalFlags & PxContactPatch::eHAS_FACE_INDICES)
|
||||
{
|
||||
return reinterpret_cast<PxU32*>(mContacts + mCount)[mCount + i];
|
||||
}
|
||||
return PXC_CONTACT_NO_FACE_INDEX;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get the maximum impulse for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return The maximum impulse
|
||||
|
||||
@see PxModifiableContact.maxImpulse
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getMaxImpulse(PxU32 i) const { return mContacts[i].maxImpulse; }
|
||||
|
||||
/**
|
||||
\brief Alter the maximum impulse for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\param[in] s The new maximum impulse
|
||||
|
||||
\note Must be nonnegative. If set to zero, the contact point will be ignored
|
||||
|
||||
@see PxModifiableContact.maxImpulse, ignore()
|
||||
*/
|
||||
PX_FORCE_INLINE void setMaxImpulse(PxU32 i, PxReal s)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->internalFlags |= PxContactPatch::eHAS_MAX_IMPULSE;
|
||||
mContacts[i].maxImpulse = s;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get the restitution coefficient for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return The restitution coefficient
|
||||
|
||||
@see PxModifiableContact.restitution
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getRestitution(PxU32 i) const { return mContacts[i].restitution; }
|
||||
|
||||
/**
|
||||
\brief Alter the restitution coefficient for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\param[in] r The new restitution coefficient
|
||||
|
||||
\note Valid ranges [0,1]
|
||||
|
||||
@see PxModifiableContact.restitution
|
||||
*/
|
||||
PX_FORCE_INLINE void setRestitution(PxU32 i, PxReal r)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->internalFlags |= PxContactPatch::eREGENERATE_PATCHES;
|
||||
mContacts[i].restitution = r;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get the static friction coefficient for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return The friction coefficient (dimensionless)
|
||||
|
||||
@see PxModifiableContact.staticFriction
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getStaticFriction(PxU32 i) const { return mContacts[i].staticFriction; }
|
||||
|
||||
/**
|
||||
\brief Alter the static friction coefficient for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\param[in] f The new friction coefficient (dimensionless), range [0, inf]
|
||||
|
||||
@see PxModifiableContact.staticFriction
|
||||
*/
|
||||
PX_FORCE_INLINE void setStaticFriction(PxU32 i, PxReal f)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->internalFlags |= PxContactPatch::eREGENERATE_PATCHES;
|
||||
mContacts[i].staticFriction = f;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get the static friction coefficient for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\return The friction coefficient
|
||||
|
||||
@see PxModifiableContact.dynamicFriction
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getDynamicFriction(PxU32 i) const { return mContacts[i].dynamicFriction; }
|
||||
|
||||
/**
|
||||
\brief Alter the static dynamic coefficient for a specific contact point in the set.
|
||||
\param[in] i Index of the point in the set
|
||||
\param[in] f The new friction coefficient
|
||||
|
||||
@see PxModifiableContact.dynamicFriction
|
||||
*/
|
||||
PX_FORCE_INLINE void setDynamicFriction(PxU32 i, PxReal f)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->internalFlags |= PxContactPatch::eREGENERATE_PATCHES;
|
||||
mContacts[i].dynamicFriction = f;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Ignore the contact point.
|
||||
\param[in] i Index of the point in the set
|
||||
|
||||
If a contact point is ignored then no force will get applied at this point. This can be used to disable collision in certain areas of a shape, for example.
|
||||
*/
|
||||
PX_FORCE_INLINE void ignore(PxU32 i) { setMaxImpulse(i, 0.0f); }
|
||||
|
||||
/**
|
||||
\brief The number of contact points in the set.
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 size() const { return mCount; }
|
||||
|
||||
/**
|
||||
\brief Returns the invMassScale of body 0
|
||||
|
||||
A value < 1.0 makes this contact treat the body as if it had larger mass. A value of 0.f makes this contact
|
||||
treat the body as if it had infinite mass. Any value > 1.f makes this contact treat the body as if it had smaller mass.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getInvMassScale0() const
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
return patch->mMassModification.mInvMassScale0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns the invMassScale of body 1
|
||||
|
||||
A value < 1.0 makes this contact treat the body as if it had larger mass. A value of 0.f makes this contact
|
||||
treat the body as if it had infinite mass. Any value > 1.f makes this contact treat the body as if it had smaller mass.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getInvMassScale1() const
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
return patch->mMassModification.mInvMassScale1;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns the invInertiaScale of body 0
|
||||
|
||||
A value < 1.0 makes this contact treat the body as if it had larger inertia. A value of 0.f makes this contact
|
||||
treat the body as if it had infinite inertia. Any value > 1.f makes this contact treat the body as if it had smaller inertia.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getInvInertiaScale0() const
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
return patch->mMassModification.mInvInertiaScale0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Returns the invInertiaScale of body 1
|
||||
|
||||
A value < 1.0 makes this contact treat the body as if it had larger inertia. A value of 0.f makes this contact
|
||||
treat the body as if it had infinite inertia. Any value > 1.f makes this contact treat the body as if it had smaller inertia.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getInvInertiaScale1() const
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
return patch->mMassModification.mInvInertiaScale1;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Sets the invMassScale of body 0
|
||||
\param[in] scale The new scale
|
||||
|
||||
This can be set to any value in the range [0, PX_MAX_F32). A value < 1.0 makes this contact treat the body as if it had larger mass. A value of 0.f makes this contact
|
||||
treat the body as if it had infinite mass. Any value > 1.f makes this contact treat the body as if it had smaller mass.
|
||||
*/
|
||||
PX_FORCE_INLINE void setInvMassScale0(const PxReal scale)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->mMassModification.mInvMassScale0 = scale;
|
||||
patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Sets the invMassScale of body 1
|
||||
\param[in] scale The new scale
|
||||
|
||||
This can be set to any value in the range [0, PX_MAX_F32). A value < 1.0 makes this contact treat the body as if it had larger mass. A value of 0.f makes this contact
|
||||
treat the body as if it had infinite mass. Any value > 1.f makes this contact treat the body as if it had smaller mass.
|
||||
*/
|
||||
PX_FORCE_INLINE void setInvMassScale1(const PxReal scale)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->mMassModification.mInvMassScale1 = scale;
|
||||
patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Sets the invInertiaScale of body 0
|
||||
\param[in] scale The new scale
|
||||
|
||||
This can be set to any value in the range [0, PX_MAX_F32). A value < 1.0 makes this contact treat the body as if it had larger inertia. A value of 0.f makes this contact
|
||||
treat the body as if it had infinite inertia. Any value > 1.f makes this contact treat the body as if it had smaller inertia.
|
||||
*/
|
||||
PX_FORCE_INLINE void setInvInertiaScale0(const PxReal scale)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->mMassModification.mInvInertiaScale0 = scale;
|
||||
patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Sets the invInertiaScale of body 1
|
||||
\param[in] scale The new scale
|
||||
|
||||
This can be set to any value in the range [0, PX_MAX_F32). A value < 1.0 makes this contact treat the body as if it had larger inertia. A value of 0.f makes this contact
|
||||
treat the body as if it had infinite inertia. Any value > 1.f makes this contact treat the body as if it had smaller inertia.
|
||||
*/
|
||||
PX_FORCE_INLINE void setInvInertiaScale1(const PxReal scale)
|
||||
{
|
||||
PxContactPatch* patch = getPatch();
|
||||
patch->mMassModification.mInvInertiaScale1 = scale;
|
||||
patch->internalFlags |= PxContactPatch::eHAS_MODIFIED_MASS_RATIOS;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
PX_FORCE_INLINE PxContactPatch* getPatch() const
|
||||
{
|
||||
const size_t headerOffset = sizeof(PxContactPatch)*mCount;
|
||||
return reinterpret_cast<PxContactPatch*>(reinterpret_cast<PxU8*>(mContacts) - headerOffset);
|
||||
}
|
||||
|
||||
PxU32 mCount; //!< Number of contact points in the set
|
||||
PxModifiableContact* mContacts; //!< The contact points of the set
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief An array of instances of this class is passed to PxContactModifyCallback::onContactModify().
|
||||
|
||||
@see PxContactModifyCallback
|
||||
*/
|
||||
|
||||
class PxContactModifyPair
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief The actors which make up the pair in contact.
|
||||
|
||||
Note that these are the actors as seen by the simulation, and may have been deleted since the simulation step started.
|
||||
*/
|
||||
const PxRigidActor* actor[2];
|
||||
|
||||
/**
|
||||
\brief The shapes which make up the pair in contact.
|
||||
|
||||
Note that these are the shapes as seen by the simulation, and may have been deleted since the simulation step started.
|
||||
*/
|
||||
const PxShape* shape[2];
|
||||
|
||||
/**
|
||||
\brief The shape to world transforms of the two shapes.
|
||||
|
||||
These are the transforms as the simulation engine sees them, and may have been modified by the application
|
||||
since the simulation step started.
|
||||
*/
|
||||
PxTransform transform[2];
|
||||
|
||||
/**
|
||||
\brief An array of contact points between these two shapes.
|
||||
*/
|
||||
PxContactSet contacts;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief An interface class that the user can implement in order to modify contact constraints.
|
||||
|
||||
<b>Threading:</b> It is <b>necessary</b> to make this class thread safe as it will be called in the context of the
|
||||
simulation thread. It might also be necessary to make it reentrant, since some calls can be made by multi-threaded
|
||||
parts of the physics engine.
|
||||
|
||||
You can enable the use of this contact modification callback by raising the flag PxPairFlag::eMODIFY_CONTACTS in
|
||||
the filter shader/callback (see #PxSimulationFilterShader) for a pair of rigid body objects.
|
||||
|
||||
Please note:
|
||||
+ Raising the contact modification flag will not wake the actors up automatically.
|
||||
+ It is not possible to turn off the performance degradation by simply removing the callback from the scene, the
|
||||
filter shader/callback has to be used to clear the contact modification flag.
|
||||
+ The contacts will only be reported as long as the actors are awake. There will be no callbacks while the actors are sleeping.
|
||||
|
||||
@see PxScene.setContactModifyCallback() PxScene.getContactModifyCallback()
|
||||
*/
|
||||
class PxContactModifyCallback
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Passes modifiable arrays of contacts to the application.
|
||||
|
||||
The initial contacts are regenerated from scratch each frame by collision detection.
|
||||
|
||||
The number of contacts can not be changed, so you cannot add your own contacts. You may however
|
||||
disable contacts using PxContactSet::ignore().
|
||||
|
||||
\param[in,out] pairs The contact pairs that may be modified
|
||||
\param[in] count Number of contact pairs
|
||||
|
||||
@see PxContactModifyPair
|
||||
*/
|
||||
virtual void onContactModify(PxContactModifyPair* const pairs, PxU32 count) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxContactModifyCallback(){}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief An interface class that the user can implement in order to modify CCD contact constraints.
|
||||
|
||||
<b>Threading:</b> It is <b>necessary</b> to make this class thread safe as it will be called in the context of the
|
||||
simulation thread. It might also be necessary to make it reentrant, since some calls can be made by multi-threaded
|
||||
parts of the physics engine.
|
||||
|
||||
You can enable the use of this contact modification callback by raising the flag PxPairFlag::eMODIFY_CONTACTS in
|
||||
the filter shader/callback (see #PxSimulationFilterShader) for a pair of rigid body objects.
|
||||
|
||||
Please note:
|
||||
+ Raising the contact modification flag will not wake the actors up automatically.
|
||||
+ It is not possible to turn off the performance degradation by simply removing the callback from the scene, the
|
||||
filter shader/callback has to be used to clear the contact modification flag.
|
||||
+ The contacts will only be reported as long as the actors are awake. There will be no callbacks while the actors are sleeping.
|
||||
|
||||
@see PxScene.setContactModifyCallback() PxScene.getContactModifyCallback()
|
||||
*/
|
||||
class PxCCDContactModifyCallback
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Passes modifiable arrays of contacts to the application.
|
||||
|
||||
The initial contacts are regenerated from scratch each frame by collision detection.
|
||||
|
||||
The number of contacts can not be changed, so you cannot add your own contacts. You may however
|
||||
disable contacts using PxContactSet::ignore().
|
||||
|
||||
\param[in,out] pairs The contact pairs that may be modified
|
||||
\param[in] count Number of contact pairs
|
||||
*/
|
||||
virtual void onCCDContactModify(PxContactModifyPair* const pairs, PxU32 count) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxCCDContactModifyCallback(){}
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,105 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CUSTOM_PARTICLE_SYSTEM_SOLVER_CALLBACK_H
|
||||
#define PX_CUSTOM_PARTICLE_SYSTEM_SOLVER_CALLBACK_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "cudamanager/PxCudaTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4435)
|
||||
#endif
|
||||
|
||||
class PxGpuParticleSystem;
|
||||
|
||||
|
||||
class PxCustomParticleSystemSolverCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief callback called when the particle solver begins.
|
||||
|
||||
This is called once per frame. It occurs after external forces have been pre-integrated into the particle state.
|
||||
It is called prior to the particles being reordered by spatial hash index, so state can be accessed in the unsorted buffers only at this stage. This provides an opportunity to add custom
|
||||
forces and modifications to position or velocity.
|
||||
|
||||
\param [in] gpuParticleSystem A pointer to the GPU particle system. This pointer points to a mirror of the particle system in device memory.
|
||||
\param [in] dt The time-step.
|
||||
\param [in] stream The CUDA stream currently being used by the particle system. Additional kernels should either be launched on this stream, or synchronization events should be used to avoid race conditions.
|
||||
*/
|
||||
virtual void onBegin(PxGpuParticleSystem* gpuParticleSystem, PxReal dt, CUstream stream) = 0;
|
||||
|
||||
/**
|
||||
\brief callback called during the iterative particle solve stage.
|
||||
|
||||
This callback will potentially be called multiple times between onBegin and onFinalize.
|
||||
|
||||
\param [in] gpuParticleSystem A pointer to the GPU particle system. This pointer points to a mirror of the particle system in device memory.
|
||||
\param [in] dt The time-step.
|
||||
\param [in] stream The CUDA stream currently being used by the particle system. Additional kernels should either be launched on this stream, or synchronization events should be used to avoid race conditions.
|
||||
*/
|
||||
virtual void onSolve(PxGpuParticleSystem* gpuParticleSystem, PxReal dt, CUstream stream) = 0;
|
||||
|
||||
/**
|
||||
\brief callback called after all solver iterations have completed.
|
||||
|
||||
This callback will be called once per frame, after integration has completed.
|
||||
|
||||
\param [in] gpuParticleSystem A pointer to the GPU particle system. This pointer points to a mirror of the particle system in device memory.
|
||||
\param [in] dt The time-step.
|
||||
\param [in] stream The CUDA stream currently being used by the particle system. Additional kernels should either be launched on this stream, or synchronization events should be used to avoid race conditions.
|
||||
*/
|
||||
virtual void onFinalize(PxGpuParticleSystem* gpuParticleSystem, PxReal dt, CUstream stream) = 0;
|
||||
|
||||
/**
|
||||
\brief Destructor
|
||||
*/
|
||||
virtual ~PxCustomParticleSystemSolverCallback() {}
|
||||
};
|
||||
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,104 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_DELETION_LISTENER_H
|
||||
#define PX_DELETION_LISTENER_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Flags specifying deletion event types.
|
||||
|
||||
@see PxDeletionListener::onRelease PxPhysics.registerDeletionListener()
|
||||
*/
|
||||
struct PxDeletionEventFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eUSER_RELEASE = (1<<0), //!< The user has called release on an object.
|
||||
eMEMORY_RELEASE = (1<<1) //!< The destructor of an object has been called and the memory has been released.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Collection of set bits defined in PxDeletionEventFlag.
|
||||
|
||||
@see PxDeletionEventFlag
|
||||
*/
|
||||
typedef PxFlags<PxDeletionEventFlag::Enum,PxU8> PxDeletionEventFlags;
|
||||
PX_FLAGS_OPERATORS(PxDeletionEventFlag::Enum,PxU8)
|
||||
|
||||
|
||||
/**
|
||||
\brief interface to get notification on object deletion
|
||||
|
||||
*/
|
||||
class PxDeletionListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Notification if an object or its memory gets released
|
||||
|
||||
If release() gets called on a PxBase object, an eUSER_RELEASE event will get fired immediately. The object state can be queried in the callback but
|
||||
it is not allowed to change the state. Furthermore, when reading from the object it is the user's responsibility to make sure that no other thread
|
||||
is writing at the same time to the object (this includes the simulation itself, i.e., #PxScene::fetchResults() must not get called at the same time).
|
||||
|
||||
Calling release() on a PxBase object does not necessarily trigger its destructor immediately. For example, the object can be shared and might still
|
||||
be referenced by other objects or the simulation might still be running and accessing the object state. In such cases the destructor will be called
|
||||
as soon as it is safe to do so. After the destruction of the object and its memory, an eMEMORY_RELEASE event will get fired. In this case it is not
|
||||
allowed to dereference the object pointer in the callback.
|
||||
|
||||
\param[in] observed The object for which the deletion event gets fired.
|
||||
\param[in] userData The user data pointer of the object for which the deletion event gets fired. Not available for all object types in which case it will be set to 0.
|
||||
\param[in] deletionEvent The type of deletion event. Do not dereference the object pointer argument if the event is eMEMORY_RELEASE.
|
||||
|
||||
*/
|
||||
virtual void onRelease(const PxBase* observed, void* userData, PxDeletionEventFlag::Enum deletionEvent) = 0;
|
||||
|
||||
protected:
|
||||
PxDeletionListener() {}
|
||||
virtual ~PxDeletionListener() {}
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PHYSICS_FEM_CLOTH_FLAGS_H
|
||||
#define PX_PHYSICS_FEM_CLOTH_FLAGS_H
|
||||
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Identifies input and output buffers for PxFEMCloth.
|
||||
@see PxFEMClothData::readData(), PxFEMClothData::writeData(), PxBuffer.
|
||||
*/
|
||||
struct PxFEMClothData
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE = 0,
|
||||
ePOSITION_INVMASS = 1 << 0,
|
||||
eVELOCITY = 1 << 1,
|
||||
eREST_POSITION = 1 << 2,
|
||||
eALL = ePOSITION_INVMASS | eVELOCITY | eREST_POSITION
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxFEMClothData::Enum, PxU32> PxFEMClothDataFlags;
|
||||
|
||||
struct PxFEMClothFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eDISABLE_SELF_COLLISION = 1 << 0,
|
||||
eUSE_ISOTROPIC_CLOTH = 1 << 1, // 0: use anistropic model
|
||||
eUSE_REST_POSITION_FOR_BENDING = 1 << 2 // 0: use zero bending angle
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxFEMClothFlag::Enum, PxU32> PxFEMClothFlags;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,116 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_FEM_CLOTH_MATERIAL_H
|
||||
#define PX_FEM_CLOTH_MATERIAL_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxFEMMaterial.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Material class to represent a set of FEM material properties.
|
||||
|
||||
@see PxPhysics.createFEMClothMaterial
|
||||
*/
|
||||
class PxFEMClothMaterial : public PxFEMMaterial
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Sets material thickness
|
||||
|
||||
\param[in] thickness Material thickness.
|
||||
|
||||
@see getThickness
|
||||
*/
|
||||
virtual void setThickness(PxReal thickness) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the material thickness.
|
||||
\return thickness.
|
||||
|
||||
@see setDamping()
|
||||
*/
|
||||
virtual PxReal getThickness() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the elasticity damping for the internal cloth solver.
|
||||
|
||||
\param[in] damping The elasticity damping term. <b>Range:</b> [0.0, Inf)
|
||||
|
||||
@see getElasticityDamping()
|
||||
*/
|
||||
virtual void setElasticityDamping(PxReal damping) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the elasticity damping term.
|
||||
\return The elasticity damping term.
|
||||
|
||||
@see setElasticityDamping()
|
||||
*/
|
||||
virtual PxReal getElasticityDamping() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the bending coefficient for bending constraints.
|
||||
|
||||
\param[in] damping The bending coefficient. <b>Range:</b> [0.0, Inf)
|
||||
|
||||
@see getBendingDamping()
|
||||
*/
|
||||
virtual void setBendingDamping(PxReal damping) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the bending coefficient for bending constraints.
|
||||
\return The bending coefficient.
|
||||
|
||||
@see setBendingDamping()
|
||||
*/
|
||||
virtual PxReal getBendingDamping() const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxFEMClothMaterial"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxFEMClothMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxFEMMaterial(concreteType, baseFlags) {}
|
||||
PX_INLINE PxFEMClothMaterial(PxBaseFlags baseFlags) : PxFEMMaterial(baseFlags) {}
|
||||
virtual ~PxFEMClothMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxFEMClothMaterial", name) || PxRefCounted::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,118 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_FEM_MATERIAL_H
|
||||
#define PX_FEM_MATERIAL_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxBaseMaterial.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxScene;
|
||||
|
||||
/**
|
||||
\brief Material class to represent a set of FEM material properties.
|
||||
|
||||
@see PxPhysics.createFEMSoftBodyMaterial
|
||||
*/
|
||||
class PxFEMMaterial : public PxBaseMaterial
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Sets young's modulus which defines the body's stiffness
|
||||
|
||||
\param[in] young Young's modulus. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getYoungsModulus()
|
||||
*/
|
||||
virtual void setYoungsModulus(PxReal young) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the young's modulus value.
|
||||
|
||||
\return The young's modulus value.
|
||||
|
||||
@see setYoungsModulus()
|
||||
*/
|
||||
virtual PxReal getYoungsModulus() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the Poisson's ratio which defines the body's volume preservation. Completely incompressible materials have a poisson ratio of 0.5. Its value should not be set to exactly 0.5 because this leads to numerical problems.
|
||||
|
||||
\param[in] poisson Poisson's ratio. <b>Range:</b> [0, 0.5)
|
||||
|
||||
@see getPoissons()
|
||||
*/
|
||||
virtual void setPoissons(PxReal poisson) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the Poisson's ratio.
|
||||
\return The Poisson's ratio.
|
||||
|
||||
@see setPoissons()
|
||||
*/
|
||||
virtual PxReal getPoissons() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the dynamic friction value which defines the strength of resistance when two objects slide relative to each other while in contact.
|
||||
|
||||
\param[in] dynamicFriction The dynamic friction value. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getDynamicFriction()
|
||||
*/
|
||||
virtual void setDynamicFriction(PxReal dynamicFriction) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the dynamic friction value
|
||||
\return The dynamic friction value
|
||||
|
||||
@see setDynamicFriction()
|
||||
*/
|
||||
virtual PxReal getDynamicFriction() const = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxFEMMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxBaseMaterial(concreteType, baseFlags) {}
|
||||
PX_INLINE PxFEMMaterial(PxBaseFlags baseFlags) : PxBaseMaterial(baseFlags) {}
|
||||
virtual ~PxFEMMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxFEMMaterial", name) || PxBaseMaterial::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
|
||||
#ifndef PX_PHYSICS_FEM_PARAMETER_H
|
||||
#define PX_PHYSICS_FEM_PARAMETER_H
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Set of parameters to control the sleeping and collision behavior of FEM based objects
|
||||
*/
|
||||
struct PxFEMParameters
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Velocity damping value. After every timestep the velocity is reduced while the magnitude of the reduction depends on velocityDamping
|
||||
<b>Default:</b> 0.05
|
||||
*/
|
||||
PxReal velocityDamping;
|
||||
/**
|
||||
\brief Threshold that defines the maximal magnitude of the linear motion a fem body can move in one second before it becomes a candidate for sleeping
|
||||
<b>Default:</b> 0.1
|
||||
*/
|
||||
PxReal settlingThreshold;
|
||||
/**
|
||||
\brief Threshold that defines the maximal magnitude of the linear motion a fem body can move in one second such that it can go to sleep in the next frame
|
||||
<b>Default:</b> 0.05
|
||||
*/
|
||||
PxReal sleepThreshold;
|
||||
/**
|
||||
\brief Damping value that damps the motion of bodies that move slow enough to be candidates for sleeping (see settlingThreshold)
|
||||
<b>Default:</b> 10
|
||||
*/
|
||||
PxReal sleepDamping;
|
||||
/**
|
||||
\brief Penetration value that needs to get exceeded before contacts for self collision are generated. Will only have an effect if self collisions are enabled.
|
||||
<b>Default:</b> 0.1
|
||||
*/
|
||||
PxReal selfCollisionFilterDistance;
|
||||
/**
|
||||
\brief Stress threshold to deactivate collision contacts in case the tetrahedron's stress magnitude exceeds the threshold
|
||||
<b>Default:</b> 0.9
|
||||
*/
|
||||
PxReal selfCollisionStressTolerance;
|
||||
|
||||
#ifndef __CUDACC__
|
||||
PxFEMParameters()
|
||||
{
|
||||
velocityDamping = 0.05f;
|
||||
settlingThreshold = 0.1f;
|
||||
sleepThreshold = 0.05f;
|
||||
sleepDamping = 10.f;
|
||||
selfCollisionFilterDistance = 0.1f;
|
||||
selfCollisionStressTolerance = 0.9f;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,100 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_FEM_SOFT_BODY_MATERIAL_H
|
||||
#define PX_FEM_SOFT_BODY_MATERIAL_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxFEMMaterial.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxScene;
|
||||
/**
|
||||
\brief Material class to represent a set of softbody FEM material properties.
|
||||
|
||||
@see PxPhysics.createFEMSoftBodyMaterial
|
||||
*/
|
||||
class PX_DEPRECATED PxFEMSoftBodyMaterial : public PxFEMMaterial
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Sets material velocity damping term
|
||||
|
||||
\param[in] damping Material velocity damping term. <b>Range:</b> [0, PX_MAX_F32)<br>
|
||||
|
||||
@see getDamping
|
||||
*/
|
||||
virtual void setDamping(PxReal damping) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves velocity damping
|
||||
\return The velocity damping.
|
||||
|
||||
@see setDamping()
|
||||
*/
|
||||
virtual PxReal getDamping() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material damping scale. A scale of 1 corresponds to default damping, a value of 0 will only apply damping to certain motions leading to special effects that look similar to water filled softbodies.
|
||||
|
||||
\param[in] scale Damping scale term. <b>Default:</b> 1 <b>Range:</b> [0, 1]
|
||||
|
||||
@see getDampingScale
|
||||
*/
|
||||
virtual void setDampingScale(PxReal scale) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves material damping scale.
|
||||
\return The damping scale term.
|
||||
|
||||
@see setDamping()
|
||||
*/
|
||||
virtual PxReal getDampingScale() const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxFEMSoftBodyMaterial"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxFEMSoftBodyMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxFEMMaterial(concreteType, baseFlags) {}
|
||||
PX_INLINE PxFEMSoftBodyMaterial(PxBaseFlags baseFlags) : PxFEMMaterial(baseFlags) {}
|
||||
virtual ~PxFEMSoftBodyMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxFEMSoftBodyMaterial", name) || PxFEMMaterial::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_FLIP_MATERIAL_H
|
||||
#define PX_FLIP_MATERIAL_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxParticleMaterial.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxScene;
|
||||
/**
|
||||
\brief Material class to represent a set of FLIP particle material properties.
|
||||
|
||||
@see #PxPhysics.createFLIPMaterial()
|
||||
*/
|
||||
class PxFLIPMaterial : public PxParticleMaterial
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Sets viscosity
|
||||
|
||||
\param[in] viscosity Viscosity. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getViscosity()
|
||||
*/
|
||||
virtual void setViscosity(PxReal viscosity) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the viscosity value.
|
||||
|
||||
\return The viscosity value.
|
||||
|
||||
@see #setViscosity()
|
||||
*/
|
||||
virtual PxReal getViscosity() const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxFLIPMaterial"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxFLIPMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxParticleMaterial(concreteType, baseFlags) {}
|
||||
PX_INLINE PxFLIPMaterial(PxBaseFlags baseFlags) : PxParticleMaterial(baseFlags) {}
|
||||
virtual ~PxFLIPMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxFLIPMaterial", name) || PxParticleMaterial::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
785
modules/PhysX/physx/physx-sys/physx/physx/include/PxFiltering.h
Normal file
785
modules/PhysX/physx/physx-sys/physx/physx/include/PxFiltering.h
Normal file
@@ -0,0 +1,785 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_FILTERING_H
|
||||
#define PX_FILTERING_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxActor;
|
||||
class PxShape;
|
||||
|
||||
static const PxU32 INVALID_FILTER_PAIR_INDEX = 0xffffffff;
|
||||
|
||||
/**
|
||||
\brief Collection of flags describing the actions to take for a collision pair.
|
||||
|
||||
@see PxPairFlags PxSimulationFilterShader.filter() PxSimulationFilterCallback
|
||||
*/
|
||||
struct PxPairFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief Process the contacts of this collision pair in the dynamics solver.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
*/
|
||||
eSOLVE_CONTACT = (1<<0),
|
||||
|
||||
/**
|
||||
\brief Call contact modification callback for this collision pair
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
@see PxContactModifyCallback
|
||||
*/
|
||||
eMODIFY_CONTACTS = (1<<1),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback or trigger callback when this collision pair starts to be in contact.
|
||||
|
||||
If one of the two collision objects is a trigger shape (see #PxShapeFlag::eTRIGGER_SHAPE)
|
||||
then the trigger callback will get called as soon as the other object enters the trigger volume.
|
||||
If none of the two collision objects is a trigger shape then the contact report callback will get
|
||||
called when the actors of this collision pair start to be in contact.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
eNOTIFY_TOUCH_FOUND = (1<<2),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback while this collision pair is in contact
|
||||
|
||||
If none of the two collision objects is a trigger shape then the contact report callback will get
|
||||
called while the actors of this collision pair are in contact.
|
||||
|
||||
\note Triggers do not support this event. Persistent trigger contacts need to be tracked separately by observing eNOTIFY_TOUCH_FOUND/eNOTIFY_TOUCH_LOST events.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note No report will get sent if the objects in contact are sleeping.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
\note If this flag gets enabled while a pair is in touch already, there will be no eNOTIFY_TOUCH_PERSISTS events until the pair loses and regains touch.
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
eNOTIFY_TOUCH_PERSISTS = (1<<3),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback or trigger callback when this collision pair stops to be in contact
|
||||
|
||||
If one of the two collision objects is a trigger shape (see #PxShapeFlag::eTRIGGER_SHAPE)
|
||||
then the trigger callback will get called as soon as the other object leaves the trigger volume.
|
||||
If none of the two collision objects is a trigger shape then the contact report callback will get
|
||||
called when the actors of this collision pair stop to be in contact.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note This event will also get triggered if one of the colliding objects gets deleted.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
eNOTIFY_TOUCH_LOST = (1<<4),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when this collision pair is in contact during CCD passes.
|
||||
|
||||
If CCD with multiple passes is enabled, then a fast moving object might bounce on and off the same
|
||||
object multiple times. Hence, the same pair might be in contact multiple times during a simulation step.
|
||||
This flag will make sure that all the detected collision during CCD will get reported. For performance
|
||||
reasons, the system can not always tell whether the contact pair lost touch in one of the previous CCD
|
||||
passes and thus can also not always tell whether the contact is new or has persisted. eNOTIFY_TOUCH_CCD
|
||||
just reports when the two collision objects were detected as being in contact during a CCD pass.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note Trigger shapes are not supported.
|
||||
|
||||
\note Only takes effect if eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
eNOTIFY_TOUCH_CCD = (1<<5),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when the contact force between the actors of this collision pair exceeds one of the actor-defined force thresholds.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
eNOTIFY_THRESHOLD_FORCE_FOUND = (1<<6),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when the contact force between the actors of this collision pair continues to exceed one of the actor-defined force thresholds.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note If a pair gets re-filtered and this flag has previously been disabled, then the report will not get fired in the same frame even if the force threshold has been reached in the
|
||||
previous one (unless #eNOTIFY_THRESHOLD_FORCE_FOUND has been set in the previous frame).
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
eNOTIFY_THRESHOLD_FORCE_PERSISTS = (1<<7),
|
||||
|
||||
/**
|
||||
\brief Call contact report callback when the contact force between the actors of this collision pair falls below one of the actor-defined force thresholds (includes the case where this collision pair stops being in contact).
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies.
|
||||
|
||||
\note If a pair gets re-filtered and this flag has previously been disabled, then the report will not get fired in the same frame even if the force threshold has been reached in the
|
||||
previous one (unless #eNOTIFY_THRESHOLD_FORCE_FOUND or #eNOTIFY_THRESHOLD_FORCE_PERSISTS has been set in the previous frame).
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
eNOTIFY_THRESHOLD_FORCE_LOST = (1<<8),
|
||||
|
||||
/**
|
||||
\brief Provide contact points in contact reports for this collision pair.
|
||||
|
||||
\note Only takes effect if the colliding actors are rigid bodies and if used in combination with the flags eNOTIFY_TOUCH_... or eNOTIFY_THRESHOLD_FORCE_...
|
||||
|
||||
\note Only takes effect if eDETECT_DISCRETE_CONTACT or eDETECT_CCD_CONTACT is raised
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxContactPair PxContactPair.extractContacts()
|
||||
*/
|
||||
eNOTIFY_CONTACT_POINTS = (1<<9),
|
||||
|
||||
/**
|
||||
\brief This flag is used to indicate whether this pair generates discrete collision detection contacts.
|
||||
|
||||
\note Contacts are only responded to if eSOLVE_CONTACT is enabled.
|
||||
*/
|
||||
eDETECT_DISCRETE_CONTACT = (1<<10),
|
||||
|
||||
/**
|
||||
\brief This flag is used to indicate whether this pair generates CCD contacts.
|
||||
|
||||
\note The contacts will only be responded to if eSOLVE_CONTACT is enabled on this pair.
|
||||
\note The scene must have PxSceneFlag::eENABLE_CCD enabled to use this feature.
|
||||
\note Non-static bodies of the pair should have PxRigidBodyFlag::eENABLE_CCD specified for this feature to work correctly.
|
||||
\note This flag is not supported with trigger shapes. However, CCD trigger events can be emulated using non-trigger shapes
|
||||
and requesting eNOTIFY_TOUCH_FOUND and eNOTIFY_TOUCH_LOST and not raising eSOLVE_CONTACT on the pair.
|
||||
|
||||
@see PxRigidBodyFlag::eENABLE_CCD
|
||||
@see PxSceneFlag::eENABLE_CCD
|
||||
*/
|
||||
eDETECT_CCD_CONTACT = (1<<11),
|
||||
|
||||
/**
|
||||
\brief Provide pre solver velocities in contact reports for this collision pair.
|
||||
|
||||
If the collision pair has contact reports enabled, the velocities of the rigid bodies before contacts have been solved
|
||||
will be provided in the contact report callback unless the pair lost touch in which case no data will be provided.
|
||||
|
||||
\note Usually it is not necessary to request these velocities as they will be available by querying the velocity from the provided
|
||||
PxRigidActor object directly. However, it might be the case that the velocity of a rigid body gets set while the simulation is running
|
||||
in which case the PxRigidActor would return this new velocity in the contact report callback and not the velocity the simulation used.
|
||||
|
||||
@see PxSimulationEventCallback.onContact(), PxContactPairVelocity, PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
ePRE_SOLVER_VELOCITY = (1<<12),
|
||||
|
||||
/**
|
||||
\brief Provide post solver velocities in contact reports for this collision pair.
|
||||
|
||||
If the collision pair has contact reports enabled, the velocities of the rigid bodies after contacts have been solved
|
||||
will be provided in the contact report callback unless the pair lost touch in which case no data will be provided.
|
||||
|
||||
@see PxSimulationEventCallback.onContact(), PxContactPairVelocity, PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
ePOST_SOLVER_VELOCITY = (1<<13),
|
||||
|
||||
/**
|
||||
\brief Provide rigid body poses in contact reports for this collision pair.
|
||||
|
||||
If the collision pair has contact reports enabled, the rigid body poses at the contact event will be provided
|
||||
in the contact report callback unless the pair lost touch in which case no data will be provided.
|
||||
|
||||
\note Usually it is not necessary to request these poses as they will be available by querying the pose from the provided
|
||||
PxRigidActor object directly. However, it might be the case that the pose of a rigid body gets set while the simulation is running
|
||||
in which case the PxRigidActor would return this new pose in the contact report callback and not the pose the simulation used.
|
||||
Another use case is related to CCD with multiple passes enabled, A fast moving object might bounce on and off the same
|
||||
object multiple times. This flag can be used to request the rigid body poses at the time of impact for each such collision event.
|
||||
|
||||
@see PxSimulationEventCallback.onContact(), PxContactPairPose, PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
eCONTACT_EVENT_POSE = (1<<14),
|
||||
|
||||
eNEXT_FREE = (1<<15), //!< For internal use only.
|
||||
|
||||
/**
|
||||
\brief Provided default flag to do simple contact processing for this collision pair.
|
||||
*/
|
||||
eCONTACT_DEFAULT = eSOLVE_CONTACT | eDETECT_DISCRETE_CONTACT,
|
||||
|
||||
/**
|
||||
\brief Provided default flag to get commonly used trigger behavior for this collision pair.
|
||||
*/
|
||||
eTRIGGER_DEFAULT = eNOTIFY_TOUCH_FOUND | eNOTIFY_TOUCH_LOST | eDETECT_DISCRETE_CONTACT
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxPairFlag.
|
||||
|
||||
@see PxPairFlag
|
||||
*/
|
||||
typedef PxFlags<PxPairFlag::Enum, PxU16> PxPairFlags;
|
||||
PX_FLAGS_OPERATORS(PxPairFlag::Enum, PxU16)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief Collection of flags describing the filter actions to take for a collision pair.
|
||||
|
||||
@see PxFilterFlags PxSimulationFilterShader PxSimulationFilterCallback
|
||||
*/
|
||||
struct PxFilterFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief Ignore the collision pair as long as the bounding volumes of the pair objects overlap.
|
||||
|
||||
Killed pairs will be ignored by the simulation and won't run through the filter again until one
|
||||
of the following occurs:
|
||||
|
||||
\li The bounding volumes of the two objects overlap again (after being separated)
|
||||
\li The user enforces a re-filtering (see #PxScene::resetFiltering())
|
||||
|
||||
@see PxScene::resetFiltering()
|
||||
*/
|
||||
eKILL = (1<<0),
|
||||
|
||||
/**
|
||||
\brief Ignore the collision pair as long as the bounding volumes of the pair objects overlap or until filtering relevant data changes for one of the collision objects.
|
||||
|
||||
Suppressed pairs will be ignored by the simulation and won't make another filter request until one
|
||||
of the following occurs:
|
||||
|
||||
\li Same conditions as for killed pairs (see #eKILL)
|
||||
\li The filter data or the filter object attributes change for one of the collision objects
|
||||
|
||||
@see PxFilterData PxFilterObjectAttributes
|
||||
*/
|
||||
eSUPPRESS = (1<<1),
|
||||
|
||||
/**
|
||||
\brief Invoke the filter callback (#PxSimulationFilterCallback::pairFound()) for this collision pair.
|
||||
|
||||
@see PxSimulationFilterCallback
|
||||
*/
|
||||
eCALLBACK = (1<<2),
|
||||
|
||||
/**
|
||||
\brief Track this collision pair with the filter callback mechanism.
|
||||
|
||||
When the bounding volumes of the collision pair lose contact, the filter callback #PxSimulationFilterCallback::pairLost()
|
||||
will be invoked. Furthermore, the filter status of the collision pair can be adjusted through #PxSimulationFilterCallback::statusChange()
|
||||
once per frame (until a pairLost() notification occurs).
|
||||
|
||||
@see PxSimulationFilterCallback
|
||||
*/
|
||||
eNOTIFY = (1<<3) | eCALLBACK,
|
||||
|
||||
/**
|
||||
\brief Provided default to get standard behavior:
|
||||
|
||||
The application configure the pair's collision properties once when bounding volume overlap is found and
|
||||
doesn't get asked again about that pair until overlap status or filter properties changes, or re-filtering is requested.
|
||||
|
||||
No notification is provided when bounding volume overlap is lost
|
||||
|
||||
The pair will not be killed or suppressed, so collision detection will be processed
|
||||
*/
|
||||
|
||||
eDEFAULT = 0
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxFilterFlag.
|
||||
|
||||
@see PxFilterFlag
|
||||
*/
|
||||
typedef PxFlags<PxFilterFlag::Enum, PxU16> PxFilterFlags;
|
||||
PX_FLAGS_OPERATORS(PxFilterFlag::Enum, PxU16)
|
||||
|
||||
|
||||
/**
|
||||
\brief PxFilterData is user-definable data which gets passed into the collision filtering shader and/or callback.
|
||||
|
||||
@see PxShape.setSimulationFilterData() PxShape.getSimulationFilterData() PxSimulationFilterShader PxSimulationFilterCallback
|
||||
*/
|
||||
struct PxFilterData
|
||||
{
|
||||
//= ATTENTION! =====================================================================================
|
||||
// Changing the data layout of this class breaks the binary serialization format. See comments for
|
||||
// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
|
||||
// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
|
||||
// accordingly.
|
||||
//==================================================================================================
|
||||
|
||||
PX_INLINE PxFilterData(const PxEMPTY)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Default constructor.
|
||||
*/
|
||||
PX_INLINE PxFilterData()
|
||||
{
|
||||
word0 = word1 = word2 = word3 = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
*/
|
||||
PX_INLINE PxFilterData(const PxFilterData& fd) : word0(fd.word0), word1(fd.word1), word2(fd.word2), word3(fd.word3) {}
|
||||
|
||||
/**
|
||||
\brief Constructor to set filter data initially.
|
||||
*/
|
||||
PX_INLINE PxFilterData(PxU32 w0, PxU32 w1, PxU32 w2, PxU32 w3) : word0(w0), word1(w1), word2(w2), word3(w3) {}
|
||||
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE void setToDefault()
|
||||
{
|
||||
*this = PxFilterData();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator = (const PxFilterData& fd)
|
||||
{
|
||||
word0 = fd.word0;
|
||||
word1 = fd.word1;
|
||||
word2 = fd.word2;
|
||||
word3 = fd.word3;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Comparison operator to allow use in Array.
|
||||
*/
|
||||
PX_INLINE bool operator == (const PxFilterData& a) const
|
||||
{
|
||||
return a.word0 == word0 && a.word1 == word1 && a.word2 == word2 && a.word3 == word3;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Comparison operator to allow use in Array.
|
||||
*/
|
||||
PX_INLINE bool operator != (const PxFilterData& a) const
|
||||
{
|
||||
return !(a == *this);
|
||||
}
|
||||
|
||||
PxU32 word0;
|
||||
PxU32 word1;
|
||||
PxU32 word2;
|
||||
PxU32 word3;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Identifies each type of filter object.
|
||||
|
||||
@see PxGetFilterObjectType()
|
||||
*/
|
||||
struct PxFilterObjectType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief A static rigid body
|
||||
@see PxRigidStatic
|
||||
*/
|
||||
eRIGID_STATIC,
|
||||
|
||||
/**
|
||||
\brief A dynamic rigid body
|
||||
@see PxRigidDynamic
|
||||
*/
|
||||
eRIGID_DYNAMIC,
|
||||
|
||||
/**
|
||||
\brief An articulation
|
||||
@see PxArticulationReducedCoordinate
|
||||
*/
|
||||
eARTICULATION,
|
||||
|
||||
/**
|
||||
\brief A particle system
|
||||
@see PxParticleSystem
|
||||
*/
|
||||
ePARTICLESYSTEM,
|
||||
|
||||
/**
|
||||
\brief A FEM-based soft body
|
||||
@see PxSoftBody
|
||||
*/
|
||||
eSOFTBODY,
|
||||
|
||||
/**
|
||||
\brief A FEM-based cloth
|
||||
\note In development
|
||||
@see PxFEMCloth
|
||||
*/
|
||||
eFEMCLOTH,
|
||||
|
||||
/**
|
||||
\brief A hair system
|
||||
\note In development
|
||||
@see PxHairSystem
|
||||
*/
|
||||
eHAIRSYSTEM,
|
||||
|
||||
//! \brief internal use only!
|
||||
eMAX_TYPE_COUNT = 16,
|
||||
|
||||
//! \brief internal use only!
|
||||
eUNDEFINED = eMAX_TYPE_COUNT-1
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// For internal use only
|
||||
struct PxFilterObjectFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eKINEMATIC = (1<<4),
|
||||
eTRIGGER = (1<<5)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Structure which gets passed into the collision filtering shader and/or callback providing additional information on objects of a collision pair
|
||||
|
||||
@see PxSimulationFilterShader PxSimulationFilterCallback getActorType() PxFilterObjectIsKinematic() PxFilterObjectIsTrigger()
|
||||
*/
|
||||
typedef PxU32 PxFilterObjectAttributes;
|
||||
|
||||
|
||||
/**
|
||||
\brief Extract filter object type from the filter attributes of a collision pair object
|
||||
|
||||
\param[in] attr The filter attribute of a collision pair object
|
||||
\return The type of the collision pair object.
|
||||
|
||||
@see PxFilterObjectType
|
||||
*/
|
||||
PX_INLINE PxFilterObjectType::Enum PxGetFilterObjectType(PxFilterObjectAttributes attr)
|
||||
{
|
||||
return PxFilterObjectType::Enum(attr & (PxFilterObjectType::eMAX_TYPE_COUNT-1));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Specifies whether the collision object belongs to a kinematic rigid body
|
||||
|
||||
\param[in] attr The filter attribute of a collision pair object
|
||||
\return True if the object belongs to a kinematic rigid body, else false
|
||||
|
||||
@see PxRigidBodyFlag::eKINEMATIC
|
||||
*/
|
||||
PX_INLINE bool PxFilterObjectIsKinematic(PxFilterObjectAttributes attr)
|
||||
{
|
||||
return (attr & PxFilterObjectFlag::eKINEMATIC) != 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Specifies whether the collision object is a trigger shape
|
||||
|
||||
\param[in] attr The filter attribute of a collision pair object
|
||||
\return True if the object is a trigger shape, else false
|
||||
|
||||
@see PxShapeFlag::eTRIGGER_SHAPE
|
||||
*/
|
||||
PX_INLINE bool PxFilterObjectIsTrigger(PxFilterObjectAttributes attr)
|
||||
{
|
||||
return (attr & PxFilterObjectFlag::eTRIGGER) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Filter method to specify how a pair of potentially colliding objects should be processed.
|
||||
|
||||
Collision filtering is a mechanism to specify how a pair of potentially colliding objects should be processed by the
|
||||
simulation. A pair of objects is potentially colliding if the bounding volumes of the two objects overlap.
|
||||
In short, a collision filter decides whether a collision pair should get processed, temporarily ignored or discarded.
|
||||
If a collision pair should get processed, the filter can additionally specify how it should get processed, for instance,
|
||||
whether contacts should get resolved, which callbacks should get invoked or which reports should be sent etc.
|
||||
The function returns the PxFilterFlag flags and sets the PxPairFlag flags to define what the simulation should do with the given collision pair.
|
||||
|
||||
\note A default implementation of a filter shader is provided in the PhysX extensions library, see #PxDefaultSimulationFilterShader.
|
||||
|
||||
This methods gets called when:
|
||||
\li The bounding volumes of two objects start to overlap.
|
||||
\li The bounding volumes of two objects overlap and the filter data or filter attributes of one of the objects changed
|
||||
\li A re-filtering was forced through resetFiltering() (see #PxScene::resetFiltering())
|
||||
\li Filtering is requested in scene queries
|
||||
|
||||
\note Certain pairs of objects are always ignored and this method does not get called. This is the case for the
|
||||
following pairs:
|
||||
|
||||
\li Pair of static rigid actors
|
||||
\li A static rigid actor and a kinematic actor (unless one is a trigger or if explicitly enabled through PxPairFilteringMode::eKEEP)
|
||||
\li Two kinematic actors (unless one is a trigger or if explicitly enabled through PxPairFilteringMode::eKEEP)
|
||||
\li Two jointed rigid bodies and the joint was defined to disable collision
|
||||
\li Two articulation links if connected through an articulation joint
|
||||
|
||||
\note This is a performance critical method and should be stateless. You should neither access external objects
|
||||
from within this method nor should you call external methods that are not inlined. If you need a more complex
|
||||
logic to filter a collision pair then use the filter callback mechanism for this pair (see #PxSimulationFilterCallback,
|
||||
#PxFilterFlag::eCALLBACK, #PxFilterFlag::eNOTIFY).
|
||||
|
||||
\param[in] attributes0 The filter attribute of the first object
|
||||
\param[in] filterData0 The custom filter data of the first object
|
||||
\param[in] attributes1 The filter attribute of the second object
|
||||
\param[in] filterData1 The custom filter data of the second object
|
||||
\param[out] pairFlags Flags giving additional information on how an accepted pair should get processed
|
||||
\param[in] constantBlock The constant global filter data (see #PxSceneDesc.filterShaderData)
|
||||
\param[in] constantBlockSize Size of the global filter data (see #PxSceneDesc.filterShaderDataSize)
|
||||
\return Filter flags defining whether the pair should be discarded, temporarily ignored, processed and whether the
|
||||
filter callback should get invoked for this pair.
|
||||
|
||||
@see PxSimulationFilterCallback PxFilterData PxFilterObjectAttributes PxFilterFlag PxFilterFlags PxPairFlag PxPairFlags PxSceneDesc.filterShader
|
||||
*/
|
||||
typedef PxFilterFlags (*PxSimulationFilterShader)
|
||||
(PxFilterObjectAttributes attributes0, PxFilterData filterData0,
|
||||
PxFilterObjectAttributes attributes1, PxFilterData filterData1,
|
||||
PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief Filter callback to specify handling of collision pairs.
|
||||
|
||||
This class is provided to implement more complex and flexible collision pair filtering logic, for instance, taking
|
||||
the state of the user application into account. Filter callbacks also give the user the opportunity to track collision
|
||||
pairs and update their filter state.
|
||||
|
||||
You might want to check the documentation on #PxSimulationFilterShader as well since it includes more general information
|
||||
on filtering.
|
||||
|
||||
\note SDK state should not be modified from within the callbacks. In particular objects should not
|
||||
be created or destroyed. If state modification is needed then the changes should be stored to a buffer
|
||||
and performed after the simulation step.
|
||||
|
||||
\note The callbacks may execute in user threads or simulation threads, possibly simultaneously. The corresponding objects
|
||||
may have been deleted by the application earlier in the frame. It is the application's responsibility to prevent race conditions
|
||||
arising from using the SDK API in the callback while an application thread is making write calls to the scene, and to ensure that
|
||||
the callbacks are thread-safe. Return values which depend on when the callback is called during the frame will introduce nondeterminism
|
||||
into the simulation.
|
||||
|
||||
@see PxSceneDesc.filterCallback PxSimulationFilterShader
|
||||
*/
|
||||
class PxSimulationFilterCallback
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Filter method to specify how a pair of potentially colliding objects should be processed.
|
||||
|
||||
This method gets called when the filter flags returned by the filter shader (see #PxSimulationFilterShader)
|
||||
indicate that the filter callback should be invoked (#PxFilterFlag::eCALLBACK or #PxFilterFlag::eNOTIFY set).
|
||||
Return the PxFilterFlag flags and set the PxPairFlag flags to define what the simulation should do with the given
|
||||
collision pair.
|
||||
|
||||
\param[in] pairID Unique ID of the collision pair used to issue filter status changes for the pair (see #statusChange())
|
||||
\param[in] attributes0 The filter attribute of the first object
|
||||
\param[in] filterData0 The custom filter data of the first object
|
||||
\param[in] a0 Actor pointer of the first object
|
||||
\param[in] s0 Shape pointer of the first object (NULL if the object has no shapes)
|
||||
\param[in] attributes1 The filter attribute of the second object
|
||||
\param[in] filterData1 The custom filter data of the second object
|
||||
\param[in] a1 Actor pointer of the second object
|
||||
\param[in] s1 Shape pointer of the second object (NULL if the object has no shapes)
|
||||
\param[in,out] pairFlags In: Pair flags returned by the filter shader. Out: Additional information on how an accepted pair should get processed
|
||||
\return Filter flags defining whether the pair should be discarded, temporarily ignored or processed and whether the pair
|
||||
should be tracked and send a report on pair deletion through the filter callback
|
||||
|
||||
@see PxSimulationFilterShader PxFilterData PxFilterObjectAttributes PxFilterFlag PxPairFlag
|
||||
*/
|
||||
virtual PxFilterFlags pairFound( PxU32 pairID,
|
||||
PxFilterObjectAttributes attributes0, PxFilterData filterData0, const PxActor* a0, const PxShape* s0,
|
||||
PxFilterObjectAttributes attributes1, PxFilterData filterData1, const PxActor* a1, const PxShape* s1,
|
||||
PxPairFlags& pairFlags) = 0;
|
||||
|
||||
/**
|
||||
\brief Callback to inform that a tracked collision pair is gone.
|
||||
|
||||
This method gets called when a collision pair disappears or gets re-filtered. Only applies to
|
||||
collision pairs which have been marked as filter callback pairs (#PxFilterFlag::eNOTIFY set in #pairFound()).
|
||||
|
||||
\param[in] pairID Unique ID of the collision pair that disappeared
|
||||
\param[in] attributes0 The filter attribute of the first object
|
||||
\param[in] filterData0 The custom filter data of the first object
|
||||
\param[in] attributes1 The filter attribute of the second object
|
||||
\param[in] filterData1 The custom filter data of the second object
|
||||
\param[in] objectRemoved True if the pair was lost because one of the objects got removed from the scene
|
||||
|
||||
@see pairFound() PxSimulationFilterShader PxFilterData PxFilterObjectAttributes
|
||||
*/
|
||||
virtual void pairLost( PxU32 pairID,
|
||||
PxFilterObjectAttributes attributes0,
|
||||
PxFilterData filterData0,
|
||||
PxFilterObjectAttributes attributes1,
|
||||
PxFilterData filterData1,
|
||||
bool objectRemoved) = 0;
|
||||
|
||||
/**
|
||||
\brief Callback to give the opportunity to change the filter state of a tracked collision pair.
|
||||
|
||||
This method gets called once per simulation step to let the application change the filter and pair
|
||||
flags of a collision pair that has been reported in #pairFound() and requested callbacks by
|
||||
setting #PxFilterFlag::eNOTIFY. To request a change of filter status, the target pair has to be
|
||||
specified by its ID, the new filter and pair flags have to be provided and the method should return true.
|
||||
|
||||
\note If this method changes the filter status of a collision pair and the pair should keep being tracked
|
||||
by the filter callbacks then #PxFilterFlag::eNOTIFY has to be set.
|
||||
|
||||
\note The application is responsible to ensure that this method does not get called for pairs that have been
|
||||
reported as lost, see #pairLost().
|
||||
|
||||
\param[out] pairID ID of the collision pair for which the filter status should be changed
|
||||
\param[out] pairFlags The new pairFlags to apply to the collision pair
|
||||
\param[out] filterFlags The new filterFlags to apply to the collision pair
|
||||
\return True if the changes should be applied. In this case the method will get called again. False if
|
||||
no more status changes should be done in the current simulation step. In that case the provided flags will be discarded.
|
||||
|
||||
@see pairFound() pairLost() PxFilterFlag PxPairFlag
|
||||
*/
|
||||
virtual bool statusChange(PxU32& pairID, PxPairFlags& pairFlags, PxFilterFlags& filterFlags) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxSimulationFilterCallback() {}
|
||||
};
|
||||
|
||||
struct PxPairFilteringMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief Output pair from BP, potentially send to user callbacks, create regular interaction object.
|
||||
|
||||
Enable contact pair filtering between kinematic/static or kinematic/kinematic rigid bodies.
|
||||
|
||||
By default contacts between these are suppressed (see #PxFilterFlag::eSUPPRESS) and don't get reported to the filter mechanism.
|
||||
Use this mode if these pairs should go through the filtering pipeline nonetheless.
|
||||
|
||||
\note This mode is not mutable, and must be set in PxSceneDesc at scene creation.
|
||||
*/
|
||||
eKEEP,
|
||||
|
||||
/**
|
||||
\brief Output pair from BP, create interaction marker. Can be later switched to regular interaction.
|
||||
*/
|
||||
eSUPPRESS,
|
||||
|
||||
/**
|
||||
\brief Don't output pair from BP. Cannot be later switched to regular interaction, needs "resetFiltering" call.
|
||||
*/
|
||||
eKILL,
|
||||
|
||||
/**
|
||||
\brief Default is eSUPPRESS for compatibility with previous PhysX versions.
|
||||
*/
|
||||
eDEFAULT PX_DEPRECATED = eSUPPRESS
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Struct for storing a particle/vertex - rigid filter pair with comparison operators
|
||||
*/
|
||||
struct PxParticleRigidFilterPair
|
||||
{
|
||||
PxU64 mID0; //!< Rigid node index
|
||||
PxU64 mID1; //!< Particle/vertex id
|
||||
|
||||
PX_CUDA_CALLABLE bool operator<(const PxParticleRigidFilterPair& other) const
|
||||
{
|
||||
if(mID0 < other.mID0)
|
||||
return true;
|
||||
if(mID0 == other.mID0 && mID1 < other.mID1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE bool operator>(const PxParticleRigidFilterPair& other) const
|
||||
{
|
||||
if(mID0 > other.mID0)
|
||||
return true;
|
||||
if(mID0 == other.mID0 && mID1 > other.mID1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE bool operator==(const PxParticleRigidFilterPair& other) const
|
||||
{
|
||||
return (mID0 == other.mID0 && mID1 == other.mID1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_FORCE_MODE_H
|
||||
#define PX_FORCE_MODE_H
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Parameter to addForce() and addTorque() calls, determines the exact operation that is carried out.
|
||||
|
||||
@see PxRigidBody.addForce() PxRigidBody.addTorque()
|
||||
*/
|
||||
struct PxForceMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eFORCE, //!< parameter has unit of mass * length / time^2, i.e., a force
|
||||
eIMPULSE, //!< parameter has unit of mass * length / time, i.e., force * time
|
||||
eVELOCITY_CHANGE, //!< parameter has unit of length / time, i.e., the effect is mass independent: a velocity change.
|
||||
eACCELERATION //!< parameter has unit of length/ time^2, i.e., an acceleration. It gets treated just like a force except the mass is not divided out before integration.
|
||||
};
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,74 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_HAIR_SYSTEM_FLAG_H
|
||||
#define PX_HAIR_SYSTEM_FLAG_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Identifies input and output buffers for PxHairSystem
|
||||
\see PxHairSystemData::readData(), PxHairSystemData::writeData(), PxBuffer
|
||||
*/
|
||||
struct PxHairSystemData
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE = 0, //!< No data specified
|
||||
ePOSITION_INVMASS = 1 << 0, //!< Specifies the position (first 3 floats) and inverse mass (last float) data (array of PxVec4 * max number of vertices)
|
||||
eVELOCITY = 1 << 1, //!< Specifies the velocity (first 3 floats) data (array of PxVec4 * max number of vertices)
|
||||
eALL = ePOSITION_INVMASS | eVELOCITY //!< Specifies everything
|
||||
};
|
||||
};
|
||||
typedef PxFlags<PxHairSystemData::Enum, PxU32> PxHairSystemDataFlags;
|
||||
|
||||
/**
|
||||
\brief Binary settings for hair system simulation
|
||||
*/
|
||||
struct PxHairSystemFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eDISABLE_SELF_COLLISION = 1 << 0, //!< Determines if self-collision between hair vertices is ignored
|
||||
eDISABLE_EXTERNAL_COLLISION = 1 << 1, //!< Determines if collision between hair and external bodies is ignored
|
||||
eDISABLE_TWOSIDED_ATTACHMENT = 1 << 2 //!< Determines if attachment constraint is also felt by body to which the hair is attached
|
||||
};
|
||||
};
|
||||
typedef PxFlags<PxHairSystemFlag::Enum, PxU32> PxHairSystemFlags;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,771 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_IMMEDIATE_MODE_H
|
||||
#define PX_IMMEDIATE_MODE_H
|
||||
/** \addtogroup immediatemode
|
||||
@{ */
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
#include "solver/PxSolverDefs.h"
|
||||
#include "collision/PxCollisionDefs.h"
|
||||
#include "PxArticulationReducedCoordinate.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxCudaContextManager;
|
||||
class PxBaseTask;
|
||||
class PxGeometry;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace immediate
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef void* PxArticulationHandle;
|
||||
|
||||
/**
|
||||
\brief Structure to store linear and angular components of spatial vector
|
||||
*/
|
||||
struct PxSpatialVector
|
||||
{
|
||||
PxVec3 top;
|
||||
PxReal pad0;
|
||||
PxVec3 bottom;
|
||||
PxReal pad1;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Structure to store rigid body properties
|
||||
*/
|
||||
struct PxRigidBodyData
|
||||
{
|
||||
PX_ALIGN(16, PxVec3 linearVelocity); //!< 12 Linear velocity
|
||||
PxReal invMass; //!< 16 Inverse mass
|
||||
PxVec3 angularVelocity; //!< 28 Angular velocity
|
||||
PxReal maxDepenetrationVelocity; //!< 32 Maximum de-penetration velocity
|
||||
PxVec3 invInertia; //!< 44 Mass-space inverse interia diagonal vector
|
||||
PxReal maxContactImpulse; //!< 48 Maximum permissable contact impulse
|
||||
PxTransform body2World; //!< 76 World space transform
|
||||
PxReal linearDamping; //!< 80 Linear damping coefficient
|
||||
PxReal angularDamping; //!< 84 Angular damping coefficient
|
||||
PxReal maxLinearVelocitySq; //!< 88 Squared maximum linear velocity
|
||||
PxReal maxAngularVelocitySq; //!< 92 Squared maximum angular velocity
|
||||
PxU32 pad; //!< 96 Padding for 16-byte alignment
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Callback class to record contact points produced by immediate::PxGenerateContacts
|
||||
*/
|
||||
class PxContactRecorder
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Method to record new contacts
|
||||
\param [in] contactPoints The contact points produced
|
||||
\param [in] nbContacts The number of contact points produced
|
||||
\param [in] index The index of this pair. This is an index from 0-N-1 identifying which pair this relates to from within the array of pairs passed to PxGenerateContacts
|
||||
\return a boolean to indicate if this callback successfully stored the contacts or not.
|
||||
*/
|
||||
virtual bool recordContacts(const PxContactPoint* contactPoints, const PxU32 nbContacts, const PxU32 index) = 0;
|
||||
|
||||
virtual ~PxContactRecorder(){}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Constructs a PxSolverBodyData structure based on rigid body properties. Applies gravity, damping and clamps maximum velocity.
|
||||
\param [in] inRigidData The array rigid body properties
|
||||
\param [out] outSolverBodyData The array of solverBodyData produced to represent these bodies
|
||||
\param [in] nbBodies The total number of solver bodies to create
|
||||
\param [in] gravity The gravity vector
|
||||
\param [in] dt The timestep
|
||||
\param [in] gyroscopicForces Indicates whether gyroscopic forces should be integrated
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxConstructSolverBodies(const PxRigidBodyData* inRigidData, PxSolverBodyData* outSolverBodyData, PxU32 nbBodies, const PxVec3& gravity, PxReal dt, bool gyroscopicForces = false);
|
||||
|
||||
/**
|
||||
\brief Constructs a PxSolverBodyData structure for a static body at a given pose.
|
||||
\param [in] globalPose The pose of this static actor
|
||||
\param [out] solverBodyData The solver body representation of this static actor
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxConstructStaticSolverBody(const PxTransform& globalPose, PxSolverBodyData& solverBodyData);
|
||||
|
||||
/**
|
||||
\brief Groups together sets of independent PxSolverConstraintDesc objects to be solved using SIMD SOA approach.
|
||||
\param [in] solverConstraintDescs The set of solver constraint descs to batch
|
||||
\param [in] nbConstraints The number of constraints to batch
|
||||
\param [in,out] solverBodies The array of solver bodies that the constraints reference. Some fields in these structures are written to as scratch memory for the batching.
|
||||
\param [in] nbBodies The number of bodies
|
||||
\param [out] outBatchHeaders The batch headers produced by this batching process. This array must have at least 1 entry per input constraint
|
||||
\param [out] outOrderedConstraintDescs A reordered copy of the constraint descs. This array is referenced by the constraint batches. This array must have at least 1 entry per input constraint.
|
||||
\param [in,out] articulations The array of articulations that the constraints reference. Some fields in these structures are written to as scratch memory for the batching.
|
||||
\param [in] nbArticulations The number of articulations
|
||||
\return The total number of batches produced. This should be less than or equal to nbConstraints.
|
||||
|
||||
\note This method considers all bodies within the range [0, nbBodies-1] to be valid dynamic bodies. A given dynamic body can only be referenced in a batch once. Static or kinematic bodies can be
|
||||
referenced multiple times within a batch safely because constraints do not affect their velocities. The batching will implicitly consider any bodies outside of the range [0, nbBodies-1] to be
|
||||
infinite mass (static or kinematic). This means that either appending static/kinematic to the end of the array of bodies or placing static/kinematic bodies at before the start body pointer
|
||||
will ensure that the minimum number of batches are produced.
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxU32 PxBatchConstraints( const PxSolverConstraintDesc* solverConstraintDescs, PxU32 nbConstraints, PxSolverBody* solverBodies, PxU32 nbBodies,
|
||||
PxConstraintBatchHeader* outBatchHeaders, PxSolverConstraintDesc* outOrderedConstraintDescs,
|
||||
PxArticulationHandle* articulations=NULL, PxU32 nbArticulations=0);
|
||||
|
||||
/**
|
||||
\brief Creates a set of contact constraint blocks. Note that, depending the results of PxBatchConstraints, each batchHeader may refer to up to 4 solverConstraintDescs.
|
||||
This function will allocate both constraint and friction patch data via the PxConstraintAllocator provided. Constraint data is only valid until PxSolveConstraints has completed.
|
||||
Friction data is to be retained and provided by the application for friction correlation.
|
||||
|
||||
\param [in] batchHeaders Array of batch headers to process
|
||||
\param [in] nbHeaders The total number of headers
|
||||
\param [in] contactDescs An array of contact descs defining the pair and contact properties of each respective contacting pair
|
||||
\param [in] allocator An allocator callback to allocate constraint and friction memory
|
||||
\param [in] invDt The inverse timestep
|
||||
\param [in] bounceThreshold The bounce threshold. Relative velocities below this will be solved by bias only. Relative velocities above this will be solved by restitution. If restitution is zero
|
||||
then these pairs will always be solved by bias.
|
||||
\param [in] frictionOffsetThreshold The friction offset threshold. Contacts whose separations are below this threshold can generate friction constraints.
|
||||
\param [in] correlationDistance The correlation distance used by friction correlation to identify whether a friction patch is broken on the grounds of relation separation.
|
||||
\param [out] Z Temporary buffer for impulse propagation.
|
||||
|
||||
\return a boolean to define if this method was successful or not.
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateContactConstraints(PxConstraintBatchHeader* batchHeaders, PxU32 nbHeaders, PxSolverContactDesc* contactDescs,
|
||||
PxConstraintAllocator& allocator, PxReal invDt, PxReal bounceThreshold, PxReal frictionOffsetThreshold, PxReal correlationDistance,
|
||||
PxSpatialVector* Z = NULL);
|
||||
|
||||
/**
|
||||
\brief Creates a set of joint constraint blocks. Note that, depending the results of PxBatchConstraints, the batchHeader may refer to up to 4 solverConstraintDescs
|
||||
\param [in] batchHeaders The array of batch headers to be processed.
|
||||
\param [in] nbHeaders The total number of batch headers to process.
|
||||
\param [in] jointDescs An array of constraint prep descs defining the properties of the constraints being created.
|
||||
\param [in] allocator An allocator callback to allocate constraint data.
|
||||
\param [in] dt The timestep.
|
||||
\param [in] invDt The inverse timestep.
|
||||
\param [out] Z Temporary buffer for impulse propagation.
|
||||
\return a boolean indicating if this method was successful or not.
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateJointConstraints(PxConstraintBatchHeader* batchHeaders, PxU32 nbHeaders, PxSolverConstraintPrepDesc* jointDescs, PxConstraintAllocator& allocator, PxSpatialVector* Z, PxReal dt, PxReal invDt);
|
||||
|
||||
/**
|
||||
\brief Creates a set of joint constraint blocks. This function runs joint shaders defined inside PxConstraint** param, fills in joint row information in jointDescs and then calls PxCreateJointConstraints.
|
||||
\param [in] batchHeaders The set of batchHeaders to be processed.
|
||||
\param [in] nbBatchHeaders The number of batch headers to process.
|
||||
\param [in] constraints The set of constraints to be used to produce constraint rows.
|
||||
\param [in,out] jointDescs An array of constraint prep descs defining the properties of the constraints being created.
|
||||
\param [in] allocator An allocator callback to allocate constraint data.
|
||||
\param [in] dt The timestep.
|
||||
\param [in] invDt The inverse timestep.
|
||||
\param [out] Z Temporary buffer for impulse propagation.
|
||||
\return a boolean indicating if this method was successful or not.
|
||||
@see PxCreateJointConstraints
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateJointConstraintsWithShaders(PxConstraintBatchHeader* batchHeaders, PxU32 nbBatchHeaders, PxConstraint** constraints, PxSolverConstraintPrepDesc* jointDescs, PxConstraintAllocator& allocator, PxReal dt, PxReal invDt, PxSpatialVector* Z = NULL);
|
||||
|
||||
struct PxImmediateConstraint
|
||||
{
|
||||
PxConstraintSolverPrep prep;
|
||||
const void* constantBlock;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Creates a set of joint constraint blocks. This function runs joint shaders defined inside PxImmediateConstraint* param, fills in joint row information in jointDescs and then calls PxCreateJointConstraints.
|
||||
\param [in] batchHeaders The set of batchHeaders to be processed.
|
||||
\param [in] nbBatchHeaders The number of batch headers to process.
|
||||
\param [in] constraints The set of constraints to be used to produce constraint rows.
|
||||
\param [in,out] jointDescs An array of constraint prep descs defining the properties of the constraints being created.
|
||||
\param [in] allocator An allocator callback to allocate constraint data.
|
||||
\param [in] dt The timestep.
|
||||
\param [in] invDt The inverse timestep.
|
||||
\param [out] Z Temporary buffer for impulse propagation.
|
||||
\return a boolean indicating if this method was successful or not.
|
||||
@see PxCreateJointConstraints
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateJointConstraintsWithImmediateShaders(PxConstraintBatchHeader* batchHeaders, PxU32 nbBatchHeaders, PxImmediateConstraint* constraints, PxSolverConstraintPrepDesc* jointDescs, PxConstraintAllocator& allocator, PxReal dt, PxReal invDt, PxSpatialVector* Z = NULL);
|
||||
|
||||
/**
|
||||
\brief Iteratively solves the set of constraints defined by the provided PxConstraintBatchHeader and PxSolverConstraintDesc structures. Updates deltaVelocities inside the PxSolverBody structures. Produces resulting linear and angular motion velocities.
|
||||
\param [in] batchHeaders The set of batch headers to be solved
|
||||
\param [in] nbBatchHeaders The total number of batch headers to be solved
|
||||
\param [in] solverConstraintDescs The reordererd set of solver constraint descs referenced by the batch headers
|
||||
\param [in,out] solverBodies The set of solver bodies the bodies reference
|
||||
\param [out] linearMotionVelocity The resulting linear motion velocity
|
||||
\param [out] angularMotionVelocity The resulting angular motion velocity.
|
||||
\param [in] nbSolverBodies The total number of solver bodies
|
||||
\param [in] nbPositionIterations The number of position iterations to run
|
||||
\param [in] nbVelocityIterations The number of velocity iterations to run
|
||||
\param [in] dt Timestep. Only needed if articulations are sent to the function.
|
||||
\param [in] invDt Inverse timestep. Only needed if articulations are sent to the function.
|
||||
\param [in] nbSolverArticulations Number of articulations to solve constraints for.
|
||||
\param [in] solverArticulations Array of articulations to solve constraints for.
|
||||
\param [out] Z Temporary buffer for impulse propagation
|
||||
\param [out] deltaV Temporary buffer for velocity change
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxSolveConstraints(const PxConstraintBatchHeader* batchHeaders, PxU32 nbBatchHeaders, const PxSolverConstraintDesc* solverConstraintDescs,
|
||||
const PxSolverBody* solverBodies, PxVec3* linearMotionVelocity, PxVec3* angularMotionVelocity, PxU32 nbSolverBodies, PxU32 nbPositionIterations, PxU32 nbVelocityIterations,
|
||||
float dt=0.0f, float invDt=0.0f, PxU32 nbSolverArticulations=0, PxArticulationHandle* solverArticulations=NULL, PxSpatialVector* Z = NULL, PxSpatialVector* deltaV = NULL);
|
||||
|
||||
/**
|
||||
\brief Integrates a rigid body, returning the new velocities and transforms. After this function has been called, solverBodyData stores all the body's velocity data.
|
||||
|
||||
\param [in,out] solverBodyData The array of solver body data to be integrated
|
||||
\param [in] solverBody The bodies' linear and angular velocities
|
||||
\param [in] linearMotionVelocity The bodies' linear motion velocity array
|
||||
\param [in] angularMotionState The bodies' angular motion velocity array
|
||||
\param [in] nbBodiesToIntegrate The total number of bodies to integrate
|
||||
\param [in] dt The timestep
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxIntegrateSolverBodies(PxSolverBodyData* solverBodyData, PxSolverBody* solverBody, const PxVec3* linearMotionVelocity, const PxVec3* angularMotionState, PxU32 nbBodiesToIntegrate, PxReal dt);
|
||||
|
||||
/**
|
||||
\brief Performs contact generation for a given pair of geometries at the specified poses. Produced contacts are stored in the provided contact recorder. Information is cached in PxCache structure
|
||||
to accelerate future contact generation between pairs. This cache data is valid only as long as the memory provided by PxCacheAllocator has not been released/re-used. Recommendation is to
|
||||
retain that data for a single simulation frame, discarding cached data after 2 frames. If the cached memory has been released/re-used prior to the corresponding pair having contact generation
|
||||
performed again, it is the application's responsibility to reset the PxCache.
|
||||
|
||||
\param [in] geom0 Array of geometries to perform collision detection on.
|
||||
\param [in] geom1 Array of geometries to perform collision detection on
|
||||
\param [in] pose0 Array of poses associated with the corresponding entry in the geom0 array
|
||||
\param [in] pose1 Array of poses associated with the corresponding entry in the geom1 array
|
||||
\param [in,out] contactCache Array of contact caches associated with each pair geom0[i] + geom1[i]
|
||||
\param [in] nbPairs The total number of pairs to process
|
||||
\param [out] contactRecorder A callback that is called to record contacts for each pair that detects contacts
|
||||
\param [in] contactDistance The distance at which contacts begin to be generated between the pairs
|
||||
\param [in] meshContactMargin The mesh contact margin.
|
||||
\param [in] toleranceLength The toleranceLength. Used for scaling distance-based thresholds internally to produce appropriate results given simulations in different units
|
||||
\param [in] allocator A callback to allocate memory for the contact cache
|
||||
|
||||
\return a boolean indicating if the function was successful or not.
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxGenerateContacts( const PxGeometry* const * geom0, const PxGeometry* const * geom1, const PxTransform* pose0, const PxTransform* pose1,
|
||||
PxCache* contactCache, PxU32 nbPairs, PxContactRecorder& contactRecorder,
|
||||
PxReal contactDistance, PxReal meshContactMargin, PxReal toleranceLength, PxCacheAllocator& allocator);
|
||||
|
||||
/**
|
||||
\brief Register articulation-related solver functions. This is equivalent to PxRegisterArticulationsReducedCoordinate() for PxScene-level articulations.
|
||||
Call this first to enable reduced coordinates articulations in immediate mode.
|
||||
|
||||
@see PxRegisterArticulationsReducedCoordinate
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxRegisterImmediateArticulations();
|
||||
|
||||
struct PxArticulationJointDataRC
|
||||
{
|
||||
PxTransform parentPose;
|
||||
PxTransform childPose;
|
||||
PxArticulationMotion::Enum motion[PxArticulationAxis::eCOUNT];
|
||||
PxArticulationLimit limits[PxArticulationAxis::eCOUNT];
|
||||
PxArticulationDrive drives[PxArticulationAxis::eCOUNT];
|
||||
PxReal targetPos[PxArticulationAxis::eCOUNT];
|
||||
PxReal targetVel[PxArticulationAxis::eCOUNT];
|
||||
PxReal armature[PxArticulationAxis::eCOUNT];
|
||||
PxReal jointPos[PxArticulationAxis::eCOUNT];
|
||||
PxReal jointVel[PxArticulationAxis::eCOUNT];
|
||||
PxReal frictionCoefficient;
|
||||
PxReal maxJointVelocity;
|
||||
PxArticulationJointType::Enum type;
|
||||
|
||||
void initData()
|
||||
{
|
||||
parentPose = PxTransform(PxIdentity);
|
||||
childPose = PxTransform(PxIdentity);
|
||||
frictionCoefficient = 0.05f;
|
||||
maxJointVelocity = 100.0f;
|
||||
type = PxArticulationJointType::eUNDEFINED; // For root
|
||||
|
||||
for(PxU32 i=0;i<PxArticulationAxis::eCOUNT;i++)
|
||||
{
|
||||
motion[i] = PxArticulationMotion::eLOCKED;
|
||||
limits[i] = PxArticulationLimit(0.0f, 0.0f);
|
||||
drives[i] = PxArticulationDrive(0.0f, 0.0f, 0.0f);
|
||||
armature[i] = 0.0f;
|
||||
jointPos[i] = 0.0f;
|
||||
jointVel[i] = 0.0f;
|
||||
}
|
||||
PxMemSet(targetPos, 0xff, sizeof(PxReal)*PxArticulationAxis::eCOUNT);
|
||||
PxMemSet(targetVel, 0xff, sizeof(PxReal)*PxArticulationAxis::eCOUNT);
|
||||
}
|
||||
};
|
||||
|
||||
struct PxArticulationDataRC
|
||||
{
|
||||
PxArticulationFlags flags;
|
||||
};
|
||||
|
||||
struct PxArticulationLinkMutableDataRC
|
||||
{
|
||||
PxVec3 inverseInertia;
|
||||
float inverseMass;
|
||||
float linearDamping;
|
||||
float angularDamping;
|
||||
float maxLinearVelocitySq;
|
||||
float maxAngularVelocitySq;
|
||||
float cfmScale;
|
||||
bool disableGravity;
|
||||
|
||||
void initData()
|
||||
{
|
||||
inverseInertia = PxVec3(1.0f);
|
||||
inverseMass = 1.0f;
|
||||
linearDamping = 0.05f;
|
||||
angularDamping = 0.05f;
|
||||
maxLinearVelocitySq = 100.0f * 100.0f;
|
||||
maxAngularVelocitySq = 50.0f * 50.0f;
|
||||
cfmScale = 0.025f;
|
||||
disableGravity = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct PxArticulationLinkDerivedDataRC
|
||||
{
|
||||
PxTransform pose;
|
||||
PxVec3 linearVelocity;
|
||||
PxVec3 angularVelocity;
|
||||
};
|
||||
|
||||
struct PxArticulationLinkDataRC : PxArticulationLinkMutableDataRC
|
||||
{
|
||||
PxArticulationLinkDataRC() { PxArticulationLinkDataRC::initData(); }
|
||||
|
||||
void initData()
|
||||
{
|
||||
pose = PxTransform(PxIdentity);
|
||||
|
||||
PxArticulationLinkMutableDataRC::initData();
|
||||
inboundJoint.initData();
|
||||
}
|
||||
|
||||
PxArticulationJointDataRC inboundJoint;
|
||||
PxTransform pose;
|
||||
};
|
||||
|
||||
typedef void* PxArticulationCookie;
|
||||
|
||||
struct PxArticulationLinkCookie
|
||||
{
|
||||
PxArticulationCookie articulation;
|
||||
PxU32 linkId;
|
||||
};
|
||||
|
||||
struct PxCreateArticulationLinkCookie : PxArticulationLinkCookie
|
||||
{
|
||||
PX_FORCE_INLINE PxCreateArticulationLinkCookie(PxArticulationCookie art=NULL, PxU32 id=0xffffffff)
|
||||
{
|
||||
articulation = art;
|
||||
linkId = id;
|
||||
}
|
||||
};
|
||||
|
||||
struct PxArticulationLinkHandle
|
||||
{
|
||||
PX_FORCE_INLINE PxArticulationLinkHandle(PxArticulationHandle art=NULL, const PxU32 id=0xffffffff) : articulation(art), linkId(id) {}
|
||||
|
||||
PxArticulationHandle articulation;
|
||||
PxU32 linkId;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Begin creation of an immediate-mode reduced-coordinate articulation.
|
||||
|
||||
Returned cookie must be used to add links to the articulation, and to complete creating the articulation.
|
||||
|
||||
The cookie is a temporary ID for the articulation, only valid until PxEndCreateArticulationRC is called.
|
||||
|
||||
\param [in] data Articulation data
|
||||
|
||||
\return Articulation cookie
|
||||
|
||||
@see PxAddArticulationLink PxEndCreateArticulationRC
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxArticulationCookie PxBeginCreateArticulationRC(const PxArticulationDataRC& data);
|
||||
|
||||
/**
|
||||
\brief Add a link to the articulation.
|
||||
|
||||
All links must be added before the articulation is completed. It is not possible to add a new link at runtime.
|
||||
|
||||
Returned cookie is a temporary ID for the link, only valid until PxEndCreateArticulationRC is called.
|
||||
|
||||
\param [in] articulation Cookie value returned by PxBeginCreateArticulationRC
|
||||
\param [in] parent Parent for the new link, or NULL if this is the root link
|
||||
\param [in] data Link data
|
||||
|
||||
\return Link cookie
|
||||
|
||||
@see PxBeginCreateArticulationRC PxEndCreateArticulationRC
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxArticulationLinkCookie PxAddArticulationLink(PxArticulationCookie articulation, const PxArticulationLinkCookie* parent, const PxArticulationLinkDataRC& data);
|
||||
|
||||
/**
|
||||
\brief End creation of an immediate-mode reduced-coordinate articulation.
|
||||
|
||||
This call completes the creation of the articulation. All involved cookies become unsafe to use after that point.
|
||||
|
||||
The links are actually created in this function, and it returns the actual link handles to users. The given buffer should be large enough
|
||||
to contain as many links as created between the PxBeginCreateArticulationRC & PxEndCreateArticulationRC calls, i.e.
|
||||
if N calls were made to PxAddArticulationLink, the buffer should be large enough to contain N handles.
|
||||
|
||||
\param [in] articulation Cookie value returned by PxBeginCreateArticulationRC
|
||||
\param [out] linkHandles Articulation link handles of all created articulation links
|
||||
\param [in] bufferSize Size of linkHandles buffer. Must match internal expected number of articulation links.
|
||||
|
||||
\return Articulation handle, or NULL if creation failed
|
||||
|
||||
@see PxAddArticulationLink PxEndCreateArticulationRC
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxArticulationHandle PxEndCreateArticulationRC(PxArticulationCookie articulation, PxArticulationLinkHandle* linkHandles, PxU32 bufferSize);
|
||||
|
||||
/**
|
||||
\brief Releases an immediate-mode reduced-coordinate articulation.
|
||||
\param [in] articulation Articulation handle
|
||||
|
||||
@see PxCreateFeatherstoneArticulation
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxReleaseArticulation(PxArticulationHandle articulation);
|
||||
|
||||
/**
|
||||
\brief Creates an articulation cache.
|
||||
\param [in] articulation Articulation handle
|
||||
\return Articulation cache
|
||||
|
||||
@see PxReleaseArticulationCache
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxArticulationCache* PxCreateArticulationCache(PxArticulationHandle articulation);
|
||||
|
||||
/**
|
||||
\brief Copy the internal data of the articulation to the cache
|
||||
\param[in] articulation Articulation handle.
|
||||
\param[in] cache Articulation data
|
||||
\param[in] flag Indicates which values of the articulation system are copied to the cache
|
||||
|
||||
@see createCache PxApplyArticulationCache
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxCopyInternalStateToArticulationCache(PxArticulationHandle articulation, PxArticulationCache& cache, PxArticulationCacheFlags flag);
|
||||
|
||||
/**
|
||||
\brief Apply the user defined data in the cache to the articulation system
|
||||
\param[in] articulation Articulation handle.
|
||||
\param[in] cache Articulation data.
|
||||
\param[in] flag Defines which values in the cache will be applied to the articulation
|
||||
|
||||
@see createCache PxCopyInternalStateToArticulationCache
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxApplyArticulationCache(PxArticulationHandle articulation, PxArticulationCache& cache, PxArticulationCacheFlags flag);
|
||||
|
||||
/**
|
||||
\brief Release an articulation cache
|
||||
|
||||
\param[in] cache The cache to release
|
||||
|
||||
@see PxCreateArticulationCache PxCopyInternalStateToArticulationCache PxCopyInternalStateToArticulationCache
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxReleaseArticulationCache(PxArticulationCache& cache);
|
||||
|
||||
/**
|
||||
\brief Retrieves non-mutable link data from a link handle.
|
||||
The data here is computed by the articulation code but cannot be directly changed by users.
|
||||
\param [in] link Link handle
|
||||
\param [out] data Link data
|
||||
\return True if success
|
||||
|
||||
@see PxGetAllLinkData
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxGetLinkData(const PxArticulationLinkHandle& link, PxArticulationLinkDerivedDataRC& data);
|
||||
|
||||
/**
|
||||
\brief Retrieves non-mutable link data from an articulation handle (all links).
|
||||
The data here is computed by the articulation code but cannot be directly changed by users.
|
||||
\param [in] articulation Articulation handle
|
||||
\param [out] data Link data for N links, or NULL to just retrieve the number of links.
|
||||
\return Number of links in the articulation = number of link data structure written to the data array.
|
||||
|
||||
@see PxGetLinkData
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxU32 PxGetAllLinkData(const PxArticulationHandle articulation, PxArticulationLinkDerivedDataRC* data);
|
||||
|
||||
/**
|
||||
\brief Retrieves mutable link data from a link handle.
|
||||
\param [in] link Link handle
|
||||
\param [out] data Data for this link
|
||||
\return True if success
|
||||
|
||||
@see PxSetMutableLinkData
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxGetMutableLinkData(const PxArticulationLinkHandle& link, PxArticulationLinkMutableDataRC& data);
|
||||
|
||||
/**
|
||||
\brief Sets mutable link data for given link.
|
||||
\param [in] link Link handle
|
||||
\param [in] data Data for this link
|
||||
\return True if success
|
||||
|
||||
@see PxGetMutableLinkData
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxSetMutableLinkData(const PxArticulationLinkHandle& link, const PxArticulationLinkMutableDataRC& data);
|
||||
|
||||
/**
|
||||
\brief Retrieves joint data from a link handle.
|
||||
\param [in] link Link handle
|
||||
\param [out] data Joint data for this link
|
||||
\return True if success
|
||||
|
||||
@see PxSetJointData
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxGetJointData(const PxArticulationLinkHandle& link, PxArticulationJointDataRC& data);
|
||||
|
||||
/**
|
||||
\brief Sets joint data for given link.
|
||||
\param [in] link Link handle
|
||||
\param [in] data Joint data for this link
|
||||
\return True if success
|
||||
|
||||
@see PxGetJointData
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxSetJointData(const PxArticulationLinkHandle& link, const PxArticulationJointDataRC& data);
|
||||
|
||||
/**
|
||||
\brief Computes unconstrained velocities for a given articulation.
|
||||
\param [in] articulation Articulation handle
|
||||
\param [in] gravity Gravity vector
|
||||
\param [in] dt Timestep
|
||||
\param [in] invLengthScale 1/lengthScale from PxTolerancesScale.
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxComputeUnconstrainedVelocities(PxArticulationHandle articulation, const PxVec3& gravity, const PxReal dt, const PxReal invLengthScale);
|
||||
|
||||
/**
|
||||
\brief Updates bodies for a given articulation.
|
||||
\param [in] articulation Articulation handle
|
||||
\param [in] dt Timestep
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxUpdateArticulationBodies(PxArticulationHandle articulation, const PxReal dt);
|
||||
|
||||
/**
|
||||
\brief Computes unconstrained velocities for a given articulation.
|
||||
\param [in] articulation Articulation handle
|
||||
\param [in] gravity Gravity vector
|
||||
\param [in] dt Timestep/numPosIterations
|
||||
\param [in] totalDt Timestep
|
||||
\param [in] invDt 1/(Timestep/numPosIterations)
|
||||
\param [in] invTotalDt 1/Timestep
|
||||
\param [in] invLengthScale 1/lengthScale from PxTolerancesScale.
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxComputeUnconstrainedVelocitiesTGS( PxArticulationHandle articulation, const PxVec3& gravity, const PxReal dt,
|
||||
const PxReal totalDt, const PxReal invDt, const PxReal invTotalDt, const PxReal invLengthScale);
|
||||
|
||||
/**
|
||||
\brief Updates bodies for a given articulation.
|
||||
\param [in] articulation Articulation handle
|
||||
\param [in] dt Timestep
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxUpdateArticulationBodiesTGS(PxArticulationHandle articulation, const PxReal dt);
|
||||
|
||||
/**
|
||||
\brief Constructs a PxSolverBodyData structure based on rigid body properties. Applies gravity, damping and clamps maximum velocity.
|
||||
\param [in] inRigidData The array rigid body properties
|
||||
\param [out] outSolverBodyVel The array of PxTGSSolverBodyVel structures produced to represent these bodies
|
||||
\param [out] outSolverBodyTxInertia The array of PxTGSSolverBodyTxInertia produced to represent these bodies
|
||||
\param [out] outSolverBodyData The array of PxTGSolverBodyData produced to represent these bodies
|
||||
\param [in] nbBodies The total number of solver bodies to create
|
||||
\param [in] gravity The gravity vector
|
||||
\param [in] dt The timestep
|
||||
\param [in] gyroscopicForces Indicates whether gyroscopic forces should be integrated
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxConstructSolverBodiesTGS(const PxRigidBodyData* inRigidData, PxTGSSolverBodyVel* outSolverBodyVel, PxTGSSolverBodyTxInertia* outSolverBodyTxInertia, PxTGSSolverBodyData* outSolverBodyData, const PxU32 nbBodies, const PxVec3& gravity, const PxReal dt, const bool gyroscopicForces = false);
|
||||
|
||||
/**
|
||||
\brief Constructs a PxSolverBodyData structure for a static body at a given pose.
|
||||
\param [in] globalPose The pose of this static actor
|
||||
\param [out] solverBodyVel The velocity component of this body (will be zero)
|
||||
\param [out] solverBodyTxInertia The intertia and transform delta component of this body (will be zero)
|
||||
\param [out] solverBodyData The solver body representation of this static actor
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxConstructStaticSolverBodyTGS(const PxTransform& globalPose, PxTGSSolverBodyVel& solverBodyVel, PxTGSSolverBodyTxInertia& solverBodyTxInertia, PxTGSSolverBodyData& solverBodyData);
|
||||
|
||||
/**
|
||||
\brief Groups together sets of independent PxSolverConstraintDesc objects to be solved using SIMD SOA approach.
|
||||
\param [in] solverConstraintDescs The set of solver constraint descs to batch
|
||||
\param [in] nbConstraints The number of constraints to batch
|
||||
\param [in,out] solverBodies The array of solver bodies that the constraints reference. Some fields in these structures are written to as scratch memory for the batching.
|
||||
\param [in] nbBodies The number of bodies
|
||||
\param [out] outBatchHeaders The batch headers produced by this batching process. This array must have at least 1 entry per input constraint
|
||||
\param [out] outOrderedConstraintDescs A reordered copy of the constraint descs. This array is referenced by the constraint batches. This array must have at least 1 entry per input constraint.
|
||||
\param [in,out] articulations The array of articulations that the constraints reference. Some fields in these structures are written to as scratch memory for the batching.
|
||||
\param [in] nbArticulations The number of articulations
|
||||
\return The total number of batches produced. This should be less than or equal to nbConstraints.
|
||||
|
||||
\note This method considers all bodies within the range [0, nbBodies-1] to be valid dynamic bodies. A given dynamic body can only be referenced in a batch once. Static or kinematic bodies can be
|
||||
referenced multiple times within a batch safely because constraints do not affect their velocities. The batching will implicitly consider any bodies outside of the range [0, nbBodies-1] to be
|
||||
infinite mass (static or kinematic). This means that either appending static/kinematic to the end of the array of bodies or placing static/kinematic bodies at before the start body pointer
|
||||
will ensure that the minimum number of batches are produced.
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API PxU32 PxBatchConstraintsTGS( const PxSolverConstraintDesc* solverConstraintDescs, const PxU32 nbConstraints, PxTGSSolverBodyVel* solverBodies, const PxU32 nbBodies,
|
||||
PxConstraintBatchHeader* outBatchHeaders, PxSolverConstraintDesc* outOrderedConstraintDescs,
|
||||
PxArticulationHandle* articulations = NULL, const PxU32 nbArticulations = 0);
|
||||
|
||||
/**
|
||||
\brief Creates a set of contact constraint blocks. Note that, depending the results of PxBatchConstraints, each batchHeader may refer to up to 4 solverConstraintDescs.
|
||||
This function will allocate both constraint and friction patch data via the PxConstraintAllocator provided. Constraint data is only valid until PxSolveConstraints has completed.
|
||||
Friction data is to be retained and provided by the application for friction correlation.
|
||||
|
||||
\param [in] batchHeaders Array of batch headers to process
|
||||
\param [in] nbHeaders The total number of headers
|
||||
\param [in] contactDescs An array of contact descs defining the pair and contact properties of each respective contacting pair
|
||||
\param [in] allocator An allocator callback to allocate constraint and friction memory
|
||||
\param [in] invDt The inverse timestep/nbPositionIterations
|
||||
\param [in] invTotalDt The inverse time-step
|
||||
\param [in] bounceThreshold The bounce threshold. Relative velocities below this will be solved by bias only. Relative velocities above this will be solved by restitution. If restitution is zero
|
||||
then these pairs will always be solved by bias.
|
||||
\param [in] frictionOffsetThreshold The friction offset threshold. Contacts whose separations are below this threshold can generate friction constraints.
|
||||
\param [in] correlationDistance The correlation distance used by friction correlation to identify whether a friction patch is broken on the grounds of relation separation.
|
||||
|
||||
\return a boolean to define if this method was successful or not.
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateContactConstraintsTGS( PxConstraintBatchHeader* batchHeaders, const PxU32 nbHeaders, PxTGSSolverContactDesc* contactDescs,
|
||||
PxConstraintAllocator& allocator, const PxReal invDt, const PxReal invTotalDt, const PxReal bounceThreshold,
|
||||
const PxReal frictionOffsetThreshold, const PxReal correlationDistance);
|
||||
|
||||
/**
|
||||
\brief Creates a set of joint constraint blocks. Note that, depending the results of PxBatchConstraints, the batchHeader may refer to up to 4 solverConstraintDescs
|
||||
\param [in] batchHeaders The array of batch headers to be processed
|
||||
\param [in] nbHeaders The total number of batch headers to process
|
||||
\param [in] jointDescs An array of constraint prep descs defining the properties of the constraints being created
|
||||
\param [in] allocator An allocator callback to allocate constraint data
|
||||
\param [in] dt The total time-step/nbPositionIterations
|
||||
\param [in] totalDt The total time-step
|
||||
\param [in] invDt The inverse (timestep/nbPositionIterations)
|
||||
\param [in] invTotalDt The inverse total time-step
|
||||
\param [in] lengthScale PxToleranceScale::length, i.e. a meter in simulation units
|
||||
\return a boolean indicating if this method was successful or not.
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateJointConstraintsTGS( PxConstraintBatchHeader* batchHeaders, const PxU32 nbHeaders,
|
||||
PxTGSSolverConstraintPrepDesc* jointDescs, PxConstraintAllocator& allocator, const PxReal dt, const PxReal totalDt, const PxReal invDt,
|
||||
const PxReal invTotalDt, const PxReal lengthScale);
|
||||
|
||||
/**
|
||||
\brief Creates a set of joint constraint blocks. This function runs joint shaders defined inside PxConstraint** param, fills in joint row information in jointDescs and then calls PxCreateJointConstraints.
|
||||
\param [in] batchHeaders The set of batchHeaders to be processed
|
||||
\param [in] nbBatchHeaders The number of batch headers to process.
|
||||
\param [in] constraints The set of constraints to be used to produce constraint rows
|
||||
\param [in,out] jointDescs An array of constraint prep descs defining the properties of the constraints being created
|
||||
\param [in] allocator An allocator callback to allocate constraint data
|
||||
\param [in] dt The total time-step/nbPositionIterations
|
||||
\param [in] totalDt The total time-step
|
||||
\param [in] invDt The inverse (timestep/nbPositionIterations)
|
||||
\param [in] invTotalDt The inverse total time-step
|
||||
\param [in] lengthScale PxToleranceScale::length, i.e. a meter in simulation units
|
||||
\return a boolean indicating if this method was successful or not.
|
||||
@see PxCreateJointConstraints
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateJointConstraintsWithShadersTGS( PxConstraintBatchHeader* batchHeaders, const PxU32 nbBatchHeaders, PxConstraint** constraints, PxTGSSolverConstraintPrepDesc* jointDescs, PxConstraintAllocator& allocator,
|
||||
const PxReal dt, const PxReal totalDt, const PxReal invDt, const PxReal invTotalDt, const PxReal lengthScale);
|
||||
|
||||
/**
|
||||
\brief Creates a set of joint constraint blocks. This function runs joint shaders defined inside PxImmediateConstraint* param, fills in joint row information in jointDescs and then calls PxCreateJointConstraints.
|
||||
\param [in] batchHeaders The set of batchHeaders to be processed
|
||||
\param [in] nbBatchHeaders The number of batch headers to process.
|
||||
\param [in] constraints The set of constraints to be used to produce constraint rows
|
||||
\param [in,out] jointDescs An array of constraint prep descs defining the properties of the constraints being created
|
||||
\param [in] allocator An allocator callback to allocate constraint data
|
||||
\param [in] dt The total time-step/nbPositionIterations
|
||||
\param [in] totalDt The total time-step
|
||||
\param [in] invDt The inverse (timestep/nbPositionIterations)
|
||||
\param [in] invTotalDt The inverse total time-step
|
||||
\param [in] lengthScale PxToleranceScale::length, i.e. a meter in simulation units
|
||||
\return a boolean indicating if this method was successful or not.
|
||||
@see PxCreateJointConstraints
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateJointConstraintsWithImmediateShadersTGS(PxConstraintBatchHeader* batchHeaders, const PxU32 nbBatchHeaders, PxImmediateConstraint* constraints, PxTGSSolverConstraintPrepDesc* jointDescs,
|
||||
PxConstraintAllocator& allocator, const PxReal dt, const PxReal totalDt, const PxReal invDt, const PxReal invTotalDt, const PxReal lengthScale);
|
||||
|
||||
/**
|
||||
\brief Iteratively solves the set of constraints defined by the provided PxConstraintBatchHeader and PxSolverConstraintDesc structures. Updates deltaVelocities inside the PxSolverBody structures. Produces resulting linear and angular motion velocities.
|
||||
\param [in] batchHeaders The set of batch headers to be solved
|
||||
\param [in] nbBatchHeaders The total number of batch headers to be solved
|
||||
\param [in] solverConstraintDescs The reordererd set of solver constraint descs referenced by the batch headers
|
||||
\param [in,out] solverBodies The set of solver bodies the bodies reference
|
||||
\param [in,out] txInertias The set of solver body TxInertias the bodies reference
|
||||
\param [in] nbSolverBodies The total number of solver bodies
|
||||
\param [in] nbPositionIterations The number of position iterations to run
|
||||
\param [in] nbVelocityIterations The number of velocity iterations to run
|
||||
\param [in] dt time-step/nbPositionIterations
|
||||
\param [in] invDt 1/(time-step/nbPositionIterations)
|
||||
\param [in] nbSolverArticulations Number of articulations to solve constraints for.
|
||||
\param [in] solverArticulations Array of articulations to solve constraints for.
|
||||
\param [out] Z Temporary buffer for impulse propagation (only if articulations are used, size should be at least as large as the maximum number of links in any articulations being simulated)
|
||||
\param [out] deltaV Temporary buffer for velocity change (only if articulations are used, size should be at least as large as the maximum number of links in any articulations being simulated)
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxSolveConstraintsTGS( const PxConstraintBatchHeader* batchHeaders, const PxU32 nbBatchHeaders, const PxSolverConstraintDesc* solverConstraintDescs,
|
||||
PxTGSSolverBodyVel* solverBodies, PxTGSSolverBodyTxInertia* txInertias, const PxU32 nbSolverBodies, const PxU32 nbPositionIterations, const PxU32 nbVelocityIterations,
|
||||
const float dt, const float invDt, const PxU32 nbSolverArticulations = 0, PxArticulationHandle* solverArticulations = NULL, PxSpatialVector* Z = NULL, PxSpatialVector* deltaV = NULL);
|
||||
|
||||
/**
|
||||
\brief Integrates a rigid body, returning the new velocities and transforms. After this function has been called, solverBody stores all the body's velocity data.
|
||||
|
||||
\param [in,out] solverBody The array of solver bodies to be integrated
|
||||
\param [in] txInertia The delta pose and inertia terms
|
||||
\param [in,out] poses The original poses of the bodies. Updated to be the new poses of the bodies
|
||||
\param [in] nbBodiesToIntegrate The total number of bodies to integrate
|
||||
\param [in] dt The timestep
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PxIntegrateSolverBodiesTGS(PxTGSSolverBodyVel* solverBody, PxTGSSolverBodyTxInertia* txInertia, PxTransform* poses, const PxU32 nbBodiesToIntegrate, const PxReal dt);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
typedef PX_DEPRECATED PxArticulationJointDataRC PxFeatherstoneArticulationJointData;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
typedef PX_DEPRECATED PxArticulationLinkDataRC PxFeatherstoneArticulationLinkData;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
typedef PX_DEPRECATED PxArticulationDataRC PxFeatherstoneArticulationData;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
typedef PX_DEPRECATED PxArticulationLinkMutableDataRC PxMutableLinkData;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
typedef PX_DEPRECATED PxArticulationLinkDerivedDataRC PxLinkData;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_LOCKED_DATA_H
|
||||
#define PX_LOCKED_DATA_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxDataAccessFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eREADABLE = (1 << 0),
|
||||
eWRITABLE = (1 << 1),
|
||||
eDEVICE = (1 << 2)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxDataAccessFlag.
|
||||
|
||||
@see PxDataAccessFlag
|
||||
*/
|
||||
typedef PxFlags<PxDataAccessFlag::Enum,PxU8> PxDataAccessFlags;
|
||||
PX_FLAGS_OPERATORS(PxDataAccessFlag::Enum,PxU8)
|
||||
|
||||
|
||||
/**
|
||||
\brief Parent class for bulk data that is shared between the SDK and the application.
|
||||
*/
|
||||
class PxLockedData
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Any combination of PxDataAccessFlag::eREADABLE and PxDataAccessFlag::eWRITABLE
|
||||
@see PxDataAccessFlag
|
||||
*/
|
||||
virtual PxDataAccessFlags getDataAccessFlags() = 0;
|
||||
|
||||
/**
|
||||
\brief Unlocks the bulk data.
|
||||
*/
|
||||
virtual void unlock() = 0;
|
||||
|
||||
/**
|
||||
\brief virtual destructor
|
||||
*/
|
||||
virtual ~PxLockedData() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,416 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_MPM_MATERIAL_H
|
||||
#define PX_MPM_MATERIAL_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxParticleMaterial.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief MPM material models
|
||||
*/
|
||||
struct PxMPMMaterialModel
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eATTACHED = 1 << 0, //!< Marker to indicate that all particles with an attached material should be treated as attached to whatever object they are located in
|
||||
eNEO_HOOKEAN = 1 << 1, //!< A Neo-Hookean material model will be used
|
||||
eELASTIC = 1 << 2, //!< A corotaional cauchy strain based material model will be used
|
||||
eSNOW = 1 << 3, //!< A corotaional cauchy strain based material model with strain limiting and hardening will be used
|
||||
eSAND = 1 << 4, //!< A Ducker-Prager elastoplasticity material model will be used
|
||||
eVON_MISES = 1 << 5 //!< A von Mises material model will be used
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief MPM surface types that influence interaction between particles and obstacles
|
||||
*/
|
||||
struct PxMPMSurfaceType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eDEFAULT = 0, //!< Normal surface with friction in tangential direction
|
||||
eSTICKY = 1 << 0, //!< Surface will always have friction in the tangential and the normal direction
|
||||
eSLIPPERY = 1 << 1 //!< Surface will not cause any friction
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Optional MPM modes that improve the quality of fracture and/or cutting
|
||||
*/
|
||||
struct PxMPMCuttingFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE = 0, //!< No special processing to support cutting will be performed
|
||||
eSUPPORT_THIN_BLADES = 1 << 0, //!< Special collision detection will be performed to improve support for blade like objects that are thinner than the mpm grid spacing
|
||||
eENABLE_DAMAGE_TRACKING = 1 << 1 //!< A damage value will get updated on every particle to simulate material weakening to get more realistic crack propagation
|
||||
};
|
||||
};
|
||||
typedef PxFlags<PxMPMCuttingFlag::Enum,PxU16> PxMPMCuttingFlags;
|
||||
PX_FLAGS_OPERATORS(PxMPMCuttingFlag::Enum,PxU16)
|
||||
|
||||
class PxScene;
|
||||
|
||||
/**
|
||||
\brief Material class to represent a set of MPM particle material properties.
|
||||
|
||||
@see PxPhysics.createMPMMaterial
|
||||
*/
|
||||
class PxMPMMaterial : public PxParticleMaterial
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Sets stretch and shear damping which dampens stretch and shear motion of MPM bodies. The effect is comparable to viscosity for fluids.
|
||||
|
||||
\param[in] stretchAndShearDamping The stretch and shear damping
|
||||
|
||||
@see getStretchAndShearDamping()
|
||||
*/
|
||||
virtual void setStretchAndShearDamping(PxReal stretchAndShearDamping) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the stretch and shear damping.
|
||||
|
||||
\return The stretch and shear damping
|
||||
|
||||
@see setStretchAndShearDamping()
|
||||
*/
|
||||
virtual PxReal getStretchAndShearDamping() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets the rotational damping which dampens rotations of mpm bodies
|
||||
|
||||
\param[in] rotationalDamping The rotational damping
|
||||
|
||||
@see getRotationalDamping()
|
||||
*/
|
||||
virtual void setRotationalDamping(PxReal rotationalDamping) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the rotational damping.
|
||||
|
||||
\return The rotational damping
|
||||
|
||||
@see setRotationalDamping()
|
||||
*/
|
||||
virtual PxReal getRotationalDamping() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets density which influences the body's weight
|
||||
|
||||
\param[in] density The material's density
|
||||
|
||||
@see getDensity()
|
||||
*/
|
||||
virtual void setDensity(PxReal density) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the density value.
|
||||
|
||||
\return The density
|
||||
|
||||
@see setDensity()
|
||||
*/
|
||||
virtual PxReal getDensity() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets the material model which influences interaction between MPM particles
|
||||
|
||||
\param[in] materialModel The material model
|
||||
|
||||
@see getMaterialModel()
|
||||
*/
|
||||
virtual void setMaterialModel(PxMPMMaterialModel::Enum materialModel) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the material model.
|
||||
|
||||
\return The material model
|
||||
|
||||
@see setMaterialModel()
|
||||
*/
|
||||
virtual PxMPMMaterialModel::Enum getMaterialModel() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets the cutting flags which can enable damage tracking or thin blade support
|
||||
|
||||
\param[in] cuttingFlags The cutting flags
|
||||
|
||||
@see getCuttingFlags()
|
||||
*/
|
||||
virtual void setCuttingFlags(PxMPMCuttingFlags cuttingFlags) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the cutting flags.
|
||||
|
||||
\return The cutting flags
|
||||
|
||||
@see setCuttingFlags()
|
||||
*/
|
||||
virtual PxMPMCuttingFlags getCuttingFlags() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets the sand friction angle, only applied if the material model is set to sand
|
||||
|
||||
\param[in] sandFrictionAngle The sand friction angle
|
||||
|
||||
@see getSandFrictionAngle()
|
||||
*/
|
||||
virtual void setSandFrictionAngle(PxReal sandFrictionAngle) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the sand friction angle.
|
||||
|
||||
\return The sand friction angle
|
||||
|
||||
@see setSandFrictionAngle()
|
||||
*/
|
||||
virtual PxReal getSandFrictionAngle() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets the yield stress, only applied if the material model is set to Von Mises
|
||||
|
||||
\param[in] yieldStress The yield stress
|
||||
|
||||
@see getYieldStress()
|
||||
*/
|
||||
virtual void setYieldStress(PxReal yieldStress) = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Retrieves the yield stress.
|
||||
|
||||
\return The yield stress
|
||||
|
||||
@see setYieldStress()
|
||||
*/
|
||||
virtual PxReal getYieldStress() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Set material to plastic
|
||||
|
||||
\param[in] isPlastic True if plastic
|
||||
|
||||
@see getIsPlastic()
|
||||
*/
|
||||
virtual void setIsPlastic(bool isPlastic) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns true if material is plastic
|
||||
|
||||
\return True if plastic
|
||||
|
||||
@see setIsPlastic()
|
||||
*/
|
||||
virtual bool getIsPlastic() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets Young's modulus which defines the body's stiffness
|
||||
|
||||
\param[in] young Young's modulus. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getYoungsModulus()
|
||||
*/
|
||||
virtual void setYoungsModulus(PxReal young) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the Young's modulus value.
|
||||
|
||||
\return The Young's modulus value.
|
||||
|
||||
@see setYoungsModulus()
|
||||
*/
|
||||
virtual PxReal getYoungsModulus() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets Poisson's ratio defines the body's volume preservation. Completely incompressible materials have a Poisson ratio of 0.5 which will lead to numerical problems.
|
||||
|
||||
\param[in] poisson Poisson's ratio. <b>Range:</b> [0, 0.5)
|
||||
|
||||
@see getPoissons()
|
||||
*/
|
||||
virtual void setPoissons(PxReal poisson) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the Poisson's ratio.
|
||||
\return The Poisson's ratio.
|
||||
|
||||
@see setPoissons()
|
||||
*/
|
||||
virtual PxReal getPoissons() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material hardening coefficient
|
||||
|
||||
Tendency to get more rigid under compression. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
\param[in] hardening Material hardening coefficient.
|
||||
|
||||
@see getHardening
|
||||
*/
|
||||
virtual void setHardening(PxReal hardening) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the hardening coefficient.
|
||||
|
||||
\return The hardening coefficient.
|
||||
|
||||
@see setHardening()
|
||||
*/
|
||||
virtual PxReal getHardening() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material critical compression coefficient
|
||||
|
||||
Compression clamping threshold (higher means more compression is allowed before yield). <b>Range:</b> [0, 1)
|
||||
|
||||
\param[in] criticalCompression Material critical compression coefficient.
|
||||
|
||||
@see getCriticalCompression
|
||||
*/
|
||||
virtual void setCriticalCompression(PxReal criticalCompression) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the critical compression coefficient.
|
||||
|
||||
\return The criticalCompression coefficient.
|
||||
|
||||
@see setCriticalCompression()
|
||||
*/
|
||||
virtual PxReal getCriticalCompression() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material critical stretch coefficient
|
||||
|
||||
Stretch clamping threshold (higher means more stretching is allowed before yield). <b>Range:</b> [0, 1]
|
||||
|
||||
\param[in] criticalStretch Material critical stretch coefficient.
|
||||
|
||||
@see getCriticalStretch
|
||||
*/
|
||||
virtual void setCriticalStretch(PxReal criticalStretch) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the critical stretch coefficient.
|
||||
|
||||
\return The criticalStretch coefficient.
|
||||
|
||||
@see setCriticalStretch()
|
||||
*/
|
||||
virtual PxReal getCriticalStretch() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material tensile damage sensitivity coefficient
|
||||
|
||||
Sensitivity to tensile loads. The higher the sensitivity, the quicker damage will occur under tensile loads. <b>Range:</b> [0, PX_MAX_U32)
|
||||
|
||||
\param[in] tensileDamageSensitivity Material tensile damage sensitivity coefficient.
|
||||
|
||||
@see getTensileDamageSensitivity
|
||||
*/
|
||||
virtual void setTensileDamageSensitivity(PxReal tensileDamageSensitivity) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the tensile damage sensitivity coefficient.
|
||||
|
||||
\return The tensileDamageSensitivity coefficient.
|
||||
|
||||
@see setTensileDamageSensitivity()
|
||||
*/
|
||||
virtual PxReal getTensileDamageSensitivity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material compressive damage sensitivity coefficient
|
||||
|
||||
Sensitivity to compressive loads. The higher the sensitivity, the quicker damage will occur under compressive loads <b>Range:</b> [0, PX_MAX_U32)
|
||||
|
||||
\param[in] compressiveDamageSensitivity Material compressive damage sensitivity coefficient.
|
||||
|
||||
@see getCompressiveDamageSensitivity
|
||||
*/
|
||||
virtual void setCompressiveDamageSensitivity(PxReal compressiveDamageSensitivity) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the compressive damage sensitivity coefficient.
|
||||
|
||||
\return The compressiveDamageSensitivity coefficient.
|
||||
|
||||
@see setCompressiveDamageSensitivity()
|
||||
*/
|
||||
virtual PxReal getCompressiveDamageSensitivity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material attractive force residual coefficient
|
||||
|
||||
Relative amount of attractive force a fully damaged particle can exert on other particles compared to an undamaged one. <b>Range:</b> [0, 1]
|
||||
|
||||
\param[in] attractiveForceResidual Material attractive force residual coefficient.
|
||||
|
||||
@see getAttractiveForceResidual
|
||||
*/
|
||||
virtual void setAttractiveForceResidual(PxReal attractiveForceResidual) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the attractive force residual coefficient.
|
||||
\return The attractiveForceResidual coefficient.
|
||||
|
||||
@see setAttractiveForceResidual()
|
||||
*/
|
||||
virtual PxReal getAttractiveForceResidual() const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxMPMMaterial"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxMPMMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxParticleMaterial(concreteType, baseFlags) {}
|
||||
PX_INLINE PxMPMMaterial(PxBaseFlags baseFlags) : PxParticleMaterial(baseFlags) {}
|
||||
virtual ~PxMPMMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxMPMMaterial", name) || PxParticleMaterial::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
358
modules/PhysX/physx/physx-sys/physx/physx/include/PxMaterial.h
Normal file
358
modules/PhysX/physx/physx-sys/physx/physx/include/PxMaterial.h
Normal file
@@ -0,0 +1,358 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_MATERIAL_H
|
||||
#define PX_MATERIAL_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxBaseMaterial.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxScene;
|
||||
|
||||
/**
|
||||
\brief Flags which control the behavior of a material.
|
||||
|
||||
@see PxMaterial
|
||||
*/
|
||||
struct PxMaterialFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
|
||||
/**
|
||||
\brief If this flag is set, friction computations are always skipped between shapes with this material and any other shape.
|
||||
*/
|
||||
eDISABLE_FRICTION = 1 << 0,
|
||||
|
||||
/**
|
||||
\brief Whether to use strong friction.
|
||||
The difference between "normal" and "strong" friction is that the strong friction feature
|
||||
remembers the "friction error" between simulation steps. The friction is a force trying to
|
||||
hold objects in place (or slow them down) and this is handled in the solver. But since the
|
||||
solver is only an approximation, the result of the friction calculation can include a small
|
||||
"error" - e.g. a box resting on a slope should not move at all if the static friction is in
|
||||
action, but could slowly glide down the slope because of a small friction error in each
|
||||
simulation step. The strong friction counter-acts this by remembering the small error and
|
||||
taking it to account during the next simulation step.
|
||||
|
||||
However, in some cases the strong friction could cause problems, and this is why it is
|
||||
possible to disable the strong friction feature by setting this flag. One example is
|
||||
raycast vehicles that are sliding fast across the surface, but still need a precise
|
||||
steering behavior. It may be a good idea to reenable the strong friction when objects
|
||||
are coming to a rest, to prevent them from slowly creeping down inclines.
|
||||
|
||||
Note: This flag only has an effect if the PxMaterialFlag::eDISABLE_FRICTION bit is 0.
|
||||
*/
|
||||
eDISABLE_STRONG_FRICTION = 1 << 1,
|
||||
|
||||
/**
|
||||
\brief Whether to use the patch friction model.
|
||||
This flag only has an effect if PxFrictionType::ePATCH friction model is used.
|
||||
|
||||
When using the patch friction model, up to 2 friction anchors are generated per patch. As the number of friction anchors
|
||||
can be smaller than the number of contacts, the normal force is accumulated over all contacts and used to compute friction
|
||||
for all anchors. Where there are more than 2 anchors, this can produce frictional behavior that is too strong (approximately 2x as strong
|
||||
as analytical models suggest).
|
||||
|
||||
This flag causes the normal force to be distributed between the friction anchors such that the total amount of friction applied does not
|
||||
exceed the analytical results.
|
||||
*/
|
||||
eIMPROVED_PATCH_FRICTION = 1 << 2,
|
||||
|
||||
/**
|
||||
\brief This flag has the effect of enabling an implicit spring model for the normal force computation.
|
||||
@see PxMaterial.setRestitution, PxMaterial.setDamping
|
||||
*/
|
||||
eCOMPLIANT_CONTACT = 1 << 3
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxMaterialFlag.
|
||||
|
||||
@see PxMaterialFlag
|
||||
*/
|
||||
typedef PxFlags<PxMaterialFlag::Enum,PxU16> PxMaterialFlags;
|
||||
PX_FLAGS_OPERATORS(PxMaterialFlag::Enum,PxU16)
|
||||
|
||||
|
||||
/**
|
||||
\brief Enumeration that determines the way in which two material properties will be combined to yield a friction or restitution coefficient for a collision.
|
||||
|
||||
When two actors come in contact with each other, they each have materials with various coefficients, but we only need a single set of coefficients for the pair.
|
||||
|
||||
Physics doesn't have any inherent combinations because the coefficients are determined empirically on a case by case
|
||||
basis. However, simulating this with a pairwise lookup table is often impractical.
|
||||
|
||||
For this reason the following combine behaviors are available:
|
||||
|
||||
eAVERAGE
|
||||
eMIN
|
||||
eMULTIPLY
|
||||
eMAX
|
||||
|
||||
The effective combine mode for the pair is maximum(material0.combineMode, material1.combineMode).
|
||||
|
||||
@see PxMaterial.setFrictionCombineMode() PxMaterial.getFrictionCombineMode() PxMaterial.setRestitutionCombineMode() PxMaterial.getFrictionCombineMode()
|
||||
*/
|
||||
struct PxCombineMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eAVERAGE = 0, //!< Average: (a + b)/2
|
||||
eMIN = 1, //!< Minimum: minimum(a,b)
|
||||
eMULTIPLY = 2, //!< Multiply: a*b
|
||||
eMAX = 3, //!< Maximum: maximum(a,b)
|
||||
eN_VALUES = 4, //!< This is not a valid combine mode, it is a sentinel to denote the number of possible values. We assert that the variable's value is smaller than this.
|
||||
ePAD_32 = 0x7fffffff //!< This is not a valid combine mode, it is to assure that the size of the enum type is big enough.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Material class to represent a set of surface properties.
|
||||
|
||||
@see PxPhysics.createMaterial
|
||||
*/
|
||||
class PxMaterial : public PxBaseMaterial
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Sets the coefficient of dynamic friction.
|
||||
|
||||
The coefficient of dynamic friction should be in [0, PX_MAX_F32). If set to greater than staticFriction, the effective value of staticFriction will be increased to match.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake any actors which may be affected.
|
||||
|
||||
\param[in] coef Coefficient of dynamic friction. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getDynamicFriction()
|
||||
*/
|
||||
virtual void setDynamicFriction(PxReal coef) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the DynamicFriction value.
|
||||
|
||||
\return The coefficient of dynamic friction.
|
||||
|
||||
@see setDynamicFriction
|
||||
*/
|
||||
virtual PxReal getDynamicFriction() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the coefficient of static friction
|
||||
|
||||
The coefficient of static friction should be in the range [0, PX_MAX_F32)
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake any actors which may be affected.
|
||||
|
||||
\param[in] coef Coefficient of static friction. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getStaticFriction()
|
||||
*/
|
||||
virtual void setStaticFriction(PxReal coef) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the coefficient of static friction.
|
||||
\return The coefficient of static friction.
|
||||
|
||||
@see setStaticFriction
|
||||
*/
|
||||
virtual PxReal getStaticFriction() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the coefficient of restitution
|
||||
|
||||
A coefficient of 0 makes the object bounce as little as possible, higher values up to 1.0 result in more bounce.
|
||||
|
||||
This property is overloaded when PxMaterialFlag::eCOMPLIANT_CONTACT flag is enabled. This permits negative values for restitution to be provided.
|
||||
The negative values are converted into spring stiffness terms for an implicit spring simulated at the contact site, with the spring positional error defined by
|
||||
the contact separation value. Higher stiffness terms produce stiffer springs that behave more like a rigid contact.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake any actors which may be affected.
|
||||
|
||||
\param[in] rest Coefficient of restitution. <b>Range:</b> [-INF,1]
|
||||
|
||||
@see getRestitution()
|
||||
*/
|
||||
virtual void setRestitution(PxReal rest) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the coefficient of restitution.
|
||||
|
||||
See #setRestitution.
|
||||
|
||||
\return The coefficient of restitution.
|
||||
|
||||
@see setRestitution()
|
||||
*/
|
||||
virtual PxReal getRestitution() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets the coefficient of damping
|
||||
|
||||
This property only affects the simulation if PxMaterialFlag::eCOMPLIANT_CONTACT is raised.
|
||||
Damping works together with spring stiffness (set through a negative restitution value). Spring stiffness corrects positional error while
|
||||
damping resists relative velocity. Setting a high damping coefficient can produce spongy contacts.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake any actors which may be affected.
|
||||
|
||||
\param[in] damping Coefficient of damping. <b>Range:</b> [0,INF]
|
||||
|
||||
@see getDamping()
|
||||
*/
|
||||
virtual void setDamping(PxReal damping) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the coefficient of damping.
|
||||
|
||||
See #setDamping.
|
||||
|
||||
\return The coefficient of damping.
|
||||
|
||||
@see setDamping()
|
||||
*/
|
||||
virtual PxReal getDamping() const = 0;
|
||||
|
||||
/**
|
||||
\brief Raises or clears a particular material flag.
|
||||
|
||||
See the list of flags #PxMaterialFlag
|
||||
|
||||
<b>Default:</b> eIMPROVED_PATCH_FRICTION
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake any actors which may be affected.
|
||||
|
||||
\param[in] flag The PxMaterial flag to raise(set) or clear.
|
||||
\param[in] b New state of the flag
|
||||
|
||||
@see getFlags() setFlags() PxMaterialFlag
|
||||
*/
|
||||
virtual void setFlag(PxMaterialFlag::Enum flag, bool b) = 0;
|
||||
|
||||
/**
|
||||
\brief sets all the material flags.
|
||||
|
||||
See the list of flags #PxMaterialFlag
|
||||
|
||||
<b>Default:</b> eIMPROVED_PATCH_FRICTION
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake any actors which may be affected.
|
||||
|
||||
\param[in] flags All PxMaterial flags
|
||||
|
||||
@see getFlags() setFlag() PxMaterialFlag
|
||||
*/
|
||||
virtual void setFlags(PxMaterialFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the flags. See #PxMaterialFlag.
|
||||
|
||||
\return The material flags.
|
||||
|
||||
@see PxMaterialFlag setFlags()
|
||||
*/
|
||||
virtual PxMaterialFlags getFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the friction combine mode.
|
||||
|
||||
See the enum ::PxCombineMode .
|
||||
|
||||
<b>Default:</b> PxCombineMode::eAVERAGE
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake any actors which may be affected.
|
||||
|
||||
\param[in] combMode Friction combine mode to set for this material. See #PxCombineMode.
|
||||
|
||||
@see PxCombineMode getFrictionCombineMode setStaticFriction() setDynamicFriction()
|
||||
*/
|
||||
virtual void setFrictionCombineMode(PxCombineMode::Enum combMode) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the friction combine mode.
|
||||
|
||||
See #setFrictionCombineMode.
|
||||
|
||||
\return The friction combine mode for this material.
|
||||
|
||||
@see PxCombineMode setFrictionCombineMode()
|
||||
*/
|
||||
virtual PxCombineMode::Enum getFrictionCombineMode() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the restitution combine mode.
|
||||
|
||||
See the enum ::PxCombineMode .
|
||||
|
||||
<b>Default:</b> PxCombineMode::eAVERAGE
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake any actors which may be affected.
|
||||
|
||||
\param[in] combMode Restitution combine mode for this material. See #PxCombineMode.
|
||||
|
||||
@see PxCombineMode getRestitutionCombineMode() setRestitution()
|
||||
*/
|
||||
virtual void setRestitutionCombineMode(PxCombineMode::Enum combMode) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the restitution combine mode.
|
||||
|
||||
See #setRestitutionCombineMode.
|
||||
|
||||
\return The coefficient of restitution combine mode for this material.
|
||||
|
||||
@see PxCombineMode setRestitutionCombineMode getRestitution()
|
||||
*/
|
||||
virtual PxCombineMode::Enum getRestitutionCombineMode() const = 0;
|
||||
|
||||
// PxBase
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxMaterial"; }
|
||||
//~PxBase
|
||||
|
||||
protected:
|
||||
PX_INLINE PxMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxBaseMaterial(concreteType, baseFlags) {}
|
||||
PX_INLINE PxMaterial(PxBaseFlags baseFlags) : PxBaseMaterial(baseFlags) {}
|
||||
virtual ~PxMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxMaterial", name) || PxBaseMaterial::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_NODEINDEX_H
|
||||
#define PX_NODEINDEX_H
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#define PX_INVALID_NODE 0xFFFFFFFFu
|
||||
|
||||
|
||||
/**
|
||||
\brief PxNodeIndex
|
||||
|
||||
Node index is the unique index for each actor referenced by the island gen. It contains details like
|
||||
if the actor is an articulation or rigid body. If it is an articulation, the node index also contains
|
||||
the link index of the rigid body within the articulation. Also, it contains information to detect whether
|
||||
the rigid body is static body or not
|
||||
*/
|
||||
class PxNodeIndex
|
||||
{
|
||||
protected:
|
||||
PxU64 ind;
|
||||
|
||||
public:
|
||||
|
||||
explicit PX_CUDA_CALLABLE PX_FORCE_INLINE PxNodeIndex(PxU32 id, PxU32 articLinkId) : ind((PxU64(id) << 32) | (articLinkId << 1) | 1)
|
||||
{
|
||||
}
|
||||
|
||||
explicit PX_CUDA_CALLABLE PX_FORCE_INLINE PxNodeIndex(PxU32 id = PX_INVALID_NODE) : ind((PxU64(id) << 32))
|
||||
{
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 index() const { return PxU32(ind >> 32); }
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 articulationLinkId() const { return PxU32((ind >> 1) & 0x7FFFFFFF); }
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 isArticulation() const { return PxU32(ind & 1); }
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isStaticBody() const { return PxU32(ind >> 32) == PX_INVALID_NODE; }
|
||||
|
||||
PX_CUDA_CALLABLE bool isValid() const { return PxU32(ind >> 32) != PX_INVALID_NODE; }
|
||||
|
||||
PX_CUDA_CALLABLE void setIndices(PxU32 index, PxU32 articLinkId) { ind = ((PxU64(index) << 32) | (articLinkId << 1) | 1); }
|
||||
|
||||
PX_CUDA_CALLABLE void setIndices(PxU32 index) { ind = ((PxU64(index) << 32)); }
|
||||
|
||||
PX_CUDA_CALLABLE bool operator < (const PxNodeIndex& other) const { return ind < other.ind; }
|
||||
|
||||
PX_CUDA_CALLABLE bool operator <= (const PxNodeIndex& other) const { return ind <= other.ind; }
|
||||
|
||||
PX_CUDA_CALLABLE bool operator == (const PxNodeIndex& other) const { return ind == other.ind; }
|
||||
|
||||
PX_CUDA_CALLABLE PxU64 getInd() const { return ind; }
|
||||
};
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,231 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PBD_MATERIAL_H
|
||||
#define PX_PBD_MATERIAL_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxParticleMaterial.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxScene;
|
||||
/**
|
||||
\brief Material class to represent a set of PBD particle material properties.
|
||||
|
||||
@see #PxPhysics.createPBDMaterial
|
||||
*/
|
||||
class PX_DEPRECATED PxPBDMaterial : public PxParticleMaterial
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Sets viscosity
|
||||
|
||||
\param[in] viscosity Viscosity. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getViscosity()
|
||||
*/
|
||||
virtual void setViscosity(PxReal viscosity) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the viscosity value.
|
||||
|
||||
\return The viscosity value.
|
||||
|
||||
@see #setViscosity()
|
||||
*/
|
||||
virtual PxReal getViscosity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material vorticity confinement coefficient
|
||||
|
||||
\param[in] vorticityConfinement Material vorticity confinement coefficient. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getVorticityConfinement()
|
||||
*/
|
||||
virtual void setVorticityConfinement(PxReal vorticityConfinement) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the vorticity confinement coefficient.
|
||||
\return The vorticity confinement coefficient.
|
||||
|
||||
@see #setVorticityConfinement()
|
||||
*/
|
||||
virtual PxReal getVorticityConfinement() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material surface tension coefficient
|
||||
|
||||
\param[in] surfaceTension Material surface tension coefficient. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getSurfaceTension()
|
||||
*/
|
||||
virtual void setSurfaceTension(PxReal surfaceTension) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the surface tension coefficient.
|
||||
\return The surface tension coefficient.
|
||||
|
||||
@see #setSurfaceTension()
|
||||
*/
|
||||
virtual PxReal getSurfaceTension() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material cohesion coefficient
|
||||
|
||||
\param[in] cohesion Material cohesion coefficient. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getCohesion()
|
||||
*/
|
||||
virtual void setCohesion(PxReal cohesion) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the cohesion coefficient.
|
||||
\return The cohesion coefficient.
|
||||
|
||||
@see #setCohesion()
|
||||
*/
|
||||
virtual PxReal getCohesion() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material lift coefficient
|
||||
|
||||
\param[in] lift Material lift coefficient. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getLift()
|
||||
*/
|
||||
virtual void setLift(PxReal lift) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the lift coefficient.
|
||||
\return The lift coefficient.
|
||||
|
||||
@see #setLift()
|
||||
*/
|
||||
virtual PxReal getLift() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material drag coefficient
|
||||
|
||||
\param[in] drag Material drag coefficient. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getDrag()
|
||||
*/
|
||||
virtual void setDrag(PxReal drag) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the drag coefficient.
|
||||
\return The drag coefficient.
|
||||
|
||||
@see #setDrag()
|
||||
*/
|
||||
virtual PxReal getDrag() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the CFL coefficient.
|
||||
|
||||
\param[in] coefficient CFL coefficient. This coefficient scales the CFL term used to limit relative motion between fluid particles. <b>Range:</b> [1.f, PX_MAX_F32)
|
||||
*/
|
||||
virtual void setCFLCoefficient(PxReal coefficient) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the CFL coefficient.
|
||||
\return The CFL coefficient.
|
||||
|
||||
@see #setCFLCoefficient()
|
||||
*/
|
||||
virtual PxReal getCFLCoefficient() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material particle friction scale. This allows the application to scale up/down the frictional effect between particles independent of the friction
|
||||
coefficient, which also defines frictional behavior between the particle and rigid bodies/soft bodies/cloth etc.
|
||||
|
||||
\param[in] scale particle friction scale. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getParticleFrictionScale()
|
||||
*/
|
||||
virtual void setParticleFrictionScale(PxReal scale) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the particle friction scale.
|
||||
\return The particle friction scale.
|
||||
|
||||
@see #setParticleFrictionScale()
|
||||
*/
|
||||
virtual PxReal getParticleFrictionScale() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material particle adhesion scale value. This is the adhesive value between particles defined as a scaled multiple of the adhesion parameter.
|
||||
|
||||
\param[in] adhesion particle adhesion scale value. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getParticleAdhesionScale()
|
||||
*/
|
||||
virtual void setParticleAdhesionScale(PxReal adhesion) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the particle adhesion scale value.
|
||||
\return The particle adhesion scale value.
|
||||
|
||||
@see #setParticleAdhesionScale()
|
||||
*/
|
||||
virtual PxReal getParticleAdhesionScale() const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxPBDMaterial"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxPBDMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxParticleMaterial(concreteType, baseFlags) {}
|
||||
PX_INLINE PxPBDMaterial(PxBaseFlags baseFlags) : PxParticleMaterial(baseFlags) {}
|
||||
virtual ~PxPBDMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxPBDMaterial", name) || PxParticleMaterial::isKindOf(name); }
|
||||
};
|
||||
|
||||
class PX_DEPRECATED PxCustomMaterial : public PxParticleMaterial
|
||||
{
|
||||
public:
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxCustomMaterial"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxCustomMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxParticleMaterial(concreteType, baseFlags) {}
|
||||
PX_INLINE PxCustomMaterial(PxBaseFlags baseFlags) : PxParticleMaterial(baseFlags) {}
|
||||
virtual ~PxCustomMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxCustomMaterial", name) || PxParticleMaterial::isKindOf(name); }
|
||||
};
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,153 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PBD_PARTICLE_SYSTEM_H
|
||||
#define PX_PBD_PARTICLE_SYSTEM_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#if PX_SUPPORT_GPU_PHYSX
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#include "PxParticleSystem.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4435)
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A particle system that uses the position based dynamics(PBD) solver.
|
||||
|
||||
The position based dynamics solver for particle systems supports behaviors like
|
||||
fluid, cloth, inflatables etc.
|
||||
|
||||
*/
|
||||
class PxPBDParticleSystem : public PxParticleSystem
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~PxPBDParticleSystem() {}
|
||||
|
||||
/**
|
||||
\brief Set wind direction and intensity
|
||||
|
||||
\param[in] wind The wind direction and intensity
|
||||
*/
|
||||
virtual void setWind(const PxVec3& wind) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the wind direction and intensity.
|
||||
|
||||
\return The wind direction and intensity
|
||||
*/
|
||||
virtual PxVec3 getWind() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the fluid boundary density scale
|
||||
|
||||
Defines how strong of a contribution the boundary (typically a rigid surface) should have on a fluid particle's density.
|
||||
|
||||
\param[in] fluidBoundaryDensityScale <b>Range:</b> (0.0, 1.0)
|
||||
*/
|
||||
virtual void setFluidBoundaryDensityScale(PxReal fluidBoundaryDensityScale) = 0;
|
||||
|
||||
/**
|
||||
\brief Return the fluid boundary density scale
|
||||
\return the fluid boundary density scale
|
||||
|
||||
See #setFluidBoundaryDensityScale()
|
||||
*/
|
||||
virtual PxReal getFluidBoundaryDensityScale() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the fluid rest offset
|
||||
|
||||
Two fluid particles will come to rest at a distance equal to twice the fluidRestOffset value.
|
||||
|
||||
\param[in] fluidRestOffset <b>Range:</b> (0, particleContactOffset)
|
||||
*/
|
||||
virtual void setFluidRestOffset(PxReal fluidRestOffset) = 0;
|
||||
|
||||
/**
|
||||
\brief Return the fluid rest offset
|
||||
\return the fluid rest offset
|
||||
|
||||
See #setFluidRestOffset()
|
||||
*/
|
||||
virtual PxReal getFluidRestOffset() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the particle system grid size x dimension
|
||||
|
||||
\param[in] gridSizeX x dimension in the particle grid
|
||||
*/
|
||||
virtual void setGridSizeX(PxU32 gridSizeX) = 0;
|
||||
|
||||
/**
|
||||
\brief Set the particle system grid size y dimension
|
||||
|
||||
\param[in] gridSizeY y dimension in the particle grid
|
||||
*/
|
||||
virtual void setGridSizeY(PxU32 gridSizeY) = 0;
|
||||
|
||||
/**
|
||||
\brief Set the particle system grid size z dimension
|
||||
|
||||
\param[in] gridSizeZ z dimension in the particle grid
|
||||
*/
|
||||
virtual void setGridSizeZ(PxU32 gridSizeZ) = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxPBDParticleSystem"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxPBDParticleSystem(PxType concreteType, PxBaseFlags baseFlags) : PxParticleSystem(concreteType, baseFlags) {}
|
||||
PX_INLINE PxPBDParticleSystem(PxBaseFlags baseFlags) : PxParticleSystem(baseFlags) {}
|
||||
virtual bool isKindOf(const char* name) const PX_OVERRIDE { return !::strcmp("PxPBDParticleSystem", name) || PxParticleSystem::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,608 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PARTICLE_BUFFER_H
|
||||
#define PX_PARTICLE_BUFFER_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "common/PxBase.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "common/PxTypeInfo.h"
|
||||
|
||||
#include "PxParticleSystemFlag.h"
|
||||
|
||||
#include "foundation/PxBounds3.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxVec4.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4435)
|
||||
#endif
|
||||
|
||||
class PxCudaContextManager;
|
||||
struct PxParticleRigidFilterPair;
|
||||
struct PxParticleRigidAttachment;
|
||||
|
||||
/**
|
||||
\brief Particle volume structure. Used to track the bounding volume of a user-specified set of particles. The particles are required
|
||||
to be laid out contiguously within the same PxParticleBuffer.
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct PxParticleVolume
|
||||
{
|
||||
PxBounds3 bound; //!< The current bounds of the particles contained in this #PxParticleVolume.
|
||||
PxU32 particleIndicesOffset; //!< The index into the particle list of the #PxParticleBuffer for the first particle of this volume.
|
||||
PxU32 numParticles; //!< The number of particles contained in this #PxParticleVolume.
|
||||
} PX_ALIGN_SUFFIX(16);
|
||||
|
||||
|
||||
/**
|
||||
\brief The shared base class for all particle buffers, can be instantiated directly to simulate granular and fluid particles.
|
||||
|
||||
See #PxPhysics::createParticleBuffer.
|
||||
|
||||
A particle buffer is a container that specifies per-particle attributes of a set of particles that will be used during the simulation
|
||||
of a particle system. It exposes direct access to the underlying GPU buffers and is independent of the scene and particle system. Particle
|
||||
buffers can be added/removed from a particle system at any time between simulation steps, and transferred from one particle system to another.
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleBuffer : public PxBase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Get positions and inverse masses for this particle buffer.
|
||||
\return A pointer to a device buffer containing the positions and inverse mass packed as PxVec4(pos.x, pos.y, pos.z, inverseMass).
|
||||
*/
|
||||
virtual PxVec4* getPositionInvMasses() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get velocities for this particle buffer.
|
||||
\return A pointer to a device buffer containing the velocities packed as PxVec4(vel.x, vel.y, vel.z, 0.0f).
|
||||
*/
|
||||
virtual PxVec4* getVelocities() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get phases for this particle buffer.
|
||||
|
||||
See #PxParticlePhase
|
||||
|
||||
\return A pointer to a device buffer containing the per-particle phases for this particle buffer.
|
||||
*/
|
||||
virtual PxU32* getPhases() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get particle volumes for this particle buffer.
|
||||
|
||||
See #PxParticleVolume
|
||||
|
||||
\return A pointer to a device buffer containing the #PxParticleVolume s for this particle buffer.
|
||||
*/
|
||||
virtual PxParticleVolume* getParticleVolumes() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the number of active particles for this particle buffer.
|
||||
\param[in] nbActiveParticles The number of active particles.
|
||||
|
||||
The number of active particles can be <= PxParticleBuffer::getMaxParticles(). The particle system will simulate the first
|
||||
x particles in the #PxParticleBuffer, where x is the number of active particles.
|
||||
*/
|
||||
virtual void setNbActiveParticles(PxU32 nbActiveParticles) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the number of active particles for this particle buffer.
|
||||
\return The number of active particles.
|
||||
*/
|
||||
virtual PxU32 getNbActiveParticles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the maximum number particles this particle buffer can hold.
|
||||
|
||||
The maximum number of particles is specified when creating a #PxParticleBuffer. See #PxPhysics::createParticleBuffer.
|
||||
|
||||
\return The maximum number of particles.
|
||||
*/
|
||||
virtual PxU32 getMaxParticles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the number of particle volumes in this particle buffer.
|
||||
\return The number of #PxParticleVolume s for this particle buffer.
|
||||
*/
|
||||
virtual PxU32 getNbParticleVolumes() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the number of #PxParticleVolume s for this particle buffer.
|
||||
\param[in] nbParticleVolumes The number of particle volumes in this particle buffer.
|
||||
*/
|
||||
virtual void setNbParticleVolumes(PxU32 nbParticleVolumes) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the maximum number of particle volumes this particle buffer can hold.
|
||||
|
||||
See #PxParticleVolume.
|
||||
|
||||
\return The maximum number of particle volumes this particle buffer can hold.
|
||||
*/
|
||||
virtual PxU32 getMaxParticleVolumes() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the #PxParticleRigidFilterPair s for collision filtering of particles in this buffer with rigid bodies.
|
||||
|
||||
See #PxParticleRigidFilterPair
|
||||
|
||||
\param[in] filters A device buffer containing #PxParticleRigidFilterPair s.
|
||||
\param[in] nbFilters The number of particle-rigid body collision filtering pairs.
|
||||
*/
|
||||
virtual void setRigidFilters(PxParticleRigidFilterPair* filters, PxU32 nbFilters) = 0;
|
||||
|
||||
/**
|
||||
\brief Set the particle-rigid body attachments for particles in this particle buffer.
|
||||
|
||||
See #PxParticleRigidAttachment
|
||||
|
||||
\param[in] attachments A device buffer containing #PxParticleRigidAttachment s.
|
||||
\param[in] nbAttachments The number of particle-rigid body attachments.
|
||||
*/
|
||||
virtual void setRigidAttachments(PxParticleRigidAttachment* attachments, PxU32 nbAttachments) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the start index for the first particle of this particle buffer in the complete list of
|
||||
particles of the particle system this buffer is used in.
|
||||
|
||||
The return value is only correct if the particle buffer is assigned to a particle system and at least
|
||||
one call to simulate() has been performed.
|
||||
|
||||
\return The index of the first particle in the complete particle list.
|
||||
*/
|
||||
virtual PxU32 getFlatListStartIndex() const = 0;
|
||||
|
||||
/**
|
||||
\brief Raise dirty flags on this particle buffer to communicate that the corresponding data has been updated
|
||||
by the user.
|
||||
\param[in] flags The flag corresponding to the data that is dirty.
|
||||
|
||||
See #PxParticleBufferFlag.
|
||||
*/
|
||||
virtual void raiseFlags(PxParticleBufferFlag::Enum flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Release this buffer and deallocate all the memory.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Cleanup helper used in case a particle system is released before the particle buffers have been removed.
|
||||
*/
|
||||
virtual void onParticleSystemDestroy() = 0;
|
||||
|
||||
/**
|
||||
\brief Reserved for internal use.
|
||||
*/
|
||||
virtual void setInternalData(void* data) = 0;
|
||||
|
||||
/**
|
||||
\brief Index of this buffer in the particle system it is assigned to.
|
||||
*/
|
||||
PxU32 bufferIndex;
|
||||
|
||||
/**
|
||||
\brief Unique index that does not change over the lifetime of a PxParticleBuffer.
|
||||
*/
|
||||
const PxU32 bufferUniqueId;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~PxParticleBuffer() { }
|
||||
PX_INLINE PxParticleBuffer(PxU32 uniqueId) : PxBase(PxConcreteType::ePARTICLE_BUFFER, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE), bufferIndex(0xffffffff), bufferUniqueId(uniqueId){}
|
||||
PX_INLINE PxParticleBuffer(PxU32 uniqueId, PxType type) : PxBase(type, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE), bufferIndex(0xffffffff), bufferUniqueId(uniqueId){}
|
||||
|
||||
private:
|
||||
PX_NOCOPY(PxParticleBuffer)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Parameters to configure the behavior of diffuse particles
|
||||
*/
|
||||
class PxDiffuseParticleParams
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Construct parameters with default values.
|
||||
*/
|
||||
PX_INLINE PxDiffuseParticleParams()
|
||||
{
|
||||
threshold = 100.0f;
|
||||
lifetime = 5.0f;
|
||||
airDrag = 0.0f;
|
||||
bubbleDrag = 0.5f;
|
||||
buoyancy = 0.8f;
|
||||
kineticEnergyWeight = 0.01f;
|
||||
pressureWeight = 1.0f;
|
||||
divergenceWeight = 5.0f;
|
||||
collisionDecay = 0.5f;
|
||||
useAccurateVelocity = false;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE void setToDefault()
|
||||
{
|
||||
*this = PxDiffuseParticleParams();
|
||||
}
|
||||
|
||||
PxReal threshold; //!< Particles with potential value greater than the threshold will spawn diffuse particles
|
||||
PxReal lifetime; //!< Diffuse particle will be removed after the specified lifetime
|
||||
PxReal airDrag; //!< Air drag force factor for spray particles
|
||||
PxReal bubbleDrag; //!< Fluid drag force factor for bubble particles
|
||||
PxReal buoyancy; //!< Buoyancy force factor for bubble particles
|
||||
PxReal kineticEnergyWeight; //!< Contribution from kinetic energy when deciding diffuse particle creation.
|
||||
PxReal pressureWeight; //!< Contribution from pressure when deciding diffuse particle creation.
|
||||
PxReal divergenceWeight; //!< Contribution from divergence when deciding diffuse particle creation.
|
||||
PxReal collisionDecay; //!< Decay factor of diffuse particles' lifetime after they collide with shapes.
|
||||
bool useAccurateVelocity; //!< If true, enables accurate velocity estimation when using PBD solver.
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A particle buffer used to simulate diffuse particles.
|
||||
|
||||
See #PxPhysics::createParticleAndDiffuseBuffer.
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleAndDiffuseBuffer : public PxParticleBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Get a device buffer of positions and remaining lifetimes for the diffuse particles.
|
||||
\return A device buffer containing positions and lifetimes of diffuse particles packed as PxVec4(pos.x, pos.y, pos.z, lifetime).
|
||||
*/
|
||||
virtual PxVec4* getDiffusePositionLifeTime() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get number of currently active diffuse particles.
|
||||
\return The number of currently active diffuse particles.
|
||||
*/
|
||||
virtual PxU32 getNbActiveDiffuseParticles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the maximum possible number of diffuse particles for this buffer.
|
||||
\param[in] maxActiveDiffuseParticles the maximum number of active diffuse particles.
|
||||
|
||||
\note Must be in the range [0, PxParticleAndDiffuseBuffer::getMaxDiffuseParticles()]
|
||||
*/
|
||||
virtual void setMaxActiveDiffuseParticles(PxU32 maxActiveDiffuseParticles) = 0;
|
||||
|
||||
/**
|
||||
\brief Get maximum possible number of diffuse particles.
|
||||
\return The maximum possible number diffuse particles.
|
||||
*/
|
||||
virtual PxU32 getMaxDiffuseParticles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the parameters for diffuse particle simulation.
|
||||
\param[in] params The diffuse particle parameters.
|
||||
|
||||
See #PxDiffuseParticleParams
|
||||
*/
|
||||
virtual void setDiffuseParticleParams(const PxDiffuseParticleParams& params) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the parameters currently used for diffuse particle simulation.
|
||||
\return A PxDiffuseParticleParams structure.
|
||||
*/
|
||||
virtual PxDiffuseParticleParams getDiffuseParticleParams() const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~PxParticleAndDiffuseBuffer() {}
|
||||
PX_INLINE PxParticleAndDiffuseBuffer(PxU32 uniqueId) : PxParticleBuffer(uniqueId, PxConcreteType::ePARTICLE_DIFFUSE_BUFFER){}
|
||||
|
||||
private:
|
||||
PX_NOCOPY(PxParticleAndDiffuseBuffer)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Holds all the information for a spring constraint between two particles. Used for particle cloth simulation.
|
||||
*/
|
||||
struct PX_ALIGN_PREFIX(8) PxParticleSpring
|
||||
{
|
||||
PxU32 ind0; //!< particle index of first particle
|
||||
PxU32 ind1; //!< particle index of second particle
|
||||
PxReal length; //!< spring length
|
||||
PxReal stiffness; //!< spring stiffness
|
||||
PxReal damping; //!< spring damping factor
|
||||
PxReal pad; //!< padding bytes.
|
||||
} PX_ALIGN_SUFFIX(8);
|
||||
|
||||
/**
|
||||
\brief Particle cloth structure. Holds information about a single piece of cloth that is part of a #PxParticleClothBuffer.
|
||||
*/
|
||||
struct PX_DEPRECATED PxParticleCloth
|
||||
{
|
||||
PxU32 startVertexIndex; //!< Index of the first particle of this cloth in the position/velocity buffers of the parent #PxParticleClothBuffer
|
||||
PxU32 numVertices; //!< The number of particles of this piece of cloth
|
||||
PxReal clothBlendScale; //!< Used internally.
|
||||
PxReal restVolume; //!< The rest volume of this piece of cloth, used for inflatable simulation.
|
||||
PxReal pressure; //!< The factor of the rest volume to specify the target volume for this piece of cloth, used for inflatable simulation.
|
||||
PxU32 startTriangleIndex; //!< The index of the first triangle of this piece of cloth in the triangle list.
|
||||
PxU32 numTriangles; //!< The number of triangles of this piece of cloth.
|
||||
|
||||
bool operator <= (const PxParticleCloth& other) const { return startVertexIndex <= other.startVertexIndex; }
|
||||
bool operator >= (const PxParticleCloth& other) const { return startVertexIndex >= other.startVertexIndex; }
|
||||
bool operator < (const PxParticleCloth& other) const { return startVertexIndex < other.startVertexIndex; }
|
||||
bool operator > (const PxParticleCloth& other) const { return startVertexIndex > other.startVertexIndex; }
|
||||
bool operator == (const PxParticleCloth& other) const { return startVertexIndex == other.startVertexIndex; }
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Structure to describe the set of particle cloths in the same #PxParticleClothBuffer. Used an input for the cloth preprocessing.
|
||||
*/
|
||||
struct PX_DEPRECATED PxParticleClothDesc
|
||||
{
|
||||
PxParticleClothDesc() : cloths(NULL), triangles(NULL), springs(NULL), restPositions(NULL),
|
||||
nbCloths(0), nbSprings(0), nbTriangles(0), nbParticles(0)
|
||||
{
|
||||
}
|
||||
|
||||
PxParticleCloth* cloths; //!< List of PxParticleCloth s, describes the individual cloths.
|
||||
PxU32* triangles; //!< List of triangle indices, 3 consecutive PxU32 that map triangle vertices to particles
|
||||
PxParticleSpring* springs; //!< List of PxParticleSpring s.
|
||||
PxVec4* restPositions; //!< List of rest positions for all particles
|
||||
PxU32 nbCloths; //!< The number of cloths in described using this cloth descriptor
|
||||
PxU32 nbSprings; //!< The number of springs in this cloth descriptor
|
||||
PxU32 nbTriangles; //!< The number of triangles in this cloth descriptor
|
||||
PxU32 nbParticles; //!< The number of particles in this cloth descriptor
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Structure to describe the output of the particle cloth preprocessing. Used as an input to specify cloth data for a #PxParticleClothBuffer.
|
||||
All the pointers point to pinned host memory.
|
||||
|
||||
See #PxParticleClothPreProcessor
|
||||
*/
|
||||
struct PX_DEPRECATED PX_PHYSX_CORE_API PxPartitionedParticleCloth
|
||||
{
|
||||
PxU32* accumulatedSpringsPerPartitions; //!< The number of springs in each partition. Size: numPartitions.
|
||||
PxU32* accumulatedCopiesPerParticles; //!< Start index for each particle in the accumulation buffer. Size: numParticles.
|
||||
PxU32* remapOutput; //!< Index of the next copy of this particle in the next partition, or in the accumulation buffer. Size: numSprings * 2.
|
||||
PxParticleSpring* orderedSprings; //!< Springs ordered by partition. Size: numSprings.
|
||||
PxU32* sortedClothStartIndices; //!< The first particle index into the position buffer of the #PxParticleClothBuffer for each cloth. Cloths are sorted by start particle index. Size: numCloths.
|
||||
PxParticleCloth* cloths; //!< The #PxParticleCloth s sorted by start particle index.
|
||||
|
||||
PxU32 remapOutputSize; //!< Size of remapOutput.
|
||||
PxU32 nbPartitions; //!< The number of partitions.
|
||||
PxU32 nbSprings; //!< The number of springs.
|
||||
PxU32 nbCloths; //!< The number of cloths.
|
||||
PxU32 maxSpringsPerPartition; //!< The maximum number of springs in a partition.
|
||||
|
||||
PxCudaContextManager* mCudaManager; //!< A cuda context manager.
|
||||
|
||||
PxPartitionedParticleCloth();
|
||||
~PxPartitionedParticleCloth();
|
||||
|
||||
/**
|
||||
\brief allocate all the buffers for this #PxPartitionedParticleCloth.
|
||||
|
||||
\param[in] nbParticles the number of particles this #PxPartitionedParticleCloth will be generated for.
|
||||
\param[in] cudaManager a cuda context manager.
|
||||
*/
|
||||
void allocateBuffers(PxU32 nbParticles, PxCudaContextManager* cudaManager);
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A particle buffer used to simulate particle cloth.
|
||||
|
||||
See #PxPhysics::createParticleClothBuffer.
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleClothBuffer : public PxParticleBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Get rest positions for this particle buffer.
|
||||
\return A pointer to a device buffer containing the rest positions packed as PxVec4(pos.x, pos.y, pos.z, 0.0f).
|
||||
*/
|
||||
virtual PxVec4* getRestPositions() = 0;
|
||||
|
||||
/**
|
||||
\brief Get the triangle indices for this particle buffer.
|
||||
\return A pointer to a device buffer containing the triangle indices for this cloth buffer.
|
||||
*/
|
||||
virtual PxU32* getTriangles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the number of triangles for this particle buffer.
|
||||
\param[in] nbTriangles The number of triangles for this particle cloth buffer.
|
||||
*/
|
||||
virtual void setNbTriangles(PxU32 nbTriangles) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the number of triangles for this particle buffer.
|
||||
\return The number triangles for this cloth buffer.
|
||||
*/
|
||||
virtual PxU32 getNbTriangles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the number of springs in this particle buffer.
|
||||
\return The number of springs in this cloth buffer.
|
||||
*/
|
||||
virtual PxU32 getNbSprings() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the springs for this particle buffer.
|
||||
\return A pointer to a device buffer containing the springs for this cloth buffer.
|
||||
*/
|
||||
virtual PxParticleSpring* getSprings() = 0;
|
||||
|
||||
/**
|
||||
\brief Set cloths for this particle buffer.
|
||||
\param[in] cloths A pointer to a PxPartitionedParticleCloth.
|
||||
|
||||
See #PxPartitionedParticleCloth, #PxParticleClothPreProcessor
|
||||
*/
|
||||
virtual void setCloths(PxPartitionedParticleCloth& cloths) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~PxParticleClothBuffer() {}
|
||||
PX_INLINE PxParticleClothBuffer(PxU32 uniqueId) : PxParticleBuffer(uniqueId, PxConcreteType::ePARTICLE_CLOTH_BUFFER) {}
|
||||
|
||||
private:
|
||||
PX_NOCOPY(PxParticleClothBuffer)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A particle buffer used to simulate rigid bodies using shape matching with particles.
|
||||
|
||||
See #PxPhysics::createParticleRigidBuffer.
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleRigidBuffer : public PxParticleBuffer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Get the particle indices of the first particle for each shape matched rigid body.
|
||||
\return A device buffer containing the list of particle start indices of each shape matched rigid body.
|
||||
*/
|
||||
virtual PxU32* getRigidOffsets() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the stiffness coefficients for all shape matched rigid bodies in this buffer.
|
||||
|
||||
Stiffness must be in the range [0, 1].
|
||||
|
||||
\return A device buffer containing the list of stiffness coefficients for each rigid body.
|
||||
*/
|
||||
virtual PxReal* getRigidCoefficients() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the local position of each particle relative to the rigid body's center of mass.
|
||||
\return A pointer to a device buffer containing the local position for each particle.
|
||||
*/
|
||||
virtual PxVec4* getRigidLocalPositions() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the world-space translations for all rigid bodies in this buffer.
|
||||
\return A pointer to a device buffer containing the world-space translations for all shape-matched rigid bodies in this buffer.
|
||||
*/
|
||||
virtual PxVec4* getRigidTranslations() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the world-space rotation of every shape-matched rigid body in this buffer.
|
||||
|
||||
Rotations are specified as quaternions.
|
||||
|
||||
\return A pointer to a device buffer containing the world-space rotation for every shape-matched rigid body in this buffer.
|
||||
*/
|
||||
virtual PxVec4* getRigidRotations() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the local space normals for each particle relative to the shape of the corresponding rigid body.
|
||||
|
||||
The 4th component of every PxVec4 should be the negative signed distance of the particle inside its shape.
|
||||
|
||||
\return A pointer to a device buffer containing the local-space normals for each particle.
|
||||
*/
|
||||
virtual PxVec4* getRigidLocalNormals() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the number of shape matched rigid bodies in this buffer.
|
||||
\param[in] nbRigids The number of shape matched rigid bodies
|
||||
*/
|
||||
virtual void setNbRigids(PxU32 nbRigids) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the number of shape matched rigid bodies in this buffer.
|
||||
\return The number of shape matched rigid bodies in this buffer.
|
||||
*/
|
||||
virtual PxU32 getNbRigids() const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~PxParticleRigidBuffer() {}
|
||||
PX_INLINE PxParticleRigidBuffer(PxU32 uniqueId) : PxParticleBuffer(uniqueId, PxConcreteType::ePARTICLE_RIGID_BUFFER) {}
|
||||
|
||||
private:
|
||||
PX_NOCOPY(PxParticleRigidBuffer)
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Preprocessor to prepare particle cloths for simulation.
|
||||
|
||||
Preprocessing is done by calling #PxParticleClothPreProcessor::partitionSprings() on an instance of this class. This will allocate the memory in the
|
||||
output object, partition the springs and fill all the members of the ouput object. The output can then be passed without
|
||||
any further modifications to #PxParticleClothBuffer::setCloths().
|
||||
|
||||
See #PxCreateParticleClothPreprocessor, #PxParticleClothDesc, #PxPartitionedParticleCloth
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleClothPreProcessor
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Release this object and deallocate all the memory.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Partition the spring constraints for particle cloth simulation.
|
||||
\param[in] clothDesc Reference to a valid #PxParticleClothDesc.
|
||||
\param[in] output Reference to a #PxPartitionedParticleCloth object. This is the output of the preprocessing and should be passed to a #PxParticleClothBuffer.
|
||||
*/
|
||||
virtual void partitionSprings(const PxParticleClothDesc& clothDesc, PxPartitionedParticleCloth& output) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxParticleClothPreProcessor(){}
|
||||
};
|
||||
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Create a particle cloth preprocessor.
|
||||
\param[in] cudaContextManager A cuda context manager.
|
||||
|
||||
See #PxParticleClothDesc, #PxPartitionedParticleCloth.
|
||||
*/
|
||||
PX_DEPRECATED PX_C_EXPORT PX_PHYSX_CORE_API physx::PxParticleClothPreProcessor* PX_CALL_CONV PxCreateParticleClothPreProcessor(physx::PxCudaContextManager* cudaContextManager);
|
||||
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,192 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_GPU_PARTICLE_SYSTEM_H
|
||||
#define PX_GPU_PARTICLE_SYSTEM_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#include "PxParticleSystem.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
@brief Common material properties for particles. See #PxParticleMaterial.
|
||||
|
||||
Accessed by either integration or particle-rigid collisions
|
||||
*/
|
||||
struct PxsParticleMaterialData
|
||||
{
|
||||
PxReal friction; // 4
|
||||
PxReal damping; // 8
|
||||
PxReal adhesion; // 12
|
||||
PxReal gravityScale; // 16
|
||||
PxReal adhesionRadiusScale; // 20
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#if PX_SUPPORT_GPU_PHYSX
|
||||
|
||||
struct float4;
|
||||
|
||||
PX_CUDA_CALLABLE inline physx::PxU32 PxGetGroup(physx::PxU32 phase) { return phase & physx::PxParticlePhaseFlag::eParticlePhaseGroupMask; }
|
||||
PX_CUDA_CALLABLE inline bool PxGetFluid(physx::PxU32 phase) { return (phase & physx::PxParticlePhaseFlag::eParticlePhaseFluid) != 0; }
|
||||
PX_CUDA_CALLABLE inline bool PxGetSelfCollide(physx::PxU32 phase) { return (phase & physx::PxParticlePhaseFlag::eParticlePhaseSelfCollide) != 0; }
|
||||
PX_CUDA_CALLABLE inline bool PxGetSelfCollideFilter(physx::PxU32 phase) { return (phase & physx::PxParticlePhaseFlag::eParticlePhaseSelfCollideFilter) != 0; }
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
@brief An iterator class to iterate over the neighbors of a particle during particle system simulation.
|
||||
*/
|
||||
class PxNeighborhoodIterator
|
||||
{
|
||||
|
||||
const PxU32* PX_RESTRICT mCollisionIndex; //!< Pointer to the current state of the iterator.
|
||||
PxU32 mMaxParticles; //!< The maximum number of particles of the particle system this iterator is used on.
|
||||
|
||||
public:
|
||||
PX_CUDA_CALLABLE PxNeighborhoodIterator(const PxU32* PX_RESTRICT collisionIndex, PxU32 maxParticles) :
|
||||
mCollisionIndex(collisionIndex), mMaxParticles(maxParticles)
|
||||
{
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PxU32 getNextIndex()
|
||||
{
|
||||
PxU32 result = *mCollisionIndex;
|
||||
mCollisionIndex += mMaxParticles;
|
||||
return result;
|
||||
}
|
||||
|
||||
PX_INLINE PxNeighborhoodIterator(const PxNeighborhoodIterator& params)
|
||||
{
|
||||
mCollisionIndex = params.mCollisionIndex;
|
||||
mMaxParticles = params.mMaxParticles;
|
||||
}
|
||||
|
||||
PX_INLINE void operator = (const PxNeighborhoodIterator& params)
|
||||
{
|
||||
mCollisionIndex = params.mCollisionIndex;
|
||||
mMaxParticles = params.mMaxParticles;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Structure that holds simulation parameters of a #PxGpuParticleSystem.
|
||||
*/
|
||||
struct PxGpuParticleData
|
||||
{
|
||||
PxVec3 mPeriod; //!< Size of the unit cell for periodic boundary conditions. If 0, the size of the simulation domain is specified by the mGridSize * mParticleContactDistance.
|
||||
|
||||
PxU32 mGridSizeX; //!< Size of the x-dimension of the background simulation grid. Translates to an absolute size of mGridSizeX * mParticleContactDistance.
|
||||
PxU32 mGridSizeY; //!< Size of the y-dimension of the background simulation grid. Translates to an absolute size of mGridSizeY * mParticleContactDistance.
|
||||
PxU32 mGridSizeZ; //!< Size of the z-dimension of the background simulation grid. Translates to an absolute size of mGridSizeZ * mParticleContactDistance.
|
||||
|
||||
PxReal mParticleContactDistance; //!< Two particles start interacting if their distance is lower than mParticleContactDistance.
|
||||
PxReal mParticleContactDistanceInv; //!< 1.f / mParticleContactDistance.
|
||||
PxReal mParticleContactDistanceSq; //!< mParticleContactDistance * mParticleContactDistance.
|
||||
|
||||
PxU32 mNumParticles; //!< The number of particles in this particle system.
|
||||
PxU32 mMaxParticles; //!< The maximum number of particles that can be simulated in this particle system.
|
||||
PxU32 mMaxNeighborhood; //!< The maximum number of particles considered when computing neighborhood based particle interactions.
|
||||
PxU32 mMaxDiffuseParticles; //!< The maximum number of diffuse particles that can be simulated using this particle system.
|
||||
PxU32 mNumParticleBuffers; //!< The number of particle buffers that are simulated in this particle system.
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Container class for a GPU particle system. Used to communicate particle system parameters and simulation state
|
||||
between the internal SDK simulation and the particle system callbacks.
|
||||
|
||||
See #PxParticleSystem, #PxParticleSystemCallback.
|
||||
*/
|
||||
class PxGpuParticleSystem
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
@brief Returns the number of cells of the background simulation grid.
|
||||
|
||||
@return PxU32 the number of cells.
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNumCells() { return mCommonData.mGridSizeX * mCommonData.mGridSizeY * mCommonData.mGridSizeZ; }
|
||||
|
||||
/* Unsorted particle state buffers */
|
||||
float4* mUnsortedPositions_InvMass; //!< GPU pointer to unsorted particle positions and inverse masses.
|
||||
float4* mUnsortedVelocities; //!< GPU pointer to unsorted particle velocities.
|
||||
PxU32* mUnsortedPhaseArray; //!< GPU pointer to unsorted particle phase array. See #PxParticlePhase.
|
||||
|
||||
/* Sorted particle state buffers. Sorted by increasing hash value in background grid. */
|
||||
float4* mSortedPositions_InvMass; //!< GPU pointer to sorted particle positions
|
||||
float4* mSortedVelocities; //!< GPU pointer to sorted particle velocities
|
||||
PxU32* mSortedPhaseArray; //!< GPU pointer to sorted particle phase array
|
||||
|
||||
/* Mappings to/from sorted particle states */
|
||||
PxU32* mUnsortedToSortedMapping; //!< GPU pointer to the mapping from unsortedParticle ID to sorted particle ID
|
||||
PxU32* mSortedToUnsortedMapping; //!< GPU pointer to the mapping from sorted particle ID to unsorted particle ID
|
||||
|
||||
/* Neighborhood information */
|
||||
PxU32* mParticleSelfCollisionCount; //!< Per-particle neighborhood count
|
||||
PxU32* mCollisionIndex; //!< Set of sorted particle indices per neighbor
|
||||
|
||||
PxsParticleMaterialData* mParticleMaterials; //!< GPU pointer to the particle materials used in this particle system.
|
||||
PxGpuParticleData mCommonData; //!< Structure holding simulation parameters and state for this particle system. See #PxGpuParticleData.
|
||||
|
||||
/**
|
||||
@brief Get a PxNeighborhoodIterator initialized for usage with this particle system.
|
||||
|
||||
@param particleId An initial particle index for the initialization of the iterator.
|
||||
|
||||
@return An initialized PxNeighborhoodIterator.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PxNeighborhoodIterator getIterator(PxU32 particleId) const
|
||||
{
|
||||
return PxNeighborhoodIterator(mCollisionIndex + particleId, mCommonData.mMaxParticles);
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PARTICLE_MATERIAL_H
|
||||
#define PX_PARTICLE_MATERIAL_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#include "PxBaseMaterial.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Material class to represent a set of particle material properties.
|
||||
|
||||
@see #PxPhysics.createPBDMaterial, #PxPhysics.createFLIPMaterial, #PxPhysics.createMPMMaterial
|
||||
*/
|
||||
class PxParticleMaterial : public PxBaseMaterial
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Sets friction
|
||||
|
||||
\param[in] friction Friction. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getFriction()
|
||||
*/
|
||||
virtual void setFriction(PxReal friction) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the friction value.
|
||||
|
||||
\return The friction value.
|
||||
|
||||
@see #setFriction()
|
||||
*/
|
||||
virtual PxReal getFriction() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets velocity damping term
|
||||
|
||||
\param[in] damping Velocity damping term. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getDamping
|
||||
*/
|
||||
virtual void setDamping(PxReal damping) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the velocity damping term
|
||||
\return The velocity damping term.
|
||||
|
||||
@see #setDamping()
|
||||
*/
|
||||
virtual PxReal getDamping() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets adhesion term
|
||||
|
||||
\param[in] adhesion adhesion coefficient. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getAdhesion
|
||||
*/
|
||||
virtual void setAdhesion(PxReal adhesion) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the adhesion term
|
||||
\return The adhesion term.
|
||||
|
||||
@see #setAdhesion()
|
||||
*/
|
||||
virtual PxReal getAdhesion() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets gravity scale term
|
||||
|
||||
\param[in] scale gravity scale coefficient. <b>Range:</b> (-PX_MAX_F32, PX_MAX_F32)
|
||||
|
||||
@see #getAdhesion
|
||||
*/
|
||||
virtual void setGravityScale(PxReal scale) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the gravity scale term
|
||||
\return The gravity scale term.
|
||||
|
||||
@see #setAdhesion()
|
||||
*/
|
||||
virtual PxReal getGravityScale() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets material adhesion radius scale. This is multiplied by the particle rest offset to compute the fall-off distance
|
||||
at which point adhesion ceases to operate.
|
||||
|
||||
\param[in] scale Material adhesion radius scale. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see #getAdhesionRadiusScale
|
||||
*/
|
||||
virtual void setAdhesionRadiusScale(PxReal scale) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the adhesion radius scale.
|
||||
\return The adhesion radius scale.
|
||||
|
||||
@see #setAdhesionRadiusScale()
|
||||
*/
|
||||
virtual PxReal getAdhesionRadiusScale() const = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxParticleMaterial(PxType concreteType, PxBaseFlags baseFlags) : PxBaseMaterial(concreteType, baseFlags) {}
|
||||
PX_INLINE PxParticleMaterial(PxBaseFlags baseFlags) : PxBaseMaterial(baseFlags) {}
|
||||
virtual ~PxParticleMaterial() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxParticleMaterial", name) || PxBaseMaterial::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PARTICLE_SOLVER_TYPE_H
|
||||
#define PX_PARTICLE_SOLVER_TYPE_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4435)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Identifies the solver to use for a particle system.
|
||||
*/
|
||||
struct PxParticleSolverType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
ePBD = 1 << 0, //!< The position based dynamics solver that can handle fluid, granular material, cloth, inflatables etc. See #PxPBDParticleSystem.
|
||||
eFLIP = 1 << 1, //!< The FLIP fluid solver. See #PxFLIPParticleSystem.
|
||||
eMPM = 1 << 2, //!< The MPM (material point method) solver that can handle a variety of materials. See #PxMPMParticleSystem.
|
||||
eCUSTOM = 1 << 3 //!< Custom solver. The user needs to specify the interaction of the particle by providing appropriate functions. Can be used e.g. for molecular dynamics simulations. See #PxCustomParticleSystem.
|
||||
};
|
||||
};
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,455 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PARTICLE_SYSTEM_H
|
||||
#define PX_PARTICLE_SYSTEM_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#if PX_SUPPORT_GPU_PHYSX
|
||||
|
||||
#include "PxActor.h"
|
||||
#include "PxFiltering.h"
|
||||
#include "PxParticleSystemFlag.h"
|
||||
|
||||
#include "cudamanager/PxCudaTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4435)
|
||||
#endif
|
||||
|
||||
class PxCudaContextManager;
|
||||
class PxGpuParticleSystem;
|
||||
|
||||
class PxParticleAndDiffuseBuffer;
|
||||
class PxParticleBuffer;
|
||||
class PxParticleMaterial;
|
||||
|
||||
/**
|
||||
\brief Container to hold a pair of corresponding device and host pointers. These pointers should point to GPU / CPU mirrors of the same data, but
|
||||
this is not enforced.
|
||||
*/
|
||||
template <typename Type>
|
||||
struct PxGpuMirroredPointer
|
||||
{
|
||||
Type* mDevicePtr;
|
||||
Type* mHostPtr;
|
||||
|
||||
PxGpuMirroredPointer(Type* devicePtr, Type* hostPtr) : mDevicePtr(devicePtr), mHostPtr(hostPtr) { }
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Particle system callback base class to schedule work that should be done before, while or after the particle system updates.
|
||||
A call to fetchResultsParticleSystem() on the PxScene will synchronize the work such that the caller knows that all tasks of this callback completed.
|
||||
*/
|
||||
class PxParticleSystemCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Method gets called when dirty data from the particle system is uploated to the gpu
|
||||
|
||||
\param[in] gpuParticleSystem Pointers to the particle systems gpu data available as host accessible pointer and as gpu accessible pointer
|
||||
\param[in] stream The stream on which all cuda kernel calls get scheduled for execution. A call to fetchResultsParticleSystem() on the
|
||||
PxScene will synchronize the work such that the caller knows that the task completed.
|
||||
*/
|
||||
virtual void onBegin(const PxGpuMirroredPointer<PxGpuParticleSystem>& gpuParticleSystem, CUstream stream) = 0;
|
||||
|
||||
/**
|
||||
\brief Method gets called when the simulation step of the particle system is performed
|
||||
|
||||
\param[in] gpuParticleSystem Pointers to the particle systems gpu data available as host accessible pointer and as gpu accessible pointer
|
||||
\param[in] stream The stream on which all cuda kernel calls get scheduled for execution. A call to fetchResultsParticleSystem() on the
|
||||
PxScene will synchronize the work such that the caller knows that the task completed.
|
||||
*/
|
||||
virtual void onAdvance(const PxGpuMirroredPointer<PxGpuParticleSystem>& gpuParticleSystem, CUstream stream) = 0;
|
||||
|
||||
/**
|
||||
\brief Method gets called after the particle system simulation step completed
|
||||
|
||||
\param[in] gpuParticleSystem Pointers to the particle systems gpu data available as host accessible pointer and as gpu accessible pointer
|
||||
\param[in] stream The stream on which all cuda kernel calls get scheduled for execution. A call to fetchResultsParticleSystem() on the
|
||||
PxScene will synchronize the work such that the caller knows that the task completed.
|
||||
*/
|
||||
virtual void onPostSolve(const PxGpuMirroredPointer<PxGpuParticleSystem>& gpuParticleSystem, CUstream stream) = 0;
|
||||
|
||||
/**
|
||||
\brief Destructor
|
||||
*/
|
||||
virtual ~PxParticleSystemCallback() {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Flags which control the behaviour of a particle system.
|
||||
|
||||
See #PxParticleSystem::setParticleFlag(), #PxParticleSystem::setParticleFlags(), #PxParticleSystem::getParticleFlags()
|
||||
*/
|
||||
struct PxParticleFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eDISABLE_SELF_COLLISION = 1 << 0, //!< Disables particle self-collision
|
||||
eDISABLE_RIGID_COLLISION = 1 << 1, //!< Disables particle-rigid body collision
|
||||
eFULL_DIFFUSE_ADVECTION = 1 << 2 //!< Enables full advection of diffuse particles. By default, diffuse particles are advected only by particles in the cell they are contained. This flag enables full neighbourhood generation (more expensive).
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxParticleFlag::Enum, PxU32> PxParticleFlags;
|
||||
|
||||
/**
|
||||
\brief The shared base class for all particle systems
|
||||
|
||||
A particle system simulates a bunch of particles that interact with each other. The interactions can be simple collisions
|
||||
with friction (granular material) ore more complex like fluid interactions, cloth, inflatables etc.
|
||||
|
||||
*/
|
||||
class PX_DEPRECATED PxParticleSystem : public PxActor
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Sets the solver iteration counts for the body.
|
||||
|
||||
The solver iteration count determines how accurately joints and contacts are resolved.
|
||||
If you are having trouble with jointed bodies oscillating and behaving erratically, then
|
||||
setting a higher position iteration count may improve their stability.
|
||||
|
||||
If intersecting bodies are being depenetrated too violently, increase the number of velocity
|
||||
iterations. More velocity iterations will drive the relative exit velocity of the intersecting
|
||||
objects closer to the correct value given the restitution.
|
||||
|
||||
<b>Default:</b> 4 position iterations, 1 velocity iteration
|
||||
|
||||
\param[in] minPositionIters Number of position iterations the solver should perform for this body. <b>Range:</b> [1,255]
|
||||
\param[in] minVelocityIters Number of velocity iterations the solver should perform for this body. <b>Range:</b> [1,255]
|
||||
|
||||
See #getSolverIterationCounts()
|
||||
*/
|
||||
virtual void setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters = 1) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the solver iteration counts.
|
||||
|
||||
See #setSolverIterationCounts()
|
||||
*/
|
||||
virtual void getSolverIterationCounts(PxU32& minPositionIters, PxU32& minVelocityIters) const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the collision filter settings.
|
||||
|
||||
\return The filter data
|
||||
*/
|
||||
virtual PxFilterData getSimulationFilterData() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set collision filter settings
|
||||
|
||||
Allows to control with which objects the particle system collides
|
||||
|
||||
\param[in] data The filter data
|
||||
*/
|
||||
virtual void setSimulationFilterData(const PxFilterData& data) = 0;
|
||||
|
||||
/**
|
||||
\brief Set particle flag
|
||||
|
||||
Allows to control self collision etc.
|
||||
|
||||
\param[in] flag The flag to set
|
||||
\param[in] val The new value of the flag
|
||||
*/
|
||||
virtual void setParticleFlag(PxParticleFlag::Enum flag, bool val) = 0;
|
||||
|
||||
/**
|
||||
\brief Set particle flags
|
||||
|
||||
Allows to control self collision etc.
|
||||
|
||||
\param[in] flags The flags to set
|
||||
*/
|
||||
virtual void setParticleFlags(PxParticleFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the particle flags.
|
||||
|
||||
\return The particle flags
|
||||
*/
|
||||
virtual PxParticleFlags getParticleFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the maximal depenetration velocity particles can reach
|
||||
|
||||
Allows to limit the particles' maximal depenetration velocity to avoid that collision responses lead to very high particle velocities
|
||||
|
||||
\param[in] maxDepenetrationVelocity The maximal depenetration velocity
|
||||
*/
|
||||
virtual void setMaxDepenetrationVelocity(PxReal maxDepenetrationVelocity) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves maximal depenetration velocity a particle can have.
|
||||
|
||||
\return The maximal depenetration velocity
|
||||
*/
|
||||
virtual PxReal getMaxDepenetrationVelocity() = 0;
|
||||
|
||||
/**
|
||||
\brief Set the maximal velocity particles can reach
|
||||
|
||||
Allows to limit the particles' maximal velocity to control the maximal distance a particle can move per frame
|
||||
|
||||
\param[in] maxVelocity The maximal velocity
|
||||
*/
|
||||
virtual void setMaxVelocity(PxReal maxVelocity) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves maximal velocity a particle can have.
|
||||
|
||||
\return The maximal velocity
|
||||
*/
|
||||
virtual PxReal getMaxVelocity() = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Return the cuda context manager
|
||||
|
||||
\return The cuda context manager
|
||||
*/
|
||||
virtual PxCudaContextManager* getCudaContextManager() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the rest offset for the collision between particles and rigids or soft bodies.
|
||||
|
||||
A particle and a rigid or soft body will come to rest at a distance equal to the sum of their restOffset values.
|
||||
|
||||
\param[in] restOffset <b>Range:</b> (0, contactOffset)
|
||||
*/
|
||||
virtual void setRestOffset(PxReal restOffset) = 0;
|
||||
|
||||
/**
|
||||
\brief Return the rest offset
|
||||
\return the rest offset
|
||||
|
||||
See #setRestOffset()
|
||||
*/
|
||||
virtual PxReal getRestOffset() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the contact offset for the collision between particles and rigids or soft bodies
|
||||
|
||||
The contact offset needs to be larger than the rest offset.
|
||||
Contact constraints are generated for a particle and a rigid or softbody below the distance equal to the sum of their contacOffset values.
|
||||
|
||||
\param[in] contactOffset <b>Range:</b> (restOffset, PX_MAX_F32)
|
||||
*/
|
||||
virtual void setContactOffset(PxReal contactOffset) = 0;
|
||||
|
||||
/**
|
||||
\brief Return the contact offset
|
||||
\return the contact offset
|
||||
|
||||
See #setContactOffset()
|
||||
*/
|
||||
virtual PxReal getContactOffset() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the contact offset for the interactions between particles
|
||||
|
||||
The particle contact offset needs to be larger than the fluid rest offset and larger than the solid rest offset.
|
||||
Interactions for two particles are computed if their distance is below twice the particleContactOffset value.
|
||||
|
||||
\param[in] particleContactOffset <b>Range:</b> (Max(solidRestOffset, fluidRestOffset), PX_MAX_F32)
|
||||
*/
|
||||
virtual void setParticleContactOffset(PxReal particleContactOffset) = 0;
|
||||
|
||||
/**
|
||||
\brief Return the particle contact offset
|
||||
\return the particle contact offset
|
||||
|
||||
See #setParticleContactOffset()
|
||||
*/
|
||||
virtual PxReal getParticleContactOffset() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set the solid rest offset
|
||||
|
||||
Two solid particles (or a solid and a fluid particle) will come to rest at a distance equal to twice the solidRestOffset value.
|
||||
|
||||
\param[in] solidRestOffset <b>Range:</b> (0, particleContactOffset)
|
||||
*/
|
||||
virtual void setSolidRestOffset(PxReal solidRestOffset) = 0;
|
||||
|
||||
/**
|
||||
\brief Return the solid rest offset
|
||||
\return the solid rest offset
|
||||
|
||||
See #setSolidRestOffset()
|
||||
*/
|
||||
virtual PxReal getSolidRestOffset() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Creates a rigid attachment between a particle and a rigid actor.
|
||||
|
||||
This method creates a symbolic attachment between the particle system and a rigid body for the purpose of island management.
|
||||
The actual attachments will be contained in the particle buffers.
|
||||
|
||||
Be aware that destroying the rigid body before destroying the attachment is illegal and may cause a crash.
|
||||
The particle system keeps track of these attachments but the rigid body does not.
|
||||
|
||||
\param[in] actor The rigid actor used for the attachment
|
||||
*/
|
||||
virtual void addRigidAttachment(PxRigidActor* actor) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes a rigid attachment between a particle and a rigid body.
|
||||
|
||||
This method destroys a symbolic attachment between the particle system and a rigid body for the purpose of island management.
|
||||
|
||||
Be aware that destroying the rigid body before destroying the attachment is illegal and may cause a crash.
|
||||
The particle system keeps track of these attachments but the rigid body does not.
|
||||
|
||||
\param[in] actor The rigid body actor used for the attachment
|
||||
*/
|
||||
virtual void removeRigidAttachment(PxRigidActor* actor) = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Enable continuous collision detection for particles
|
||||
|
||||
\param[in] enable Boolean indicates whether continuous collision detection is enabled.
|
||||
*/
|
||||
virtual void enableCCD(bool enable) = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Creates combined particle flag with particle material and particle phase flags.
|
||||
|
||||
\param[in] material A material instance to associate with the new particle group.
|
||||
\param[in] flags The particle phase flags.
|
||||
\return The combined particle group index and phase flags.
|
||||
|
||||
See #PxParticlePhaseFlag
|
||||
*/
|
||||
virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Returns number of particle materials
|
||||
\return The number of particle materials
|
||||
*/
|
||||
virtual PxU32 getNbParticleMaterials() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets a user notify object which receives special simulation events when they occur.
|
||||
|
||||
\note Do not set the callback while the simulation is running. Calls to this method while the simulation is running will be ignored.
|
||||
\note A call to fetchResultsParticleSystem() on the PxScene will synchronize the work such that the caller knows that all worke done in the callback completed.
|
||||
|
||||
\param[in] callback User notification callback. See PxSimulationEventCallback.
|
||||
|
||||
See #PxParticleSystemCallback, #getParticleSystemCallback()
|
||||
*/
|
||||
virtual void setParticleSystemCallback(PxParticleSystemCallback* callback) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the simulationEventCallback pointer set with setSimulationEventCallback().
|
||||
\return The current user notify pointer. See PxSimulationEventCallback.
|
||||
|
||||
See #PxParticleSystemCallback, #setParticleSystemCallback()
|
||||
*/
|
||||
virtual PxParticleSystemCallback* getParticleSystemCallback() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets periodic boundary wrap value
|
||||
\param[in] boundary The periodic boundary wrap value
|
||||
|
||||
See #getPeriodicBoundary()
|
||||
*/
|
||||
virtual void setPeriodicBoundary(const PxVec3& boundary) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets periodic boundary wrap value
|
||||
\return boundary The periodic boundary wrap value
|
||||
|
||||
See #setPeriodicBoundary()
|
||||
*/
|
||||
virtual PxVec3 getPeriodicBoundary() const = 0;
|
||||
|
||||
/**
|
||||
\brief Add an existing particle buffer to the particle system.
|
||||
\param[in] particleBuffer a PxParticleBuffer*.
|
||||
|
||||
See #PxParticleBuffer.
|
||||
*/
|
||||
virtual void addParticleBuffer(PxParticleBuffer* particleBuffer) = 0;
|
||||
|
||||
/**
|
||||
\brief Remove particle buffer from the particle system.
|
||||
\param[in] particleBuffer a PxParticleBuffer*.
|
||||
|
||||
See #PxParticleBuffer.
|
||||
*/
|
||||
virtual void removeParticleBuffer(PxParticleBuffer* particleBuffer) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the GPU particle system index.
|
||||
\return The GPU index, if the particle system is in a scene and PxSceneFlag::eSUPPRESS_READBACK is set, or 0xFFFFFFFF otherwise.
|
||||
*/
|
||||
virtual PxU32 getGpuParticleSystemIndex() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~PxParticleSystem() {}
|
||||
|
||||
PX_INLINE PxParticleSystem(PxType concreteType, PxBaseFlags baseFlags) : PxActor(concreteType, baseFlags) {}
|
||||
PX_INLINE PxParticleSystem(PxBaseFlags baseFlags) : PxActor(baseFlags) {}
|
||||
virtual bool isKindOf(const char* name) const PX_OVERRIDE { return !::strcmp("PxParticleSystem", name) || PxActor::isKindOf(name); }
|
||||
};
|
||||
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,101 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PARTICLE_SYSTEM_FLAG_H
|
||||
#define PX_PARTICLE_SYSTEM_FLAG_H
|
||||
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Identifies dirty particle buffers that need to be updated in the particle system.
|
||||
|
||||
This flag can be used mark the device user buffers that are dirty and need to be written to the particle system.
|
||||
*/
|
||||
struct PxParticleBufferFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE = 0, //!< No data specified
|
||||
|
||||
eUPDATE_POSITION = 1 << 0, //!< Specifies the position (first 3 floats) and inverse mass (last float) data (array of PxVec4 * number of particles)
|
||||
eUPDATE_VELOCITY = 1 << 1, //!< Specifies the velocity (first 3 floats) data (array of PxVec4 * number of particles)
|
||||
eUPDATE_PHASE = 1 << 2, //!< Specifies the per-particle phase flag data (array of PxU32 * number of particles)
|
||||
eUPDATE_RESTPOSITION = 1 << 3, //!< Specifies the rest position (first 3 floats) data for cloth buffers
|
||||
eUPDATE_CLOTH = 1 << 5, //!< Specifies the cloth buffer (see PxParticleClothBuffer)
|
||||
eUPDATE_RIGID = 1 << 6, //!< Specifies the rigid buffer (see PxParticleRigidBuffer)
|
||||
eUPDATE_DIFFUSE_PARAM = 1 << 7, //!< Specifies the diffuse particle parameter buffer (see PxDiffuseParticleParams)
|
||||
eUPDATE_ATTACHMENTS = 1 << 8, //!< Specifies the attachments.
|
||||
|
||||
eALL =
|
||||
eUPDATE_POSITION | eUPDATE_VELOCITY | eUPDATE_PHASE | eUPDATE_RESTPOSITION | eUPDATE_CLOTH | eUPDATE_RIGID | eUPDATE_DIFFUSE_PARAM | eUPDATE_ATTACHMENTS
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxParticleBufferFlag::Enum, PxU32> PxParticleBufferFlags;
|
||||
|
||||
/**
|
||||
\brief A pair of particle buffer unique id and GPU particle system index.
|
||||
|
||||
@see PxScene::applyParticleBufferData
|
||||
*/
|
||||
struct PxGpuParticleBufferIndexPair
|
||||
{
|
||||
PxU32 systemIndex; // gpu particle system index
|
||||
PxU32 bufferIndex; // particle buffer unique id
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Identifies per-particle behavior for a PxParticleSystem.
|
||||
|
||||
See #PxParticleSystem::createPhase().
|
||||
*/
|
||||
struct PxParticlePhaseFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eParticlePhaseGroupMask = 0x000fffff, //!< Bits [ 0, 19] represent the particle group for controlling collisions
|
||||
eParticlePhaseFlagsMask = 0xfff00000, //!< Bits [20, 23] hold flags about how the particle behave
|
||||
|
||||
eParticlePhaseSelfCollide = 1 << 20, //!< If set this particle will interact with particles of the same group
|
||||
eParticlePhaseSelfCollideFilter = 1 << 21, //!< If set this particle will ignore collisions with particles closer than the radius in the rest pose, this flag should not be specified unless valid rest positions have been specified using setRestParticles()
|
||||
eParticlePhaseFluid = 1 << 22 //!< If set this particle will generate fluid density constraints for its overlapping neighbors
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxParticlePhaseFlag::Enum, PxU32> PxParticlePhaseFlags;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PHYSICS_CONFIG_H
|
||||
#define PX_PHYSICS_CONFIG_H
|
||||
|
||||
/** Configuration include file for PhysX SDK */
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
1317
modules/PhysX/physx/physx-sys/physx/physx/include/PxPhysics.h
Normal file
1317
modules/PhysX/physx/physx-sys/physx/physx/include/PxPhysics.h
Normal file
File diff suppressed because it is too large
Load Diff
253
modules/PhysX/physx/physx-sys/physx/physx/include/PxPhysicsAPI.h
Normal file
253
modules/PhysX/physx/physx-sys/physx/physx/include/PxPhysicsAPI.h
Normal file
@@ -0,0 +1,253 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PHYSICS_API_H
|
||||
#define PX_PHYSICS_API_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
This is the main include header for the Physics SDK, for users who
|
||||
want to use a single #include file.
|
||||
|
||||
Alternatively, one can instead directly #include a subset of the below files.
|
||||
*/
|
||||
|
||||
// Foundation SDK
|
||||
#include "foundation/Px.h"
|
||||
#include "foundation/PxAlignedMalloc.h"
|
||||
#include "foundation/PxAlloca.h"
|
||||
#include "foundation/PxAllocatorCallback.h"
|
||||
#include "foundation/PxArray.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "foundation/PxAtomic.h"
|
||||
#include "foundation/PxBasicTemplates.h"
|
||||
#include "foundation/PxBitAndData.h"
|
||||
#include "foundation/PxBitMap.h"
|
||||
#include "foundation/PxBitUtils.h"
|
||||
#include "foundation/PxBounds3.h"
|
||||
#include "foundation/PxBroadcast.h"
|
||||
#include "foundation/PxErrorCallback.h"
|
||||
#include "foundation/PxErrors.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "foundation/PxFoundation.h"
|
||||
#include "foundation/PxFoundationConfig.h"
|
||||
#include "foundation/PxFPU.h"
|
||||
#include "foundation/PxHash.h"
|
||||
#include "foundation/PxHashMap.h"
|
||||
#include "foundation/PxHashSet.h"
|
||||
#include "foundation/PxInlineAllocator.h"
|
||||
#include "foundation/PxInlineArray.h"
|
||||
#include "foundation/PxIntrinsics.h"
|
||||
#include "foundation/PxIO.h"
|
||||
#include "foundation/PxMat33.h"
|
||||
#include "foundation/PxMat44.h"
|
||||
#include "foundation/PxMath.h"
|
||||
#include "foundation/PxMathIntrinsics.h"
|
||||
#include "foundation/PxMathUtils.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
#include "foundation/PxMutex.h"
|
||||
#include "foundation/PxPhysicsVersion.h"
|
||||
#include "foundation/PxPlane.h"
|
||||
#include "foundation/PxPool.h"
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
#include "foundation/PxProfiler.h"
|
||||
#include "foundation/PxQuat.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxSList.h"
|
||||
#include "foundation/PxSocket.h"
|
||||
#include "foundation/PxSort.h"
|
||||
#include "foundation/PxStrideIterator.h"
|
||||
#include "foundation/PxString.h"
|
||||
#include "foundation/PxSync.h"
|
||||
#include "foundation/PxTempAllocator.h"
|
||||
#include "foundation/PxThread.h"
|
||||
#include "foundation/PxTime.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxUnionCast.h"
|
||||
#include "foundation/PxUserAllocated.h"
|
||||
#include "foundation/PxUtilities.h"
|
||||
#include "foundation/PxVec2.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxVec4.h"
|
||||
#include "foundation/PxVecMath.h"
|
||||
#include "foundation/PxVecQuat.h"
|
||||
#include "foundation/PxVecTransform.h"
|
||||
|
||||
|
||||
//Not physics specific utilities and common code
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
#include "common/PxRenderBuffer.h"
|
||||
#include "common/PxBase.h"
|
||||
#include "common/PxTolerancesScale.h"
|
||||
#include "common/PxTypeInfo.h"
|
||||
#include "common/PxStringTable.h"
|
||||
#include "common/PxSerializer.h"
|
||||
#include "common/PxMetaData.h"
|
||||
#include "common/PxMetaDataFlags.h"
|
||||
#include "common/PxSerialFramework.h"
|
||||
#include "common/PxInsertionCallback.h"
|
||||
|
||||
//Task Manager
|
||||
#include "task/PxTask.h"
|
||||
|
||||
// Cuda Mananger
|
||||
#if PX_SUPPORT_GPU_PHYSX
|
||||
#include "gpu/PxGpu.h"
|
||||
#endif
|
||||
|
||||
//Geometry Library
|
||||
#include "geometry/PxBoxGeometry.h"
|
||||
#include "geometry/PxBVH.h"
|
||||
#include "geometry/PxBVHBuildStrategy.h"
|
||||
#include "geometry/PxCapsuleGeometry.h"
|
||||
#include "geometry/PxConvexMesh.h"
|
||||
#include "geometry/PxConvexMeshGeometry.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "geometry/PxGeometryHelpers.h"
|
||||
#include "geometry/PxGeometryQuery.h"
|
||||
#include "geometry/PxHeightField.h"
|
||||
#include "geometry/PxHeightFieldDesc.h"
|
||||
#include "geometry/PxHeightFieldFlag.h"
|
||||
#include "geometry/PxHeightFieldGeometry.h"
|
||||
#include "geometry/PxHeightFieldSample.h"
|
||||
#include "geometry/PxMeshQuery.h"
|
||||
#include "geometry/PxMeshScale.h"
|
||||
#include "geometry/PxPlaneGeometry.h"
|
||||
#include "geometry/PxSimpleTriangleMesh.h"
|
||||
#include "geometry/PxSphereGeometry.h"
|
||||
#include "geometry/PxTriangle.h"
|
||||
#include "geometry/PxTriangleMesh.h"
|
||||
#include "geometry/PxTriangleMeshGeometry.h"
|
||||
#include "geometry/PxTetrahedron.h"
|
||||
#include "geometry/PxTetrahedronMesh.h"
|
||||
#include "geometry/PxTetrahedronMeshGeometry.h"
|
||||
|
||||
// PhysX Core SDK
|
||||
#include "PxActor.h"
|
||||
#include "PxAggregate.h"
|
||||
#include "PxArticulationReducedCoordinate.h"
|
||||
#include "PxArticulationJointReducedCoordinate.h"
|
||||
#include "PxArticulationLink.h"
|
||||
#include "PxClient.h"
|
||||
#include "PxConeLimitedConstraint.h"
|
||||
#include "PxConstraint.h"
|
||||
#include "PxConstraintDesc.h"
|
||||
#include "PxContact.h"
|
||||
#include "PxContactModifyCallback.h"
|
||||
#include "PxDeletionListener.h"
|
||||
#include "PxFEMSoftBodyMaterial.h"
|
||||
#include "PxFiltering.h"
|
||||
#include "PxForceMode.h"
|
||||
#include "PxLockedData.h"
|
||||
#include "PxMaterial.h"
|
||||
#include "PxParticleBuffer.h"
|
||||
#include "PxParticleSystem.h"
|
||||
#include "PxPBDParticleSystem.h"
|
||||
#include "PxPBDMaterial.h"
|
||||
#include "PxPhysics.h"
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxQueryFiltering.h"
|
||||
#include "PxQueryReport.h"
|
||||
#include "PxRigidActor.h"
|
||||
#include "PxRigidBody.h"
|
||||
#include "PxRigidDynamic.h"
|
||||
#include "PxRigidStatic.h"
|
||||
#include "PxScene.h"
|
||||
#include "PxSceneDesc.h"
|
||||
#include "PxSceneLock.h"
|
||||
#include "PxShape.h"
|
||||
#include "PxSimulationEventCallback.h"
|
||||
#include "PxSimulationStatistics.h"
|
||||
#include "PxSoftBody.h"
|
||||
#include "PxVisualizationParameter.h"
|
||||
#include "PxPruningStructure.h"
|
||||
#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
|
||||
#include "PxCustomParticleSystem.h"
|
||||
#include "PxFEMCloth.h"
|
||||
#include "PxFEMClothMaterial.h"
|
||||
#include "PxFLIPParticleSystem.h"
|
||||
#include "PxFLIPMaterial.h"
|
||||
#include "PxHairSystem.h"
|
||||
#include "PxMPMMaterial.h"
|
||||
#include "PxMPMParticleSystem.h"
|
||||
#endif
|
||||
|
||||
//Character Controller
|
||||
#include "characterkinematic/PxBoxController.h"
|
||||
#include "characterkinematic/PxCapsuleController.h"
|
||||
#include "characterkinematic/PxController.h"
|
||||
#include "characterkinematic/PxControllerBehavior.h"
|
||||
#include "characterkinematic/PxControllerManager.h"
|
||||
#include "characterkinematic/PxControllerObstacles.h"
|
||||
#include "characterkinematic/PxExtended.h"
|
||||
|
||||
//Cooking (data preprocessing)
|
||||
#include "cooking/Pxc.h"
|
||||
#include "cooking/PxConvexMeshDesc.h"
|
||||
#include "cooking/PxCooking.h"
|
||||
#include "cooking/PxTriangleMeshDesc.h"
|
||||
#include "cooking/PxBVH33MidphaseDesc.h"
|
||||
#include "cooking/PxBVH34MidphaseDesc.h"
|
||||
#include "cooking/PxMidphaseDesc.h"
|
||||
|
||||
//Extensions to the SDK
|
||||
#include "extensions/PxDefaultStreams.h"
|
||||
#include "extensions/PxExtensionsAPI.h"
|
||||
|
||||
//Serialization
|
||||
#include "extensions/PxSerialization.h"
|
||||
#include "extensions/PxBinaryConverter.h"
|
||||
#include "extensions/PxRepXSerializer.h"
|
||||
|
||||
//Vehicle Simulation
|
||||
#include "vehicle2/PxVehicleAPI.h"
|
||||
#include "vehicle/PxVehicleComponents.h"
|
||||
#include "vehicle/PxVehicleDrive.h"
|
||||
#include "vehicle/PxVehicleDrive4W.h"
|
||||
#include "vehicle/PxVehicleDriveTank.h"
|
||||
#include "vehicle/PxVehicleSDK.h"
|
||||
#include "vehicle/PxVehicleShaders.h"
|
||||
#include "vehicle/PxVehicleTireFriction.h"
|
||||
#include "vehicle/PxVehicleUpdate.h"
|
||||
#include "vehicle/PxVehicleUtil.h"
|
||||
#include "vehicle/PxVehicleUtilControl.h"
|
||||
#include "vehicle/PxVehicleUtilSetup.h"
|
||||
#include "vehicle/PxVehicleUtilTelemetry.h"
|
||||
#include "vehicle/PxVehicleWheels.h"
|
||||
#include "vehicle/PxVehicleNoDrive.h"
|
||||
#include "vehicle/PxVehicleDriveNW.h"
|
||||
|
||||
//Connecting the SDK to Visual Debugger
|
||||
#include "pvd/PxPvdSceneClient.h"
|
||||
#include "pvd/PxPvd.h"
|
||||
#include "pvd/PxPvdTransport.h"
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PHYSICS_SERIALIZATION_H
|
||||
#define PX_PHYSICS_SERIALIZATION_H
|
||||
|
||||
#include "common/PxSerialFramework.h"
|
||||
#include "PxPhysXConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
/**
|
||||
\brief Retrieves the PhysX SDK metadata.
|
||||
|
||||
\deprecated Binary conversion and binary meta data are deprecated.
|
||||
|
||||
This function is used to implement PxSerialization.dumpBinaryMetaData() and is not intended to be needed otherwise.
|
||||
@see PxSerialization.dumpBinaryMetaData()
|
||||
*/
|
||||
PX_DEPRECATED PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxGetPhysicsBinaryMetaData(physx::PxOutputStream& stream);
|
||||
|
||||
/**
|
||||
\brief Registers physics classes for serialization.
|
||||
This function is used to implement PxSerialization.createSerializationRegistry() and is not intended to be needed otherwise.
|
||||
@see PxSerializationRegistry
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterPhysicsSerializers(physx::PxSerializationRegistry& sr);
|
||||
|
||||
/**
|
||||
\brief Unregisters physics classes for serialization.
|
||||
This function is used in the release implementation of PxSerializationRegistry and in not intended to be used otherwise.
|
||||
@see PxSerializationRegistry
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxUnregisterPhysicsSerializers(physx::PxSerializationRegistry& sr);
|
||||
|
||||
|
||||
/**
|
||||
\brief Adds collected objects to PxPhysics.
|
||||
|
||||
This function adds all objects contained in the input collection to the PxPhysics instance. This is used after deserializing
|
||||
the collection, to populate the physics with inplace deserialized objects. This function is used in the implementation of
|
||||
PxSerialization.createCollectionFromBinary and is not intended to be needed otherwise.
|
||||
\param[in] collection Objects to add to the PxPhysics instance.
|
||||
|
||||
@see PxCollection, PxSerialization.createCollectionFromBinary
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxAddCollectionToPhysics(const physx::PxCollection& collection);
|
||||
|
||||
#endif // !PX_DOXYGEN
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_PRUNING_STRUCTURE_H
|
||||
#define PX_PRUNING_STRUCTURE_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief A precomputed pruning structure to accelerate scene queries against newly added actors.
|
||||
|
||||
The pruning structure can be provided to #PxScene:: addActors() in which case it will get merged
|
||||
directly into the scene query optimization AABB tree, thus leading to improved performance when
|
||||
doing queries against the newly added actors. This applies to both static and dynamic actors.
|
||||
|
||||
\note PxPruningStructure objects can be added to a collection and get serialized.
|
||||
\note Adding a PxPruningStructure object to a collection will also add the actors that were used to build the pruning structure.
|
||||
|
||||
\note PxPruningStructure must be released before its rigid actors.
|
||||
\note PxRigidBody objects can be in one PxPruningStructure only.
|
||||
\note Changing the bounds of PxRigidBody objects assigned to a pruning structure that has not been added to a scene yet will
|
||||
invalidate the pruning structure. Same happens if shape scene query flags change or shape gets removed from an actor.
|
||||
|
||||
@see PxScene::addActors PxCollection
|
||||
*/
|
||||
class PxPruningStructure : public PxBase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Release this object.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve rigid actors in the pruning structure.
|
||||
|
||||
You can retrieve the number of rigid actor pointers by calling #getNbRigidActors()
|
||||
|
||||
\param[out] userBuffer The buffer to store the actor pointers.
|
||||
\param[in] bufferSize Size of provided user buffer.
|
||||
\param[in] startIndex Index of first actor pointer to be retrieved
|
||||
\return Number of rigid actor pointers written to the buffer.
|
||||
|
||||
@see PxRigidActor
|
||||
*/
|
||||
virtual PxU32 getRigidActors(PxRigidActor** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of rigid actors in the pruning structure.
|
||||
|
||||
You can use #getRigidActors() to retrieve the rigid actor pointers.
|
||||
|
||||
\return Number of rigid actors in the pruning structure.
|
||||
|
||||
@see PxRigidActor
|
||||
*/
|
||||
virtual PxU32 getNbRigidActors() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the merge data for static actors
|
||||
|
||||
This is mainly called by the PxSceneQuerySystem::merge() function to merge a PxPruningStructure
|
||||
with the internal data-structures of the scene-query system.
|
||||
|
||||
\return Implementation-dependent merge data for static actors.
|
||||
|
||||
@see PxSceneQuerySystem::merge()
|
||||
*/
|
||||
virtual const void* getStaticMergeData() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the merge data for dynamic actors
|
||||
|
||||
This is mainly called by the PxSceneQuerySystem::merge() function to merge a PxPruningStructure
|
||||
with the internal data-structures of the scene-query system.
|
||||
|
||||
\return Implementation-dependent merge data for dynamic actors.
|
||||
|
||||
@see PxSceneQuerySystem::merge()
|
||||
*/
|
||||
virtual const void* getDynamicMergeData() const = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxPruningStructure"; }
|
||||
protected:
|
||||
PX_INLINE PxPruningStructure(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
|
||||
PX_INLINE PxPruningStructure(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
virtual ~PxPruningStructure() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxPruningStructure", name) || PxBase::isKindOf(name); }
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_QUERY_FILTERING_H
|
||||
#define PX_QUERY_FILTERING_H
|
||||
/** \addtogroup scenequery
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxFiltering.h"
|
||||
#include "PxQueryReport.h"
|
||||
#include "PxClient.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxShape;
|
||||
class PxRigidActor;
|
||||
struct PxQueryHit;
|
||||
|
||||
/**
|
||||
\brief Filtering flags for scene queries.
|
||||
|
||||
@see PxQueryFilterData.flags
|
||||
*/
|
||||
struct PxQueryFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eSTATIC = (1<<0), //!< Traverse static shapes
|
||||
|
||||
eDYNAMIC = (1<<1), //!< Traverse dynamic shapes
|
||||
|
||||
ePREFILTER = (1<<2), //!< Run the pre-intersection-test filter (see #PxQueryFilterCallback::preFilter())
|
||||
|
||||
ePOSTFILTER = (1<<3), //!< Run the post-intersection-test filter (see #PxQueryFilterCallback::postFilter())
|
||||
|
||||
eANY_HIT = (1<<4), //!< Abort traversal as soon as any hit is found and return it via callback.block.
|
||||
//!< Helps query performance. Both eTOUCH and eBLOCK hitTypes are considered hits with this flag.
|
||||
|
||||
eNO_BLOCK = (1<<5), //!< All hits are reported as touching. Overrides eBLOCK returned from user filters with eTOUCH.
|
||||
//!< This is also an optimization hint that may improve query performance.
|
||||
|
||||
eBATCH_QUERY_LEGACY_BEHAVIOUR PX_DEPRECATED = (1<<6), //!< Run with legacy batch query filter behavior. Raising this flag ensures that
|
||||
//!< the hardcoded filter equation is neglected. This guarantees that any provided PxQueryFilterCallback
|
||||
//!< will be utilised, as specified by the ePREFILTER and ePOSTFILTER flags.
|
||||
|
||||
eDISABLE_HARDCODED_FILTER = (1<<6), //!< Same as eBATCH_QUERY_LEGACY_BEHAVIOUR, more explicit name making it clearer that this can also be used
|
||||
//!< with regular/non-batched queries if needed.
|
||||
|
||||
eRESERVED = (1<<15) //!< Reserved for internal use
|
||||
};
|
||||
};
|
||||
PX_COMPILE_TIME_ASSERT(PxQueryFlag::eSTATIC==(1<<0));
|
||||
PX_COMPILE_TIME_ASSERT(PxQueryFlag::eDYNAMIC==(1<<1));
|
||||
PX_COMPILE_TIME_ASSERT(PxQueryFlag::eBATCH_QUERY_LEGACY_BEHAVIOUR==PxQueryFlag::eDISABLE_HARDCODED_FILTER);
|
||||
|
||||
/**
|
||||
\brief Flags typedef for the set of bits defined in PxQueryFlag.
|
||||
|
||||
*/
|
||||
typedef PxFlags<PxQueryFlag::Enum,PxU16> PxQueryFlags;
|
||||
PX_FLAGS_OPERATORS(PxQueryFlag::Enum,PxU16)
|
||||
|
||||
/**
|
||||
\brief Classification of scene query hits (intersections).
|
||||
|
||||
- eNONE: Returning this hit type means that the hit should not be reported.
|
||||
- eBLOCK: For all raycast, sweep and overlap queries the nearest eBLOCK type hit will always be returned in PxHitCallback::block member.
|
||||
- eTOUCH: Whenever a raycast, sweep or overlap query was called with non-zero PxHitCallback::nbTouches and PxHitCallback::touches
|
||||
parameters, eTOUCH type hits that are closer or same distance (touchDistance <= blockDistance condition)
|
||||
as the globally nearest eBLOCK type hit, will be reported.
|
||||
- For example, to record all hits from a raycast query, always return eTOUCH.
|
||||
|
||||
All hits in overlap() queries are treated as if the intersection distance were zero.
|
||||
This means the hits are unsorted and all eTOUCH hits are recorded by the callback even if an eBLOCK overlap hit was encountered.
|
||||
Even though all overlap() blocking hits have zero length, only one (arbitrary) eBLOCK overlap hit is recorded in PxHitCallback::block.
|
||||
All overlap() eTOUCH type hits are reported (zero touchDistance <= zero blockDistance condition).
|
||||
|
||||
For raycast/sweep/overlap calls with zero touch buffer or PxHitCallback::nbTouches member,
|
||||
only the closest hit of type eBLOCK is returned. All eTOUCH hits are discarded.
|
||||
|
||||
@see PxQueryFilterCallback.preFilter PxQueryFilterCallback.postFilter PxScene.raycast PxScene.sweep PxScene.overlap
|
||||
*/
|
||||
struct PxQueryHitType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE = 0, //!< the query should ignore this shape
|
||||
eTOUCH = 1, //!< a hit on the shape touches the intersection geometry of the query but does not block it
|
||||
eBLOCK = 2 //!< a hit on the shape blocks the query (does not block overlap queries)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Scene query filtering data.
|
||||
|
||||
Whenever the scene query intersects a shape, filtering is performed in the following order:
|
||||
|
||||
\li For non-batched queries only:<br>If the data field is non-zero, and the bitwise-AND value of data AND the shape's
|
||||
queryFilterData is zero, the shape is skipped
|
||||
\li If filter callbacks are enabled in flags field (see #PxQueryFlags) they will get invoked accordingly.
|
||||
\li If neither #PxQueryFlag::ePREFILTER or #PxQueryFlag::ePOSTFILTER is set, the hit defaults
|
||||
to type #PxQueryHitType::eBLOCK when the value of PxHitCallback::nbTouches provided with the query is zero and to type
|
||||
#PxQueryHitType::eTOUCH when PxHitCallback::nbTouches is positive.
|
||||
|
||||
@see PxScene.raycast PxScene.sweep PxScene.overlap PxQueryFlag::eANY_HIT
|
||||
*/
|
||||
struct PxQueryFilterData
|
||||
{
|
||||
/** \brief default constructor */
|
||||
explicit PX_INLINE PxQueryFilterData() : flags(PxQueryFlag::eDYNAMIC | PxQueryFlag::eSTATIC) {}
|
||||
|
||||
/** \brief constructor to set both filter data and filter flags */
|
||||
explicit PX_INLINE PxQueryFilterData(const PxFilterData& fd, PxQueryFlags f) : data(fd), flags(f) {}
|
||||
|
||||
/** \brief constructor to set filter flags only */
|
||||
explicit PX_INLINE PxQueryFilterData(PxQueryFlags f) : flags(f) {}
|
||||
|
||||
PxFilterData data; //!< Filter data associated with the scene query
|
||||
PxQueryFlags flags; //!< Filter flags (see #PxQueryFlags)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Scene query filtering callbacks.
|
||||
|
||||
Custom filtering logic for scene query intersection candidates. If an intersection candidate object passes the data based filter
|
||||
(see #PxQueryFilterData), filtering callbacks are executed if requested (see #PxQueryFilterData.flags)
|
||||
|
||||
\li If #PxQueryFlag::ePREFILTER is set, the preFilter function runs before exact intersection tests.
|
||||
If this function returns #PxQueryHitType::eTOUCH or #PxQueryHitType::eBLOCK, exact testing is performed to
|
||||
determine the intersection location.
|
||||
|
||||
The preFilter function may overwrite the copy of queryFlags it receives as an argument to specify any of #PxHitFlag::eMODIFIABLE_FLAGS
|
||||
on a per-shape basis. Changes apply only to the shape being filtered, and changes to other flags are ignored.
|
||||
|
||||
\li If #PxQueryFlag::ePREFILTER is not set, precise intersection testing is performed using the original query's filterData.flags.
|
||||
|
||||
\li If #PxQueryFlag::ePOSTFILTER is set, the postFilter function is called for each intersection to determine the touch/block status.
|
||||
This overrides any touch/block status previously returned from the preFilter function for this shape.
|
||||
|
||||
Filtering calls are not guaranteed to be sorted along the ray or sweep direction.
|
||||
|
||||
@see PxScene.raycast PxScene.sweep PxScene.overlap PxQueryFlags PxHitFlags
|
||||
*/
|
||||
class PxQueryFilterCallback
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief This filter callback is executed before the exact intersection test if PxQueryFlag::ePREFILTER flag was set.
|
||||
|
||||
\param[in] filterData custom filter data specified as the query's filterData.data parameter.
|
||||
\param[in] shape A shape that has not yet passed the exact intersection test.
|
||||
\param[in] actor The shape's actor.
|
||||
\param[in,out] queryFlags scene query flags from the query's function call (only flags from PxHitFlag::eMODIFIABLE_FLAGS bitmask can be modified)
|
||||
\return the updated type for this hit (see #PxQueryHitType)
|
||||
*/
|
||||
virtual PxQueryHitType::Enum preFilter(
|
||||
const PxFilterData& filterData, const PxShape* shape, const PxRigidActor* actor, PxHitFlags& queryFlags) = 0;
|
||||
|
||||
/**
|
||||
\brief This filter callback is executed if the exact intersection test returned true and PxQueryFlag::ePOSTFILTER flag was set.
|
||||
|
||||
\param[in] filterData custom filter data of the query
|
||||
\param[in] hit Scene query hit information. faceIndex member is not valid for overlap queries. For sweep and raycast queries the hit information can be cast to #PxSweepHit and #PxRaycastHit respectively.
|
||||
\return the updated hit type for this hit (see #PxQueryHitType)
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED virtual PxQueryHitType::Enum postFilter(const PxFilterData& filterData, const PxQueryHit& hit)
|
||||
{
|
||||
PX_UNUSED(filterData);
|
||||
PX_UNUSED(hit);
|
||||
return PxQueryHitType::eBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief This filter callback is executed if the exact intersection test returned true and PxQueryFlag::ePOSTFILTER flag was set.
|
||||
|
||||
\param[in] filterData custom filter data of the query
|
||||
\param[in] hit Scene query hit information. faceIndex member is not valid for overlap queries. For sweep and raycast queries the hit information can be cast to #PxSweepHit and #PxRaycastHit respectively.
|
||||
\param[in] shape Hit shape
|
||||
\param[in] actor Hit actor
|
||||
\return the updated hit type for this hit (see #PxQueryHitType)
|
||||
*/
|
||||
virtual PxQueryHitType::Enum postFilter(const PxFilterData& filterData, const PxQueryHit& hit, const PxShape* shape, const PxRigidActor* actor)
|
||||
{
|
||||
PX_UNUSED(shape);
|
||||
PX_UNUSED(actor);
|
||||
return postFilter(filterData, hit);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief virtual destructor
|
||||
*/
|
||||
virtual ~PxQueryFilterCallback() {}
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,285 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_QUERY_REPORT_H
|
||||
#define PX_QUERY_REPORT_H
|
||||
/** \addtogroup scenequery
|
||||
@{
|
||||
*/
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "geometry/PxGeometryHit.h"
|
||||
#include "geometry/PxGeometryQueryContext.h"
|
||||
#include "PxPhysXConfig.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxShape;
|
||||
class PxRigidActor;
|
||||
|
||||
/**
|
||||
\brief Combines a shape pointer and the actor the shape belongs to into one memory location.
|
||||
|
||||
Serves as a base class for PxQueryHit.
|
||||
|
||||
@see PxQueryHit
|
||||
*/
|
||||
struct PxActorShape
|
||||
{
|
||||
PX_INLINE PxActorShape() : actor(NULL), shape(NULL) {}
|
||||
PX_INLINE PxActorShape(PxRigidActor* a, PxShape* s) : actor(a), shape(s) {}
|
||||
|
||||
PxRigidActor* actor;
|
||||
PxShape* shape;
|
||||
};
|
||||
|
||||
// Extends geom hits with Px object pointers
|
||||
struct PxRaycastHit : PxGeomRaycastHit, PxActorShape {};
|
||||
struct PxOverlapHit : PxGeomOverlapHit, PxActorShape {};
|
||||
struct PxSweepHit : PxGeomSweepHit, PxActorShape {};
|
||||
|
||||
/**
|
||||
\brief Describes query behavior after returning a partial query result via a callback.
|
||||
|
||||
If callback returns true, traversal will continue and callback can be issued again.
|
||||
If callback returns false, traversal will stop, callback will not be issued again.
|
||||
|
||||
@see PxHitCallback
|
||||
*/
|
||||
typedef bool PxAgain;
|
||||
|
||||
/**
|
||||
\brief This callback class facilitates reporting scene query hits (intersections) to the user.
|
||||
|
||||
User overrides the virtual processTouches function to receive hits in (possibly multiple) fixed size blocks.
|
||||
|
||||
\note PxHitBuffer derives from this class and is used to receive touching hits in a fixed size buffer.
|
||||
\note Since the compiler doesn't look in template dependent base classes when looking for non-dependent names
|
||||
\note with some compilers it will be necessary to use "this->hasBlock" notation to access a parent variable
|
||||
\note in a child callback class.
|
||||
\note Pre-made typedef shorthands, such as ::PxRaycastCallback can be used for raycast, overlap and sweep queries.
|
||||
|
||||
@see PxHitBuffer PxRaycastHit PxSweepHit PxOverlapHit PxRaycastCallback PxOverlapCallback PxSweepCallback
|
||||
*/
|
||||
template<typename HitType>
|
||||
struct PxHitCallback : PxQueryThreadContext
|
||||
{
|
||||
HitType block; //!< Holds the closest blocking hit result for the query. Invalid if hasBlock is false.
|
||||
bool hasBlock; //!< Set to true if there was a blocking hit during query.
|
||||
|
||||
HitType* touches; //!< User specified buffer for touching hits.
|
||||
|
||||
/**
|
||||
\brief Size of the user specified touching hits buffer.
|
||||
\note If set to 0 all hits will default to PxQueryHitType::eBLOCK, otherwise to PxQueryHitType::eTOUCH
|
||||
\note Hit type returned from pre-filter overrides this default */
|
||||
PxU32 maxNbTouches;
|
||||
|
||||
/**
|
||||
\brief Number of touching hits returned by the query. Used with PxHitBuffer.
|
||||
\note If true (PxAgain) is returned from the callback, nbTouches will be reset to 0. */
|
||||
PxU32 nbTouches;
|
||||
|
||||
/**
|
||||
\brief Initializes the class with user provided buffer.
|
||||
|
||||
\param[in] aTouches Optional buffer for recording PxQueryHitType::eTOUCH type hits.
|
||||
\param[in] aMaxNbTouches Size of touch buffer.
|
||||
|
||||
\note if aTouches is NULL and aMaxNbTouches is 0, only the closest blocking hit will be recorded by the query.
|
||||
\note If PxQueryFlag::eANY_HIT flag is used as a query parameter, hasBlock will be set to true and blockingHit will be used to receive the result.
|
||||
\note Both eTOUCH and eBLOCK hits will be registered as hasBlock=true and stored in PxHitCallback.block when eANY_HIT flag is used.
|
||||
|
||||
@see PxHitCallback.hasBlock PxHitCallback.block */
|
||||
PxHitCallback(HitType* aTouches, PxU32 aMaxNbTouches)
|
||||
: hasBlock(false), touches(aTouches), maxNbTouches(aMaxNbTouches), nbTouches(0)
|
||||
{}
|
||||
|
||||
/**
|
||||
\brief virtual callback function used to communicate query results to the user.
|
||||
|
||||
This callback will always be invoked with #touches as a buffer if #touches was specified as non-NULL.
|
||||
All reported touch hits are guaranteed to be closer than the closest blocking hit.
|
||||
|
||||
\param[in] buffer Callback will report touch hits to the user in this buffer. This pointer will be the same as #touches.
|
||||
\param[in] nbHits Number of touch hits reported in buffer. This number will not exceed #maxNbTouches.
|
||||
|
||||
\note There is a significant performance penalty in case multiple touch callbacks are issued (up to 2x)
|
||||
\note to avoid the penalty use a bigger buffer so that all touching hits can be reported in a single buffer.
|
||||
\note If true (again) is returned from the callback, nbTouches will be reset to 0,
|
||||
\note If false is returned, nbTouched will remain unchanged.
|
||||
\note By the time processTouches is first called, the globally closest blocking hit is already determined,
|
||||
\note values of hasBlock and block are final and all touch hits are guaranteed to be closer than the blocking hit.
|
||||
\note touches and maxNbTouches can be modified inside of processTouches callback.
|
||||
|
||||
\return true to continue receiving callbacks in case there are more hits or false to stop.
|
||||
|
||||
@see PxAgain PxRaycastHit PxSweepHit PxOverlapHit */
|
||||
virtual PxAgain processTouches(const HitType* buffer, PxU32 nbHits) = 0;
|
||||
|
||||
virtual void finalizeQuery() {} //!< Query finalization callback, called after the last processTouches callback.
|
||||
|
||||
virtual ~PxHitCallback() {}
|
||||
|
||||
/** \brief Returns true if any blocking or touching hits were encountered during a query. */
|
||||
PX_FORCE_INLINE bool hasAnyHits() { return (hasBlock || (nbTouches > 0)); }
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Returns scene query hits (intersections) to the user in a preallocated buffer.
|
||||
|
||||
Will clip touch hits to maximum buffer capacity. When clipped, an arbitrary subset of touching hits will be discarded.
|
||||
Overflow does not trigger warnings or errors. block and hasBlock will be valid in finalizeQuery callback and after query completion.
|
||||
Touching hits are guaranteed to have closer or same distance ( <= condition) as the globally nearest blocking hit at the time any processTouches()
|
||||
callback is issued.
|
||||
|
||||
\note Pre-made typedef shorthands, such as ::PxRaycastBuffer can be used for raycast, overlap and sweep queries.
|
||||
|
||||
@see PxHitCallback
|
||||
@see PxRaycastBuffer PxOverlapBuffer PxSweepBuffer PxRaycastBufferN PxOverlapBufferN PxSweepBufferN
|
||||
*/
|
||||
template<typename HitType>
|
||||
struct PxHitBuffer : public PxHitCallback<HitType>
|
||||
{
|
||||
/**
|
||||
\brief Initializes the buffer with user memory.
|
||||
|
||||
The buffer is initialized with 0 touch hits by default => query will only report a single closest blocking hit.
|
||||
Use PxQueryFlag::eANY_HIT to tell the query to abort and return any first hit encoutered as blocking.
|
||||
|
||||
\param[in] aTouches Optional buffer for recording PxQueryHitType::eTOUCH type hits.
|
||||
\param[in] aMaxNbTouches Size of touch buffer.
|
||||
|
||||
@see PxHitCallback */
|
||||
PxHitBuffer(HitType* aTouches = NULL, PxU32 aMaxNbTouches = 0) : PxHitCallback<HitType>(aTouches, aMaxNbTouches) {}
|
||||
|
||||
/** \brief Computes the number of any hits in this result, blocking or touching. */
|
||||
PX_INLINE PxU32 getNbAnyHits() const { return getNbTouches() + PxU32(this->hasBlock); }
|
||||
/** \brief Convenience iterator used to access any hits in this result, blocking or touching. */
|
||||
PX_INLINE const HitType& getAnyHit(const PxU32 index) const { PX_ASSERT(index < getNbTouches() + PxU32(this->hasBlock));
|
||||
return index < getNbTouches() ? getTouches()[index] : this->block; }
|
||||
|
||||
PX_INLINE PxU32 getNbTouches() const { return this->nbTouches; }
|
||||
PX_INLINE const HitType* getTouches() const { return this->touches; }
|
||||
PX_INLINE const HitType& getTouch(const PxU32 index) const { PX_ASSERT(index < getNbTouches()); return getTouches()[index]; }
|
||||
PX_INLINE PxU32 getMaxNbTouches() const { return this->maxNbTouches; }
|
||||
|
||||
virtual ~PxHitBuffer() {}
|
||||
|
||||
protected:
|
||||
// stops after the first callback
|
||||
virtual PxAgain processTouches(const HitType* buffer, PxU32 nbHits) { PX_UNUSED(buffer); PX_UNUSED(nbHits); return false; }
|
||||
};
|
||||
|
||||
/** \brief Raycast query callback. */
|
||||
typedef PxHitCallback<PxRaycastHit> PxRaycastCallback;
|
||||
|
||||
/** \brief Overlap query callback. */
|
||||
typedef PxHitCallback<PxOverlapHit> PxOverlapCallback;
|
||||
|
||||
/** \brief Sweep query callback. */
|
||||
typedef PxHitCallback<PxSweepHit> PxSweepCallback;
|
||||
|
||||
/** \brief Raycast query buffer. */
|
||||
typedef PxHitBuffer<PxRaycastHit> PxRaycastBuffer;
|
||||
|
||||
/** \brief Overlap query buffer. */
|
||||
typedef PxHitBuffer<PxOverlapHit> PxOverlapBuffer;
|
||||
|
||||
/** \brief Sweep query buffer. */
|
||||
typedef PxHitBuffer<PxSweepHit> PxSweepBuffer;
|
||||
|
||||
/** \brief Returns touching raycast hits to the user in a fixed size array embedded in the buffer class. **/
|
||||
template <int N>
|
||||
struct PxRaycastBufferN : public PxHitBuffer<PxRaycastHit>
|
||||
{
|
||||
PxRaycastHit hits[N];
|
||||
PxRaycastBufferN() : PxHitBuffer<PxRaycastHit>(hits, N) {}
|
||||
};
|
||||
|
||||
/** \brief Returns touching overlap hits to the user in a fixed size array embedded in the buffer class. **/
|
||||
template <int N>
|
||||
struct PxOverlapBufferN : public PxHitBuffer<PxOverlapHit>
|
||||
{
|
||||
PxOverlapHit hits[N];
|
||||
PxOverlapBufferN() : PxHitBuffer<PxOverlapHit>(hits, N) {}
|
||||
};
|
||||
|
||||
/** \brief Returns touching sweep hits to the user in a fixed size array embedded in the buffer class. **/
|
||||
template <int N>
|
||||
struct PxSweepBufferN : public PxHitBuffer<PxSweepHit>
|
||||
{
|
||||
PxSweepHit hits[N];
|
||||
PxSweepBufferN() : PxHitBuffer<PxSweepHit>(hits, N) {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief single hit cache for scene queries.
|
||||
|
||||
If a cache object is supplied to a scene query, the cached actor/shape pair is checked for intersection first.
|
||||
\note Filters are not executed for the cached shape.
|
||||
\note If intersection is found, the hit is treated as blocking.
|
||||
\note Typically actor and shape from the last PxHitCallback.block query result is used as a cached actor/shape pair.
|
||||
\note Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\note Cache is only used if no touch buffer was provided, for single nearest blocking hit queries and queries using eANY_HIT flag.
|
||||
\note if non-zero touch buffer was provided, cache will be ignored
|
||||
|
||||
\note It is the user's responsibility to ensure that the shape and actor are valid, so care must be taken
|
||||
when deleting shapes to invalidate cached references.
|
||||
|
||||
The faceIndex field is an additional hint for a mesh or height field which is not currently used.
|
||||
|
||||
@see PxScene.raycast
|
||||
*/
|
||||
struct PxQueryCache
|
||||
{
|
||||
/**
|
||||
\brief constructor sets to default
|
||||
*/
|
||||
PX_INLINE PxQueryCache() : shape(NULL), actor(NULL), faceIndex(0xffffffff) {}
|
||||
|
||||
/**
|
||||
\brief constructor to set properties
|
||||
*/
|
||||
PX_INLINE PxQueryCache(PxShape* s, PxU32 findex) : shape(s), actor(NULL), faceIndex(findex) {}
|
||||
|
||||
PxShape* shape; //!< Shape to test for intersection first
|
||||
PxRigidActor* actor; //!< Actor to which the shape belongs
|
||||
PxU32 faceIndex; //!< Triangle index to test first - NOT CURRENTLY SUPPORTED
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
235
modules/PhysX/physx/physx-sys/physx/physx/include/PxRigidActor.h
Normal file
235
modules/PhysX/physx/physx-sys/physx/physx/include/PxRigidActor.h
Normal file
@@ -0,0 +1,235 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_RIGID_ACTOR_H
|
||||
#define PX_RIGID_ACTOR_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxActor.h"
|
||||
#include "PxShape.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxConstraint;
|
||||
|
||||
/**
|
||||
\brief PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SDK.
|
||||
|
||||
PxRigidActor objects specify the geometry of the object by defining a set of attached shapes (see #PxShape).
|
||||
|
||||
@see PxActor
|
||||
*/
|
||||
class PxRigidActor : public PxActor
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Deletes the rigid actor object.
|
||||
|
||||
Also releases any shapes associated with the actor.
|
||||
|
||||
Releasing an actor will affect any objects that are connected to the actor (constraint shaders like joints etc.).
|
||||
Such connected objects will be deleted upon scene deletion, or explicitly by the user by calling release()
|
||||
on these objects. It is recommended to always remove all objects that reference actors before the actors
|
||||
themselves are removed. It is not possible to retrieve list of dead connected objects.
|
||||
|
||||
<b>Sleeping:</b> This call will awaken any sleeping actors contacting the deleted actor (directly or indirectly).
|
||||
|
||||
Calls #PxActor::release() so you might want to check the documentation of that method as well.
|
||||
|
||||
@see PxActor::release()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the internal actor index.
|
||||
|
||||
\warning This is only defined for actors that have been added to a scene.
|
||||
|
||||
\return The internal actor index, or 0xffffffff if the actor is not part of a scene.
|
||||
*/
|
||||
virtual PxU32 getInternalActorIndex() const = 0;
|
||||
|
||||
/************************************************************************************************/
|
||||
/** @name Global Pose Manipulation
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Retrieves the actors world space transform.
|
||||
|
||||
The getGlobalPose() method retrieves the actor's current actor space to world space transformation.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running (except during PxScene::collide(),
|
||||
in PxContactModifyCallback or in contact report callbacks).
|
||||
|
||||
\return Global pose of object.
|
||||
|
||||
@see PxRigidDynamic.setGlobalPose() PxRigidStatic.setGlobalPose()
|
||||
*/
|
||||
virtual PxTransform getGlobalPose() const = 0;
|
||||
|
||||
/**
|
||||
\brief Method for setting an actor's pose in the world.
|
||||
|
||||
This method instantaneously changes the actor space to world space transformation.
|
||||
|
||||
This method is mainly for dynamic rigid bodies (see #PxRigidDynamic). Calling this method on static actors is
|
||||
likely to result in a performance penalty, since internal optimization structures for static actors may need to be
|
||||
recomputed. In addition, moving static actors will not interact correctly with dynamic actors or joints.
|
||||
|
||||
To directly control an actor's position and have it correctly interact with dynamic bodies and joints, create a dynamic
|
||||
body with the PxRigidBodyFlag::eKINEMATIC flag, then use the setKinematicTarget() commands to define its path.
|
||||
|
||||
Even when moving dynamic actors, exercise restraint in making use of this method. Where possible, avoid:
|
||||
|
||||
\li moving actors into other actors, thus causing overlap (an invalid physical state)
|
||||
|
||||
\li moving an actor that is connected by a joint to another away from the other (thus causing joint error)
|
||||
|
||||
<b>Sleeping:</b> This call wakes dynamic actors if they are sleeping and the autowake parameter is true (default).
|
||||
|
||||
\param[in] pose Transformation from the actors local frame to the global frame. <b>Range:</b> rigid body transform.
|
||||
\param[in] autowake whether to wake the object if it is dynamic. This parameter has no effect for static or kinematic actors. If true and the current wake counter value is smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
|
||||
|
||||
@see getGlobalPose()
|
||||
*/
|
||||
virtual void setGlobalPose(const PxTransform& pose, bool autowake = true) = 0;
|
||||
|
||||
/************************************************************************************************/
|
||||
/** @name Shapes
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Attach a shape to an actor
|
||||
|
||||
This call will increment the reference count of the shape.
|
||||
|
||||
\note Mass properties of dynamic rigid actors will not automatically be recomputed
|
||||
to reflect the new mass distribution implied by the shape. Follow this call with a call to
|
||||
the PhysX extensions method #PxRigidBodyExt::updateMassAndInertia() to do that.
|
||||
|
||||
Attaching a triangle mesh, heightfield or plane geometry shape configured as eSIMULATION_SHAPE is not supported for
|
||||
non-kinematic PxRigidDynamic instances.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
|
||||
|
||||
\param[in] shape the shape to attach.
|
||||
|
||||
\return True if success.
|
||||
*/
|
||||
virtual bool attachShape(PxShape& shape) = 0;
|
||||
|
||||
/**
|
||||
\brief Detach a shape from an actor.
|
||||
|
||||
This will also decrement the reference count of the PxShape, and if the reference count is zero, will cause it to be deleted.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
|
||||
|
||||
\param[in] shape the shape to detach.
|
||||
\param[in] wakeOnLostTouch Specifies whether touching objects from the previous frame should get woken up in the next frame. Only applies to PxArticulationReducedCoordinate and PxRigidActor types.
|
||||
*/
|
||||
virtual void detachShape(PxShape& shape, bool wakeOnLostTouch = true) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of shapes assigned to the actor.
|
||||
|
||||
You can use #getShapes() to retrieve the shape pointers.
|
||||
|
||||
\return Number of shapes associated with this actor.
|
||||
|
||||
@see PxShape getShapes()
|
||||
*/
|
||||
virtual PxU32 getNbShapes() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve all the shape pointers belonging to the actor.
|
||||
|
||||
These are the shapes used by the actor for collision detection.
|
||||
|
||||
You can retrieve the number of shape pointers by calling #getNbShapes()
|
||||
|
||||
Note: Removing shapes with #PxShape::release() will invalidate the pointer of the released shape.
|
||||
|
||||
\param[out] userBuffer The buffer to store the shape pointers.
|
||||
\param[in] bufferSize Size of provided user buffer.
|
||||
\param[in] startIndex Index of first shape pointer to be retrieved
|
||||
\return Number of shape pointers written to the buffer.
|
||||
|
||||
@see PxShape getNbShapes() PxShape::release()
|
||||
*/
|
||||
virtual PxU32 getShapes(PxShape** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
|
||||
|
||||
/************************************************************************************************/
|
||||
/** @name Constraints
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Returns the number of constraint shaders attached to the actor.
|
||||
|
||||
You can use #getConstraints() to retrieve the constraint shader pointers.
|
||||
|
||||
\return Number of constraint shaders attached to this actor.
|
||||
|
||||
@see PxConstraint getConstraints()
|
||||
*/
|
||||
virtual PxU32 getNbConstraints() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve all the constraint shader pointers belonging to the actor.
|
||||
|
||||
You can retrieve the number of constraint shader pointers by calling #getNbConstraints()
|
||||
|
||||
Note: Removing constraint shaders with #PxConstraint::release() will invalidate the pointer of the released constraint.
|
||||
|
||||
\param[out] userBuffer The buffer to store the constraint shader pointers.
|
||||
\param[in] bufferSize Size of provided user buffer.
|
||||
\param[in] startIndex Index of first constraint pointer to be retrieved
|
||||
\return Number of constraint shader pointers written to the buffer.
|
||||
|
||||
@see PxConstraint getNbConstraints() PxConstraint::release()
|
||||
*/
|
||||
virtual PxU32 getConstraints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxRigidActor(PxType concreteType, PxBaseFlags baseFlags) : PxActor(concreteType, baseFlags) {}
|
||||
PX_INLINE PxRigidActor(PxBaseFlags baseFlags) : PxActor(baseFlags) {}
|
||||
virtual ~PxRigidActor() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxRigidActor", name) || PxActor::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
710
modules/PhysX/physx/physx-sys/physx/physx/include/PxRigidBody.h
Normal file
710
modules/PhysX/physx/physx-sys/physx/physx/include/PxRigidBody.h
Normal file
@@ -0,0 +1,710 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_RIGID_BODY_H
|
||||
#define PX_RIGID_BODY_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxRigidActor.h"
|
||||
#include "PxForceMode.h"
|
||||
#include "PxNodeIndex.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Collection of flags describing the behavior of a rigid body.
|
||||
|
||||
@see PxRigidBody.setRigidBodyFlag(), PxRigidBody.getRigidBodyFlags()
|
||||
*/
|
||||
struct PxRigidBodyFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief Enables kinematic mode for the actor.
|
||||
|
||||
Kinematic actors are special dynamic actors that are not
|
||||
influenced by forces (such as gravity), and have no momentum. They are considered to have infinite
|
||||
mass and can be moved around the world using the setKinematicTarget() method. They will push
|
||||
regular dynamic actors out of the way. Kinematics will not collide with static or other kinematic objects.
|
||||
|
||||
Kinematic actors are great for moving platforms or characters, where direct motion control is desired.
|
||||
|
||||
You can not connect Reduced joints to kinematic actors. Lagrange joints work ok if the platform
|
||||
is moving with a relatively low, uniform velocity.
|
||||
|
||||
<b>Sleeping:</b>
|
||||
\li Setting this flag on a dynamic actor will put the actor to sleep and set the velocities to 0.
|
||||
\li If this flag gets cleared, the current sleep state of the actor will be kept.
|
||||
|
||||
\note kinematic actors are incompatible with CCD so raising this flag will automatically clear eENABLE_CCD
|
||||
|
||||
@see PxRigidDynamic.setKinematicTarget()
|
||||
*/
|
||||
eKINEMATIC = (1<<0), //!< Enable kinematic mode for the body.
|
||||
|
||||
/**
|
||||
\brief Use the kinematic target transform for scene queries.
|
||||
|
||||
If this flag is raised, then scene queries will treat the kinematic target transform as the current pose
|
||||
of the body (instead of using the actual pose). Without this flag, the kinematic target will only take
|
||||
effect with respect to scene queries after a simulation step.
|
||||
|
||||
@see PxRigidDynamic.setKinematicTarget()
|
||||
*/
|
||||
eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES = (1<<1),
|
||||
|
||||
/**
|
||||
\brief Enables swept integration for the actor.
|
||||
|
||||
If this flag is raised and CCD is enabled on the scene, then this body will be simulated by the CCD system to ensure that collisions are not missed due to
|
||||
high-speed motion. Note individual shape pairs still need to enable PxPairFlag::eDETECT_CCD_CONTACT in the collision filtering to enable the CCD to respond to
|
||||
individual interactions.
|
||||
|
||||
\note kinematic actors are incompatible with CCD so this flag will be cleared automatically when raised on a kinematic actor
|
||||
*/
|
||||
eENABLE_CCD = (1<<2), //!< Enable CCD for the body.
|
||||
|
||||
/**
|
||||
\brief Enabled CCD in swept integration for the actor.
|
||||
|
||||
If this flag is raised and CCD is enabled, CCD interactions will simulate friction. By default, friction is disabled in CCD interactions because
|
||||
CCD friction has been observed to introduce some simulation artifacts. CCD friction was enabled in previous versions of the SDK. Raising this flag will result in behavior
|
||||
that is a closer match for previous versions of the SDK.
|
||||
|
||||
\note This flag requires PxRigidBodyFlag::eENABLE_CCD to be raised to have any effect.
|
||||
*/
|
||||
eENABLE_CCD_FRICTION = (1<<3),
|
||||
|
||||
/**
|
||||
\brief Register a rigid body to dynamically adjust contact offset based on velocity. This can be used to achieve a CCD effect.
|
||||
|
||||
If both eENABLE_CCD and eENABLE_SPECULATIVE_CCD are set on the same body, then angular motions are handled by speculative
|
||||
contacts (eENABLE_SPECULATIVE_CCD) while linear motions are handled by sweeps (eENABLE_CCD).
|
||||
*/
|
||||
eENABLE_SPECULATIVE_CCD = (1<<4),
|
||||
|
||||
/**
|
||||
\brief Register a rigid body for reporting pose changes by the simulation at an early stage.
|
||||
|
||||
Sometimes it might be advantageous to get access to the new pose of a rigid body as early as possible and
|
||||
not wait until the call to fetchResults() returns. Setting this flag will schedule the rigid body to get reported
|
||||
in #PxSimulationEventCallback::onAdvance(). Please refer to the documentation of that callback to understand
|
||||
the behavior and limitations of this functionality.
|
||||
|
||||
@see PxSimulationEventCallback::onAdvance()
|
||||
*/
|
||||
eENABLE_POSE_INTEGRATION_PREVIEW = (1<<5),
|
||||
|
||||
/**
|
||||
\brief Permit CCD to limit maxContactImpulse. This is useful for use-cases like a destruction system but can cause visual artefacts so is not enabled by default.
|
||||
*/
|
||||
eENABLE_CCD_MAX_CONTACT_IMPULSE = (1<<6),
|
||||
|
||||
/**
|
||||
\brief Carries over forces/accelerations between frames, rather than clearing them
|
||||
*/
|
||||
eRETAIN_ACCELERATIONS = (1<<7),
|
||||
|
||||
/**
|
||||
\brief Forces kinematic-kinematic pairs notifications for this actor.
|
||||
|
||||
This flag overrides the global scene-level PxPairFilteringMode setting for kinematic actors.
|
||||
This is equivalent to having PxPairFilteringMode::eKEEP for pairs involving this actor.
|
||||
|
||||
A particular use case is when you have a large amount of kinematic actors, but you are only
|
||||
interested in interactions between a few of them. In this case it is best to use
|
||||
PxSceneDesc.kineKineFilteringMode = PxPairFilteringMode::eKILL, and then raise the
|
||||
eFORCE_KINE_KINE_NOTIFICATIONS flag on the small set of kinematic actors that need
|
||||
notifications.
|
||||
|
||||
\note This has no effect if PxRigidBodyFlag::eKINEMATIC is not set.
|
||||
|
||||
\warning Changing this flag at runtime will not have an effect until you remove and re-add the actor to the scene.
|
||||
|
||||
@see PxPairFilteringMode PxSceneDesc.kineKineFilteringMode
|
||||
*/
|
||||
eFORCE_KINE_KINE_NOTIFICATIONS = (1<<8),
|
||||
|
||||
/**
|
||||
\brief Forces static-kinematic pairs notifications for this actor.
|
||||
|
||||
Similar to eFORCE_KINE_KINE_NOTIFICATIONS, but for static-kinematic interactions.
|
||||
|
||||
\note This has no effect if PxRigidBodyFlag::eKINEMATIC is not set.
|
||||
|
||||
\warning Changing this flag at runtime will not have an effect until you remove and re-add the actor to the scene.
|
||||
|
||||
@see PxPairFilteringMode PxSceneDesc.staticKineFilteringMode
|
||||
*/
|
||||
eFORCE_STATIC_KINE_NOTIFICATIONS = (1<<9),
|
||||
|
||||
/**
|
||||
\brief Enables computation of gyroscopic forces on the rigid body.
|
||||
*/
|
||||
eENABLE_GYROSCOPIC_FORCES = (1<<10),
|
||||
|
||||
/**
|
||||
\brief Reserved for internal usage
|
||||
*/
|
||||
eRESERVED PX_DEPRECATED = (1<<15)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxRigidBodyFlag.
|
||||
|
||||
@see PxRigidBodyFlag
|
||||
*/
|
||||
typedef PxFlags<PxRigidBodyFlag::Enum,PxU16> PxRigidBodyFlags;
|
||||
PX_FLAGS_OPERATORS(PxRigidBodyFlag::Enum,PxU16)
|
||||
|
||||
/**
|
||||
\brief PxRigidBody is a base class shared between dynamic rigid body objects.
|
||||
|
||||
@see PxRigidActor
|
||||
*/
|
||||
|
||||
class PxRigidBody : public PxRigidActor
|
||||
{
|
||||
public:
|
||||
// Runtime modifications
|
||||
|
||||
/************************************************************************************************/
|
||||
/** @name Mass Manipulation
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Sets the pose of the center of mass relative to the actor.
|
||||
|
||||
\note Changing this transform will not move the actor in the world!
|
||||
|
||||
\note Setting an unrealistic center of mass which is a long way from the body can make it difficult for
|
||||
the SDK to solve constraints. Perhaps leading to instability and jittering bodies.
|
||||
|
||||
<b>Default:</b> the identity transform
|
||||
|
||||
\param[in] pose Mass frame offset transform relative to the actor frame. <b>Range:</b> rigid body transform.
|
||||
|
||||
@see getCMassLocalPose() PxRigidBodyDesc.massLocalPose
|
||||
*/
|
||||
virtual void setCMassLocalPose(const PxTransform& pose) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the center of mass pose relative to the actor frame.
|
||||
|
||||
\return The center of mass pose relative to the actor frame.
|
||||
|
||||
@see setCMassLocalPose() PxRigidBodyDesc.massLocalPose
|
||||
*/
|
||||
virtual PxTransform getCMassLocalPose() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the mass of a dynamic actor.
|
||||
|
||||
The mass must be non-negative.
|
||||
|
||||
setMass() does not update the inertial properties of the body, to change the inertia tensor
|
||||
use setMassSpaceInertiaTensor() or the PhysX extensions method #PxRigidBodyExt::updateMassAndInertia().
|
||||
|
||||
\note A value of 0 is interpreted as infinite mass.
|
||||
\note Values of 0 are not permitted for instances of PxArticulationLink but are permitted for instances of PxRigidDynamic.
|
||||
|
||||
<b>Default:</b> 1.0
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
|
||||
|
||||
\param[in] mass New mass value for the actor. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getMass() PxRigidBodyDesc.mass setMassSpaceInertiaTensor()
|
||||
*/
|
||||
virtual void setMass(PxReal mass) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the mass of the actor.
|
||||
|
||||
\note A value of 0 is interpreted as infinite mass.
|
||||
|
||||
\return The mass of this actor.
|
||||
|
||||
@see setMass() PxRigidBodyDesc.mass setMassSpaceInertiaTensor()
|
||||
*/
|
||||
virtual PxReal getMass() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the inverse mass of the actor.
|
||||
|
||||
\return The inverse mass of this actor.
|
||||
|
||||
@see setMass() PxRigidBodyDesc.mass setMassSpaceInertiaTensor()
|
||||
*/
|
||||
virtual PxReal getInvMass() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the inertia tensor, using a parameter specified in mass space coordinates.
|
||||
|
||||
Note that such matrices are diagonal -- the passed vector is the diagonal.
|
||||
|
||||
If you have a non diagonal world/actor space inertia tensor(3x3 matrix). Then you need to
|
||||
diagonalize it and set an appropriate mass space transform. See #setCMassLocalPose().
|
||||
|
||||
The inertia tensor elements must be non-negative.
|
||||
|
||||
\note A value of 0 in an element is interpreted as infinite inertia along that axis.
|
||||
\note Values of 0 are not permitted for instances of PxArticulationLink but are permitted for instances of PxRigidDynamic.
|
||||
|
||||
<b>Default:</b> (1.0, 1.0, 1.0)
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
|
||||
|
||||
\param[in] m New mass space inertia tensor for the actor.
|
||||
|
||||
@see PxRigidBodyDesc.massSpaceInertia getMassSpaceInertia() setMass() setCMassLocalPose()
|
||||
*/
|
||||
virtual void setMassSpaceInertiaTensor(const PxVec3& m) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the diagonal inertia tensor of the actor relative to the mass coordinate frame.
|
||||
|
||||
This method retrieves a mass frame inertia vector.
|
||||
|
||||
\return The mass space inertia tensor of this actor.
|
||||
|
||||
\note A value of 0 in an element is interpreted as infinite inertia along that axis.
|
||||
|
||||
@see PxRigidBodyDesc.massSpaceInertia setMassSpaceInertiaTensor() setMass() setCMassLocalPose()
|
||||
*/
|
||||
virtual PxVec3 getMassSpaceInertiaTensor() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the diagonal inverse inertia tensor of the actor relative to the mass coordinate frame.
|
||||
|
||||
This method retrieves a mass frame inverse inertia vector.
|
||||
|
||||
\note A value of 0 in an element is interpreted as infinite inertia along that axis.
|
||||
|
||||
\return The mass space inverse inertia tensor of this actor.
|
||||
|
||||
@see PxRigidBodyDesc.massSpaceInertia setMassSpaceInertiaTensor() setMass() setCMassLocalPose()
|
||||
*/
|
||||
virtual PxVec3 getMassSpaceInvInertiaTensor() const = 0;
|
||||
|
||||
/************************************************************************************************/
|
||||
/** @name Damping
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Sets the linear damping coefficient.
|
||||
|
||||
Zero represents no damping. The damping coefficient must be nonnegative.
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
\param[in] linDamp Linear damping coefficient. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getLinearDamping() setAngularDamping()
|
||||
*/
|
||||
virtual void setLinearDamping(PxReal linDamp) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the linear damping coefficient.
|
||||
|
||||
\return The linear damping coefficient associated with this actor.
|
||||
|
||||
@see setLinearDamping() getAngularDamping()
|
||||
*/
|
||||
virtual PxReal getLinearDamping() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the angular damping coefficient.
|
||||
|
||||
Zero represents no damping.
|
||||
|
||||
The angular damping coefficient must be nonnegative.
|
||||
|
||||
<b>Default:</b> 0.05
|
||||
|
||||
\param[in] angDamp Angular damping coefficient. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getAngularDamping() setLinearDamping()
|
||||
*/
|
||||
virtual void setAngularDamping(PxReal angDamp) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the angular damping coefficient.
|
||||
|
||||
\return The angular damping coefficient associated with this actor.
|
||||
|
||||
@see setAngularDamping() getLinearDamping()
|
||||
*/
|
||||
virtual PxReal getAngularDamping() const = 0;
|
||||
|
||||
|
||||
/************************************************************************************************/
|
||||
/** @name Velocity
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Retrieves the linear velocity of an actor.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running (except during PxScene::collide(),
|
||||
in PxContactModifyCallback or in contact report callbacks).
|
||||
|
||||
\return The linear velocity of the actor.
|
||||
|
||||
@see PxRigidDynamic.setLinearVelocity() getAngularVelocity()
|
||||
*/
|
||||
virtual PxVec3 getLinearVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the angular velocity of the actor.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running (except during PxScene::collide(),
|
||||
in PxContactModifyCallback or in contact report callbacks).
|
||||
|
||||
\return The angular velocity of the actor.
|
||||
|
||||
@see PxRigidDynamic.setAngularVelocity() getLinearVelocity()
|
||||
*/
|
||||
virtual PxVec3 getAngularVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Lets you set the maximum linear velocity permitted for this actor.
|
||||
|
||||
With this function, you can set the maximum linear velocity permitted for this rigid body.
|
||||
Higher angular velocities are clamped to this value.
|
||||
|
||||
Note: The angular velocity is clamped to the set value <i>before</i> the solver, which means that
|
||||
the limit may still be momentarily exceeded.
|
||||
|
||||
<b>Default:</b> PX_MAX_F32
|
||||
|
||||
\param[in] maxLinVel Max allowable linear velocity for actor. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getMaxAngularVelocity()
|
||||
*/
|
||||
virtual void setMaxLinearVelocity(PxReal maxLinVel) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the maximum angular velocity permitted for this actor.
|
||||
|
||||
\return The maximum allowed angular velocity for this actor.
|
||||
|
||||
@see setMaxLinearVelocity
|
||||
*/
|
||||
virtual PxReal getMaxLinearVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Lets you set the maximum angular velocity permitted for this actor.
|
||||
|
||||
For various internal computations, very quickly rotating actors introduce error
|
||||
into the simulation, which leads to undesired results.
|
||||
|
||||
With this function, you can set the maximum angular velocity permitted for this rigid body.
|
||||
Higher angular velocities are clamped to this value.
|
||||
|
||||
Note: The angular velocity is clamped to the set value <i>before</i> the solver, which means that
|
||||
the limit may still be momentarily exceeded.
|
||||
|
||||
<b>Default:</b> 100.0
|
||||
|
||||
\param[in] maxAngVel Max allowable angular velocity for actor. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getMaxAngularVelocity()
|
||||
*/
|
||||
virtual void setMaxAngularVelocity(PxReal maxAngVel) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the maximum angular velocity permitted for this actor.
|
||||
|
||||
\return The maximum allowed angular velocity for this actor.
|
||||
|
||||
@see setMaxAngularVelocity
|
||||
*/
|
||||
virtual PxReal getMaxAngularVelocity() const = 0;
|
||||
|
||||
/************************************************************************************************/
|
||||
/** @name Forces
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Applies a force (or impulse) defined in the global coordinate frame to the actor at its center of mass.
|
||||
|
||||
<b>This will not induce a torque</b>.
|
||||
|
||||
::PxForceMode determines if the force is to be conventional or impulsive.
|
||||
|
||||
Each actor has an acceleration and a velocity change accumulator which are directly modified using the modes PxForceMode::eACCELERATION
|
||||
and PxForceMode::eVELOCITY_CHANGE respectively. The modes PxForceMode::eFORCE and PxForceMode::eIMPULSE also modify these same
|
||||
accumulators and are just short hand for multiplying the vector parameter by inverse mass and then using PxForceMode::eACCELERATION and
|
||||
PxForceMode::eVELOCITY_CHANGE respectively.
|
||||
|
||||
\note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
\note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
|
||||
|
||||
\note if this is called on an articulation link, only the link is updated, not the entire articulation.
|
||||
|
||||
\note see #PxRigidBodyExt::computeVelocityDeltaFromImpulse for details of how to compute the change in linear velocity that
|
||||
will arise from the application of an impulsive force, where an impulsive force is applied force multiplied by a timestep.
|
||||
|
||||
<b>Sleeping:</b> This call wakes the actor if it is sleeping, and the autowake parameter is true (default) or the force is non-zero.
|
||||
|
||||
\param[in] force Force/Impulse to apply defined in the global frame.
|
||||
\param[in] mode The mode to use when applying the force/impulse(see #PxForceMode)
|
||||
\param[in] autowake Specify if the call should wake up the actor if it is currently asleep. If true and the current wake counter value
|
||||
is smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
|
||||
|
||||
@see PxForceMode addTorque
|
||||
*/
|
||||
virtual void addForce(const PxVec3& force, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true) = 0;
|
||||
|
||||
/**
|
||||
\brief Applies an impulsive torque defined in the global coordinate frame to the actor.
|
||||
|
||||
::PxForceMode determines if the torque is to be conventional or impulsive.
|
||||
|
||||
Each actor has an angular acceleration and an angular velocity change accumulator which are directly modified using the modes
|
||||
PxForceMode::eACCELERATION and PxForceMode::eVELOCITY_CHANGE respectively. The modes PxForceMode::eFORCE and PxForceMode::eIMPULSE
|
||||
also modify these same accumulators and are just short hand for multiplying the vector parameter by inverse inertia and then
|
||||
using PxForceMode::eACCELERATION and PxForceMode::eVELOCITY_CHANGE respectively.
|
||||
|
||||
\note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
\note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
|
||||
|
||||
\note if this called on an articulation link, only the link is updated, not the entire articulation.
|
||||
|
||||
\note see #PxRigidBodyExt::computeVelocityDeltaFromImpulse for details of how to compute the change in angular velocity that
|
||||
will arise from the application of an impulsive torque, where an impulsive torque is an applied torque multiplied by a timestep.
|
||||
|
||||
<b>Sleeping:</b> This call wakes the actor if it is sleeping, and the autowake parameter is true (default) or the torque is non-zero.
|
||||
|
||||
\param[in] torque Torque to apply defined in the global frame. <b>Range:</b> torque vector
|
||||
\param[in] mode The mode to use when applying the force/impulse(see #PxForceMode).
|
||||
\param[in] autowake Specify if the call should wake up the actor if it is currently asleep. If true and the current wake counter value
|
||||
is smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
|
||||
|
||||
@see PxForceMode addForce()
|
||||
*/
|
||||
virtual void addTorque(const PxVec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE, bool autowake = true) = 0;
|
||||
|
||||
/**
|
||||
\brief Clears the accumulated forces (sets the accumulated force back to zero).
|
||||
|
||||
Each actor has an acceleration and a velocity change accumulator which are directly modified using the modes PxForceMode::eACCELERATION
|
||||
and PxForceMode::eVELOCITY_CHANGE respectively. The modes PxForceMode::eFORCE and PxForceMode::eIMPULSE also modify these same
|
||||
accumulators (see PxRigidBody::addForce() for details); therefore the effect of calling clearForce(PxForceMode::eFORCE) is equivalent to calling
|
||||
clearForce(PxForceMode::eACCELERATION), and the effect of calling clearForce(PxForceMode::eIMPULSE) is equivalent to calling
|
||||
clearForce(PxForceMode::eVELOCITY_CHANGE).
|
||||
|
||||
::PxForceMode determines if the cleared force is to be conventional or impulsive.
|
||||
|
||||
\note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
|
||||
|
||||
\note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
\param[in] mode The mode to use when clearing the force/impulse(see #PxForceMode)
|
||||
|
||||
@see PxForceMode addForce
|
||||
*/
|
||||
virtual void clearForce(PxForceMode::Enum mode = PxForceMode::eFORCE) = 0;
|
||||
|
||||
/**
|
||||
\brief Clears the impulsive torque defined in the global coordinate frame to the actor.
|
||||
|
||||
::PxForceMode determines if the cleared torque is to be conventional or impulsive.
|
||||
|
||||
Each actor has an angular acceleration and a velocity change accumulator which are directly modified using the modes PxForceMode::eACCELERATION
|
||||
and PxForceMode::eVELOCITY_CHANGE respectively. The modes PxForceMode::eFORCE and PxForceMode::eIMPULSE also modify these same
|
||||
accumulators (see PxRigidBody::addTorque() for details); therefore the effect of calling clearTorque(PxForceMode::eFORCE) is equivalent to calling
|
||||
clearTorque(PxForceMode::eACCELERATION), and the effect of calling clearTorque(PxForceMode::eIMPULSE) is equivalent to calling
|
||||
clearTorque(PxForceMode::eVELOCITY_CHANGE).
|
||||
|
||||
\note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
|
||||
|
||||
\note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
\param[in] mode The mode to use when clearing the force/impulse(see #PxForceMode).
|
||||
|
||||
@see PxForceMode addTorque
|
||||
*/
|
||||
virtual void clearTorque(PxForceMode::Enum mode = PxForceMode::eFORCE) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the impulsive force and torque defined in the global coordinate frame to the actor.
|
||||
|
||||
::PxForceMode determines if the cleared torque is to be conventional or impulsive.
|
||||
|
||||
\note The force modes PxForceMode::eIMPULSE and PxForceMode::eVELOCITY_CHANGE can not be applied to articulation links.
|
||||
|
||||
\note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
@see PxForceMode addTorque
|
||||
*/
|
||||
virtual void setForceAndTorque(const PxVec3& force, const PxVec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE) = 0;
|
||||
|
||||
/**
|
||||
\brief Raises or clears a particular rigid body flag.
|
||||
|
||||
See the list of flags #PxRigidBodyFlag
|
||||
|
||||
<b>Default:</b> no flags are set
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
|
||||
|
||||
\param[in] flag The PxRigidBody flag to raise(set) or clear. See #PxRigidBodyFlag.
|
||||
\param[in] value The new boolean value for the flag.
|
||||
|
||||
@see PxRigidBodyFlag getRigidBodyFlags()
|
||||
*/
|
||||
virtual void setRigidBodyFlag(PxRigidBodyFlag::Enum flag, bool value) = 0;
|
||||
virtual void setRigidBodyFlags(PxRigidBodyFlags inFlags) = 0;
|
||||
|
||||
/**
|
||||
\brief Reads the PxRigidBody flags.
|
||||
|
||||
See the list of flags #PxRigidBodyFlag
|
||||
|
||||
\return The values of the PxRigidBody flags.
|
||||
|
||||
@see PxRigidBodyFlag setRigidBodyFlag()
|
||||
*/
|
||||
virtual PxRigidBodyFlags getRigidBodyFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the CCD minimum advance coefficient.
|
||||
|
||||
The CCD minimum advance coefficient is a value in the range [0, 1] that is used to control the minimum amount of time a body is integrated when
|
||||
it has a CCD contact. The actual minimum amount of time that is integrated depends on various properties, including the relative speed and collision shapes
|
||||
of the bodies involved in the contact. From these properties, a numeric value is calculated that determines the maximum distance (and therefore maximum time)
|
||||
which these bodies could be integrated forwards that would ensure that these bodies did not pass through each-other. This value is then scaled by CCD minimum advance
|
||||
coefficient to determine the amount of time that will be consumed in the CCD pass.
|
||||
|
||||
<b>Things to consider:</b>
|
||||
A large value (approaching 1) ensures that the objects will always advance some time. However, larger values increase the chances of objects gently drifting through each-other in
|
||||
scenes which the constraint solver can't converge, e.g. scenes where an object is being dragged through a wall with a constraint.
|
||||
A value of 0 ensures that the pair of objects stop at the exact time-of-impact and will not gently drift through each-other. However, with very small/thin objects initially in
|
||||
contact, this can lead to a large amount of time being dropped and increases the chances of jamming. Jamming occurs when the an object is persistently in contact with an object
|
||||
such that the time-of-impact is 0, which results in no time being advanced for those objects in that CCD pass.
|
||||
|
||||
The chances of jamming can be reduced by increasing the number of CCD mass @see PxSceneDesc.ccdMaxPasses. However, increasing this number increases the CCD overhead.
|
||||
|
||||
\param[in] advanceCoefficient The CCD min advance coefficient. <b>Range:</b> [0, 1] <b>Default:</b> 0.15
|
||||
*/
|
||||
virtual void setMinCCDAdvanceCoefficient(PxReal advanceCoefficient) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the CCD minimum advance coefficient.
|
||||
|
||||
\return The value of the CCD min advance coefficient.
|
||||
|
||||
@see setMinCCDAdvanceCoefficient
|
||||
*/
|
||||
virtual PxReal getMinCCDAdvanceCoefficient() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the maximum depenetration velocity permitted to be introduced by the solver.
|
||||
This value controls how much velocity the solver can introduce to correct for penetrations in contacts.
|
||||
\param[in] biasClamp The maximum velocity to de-penetrate by <b>Range:</b> (0, PX_MAX_F32].
|
||||
*/
|
||||
virtual void setMaxDepenetrationVelocity(PxReal biasClamp) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the maximum depenetration velocity the solver is permitted to introduced.
|
||||
This value controls how much velocity the solver can introduce to correct for penetrations in contacts.
|
||||
\return The maximum penetration bias applied by the solver.
|
||||
*/
|
||||
virtual PxReal getMaxDepenetrationVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets a limit on the impulse that may be applied at a contact. The maximum impulse at a contact between two dynamic or kinematic
|
||||
bodies will be the minimum of the two limit values. For a collision between a static and a dynamic body, the impulse is limited
|
||||
by the value for the dynamic body.
|
||||
|
||||
\param[in] maxImpulse the maximum contact impulse. <b>Range:</b> [0, PX_MAX_F32] <b>Default:</b> PX_MAX_F32
|
||||
|
||||
@see getMaxContactImpulse
|
||||
*/
|
||||
virtual void setMaxContactImpulse(PxReal maxImpulse) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the maximum impulse that may be applied at a contact.
|
||||
|
||||
\return The maximum impulse that may be applied at a contact
|
||||
|
||||
@see setMaxContactImpulse
|
||||
*/
|
||||
virtual PxReal getMaxContactImpulse() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets a distance scale whereby the angular influence of a contact on the normal constraint in a contact is
|
||||
zeroed if normal.cross(offset) falls below this tolerance. Rather than acting as an absolute value, this tolerance
|
||||
is scaled by the ratio rXn.dot(angVel)/normal.dot(linVel) such that contacts that have relatively larger angular velocity
|
||||
than linear normal velocity (e.g. rolling wheels) achieve larger slop values as the angular velocity increases.
|
||||
|
||||
\param[in] slopCoefficient the Slop coefficient. <b>Range:</b> [0, PX_MAX_F32] <b>Default:</b> 0
|
||||
|
||||
@see getContactSlopCoefficient
|
||||
*/
|
||||
virtual void setContactSlopCoefficient(PxReal slopCoefficient) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the contact slop coefficient.
|
||||
|
||||
\return The contact slop coefficient.
|
||||
|
||||
@see setContactSlopCoefficient
|
||||
*/
|
||||
virtual PxReal getContactSlopCoefficient() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the island node index
|
||||
|
||||
\return The island node index.
|
||||
*/
|
||||
virtual PxNodeIndex getInternalIslandNodeIndex() const = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxRigidBody(PxType concreteType, PxBaseFlags baseFlags) : PxRigidActor(concreteType, baseFlags) {}
|
||||
PX_INLINE PxRigidBody(PxBaseFlags baseFlags) : PxRigidActor(baseFlags) {}
|
||||
virtual ~PxRigidBody() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxRigidBody", name) || PxRigidActor::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,454 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_RIGID_DYNAMIC_H
|
||||
#define PX_RIGID_DYNAMIC_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxRigidBody.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Collection of flags providing a mechanism to lock motion along/around a specific axis.
|
||||
|
||||
@see PxRigidDynamic.setRigidDynamicLockFlag(), PxRigidBody.getRigidDynamicLockFlags()
|
||||
*/
|
||||
struct PxRigidDynamicLockFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eLOCK_LINEAR_X = (1 << 0),
|
||||
eLOCK_LINEAR_Y = (1 << 1),
|
||||
eLOCK_LINEAR_Z = (1 << 2),
|
||||
eLOCK_ANGULAR_X = (1 << 3),
|
||||
eLOCK_ANGULAR_Y = (1 << 4),
|
||||
eLOCK_ANGULAR_Z = (1 << 5)
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxRigidDynamicLockFlag::Enum, PxU8> PxRigidDynamicLockFlags;
|
||||
PX_FLAGS_OPERATORS(PxRigidDynamicLockFlag::Enum, PxU8)
|
||||
|
||||
/**
|
||||
\brief PxRigidDynamic represents a dynamic rigid simulation object in the physics SDK.
|
||||
|
||||
<h3>Creation</h3>
|
||||
Instances of this class are created by calling #PxPhysics::createRigidDynamic() and deleted with #release().
|
||||
|
||||
|
||||
<h3>Visualizations</h3>
|
||||
\li #PxVisualizationParameter::eACTOR_AXES
|
||||
\li #PxVisualizationParameter::eBODY_AXES
|
||||
\li #PxVisualizationParameter::eBODY_MASS_AXES
|
||||
\li #PxVisualizationParameter::eBODY_LIN_VELOCITY
|
||||
\li #PxVisualizationParameter::eBODY_ANG_VELOCITY
|
||||
|
||||
@see PxRigidBody PxPhysics.createRigidDynamic() release()
|
||||
*/
|
||||
|
||||
class PxRigidDynamic : public PxRigidBody
|
||||
{
|
||||
public:
|
||||
// Runtime modifications
|
||||
|
||||
|
||||
/************************************************************************************************/
|
||||
/** @name Kinematic Actors
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Moves kinematically controlled dynamic actors through the game world.
|
||||
|
||||
You set a dynamic actor to be kinematic using the PxRigidBodyFlag::eKINEMATIC flag
|
||||
with setRigidBodyFlag().
|
||||
|
||||
The move command will result in a velocity that will move the body into
|
||||
the desired pose. After the move is carried out during a single time step,
|
||||
the velocity is returned to zero. Thus, you must continuously call
|
||||
this in every time step for kinematic actors so that they move along a path.
|
||||
|
||||
This function simply stores the move destination until the next simulation
|
||||
step is processed, so consecutive calls will simply overwrite the stored target variable.
|
||||
|
||||
The motion is always fully carried out.
|
||||
|
||||
\note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
<b>Sleeping:</b> This call wakes the actor if it is sleeping and will set the wake counter to #PxSceneDesc::wakeCounterResetValue.
|
||||
|
||||
\param[in] destination The desired pose for the kinematic actor, in the global frame. <b>Range:</b> rigid body transform.
|
||||
|
||||
@see getKinematicTarget() PxRigidBodyFlag setRigidBodyFlag()
|
||||
*/
|
||||
virtual void setKinematicTarget(const PxTransform& destination) = 0;
|
||||
|
||||
/**
|
||||
\brief Get target pose of a kinematically controlled dynamic actor.
|
||||
|
||||
\param[out] target Transform to write the target pose to. Only valid if the method returns true.
|
||||
\return True if the actor is a kinematically controlled dynamic and the target has been set, else False.
|
||||
|
||||
@see setKinematicTarget() PxRigidBodyFlag setRigidBodyFlag()
|
||||
*/
|
||||
virtual bool getKinematicTarget(PxTransform& target) const = 0;
|
||||
|
||||
|
||||
/************************************************************************************************/
|
||||
/** @name Sleeping
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Returns true if this body is sleeping.
|
||||
|
||||
When an actor does not move for a period of time, it is no longer simulated in order to save time. This state
|
||||
is called sleeping. However, because the object automatically wakes up when it is either touched by an awake object,
|
||||
or one of its properties is changed by the user, the entire sleep mechanism should be transparent to the user.
|
||||
|
||||
In general, a dynamic rigid actor is guaranteed to be awake if at least one of the following holds:
|
||||
|
||||
\li The wake counter is positive (see #setWakeCounter()).
|
||||
\li The linear or angular velocity is non-zero.
|
||||
\li A non-zero force or torque has been applied.
|
||||
|
||||
If a dynamic rigid actor is sleeping, the following state is guaranteed:
|
||||
|
||||
\li The wake counter is zero.
|
||||
\li The linear and angular velocity is zero.
|
||||
\li There is no force update pending.
|
||||
|
||||
When an actor gets inserted into a scene, it will be considered asleep if all the points above hold, else it will be treated as awake.
|
||||
|
||||
If an actor is asleep after the call to PxScene::fetchResults() returns, it is guaranteed that the pose of the actor
|
||||
was not changed. You can use this information to avoid updating the transforms of associated objects.
|
||||
|
||||
\note A kinematic actor is asleep unless a target pose has been set (in which case it will stay awake until two consecutive
|
||||
simulation steps without a target pose being set have passed). The wake counter will get set to zero or to the reset value
|
||||
#PxSceneDesc::wakeCounterResetValue in the case where a target pose has been set to be consistent with the definitions above.
|
||||
|
||||
\note It is invalid to use this method if the actor has not been added to a scene already.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running.
|
||||
|
||||
\return True if the actor is sleeping.
|
||||
|
||||
@see isSleeping() wakeUp() putToSleep() getSleepThreshold()
|
||||
*/
|
||||
virtual bool isSleeping() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Sets the mass-normalized kinetic energy threshold below which an actor may go to sleep.
|
||||
|
||||
Actors whose kinetic energy divided by their mass is below this threshold will be candidates for sleeping.
|
||||
|
||||
<b>Default:</b> 5e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed
|
||||
|
||||
\param[in] threshold Energy below which an actor may go to sleep. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see isSleeping() getSleepThreshold() wakeUp() putToSleep() PxTolerancesScale
|
||||
*/
|
||||
virtual void setSleepThreshold(PxReal threshold) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the mass-normalized kinetic energy below which an actor may go to sleep.
|
||||
|
||||
\return The energy threshold for sleeping.
|
||||
|
||||
@see isSleeping() wakeUp() putToSleep() setSleepThreshold()
|
||||
*/
|
||||
virtual PxReal getSleepThreshold() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the mass-normalized kinetic energy threshold below which an actor may participate in stabilization.
|
||||
|
||||
Actors whose kinetic energy divided by their mass is above this threshold will not participate in stabilization.
|
||||
|
||||
This value has no effect if PxSceneFlag::eENABLE_STABILIZATION was not enabled on the PxSceneDesc.
|
||||
|
||||
<b>Default:</b> 1e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed
|
||||
|
||||
\param[in] threshold Energy below which an actor may participate in stabilization. <b>Range:</b> [0,inf)
|
||||
|
||||
@see getStabilizationThreshold() PxSceneFlag::eENABLE_STABILIZATION
|
||||
*/
|
||||
virtual void setStabilizationThreshold(PxReal threshold) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the mass-normalized kinetic energy below which an actor may participate in stabilization.
|
||||
|
||||
Actors whose kinetic energy divided by their mass is above this threshold will not participate in stabilization.
|
||||
|
||||
\return The energy threshold for participating in stabilization.
|
||||
|
||||
@see setStabilizationThreshold() PxSceneFlag::eENABLE_STABILIZATION
|
||||
*/
|
||||
virtual PxReal getStabilizationThreshold() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Reads the PxRigidDynamic lock flags.
|
||||
|
||||
See the list of flags #PxRigidDynamicLockFlag
|
||||
|
||||
\return The values of the PxRigidDynamicLock flags.
|
||||
|
||||
@see PxRigidDynamicLockFlag setRigidDynamicLockFlag()
|
||||
*/
|
||||
virtual PxRigidDynamicLockFlags getRigidDynamicLockFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Raises or clears a particular rigid dynamic lock flag.
|
||||
|
||||
See the list of flags #PxRigidDynamicLockFlag
|
||||
|
||||
<b>Default:</b> no flags are set
|
||||
|
||||
|
||||
\param[in] flag The PxRigidDynamicLockBody flag to raise(set) or clear. See #PxRigidBodyFlag.
|
||||
\param[in] value The new boolean value for the flag.
|
||||
|
||||
@see PxRigidDynamicLockFlag getRigidDynamicLockFlags()
|
||||
*/
|
||||
virtual void setRigidDynamicLockFlag(PxRigidDynamicLockFlag::Enum flag, bool value) = 0;
|
||||
virtual void setRigidDynamicLockFlags(PxRigidDynamicLockFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the linear velocity of an actor.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running (except during PxScene::collide(),
|
||||
in PxContactModifyCallback or in contact report callbacks).
|
||||
|
||||
\return The linear velocity of the actor.
|
||||
|
||||
@see PxRigidDynamic.setLinearVelocity() getAngularVelocity()
|
||||
*/
|
||||
virtual PxVec3 getLinearVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the linear velocity of the actor.
|
||||
|
||||
Note that if you continuously set the velocity of an actor yourself,
|
||||
forces such as gravity or friction will not be able to manifest themselves, because forces directly
|
||||
influence only the velocity/momentum of an actor.
|
||||
|
||||
<b>Default:</b> (0.0, 0.0, 0.0)
|
||||
|
||||
<b>Sleeping:</b> This call wakes the actor if it is sleeping, and the autowake parameter is true (default) or the
|
||||
new velocity is non-zero.
|
||||
|
||||
\note It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
\param[in] linVel New linear velocity of actor. <b>Range:</b> velocity vector
|
||||
\param[in] autowake Whether to wake the object up if it is asleep. If true and the current wake counter value is
|
||||
smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
|
||||
|
||||
@see getLinearVelocity() setAngularVelocity()
|
||||
*/
|
||||
virtual void setLinearVelocity(const PxVec3& linVel, bool autowake = true) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the angular velocity of the actor.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running (except during PxScene::collide(),
|
||||
in PxContactModifyCallback or in contact report callbacks).
|
||||
|
||||
\return The angular velocity of the actor.
|
||||
|
||||
@see PxRigidDynamic.setAngularVelocity() getLinearVelocity()
|
||||
*/
|
||||
virtual PxVec3 getAngularVelocity() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the angular velocity of the actor.
|
||||
|
||||
Note that if you continuously set the angular velocity of an actor yourself,
|
||||
forces such as friction will not be able to rotate the actor, because forces directly influence only the velocity/momentum.
|
||||
|
||||
<b>Default:</b> (0.0, 0.0, 0.0)
|
||||
|
||||
<b>Sleeping:</b> This call wakes the actor if it is sleeping, and the autowake parameter is true (default) or the
|
||||
new velocity is non-zero.
|
||||
|
||||
\note It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
\param[in] angVel New angular velocity of actor. <b>Range:</b> angular velocity vector
|
||||
\param[in] autowake Whether to wake the object up if it is asleep. If true and the current wake counter value is
|
||||
smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
|
||||
|
||||
@see getAngularVelocity() setLinearVelocity()
|
||||
*/
|
||||
virtual void setAngularVelocity(const PxVec3& angVel, bool autowake = true) = 0;
|
||||
/**
|
||||
\brief Sets the wake counter for the actor.
|
||||
|
||||
The wake counter value determines the minimum amount of time until the body can be put to sleep. Please note
|
||||
that a body will not be put to sleep if the energy is above the specified threshold (see #setSleepThreshold())
|
||||
or if other awake bodies are touching it.
|
||||
|
||||
\note Passing in a positive value will wake the actor up automatically.
|
||||
|
||||
\note It is invalid to use this method for kinematic actors since the wake counter for kinematics is defined
|
||||
based on whether a target pose has been set (see the comment in #isSleeping()).
|
||||
|
||||
\note It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
<b>Default:</b> 0.4 (which corresponds to 20 frames for a time step of 0.02)
|
||||
|
||||
\param[in] wakeCounterValue Wake counter value. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see isSleeping() getWakeCounter()
|
||||
*/
|
||||
virtual void setWakeCounter(PxReal wakeCounterValue) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the wake counter of the actor.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running.
|
||||
|
||||
\return The wake counter of the actor.
|
||||
|
||||
@see isSleeping() setWakeCounter()
|
||||
*/
|
||||
virtual PxReal getWakeCounter() const = 0;
|
||||
|
||||
/**
|
||||
\brief Wakes up the actor if it is sleeping.
|
||||
|
||||
The actor will get woken up and might cause other touching actors to wake up as well during the next simulation step.
|
||||
|
||||
\note This will set the wake counter of the actor to the value specified in #PxSceneDesc::wakeCounterResetValue.
|
||||
|
||||
\note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
\note It is invalid to use this method for kinematic actors since the sleep state for kinematics is defined
|
||||
based on whether a target pose has been set (see the comment in #isSleeping()).
|
||||
|
||||
@see isSleeping() putToSleep()
|
||||
*/
|
||||
virtual void wakeUp() = 0;
|
||||
|
||||
/**
|
||||
\brief Forces the actor to sleep.
|
||||
|
||||
The actor will stay asleep during the next simulation step if not touched by another non-sleeping actor.
|
||||
|
||||
\note Any applied force will be cleared and the velocity and the wake counter of the actor will be set to 0.
|
||||
|
||||
\note It is invalid to use this method if the actor has not been added to a scene already or if PxActorFlag::eDISABLE_SIMULATION is set.
|
||||
|
||||
\note It is invalid to use this method for kinematic actors since the sleep state for kinematics is defined
|
||||
based on whether a target pose has been set (see the comment in #isSleeping()).
|
||||
|
||||
@see isSleeping() wakeUp()
|
||||
*/
|
||||
virtual void putToSleep() = 0;
|
||||
|
||||
/************************************************************************************************/
|
||||
|
||||
/**
|
||||
\brief Sets the solver iteration counts for the body.
|
||||
|
||||
The solver iteration count determines how accurately joints and contacts are resolved.
|
||||
If you are having trouble with jointed bodies oscillating and behaving erratically, then
|
||||
setting a higher position iteration count may improve their stability.
|
||||
|
||||
If intersecting bodies are being depenetrated too violently, increase the number of velocity
|
||||
iterations. More velocity iterations will drive the relative exit velocity of the intersecting
|
||||
objects closer to the correct value given the restitution.
|
||||
|
||||
<b>Default:</b> 4 position iterations, 1 velocity iteration
|
||||
|
||||
\param[in] minPositionIters Number of position iterations the solver should perform for this body. <b>Range:</b> [1,255]
|
||||
\param[in] minVelocityIters Number of velocity iterations the solver should perform for this body. <b>Range:</b> [0,255]
|
||||
|
||||
@see getSolverIterationCounts()
|
||||
*/
|
||||
virtual void setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters = 1) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the solver iteration counts.
|
||||
|
||||
@see setSolverIterationCounts()
|
||||
*/
|
||||
virtual void getSolverIterationCounts(PxU32& minPositionIters, PxU32& minVelocityIters) const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the force threshold for contact reports.
|
||||
|
||||
The contact report threshold is a force threshold. If the force between
|
||||
two actors exceeds this threshold for either of the two actors, a contact report
|
||||
will be generated according to the contact report threshold flags provided by
|
||||
the filter shader/callback.
|
||||
See #PxPairFlag.
|
||||
|
||||
The threshold used for a collision between a dynamic actor and the static environment is
|
||||
the threshold of the dynamic actor, and all contacts with static actors are summed to find
|
||||
the total normal force.
|
||||
|
||||
<b>Default:</b> PX_MAX_F32
|
||||
|
||||
\return Force threshold for contact reports.
|
||||
|
||||
@see setContactReportThreshold PxPairFlag PxSimulationFilterShader PxSimulationFilterCallback
|
||||
*/
|
||||
virtual PxReal getContactReportThreshold() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the force threshold for contact reports.
|
||||
|
||||
See #getContactReportThreshold().
|
||||
|
||||
\param[in] threshold Force threshold for contact reports. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see getContactReportThreshold PxPairFlag
|
||||
*/
|
||||
virtual void setContactReportThreshold(PxReal threshold) = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxRigidDynamic"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxRigidDynamic(PxType concreteType, PxBaseFlags baseFlags) : PxRigidBody(concreteType, baseFlags) { }
|
||||
PX_INLINE PxRigidDynamic(PxBaseFlags baseFlags) : PxRigidBody(baseFlags) {}
|
||||
virtual ~PxRigidDynamic() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxRigidDynamic", name) || PxRigidBody::isKindOf(name); }
|
||||
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_RIGID_STATIC_H
|
||||
#define PX_RIGID_STATIC_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxRigidActor.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief PxRigidStatic represents a static rigid body simulation object in the physics SDK.
|
||||
|
||||
PxRigidStatic objects are static rigid physics entities. They shall be used to define solid objects which are fixed in the world.
|
||||
|
||||
<h3>Creation</h3>
|
||||
Instances of this class are created by calling #PxPhysics::createRigidStatic() and deleted with #release().
|
||||
|
||||
<h3>Visualizations</h3>
|
||||
\li #PxVisualizationParameter::eACTOR_AXES
|
||||
|
||||
@see PxRigidActor PxPhysics.createRigidStatic() release()
|
||||
*/
|
||||
|
||||
class PxRigidStatic : public PxRigidActor
|
||||
{
|
||||
public:
|
||||
virtual const char* getConcreteTypeName() const { return "PxRigidStatic"; }
|
||||
|
||||
protected:
|
||||
PX_INLINE PxRigidStatic(PxType concreteType, PxBaseFlags baseFlags) : PxRigidActor(concreteType, baseFlags) {}
|
||||
PX_INLINE PxRigidStatic(PxBaseFlags baseFlags) : PxRigidActor(baseFlags){}
|
||||
virtual ~PxRigidStatic() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxRigidStatic", name) || PxRigidActor::isKindOf(name); }
|
||||
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
1816
modules/PhysX/physx/physx-sys/physx/physx/include/PxScene.h
Normal file
1816
modules/PhysX/physx/physx-sys/physx/physx/include/PxScene.h
Normal file
File diff suppressed because it is too large
Load Diff
1042
modules/PhysX/physx/physx-sys/physx/physx/include/PxSceneDesc.h
Normal file
1042
modules/PhysX/physx/physx-sys/physx/physx/include/PxSceneDesc.h
Normal file
File diff suppressed because it is too large
Load Diff
127
modules/PhysX/physx/physx-sys/physx/physx/include/PxSceneLock.h
Normal file
127
modules/PhysX/physx/physx-sys/physx/physx/include/PxSceneLock.h
Normal file
@@ -0,0 +1,127 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SCENE_LOCK_H
|
||||
#define PX_SCENE_LOCK_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxScene.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief RAII wrapper for the PxScene read lock.
|
||||
|
||||
Use this class as follows to lock the scene for reading by the current thread
|
||||
for the duration of the enclosing scope:
|
||||
|
||||
PxSceneReadLock lock(sceneRef);
|
||||
|
||||
@see PxScene::lockRead(), PxScene::unlockRead(), PxSceneFlag::eREQUIRE_RW_LOCK
|
||||
*/
|
||||
class PxSceneReadLock
|
||||
{
|
||||
PxSceneReadLock(const PxSceneReadLock&);
|
||||
PxSceneReadLock& operator=(const PxSceneReadLock&);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
\param scene The scene to lock for reading
|
||||
\param file Optional string for debugging purposes
|
||||
\param line Optional line number for debugging purposes
|
||||
*/
|
||||
PxSceneReadLock(PxScene& scene, const char* file=NULL, PxU32 line=0)
|
||||
: mScene(scene)
|
||||
{
|
||||
mScene.lockRead(file, line);
|
||||
}
|
||||
|
||||
~PxSceneReadLock()
|
||||
{
|
||||
mScene.unlockRead();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
PxScene& mScene;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief RAII wrapper for the PxScene write lock.
|
||||
|
||||
Use this class as follows to lock the scene for writing by the current thread
|
||||
for the duration of the enclosing scope:
|
||||
|
||||
PxSceneWriteLock lock(sceneRef);
|
||||
|
||||
@see PxScene::lockWrite(), PxScene::unlockWrite(), PxSceneFlag::eREQUIRE_RW_LOCK
|
||||
*/
|
||||
class PxSceneWriteLock
|
||||
{
|
||||
PxSceneWriteLock(const PxSceneWriteLock&);
|
||||
PxSceneWriteLock& operator=(const PxSceneWriteLock&);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Constructor
|
||||
\param scene The scene to lock for writing
|
||||
\param file Optional string for debugging purposes
|
||||
\param line Optional line number for debugging purposes
|
||||
*/
|
||||
PxSceneWriteLock(PxScene& scene, const char* file=NULL, PxU32 line=0)
|
||||
: mScene(scene)
|
||||
{
|
||||
mScene.lockWrite(file, line);
|
||||
}
|
||||
|
||||
~PxSceneWriteLock()
|
||||
{
|
||||
mScene.unlockWrite();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
PxScene& mScene;
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,328 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SCENE_QUERY_DESC_H
|
||||
#define PX_SCENE_QUERY_DESC_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "geometry/PxBVHBuildStrategy.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxSceneQuerySystem;
|
||||
|
||||
/**
|
||||
\brief Pruning structure used to accelerate scene queries.
|
||||
|
||||
eNONE uses a simple data structure that consumes less memory than the alternatives,
|
||||
but generally has slower query performance.
|
||||
|
||||
eDYNAMIC_AABB_TREE usually provides the fastest queries. However there is a
|
||||
constant per-frame management cost associated with this structure. How much work should
|
||||
be done per frame can be tuned via the #PxSceneQueryDesc::dynamicTreeRebuildRateHint
|
||||
parameter.
|
||||
|
||||
eSTATIC_AABB_TREE is typically used for static objects. It is the same as the
|
||||
dynamic AABB tree, without the per-frame overhead. This can be a good choice for static
|
||||
objects, if no static objects are added, moved or removed after the scene has been
|
||||
created. If there is no such guarantee (e.g. when streaming parts of the world in and out),
|
||||
then the dynamic version is a better choice even for static objects.
|
||||
*/
|
||||
struct PxPruningStructureType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE, //!< Using a simple data structure
|
||||
eDYNAMIC_AABB_TREE, //!< Using a dynamic AABB tree
|
||||
eSTATIC_AABB_TREE, //!< Using a static AABB tree
|
||||
|
||||
eLAST
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Secondary pruning structure used for newly added objects in dynamic trees.
|
||||
|
||||
Dynamic trees (PxPruningStructureType::eDYNAMIC_AABB_TREE) are slowly rebuilt
|
||||
over several frames. A secondary pruning structure holds and manages objects
|
||||
added to the scene while this rebuild is in progress.
|
||||
|
||||
eNONE ignores newly added objects. This means that for a number of frames (roughly
|
||||
defined by PxSceneQueryDesc::dynamicTreeRebuildRateHint) newly added objects will
|
||||
be ignored by scene queries. This can be acceptable when streaming large worlds, e.g.
|
||||
when the objects added at the boundaries of the game world don't immediately need to be
|
||||
visible from scene queries (it would be equivalent to streaming that data in a few frames
|
||||
later). The advantage of this approach is that there is no CPU cost associated with
|
||||
inserting the new objects in the scene query data structures, and no extra runtime cost
|
||||
when performing queries.
|
||||
|
||||
eBUCKET uses a structure similar to PxPruningStructureType::eNONE. Insertion is fast but
|
||||
query cost can be high.
|
||||
|
||||
eINCREMENTAL uses an incremental AABB-tree, with no direct PxPruningStructureType equivalent.
|
||||
Query time is fast but insertion cost can be high.
|
||||
|
||||
eBVH uses a PxBVH structure. This usually offers the best overall performance.
|
||||
*/
|
||||
struct PxDynamicTreeSecondaryPruner
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE, //!< no secondary pruner, new objects aren't visible to SQ for a few frames
|
||||
eBUCKET , //!< bucket-based secondary pruner, faster updates, slower query time
|
||||
eINCREMENTAL, //!< incremental-BVH secondary pruner, faster query time, slower updates
|
||||
eBVH, //!< PxBVH-based secondary pruner, good overall performance
|
||||
|
||||
eLAST
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Scene query update mode
|
||||
|
||||
This enum controls what work is done when the scene query system is updated. The updates traditionally happen when PxScene::fetchResults
|
||||
is called. This function then calls PxSceneQuerySystem::finalizeUpdates, where the update mode is used.
|
||||
|
||||
fetchResults/finalizeUpdates will sync changed bounds during simulation and update the scene query bounds in pruners, this work is mandatory.
|
||||
|
||||
eBUILD_ENABLED_COMMIT_ENABLED does allow to execute the new AABB tree build step during fetchResults/finalizeUpdates, additionally
|
||||
the pruner commit is called where any changes are applied. During commit PhysX refits the dynamic scene query tree and if a new tree
|
||||
was built and the build finished the tree is swapped with current AABB tree.
|
||||
|
||||
eBUILD_ENABLED_COMMIT_DISABLED does allow to execute the new AABB tree build step during fetchResults/finalizeUpdates. Pruner commit
|
||||
is not called, this means that refit will then occur during the first scene query following fetchResults/finalizeUpdates, or may be forced
|
||||
by the method PxScene::flushQueryUpdates() / PxSceneQuerySystemBase::flushUpdates().
|
||||
|
||||
eBUILD_DISABLED_COMMIT_DISABLED no further scene query work is executed. The scene queries update needs to be called manually, see
|
||||
PxScene::sceneQueriesUpdate (see that function's doc for the equivalent PxSceneQuerySystem sequence). It is recommended to call
|
||||
PxScene::sceneQueriesUpdate right after fetchResults/finalizeUpdates as the pruning structures are not updated.
|
||||
*/
|
||||
struct PxSceneQueryUpdateMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eBUILD_ENABLED_COMMIT_ENABLED, //!< Both scene query build and commit are executed.
|
||||
eBUILD_ENABLED_COMMIT_DISABLED, //!< Scene query build only is executed.
|
||||
eBUILD_DISABLED_COMMIT_DISABLED //!< No work is done, no update of scene queries
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Descriptor class for scene query system. See #PxSceneQuerySystem.
|
||||
*/
|
||||
class PxSceneQueryDesc
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Defines the structure used to store static objects (PxRigidStatic actors).
|
||||
|
||||
There are usually a lot more static actors than dynamic actors in a scene, so they are stored
|
||||
in a separate structure. The idea is that when dynamic actors move each frame, the static structure
|
||||
remains untouched and does not need updating.
|
||||
|
||||
<b>Default:</b> PxPruningStructureType::eDYNAMIC_AABB_TREE
|
||||
|
||||
\note Only PxPruningStructureType::eSTATIC_AABB_TREE and PxPruningStructureType::eDYNAMIC_AABB_TREE are allowed here.
|
||||
|
||||
@see PxPruningStructureType PxSceneSQSystem.getStaticStructure()
|
||||
*/
|
||||
PxPruningStructureType::Enum staticStructure;
|
||||
|
||||
/**
|
||||
\brief Defines the structure used to store dynamic objects (non-PxRigidStatic actors).
|
||||
|
||||
<b>Default:</b> PxPruningStructureType::eDYNAMIC_AABB_TREE
|
||||
|
||||
@see PxPruningStructureType PxSceneSQSystem.getDynamicStructure()
|
||||
*/
|
||||
PxPruningStructureType::Enum dynamicStructure;
|
||||
|
||||
/**
|
||||
\brief Hint for how much work should be done per simulation frame to rebuild the pruning structures.
|
||||
|
||||
This parameter gives a hint on the distribution of the workload for rebuilding the dynamic AABB tree
|
||||
pruning structure #PxPruningStructureType::eDYNAMIC_AABB_TREE. It specifies the desired number of simulation frames
|
||||
the rebuild process should take. Higher values will decrease the workload per frame but the pruning
|
||||
structure will get more and more outdated the longer the rebuild takes (which can make
|
||||
scene queries less efficient).
|
||||
|
||||
\note Only used for #PxPruningStructureType::eDYNAMIC_AABB_TREE pruning structures.
|
||||
|
||||
\note Both staticStructure & dynamicStructure can use a PxPruningStructureType::eDYNAMIC_AABB_TREE, in which case
|
||||
this parameter is used for both.
|
||||
|
||||
\note This parameter gives only a hint. The rebuild process might still take more or less time depending on the
|
||||
number of objects involved.
|
||||
|
||||
<b>Range:</b> [4, PX_MAX_U32)<br>
|
||||
<b>Default:</b> 100
|
||||
|
||||
@see PxSceneQuerySystemBase.setDynamicTreeRebuildRateHint() PxSceneQuerySystemBase.getDynamicTreeRebuildRateHint()
|
||||
*/
|
||||
PxU32 dynamicTreeRebuildRateHint;
|
||||
|
||||
/**
|
||||
\brief Secondary pruner for dynamic tree.
|
||||
|
||||
This is used for PxPruningStructureType::eDYNAMIC_AABB_TREE structures, to control how objects added to the system
|
||||
at runtime are managed.
|
||||
|
||||
\note Both staticStructure & dynamicStructure can use a PxPruningStructureType::eDYNAMIC_AABB_TREE, in which case
|
||||
this parameter is used for both.
|
||||
|
||||
<b>Default:</b> PxDynamicTreeSecondaryPruner::eINCREMENTAL
|
||||
|
||||
@see PxDynamicTreeSecondaryPruner
|
||||
*/
|
||||
PxDynamicTreeSecondaryPruner::Enum dynamicTreeSecondaryPruner;
|
||||
|
||||
/**
|
||||
\brief Build strategy for PxSceneQueryDesc::staticStructure.
|
||||
|
||||
This parameter is used to refine / control the build strategy of PxSceneQueryDesc::staticStructure. This is only
|
||||
used with PxPruningStructureType::eDYNAMIC_AABB_TREE and PxPruningStructureType::eSTATIC_AABB_TREE.
|
||||
|
||||
<b>Default:</b> PxBVHBuildStrategy::eFAST
|
||||
|
||||
@see PxBVHBuildStrategy PxSceneQueryDesc::staticStructure
|
||||
*/
|
||||
PxBVHBuildStrategy::Enum staticBVHBuildStrategy;
|
||||
|
||||
/**
|
||||
\brief Build strategy for PxSceneQueryDesc::dynamicStructure.
|
||||
|
||||
This parameter is used to refine / control the build strategy of PxSceneQueryDesc::dynamicStructure. This is only
|
||||
used with PxPruningStructureType::eDYNAMIC_AABB_TREE and PxPruningStructureType::eSTATIC_AABB_TREE.
|
||||
|
||||
<b>Default:</b> PxBVHBuildStrategy::eFAST
|
||||
|
||||
@see PxBVHBuildStrategy PxSceneQueryDesc::dynamicStructure
|
||||
*/
|
||||
PxBVHBuildStrategy::Enum dynamicBVHBuildStrategy;
|
||||
|
||||
/**
|
||||
\brief Number of objects per node for PxSceneQueryDesc::staticStructure.
|
||||
|
||||
This parameter is used to refine / control the number of objects per node for PxSceneQueryDesc::staticStructure.
|
||||
This is only used with PxPruningStructureType::eDYNAMIC_AABB_TREE and PxPruningStructureType::eSTATIC_AABB_TREE.
|
||||
|
||||
This parameter has an impact on how quickly the structure gets built, and on the per-frame cost of maintaining
|
||||
the structure. Increasing this value gives smaller AABB-trees that use less memory, are faster to build and
|
||||
update, but it can lead to slower queries.
|
||||
|
||||
<b>Default:</b> 4
|
||||
|
||||
@see PxSceneQueryDesc::staticStructure
|
||||
*/
|
||||
PxU32 staticNbObjectsPerNode;
|
||||
|
||||
/**
|
||||
\brief Number of objects per node for PxSceneQueryDesc::dynamicStructure.
|
||||
|
||||
This parameter is used to refine / control the number of objects per node for PxSceneQueryDesc::dynamicStructure.
|
||||
This is only used with PxPruningStructureType::eDYNAMIC_AABB_TREE and PxPruningStructureType::eSTATIC_AABB_TREE.
|
||||
|
||||
This parameter has an impact on how quickly the structure gets built, and on the per-frame cost of maintaining
|
||||
the structure. Increasing this value gives smaller AABB-trees that use less memory, are faster to build and
|
||||
update, but it can lead to slower queries.
|
||||
|
||||
<b>Default:</b> 4
|
||||
|
||||
@see PxSceneQueryDesc::dynamicStructure
|
||||
*/
|
||||
PxU32 dynamicNbObjectsPerNode;
|
||||
|
||||
/**
|
||||
\brief Defines the scene query update mode.
|
||||
|
||||
<b>Default:</b> PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED
|
||||
|
||||
@see PxSceneQuerySystemBase.setUpdateMode() PxSceneQuerySystemBase.getUpdateMode()
|
||||
*/
|
||||
PxSceneQueryUpdateMode::Enum sceneQueryUpdateMode;
|
||||
|
||||
public:
|
||||
/**
|
||||
\brief constructor sets to default.
|
||||
*/
|
||||
PX_INLINE PxSceneQueryDesc();
|
||||
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE void setToDefault();
|
||||
|
||||
/**
|
||||
\brief Returns true if the descriptor is valid.
|
||||
\return true if the current settings are valid.
|
||||
*/
|
||||
PX_INLINE bool isValid() const;
|
||||
};
|
||||
|
||||
PX_INLINE PxSceneQueryDesc::PxSceneQueryDesc():
|
||||
staticStructure (PxPruningStructureType::eDYNAMIC_AABB_TREE),
|
||||
dynamicStructure (PxPruningStructureType::eDYNAMIC_AABB_TREE),
|
||||
dynamicTreeRebuildRateHint (100),
|
||||
dynamicTreeSecondaryPruner (PxDynamicTreeSecondaryPruner::eINCREMENTAL),
|
||||
staticBVHBuildStrategy (PxBVHBuildStrategy::eFAST),
|
||||
dynamicBVHBuildStrategy (PxBVHBuildStrategy::eFAST),
|
||||
staticNbObjectsPerNode (4),
|
||||
dynamicNbObjectsPerNode (4),
|
||||
sceneQueryUpdateMode (PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED)
|
||||
{
|
||||
}
|
||||
|
||||
PX_INLINE void PxSceneQueryDesc::setToDefault()
|
||||
{
|
||||
*this = PxSceneQueryDesc();
|
||||
}
|
||||
|
||||
PX_INLINE bool PxSceneQueryDesc::isValid() const
|
||||
{
|
||||
if(staticStructure!=PxPruningStructureType::eSTATIC_AABB_TREE && staticStructure!=PxPruningStructureType::eDYNAMIC_AABB_TREE)
|
||||
return false;
|
||||
|
||||
if(dynamicTreeRebuildRateHint < 4)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,656 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SCENE_QUERY_SYSTEM_H
|
||||
#define PX_SCENE_QUERY_SYSTEM_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxBitMap.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "PxSceneQueryDesc.h"
|
||||
#include "PxQueryReport.h"
|
||||
#include "PxQueryFiltering.h"
|
||||
#include "geometry/PxGeometryQueryFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxBaseTask;
|
||||
class PxRenderOutput;
|
||||
class PxGeometry;
|
||||
class PxRigidActor;
|
||||
class PxShape;
|
||||
class PxBVH;
|
||||
class PxPruningStructure;
|
||||
|
||||
/**
|
||||
\brief Built-in enum for default PxScene pruners
|
||||
|
||||
This is passed as a pruner index to various functions in the following APIs.
|
||||
|
||||
@see PxSceneQuerySystemBase::forceRebuildDynamicTree PxSceneQuerySystem::preallocate
|
||||
@see PxSceneQuerySystem::visualize PxSceneQuerySystem::sync PxSceneQuerySystem::prepareSceneQueryBuildStep
|
||||
*/
|
||||
enum PxScenePrunerIndex
|
||||
{
|
||||
PX_SCENE_PRUNER_STATIC = 0,
|
||||
PX_SCENE_PRUNER_DYNAMIC = 1,
|
||||
PX_SCENE_COMPOUND_PRUNER = 0xffffffff
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Base class for the scene-query system.
|
||||
|
||||
Methods defined here are common to both the traditional PxScene API and the PxSceneQuerySystem API.
|
||||
|
||||
@see PxScene PxSceneQuerySystem
|
||||
*/
|
||||
class PxSceneQuerySystemBase
|
||||
{
|
||||
protected:
|
||||
PxSceneQuerySystemBase() {}
|
||||
virtual ~PxSceneQuerySystemBase() {}
|
||||
|
||||
public:
|
||||
|
||||
/** @name Scene Query
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
\brief Sets the rebuild rate of the dynamic tree pruning structures.
|
||||
|
||||
\param[in] dynamicTreeRebuildRateHint Rebuild rate of the dynamic tree pruning structures.
|
||||
|
||||
@see PxSceneQueryDesc.dynamicTreeRebuildRateHint getDynamicTreeRebuildRateHint() forceRebuildDynamicTree()
|
||||
*/
|
||||
virtual void setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the rebuild rate of the dynamic tree pruning structures.
|
||||
|
||||
\return The rebuild rate of the dynamic tree pruning structures.
|
||||
|
||||
@see PxSceneQueryDesc.dynamicTreeRebuildRateHint setDynamicTreeRebuildRateHint() forceRebuildDynamicTree()
|
||||
*/
|
||||
virtual PxU32 getDynamicTreeRebuildRateHint() const = 0;
|
||||
|
||||
/**
|
||||
\brief Forces dynamic trees to be immediately rebuilt.
|
||||
|
||||
\param[in] prunerIndex Index of pruner containing the dynamic tree to rebuild
|
||||
|
||||
\note PxScene will call this function with the PX_SCENE_PRUNER_STATIC or PX_SCENE_PRUNER_DYNAMIC value.
|
||||
|
||||
@see PxSceneQueryDesc.dynamicTreeRebuildRateHint setDynamicTreeRebuildRateHint() getDynamicTreeRebuildRateHint()
|
||||
*/
|
||||
virtual void forceRebuildDynamicTree(PxU32 prunerIndex) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets scene query update mode
|
||||
|
||||
\param[in] updateMode Scene query update mode.
|
||||
|
||||
@see PxSceneQueryUpdateMode::Enum
|
||||
*/
|
||||
virtual void setUpdateMode(PxSceneQueryUpdateMode::Enum updateMode) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets scene query update mode
|
||||
|
||||
\return Current scene query update mode.
|
||||
|
||||
@see PxSceneQueryUpdateMode::Enum
|
||||
*/
|
||||
virtual PxSceneQueryUpdateMode::Enum getUpdateMode() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the system's internal scene query timestamp, increased each time a change to the
|
||||
static scene query structure is performed.
|
||||
|
||||
\return scene query static timestamp
|
||||
*/
|
||||
virtual PxU32 getStaticTimestamp() const = 0;
|
||||
|
||||
/**
|
||||
\brief Flushes any changes to the scene query representation.
|
||||
|
||||
This method updates the state of the scene query representation to match changes in the scene state.
|
||||
|
||||
By default, these changes are buffered until the next query is submitted. Calling this function will not change
|
||||
the results from scene queries, but can be used to ensure that a query will not perform update work in the course of
|
||||
its execution.
|
||||
|
||||
A thread performing updates will hold a write lock on the query structure, and thus stall other querying threads. In multithread
|
||||
scenarios it can be useful to explicitly schedule the period where this lock may be held for a significant period, so that
|
||||
subsequent queries issued from multiple threads will not block.
|
||||
*/
|
||||
virtual void flushUpdates() = 0;
|
||||
|
||||
/**
|
||||
\brief Performs a raycast against objects in the scene, returns results in a PxRaycastBuffer object
|
||||
or via a custom user callback implementation inheriting from PxRaycastCallback.
|
||||
|
||||
\note Touching hits are not ordered.
|
||||
\note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in user guide article SceneQuery. User can ignore such objects by employing one of the provided filter mechanisms.
|
||||
|
||||
\param[in] origin Origin of the ray.
|
||||
\param[in] unitDir Normalized direction of the ray.
|
||||
\param[in] distance Length of the ray. Has to be in the [0, inf) range.
|
||||
\param[out] hitCall Raycast hit buffer or callback object used to report raycast hits.
|
||||
\param[in] hitFlags Specifies which properties per hit should be computed and returned via the hit callback.
|
||||
\param[in] filterData Filtering data passed to the filter shader.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking.
|
||||
\param[in] cache Cached hit shape (optional). Ray is tested against cached shape first. If no hit is found the ray gets queried against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
|
||||
\return True if any touching or blocking hits were found or any hit was found in case PxQueryFlag::eANY_HIT was specified.
|
||||
|
||||
@see PxRaycastCallback PxRaycastBuffer PxQueryFilterData PxQueryFilterCallback PxQueryCache PxRaycastHit PxQueryFlag PxQueryFlag::eANY_HIT PxGeometryQueryFlag
|
||||
*/
|
||||
virtual bool raycast(const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
|
||||
PxRaycastCallback& hitCall, PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
|
||||
const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
|
||||
const PxQueryCache* cache = NULL, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
|
||||
|
||||
/**
|
||||
\brief Performs a sweep test against objects in the scene, returns results in a PxSweepBuffer object
|
||||
or via a custom user callback implementation inheriting from PxSweepCallback.
|
||||
|
||||
\note Touching hits are not ordered.
|
||||
\note If a shape from the scene is already overlapping with the query shape in its starting position,
|
||||
the hit is returned unless eASSUME_NO_INITIAL_OVERLAP was specified.
|
||||
|
||||
\param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex).
|
||||
\param[in] pose Pose of the sweep object.
|
||||
\param[in] unitDir Normalized direction of the sweep.
|
||||
\param[in] distance Sweep distance. Needs to be in [0, inf) range and >0 if eASSUME_NO_INITIAL_OVERLAP was specified. Will be clamped to PX_MAX_SWEEP_DISTANCE.
|
||||
\param[out] hitCall Sweep hit buffer or callback object used to report sweep hits.
|
||||
\param[in] hitFlags Specifies which properties per hit should be computed and returned via the hit callback.
|
||||
\param[in] filterData Filtering data and simple logic.
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking.
|
||||
\param[in] cache Cached hit shape (optional). Sweep is performed against cached shape first. If no hit is found the sweep gets queried against the scene.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
\param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
|
||||
Note: ePRECISE_SWEEP doesn't support inflation. Therefore the sweep will be performed with zero inflation.
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
|
||||
\return True if any touching or blocking hits were found or any hit was found in case PxQueryFlag::eANY_HIT was specified.
|
||||
|
||||
@see PxSweepCallback PxSweepBuffer PxQueryFilterData PxQueryFilterCallback PxSweepHit PxQueryCache PxGeometryQueryFlag
|
||||
*/
|
||||
virtual bool sweep( const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
|
||||
PxSweepCallback& hitCall, PxHitFlags hitFlags = PxHitFlag::eDEFAULT,
|
||||
const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
|
||||
const PxQueryCache* cache = NULL, const PxReal inflation = 0.0f, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
|
||||
|
||||
/**
|
||||
\brief Performs an overlap test of a given geometry against objects in the scene, returns results in a PxOverlapBuffer object
|
||||
or via a custom user callback implementation inheriting from PxOverlapCallback.
|
||||
|
||||
\note Filtering: returning eBLOCK from user filter for overlap queries will cause a warning (see #PxQueryHitType).
|
||||
|
||||
\param[in] geometry Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex).
|
||||
\param[in] pose Pose of the object.
|
||||
\param[out] hitCall Overlap hit buffer or callback object used to report overlap hits.
|
||||
\param[in] filterData Filtering data and simple logic. See #PxQueryFilterData #PxQueryFilterCallback
|
||||
\param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to overlap.
|
||||
\param[in] cache Cached hit shape (optional). Overlap is performed against cached shape first. If no hit is found the overlap gets queried against the scene.
|
||||
\param[in] queryFlags Optional flags controlling the query.
|
||||
Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
|
||||
Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking.
|
||||
|
||||
\return True if any touching or blocking hits were found or any hit was found in case PxQueryFlag::eANY_HIT was specified.
|
||||
|
||||
\note eBLOCK should not be returned from user filters for overlap(). Doing so will result in undefined behavior, and a warning will be issued.
|
||||
\note If the PxQueryFlag::eNO_BLOCK flag is set, the eBLOCK will instead be automatically converted to an eTOUCH and the warning suppressed.
|
||||
|
||||
@see PxOverlapCallback PxOverlapBuffer PxHitFlags PxQueryFilterData PxQueryFilterCallback PxGeometryQueryFlag
|
||||
*/
|
||||
virtual bool overlap(const PxGeometry& geometry, const PxTransform& pose, PxOverlapCallback& hitCall,
|
||||
const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
|
||||
const PxQueryCache* cache = NULL, PxGeometryQueryFlags queryFlags = PxGeometryQueryFlag::eDEFAULT) const = 0;
|
||||
//@}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Traditional SQ system for PxScene.
|
||||
|
||||
Methods defined here are only available through the traditional PxScene API.
|
||||
Thus PxSceneSQSystem effectively captures the scene-query related part of the PxScene API.
|
||||
|
||||
@see PxScene PxSceneQuerySystemBase
|
||||
*/
|
||||
class PxSceneSQSystem : public PxSceneQuerySystemBase
|
||||
{
|
||||
protected:
|
||||
PxSceneSQSystem() {}
|
||||
virtual ~PxSceneSQSystem() {}
|
||||
|
||||
public:
|
||||
|
||||
/** @name Scene Query
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
\brief Sets scene query update mode
|
||||
|
||||
\param[in] updateMode Scene query update mode.
|
||||
|
||||
@see PxSceneQueryUpdateMode::Enum
|
||||
*/
|
||||
PX_FORCE_INLINE void setSceneQueryUpdateMode(PxSceneQueryUpdateMode::Enum updateMode) { setUpdateMode(updateMode); }
|
||||
|
||||
/**
|
||||
\brief Gets scene query update mode
|
||||
|
||||
\return Current scene query update mode.
|
||||
|
||||
@see PxSceneQueryUpdateMode::Enum
|
||||
*/
|
||||
PX_FORCE_INLINE PxSceneQueryUpdateMode::Enum getSceneQueryUpdateMode() const { return getUpdateMode(); }
|
||||
|
||||
/**
|
||||
\brief Retrieves the scene's internal scene query timestamp, increased each time a change to the
|
||||
static scene query structure is performed.
|
||||
|
||||
\return scene query static timestamp
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getSceneQueryStaticTimestamp() const { return getStaticTimestamp(); }
|
||||
|
||||
/**
|
||||
\brief Flushes any changes to the scene query representation.
|
||||
|
||||
@see flushUpdates
|
||||
*/
|
||||
PX_FORCE_INLINE void flushQueryUpdates() { flushUpdates(); }
|
||||
|
||||
/**
|
||||
\brief Forces dynamic trees to be immediately rebuilt.
|
||||
|
||||
\param[in] rebuildStaticStructure True to rebuild the dynamic tree containing static objects
|
||||
\param[in] rebuildDynamicStructure True to rebuild the dynamic tree containing dynamic objects
|
||||
|
||||
@see PxSceneQueryDesc.dynamicTreeRebuildRateHint setDynamicTreeRebuildRateHint() getDynamicTreeRebuildRateHint()
|
||||
*/
|
||||
PX_FORCE_INLINE void forceDynamicTreeRebuild(bool rebuildStaticStructure, bool rebuildDynamicStructure)
|
||||
{
|
||||
if(rebuildStaticStructure)
|
||||
forceRebuildDynamicTree(PX_SCENE_PRUNER_STATIC);
|
||||
if(rebuildDynamicStructure)
|
||||
forceRebuildDynamicTree(PX_SCENE_PRUNER_DYNAMIC);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the value of PxSceneQueryDesc::staticStructure that was set when creating the scene with PxPhysics::createScene
|
||||
|
||||
@see PxSceneQueryDesc::staticStructure, PxPhysics::createScene
|
||||
*/
|
||||
virtual PxPruningStructureType::Enum getStaticStructure() const = 0;
|
||||
|
||||
/**
|
||||
\brief Return the value of PxSceneQueryDesc::dynamicStructure that was set when creating the scene with PxPhysics::createScene
|
||||
|
||||
@see PxSceneQueryDesc::dynamicStructure, PxPhysics::createScene
|
||||
*/
|
||||
virtual PxPruningStructureType::Enum getDynamicStructure() const = 0;
|
||||
|
||||
/**
|
||||
\brief Executes scene queries update tasks.
|
||||
|
||||
This function will refit dirty shapes within the pruner and will execute a task to build a new AABB tree, which is
|
||||
build on a different thread. The new AABB tree is built based on the dynamic tree rebuild hint rate. Once
|
||||
the new tree is ready it will be commited in next fetchQueries call, which must be called after.
|
||||
|
||||
This function is equivalent to the following PxSceneQuerySystem calls:
|
||||
Synchronous calls:
|
||||
- PxSceneQuerySystemBase::flushUpdates()
|
||||
- handle0 = PxSceneQuerySystem::prepareSceneQueryBuildStep(PX_SCENE_PRUNER_STATIC)
|
||||
- handle1 = PxSceneQuerySystem::prepareSceneQueryBuildStep(PX_SCENE_PRUNER_DYNAMIC)
|
||||
Asynchronous calls:
|
||||
- PxSceneQuerySystem::sceneQueryBuildStep(handle0);
|
||||
- PxSceneQuerySystem::sceneQueryBuildStep(handle1);
|
||||
|
||||
This function is part of the PxSceneSQSystem interface because it uses the PxScene task system under the hood. But
|
||||
it calls PxSceneQuerySystem functions, which are independent from this system and could be called in a similar
|
||||
fashion by a separate, possibly user-defined task manager.
|
||||
|
||||
\note If PxSceneQueryUpdateMode::eBUILD_DISABLED_COMMIT_DISABLED is used, it is required to update the scene queries
|
||||
using this function.
|
||||
|
||||
\param[in] completionTask if non-NULL, this task will have its refcount incremented in sceneQueryUpdate(), then
|
||||
decremented when the scene is ready to have fetchQueries called. So the task will not run until the
|
||||
application also calls removeReference().
|
||||
\param[in] controlSimulation if true, the scene controls its PxTaskManager simulation state. Leave
|
||||
true unless the application is calling the PxTaskManager start/stopSimulation() methods itself.
|
||||
|
||||
@see PxSceneQueryUpdateMode::eBUILD_DISABLED_COMMIT_DISABLED
|
||||
*/
|
||||
virtual void sceneQueriesUpdate(PxBaseTask* completionTask = NULL, bool controlSimulation = true) = 0;
|
||||
|
||||
/**
|
||||
\brief This checks to see if the scene queries update has completed.
|
||||
|
||||
This does not cause the data available for reading to be updated with the results of the scene queries update, it is simply a status check.
|
||||
The bool will allow it to either return immediately or block waiting for the condition to be met so that it can return true
|
||||
|
||||
\param[in] block When set to true will block until the condition is met.
|
||||
\return True if the results are available.
|
||||
|
||||
@see sceneQueriesUpdate() fetchResults()
|
||||
*/
|
||||
virtual bool checkQueries(bool block = false) = 0;
|
||||
|
||||
/**
|
||||
This method must be called after sceneQueriesUpdate. It will wait for the scene queries update to finish. If the user makes an illegal scene queries update call,
|
||||
the SDK will issue an error message.
|
||||
|
||||
If a new AABB tree build finished, then during fetchQueries the current tree within the pruning structure is swapped with the new tree.
|
||||
|
||||
\param[in] block When set to true will block until the condition is met, which is tree built task must finish running.
|
||||
*/
|
||||
virtual bool fetchQueries(bool block = false) = 0;
|
||||
//@}
|
||||
};
|
||||
|
||||
typedef PxU32 PxSQCompoundHandle;
|
||||
typedef PxU32 PxSQPrunerHandle;
|
||||
typedef void* PxSQBuildStepHandle;
|
||||
|
||||
/**
|
||||
\brief Scene-queries external sub-system for PxScene-based objects.
|
||||
|
||||
The default PxScene has hardcoded support for 2 regular pruners + 1 compound pruner, but these interfaces
|
||||
should work with multiple pruners.
|
||||
|
||||
Regular shapes are traditional PhysX shapes that belong to an actor. That actor can be a compound, i.e. it has
|
||||
more than one shape. *All of these go to the regular pruners*. This is important because it might be misleading:
|
||||
by default all shapes go to one of the two regular pruners, even shapes that belong to compound actors.
|
||||
|
||||
For compound actors, adding all the actor's shapes individually to the SQ system can be costly, since all the
|
||||
corresponding bounds will always move together and remain close together - that can put a lot of stress on the
|
||||
code that updates the SQ spatial structures. In these cases it can be more efficient to add the compound's bounds
|
||||
(i.e. the actor's bounds) to the system, as the first level of a bounds hierarchy. The scene queries would then
|
||||
be performed against the actor's bounds first, and only visit the shapes' bounds second. This is only useful
|
||||
for actors that have more than one shape, i.e. compound actors. Such actors added to the SQ system are thus
|
||||
called "SQ compounds". These objects are managed by the "compound pruner", which is only used when an explicit
|
||||
SQ compound is added to the SQ system via the addSQCompound call. So in the end one has to distinguish between:
|
||||
|
||||
- a "compound shape", which is added to regular pruners as its own individual entity.
|
||||
- an "SQ compound shape", which is added to the compound pruner as a subpart of an SQ compound actor.
|
||||
|
||||
A compound shape has an invalid compound ID, since it does not belong to an SQ compound.
|
||||
An SQ compound shape has a valid compound ID, that identifies its SQ compound owner.
|
||||
|
||||
@see PxScene PxSceneQuerySystemBase
|
||||
*/
|
||||
class PxSceneQuerySystem : public PxSceneQuerySystemBase
|
||||
{
|
||||
protected:
|
||||
PxSceneQuerySystem() {}
|
||||
virtual ~PxSceneQuerySystem() {}
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Decrements the reference count of the object and releases it if the new reference count is zero.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Acquires a counted reference to this object.
|
||||
|
||||
This method increases the reference count of the object by 1. Decrement the reference count by calling release()
|
||||
*/
|
||||
virtual void acquireReference() = 0;
|
||||
|
||||
/**
|
||||
\brief Preallocates internal arrays to minimize the amount of reallocations.
|
||||
|
||||
The system does not prevent more allocations than given numbers. It is legal to not call this function at all,
|
||||
or to add more shapes to the system than the preallocated amounts.
|
||||
|
||||
\param[in] prunerIndex Index of pruner to preallocate (PX_SCENE_PRUNER_STATIC, PX_SCENE_PRUNER_DYNAMIC or PX_SCENE_COMPOUND_PRUNER when called from PxScene).
|
||||
\param[in] nbShapes Expected number of (regular) shapes
|
||||
*/
|
||||
virtual void preallocate(PxU32 prunerIndex, PxU32 nbShapes) = 0;
|
||||
|
||||
/**
|
||||
\brief Frees internal memory that may not be in-use anymore.
|
||||
|
||||
This is an entry point for reclaiming transient memory allocated at some point by the SQ system,
|
||||
but which wasn't been immediately freed for performance reason. Calling this function might free
|
||||
some memory, but it might also produce a new set of allocations in the next frame.
|
||||
*/
|
||||
virtual void flushMemory() = 0;
|
||||
|
||||
/**
|
||||
\brief Adds a shape to the SQ system.
|
||||
|
||||
The same function is used to add either a regular shape, or a SQ compound shape.
|
||||
|
||||
\param[in] actor The shape's actor owner
|
||||
\param[in] shape The shape itself
|
||||
\param[in] bounds Shape bounds, in world-space for regular shapes, in local-space for SQ compound shapes.
|
||||
\param[in] transform Shape transform, in world-space for regular shapes, in local-space for SQ compound shapes.
|
||||
\param[in] compoundHandle Handle of SQ compound owner, or NULL for regular shapes.
|
||||
\param[in] hasPruningStructure True if the shape is part of a pruning structure. The structure will be merged later, adding the objects will not invalidate the pruner.
|
||||
|
||||
@see merge() PxPruningStructure
|
||||
*/
|
||||
virtual void addSQShape( const PxRigidActor& actor, const PxShape& shape, const PxBounds3& bounds,
|
||||
const PxTransform& transform, const PxSQCompoundHandle* compoundHandle=NULL, bool hasPruningStructure=false) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes a shape from the SQ system.
|
||||
|
||||
The same function is used to remove either a regular shape, or a SQ compound shape.
|
||||
|
||||
\param[in] actor The shape's actor owner
|
||||
\param[in] shape The shape itself
|
||||
*/
|
||||
virtual void removeSQShape(const PxRigidActor& actor, const PxShape& shape) = 0;
|
||||
|
||||
/**
|
||||
\brief Updates a shape in the SQ system.
|
||||
|
||||
The same function is used to update either a regular shape, or a SQ compound shape.
|
||||
|
||||
The transforms are eager-evaluated, but the bounds are lazy-evaluated. This means that
|
||||
the updated transform has to be passed to the update function, while the bounds are automatically
|
||||
recomputed by the system whenever needed.
|
||||
|
||||
\param[in] actor The shape's actor owner
|
||||
\param[in] shape The shape itself
|
||||
\param[in] transform New shape transform, in world-space for regular shapes, in local-space for SQ compound shapes.
|
||||
*/
|
||||
virtual void updateSQShape(const PxRigidActor& actor, const PxShape& shape, const PxTransform& transform) = 0;
|
||||
|
||||
/**
|
||||
\brief Adds a compound to the SQ system.
|
||||
|
||||
\param[in] actor The compound actor
|
||||
\param[in] shapes The compound actor's shapes
|
||||
\param[in] bvh BVH structure containing the compound's shapes in local space
|
||||
\param[in] transforms Shape transforms, in local-space
|
||||
|
||||
\return SQ compound handle
|
||||
|
||||
@see PxBVH PxCooking::createBVH
|
||||
*/
|
||||
virtual PxSQCompoundHandle addSQCompound(const PxRigidActor& actor, const PxShape** shapes, const PxBVH& bvh, const PxTransform* transforms) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes a compound from the SQ system.
|
||||
|
||||
\param[in] compoundHandle SQ compound handle (returned by addSQCompound)
|
||||
*/
|
||||
virtual void removeSQCompound(PxSQCompoundHandle compoundHandle) = 0;
|
||||
|
||||
/**
|
||||
\brief Updates a compound in the SQ system.
|
||||
|
||||
The compound structures are immediately updated when the call occurs.
|
||||
|
||||
\param[in] compoundHandle SQ compound handle (returned by addSQCompound)
|
||||
\param[in] compoundTransform New actor/compound transform, in world-space
|
||||
*/
|
||||
virtual void updateSQCompound(PxSQCompoundHandle compoundHandle, const PxTransform& compoundTransform) = 0;
|
||||
|
||||
/**
|
||||
\brief Shift the data structures' origin by the specified vector.
|
||||
|
||||
Please refer to the notes of the similar function in PxScene.
|
||||
|
||||
\param[in] shift Translation vector to shift the origin by.
|
||||
*/
|
||||
virtual void shiftOrigin(const PxVec3& shift) = 0;
|
||||
|
||||
/**
|
||||
\brief Visualizes the system's internal data-structures, for debugging purposes.
|
||||
|
||||
\param[in] prunerIndex Index of pruner to visualize (PX_SCENE_PRUNER_STATIC, PX_SCENE_PRUNER_DYNAMIC or PX_SCENE_COMPOUND_PRUNER when called from PxScene).
|
||||
|
||||
\param[out] out Filled with render output data
|
||||
|
||||
@see PxRenderOutput
|
||||
*/
|
||||
PX_DEPRECATED virtual void visualize(PxU32 prunerIndex, PxRenderOutput& out) const = 0;
|
||||
|
||||
/**
|
||||
\brief Merges a pruning structure with the SQ system's internal pruners.
|
||||
|
||||
\param[in] pruningStructure The pruning structure to merge
|
||||
|
||||
@see PxPruningStructure
|
||||
*/
|
||||
virtual void merge(const PxPruningStructure& pruningStructure) = 0;
|
||||
|
||||
/**
|
||||
\brief Shape to SQ-pruner-handle mapping function.
|
||||
|
||||
This function finds and returns the SQ pruner handle associated with a given (actor/shape) couple
|
||||
that was previously added to the system. This is needed for the sync function.
|
||||
|
||||
\param[in] actor The shape's actor owner
|
||||
\param[in] shape The shape itself
|
||||
\param[out] prunerIndex Index of pruner the shape belongs to
|
||||
|
||||
\return Associated SQ pruner handle.
|
||||
*/
|
||||
virtual PxSQPrunerHandle getHandle(const PxRigidActor& actor, const PxShape& shape, PxU32& prunerIndex) const = 0;
|
||||
|
||||
/**
|
||||
\brief Synchronizes the scene-query system with another system that references the same objects.
|
||||
|
||||
This function is used when the scene-query objects also exist in another system that can also update them. For example the scene-query objects
|
||||
(used for raycast, overlap or sweep queries) might be driven by equivalent objects in an external rigid-body simulation engine. In this case
|
||||
the rigid-body simulation engine computes the new poses and transforms, and passes them to the scene-query system using this function. It is
|
||||
more efficient than calling updateSQShape on each object individually, since updateSQShape would end up recomputing the bounds already available
|
||||
in the rigid-body engine.
|
||||
|
||||
\param[in] prunerIndex Index of pruner being synched (PX_SCENE_PRUNER_DYNAMIC for regular PhysX usage)
|
||||
\param[in] handles Handles of updated objects
|
||||
\param[in] indices Bounds & transforms indices of updated objects, i.e. object handles[i] has bounds[indices[i]] and transforms[indices[i]]
|
||||
\param[in] bounds Array of bounds for all objects (not only updated bounds)
|
||||
\param[in] transforms Array of transforms for all objects (not only updated transforms)
|
||||
\param[in] count Number of updated objects
|
||||
\param[in] ignoredIndices Optional bitmap of ignored indices, i.e. update is skipped if ignoredIndices[indices[i]] is set.
|
||||
|
||||
@see PxBounds3 PxTransform32 PxBitMap
|
||||
*/
|
||||
virtual void sync(PxU32 prunerIndex, const PxSQPrunerHandle* handles, const PxU32* indices, const PxBounds3* bounds, const PxTransform32* transforms, PxU32 count, const PxBitMap& ignoredIndices) = 0;
|
||||
|
||||
/**
|
||||
\brief Finalizes updates made to the SQ system.
|
||||
|
||||
This function should be called after updates have been made to the SQ system, to fully reflect the changes
|
||||
inside the internal pruners. In particular it should be called:
|
||||
- after calls to updateSQShape
|
||||
- after calls to sync
|
||||
|
||||
This function:
|
||||
- recomputes bounds of manually updated shapes (i.e. either regular or SQ compound shapes modified by updateSQShape)
|
||||
- updates dynamic pruners (refit operations)
|
||||
- incrementally rebuilds AABB-trees
|
||||
|
||||
The amount of work performed in this function depends on PxSceneQueryUpdateMode.
|
||||
|
||||
@see PxSceneQueryUpdateMode updateSQShape() sync()
|
||||
*/
|
||||
virtual void finalizeUpdates() = 0;
|
||||
|
||||
/**
|
||||
\brief Prepares asynchronous build step.
|
||||
|
||||
This is directly called (synchronously) by PxSceneSQSystem::sceneQueriesUpdate(). See the comments there.
|
||||
|
||||
This function is called to let the system execute any necessary synchronous operation before the
|
||||
asynchronous sceneQueryBuildStep() function is called.
|
||||
|
||||
If there is any work to do for the specific pruner, the function returns a pruner-specific handle that
|
||||
will be passed to the corresponding, asynchronous sceneQueryBuildStep function.
|
||||
|
||||
\return A pruner-specific handle that will be sent to sceneQueryBuildStep if there is any work to do, i.e. to execute the corresponding sceneQueryBuildStep() call.
|
||||
|
||||
\param[in] prunerIndex Index of pruner being built. (PX_SCENE_PRUNER_STATIC or PX_SCENE_PRUNER_DYNAMIC when called by PxScene).
|
||||
|
||||
\return Null if there is no work to do, otherwise a pruner-specific handle.
|
||||
|
||||
@see PxSceneSQSystem::sceneQueriesUpdate sceneQueryBuildStep
|
||||
*/
|
||||
virtual PxSQBuildStepHandle prepareSceneQueryBuildStep(PxU32 prunerIndex) = 0;
|
||||
|
||||
/**
|
||||
\brief Executes asynchronous build step.
|
||||
|
||||
This is directly called (asynchronously) by PxSceneSQSystem::sceneQueriesUpdate(). See the comments there.
|
||||
|
||||
This function incrementally builds the internal trees/pruners. It is called asynchronously, i.e. this can be
|
||||
called from different threads for building multiple trees at the same time.
|
||||
|
||||
\param[in] handle Pruner-specific handle previously returned by the prepareSceneQueryBuildStep function.
|
||||
|
||||
@see PxSceneSQSystem::sceneQueriesUpdate prepareSceneQueryBuildStep
|
||||
*/
|
||||
virtual void sceneQueryBuildStep(PxSQBuildStepHandle handle) = 0;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
794
modules/PhysX/physx/physx-sys/physx/physx/include/PxShape.h
Normal file
794
modules/PhysX/physx/physx-sys/physx/physx/include/PxShape.h
Normal file
@@ -0,0 +1,794 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SHAPE_H
|
||||
#define PX_SHAPE_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "common/PxBase.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
#include "geometry/PxGeometryHelpers.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxBoxGeometry;
|
||||
class PxSphereGeometry;
|
||||
class PxCapsuleGeometry;
|
||||
class PxPlaneGeometry;
|
||||
class PxConvexMeshGeometry;
|
||||
class PxTriangleMeshGeometry;
|
||||
class PxTetrahedronMeshGeometry;
|
||||
class PxHeightFieldGeometry;
|
||||
class PxParticleSystemGeometry;
|
||||
class PxHairSystemGeometry;
|
||||
class PxRigidActor;
|
||||
struct PxFilterData;
|
||||
class PxBaseMaterial;
|
||||
class PxMaterial;
|
||||
class PxFEMSoftBodyMaterial;
|
||||
class PxFEMClothMaterial;
|
||||
|
||||
/**
|
||||
\brief Flags which affect the behavior of PxShapes.
|
||||
|
||||
@see PxShape PxShape.setFlag()
|
||||
*/
|
||||
struct PxShapeFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief The shape will partake in collision in the physical simulation.
|
||||
|
||||
\note It is illegal to raise the eSIMULATION_SHAPE and eTRIGGER_SHAPE flags.
|
||||
In the event that one of these flags is already raised the sdk will reject any
|
||||
attempt to raise the other. To raise the eSIMULATION_SHAPE first ensure that
|
||||
eTRIGGER_SHAPE is already lowered.
|
||||
|
||||
\note This flag has no effect if simulation is disabled for the corresponding actor (see #PxActorFlag::eDISABLE_SIMULATION).
|
||||
|
||||
@see PxSimulationEventCallback.onContact() PxScene.setSimulationEventCallback() PxShape.setFlag(), PxShape.setFlags()
|
||||
*/
|
||||
eSIMULATION_SHAPE = (1<<0),
|
||||
|
||||
/**
|
||||
\brief The shape will partake in scene queries (ray casts, overlap tests, sweeps, ...).
|
||||
*/
|
||||
eSCENE_QUERY_SHAPE = (1<<1),
|
||||
|
||||
/**
|
||||
\brief The shape is a trigger which can send reports whenever other shapes enter/leave its volume.
|
||||
|
||||
\note Triangle meshes and heightfields can not be triggers. Shape creation will fail in these cases.
|
||||
|
||||
\note Shapes marked as triggers do not collide with other objects. If an object should act both
|
||||
as a trigger shape and a collision shape then create a rigid body with two shapes, one being a
|
||||
trigger shape and the other a collision shape. It is illegal to raise the eTRIGGER_SHAPE and
|
||||
eSIMULATION_SHAPE flags on a single PxShape instance. In the event that one of these flags is already
|
||||
raised the sdk will reject any attempt to raise the other. To raise the eTRIGGER_SHAPE flag first
|
||||
ensure that eSIMULATION_SHAPE flag is already lowered.
|
||||
|
||||
\note Trigger shapes will no longer send notification events for interactions with other trigger shapes.
|
||||
|
||||
\note Shapes marked as triggers are allowed to participate in scene queries, provided the eSCENE_QUERY_SHAPE flag is set.
|
||||
|
||||
\note This flag has no effect if simulation is disabled for the corresponding actor (see #PxActorFlag::eDISABLE_SIMULATION).
|
||||
|
||||
@see PxSimulationEventCallback.onTrigger() PxScene.setSimulationEventCallback() PxShape.setFlag(), PxShape.setFlags()
|
||||
*/
|
||||
eTRIGGER_SHAPE = (1<<2),
|
||||
|
||||
/**
|
||||
\brief Enable debug renderer for this shape
|
||||
|
||||
@see PxScene.getRenderBuffer() PxRenderBuffer PxVisualizationParameter
|
||||
*/
|
||||
eVISUALIZATION = (1<<3)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief collection of set bits defined in PxShapeFlag.
|
||||
|
||||
@see PxShapeFlag
|
||||
*/
|
||||
typedef PxFlags<PxShapeFlag::Enum,PxU8> PxShapeFlags;
|
||||
PX_FLAGS_OPERATORS(PxShapeFlag::Enum,PxU8)
|
||||
|
||||
/**
|
||||
\brief Abstract class for collision shapes.
|
||||
|
||||
Shapes are shared, reference counted objects.
|
||||
|
||||
An instance can be created by calling the createShape() method of the PxRigidActor class, or
|
||||
the createShape() method of the PxPhysics class.
|
||||
|
||||
<h3>Visualizations</h3>
|
||||
\li PxVisualizationParameter::eCOLLISION_AABBS
|
||||
\li PxVisualizationParameter::eCOLLISION_SHAPES
|
||||
\li PxVisualizationParameter::eCOLLISION_AXES
|
||||
|
||||
@see PxPhysics.createShape() PxRigidActor.createShape() PxBoxGeometry PxSphereGeometry PxCapsuleGeometry PxPlaneGeometry PxConvexMeshGeometry
|
||||
PxTriangleMeshGeometry PxHeightFieldGeometry
|
||||
*/
|
||||
class PxShape : public PxRefCounted
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Decrements the reference count of a shape and releases it if the new reference count is zero.
|
||||
|
||||
Note that in releases prior to PhysX 3.3 this method did not have reference counting semantics and was used to destroy a shape
|
||||
created with PxActor::createShape(). In PhysX 3.3 and above, this usage is deprecated, instead, use PxRigidActor::detachShape() to detach
|
||||
a shape from an actor. If the shape to be detached was created with PxActor::createShape(), the actor holds the only counted reference,
|
||||
and so when the shape is detached it will also be destroyed.
|
||||
|
||||
@see PxRigidActor::createShape() PxPhysics::createShape() PxRigidActor::attachShape() PxRigidActor::detachShape()
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Adjust the geometry of the shape.
|
||||
|
||||
\note The type of the passed in geometry must match the geometry type of the shape.
|
||||
\note It is not allowed to change the geometry type of a shape.
|
||||
\note This function does not guarantee correct/continuous behavior when objects are resting on top of old or new geometry.
|
||||
|
||||
\param[in] geometry New geometry of the shape.
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
*/
|
||||
virtual void setGeometry(const PxGeometry& geometry) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve a reference to the shape's geometry.
|
||||
|
||||
\warning The returned reference has the same lifetime as the PxShape it comes from.
|
||||
|
||||
\return Reference to internal PxGeometry object.
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType() setGeometry()
|
||||
*/
|
||||
virtual const PxGeometry& getGeometry() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the geometry type of the shape.
|
||||
|
||||
\return Type of shape geometry.
|
||||
|
||||
@see PxGeometryType
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE PxGeometryType::Enum getGeometryType() const
|
||||
{
|
||||
return getGeometry().getType();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getBoxGeometry(PxBoxGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::eBOX, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getSphereGeometry(PxSphereGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::eSPHERE, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getCapsuleGeometry(PxCapsuleGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::eCAPSULE, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getPlaneGeometry(PxPlaneGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::ePLANE, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getConvexMeshGeometry(PxConvexMeshGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::eCONVEXMESH, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getTriangleMeshGeometry(PxTriangleMeshGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::eTRIANGLEMESH, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getTetrahedronMeshGeometry(PxTetrahedronMeshGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::eTETRAHEDRONMESH, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getParticleSystemGeometry(PxParticleSystemGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::ePARTICLESYSTEM, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getHeightFieldGeometry(PxHeightFieldGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::eHEIGHTFIELD, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Fetch the geometry of the shape.
|
||||
|
||||
\note If the type of geometry to extract does not match the geometry type of the shape
|
||||
then the method will return false and the passed in geometry descriptor is not modified.
|
||||
|
||||
\param[in] geometry The descriptor to save the shape's geometry data to.
|
||||
\return True on success else false
|
||||
|
||||
@see PxGeometry PxGeometryType getGeometryType()
|
||||
@deprecated
|
||||
*/
|
||||
PX_DEPRECATED PX_FORCE_INLINE bool getCustomGeometry(PxCustomGeometry& geometry) const
|
||||
{
|
||||
return getGeometryT(PxGeometryType::eCUSTOM, geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Retrieves the actor which this shape is associated with.
|
||||
|
||||
\return The actor this shape is associated with, if it is an exclusive shape, else NULL
|
||||
|
||||
@see PxRigidStatic, PxRigidDynamic, PxArticulationLink
|
||||
*/
|
||||
virtual PxRigidActor* getActor() const = 0;
|
||||
|
||||
/************************************************************************************************/
|
||||
|
||||
/** @name Pose Manipulation
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
\brief Sets the pose of the shape in actor space, i.e. relative to the actors to which they are attached.
|
||||
|
||||
This transformation is identity by default.
|
||||
|
||||
The local pose is an attribute of the shape, and so will apply to all actors to which the shape is attached.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the associated actor up automatically.
|
||||
|
||||
<i>Note:</i> Does not automatically update the inertia properties of the owning actor (if applicable); use the
|
||||
PhysX extensions method #PxRigidBodyExt::updateMassAndInertia() to do this.
|
||||
|
||||
<b>Default:</b> the identity transform
|
||||
|
||||
\param[in] pose The new transform from the actor frame to the shape frame. <b>Range:</b> rigid body transform
|
||||
|
||||
@see getLocalPose()
|
||||
*/
|
||||
virtual void setLocalPose(const PxTransform& pose) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the pose of the shape in actor space, i.e. relative to the actor they are owned by.
|
||||
|
||||
This transformation is identity by default.
|
||||
|
||||
\return Pose of shape relative to the actor's frame.
|
||||
|
||||
@see setLocalPose()
|
||||
*/
|
||||
virtual PxTransform getLocalPose() const = 0;
|
||||
|
||||
//@}
|
||||
/************************************************************************************************/
|
||||
|
||||
/** @name Collision Filtering
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
\brief Sets the user definable collision filter data.
|
||||
|
||||
<b>Sleeping:</b> Does wake up the actor if the filter data change causes a formerly suppressed
|
||||
collision pair to be enabled.
|
||||
|
||||
<b>Default:</b> (0,0,0,0)
|
||||
|
||||
@see getSimulationFilterData()
|
||||
*/
|
||||
virtual void setSimulationFilterData(const PxFilterData& data) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the shape's collision filter data.
|
||||
|
||||
@see setSimulationFilterData()
|
||||
*/
|
||||
virtual PxFilterData getSimulationFilterData() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the user definable query filter data.
|
||||
|
||||
<b>Default:</b> (0,0,0,0)
|
||||
|
||||
@see getQueryFilterData()
|
||||
*/
|
||||
virtual void setQueryFilterData(const PxFilterData& data) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the shape's Query filter data.
|
||||
|
||||
@see setQueryFilterData()
|
||||
*/
|
||||
virtual PxFilterData getQueryFilterData() const = 0;
|
||||
|
||||
//@}
|
||||
/************************************************************************************************/
|
||||
|
||||
/**
|
||||
\brief Assigns material(s) to the shape. Will remove existing materials from the shape.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the associated actor up automatically.
|
||||
|
||||
\param[in] materials List of material pointers to assign to the shape. See #PxMaterial
|
||||
\param[in] materialCount The number of materials provided.
|
||||
|
||||
@see PxPhysics.createMaterial() getMaterials()
|
||||
*/
|
||||
virtual void setMaterials(PxMaterial*const* materials, PxU16 materialCount) = 0;
|
||||
|
||||
/**
|
||||
\brief Assigns FEM soft body material(s) to the shape. Will remove existing materials from the shape.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the associated actor up automatically.
|
||||
|
||||
\param[in] materials List of material pointers to assign to the shape. See #PxFEMSoftBodyMaterial
|
||||
\param[in] materialCount The number of materials provided.
|
||||
|
||||
@see PxPhysics.createFEMSoftBodyMaterial() getSoftBodyMaterials()
|
||||
*/
|
||||
PX_DEPRECATED virtual void setSoftBodyMaterials(PxFEMSoftBodyMaterial*const* materials, PxU16 materialCount) = 0;
|
||||
|
||||
/**
|
||||
\brief Assigns FEM cloth material(s) to the shape. Will remove existing materials from the shape.
|
||||
\warning Feature under development, only for internal usage.
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the associated actor up automatically.
|
||||
|
||||
\param[in] materials List of material pointers to assign to the shape. See #PxFEMClothMaterial
|
||||
\param[in] materialCount The number of materials provided.
|
||||
|
||||
@see PxPhysics.createFEMClothMaterial() getClothMaterials()
|
||||
*/
|
||||
PX_DEPRECATED virtual void setClothMaterials(PxFEMClothMaterial*const* materials, PxU16 materialCount) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of materials assigned to the shape.
|
||||
|
||||
You can use #getMaterials() to retrieve the material pointers.
|
||||
|
||||
\return Number of materials associated with this shape.
|
||||
|
||||
@see PxMaterial getMaterials()
|
||||
*/
|
||||
virtual PxU16 getNbMaterials() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve all the material pointers associated with the shape.
|
||||
|
||||
You can retrieve the number of material pointers by calling #getNbMaterials()
|
||||
|
||||
Note: The returned data may contain invalid pointers if you release materials using #PxMaterial::release().
|
||||
|
||||
\param[out] userBuffer The buffer to store the material pointers.
|
||||
\param[in] bufferSize Size of provided user buffer.
|
||||
\param[in] startIndex Index of first material pointer to be retrieved
|
||||
\return Number of material pointers written to the buffer.
|
||||
|
||||
@see PxMaterial getNbMaterials() PxMaterial::release()
|
||||
*/
|
||||
virtual PxU32 getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve all the FEM soft body material pointers associated with the shape.
|
||||
|
||||
You can retrieve the number of material pointers by calling #getNbMaterials()
|
||||
|
||||
Note: The returned data may contain invalid pointers if you release materials using #PxMaterial::release().
|
||||
|
||||
\param[out] userBuffer The buffer to store the material pointers.
|
||||
\param[in] bufferSize Size of provided user buffer.
|
||||
\param[in] startIndex Index of first material pointer to be retrieved
|
||||
\return Number of material pointers written to the buffer.
|
||||
|
||||
@see PxFEMSoftBodyMaterial getNbMaterials() PxMaterial::release()
|
||||
*/
|
||||
PX_DEPRECATED virtual PxU32 getSoftBodyMaterials(PxFEMSoftBodyMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve all the FEM cloth material pointers associated with the shape.
|
||||
\warning Feature under development, only for internal usage.
|
||||
|
||||
You can retrieve the number of material pointers by calling #getNbMaterials()
|
||||
|
||||
Note: The returned data may contain invalid pointers if you release materials using #PxMaterial::release().
|
||||
|
||||
\param[out] userBuffer The buffer to store the material pointers.
|
||||
\param[in] bufferSize Size of provided user buffer.
|
||||
\param[in] startIndex Index of first material pointer to be retrieved
|
||||
\return Number of material pointers written to the buffer.
|
||||
|
||||
@see PxFEMClothMaterial getNbMaterials() PxMaterial::release()
|
||||
*/
|
||||
PX_DEPRECATED virtual PxU32 getClothMaterials(PxFEMClothMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve material from given triangle index.
|
||||
|
||||
The input index is the internal triangle index as used inside the SDK. This is the index
|
||||
returned to users by various SDK functions such as raycasts.
|
||||
|
||||
This function is only useful for triangle meshes or heightfields, which have per-triangle
|
||||
materials. For other shapes or SDF triangle meshes, the function returns the single material
|
||||
associated with the shape, regardless of the index.
|
||||
|
||||
\param[in] faceIndex The internal triangle index whose material you want to retrieve.
|
||||
\return Material from input triangle
|
||||
|
||||
\note If faceIndex value of 0xFFFFffff is passed as an input for mesh and heightfield shapes, this function will issue a warning and return NULL.
|
||||
\note Scene queries set the value of PxQueryHit::faceIndex to 0xFFFFffff whenever it is undefined or does not apply.
|
||||
|
||||
@see PxMaterial getNbMaterials() PxMaterial::release()
|
||||
*/
|
||||
virtual PxBaseMaterial* getMaterialFromInternalFaceIndex(PxU32 faceIndex) const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the contact offset.
|
||||
|
||||
Shapes whose distance is less than the sum of their contactOffset values will generate contacts. The contact offset must be positive and
|
||||
greater than the rest offset. Having a contactOffset greater than than the restOffset allows the collision detection system to
|
||||
predictively enforce the contact constraint even when the objects are slightly separated. This prevents jitter that would occur
|
||||
if the constraint were enforced only when shapes were within the rest distance.
|
||||
|
||||
<b>Default:</b> 0.02f * PxTolerancesScale::length
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the associated actor up automatically.
|
||||
|
||||
\param[in] contactOffset <b>Range:</b> [maximum(0,restOffset), PX_MAX_F32)
|
||||
|
||||
@see getContactOffset PxTolerancesScale setRestOffset
|
||||
*/
|
||||
virtual void setContactOffset(PxReal contactOffset) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the contact offset.
|
||||
|
||||
\return The contact offset of the shape.
|
||||
|
||||
@see setContactOffset()
|
||||
*/
|
||||
virtual PxReal getContactOffset() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the rest offset.
|
||||
|
||||
Two shapes will come to rest at a distance equal to the sum of their restOffset values. If the restOffset is 0, they should converge to touching
|
||||
exactly. Having a restOffset greater than zero is useful to have objects slide smoothly, so that they do not get hung up on irregularities of
|
||||
each others' surfaces.
|
||||
|
||||
<b>Default:</b> 0.0f
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the associated actor up automatically.
|
||||
|
||||
\param[in] restOffset <b>Range:</b> (-PX_MAX_F32, contactOffset)
|
||||
|
||||
@see getRestOffset setContactOffset
|
||||
*/
|
||||
virtual void setRestOffset(PxReal restOffset) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the rest offset.
|
||||
|
||||
\return The rest offset of the shape.
|
||||
|
||||
@see setRestOffset()
|
||||
*/
|
||||
virtual PxReal getRestOffset() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the density used to interact with fluids.
|
||||
|
||||
To be physically accurate, the density of a rigid body should be computed as its mass divided by its volume. To
|
||||
simplify tuning the interaction of fluid and rigid bodies, the density for fluid can differ from the real density. This
|
||||
allows to create floating bodies, even if they are supposed to sink with their mass and volume.
|
||||
|
||||
<b>Default:</b> 800.0f
|
||||
|
||||
\param[in] densityForFluid <b>Range:</b> (0, PX_MAX_F32)
|
||||
|
||||
@see getDensityForFluid
|
||||
*/
|
||||
virtual void setDensityForFluid(PxReal densityForFluid) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the density used to interact with fluids.
|
||||
|
||||
\return The density of the body when interacting with fluid.
|
||||
|
||||
@see setDensityForFluid()
|
||||
*/
|
||||
virtual PxReal getDensityForFluid() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets torsional patch radius.
|
||||
|
||||
This defines the radius of the contact patch used to apply torsional friction. If the radius is 0, no torsional friction
|
||||
will be applied. If the radius is > 0, some torsional friction will be applied. This is proportional to the penetration depth
|
||||
so, if the shapes are separated or penetration is zero, no torsional friction will be applied. It is used to approximate
|
||||
rotational friction introduced by the compression of contacting surfaces.
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
\param[in] radius <b>Range:</b> (0, PX_MAX_F32)
|
||||
*/
|
||||
virtual void setTorsionalPatchRadius(PxReal radius) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets torsional patch radius.
|
||||
|
||||
This defines the radius of the contact patch used to apply torsional friction. If the radius is 0, no torsional friction
|
||||
will be applied. If the radius is > 0, some torsional friction will be applied. This is proportional to the penetration depth
|
||||
so, if the shapes are separated or penetration is zero, no torsional friction will be applied. It is used to approximate
|
||||
rotational friction introduced by the compression of contacting surfaces.
|
||||
|
||||
\return The torsional patch radius of the shape.
|
||||
*/
|
||||
virtual PxReal getTorsionalPatchRadius() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets minimum torsional patch radius.
|
||||
|
||||
This defines the minimum radius of the contact patch used to apply torsional friction. If the radius is 0, the amount of torsional friction
|
||||
that will be applied will be entirely dependent on the value of torsionalPatchRadius.
|
||||
|
||||
If the radius is > 0, some torsional friction will be applied regardless of the value of torsionalPatchRadius or the amount of penetration.
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
\param[in] radius <b>Range:</b> (0, PX_MAX_F32)
|
||||
*/
|
||||
virtual void setMinTorsionalPatchRadius(PxReal radius) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets minimum torsional patch radius.
|
||||
|
||||
This defines the minimum radius of the contact patch used to apply torsional friction. If the radius is 0, the amount of torsional friction
|
||||
that will be applied will be entirely dependent on the value of torsionalPatchRadius.
|
||||
|
||||
If the radius is > 0, some torsional friction will be applied regardless of the value of torsionalPatchRadius or the amount of penetration.
|
||||
|
||||
\return The minimum torsional patch radius of the shape.
|
||||
*/
|
||||
virtual PxReal getMinTorsionalPatchRadius() const = 0;
|
||||
|
||||
/************************************************************************************************/
|
||||
|
||||
/**
|
||||
\brief Sets shape flags
|
||||
|
||||
<b>Sleeping:</b> Does <b>NOT</b> wake the associated actor up automatically.
|
||||
|
||||
\param[in] flag The shape flag to enable/disable. See #PxShapeFlag.
|
||||
\param[in] value True to set the flag. False to clear the flag specified in flag.
|
||||
|
||||
<b>Default:</b> PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSIMULATION_SHAPE | PxShapeFlag::eSCENE_QUERY_SHAPE
|
||||
|
||||
@see PxShapeFlag getFlags()
|
||||
*/
|
||||
virtual void setFlag(PxShapeFlag::Enum flag, bool value) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets shape flags
|
||||
|
||||
@see PxShapeFlag getFlags()
|
||||
*/
|
||||
virtual void setFlags(PxShapeFlags inFlags) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves shape flags.
|
||||
|
||||
\return The values of the shape flags.
|
||||
|
||||
@see PxShapeFlag setFlag()
|
||||
*/
|
||||
virtual PxShapeFlags getFlags() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns true if the shape is exclusive to an actor.
|
||||
|
||||
@see PxPhysics::createShape()
|
||||
*/
|
||||
virtual bool isExclusive() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets a name string for the object that can be retrieved with #getName().
|
||||
|
||||
This is for debugging and is not used by the SDK.
|
||||
The string is not copied by the SDK, only the pointer is stored.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
|
||||
\param[in] name The name string to set the objects name to.
|
||||
|
||||
@see getName()
|
||||
*/
|
||||
virtual void setName(const char* name) = 0;
|
||||
|
||||
/**
|
||||
\brief retrieves the name string set with setName().
|
||||
\return The name associated with the shape.
|
||||
|
||||
@see setName()
|
||||
*/
|
||||
virtual const char* getName() const = 0;
|
||||
|
||||
|
||||
virtual const char* getConcreteTypeName() const { return "PxShape"; }
|
||||
|
||||
/************************************************************************************************/
|
||||
|
||||
void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
|
||||
|
||||
protected:
|
||||
PX_INLINE PxShape(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
|
||||
PX_INLINE PxShape(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags), userData(NULL) {}
|
||||
virtual ~PxShape() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxShape", name) || PxRefCounted::isKindOf(name); }
|
||||
|
||||
template<class T>
|
||||
PX_FORCE_INLINE bool getGeometryT(PxGeometryType::Enum type, T& geom) const
|
||||
{
|
||||
if(getGeometryType() != type)
|
||||
return false;
|
||||
|
||||
geom = static_cast<const T&>(getGeometry());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,909 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SIMULATION_EVENT_CALLBACK_H
|
||||
#define PX_SIMULATION_EVENT_CALLBACK_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "PxFiltering.h"
|
||||
#include "PxContact.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxShape;
|
||||
class PxActor;
|
||||
class PxRigidActor;
|
||||
class PxRigidBody;
|
||||
class PxConstraint;
|
||||
|
||||
|
||||
/**
|
||||
\brief Extra data item types for contact pairs.
|
||||
|
||||
@see PxContactPairExtraDataItem.type
|
||||
*/
|
||||
struct PxContactPairExtraDataType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
ePRE_SOLVER_VELOCITY, //!< see #PxContactPairVelocity
|
||||
ePOST_SOLVER_VELOCITY, //!< see #PxContactPairVelocity
|
||||
eCONTACT_EVENT_POSE, //!< see #PxContactPairPose
|
||||
eCONTACT_PAIR_INDEX //!< see #PxContactPairIndex
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Base class for items in the extra data stream of contact pairs
|
||||
|
||||
@see PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
struct PxContactPairExtraDataItem
|
||||
{
|
||||
public:
|
||||
PX_FORCE_INLINE PxContactPairExtraDataItem() {}
|
||||
|
||||
/**
|
||||
\brief The type of the extra data stream item
|
||||
*/
|
||||
PxU8 type;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Velocities of the contact pair rigid bodies
|
||||
|
||||
This struct is shared by multiple types of extra data items. The #type field allows to distinguish between them:
|
||||
\li PxContactPairExtraDataType::ePRE_SOLVER_VELOCITY: see #PxPairFlag::ePRE_SOLVER_VELOCITY
|
||||
\li PxContactPairExtraDataType::ePOST_SOLVER_VELOCITY: see #PxPairFlag::ePOST_SOLVER_VELOCITY
|
||||
|
||||
\note For static rigid bodies, the velocities will be set to zero.
|
||||
|
||||
@see PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
struct PxContactPairVelocity : public PxContactPairExtraDataItem
|
||||
{
|
||||
public:
|
||||
PX_FORCE_INLINE PxContactPairVelocity() {}
|
||||
|
||||
/**
|
||||
\brief The linear velocity of the rigid bodies
|
||||
*/
|
||||
PxVec3 linearVelocity[2];
|
||||
|
||||
/**
|
||||
\brief The angular velocity of the rigid bodies
|
||||
*/
|
||||
PxVec3 angularVelocity[2];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief World space actor poses of the contact pair rigid bodies
|
||||
|
||||
@see PxContactPairHeader.extraDataStream PxPairFlag::eCONTACT_EVENT_POSE
|
||||
*/
|
||||
struct PxContactPairPose : public PxContactPairExtraDataItem
|
||||
{
|
||||
public:
|
||||
PX_FORCE_INLINE PxContactPairPose() {}
|
||||
|
||||
/**
|
||||
\brief The world space pose of the rigid bodies
|
||||
*/
|
||||
PxTransform globalPose[2];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Marker for the beginning of a new item set in the extra data stream.
|
||||
|
||||
If CCD with multiple passes is enabled, then a fast moving object might bounce on and off the same
|
||||
object multiple times. Also, different shapes of the same actor might gain and lose contact with an other
|
||||
object over multiple passes. This marker allows to separate the extra data items for each collision case, as well as
|
||||
distinguish the shape pair reports of different CCD passes.
|
||||
|
||||
Example:
|
||||
Let us assume that an actor a0 with shapes s0_0 and s0_1 hits another actor a1 with shape s1.
|
||||
First s0_0 will hit s1, then a0 will slightly rotate and s0_1 will hit s1 while s0_0 will lose contact with s1.
|
||||
Furthermore, let us say that contact event pose information is requested as extra data.
|
||||
The extra data stream will look like this:
|
||||
|
||||
PxContactPairIndexA | PxContactPairPoseA | PxContactPairIndexB | PxContactPairPoseB
|
||||
|
||||
The corresponding array of PxContactPair events (see #PxSimulationEventCallback.onContact()) will look like this:
|
||||
|
||||
PxContactPair(touch_found: s0_0, s1) | PxContactPair(touch_lost: s0_0, s1) | PxContactPair(touch_found: s0_1, s1)
|
||||
|
||||
The #index of PxContactPairIndexA will point to the first entry in the PxContactPair array, for PxContactPairIndexB,
|
||||
#index will point to the third entry.
|
||||
|
||||
@see PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
struct PxContactPairIndex : public PxContactPairExtraDataItem
|
||||
{
|
||||
public:
|
||||
PX_FORCE_INLINE PxContactPairIndex() {}
|
||||
|
||||
/**
|
||||
\brief The next item set in the extra data stream refers to the contact pairs starting at #index in the reported PxContactPair array.
|
||||
*/
|
||||
PxU16 index;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief A class to iterate over a contact pair extra data stream.
|
||||
|
||||
@see PxContactPairHeader.extraDataStream
|
||||
*/
|
||||
struct PxContactPairExtraDataIterator
|
||||
{
|
||||
/**
|
||||
\brief Constructor
|
||||
\param[in] stream Pointer to the start of the stream.
|
||||
\param[in] size Size of the stream in bytes.
|
||||
*/
|
||||
PX_FORCE_INLINE PxContactPairExtraDataIterator(const PxU8* stream, PxU32 size)
|
||||
: currPtr(stream), endPtr(stream + size), contactPairIndex(0)
|
||||
{
|
||||
clearDataPtrs();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Advances the iterator to next set of extra data items.
|
||||
|
||||
The contact pair extra data stream contains sets of items as requested by the corresponding #PxPairFlag flags
|
||||
#PxPairFlag::ePRE_SOLVER_VELOCITY, #PxPairFlag::ePOST_SOLVER_VELOCITY, #PxPairFlag::eCONTACT_EVENT_POSE. A set can contain one
|
||||
item of each plus the PxContactPairIndex item. This method parses the stream and points the iterator
|
||||
member variables to the corresponding items of the current set, if they are available. If CCD is not enabled,
|
||||
you should only get one set of items. If CCD with multiple passes is enabled, you might get more than one item
|
||||
set.
|
||||
|
||||
\note Even though contact pair extra data is requested per shape pair, you will not get an item set per shape pair
|
||||
but one per actor pair. If, for example, an actor has two shapes and both collide with another actor, then
|
||||
there will only be one item set (since it applies to both shape pairs).
|
||||
|
||||
\return True if there was another set of extra data items in the stream, else false.
|
||||
|
||||
@see PxContactPairVelocity PxContactPairPose PxContactPairIndex
|
||||
*/
|
||||
PX_INLINE bool nextItemSet()
|
||||
{
|
||||
clearDataPtrs();
|
||||
|
||||
bool foundEntry = false;
|
||||
bool endOfItemSet = false;
|
||||
while ((currPtr < endPtr) && (!endOfItemSet))
|
||||
{
|
||||
const PxContactPairExtraDataItem* edItem = reinterpret_cast<const PxContactPairExtraDataItem*>(currPtr);
|
||||
PxU8 type = edItem->type;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case PxContactPairExtraDataType::ePRE_SOLVER_VELOCITY:
|
||||
{
|
||||
PX_ASSERT(!preSolverVelocity);
|
||||
preSolverVelocity = static_cast<const PxContactPairVelocity*>(edItem);
|
||||
currPtr += sizeof(PxContactPairVelocity);
|
||||
foundEntry = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case PxContactPairExtraDataType::ePOST_SOLVER_VELOCITY:
|
||||
{
|
||||
postSolverVelocity = static_cast<const PxContactPairVelocity*>(edItem);
|
||||
currPtr += sizeof(PxContactPairVelocity);
|
||||
foundEntry = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case PxContactPairExtraDataType::eCONTACT_EVENT_POSE:
|
||||
{
|
||||
eventPose = static_cast<const PxContactPairPose*>(edItem);
|
||||
currPtr += sizeof(PxContactPairPose);
|
||||
foundEntry = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case PxContactPairExtraDataType::eCONTACT_PAIR_INDEX:
|
||||
{
|
||||
if (!foundEntry)
|
||||
{
|
||||
contactPairIndex = static_cast<const PxContactPairIndex*>(edItem)->index;
|
||||
currPtr += sizeof(PxContactPairIndex);
|
||||
foundEntry = true;
|
||||
}
|
||||
else
|
||||
endOfItemSet = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return foundEntry;
|
||||
}
|
||||
}
|
||||
|
||||
return foundEntry;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
\brief Internal helper
|
||||
*/
|
||||
PX_FORCE_INLINE void clearDataPtrs()
|
||||
{
|
||||
preSolverVelocity = NULL;
|
||||
postSolverVelocity = NULL;
|
||||
eventPose = NULL;
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
\brief Current pointer in the stream.
|
||||
*/
|
||||
const PxU8* currPtr;
|
||||
|
||||
/**
|
||||
\brief Pointer to the end of the stream.
|
||||
*/
|
||||
const PxU8* endPtr;
|
||||
|
||||
/**
|
||||
\brief Pointer to the current pre solver velocity item in the stream. NULL if there is none.
|
||||
|
||||
@see PxContactPairVelocity
|
||||
*/
|
||||
const PxContactPairVelocity* preSolverVelocity;
|
||||
|
||||
/**
|
||||
\brief Pointer to the current post solver velocity item in the stream. NULL if there is none.
|
||||
|
||||
@see PxContactPairVelocity
|
||||
*/
|
||||
const PxContactPairVelocity* postSolverVelocity;
|
||||
|
||||
/**
|
||||
\brief Pointer to the current contact event pose item in the stream. NULL if there is none.
|
||||
|
||||
@see PxContactPairPose
|
||||
*/
|
||||
const PxContactPairPose* eventPose;
|
||||
|
||||
/**
|
||||
\brief The contact pair index of the current item set in the stream.
|
||||
|
||||
@see PxContactPairIndex
|
||||
*/
|
||||
PxU32 contactPairIndex;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Collection of flags providing information on contact report pairs.
|
||||
|
||||
@see PxContactPairHeader
|
||||
*/
|
||||
struct PxContactPairHeaderFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eREMOVED_ACTOR_0 = (1<<0), //!< The actor with index 0 has been removed from the scene.
|
||||
eREMOVED_ACTOR_1 = (1<<1) //!< The actor with index 1 has been removed from the scene.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxContactPairHeaderFlag.
|
||||
|
||||
@see PxContactPairHeaderFlag
|
||||
*/
|
||||
typedef PxFlags<PxContactPairHeaderFlag::Enum, PxU16> PxContactPairHeaderFlags;
|
||||
PX_FLAGS_OPERATORS(PxContactPairHeaderFlag::Enum, PxU16)
|
||||
|
||||
|
||||
/**
|
||||
\brief An Instance of this class is passed to PxSimulationEventCallback.onContact().
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
struct PxContactPairHeader
|
||||
{
|
||||
public:
|
||||
PX_INLINE PxContactPairHeader() {}
|
||||
|
||||
/**
|
||||
\brief The two actors of the notification shape pairs.
|
||||
|
||||
\note The actor pointers might reference deleted actors. This will be the case if PxPairFlag::eNOTIFY_TOUCH_LOST
|
||||
or PxPairFlag::eNOTIFY_THRESHOLD_FORCE_LOST events were requested for the pair and one of the involved actors
|
||||
gets deleted or removed from the scene. Check the #flags member to see whether that is the case.
|
||||
Do not dereference a pointer to a deleted actor. The pointer to a deleted actor is only provided
|
||||
such that user data structures which might depend on the pointer value can be updated.
|
||||
|
||||
@see PxActor
|
||||
*/
|
||||
PxActor* actors[2];
|
||||
|
||||
/**
|
||||
\brief Stream containing extra data as requested in the PxPairFlag flags of the simulation filter.
|
||||
|
||||
This pointer is only valid if any kind of extra data information has been requested for the contact report pair (see #PxPairFlag::ePOST_SOLVER_VELOCITY etc.),
|
||||
else it will be NULL.
|
||||
|
||||
@see PxPairFlag
|
||||
*/
|
||||
const PxU8* extraDataStream;
|
||||
|
||||
/**
|
||||
\brief Size of the extra data stream [bytes]
|
||||
*/
|
||||
PxU16 extraDataStreamSize;
|
||||
|
||||
/**
|
||||
\brief Additional information on the contact report pair.
|
||||
|
||||
@see PxContactPairHeaderFlag
|
||||
*/
|
||||
PxContactPairHeaderFlags flags;
|
||||
|
||||
/**
|
||||
\brief pointer to the contact pairs
|
||||
*/
|
||||
const struct PxContactPair* pairs;
|
||||
|
||||
/**
|
||||
\brief number of contact pairs
|
||||
*/
|
||||
PxU32 nbPairs;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Collection of flags providing information on contact report pairs.
|
||||
|
||||
@see PxContactPair
|
||||
*/
|
||||
struct PxContactPairFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief The shape with index 0 has been removed from the actor/scene.
|
||||
*/
|
||||
eREMOVED_SHAPE_0 = (1<<0),
|
||||
|
||||
/**
|
||||
\brief The shape with index 1 has been removed from the actor/scene.
|
||||
*/
|
||||
eREMOVED_SHAPE_1 = (1<<1),
|
||||
|
||||
/**
|
||||
\brief First actor pair contact.
|
||||
|
||||
The provided shape pair marks the first contact between the two actors, no other shape pair has been touching prior to the current simulation frame.
|
||||
|
||||
\note: This info is only available if #PxPairFlag::eNOTIFY_TOUCH_FOUND has been declared for the pair.
|
||||
*/
|
||||
eACTOR_PAIR_HAS_FIRST_TOUCH = (1<<2),
|
||||
|
||||
/**
|
||||
\brief All contact between the actor pair was lost.
|
||||
|
||||
All contact between the two actors has been lost, no shape pairs remain touching after the current simulation frame.
|
||||
*/
|
||||
eACTOR_PAIR_LOST_TOUCH = (1<<3),
|
||||
|
||||
/**
|
||||
\brief Internal flag, used by #PxContactPair.extractContacts()
|
||||
|
||||
The applied contact impulses are provided for every contact point.
|
||||
This is the case if #PxPairFlag::eSOLVE_CONTACT has been set for the pair.
|
||||
*/
|
||||
eINTERNAL_HAS_IMPULSES = (1<<4),
|
||||
|
||||
/**
|
||||
\brief Internal flag, used by #PxContactPair.extractContacts()
|
||||
|
||||
The provided contact point information is flipped with regards to the shapes of the contact pair. This mainly concerns the order of the internal triangle indices.
|
||||
*/
|
||||
eINTERNAL_CONTACTS_ARE_FLIPPED = (1<<5)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxContactPairFlag.
|
||||
|
||||
@see PxContactPairFlag
|
||||
*/
|
||||
typedef PxFlags<PxContactPairFlag::Enum, PxU16> PxContactPairFlags;
|
||||
PX_FLAGS_OPERATORS(PxContactPairFlag::Enum, PxU16)
|
||||
|
||||
|
||||
/**
|
||||
\brief A contact point as used by contact notification
|
||||
*/
|
||||
struct PxContactPairPoint
|
||||
{
|
||||
/**
|
||||
\brief The position of the contact point between the shapes, in world space.
|
||||
*/
|
||||
PxVec3 position;
|
||||
|
||||
/**
|
||||
\brief The separation of the shapes at the contact point. A negative separation denotes a penetration.
|
||||
*/
|
||||
PxReal separation;
|
||||
|
||||
/**
|
||||
\brief The normal of the contacting surfaces at the contact point. The normal direction points from the second shape to the first shape.
|
||||
*/
|
||||
PxVec3 normal;
|
||||
|
||||
/**
|
||||
\brief The surface index of shape 0 at the contact point. This is used to identify the surface material.
|
||||
*/
|
||||
PxU32 internalFaceIndex0;
|
||||
|
||||
/**
|
||||
\brief The impulse applied at the contact point, in world space. Divide by the simulation time step to get a force value.
|
||||
*/
|
||||
PxVec3 impulse;
|
||||
|
||||
/**
|
||||
\brief The surface index of shape 1 at the contact point. This is used to identify the surface material.
|
||||
*/
|
||||
PxU32 internalFaceIndex1;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Contact report pair information.
|
||||
|
||||
Instances of this class are passed to PxSimulationEventCallback.onContact(). If contact reports have been requested for a pair of shapes (see #PxPairFlag),
|
||||
then the corresponding contact information will be provided through this structure.
|
||||
|
||||
@see PxSimulationEventCallback.onContact()
|
||||
*/
|
||||
struct PxContactPair
|
||||
{
|
||||
public:
|
||||
PX_INLINE PxContactPair() {}
|
||||
|
||||
/**
|
||||
\brief The two shapes that make up the pair.
|
||||
|
||||
\note The shape pointers might reference deleted shapes. This will be the case if #PxPairFlag::eNOTIFY_TOUCH_LOST
|
||||
or #PxPairFlag::eNOTIFY_THRESHOLD_FORCE_LOST events were requested for the pair and one of the involved shapes
|
||||
gets deleted. Check the #flags member to see whether that is the case. Do not dereference a pointer to a
|
||||
deleted shape. The pointer to a deleted shape is only provided such that user data structures which might
|
||||
depend on the pointer value can be updated.
|
||||
|
||||
@see PxShape
|
||||
*/
|
||||
PxShape* shapes[2];
|
||||
|
||||
/**
|
||||
\brief Pointer to first patch header in contact stream containing contact patch data
|
||||
|
||||
This pointer is only valid if contact point information has been requested for the contact report pair (see #PxPairFlag::eNOTIFY_CONTACT_POINTS).
|
||||
Use #extractContacts() as a reference for the data layout of the stream.
|
||||
*/
|
||||
const PxU8* contactPatches;
|
||||
|
||||
/**
|
||||
\brief Pointer to first contact point in contact stream containing contact data
|
||||
|
||||
This pointer is only valid if contact point information has been requested for the contact report pair (see #PxPairFlag::eNOTIFY_CONTACT_POINTS).
|
||||
Use #extractContacts() as a reference for the data layout of the stream.
|
||||
*/
|
||||
const PxU8* contactPoints;
|
||||
|
||||
/**
|
||||
\brief Buffer containing applied impulse data.
|
||||
|
||||
This pointer is only valid if contact point information has been requested for the contact report pair (see #PxPairFlag::eNOTIFY_CONTACT_POINTS).
|
||||
Use #extractContacts() as a reference for the data layout of the stream.
|
||||
*/
|
||||
const PxReal* contactImpulses;
|
||||
|
||||
/**
|
||||
\brief Size of the contact stream [bytes] including force buffer
|
||||
*/
|
||||
PxU32 requiredBufferSize;
|
||||
|
||||
/**
|
||||
\brief Number of contact points stored in the contact stream
|
||||
*/
|
||||
PxU8 contactCount;
|
||||
|
||||
/**
|
||||
\brief Number of contact patches stored in the contact stream
|
||||
*/
|
||||
|
||||
PxU8 patchCount;
|
||||
|
||||
/**
|
||||
\brief Size of the contact stream [bytes] not including force buffer
|
||||
*/
|
||||
|
||||
PxU16 contactStreamSize;
|
||||
|
||||
/**
|
||||
\brief Additional information on the contact report pair.
|
||||
|
||||
@see PxContactPairFlag
|
||||
*/
|
||||
PxContactPairFlags flags;
|
||||
|
||||
/**
|
||||
\brief Flags raised due to the contact.
|
||||
|
||||
The events field is a combination of:
|
||||
|
||||
<ul>
|
||||
<li>PxPairFlag::eNOTIFY_TOUCH_FOUND,</li>
|
||||
<li>PxPairFlag::eNOTIFY_TOUCH_PERSISTS,</li>
|
||||
<li>PxPairFlag::eNOTIFY_TOUCH_LOST,</li>
|
||||
<li>PxPairFlag::eNOTIFY_TOUCH_CCD,</li>
|
||||
<li>PxPairFlag::eNOTIFY_THRESHOLD_FORCE_FOUND,</li>
|
||||
<li>PxPairFlag::eNOTIFY_THRESHOLD_FORCE_PERSISTS,</li>
|
||||
<li>PxPairFlag::eNOTIFY_THRESHOLD_FORCE_LOST</li>
|
||||
</ul>
|
||||
|
||||
See the documentation of #PxPairFlag for an explanation of each.
|
||||
|
||||
\note eNOTIFY_TOUCH_CCD can get raised even if the pair did not request this event. However, in such a case it will only get
|
||||
raised in combination with one of the other flags to point out that the other event occured during a CCD pass.
|
||||
|
||||
@see PxPairFlag
|
||||
*/
|
||||
PxPairFlags events;
|
||||
|
||||
PxU32 internalData[2]; // For internal use only
|
||||
|
||||
/**
|
||||
\brief Extracts the contact points from the stream and stores them in a convenient format.
|
||||
|
||||
\param[out] userBuffer Array of PxContactPairPoint structures to extract the contact points to. The number of contacts for a pair is defined by #contactCount
|
||||
\param[in] bufferSize Number of PxContactPairPoint structures the provided buffer can store.
|
||||
\return Number of contact points written to the buffer.
|
||||
|
||||
@see PxContactPairPoint
|
||||
*/
|
||||
PX_INLINE PxU32 extractContacts(PxContactPairPoint* userBuffer, PxU32 bufferSize) const;
|
||||
|
||||
/**
|
||||
\brief Helper method to clone the contact pair and copy the contact data stream into a user buffer.
|
||||
|
||||
The contact data stream is only accessible during the contact report callback. This helper function provides copy functionality
|
||||
to buffer the contact stream information such that it can get accessed at a later stage.
|
||||
|
||||
\param[out] newPair The contact pair info will get copied to this instance. The contact data stream pointer of the copy will be redirected to the provided user buffer. Use NULL to skip the contact pair copy operation.
|
||||
\param[out] bufferMemory Memory block to store the contact data stream to. At most #requiredBufferSize bytes will get written to the buffer.
|
||||
*/
|
||||
PX_INLINE void bufferContacts(PxContactPair* newPair, PxU8* bufferMemory) const;
|
||||
|
||||
PX_INLINE const PxU32* getInternalFaceIndices() const;
|
||||
};
|
||||
|
||||
|
||||
PX_INLINE PxU32 PxContactPair::extractContacts(PxContactPairPoint* userBuffer, PxU32 bufferSize) const
|
||||
{
|
||||
PxU32 nbContacts = 0;
|
||||
|
||||
if(contactCount && bufferSize)
|
||||
{
|
||||
PxContactStreamIterator iter(contactPatches, contactPoints, getInternalFaceIndices(), patchCount, contactCount);
|
||||
|
||||
const PxReal* impulses = contactImpulses;
|
||||
|
||||
const PxU32 flippedContacts = (flags & PxContactPairFlag::eINTERNAL_CONTACTS_ARE_FLIPPED);
|
||||
const PxU32 hasImpulses = (flags & PxContactPairFlag::eINTERNAL_HAS_IMPULSES);
|
||||
|
||||
while(iter.hasNextPatch())
|
||||
{
|
||||
iter.nextPatch();
|
||||
while(iter.hasNextContact())
|
||||
{
|
||||
iter.nextContact();
|
||||
PxContactPairPoint& dst = userBuffer[nbContacts];
|
||||
dst.position = iter.getContactPoint();
|
||||
dst.separation = iter.getSeparation();
|
||||
dst.normal = iter.getContactNormal();
|
||||
if(!flippedContacts)
|
||||
{
|
||||
dst.internalFaceIndex0 = iter.getFaceIndex0();
|
||||
dst.internalFaceIndex1 = iter.getFaceIndex1();
|
||||
}
|
||||
else
|
||||
{
|
||||
dst.internalFaceIndex0 = iter.getFaceIndex1();
|
||||
dst.internalFaceIndex1 = iter.getFaceIndex0();
|
||||
}
|
||||
|
||||
if(hasImpulses)
|
||||
{
|
||||
const PxReal impulse = impulses[nbContacts];
|
||||
dst.impulse = dst.normal * impulse;
|
||||
}
|
||||
else
|
||||
dst.impulse = PxVec3(0.0f);
|
||||
++nbContacts;
|
||||
if(nbContacts == bufferSize)
|
||||
return nbContacts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nbContacts;
|
||||
}
|
||||
|
||||
|
||||
PX_INLINE void PxContactPair::bufferContacts(PxContactPair* newPair, PxU8* bufferMemory) const
|
||||
{
|
||||
PxU8* patches = bufferMemory;
|
||||
PxU8* contacts = NULL;
|
||||
if(patches)
|
||||
{
|
||||
contacts = bufferMemory + patchCount * sizeof(PxContactPatch);
|
||||
PxMemCopy(patches, contactPatches, sizeof(PxContactPatch)*patchCount);
|
||||
PxMemCopy(contacts, contactPoints, contactStreamSize - (sizeof(PxContactPatch)*patchCount));
|
||||
}
|
||||
|
||||
if(contactImpulses)
|
||||
{
|
||||
PxMemCopy(bufferMemory + ((contactStreamSize + 15) & (~15)), contactImpulses, sizeof(PxReal) * contactCount);
|
||||
}
|
||||
|
||||
if (newPair)
|
||||
{
|
||||
*newPair = *this;
|
||||
newPair->contactPatches = patches;
|
||||
newPair->contactPoints = contacts;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PX_INLINE const PxU32* PxContactPair::getInternalFaceIndices() const
|
||||
{
|
||||
return reinterpret_cast<const PxU32*>(contactImpulses + contactCount);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Collection of flags providing information on trigger report pairs.
|
||||
|
||||
@see PxTriggerPair
|
||||
*/
|
||||
struct PxTriggerPairFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eREMOVED_SHAPE_TRIGGER = (1<<0), //!< The trigger shape has been removed from the actor/scene.
|
||||
eREMOVED_SHAPE_OTHER = (1<<1), //!< The shape causing the trigger event has been removed from the actor/scene.
|
||||
eNEXT_FREE = (1<<2) //!< For internal use only.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxTriggerPairFlag.
|
||||
|
||||
@see PxTriggerPairFlag
|
||||
*/
|
||||
typedef PxFlags<PxTriggerPairFlag::Enum, PxU8> PxTriggerPairFlags;
|
||||
PX_FLAGS_OPERATORS(PxTriggerPairFlag::Enum, PxU8)
|
||||
|
||||
|
||||
/**
|
||||
\brief Descriptor for a trigger pair.
|
||||
|
||||
An array of these structs gets passed to the PxSimulationEventCallback::onTrigger() report.
|
||||
|
||||
\note The shape pointers might reference deleted shapes. This will be the case if #PxPairFlag::eNOTIFY_TOUCH_LOST
|
||||
events were requested for the pair and one of the involved shapes gets deleted. Check the #flags member to see
|
||||
whether that is the case. Do not dereference a pointer to a deleted shape. The pointer to a deleted shape is
|
||||
only provided such that user data structures which might depend on the pointer value can be updated.
|
||||
|
||||
@see PxSimulationEventCallback.onTrigger()
|
||||
*/
|
||||
struct PxTriggerPair
|
||||
{
|
||||
PX_INLINE PxTriggerPair() {}
|
||||
|
||||
PxShape* triggerShape; //!< The shape that has been marked as a trigger.
|
||||
PxActor* triggerActor; //!< The actor to which triggerShape is attached
|
||||
PxShape* otherShape; //!< The shape causing the trigger event. \deprecated (see #PxSimulationEventCallback::onTrigger()) If collision between trigger shapes is enabled, then this member might point to a trigger shape as well.
|
||||
PxActor* otherActor; //!< The actor to which otherShape is attached
|
||||
PxPairFlag::Enum status; //!< Type of trigger event (eNOTIFY_TOUCH_FOUND or eNOTIFY_TOUCH_LOST). eNOTIFY_TOUCH_PERSISTS events are not supported.
|
||||
PxTriggerPairFlags flags; //!< Additional information on the pair (see #PxTriggerPairFlag)
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Descriptor for a broken constraint.
|
||||
|
||||
An array of these structs gets passed to the PxSimulationEventCallback::onConstraintBreak() report.
|
||||
|
||||
@see PxConstraint PxSimulationEventCallback.onConstraintBreak()
|
||||
*/
|
||||
struct PxConstraintInfo
|
||||
{
|
||||
PX_INLINE PxConstraintInfo() {}
|
||||
PX_INLINE PxConstraintInfo(PxConstraint* c, void* extRef, PxU32 t) : constraint(c), externalReference(extRef), type(t) {}
|
||||
|
||||
PxConstraint* constraint; //!< The broken constraint.
|
||||
void* externalReference; //!< The external object which owns the constraint (see #PxConstraintConnector::getExternalReference())
|
||||
PxU32 type; //!< Unique type ID of the external object. Allows to cast the provided external reference to the appropriate type
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief An interface class that the user can implement in order to receive simulation events.
|
||||
|
||||
With the exception of onAdvance(), the events get sent during the call to either #PxScene::fetchResults() or
|
||||
#PxScene::flushSimulation() with sendPendingReports=true. onAdvance() gets called while the simulation
|
||||
is running (that is between PxScene::simulate() or PxScene::advance() and PxScene::fetchResults()).
|
||||
|
||||
\note SDK state should not be modified from within the callbacks. In particular objects should not
|
||||
be created or destroyed. If state modification is needed then the changes should be stored to a buffer
|
||||
and performed after the simulation step.
|
||||
|
||||
<b>Threading:</b> With the exception of onAdvance(), it is not necessary to make these callbacks thread safe as
|
||||
they will only be called in the context of the user thread.
|
||||
|
||||
@see PxScene.setSimulationEventCallback() PxScene.getSimulationEventCallback()
|
||||
*/
|
||||
class PxSimulationEventCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief This is called when a breakable constraint breaks.
|
||||
|
||||
\note The user should not release the constraint shader inside this call!
|
||||
|
||||
\note No event will get reported if the constraint breaks but gets deleted while the time step is still being simulated.
|
||||
|
||||
\param[in] constraints - The constraints which have been broken.
|
||||
\param[in] count - The number of constraints
|
||||
|
||||
@see PxConstraint PxConstraintDesc.linearBreakForce PxConstraintDesc.angularBreakForce
|
||||
*/
|
||||
virtual void onConstraintBreak(PxConstraintInfo* constraints, PxU32 count) = 0;
|
||||
|
||||
/**
|
||||
\brief This is called with the actors which have just been woken up.
|
||||
|
||||
\note Only supported by rigid bodies yet.
|
||||
\note Only called on actors for which the PxActorFlag eSEND_SLEEP_NOTIFIES has been set.
|
||||
\note Only the latest sleep state transition happening between fetchResults() of the previous frame and fetchResults() of the current frame
|
||||
will get reported. For example, let us assume actor A is awake, then A->putToSleep() gets called, then later A->wakeUp() gets called.
|
||||
At the next simulate/fetchResults() step only an onWake() event will get triggered because that was the last transition.
|
||||
\note If an actor gets newly added to a scene with properties such that it is awake and the sleep state does not get changed by
|
||||
the user or simulation, then an onWake() event will get sent at the next simulate/fetchResults() step.
|
||||
|
||||
\param[in] actors - The actors which just woke up.
|
||||
\param[in] count - The number of actors
|
||||
|
||||
@see PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxActorFlag PxActor.setActorFlag()
|
||||
*/
|
||||
virtual void onWake(PxActor** actors, PxU32 count) = 0;
|
||||
|
||||
/**
|
||||
\brief This is called with the actors which have just been put to sleep.
|
||||
|
||||
\note Only supported by rigid bodies yet.
|
||||
\note Only called on actors for which the PxActorFlag eSEND_SLEEP_NOTIFIES has been set.
|
||||
\note Only the latest sleep state transition happening between fetchResults() of the previous frame and fetchResults() of the current frame
|
||||
will get reported. For example, let us assume actor A is asleep, then A->wakeUp() gets called, then later A->putToSleep() gets called.
|
||||
At the next simulate/fetchResults() step only an onSleep() event will get triggered because that was the last transition (assuming the simulation
|
||||
does not wake the actor up).
|
||||
\note If an actor gets newly added to a scene with properties such that it is asleep and the sleep state does not get changed by
|
||||
the user or simulation, then an onSleep() event will get sent at the next simulate/fetchResults() step.
|
||||
|
||||
\param[in] actors - The actors which have just been put to sleep.
|
||||
\param[in] count - The number of actors
|
||||
|
||||
@see PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxActorFlag PxActor.setActorFlag()
|
||||
*/
|
||||
virtual void onSleep(PxActor** actors, PxU32 count) = 0;
|
||||
|
||||
/**
|
||||
\brief This is called when certain contact events occur.
|
||||
|
||||
The method will be called for a pair of actors if one of the colliding shape pairs requested contact notification.
|
||||
You request which events are reported using the filter shader/callback mechanism (see #PxSimulationFilterShader,
|
||||
#PxSimulationFilterCallback, #PxPairFlag).
|
||||
|
||||
Do not keep references to the passed objects, as they will be
|
||||
invalid after this function returns.
|
||||
|
||||
\param[in] pairHeader Information on the two actors whose shapes triggered a contact report.
|
||||
\param[in] pairs The contact pairs of two actors for which contact reports have been requested. See #PxContactPair.
|
||||
\param[in] nbPairs The number of provided contact pairs.
|
||||
|
||||
@see PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxContactPair PxPairFlag PxSimulationFilterShader PxSimulationFilterCallback
|
||||
*/
|
||||
virtual void onContact(const PxContactPairHeader& pairHeader, const PxContactPair* pairs, PxU32 nbPairs) = 0;
|
||||
|
||||
/**
|
||||
\brief This is called with the current trigger pair events.
|
||||
|
||||
Shapes which have been marked as triggers using PxShapeFlag::eTRIGGER_SHAPE will send events
|
||||
according to the pair flag specification in the filter shader (see #PxPairFlag, #PxSimulationFilterShader).
|
||||
|
||||
\note Trigger shapes will no longer send notification events for interactions with other trigger shapes.
|
||||
|
||||
\param[in] pairs - The trigger pair events.
|
||||
\param[in] count - The number of trigger pair events.
|
||||
|
||||
@see PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxPairFlag PxSimulationFilterShader PxShapeFlag PxShape.setFlag()
|
||||
*/
|
||||
virtual void onTrigger(PxTriggerPair* pairs, PxU32 count) = 0;
|
||||
|
||||
/**
|
||||
\brief Provides early access to the new pose of moving rigid bodies.
|
||||
|
||||
When this call occurs, rigid bodies having the #PxRigidBodyFlag::eENABLE_POSE_INTEGRATION_PREVIEW
|
||||
flag set, were moved by the simulation and their new poses can be accessed through the provided buffers.
|
||||
|
||||
\note The provided buffers are valid and can be read until the next call to #PxScene::simulate() or #PxScene::collide().
|
||||
|
||||
\note This callback gets triggered while the simulation is running. If the provided rigid body references are used to
|
||||
read properties of the object, then the callback has to guarantee no other thread is writing to the same body at the same
|
||||
time.
|
||||
|
||||
\note The code in this callback should be lightweight as it can block the simulation, that is, the
|
||||
#PxScene::fetchResults() call.
|
||||
|
||||
\param[in] bodyBuffer The rigid bodies that moved and requested early pose reporting.
|
||||
\param[in] poseBuffer The integrated rigid body poses of the bodies listed in bodyBuffer.
|
||||
\param[in] count The number of entries in the provided buffers.
|
||||
|
||||
@see PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxRigidBodyFlag::eENABLE_POSE_INTEGRATION_PREVIEW
|
||||
*/
|
||||
virtual void onAdvance(const PxRigidBody*const* bodyBuffer, const PxTransform* poseBuffer, const PxU32 count) = 0;
|
||||
|
||||
virtual ~PxSimulationEventCallback() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,457 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SIMULATION_STATISTICS_H
|
||||
#define PX_SIMULATION_STATISTICS_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Class used to retrieve statistics for a simulation step.
|
||||
|
||||
@see PxScene::getSimulationStatistics()
|
||||
*/
|
||||
class PxSimulationStatistics
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Different types of rigid body collision pair statistics.
|
||||
@see getRbPairStats
|
||||
*/
|
||||
enum RbPairStatsType
|
||||
{
|
||||
/**
|
||||
\brief Shape pairs processed as discrete contact pairs for the current simulation step.
|
||||
*/
|
||||
eDISCRETE_CONTACT_PAIRS,
|
||||
|
||||
/**
|
||||
\brief Shape pairs processed as swept integration pairs for the current simulation step.
|
||||
|
||||
\note Counts the pairs for which special CCD (continuous collision detection) work was actually done and NOT the number of pairs which were configured for CCD.
|
||||
Furthermore, there can be multiple CCD passes and all processed pairs of all passes are summed up, hence the number can be larger than the amount of pairs which have been configured for CCD.
|
||||
|
||||
@see PxPairFlag::eDETECT_CCD_CONTACT,
|
||||
*/
|
||||
eCCD_PAIRS,
|
||||
|
||||
/**
|
||||
\brief Shape pairs processed with user contact modification enabled for the current simulation step.
|
||||
|
||||
@see PxContactModifyCallback
|
||||
*/
|
||||
eMODIFIED_CONTACT_PAIRS,
|
||||
|
||||
/**
|
||||
\brief Trigger shape pairs processed for the current simulation step.
|
||||
|
||||
@see PxShapeFlag::eTRIGGER_SHAPE
|
||||
*/
|
||||
eTRIGGER_PAIRS
|
||||
};
|
||||
|
||||
|
||||
//objects:
|
||||
/**
|
||||
\brief Number of active PxConstraint objects (joints etc.) for the current simulation step.
|
||||
*/
|
||||
PxU32 nbActiveConstraints;
|
||||
|
||||
/**
|
||||
\brief Number of active dynamic bodies for the current simulation step.
|
||||
|
||||
\note Does not include active kinematic bodies
|
||||
*/
|
||||
PxU32 nbActiveDynamicBodies;
|
||||
|
||||
/**
|
||||
\brief Number of active kinematic bodies for the current simulation step.
|
||||
|
||||
\note Kinematic deactivation occurs at the end of the frame after the last call to PxRigidDynamic::setKinematicTarget() was called so kinematics that are
|
||||
deactivated in a given frame will be included by this counter.
|
||||
*/
|
||||
PxU32 nbActiveKinematicBodies;
|
||||
|
||||
/**
|
||||
\brief Number of static bodies for the current simulation step.
|
||||
*/
|
||||
PxU32 nbStaticBodies;
|
||||
|
||||
/**
|
||||
\brief Number of dynamic bodies for the current simulation step.
|
||||
|
||||
\note Includes inactive bodies and articulation links
|
||||
\note Does not include kinematic bodies
|
||||
*/
|
||||
PxU32 nbDynamicBodies;
|
||||
|
||||
/**
|
||||
\brief Number of kinematic bodies for the current simulation step.
|
||||
|
||||
\note Includes inactive bodies
|
||||
*/
|
||||
PxU32 nbKinematicBodies;
|
||||
|
||||
/**
|
||||
\brief Number of shapes of each geometry type.
|
||||
*/
|
||||
|
||||
PxU32 nbShapes[PxGeometryType::eGEOMETRY_COUNT];
|
||||
|
||||
/**
|
||||
\brief Number of aggregates in the scene.
|
||||
*/
|
||||
PxU32 nbAggregates;
|
||||
|
||||
/**
|
||||
\brief Number of articulations in the scene.
|
||||
*/
|
||||
PxU32 nbArticulations;
|
||||
|
||||
//solver:
|
||||
/**
|
||||
\brief The number of 1D axis constraints(joints+contact) present in the current simulation step.
|
||||
*/
|
||||
PxU32 nbAxisSolverConstraints;
|
||||
|
||||
/**
|
||||
\brief The size (in bytes) of the compressed contact stream in the current simulation step
|
||||
*/
|
||||
PxU32 compressedContactSize;
|
||||
|
||||
/**
|
||||
\brief The total required size (in bytes) of the contact constraints in the current simulation step
|
||||
*/
|
||||
PxU32 requiredContactConstraintMemory;
|
||||
|
||||
/**
|
||||
\brief The peak amount of memory (in bytes) that was allocated for constraints (this includes joints) in the current simulation step
|
||||
*/
|
||||
PxU32 peakConstraintMemory;
|
||||
|
||||
//broadphase:
|
||||
/**
|
||||
\brief Get number of broadphase volumes added for the current simulation step.
|
||||
|
||||
\return Number of broadphase volumes added.
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbBroadPhaseAdds() const
|
||||
{
|
||||
return nbBroadPhaseAdds;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get number of broadphase volumes removed for the current simulation step.
|
||||
|
||||
\return Number of broadphase volumes removed.
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbBroadPhaseRemoves() const
|
||||
{
|
||||
return nbBroadPhaseRemoves;
|
||||
}
|
||||
|
||||
//collisions:
|
||||
/**
|
||||
\brief Get number of shape collision pairs of a certain type processed for the current simulation step.
|
||||
|
||||
There is an entry for each geometry pair type.
|
||||
|
||||
\note entry[i][j] = entry[j][i], hence, if you want the sum of all pair
|
||||
types, you need to discard the symmetric entries
|
||||
|
||||
\param[in] pairType The type of pair for which to get information
|
||||
\param[in] g0 The geometry type of one pair object
|
||||
\param[in] g1 The geometry type of the other pair object
|
||||
\return Number of processed pairs of the specified geometry types.
|
||||
*/
|
||||
PxU32 getRbPairStats(RbPairStatsType pairType, PxGeometryType::Enum g0, PxGeometryType::Enum g1) const
|
||||
{
|
||||
PX_ASSERT_WITH_MESSAGE( (pairType >= eDISCRETE_CONTACT_PAIRS) &&
|
||||
(pairType <= eTRIGGER_PAIRS),
|
||||
"Invalid pairType in PxSimulationStatistics::getRbPairStats");
|
||||
|
||||
if (g0 >= PxGeometryType::eGEOMETRY_COUNT || g1 >= PxGeometryType::eGEOMETRY_COUNT)
|
||||
{
|
||||
PX_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PxU32 nbPairs = 0;
|
||||
switch(pairType)
|
||||
{
|
||||
case eDISCRETE_CONTACT_PAIRS:
|
||||
nbPairs = nbDiscreteContactPairs[g0][g1];
|
||||
break;
|
||||
case eCCD_PAIRS:
|
||||
nbPairs = nbCCDPairs[g0][g1];
|
||||
break;
|
||||
case eMODIFIED_CONTACT_PAIRS:
|
||||
nbPairs = nbModifiedContactPairs[g0][g1];
|
||||
break;
|
||||
case eTRIGGER_PAIRS:
|
||||
nbPairs = nbTriggerPairs[g0][g1];
|
||||
break;
|
||||
}
|
||||
return nbPairs;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Total number of (non CCD) pairs reaching narrow phase
|
||||
*/
|
||||
PxU32 nbDiscreteContactPairsTotal;
|
||||
|
||||
/**
|
||||
\brief Total number of (non CCD) pairs for which contacts are successfully cached (<=nbDiscreteContactPairsTotal)
|
||||
\note This includes pairs for which no contacts are generated, it still counts as a cache hit.
|
||||
*/
|
||||
PxU32 nbDiscreteContactPairsWithCacheHits;
|
||||
|
||||
/**
|
||||
\brief Total number of (non CCD) pairs for which at least 1 contact was generated (<=nbDiscreteContactPairsTotal)
|
||||
*/
|
||||
PxU32 nbDiscreteContactPairsWithContacts;
|
||||
|
||||
/**
|
||||
\brief Number of new pairs found by BP this frame
|
||||
*/
|
||||
PxU32 nbNewPairs;
|
||||
|
||||
/**
|
||||
\brief Number of lost pairs from BP this frame
|
||||
*/
|
||||
PxU32 nbLostPairs;
|
||||
|
||||
/**
|
||||
\brief Number of new touches found by NP this frame
|
||||
*/
|
||||
PxU32 nbNewTouches;
|
||||
|
||||
/**
|
||||
\brief Number of lost touches from NP this frame
|
||||
*/
|
||||
PxU32 nbLostTouches;
|
||||
|
||||
/**
|
||||
\brief Number of partitions used by the solver this frame
|
||||
*/
|
||||
PxU32 nbPartitions;
|
||||
|
||||
/**
|
||||
\brief GPU device memory in bytes allocated for particle state accessible through API
|
||||
*/
|
||||
PxU64 gpuMemParticles;
|
||||
|
||||
/**
|
||||
\brief GPU device memory in bytes allocated for FEM-based soft body state accessible through API
|
||||
*/
|
||||
PxU64 gpuMemSoftBodies;
|
||||
|
||||
/**
|
||||
\brief GPU device memory in bytes allocated for FEM-based cloth state accessible through API
|
||||
*/
|
||||
PxU64 gpuMemFEMCloths;
|
||||
|
||||
/**
|
||||
\brief GPU device memory in bytes allocated for hairsystem state accessible through API
|
||||
*/
|
||||
PxU64 gpuMemHairSystems;
|
||||
|
||||
/**
|
||||
\brief GPU device memory in bytes allocated for internal heap allocation
|
||||
*/
|
||||
PxU64 gpuMemHeap;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for broad phase in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapBroadPhase;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for narrow phase in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapNarrowPhase;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for solver in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapSolver;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for articulations in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapArticulation;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for simulation pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapSimulation;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for articulations in the simulation pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapSimulationArticulation;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for particles in the simulation pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapSimulationParticles;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for soft bodies in the simulation pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapSimulationSoftBody;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for FEM-cloth in the simulation pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapSimulationFEMCloth;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for hairsystem in the simulation pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapSimulationHairSystem;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for shared buffers in the particles pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapParticles;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for shared buffers in the FEM-based soft body pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapSoftBodies;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for shared buffers in the FEM-based cloth pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapFEMCloths;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory used for shared buffers in the hairsystem pipeline in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapHairSystems;
|
||||
|
||||
/**
|
||||
\brief GPU device heap memory not covered by other stats in bytes
|
||||
*/
|
||||
PxU64 gpuMemHeapOther;
|
||||
|
||||
PxSimulationStatistics() :
|
||||
nbActiveConstraints (0),
|
||||
nbActiveDynamicBodies (0),
|
||||
nbActiveKinematicBodies (0),
|
||||
nbStaticBodies (0),
|
||||
nbDynamicBodies (0),
|
||||
nbKinematicBodies (0),
|
||||
nbAggregates (0),
|
||||
nbArticulations (0),
|
||||
nbAxisSolverConstraints (0),
|
||||
compressedContactSize (0),
|
||||
requiredContactConstraintMemory (0),
|
||||
peakConstraintMemory (0),
|
||||
nbDiscreteContactPairsTotal (0),
|
||||
nbDiscreteContactPairsWithCacheHits (0),
|
||||
nbDiscreteContactPairsWithContacts (0),
|
||||
nbNewPairs (0),
|
||||
nbLostPairs (0),
|
||||
nbNewTouches (0),
|
||||
nbLostTouches (0),
|
||||
nbPartitions (0),
|
||||
gpuMemParticles (0),
|
||||
gpuMemSoftBodies (0),
|
||||
gpuMemFEMCloths (0),
|
||||
gpuMemHairSystems (0),
|
||||
gpuMemHeap (0),
|
||||
gpuMemHeapBroadPhase (0),
|
||||
gpuMemHeapNarrowPhase (0),
|
||||
gpuMemHeapSolver (0),
|
||||
gpuMemHeapArticulation (0),
|
||||
gpuMemHeapSimulation (0),
|
||||
gpuMemHeapSimulationArticulation (0),
|
||||
gpuMemHeapSimulationParticles (0),
|
||||
gpuMemHeapSimulationSoftBody (0),
|
||||
gpuMemHeapSimulationFEMCloth (0),
|
||||
gpuMemHeapSimulationHairSystem (0),
|
||||
gpuMemHeapParticles (0),
|
||||
gpuMemHeapSoftBodies (0),
|
||||
gpuMemHeapFEMCloths (0),
|
||||
gpuMemHeapHairSystems (0),
|
||||
gpuMemHeapOther (0)
|
||||
{
|
||||
nbBroadPhaseAdds = 0;
|
||||
nbBroadPhaseRemoves = 0;
|
||||
|
||||
for(PxU32 i=0; i < PxGeometryType::eGEOMETRY_COUNT; i++)
|
||||
{
|
||||
for(PxU32 j=0; j < PxGeometryType::eGEOMETRY_COUNT; j++)
|
||||
{
|
||||
nbDiscreteContactPairs[i][j] = 0;
|
||||
nbModifiedContactPairs[i][j] = 0;
|
||||
nbCCDPairs[i][j] = 0;
|
||||
nbTriggerPairs[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for(PxU32 i=0; i < PxGeometryType::eGEOMETRY_COUNT; i++)
|
||||
{
|
||||
nbShapes[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// We advise to not access these members directly. Use the provided accessor methods instead.
|
||||
//
|
||||
//broadphase:
|
||||
PxU32 nbBroadPhaseAdds;
|
||||
PxU32 nbBroadPhaseRemoves;
|
||||
|
||||
//collisions:
|
||||
PxU32 nbDiscreteContactPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
|
||||
PxU32 nbCCDPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
|
||||
PxU32 nbModifiedContactPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
|
||||
PxU32 nbTriggerPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
742
modules/PhysX/physx/physx-sys/physx/physx/include/PxSoftBody.h
Normal file
742
modules/PhysX/physx/physx-sys/physx/physx/include/PxSoftBody.h
Normal file
@@ -0,0 +1,742 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SOFT_BODY_H
|
||||
#define PX_SOFT_BODY_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "PxFEMParameter.h"
|
||||
#include "PxActor.h"
|
||||
#include "PxConeLimitedConstraint.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4435)
|
||||
#endif
|
||||
|
||||
class PxCudaContextManager;
|
||||
class PxBuffer;
|
||||
class PxTetrahedronMesh;
|
||||
class PxSoftBodyAuxData;
|
||||
class PxFEMCloth;
|
||||
class PxParticleBuffer;
|
||||
|
||||
/**
|
||||
\brief The maximum tetrahedron index supported in the model.
|
||||
*/
|
||||
#define PX_MAX_TETID 0x000fffff
|
||||
|
||||
/**
|
||||
\brief Identifies input and output buffers for PxSoftBody.
|
||||
|
||||
@see PxSoftBodyData::readData(), PxSoftBodyData::writeData(), PxBuffer.
|
||||
*/
|
||||
struct PxSoftBodyData
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE = 0,
|
||||
|
||||
ePOSITION_INVMASS = 1 << 0, //!< Flag to request access to the collision mesh's positions; read only @see PxSoftBody::writeData
|
||||
eSIM_POSITION_INVMASS = 1 << 2, //!< Flag to request access to the simulation mesh's positions and inverse masses
|
||||
eSIM_VELOCITY = 1 << 3, //!< Flag to request access to the simulation mesh's velocities and inverse masses
|
||||
eSIM_KINEMATIC_TARGET = 1 << 4, //!< Flag to request access to the simulation mesh's kinematic target position
|
||||
|
||||
eALL = ePOSITION_INVMASS | eSIM_POSITION_INVMASS | eSIM_VELOCITY | eSIM_KINEMATIC_TARGET
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxSoftBodyData::Enum, PxU32> PxSoftBodyDataFlags;
|
||||
|
||||
/**
|
||||
\brief Flags to enable or disable special modes of a SoftBody
|
||||
*/
|
||||
struct PxSoftBodyFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eDISABLE_SELF_COLLISION = 1 << 0, //!< Determines if self collision will be detected and resolved
|
||||
eCOMPUTE_STRESS_TENSOR = 1 << 1, //!< Enables computation of a Cauchy stress tensor for every tetrahedron in the simulation mesh. The tensors can be accessed through the softbody direct API
|
||||
eENABLE_CCD = 1 << 2, //!< Enables support for continuous collision detection
|
||||
eDISPLAY_SIM_MESH = 1 << 3, //!< Enable debug rendering to display the simulation mesh
|
||||
eKINEMATIC = 1 << 4, //!< Enables support for kinematic motion of the collision and simulation mesh.
|
||||
ePARTIALLY_KINEMATIC = 1 << 5 //!< Enables partially kinematic motion of the collisios and simulation mesh.
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxSoftBodyFlag::Enum, PxU32> PxSoftBodyFlags;
|
||||
|
||||
/**
|
||||
\brief Represents a FEM softbody including everything to calculate its definition like geometry and material properties
|
||||
*/
|
||||
class PX_DEPRECATED PxSoftBody : public PxActor
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~PxSoftBody() {}
|
||||
|
||||
/**
|
||||
\brief Set a single softbody flag
|
||||
|
||||
\param[in] flag The flag to set or clear
|
||||
\param[in] val The new state of the flag
|
||||
*/
|
||||
virtual void setSoftBodyFlag(PxSoftBodyFlag::Enum flag, bool val) = 0;
|
||||
|
||||
/**
|
||||
\brief Set the softbody flags
|
||||
|
||||
\param[in] flags The new softbody flags
|
||||
*/
|
||||
virtual void setSoftBodyFlags(PxSoftBodyFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Get the softbody flags
|
||||
|
||||
\return The softbody flags
|
||||
*/
|
||||
virtual PxSoftBodyFlags getSoftBodyFlag() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set parameter for FEM internal solve
|
||||
|
||||
\param[in] parameters The FEM parameters
|
||||
*/
|
||||
virtual void setParameter(const PxFEMParameters parameters) = 0;
|
||||
|
||||
/**
|
||||
\brief Get parameter for FEM internal solve
|
||||
|
||||
\return The FEM parameters
|
||||
*/
|
||||
virtual PxFEMParameters getParameter() const = 0;
|
||||
|
||||
/**
|
||||
\brief Issues a read command to the PxSoftBody.
|
||||
|
||||
Read operations are scheduled and then flushed in PxScene::simulate().
|
||||
Read operations are known to be finished when PxBuffer::map() returns.
|
||||
|
||||
PxSoftBodyData::ePOSITION_INVMASS, PxSoftBodyData::eSIM_POSITION_INVMASS and PxSoftBodyData::eSIM_VELOCITY can be read from the PxSoftBody.
|
||||
|
||||
The softbody class offers internal cpu buffers that can be used to hold the data. The cpu buffers are accessible through getPositionInvMassCPU(),
|
||||
getSimPositionInvMassCPU() and getSimVelocityInvMassCPU().
|
||||
|
||||
\param[in] flags Specifies which PxSoftBody data to read from.
|
||||
\param[in] buffer Specifies buffer to which data is written to.
|
||||
\param[in] flush If set to true the command gets executed immediately, otherwise it will get executed the next time copy commands are flushed.
|
||||
|
||||
@see writeData(), PxBuffer, PxSoftBodyData
|
||||
*/
|
||||
virtual void readData(PxSoftBodyData::Enum flags, PxBuffer& buffer, bool flush = false) = 0;
|
||||
|
||||
/**
|
||||
\brief Issues a read command to the PxSoftBody.
|
||||
|
||||
Read operations are scheduled and then flushed in PxScene::simulate().
|
||||
Read operations are known to be finished when PxBuffer::map() returns.
|
||||
|
||||
PxSoftBodyData::ePOSITION_INVMASS, PxSoftBodyData::eSIM_POSITION_INVMASS and PxSoftBodyData::eSIM_VELOCITY can be read from the PxSoftBody.
|
||||
|
||||
The data to read from the GPU is written to the corresponding cpu buffer that a softbody provides. Those cpu buffers are accessible through
|
||||
getPositionInvMassCPU(), getSimPositionInvMassCPU() or getSimVelocityInvMassCPU().
|
||||
|
||||
\param[in] flags Specifies which PxSoftBody data to read from.
|
||||
\param[in] flush If set to true the command gets executed immediately, otherwise it will get executed the next time copy commands are flushed.
|
||||
|
||||
@see writeData(), PxSoftBodyData
|
||||
*/
|
||||
virtual void readData(PxSoftBodyData::Enum flags, bool flush = false) = 0;
|
||||
|
||||
/**
|
||||
\brief Issues a write command to the PxSoftBody.
|
||||
|
||||
Write operations are scheduled and then flushed in PxScene::simulate().
|
||||
Write operations are known to be finished when PxScene::fetchResult() returns.
|
||||
|
||||
PxSoftBodyData::eSIM_POSITION_INVMASS and PxSoftBodyData::eSIM_VELOCITY can be written to the PxSoftBody. PxSoftBodyData::ePOSITION_INVMASS is read only,
|
||||
because the collision-mesh vertices are driven by the simulation-mesh vertices, which can be written to with PxSoftBodyData::eSIM_POSITION_INVMASS.
|
||||
|
||||
The softbody class offers internal cpu buffers that can be used to hold the data. The cpu buffers are accessible through getPositionInvMassCPU(),
|
||||
getSimPositionInvMassCPU() and getSimVelocityInvMassCPU(). Consider to use the PxSoftBodyExt::commit() extension method if all buffers should get written.
|
||||
|
||||
\param[in] flags Specifies which PxSoftBody data to write to.
|
||||
\param[in] buffer Specifies buffer from which data is read.
|
||||
\param[in] flush If set to true the command gets executed immediately, otherwise it will get executed the next time copy commands are flushed.
|
||||
|
||||
@see readData(), PxBuffer, PxSoftBodyData, PxSoftBodyExt::commit
|
||||
*/
|
||||
virtual void writeData(PxSoftBodyData::Enum flags, PxBuffer& buffer, bool flush = false) = 0;
|
||||
|
||||
/**
|
||||
\brief Issues a write command to the PxSoftBody.
|
||||
|
||||
Write operations are scheduled and then flushed in PxScene::simulate().
|
||||
Write operations are known to be finished when PxScene::fetchResult() returns.
|
||||
|
||||
PxSoftBodyData::eSIM_POSITION_INVMASS and PxSoftBodyData::eSIM_VELOCITY can be written to the PxSoftBody. PxSoftBodyData::ePOSITION_INVMASS is read only,
|
||||
because the collision-mesh vertices are driven by the simulation-mesh vertices, which can be written to with PxSoftBodyData::eSIM_POSITION_INVMASS.
|
||||
|
||||
The data to write to the GPU is taken from the corresponding cpu buffer that a softbody provides. Those cpu buffers are accessible through
|
||||
getPositionInvMassCPU(), getSimPositionInvMassCPU() or getSimVelocityInvMassCPU().
|
||||
|
||||
\param[in] flags Specifies which PxSoftBody data to write to.
|
||||
\param[in] flush If set to true the command gets executed immediately, otherwise it will get executed the next time copy commands are flushed.
|
||||
|
||||
@see readData(), PxSoftBodyData
|
||||
*/
|
||||
virtual void writeData(PxSoftBodyData::Enum flags, bool flush = false) = 0;
|
||||
|
||||
/**
|
||||
\brief Return the cuda context manager
|
||||
|
||||
\return The cuda context manager
|
||||
*/
|
||||
virtual PxCudaContextManager* getCudaContextManager() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the wake counter for the soft body.
|
||||
|
||||
The wake counter value determines the minimum amount of time until the soft body can be put to sleep. Please note
|
||||
that a soft body will not be put to sleep if any vertex velocity is above the specified threshold
|
||||
or if other awake objects are touching it.
|
||||
|
||||
\note Passing in a positive value will wake the soft body up automatically.
|
||||
|
||||
<b>Default:</b> 0.4 (which corresponds to 20 frames for a time step of 0.02)
|
||||
|
||||
\param[in] wakeCounterValue Wake counter value. <b>Range:</b> [0, PX_MAX_F32)
|
||||
|
||||
@see isSleeping() getWakeCounter()
|
||||
*/
|
||||
virtual void setWakeCounter(PxReal wakeCounterValue) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the wake counter of the soft body.
|
||||
|
||||
\return The wake counter of the soft body.
|
||||
|
||||
@see isSleeping() setWakeCounter()
|
||||
*/
|
||||
virtual PxReal getWakeCounter() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns true if this soft body is sleeping.
|
||||
|
||||
When an actor does not move for a period of time, it is no longer simulated in order to save time. This state
|
||||
is called sleeping. However, because the object automatically wakes up when it is either touched by an awake object,
|
||||
or a sleep-affecting property is changed by the user, the entire sleep mechanism should be transparent to the user.
|
||||
|
||||
A soft body can only go to sleep if all vertices are ready for sleeping. A soft body is guaranteed to be awake
|
||||
if at least one of the following holds:
|
||||
|
||||
\li The wake counter is positive (@see setWakeCounter()).
|
||||
\li The velocity of any vertex is above the sleep threshold.
|
||||
|
||||
If a soft body is sleeping, the following state is guaranteed:
|
||||
|
||||
\li The wake counter is zero.
|
||||
\li The linear velocity of all vertices is zero.
|
||||
|
||||
When a soft body gets inserted into a scene, it will be considered asleep if all the points above hold, else it will
|
||||
be treated as awake.
|
||||
|
||||
\note It is invalid to use this method if the soft body has not been added to a scene already.
|
||||
|
||||
\return True if the soft body is sleeping.
|
||||
|
||||
@see isSleeping()
|
||||
*/
|
||||
virtual bool isSleeping() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the solver iteration counts for the body.
|
||||
|
||||
The solver iteration count determines how accurately deformation and contacts are resolved.
|
||||
If you are having trouble with softbodies that are not as stiff as they should be, then
|
||||
setting a higher position iteration count may improve the behavior.
|
||||
|
||||
If intersecting bodies are being depenetrated too violently, increase the number of velocity
|
||||
iterations.
|
||||
|
||||
<b>Default:</b> 4 position iterations, 1 velocity iteration
|
||||
|
||||
\param[in] minPositionIters Minimal number of position iterations the solver should perform for this body. <b>Range:</b> [1,255]
|
||||
\param[in] minVelocityIters Minimal number of velocity iterations the solver should perform for this body. <b>Range:</b> [1,255]
|
||||
|
||||
@see getSolverIterationCounts()
|
||||
*/
|
||||
virtual void setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters = 1) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the solver iteration counts.
|
||||
|
||||
@see setSolverIterationCounts()
|
||||
*/
|
||||
virtual void getSolverIterationCounts(PxU32& minPositionIters, PxU32& minVelocityIters) const = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Retrieves the shape pointer belonging to the actor.
|
||||
|
||||
\return Pointer to the collision mesh's shape
|
||||
@see PxShape getNbShapes() PxShape::release()
|
||||
*/
|
||||
virtual PxShape* getShape() = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Retrieve the collision mesh pointer.
|
||||
|
||||
Allows to access the geometry of the tetrahedral mesh used to perform collision detection
|
||||
|
||||
\return Pointer to the collision mesh
|
||||
*/
|
||||
virtual PxTetrahedronMesh* getCollisionMesh() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the simulation mesh pointer.
|
||||
|
||||
Allows to access the geometry of the tetrahedral mesh used to compute the object's deformation
|
||||
|
||||
\return Pointer to the simulation mesh
|
||||
*/
|
||||
virtual PxTetrahedronMesh* getSimulationMesh() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the simulation state pointer.
|
||||
|
||||
Allows to access the additional data of the simulation mesh (inverse mass, rest state etc.).
|
||||
The geometry part of the data is stored in the simulation mesh.
|
||||
|
||||
\return Pointer to the simulation state
|
||||
*/
|
||||
virtual PxSoftBodyAuxData* getSoftBodyAuxData() = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Attaches a shape
|
||||
|
||||
Attaches the shape to use for collision detection
|
||||
|
||||
\param[in] shape The shape to use for collisions
|
||||
|
||||
\return Returns true if the operation was successful
|
||||
*/
|
||||
virtual bool attachShape(PxShape& shape) = 0;
|
||||
|
||||
/**
|
||||
\brief Attaches a simulation mesh
|
||||
|
||||
Attaches the simulation mesh (geometry) and a state containing inverse mass, rest pose
|
||||
etc. required to compute the softbody deformation.
|
||||
|
||||
\param[in] simulationMesh The tetrahedral mesh used to compute the softbody's deformation
|
||||
\param[in] softBodyAuxData A state that contain a mapping from simulation to collision mesh, volume information etc.
|
||||
|
||||
\return Returns true if the operation was successful
|
||||
*/
|
||||
virtual bool attachSimulationMesh(PxTetrahedronMesh& simulationMesh, PxSoftBodyAuxData& softBodyAuxData) = 0;
|
||||
|
||||
/**
|
||||
\brief Detaches the shape
|
||||
|
||||
Detaches the shape used for collision detection.
|
||||
|
||||
@see void detachSimulationMesh()
|
||||
*/
|
||||
virtual void detachShape() = 0;
|
||||
|
||||
/**
|
||||
\brief Detaches the simulation mesh
|
||||
|
||||
Detaches the simulation mesh and simulation state used to compute the softbody deformation.
|
||||
|
||||
@see void detachShape()
|
||||
*/
|
||||
virtual void detachSimulationMesh() = 0;
|
||||
|
||||
/**
|
||||
\brief Releases the softbody
|
||||
|
||||
Releases the softbody and frees its resources.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Creates a collision filter between a particle and a tetrahedron in the soft body's collision mesh.
|
||||
|
||||
\param[in] particlesystem The particle system used for the collision filter
|
||||
\param[in] buffer The PxParticleBuffer to which the particle belongs to.
|
||||
\param[in] particleId The particle whose collisions with the tetrahedron in the soft body are filtered.
|
||||
\param[in] tetId The tetradedron in the soft body that is filtered. If tetId is PX_MAX_TETID, this particle will filter against all tetrahedra in this soft body
|
||||
*/
|
||||
virtual void addParticleFilter(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes a collision filter between a particle and a tetrahedron in the soft body's collision mesh.
|
||||
|
||||
\param[in] particlesystem The particle system used for the collision filter
|
||||
\param[in] buffer The PxParticleBuffer to which the particle belongs to.
|
||||
\param[in] particleId The particle whose collisions with the tetrahedron in the soft body are filtered.
|
||||
\param[in] tetId The tetrahedron in the soft body is filtered.
|
||||
*/
|
||||
virtual void removeParticleFilter(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates an attachment between a particle and a soft body.
|
||||
Be aware that destroying the particle system before destroying the attachment is illegal and may cause a crash.
|
||||
The soft body keeps track of these attachments but the particle system does not.
|
||||
|
||||
\param[in] particlesystem The particle system used for the attachment
|
||||
\param[in] buffer The PxParticleBuffer to which the particle belongs to.
|
||||
\param[in] particleId The particle that is attached to a tetrahedron in the soft body's collision mesh.
|
||||
\param[in] tetId The tetrahedron in the soft body's collision mesh to attach the particle to.
|
||||
\param[in] barycentric The barycentric coordinates of the particle attachment position with respect to the tetrahedron specified with tetId.
|
||||
\return Returns a handle that identifies the attachment created. This handle can be used to release the attachment later
|
||||
*/
|
||||
virtual PxU32 addParticleAttachment(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId, const PxVec4& barycentric) = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Removes an attachment between a particle and a soft body.
|
||||
Be aware that destroying the particle system before destroying the attachment is illegal and may cause a crash.
|
||||
The soft body keeps track of these attachments but the particle system does not.
|
||||
|
||||
\param[in] particlesystem The particle system used for the attachment
|
||||
\param[in] handle Index that identifies the attachment. This handle gets returned by the addParticleAttachment when the attachment is created
|
||||
*/
|
||||
virtual void removeParticleAttachment(PxPBDParticleSystem* particlesystem, PxU32 handle) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates a collision filter between a vertex in a soft body and a rigid body.
|
||||
|
||||
\param[in] actor The rigid body actor used for the collision filter
|
||||
\param[in] vertId The index of a vertex in the softbody's collision mesh whose collisions with the rigid body are filtered.
|
||||
*/
|
||||
virtual void addRigidFilter(PxRigidActor* actor, PxU32 vertId) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes a collision filter between a vertex in a soft body and a rigid body.
|
||||
|
||||
\param[in] actor The rigid body actor used for the collision filter
|
||||
\param[in] vertId The index of a vertex in the softbody's collision mesh whose collisions with the rigid body are filtered.
|
||||
*/
|
||||
virtual void removeRigidFilter(PxRigidActor* actor, PxU32 vertId) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates a rigid attachment between a soft body and a rigid body.
|
||||
Be aware that destroying the rigid body before destroying the attachment is illegal and may cause a crash.
|
||||
The soft body keeps track of these attachments but the rigid body does not.
|
||||
|
||||
This method attaches a vertex on the soft body collision mesh to the rigid body.
|
||||
|
||||
\param[in] actor The rigid body actor used for the attachment
|
||||
\param[in] vertId The index of a vertex in the softbody's collision mesh that gets attached to the rigid body.
|
||||
\param[in] actorSpacePose The location of the attachment point expressed in the rigid body's coordinate system.
|
||||
\param[in] constraint The user defined cone distance limit constraint to limit the movement between a vertex in the soft body and rigid body.
|
||||
\return Returns a handle that identifies the attachment created. This handle can be used to relese the attachment later
|
||||
*/
|
||||
virtual PxU32 addRigidAttachment(PxRigidActor* actor, PxU32 vertId, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint = NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Releases a rigid attachment between a soft body and a rigid body.
|
||||
Be aware that destroying the rigid body before destroying the attachment is illegal and may cause a crash.
|
||||
The soft body keeps track of these attachments but the rigid body does not.
|
||||
|
||||
This method removes a previously-created attachment between a vertex of the soft body collision mesh and the rigid body.
|
||||
|
||||
\param[in] actor The rigid body actor used for the attachment
|
||||
\param[in] handle Index that identifies the attachment. This handle gets returned by the addRigidAttachment when the attachment is created
|
||||
*/
|
||||
virtual void removeRigidAttachment(PxRigidActor* actor, PxU32 handle) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates collision filter between a tetrahedron in a soft body and a rigid body.
|
||||
|
||||
\param[in] actor The rigid body actor used for collision filter
|
||||
\param[in] tetIdx The index of a tetrahedron in the softbody's collision mesh whose collisions with the rigid body is filtered.
|
||||
*/
|
||||
virtual void addTetRigidFilter(PxRigidActor* actor, PxU32 tetIdx) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes collision filter between a tetrahedron in a soft body and a rigid body.
|
||||
|
||||
\param[in] actor The rigid body actor used for collision filter
|
||||
\param[in] tetIdx The index of a tetrahedron in the softbody's collision mesh whose collisions with the rigid body is filtered.
|
||||
*/
|
||||
virtual void removeTetRigidFilter(PxRigidActor* actor, PxU32 tetIdx) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates a rigid attachment between a soft body and a rigid body.
|
||||
Be aware that destroying the rigid body before destroying the attachment is illegal and may cause a crash.
|
||||
The soft body keeps track of these attachments but the rigid body does not.
|
||||
|
||||
This method attaches a point inside a tetrahedron of the collision to the rigid body.
|
||||
|
||||
\param[in] actor The rigid body actor used for the attachment
|
||||
\param[in] tetIdx The index of a tetrahedron in the softbody's collision mesh that contains the point to be attached to the rigid body
|
||||
\param[in] barycentric The barycentric coordinates of the attachment point inside the tetrahedron specified by tetIdx
|
||||
\param[in] actorSpacePose The location of the attachment point expressed in the rigid body's coordinate system.
|
||||
\param[in] constraint The user defined cone distance limit constraint to limit the movement between a tet and rigid body.
|
||||
\return Returns a handle that identifies the attachment created. This handle can be used to release the attachment later
|
||||
*/
|
||||
virtual PxU32 addTetRigidAttachment(PxRigidActor* actor, PxU32 tetIdx, const PxVec4& barycentric, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint = NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates collision filter between a tetrahedron in a soft body and a tetrahedron in another soft body.
|
||||
|
||||
\param[in] otherSoftBody The other soft body actor used for collision filter
|
||||
\param[in] otherTetIdx The index of the tetrahedron in the other softbody's collision mesh to be filtered.
|
||||
\param[in] tetIdx1 The index of the tetrahedron in the softbody's collision mesh to be filtered.
|
||||
*/
|
||||
virtual void addSoftBodyFilter(PxSoftBody* otherSoftBody, PxU32 otherTetIdx, PxU32 tetIdx1) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes collision filter between a tetrahedron in a soft body and a tetrahedron in other soft body.
|
||||
|
||||
\param[in] otherSoftBody The other soft body actor used for collision filter
|
||||
\param[in] otherTetIdx The index of the other tetrahedron in the other softbody's collision mesh whose collision with the tetrahedron with the soft body is filtered.
|
||||
\param[in] tetIdx1 The index of the tetrahedron in the softbody's collision mesh whose collision with the other tetrahedron with the other soft body is filtered.
|
||||
*/
|
||||
virtual void removeSoftBodyFilter(PxSoftBody* otherSoftBody, PxU32 otherTetIdx, PxU32 tetIdx1) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates collision filters between a tetrahedron in a soft body with another soft body.
|
||||
|
||||
\param[in] otherSoftBody The other soft body actor used for collision filter
|
||||
\param[in] otherTetIndices The indices of the tetrahedron in the other softbody's collision mesh to be filtered.
|
||||
\param[in] tetIndices The indices of the tetrahedron of the softbody's collision mesh to be filtered.
|
||||
\param[in] tetIndicesSize The size of tetIndices.
|
||||
*/
|
||||
virtual void addSoftBodyFilters(PxSoftBody* otherSoftBody, PxU32* otherTetIndices, PxU32* tetIndices, PxU32 tetIndicesSize) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes collision filters between a tetrahedron in a soft body with another soft body.
|
||||
|
||||
\param[in] otherSoftBody The other soft body actor used for collision filter
|
||||
\param[in] otherTetIndices The indices of the tetrahedron in the other softbody's collision mesh to be filtered.
|
||||
\param[in] tetIndices The indices of the tetrahedron of the softbody's collision mesh to be filtered.
|
||||
\param[in] tetIndicesSize The size of tetIndices.
|
||||
*/
|
||||
virtual void removeSoftBodyFilters(PxSoftBody* otherSoftBody, PxU32* otherTetIndices, PxU32* tetIndices, PxU32 tetIndicesSize) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates an attachment between two soft bodies.
|
||||
|
||||
This method attaches a point inside a tetrahedron of the collision mesh to a point in another soft body's tetrahedron collision mesh.
|
||||
|
||||
\param[in] softbody0 The soft body actor used for the attachment
|
||||
\param[in] tetIdx0 The index of a tetrahedron in the other soft body that contains the point to be attached to the soft body
|
||||
\param[in] tetBarycentric0 The barycentric coordinates of the attachment point inside the tetrahedron specified by tetIdx0
|
||||
\param[in] tetIdx1 The index of a tetrahedron in the softbody's collision mesh that contains the point to be attached to the softbody0
|
||||
\param[in] tetBarycentric1 The barycentric coordinates of the attachment point inside the tetrahedron specified by tetIdx1
|
||||
\param[in] constraint The user defined cone distance limit constraint to limit the movement between tets.
|
||||
\return Returns a handle that identifies the attachment created. This handle can be used to release the attachment later
|
||||
*/
|
||||
virtual PxU32 addSoftBodyAttachment(PxSoftBody* softbody0, PxU32 tetIdx0, const PxVec4& tetBarycentric0, PxU32 tetIdx1, const PxVec4& tetBarycentric1,
|
||||
PxConeLimitedConstraint* constraint = NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Releases an attachment between a soft body and the other soft body.
|
||||
Be aware that destroying the soft body before destroying the attachment is illegal and may cause a crash.
|
||||
|
||||
This method removes a previously-created attachment between a point inside a tetrahedron of the collision mesh to a point in another soft body's tetrahedron collision mesh.
|
||||
|
||||
\param[in] softbody0 The softbody actor used for the attachment.
|
||||
\param[in] handle Index that identifies the attachment. This handle gets returned by the addSoftBodyAttachment when the attachment is created.
|
||||
*/
|
||||
virtual void removeSoftBodyAttachment(PxSoftBody* softbody0, PxU32 handle) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates collision filter between a tetrahedron in a soft body and a triangle in a cloth.
|
||||
\warning Feature under development, only for internal usage.
|
||||
|
||||
\param[in] cloth The cloth actor used for collision filter
|
||||
\param[in] triIdx The index of the triangle in the cloth mesh to be filtered.
|
||||
\param[in] tetIdx The index of the tetrahedron in the softbody's collision mesh to be filtered.
|
||||
*/
|
||||
virtual void addClothFilter(PxFEMCloth* cloth, PxU32 triIdx, PxU32 tetIdx) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes collision filter between a tetrahedron in a soft body and a triangle in a cloth.
|
||||
\warning Feature under development, only for internal usage.
|
||||
|
||||
\param[in] cloth The cloth actor used for collision filter
|
||||
\param[in] triIdx The index of the triangle in the cloth mesh to be filtered.
|
||||
\param[in] tetIdx The index of the tetrahedron in the softbody's collision mesh to be filtered.
|
||||
*/
|
||||
virtual void removeClothFilter(PxFEMCloth* cloth, PxU32 triIdx, PxU32 tetIdx) = 0;
|
||||
|
||||
|
||||
/**
|
||||
\brief Creates an attachment between a soft body and a cloth.
|
||||
Be aware that destroying the rigid body before destroying the attachment is illegal and may cause a crash.
|
||||
The soft body keeps track of these attachments but the cloth does not.
|
||||
|
||||
This method attaches a point inside a tetrahedron of the collision mesh to a cloth.
|
||||
|
||||
\warning Feature under development, only for internal usage.
|
||||
|
||||
\param[in] cloth The cloth actor used for the attachment
|
||||
\param[in] triIdx The index of a triangle in the cloth mesh that contains the point to be attached to the soft body
|
||||
\param[in] triBarycentric The barycentric coordinates of the attachment point inside the triangle specified by triangleIdx
|
||||
\param[in] tetIdx The index of a tetrahedron in the softbody's collision mesh that contains the point to be attached to the cloth
|
||||
\param[in] tetBarycentric The barycentric coordinates of the attachment point inside the tetrahedron specified by tetIdx
|
||||
\param[in] constraint The user defined cone distance limit constraint to limit the movement between a triangle in the fem cloth and a tet in the soft body.
|
||||
\return Returns a handle that identifies the attachment created. This handle can be used to release the attachment later
|
||||
*/
|
||||
virtual PxU32 addClothAttachment(PxFEMCloth* cloth, PxU32 triIdx, const PxVec4& triBarycentric, PxU32 tetIdx, const PxVec4& tetBarycentric,
|
||||
PxConeLimitedConstraint* constraint = NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Releases an attachment between a cloth and a soft body.
|
||||
Be aware that destroying the cloth before destroying the attachment is illegal and may cause a crash.
|
||||
The soft body keeps track of these attachments but the cloth does not.
|
||||
|
||||
This method removes a previously-created attachment between a point inside a collision mesh tetrahedron and a point inside a cloth mesh.
|
||||
|
||||
\warning Feature under development, only for internal usage.
|
||||
|
||||
\param[in] cloth The cloth actor used for the attachment
|
||||
\param[in] handle Index that identifies the attachment. This handle gets returned by the addClothAttachment when the attachment is created
|
||||
*/
|
||||
virtual void removeClothAttachment(PxFEMCloth* cloth, PxU32 handle) = 0;
|
||||
|
||||
/**
|
||||
\brief Access to the vertices of the simulation mesh on the host
|
||||
|
||||
Each element uses 4 float values containing position and inverseMass per vertex [x, y, z, inverseMass]
|
||||
The inverse mass must match the inverse mass in the simVelocityCPU buffer at the same index. A copy of this value
|
||||
is stored in the simVelocityCPU buffer to allow for faster access on the GPU. If the inverse masses in those two buffers
|
||||
don't match, the simulation may produce wrong results
|
||||
|
||||
Allows to access the CPU buffer of the simulation mesh's vertices
|
||||
|
||||
\return The buffer that contains the simulation mesh's vertex positions (x, y, z) and the inverse mass as 4th component
|
||||
*/
|
||||
virtual PxBuffer* getSimPositionInvMassCPU() = 0;
|
||||
|
||||
/**
|
||||
\brief Access to the vertices of the simulation mesh on the host
|
||||
|
||||
Each element uses 4 float values containing position and inverseMass per vertex [x, y, z, inverseMass]
|
||||
The inverse mass must match the inverse mass in the simVelocityCPU buffer at the same index. A copy of this value
|
||||
is stored in the simVelocityCPU buffer to allow for faster access on the GPU. If the inverse masses in those two buffers
|
||||
don't match, the simulation may produce wrong results
|
||||
|
||||
Allows to access the CPU buffer of the simulation mesh's vertices
|
||||
|
||||
\return The buffer that contains the simulation mesh's vertex positions (x, y, z) and the inverse mass as 4th component
|
||||
*/
|
||||
virtual PxBuffer* getKinematicTargetCPU() = 0;
|
||||
/**
|
||||
\brief Access to the velocities of the simulation mesh on the host
|
||||
|
||||
Each element uses 4 float values containing velocity and inverseMass per vertex [x, y, z, inverseMass]
|
||||
The inverse mass must match the inverse mass in the simPositionInvMassCPU buffer at the same index. A copy of this value
|
||||
is stored in the simPositionInvMassCPU buffer to allow for faster access on the GPU. If the inverse masses in those two buffers
|
||||
don't match, the simulation may produce wrong results
|
||||
|
||||
Allows to access the CPU buffer of the simulation mesh's vertices
|
||||
|
||||
\return The buffer that contains the simulation mesh's velocities (x, y, z) and the inverse mass as 4th component
|
||||
*/
|
||||
virtual PxBuffer* getSimVelocityInvMassCPU() = 0;
|
||||
|
||||
/**
|
||||
\brief Access to the vertices of the collision mesh on the host
|
||||
|
||||
Each element uses 4 float values containing position and inverseMass per vertex [x, y, z, inverseMass]
|
||||
The inverse mass on the collision mesh has no effect, it can be set to an arbitrary value.
|
||||
|
||||
Allows to access the CPU buffer of the collision mesh's vertices
|
||||
|
||||
\return The buffer that contains the collision mesh's vertex positions (x, y, z) and the inverse mass as 4th component
|
||||
*/
|
||||
virtual PxBuffer* getPositionInvMassCPU() = 0;
|
||||
|
||||
/**
|
||||
\brief Access to the rest vertices of the collision mesh on the host
|
||||
|
||||
Each element uses 4 float values containing position and inverseMass per vertex [x, y, z, inverseMass]
|
||||
The inverse mass on the collision mesh has no effect, it can be set to an arbitrary value.
|
||||
|
||||
Allows to access the CPU buffer of the collision mesh's rest vertices
|
||||
|
||||
\return The buffer that contains the collision mesh's rest vertex positions (x, y, z) and the inverse mass as 4th component
|
||||
*/
|
||||
virtual PxBuffer* getRestPositionInvMassCPU() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the axis aligned bounding box enclosing the soft body.
|
||||
|
||||
\note It is not allowed to use this method while the simulation is running (except during PxScene::collide(),
|
||||
in PxContactModifyCallback or in contact report callbacks).
|
||||
|
||||
\param[in] inflation Scale factor for computed world bounds. Box extents are multiplied by this value.
|
||||
|
||||
\return The soft body's bounding box.
|
||||
|
||||
@see PxBounds3
|
||||
*/
|
||||
virtual PxBounds3 getWorldBounds(float inflation = 1.01f) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the GPU soft body index.
|
||||
|
||||
\return The GPU index, or 0xFFFFFFFF if the soft body is not in a scene.
|
||||
*/
|
||||
virtual PxU32 getGpuSoftBodyIndex() = 0;
|
||||
|
||||
virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxSoftBody"; }
|
||||
|
||||
|
||||
protected:
|
||||
PX_INLINE PxSoftBody(PxType concreteType, PxBaseFlags baseFlags) : PxActor(concreteType, baseFlags) {}
|
||||
PX_INLINE PxSoftBody(PxBaseFlags baseFlags) : PxActor(baseFlags) {}
|
||||
virtual bool isKindOf(const char* name) const PX_OVERRIDE { return !::strcmp("PxSoftBody", name) || PxActor::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if PX_VC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,67 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SOFT_BODY_FLAG_H
|
||||
#define PX_SOFT_BODY_FLAG_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief These flags determine what data is read or written to the gpu softbody.
|
||||
|
||||
@see PxScene::copySoftBodyData, PxScene::applySoftBodyData
|
||||
*/
|
||||
class PxSoftBodyDataFlag
|
||||
{
|
||||
public:
|
||||
enum Enum
|
||||
{
|
||||
eTET_INDICES = 0, //!< The collision mesh tetrahedron indices (quadruples of int32)
|
||||
eTET_STRESS = 1, //!< The collision mesh cauchy stress tensors (float 3x3 matrices)
|
||||
eTET_STRESSCOEFF = 2, //!< The collision mesh tetrahedron von Mises stress (float scalar)
|
||||
eTET_REST_POSES = 3, //!< The collision mesh tetrahedron rest poses (float 3x3 matrices)
|
||||
eTET_ROTATIONS = 4, //!< The collision mesh tetrahedron orientations (quaternions, quadruples of float)
|
||||
eTET_POSITION_INV_MASS = 5, //!< The collision mesh vertex positions and their inverted mass in the 4th component (quadruples of float)
|
||||
eSIM_TET_INDICES = 6, //!< The simulation mesh tetrahedron indices (quadruples of int32)
|
||||
eSIM_VELOCITY_INV_MASS = 7, //!< The simulation mesh vertex velocities and their inverted mass in the 4th component (quadruples of float)
|
||||
eSIM_POSITION_INV_MASS = 8, //!< The simulation mesh vertex positions and their inverted mass in the 4th component (quadruples of float)
|
||||
eSIM_KINEMATIC_TARGET = 9 //!< The simulation mesh kinematic target positions
|
||||
};
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,119 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SPARSE_GRID_PARAMS_H
|
||||
#define PX_SPARSE_GRID_PARAMS_H
|
||||
/** \addtogroup physics
|
||||
@{ */
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxMath.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Parameters to define the sparse grid settings like grid spacing, maximal number of subgrids etc.
|
||||
*/
|
||||
struct PxSparseGridParams
|
||||
{
|
||||
/**
|
||||
\brief Default constructor.
|
||||
*/
|
||||
PX_INLINE PxSparseGridParams()
|
||||
{
|
||||
maxNumSubgrids = 512;
|
||||
subgridSizeX = 32;
|
||||
subgridSizeY = 32;
|
||||
subgridSizeZ = 32;
|
||||
gridSpacing = 0.2f;
|
||||
haloSize = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Copy constructor.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_INLINE PxSparseGridParams(const PxSparseGridParams& params)
|
||||
{
|
||||
maxNumSubgrids = params.maxNumSubgrids;
|
||||
subgridSizeX = params.subgridSizeX;
|
||||
subgridSizeY = params.subgridSizeY;
|
||||
subgridSizeZ = params.subgridSizeZ;
|
||||
gridSpacing = params.gridSpacing;
|
||||
haloSize = params.haloSize;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_INLINE PxU32 getNumCellsPerSubgrid() const
|
||||
{
|
||||
return subgridSizeX * subgridSizeY * subgridSizeZ;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_INLINE PxReal getSqrt3dx() const
|
||||
{
|
||||
return PxSqrt(3.0f) * gridSpacing;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE void setToDefault()
|
||||
{
|
||||
*this = PxSparseGridParams();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_INLINE void operator = (const PxSparseGridParams& params)
|
||||
{
|
||||
maxNumSubgrids = params.maxNumSubgrids;
|
||||
subgridSizeX = params.subgridSizeX;
|
||||
subgridSizeY = params.subgridSizeY;
|
||||
subgridSizeZ = params.subgridSizeZ;
|
||||
gridSpacing = params.gridSpacing;
|
||||
haloSize = params.haloSize;
|
||||
}
|
||||
|
||||
PxU32 maxNumSubgrids; //!< Maximum number of subgrids
|
||||
PxReal gridSpacing; //!< Grid spacing for the grid
|
||||
PxU16 subgridSizeX; //!< Subgrid resolution in x dimension (must be an even number)
|
||||
PxU16 subgridSizeY; //!< Subgrid resolution in y dimension (must be an even number)
|
||||
PxU16 subgridSizeZ; //!< Subgrid resolution in z dimension (must be an even number)
|
||||
PxU16 haloSize; //!< Number of halo cell layers around every subgrid cell. Only 0 and 1 are valid values
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,253 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_VISUALIZATION_PARAMETER_H
|
||||
#define PX_VISUALIZATION_PARAMETER_H
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
NOTE: Parameters should NOT be conditionally compiled out. Even if a particular feature is not available.
|
||||
Otherwise the parameter values get shifted about and the numeric values change per platform. This causes problems
|
||||
when trying to serialize parameters.
|
||||
|
||||
New parameters should also be added to the end of the list for this reason. Also make sure to update
|
||||
eNUM_VALUES, which should be one higher than the maximum value in the enum.
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Debug visualization parameters.
|
||||
|
||||
#PxVisualizationParameter::eSCALE is the master switch for enabling visualization, please read the corresponding documentation
|
||||
for further details.
|
||||
|
||||
@see PxScene.setVisualizationParameter() PxScene.getVisualizationParameter() PxScene.getRenderBuffer()
|
||||
*/
|
||||
struct PxVisualizationParameter
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/* RigidBody-related parameters */
|
||||
|
||||
/**
|
||||
\brief This overall visualization scale gets multiplied with the individual scales. Setting to zero ignores all visualizations. Default is 0.
|
||||
|
||||
The below settings permit the debug visualization of various simulation properties.
|
||||
The setting is either zero, in which case the property is not drawn. Otherwise it is a scaling factor
|
||||
that determines the size of the visualization widgets.
|
||||
|
||||
Only objects for which visualization is turned on using setFlag(eVISUALIZATION) are visualized (see #PxActorFlag::eVISUALIZATION, #PxShapeFlag::eVISUALIZATION, ...).
|
||||
Contacts are visualized if they involve a body which is being visualized.
|
||||
Default is 0.
|
||||
|
||||
Notes:
|
||||
- to see any visualization, you have to set PxVisualizationParameter::eSCALE to nonzero first.
|
||||
- the scale factor has been introduced because it's difficult (if not impossible) to come up with a
|
||||
good scale for 3D vectors. Normals are normalized and their length is always 1. But it doesn't mean
|
||||
we should render a line of length 1. Depending on your objects/scene, this might be completely invisible
|
||||
or extremely huge. That's why the scale factor is here, to let you tune the length until it's ok in
|
||||
your scene.
|
||||
- however, things like collision shapes aren't ambiguous. They are clearly defined for example by the
|
||||
triangles & polygons themselves, and there's no point in scaling that. So the visualization widgets
|
||||
are only scaled when it makes sense.
|
||||
|
||||
<b>Range:</b> [0, PX_MAX_F32)<br>
|
||||
<b>Default:</b> 0
|
||||
*/
|
||||
eSCALE,
|
||||
|
||||
/**
|
||||
\brief Visualize the world axes.
|
||||
*/
|
||||
eWORLD_AXES,
|
||||
|
||||
/* Body visualizations */
|
||||
|
||||
/**
|
||||
\brief Visualize a bodies axes.
|
||||
|
||||
@see PxActor.globalPose PxActor
|
||||
*/
|
||||
eBODY_AXES,
|
||||
|
||||
/**
|
||||
\brief Visualize a body's mass axes.
|
||||
|
||||
This visualization is also useful for visualizing the sleep state of bodies. Sleeping bodies are drawn in
|
||||
black, while awake bodies are drawn in white. If the body is sleeping and part of a sleeping group, it is
|
||||
drawn in red.
|
||||
|
||||
@see PxBodyDesc.massLocalPose PxActor
|
||||
*/
|
||||
eBODY_MASS_AXES,
|
||||
|
||||
/**
|
||||
\brief Visualize the bodies linear velocity.
|
||||
|
||||
@see PxBodyDesc.linearVelocity PxActor
|
||||
*/
|
||||
eBODY_LIN_VELOCITY,
|
||||
|
||||
/**
|
||||
\brief Visualize the bodies angular velocity.
|
||||
|
||||
@see PxBodyDesc.angularVelocity PxActor
|
||||
*/
|
||||
eBODY_ANG_VELOCITY,
|
||||
|
||||
/* Contact visualisations */
|
||||
|
||||
/**
|
||||
\brief Visualize contact points. Will enable contact information.
|
||||
*/
|
||||
eCONTACT_POINT,
|
||||
|
||||
/**
|
||||
\brief Visualize contact normals. Will enable contact information.
|
||||
*/
|
||||
eCONTACT_NORMAL,
|
||||
|
||||
/**
|
||||
\brief Visualize contact errors. Will enable contact information.
|
||||
*/
|
||||
eCONTACT_ERROR,
|
||||
|
||||
/**
|
||||
\brief Visualize Contact forces. Will enable contact information.
|
||||
*/
|
||||
eCONTACT_FORCE,
|
||||
|
||||
/**
|
||||
\brief Visualize actor axes.
|
||||
|
||||
@see PxRigidStatic PxRigidDynamic PxArticulationLink
|
||||
*/
|
||||
eACTOR_AXES,
|
||||
|
||||
/**
|
||||
\brief Visualize bounds (AABBs in world space)
|
||||
*/
|
||||
eCOLLISION_AABBS,
|
||||
|
||||
/**
|
||||
\brief Shape visualization
|
||||
|
||||
@see PxShape
|
||||
*/
|
||||
eCOLLISION_SHAPES,
|
||||
|
||||
/**
|
||||
\brief Shape axis visualization
|
||||
|
||||
@see PxShape
|
||||
*/
|
||||
eCOLLISION_AXES,
|
||||
|
||||
/**
|
||||
\brief Compound visualization (compound AABBs in world space)
|
||||
*/
|
||||
eCOLLISION_COMPOUNDS,
|
||||
|
||||
/**
|
||||
\brief Mesh & convex face normals
|
||||
|
||||
@see PxTriangleMesh PxConvexMesh
|
||||
*/
|
||||
eCOLLISION_FNORMALS,
|
||||
|
||||
/**
|
||||
\brief Active edges for meshes
|
||||
|
||||
@see PxTriangleMesh
|
||||
*/
|
||||
eCOLLISION_EDGES,
|
||||
|
||||
/**
|
||||
\brief Static pruning structures
|
||||
*/
|
||||
eCOLLISION_STATIC,
|
||||
|
||||
/**
|
||||
\brief Dynamic pruning structures
|
||||
*/
|
||||
eCOLLISION_DYNAMIC,
|
||||
|
||||
/**
|
||||
\brief Joint local axes
|
||||
*/
|
||||
eJOINT_LOCAL_FRAMES,
|
||||
|
||||
/**
|
||||
\brief Joint limits
|
||||
*/
|
||||
eJOINT_LIMITS,
|
||||
|
||||
/**
|
||||
\brief Visualize culling box
|
||||
*/
|
||||
eCULL_BOX,
|
||||
|
||||
/**
|
||||
\brief MBP regions
|
||||
*/
|
||||
eMBP_REGIONS,
|
||||
|
||||
/**
|
||||
\brief Renders the simulation mesh instead of the collision mesh (only available for tetmeshes)
|
||||
*/
|
||||
eSIMULATION_MESH,
|
||||
|
||||
/**
|
||||
\brief Renders the SDF of a mesh instead of the collision mesh (only available for triangle meshes with SDFs)
|
||||
*/
|
||||
eSDF,
|
||||
|
||||
/**
|
||||
\brief This is not a parameter, it just records the current number of parameters (as maximum(PxVisualizationParameter)+1) for use in loops.
|
||||
*/
|
||||
eNUM_VALUES,
|
||||
|
||||
eFORCE_DWORD = 0x7fffffff
|
||||
};
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,227 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_BOX_CONTROLLER_H
|
||||
#define PX_BOX_CONTROLLER_H
|
||||
/** \addtogroup character
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "characterkinematic/PxController.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Descriptor for a box character controller.
|
||||
|
||||
@see PxBoxController PxControllerDesc
|
||||
*/
|
||||
class PxBoxControllerDesc : public PxControllerDesc
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief constructor sets to default.
|
||||
*/
|
||||
PX_INLINE PxBoxControllerDesc();
|
||||
PX_INLINE virtual ~PxBoxControllerDesc() {}
|
||||
|
||||
/**
|
||||
\brief copy constructor.
|
||||
*/
|
||||
PX_INLINE PxBoxControllerDesc(const PxBoxControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief assignment operator.
|
||||
*/
|
||||
PX_INLINE PxBoxControllerDesc& operator=(const PxBoxControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE virtual void setToDefault();
|
||||
|
||||
/**
|
||||
\brief returns true if the current settings are valid
|
||||
|
||||
\return True if the descriptor is valid.
|
||||
*/
|
||||
PX_INLINE virtual bool isValid() const;
|
||||
|
||||
/**
|
||||
\brief Half height
|
||||
|
||||
<b>Default:</b> 1.0
|
||||
*/
|
||||
PxF32 halfHeight; // Half-height in the "up" direction
|
||||
|
||||
/**
|
||||
\brief Half side extent
|
||||
|
||||
<b>Default:</b> 0.5
|
||||
*/
|
||||
PxF32 halfSideExtent; // Half-extent in the "side" direction
|
||||
|
||||
/**
|
||||
\brief Half forward extent
|
||||
|
||||
<b>Default:</b> 0.5
|
||||
*/
|
||||
PxF32 halfForwardExtent; // Half-extent in the "forward" direction
|
||||
|
||||
protected:
|
||||
PX_INLINE void copy(const PxBoxControllerDesc&);
|
||||
};
|
||||
|
||||
PX_INLINE PxBoxControllerDesc::PxBoxControllerDesc() :
|
||||
PxControllerDesc (PxControllerShapeType::eBOX),
|
||||
halfHeight (1.0f),
|
||||
halfSideExtent (0.5f),
|
||||
halfForwardExtent (0.5f)
|
||||
{
|
||||
}
|
||||
|
||||
PX_INLINE PxBoxControllerDesc::PxBoxControllerDesc(const PxBoxControllerDesc& other) : PxControllerDesc(other)
|
||||
{
|
||||
copy(other);
|
||||
}
|
||||
|
||||
PX_INLINE PxBoxControllerDesc& PxBoxControllerDesc::operator=(const PxBoxControllerDesc& other)
|
||||
{
|
||||
PxControllerDesc::operator=(other);
|
||||
copy(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE void PxBoxControllerDesc::copy(const PxBoxControllerDesc& other)
|
||||
{
|
||||
halfHeight = other.halfHeight;
|
||||
halfSideExtent = other.halfSideExtent;
|
||||
halfForwardExtent = other.halfForwardExtent;
|
||||
}
|
||||
|
||||
PX_INLINE void PxBoxControllerDesc::setToDefault()
|
||||
{
|
||||
*this = PxBoxControllerDesc();
|
||||
}
|
||||
|
||||
PX_INLINE bool PxBoxControllerDesc::isValid() const
|
||||
{
|
||||
if(!PxControllerDesc::isValid()) return false;
|
||||
if(halfHeight<=0.0f) return false;
|
||||
if(halfSideExtent<=0.0f) return false;
|
||||
if(halfForwardExtent<=0.0f) return false;
|
||||
if(stepOffset>2.0f*halfHeight) return false; // Prevents obvious mistakes
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Box character controller.
|
||||
|
||||
@see PxBoxControllerDesc PxController
|
||||
*/
|
||||
class PxBoxController : public PxController
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Gets controller's half height.
|
||||
|
||||
\return The half height of the controller.
|
||||
|
||||
@see PxBoxControllerDesc.halfHeight setHalfHeight()
|
||||
*/
|
||||
virtual PxF32 getHalfHeight() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets controller's half side extent.
|
||||
|
||||
\return The half side extent of the controller.
|
||||
|
||||
@see PxBoxControllerDesc.halfSideExtent setHalfSideExtent()
|
||||
*/
|
||||
virtual PxF32 getHalfSideExtent() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets controller's half forward extent.
|
||||
|
||||
\return The half forward extent of the controller.
|
||||
|
||||
@see PxBoxControllerDesc.halfForwardExtent setHalfForwardExtent()
|
||||
*/
|
||||
virtual PxF32 getHalfForwardExtent() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's half height.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] halfHeight The new half height for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
@see PxBoxControllerDesc.halfHeight getHalfHeight()
|
||||
*/
|
||||
virtual bool setHalfHeight(PxF32 halfHeight) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's half side extent.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] halfSideExtent The new half side extent for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
@see PxBoxControllerDesc.halfSideExtent getHalfSideExtent()
|
||||
*/
|
||||
virtual bool setHalfSideExtent(PxF32 halfSideExtent) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's half forward extent.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] halfForwardExtent The new half forward extent for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
@see PxBoxControllerDesc.halfForwardExtent getHalfForwardExtent()
|
||||
*/
|
||||
virtual bool setHalfForwardExtent(PxF32 halfForwardExtent) = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxBoxController() {}
|
||||
virtual ~PxBoxController() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,248 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CAPSULE_CONTROLLER_H
|
||||
#define PX_CAPSULE_CONTROLLER_H
|
||||
/** \addtogroup character
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "characterkinematic/PxController.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxCapsuleClimbingMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eEASY, //!< Standard mode, let the capsule climb over surfaces according to impact normal
|
||||
eCONSTRAINED, //!< Constrained mode, try to limit climbing according to the step offset
|
||||
|
||||
eLAST
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A descriptor for a capsule character controller.
|
||||
|
||||
@see PxCapsuleController PxControllerDesc
|
||||
*/
|
||||
class PxCapsuleControllerDesc : public PxControllerDesc
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief constructor sets to default.
|
||||
*/
|
||||
PX_INLINE PxCapsuleControllerDesc ();
|
||||
PX_INLINE virtual ~PxCapsuleControllerDesc () {}
|
||||
|
||||
/**
|
||||
\brief copy constructor.
|
||||
*/
|
||||
PX_INLINE PxCapsuleControllerDesc(const PxCapsuleControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief assignment operator.
|
||||
*/
|
||||
PX_INLINE PxCapsuleControllerDesc& operator=(const PxCapsuleControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE virtual void setToDefault();
|
||||
/**
|
||||
\brief returns true if the current settings are valid
|
||||
|
||||
\return True if the descriptor is valid.
|
||||
*/
|
||||
PX_INLINE virtual bool isValid() const;
|
||||
|
||||
/**
|
||||
\brief The radius of the capsule
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
@see PxCapsuleController
|
||||
*/
|
||||
PxF32 radius;
|
||||
|
||||
/**
|
||||
\brief The height of the controller
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
@see PxCapsuleController
|
||||
*/
|
||||
PxF32 height;
|
||||
|
||||
/**
|
||||
\brief The climbing mode
|
||||
|
||||
<b>Default:</b> PxCapsuleClimbingMode::eEASY
|
||||
|
||||
@see PxCapsuleController
|
||||
*/
|
||||
PxCapsuleClimbingMode::Enum climbingMode;
|
||||
|
||||
protected:
|
||||
PX_INLINE void copy(const PxCapsuleControllerDesc&);
|
||||
};
|
||||
|
||||
PX_INLINE PxCapsuleControllerDesc::PxCapsuleControllerDesc () : PxControllerDesc(PxControllerShapeType::eCAPSULE)
|
||||
{
|
||||
radius = height = 0.0f;
|
||||
climbingMode = PxCapsuleClimbingMode::eEASY;
|
||||
}
|
||||
|
||||
PX_INLINE PxCapsuleControllerDesc::PxCapsuleControllerDesc(const PxCapsuleControllerDesc& other) : PxControllerDesc(other)
|
||||
{
|
||||
copy(other);
|
||||
}
|
||||
|
||||
PX_INLINE PxCapsuleControllerDesc& PxCapsuleControllerDesc::operator=(const PxCapsuleControllerDesc& other)
|
||||
{
|
||||
PxControllerDesc::operator=(other);
|
||||
copy(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE void PxCapsuleControllerDesc::copy(const PxCapsuleControllerDesc& other)
|
||||
{
|
||||
radius = other.radius;
|
||||
height = other.height;
|
||||
climbingMode = other.climbingMode;
|
||||
}
|
||||
|
||||
PX_INLINE void PxCapsuleControllerDesc::setToDefault()
|
||||
{
|
||||
*this = PxCapsuleControllerDesc();
|
||||
}
|
||||
|
||||
PX_INLINE bool PxCapsuleControllerDesc::isValid() const
|
||||
{
|
||||
if(!PxControllerDesc::isValid()) return false;
|
||||
if(radius<=0.0f) return false;
|
||||
if(height<=0.0f) return false;
|
||||
if(stepOffset>height+radius*2.0f) return false; // Prevents obvious mistakes
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
\brief A capsule character controller.
|
||||
|
||||
The capsule is defined as a position, a vertical height, and a radius.
|
||||
The height is the distance between the two sphere centers at the end of the capsule.
|
||||
In other words:
|
||||
|
||||
p = pos (returned by controller)<br>
|
||||
h = height<br>
|
||||
r = radius<br>
|
||||
|
||||
p = center of capsule<br>
|
||||
top sphere center = p.y + h*0.5<br>
|
||||
bottom sphere center = p.y - h*0.5<br>
|
||||
top capsule point = p.y + h*0.5 + r<br>
|
||||
bottom capsule point = p.y - h*0.5 - r<br>
|
||||
*/
|
||||
class PxCapsuleController : public PxController
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Gets controller's radius.
|
||||
|
||||
\return The radius of the controller.
|
||||
|
||||
@see PxCapsuleControllerDesc.radius setRadius()
|
||||
*/
|
||||
virtual PxF32 getRadius() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's radius.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] radius The new radius for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
@see PxCapsuleControllerDesc.radius getRadius()
|
||||
*/
|
||||
virtual bool setRadius(PxF32 radius) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets controller's height.
|
||||
|
||||
\return The height of the capsule controller.
|
||||
|
||||
@see PxCapsuleControllerDesc.height setHeight()
|
||||
*/
|
||||
virtual PxF32 getHeight() const = 0;
|
||||
|
||||
/**
|
||||
\brief Resets controller's height.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] height The new height for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
@see PxCapsuleControllerDesc.height getHeight()
|
||||
*/
|
||||
virtual bool setHeight(PxF32 height) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets controller's climbing mode.
|
||||
|
||||
\return The capsule controller's climbing mode.
|
||||
|
||||
@see PxCapsuleControllerDesc.climbingMode setClimbingMode()
|
||||
*/
|
||||
virtual PxCapsuleClimbingMode::Enum getClimbingMode() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's climbing mode.
|
||||
|
||||
\param[in] mode The capsule controller's climbing mode.
|
||||
|
||||
@see PxCapsuleControllerDesc.climbingMode getClimbingMode()
|
||||
*/
|
||||
virtual bool setClimbingMode(PxCapsuleClimbingMode::Enum mode) = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxCapsuleController() {}
|
||||
virtual ~PxCapsuleController() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,925 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTROLLER_H
|
||||
#define PX_CONTROLLER_H
|
||||
/** \addtogroup character
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "characterkinematic/PxExtended.h"
|
||||
#include "characterkinematic/PxControllerObstacles.h"
|
||||
#include "PxQueryFiltering.h"
|
||||
#include "foundation/PxErrorCallback.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief The type of controller, eg box, sphere or capsule.
|
||||
*/
|
||||
struct PxControllerShapeType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief A box controller.
|
||||
|
||||
@see PxBoxController PxBoxControllerDesc
|
||||
*/
|
||||
eBOX,
|
||||
|
||||
/**
|
||||
\brief A capsule controller
|
||||
|
||||
@see PxCapsuleController PxCapsuleControllerDesc
|
||||
*/
|
||||
eCAPSULE,
|
||||
|
||||
eFORCE_DWORD = 0x7fffffff
|
||||
};
|
||||
};
|
||||
|
||||
class PxShape;
|
||||
class PxScene;
|
||||
class PxController;
|
||||
class PxRigidDynamic;
|
||||
class PxMaterial;
|
||||
struct PxFilterData;
|
||||
class PxQueryFilterCallback;
|
||||
class PxControllerBehaviorCallback;
|
||||
class PxObstacleContext;
|
||||
class PxObstacle;
|
||||
|
||||
/**
|
||||
\brief specifies how a CCT interacts with non-walkable parts.
|
||||
|
||||
This is only used when slopeLimit is non zero. It is currently enabled for static actors only, and not supported for spheres or capsules.
|
||||
*/
|
||||
struct PxControllerNonWalkableMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
ePREVENT_CLIMBING, //!< Stops character from climbing up non-walkable slopes, but doesn't move it otherwise
|
||||
ePREVENT_CLIMBING_AND_FORCE_SLIDING //!< Stops character from climbing up non-walkable slopes, and forces it to slide down those slopes
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief specifies which sides a character is colliding with.
|
||||
*/
|
||||
struct PxControllerCollisionFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eCOLLISION_SIDES = (1<<0), //!< Character is colliding to the sides.
|
||||
eCOLLISION_UP = (1<<1), //!< Character has collision above.
|
||||
eCOLLISION_DOWN = (1<<2) //!< Character has collision below.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxControllerCollisionFlag.
|
||||
|
||||
@see PxControllerCollisionFlag
|
||||
*/
|
||||
typedef PxFlags<PxControllerCollisionFlag::Enum, PxU8> PxControllerCollisionFlags;
|
||||
PX_FLAGS_OPERATORS(PxControllerCollisionFlag::Enum, PxU8)
|
||||
|
||||
/**
|
||||
\brief Describes a controller's internal state.
|
||||
*/
|
||||
struct PxControllerState
|
||||
{
|
||||
PxVec3 deltaXP; //!< delta position vector for the object the CCT is standing/riding on. Not always match the CCT delta when variable timesteps are used.
|
||||
PxShape* touchedShape; //!< Shape on which the CCT is standing
|
||||
PxRigidActor* touchedActor; //!< Actor owning 'touchedShape'
|
||||
PxObstacleHandle touchedObstacleHandle; // Obstacle on which the CCT is standing
|
||||
PxU32 collisionFlags; //!< Last known collision flags (PxControllerCollisionFlag)
|
||||
bool standOnAnotherCCT; //!< Are we standing on another CCT?
|
||||
bool standOnObstacle; //!< Are we standing on a user-defined obstacle?
|
||||
bool isMovingUp; //!< is CCT moving up or not? (i.e. explicit jumping)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a controller's internal statistics.
|
||||
*/
|
||||
struct PxControllerStats
|
||||
{
|
||||
PxU16 nbIterations;
|
||||
PxU16 nbFullUpdates;
|
||||
PxU16 nbPartialUpdates;
|
||||
PxU16 nbTessellation;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a generic CCT hit.
|
||||
*/
|
||||
struct PxControllerHit
|
||||
{
|
||||
PxController* controller; //!< Current controller
|
||||
PxExtendedVec3 worldPos; //!< Contact position in world space
|
||||
PxVec3 worldNormal; //!< Contact normal in world space
|
||||
PxVec3 dir; //!< Motion direction
|
||||
PxF32 length; //!< Motion length
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a hit between a CCT and a shape. Passed to onShapeHit()
|
||||
|
||||
@see PxUserControllerHitReport.onShapeHit()
|
||||
*/
|
||||
struct PxControllerShapeHit : public PxControllerHit
|
||||
{
|
||||
PxShape* shape; //!< Touched shape
|
||||
PxRigidActor* actor; //!< Touched actor
|
||||
PxU32 triangleIndex; //!< touched triangle index (only for meshes/heightfields)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a hit between a CCT and another CCT. Passed to onControllerHit().
|
||||
|
||||
@see PxUserControllerHitReport.onControllerHit()
|
||||
*/
|
||||
struct PxControllersHit : public PxControllerHit
|
||||
{
|
||||
PxController* other; //!< Touched controller
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a hit between a CCT and a user-defined obstacle. Passed to onObstacleHit().
|
||||
|
||||
@see PxUserControllerHitReport.onObstacleHit() PxObstacleContext
|
||||
*/
|
||||
struct PxControllerObstacleHit : public PxControllerHit
|
||||
{
|
||||
const void* userData;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief User callback class for character controller events.
|
||||
|
||||
\note Character controller hit reports are only generated when move is called.
|
||||
|
||||
@see PxControllerDesc.callback
|
||||
*/
|
||||
class PxUserControllerHitReport
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Called when current controller hits a shape.
|
||||
|
||||
This is called when the CCT moves and hits a shape. This will not be called when a moving shape hits a non-moving CCT.
|
||||
|
||||
\param[in] hit Provides information about the hit.
|
||||
|
||||
@see PxControllerShapeHit
|
||||
*/
|
||||
virtual void onShapeHit(const PxControllerShapeHit& hit) = 0;
|
||||
|
||||
/**
|
||||
\brief Called when current controller hits another controller.
|
||||
|
||||
\param[in] hit Provides information about the hit.
|
||||
|
||||
@see PxControllersHit
|
||||
*/
|
||||
virtual void onControllerHit(const PxControllersHit& hit) = 0;
|
||||
|
||||
/**
|
||||
\brief Called when current controller hits a user-defined obstacle.
|
||||
|
||||
\param[in] hit Provides information about the hit.
|
||||
|
||||
@see PxControllerObstacleHit PxObstacleContext
|
||||
*/
|
||||
virtual void onObstacleHit(const PxControllerObstacleHit& hit) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxUserControllerHitReport(){}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Dedicated filtering callback for CCT vs CCT.
|
||||
|
||||
This controls collisions between CCTs (one CCT vs anoter CCT).
|
||||
|
||||
To make each CCT collide against all other CCTs, just return true - or simply avoid defining a callback.
|
||||
To make each CCT freely go through all other CCTs, just return false.
|
||||
Otherwise create a custom filtering logic in this callback.
|
||||
|
||||
@see PxControllerFilters
|
||||
*/
|
||||
class PxControllerFilterCallback
|
||||
{
|
||||
public:
|
||||
virtual ~PxControllerFilterCallback(){}
|
||||
|
||||
/**
|
||||
\brief Filtering method for CCT-vs-CCT.
|
||||
|
||||
\param[in] a First CCT
|
||||
\param[in] b Second CCT
|
||||
\return true to keep the pair, false to filter it out
|
||||
*/
|
||||
virtual bool filter(const PxController& a, const PxController& b) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Filtering data for "move" call.
|
||||
|
||||
This class contains all filtering-related parameters for the PxController::move() call.
|
||||
|
||||
Collisions between a CCT and the world are filtered using the mFilterData, mFilterCallback and mFilterFlags
|
||||
members. These parameters are internally passed to PxScene::overlap() to find objects touched by the CCT.
|
||||
Please refer to the PxScene::overlap() documentation for details.
|
||||
|
||||
Collisions between a CCT and another CCT are filtered using the mCCTFilterCallback member. If this filter
|
||||
callback is not defined, none of the CCT-vs-CCT collisions are filtered, and each CCT will collide against
|
||||
all other CCTs.
|
||||
|
||||
\note PxQueryFlag::eANY_HIT and PxQueryFlag::eNO_BLOCK are ignored in mFilterFlags.
|
||||
|
||||
@see PxController.move() PxControllerFilterCallback
|
||||
*/
|
||||
class PxControllerFilters
|
||||
{
|
||||
public:
|
||||
|
||||
PX_INLINE PxControllerFilters(const PxFilterData* filterData=NULL, PxQueryFilterCallback* cb=NULL, PxControllerFilterCallback* cctFilterCb=NULL) :
|
||||
mFilterData (filterData),
|
||||
mFilterCallback (cb),
|
||||
mFilterFlags (PxQueryFlag::eSTATIC|PxQueryFlag::eDYNAMIC|PxQueryFlag::ePREFILTER),
|
||||
mCCTFilterCallback (cctFilterCb)
|
||||
{}
|
||||
|
||||
// CCT-vs-shapes:
|
||||
const PxFilterData* mFilterData; //!< Data for internal PxQueryFilterData structure. Passed to PxScene::overlap() call.
|
||||
//!< This can be NULL, in which case a default PxFilterData is used.
|
||||
PxQueryFilterCallback* mFilterCallback; //!< Custom filter logic (can be NULL). Passed to PxScene::overlap() call.
|
||||
PxQueryFlags mFilterFlags; //!< Flags for internal PxQueryFilterData structure. Passed to PxScene::overlap() call.
|
||||
// CCT-vs-CCT:
|
||||
PxControllerFilterCallback* mCCTFilterCallback; //!< CCT-vs-CCT filter callback. If NULL, all CCT-vs-CCT collisions are kept.
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Descriptor class for a character controller.
|
||||
|
||||
@see PxBoxController PxCapsuleController
|
||||
*/
|
||||
class PxControllerDesc
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief returns true if the current settings are valid
|
||||
|
||||
\return True if the descriptor is valid.
|
||||
*/
|
||||
PX_INLINE virtual bool isValid() const;
|
||||
|
||||
/**
|
||||
\brief Returns the character controller type
|
||||
|
||||
\return The controllers type.
|
||||
|
||||
@see PxControllerType PxCapsuleControllerDesc PxBoxControllerDesc
|
||||
*/
|
||||
PX_INLINE PxControllerShapeType::Enum getType() const { return mType; }
|
||||
|
||||
/**
|
||||
\brief The position of the character
|
||||
|
||||
\note The character's initial position must be such that it does not overlap the static geometry.
|
||||
|
||||
<b>Default:</b> Zero
|
||||
*/
|
||||
PxExtendedVec3 position;
|
||||
|
||||
/**
|
||||
\brief Specifies the 'up' direction
|
||||
|
||||
In order to provide stepping functionality the SDK must be informed about the up direction.
|
||||
|
||||
<b>Default:</b> (0, 1, 0)
|
||||
|
||||
*/
|
||||
PxVec3 upDirection;
|
||||
|
||||
/**
|
||||
\brief The maximum slope which the character can walk up.
|
||||
|
||||
In general it is desirable to limit where the character can walk, in particular it is unrealistic
|
||||
for the character to be able to climb arbitary slopes.
|
||||
|
||||
The limit is expressed as the cosine of desired limit angle. A value of 0 disables this feature.
|
||||
|
||||
\warning It is currently enabled for static actors only (not for dynamic/kinematic actors), and not supported for spheres or capsules.
|
||||
|
||||
<b>Default:</b> 0.707
|
||||
|
||||
@see upDirection invisibleWallHeight maxJumpHeight
|
||||
*/
|
||||
PxF32 slopeLimit;
|
||||
|
||||
/**
|
||||
\brief Height of invisible walls created around non-walkable triangles
|
||||
|
||||
The library can automatically create invisible walls around non-walkable triangles defined
|
||||
by the 'slopeLimit' parameter. This defines the height of those walls. If it is 0.0, then
|
||||
no extra triangles are created.
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
@see upDirection slopeLimit maxJumpHeight
|
||||
*/
|
||||
PxF32 invisibleWallHeight;
|
||||
|
||||
/**
|
||||
\brief Maximum height a jumping character can reach
|
||||
|
||||
This is only used if invisible walls are created ('invisibleWallHeight' is non zero).
|
||||
|
||||
When a character jumps, the non-walkable triangles he might fly over are not found
|
||||
by the collision queries (since the character's bounding volume does not touch them).
|
||||
Thus those non-walkable triangles do not create invisible walls, and it is possible
|
||||
for a jumping character to land on a non-walkable triangle, while he wouldn't have
|
||||
reached that place by just walking.
|
||||
|
||||
The 'maxJumpHeight' variable is used to extend the size of the collision volume
|
||||
downward. This way, all the non-walkable triangles are properly found by the collision
|
||||
queries and it becomes impossible to 'jump over' invisible walls.
|
||||
|
||||
If the character in your game can not jump, it is safe to use 0.0 here. Otherwise it
|
||||
is best to keep this value as small as possible, since a larger collision volume
|
||||
means more triangles to process.
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
@see upDirection slopeLimit invisibleWallHeight
|
||||
*/
|
||||
PxF32 maxJumpHeight;
|
||||
|
||||
/**
|
||||
\brief The contact offset used by the controller.
|
||||
|
||||
Specifies a skin around the object within which contacts will be generated.
|
||||
Use it to avoid numerical precision issues.
|
||||
|
||||
This is dependant on the scale of the users world, but should be a small, positive
|
||||
non zero value.
|
||||
|
||||
<b>Default:</b> 0.1
|
||||
*/
|
||||
PxF32 contactOffset;
|
||||
|
||||
/**
|
||||
\brief Defines the maximum height of an obstacle which the character can climb.
|
||||
|
||||
A small value will mean that the character gets stuck and cannot walk up stairs etc,
|
||||
a value which is too large will mean that the character can climb over unrealistically
|
||||
high obstacles.
|
||||
|
||||
<b>Default:</b> 0.5
|
||||
|
||||
@see upDirection
|
||||
*/
|
||||
PxF32 stepOffset;
|
||||
|
||||
/**
|
||||
\brief Density of underlying kinematic actor
|
||||
|
||||
The CCT creates a PhysX's kinematic actor under the hood. This controls its density.
|
||||
|
||||
<b>Default:</b> 10.0
|
||||
*/
|
||||
PxF32 density;
|
||||
|
||||
/**
|
||||
\brief Scale coefficient for underlying kinematic actor
|
||||
|
||||
The CCT creates a PhysX's kinematic actor under the hood. This controls its scale factor.
|
||||
This should be a number a bit smaller than 1.0.
|
||||
|
||||
<b>Default:</b> 0.8
|
||||
*/
|
||||
PxF32 scaleCoeff;
|
||||
|
||||
/**
|
||||
\brief Cached volume growth
|
||||
|
||||
Amount of space around the controller we cache to improve performance. This is a scale factor
|
||||
that should be higher than 1.0f but not too big, ideally lower than 2.0f.
|
||||
|
||||
<b>Default:</b> 1.5
|
||||
*/
|
||||
PxF32 volumeGrowth;
|
||||
|
||||
/**
|
||||
\brief Specifies a user report callback.
|
||||
|
||||
This report callback is called when the character collides with shapes and other characters.
|
||||
|
||||
Setting this to NULL disables the callback.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
|
||||
@see PxUserControllerHitReport
|
||||
*/
|
||||
PxUserControllerHitReport* reportCallback;
|
||||
|
||||
/**
|
||||
\brief Specifies a user behavior callback.
|
||||
|
||||
This behavior callback is called to customize the controller's behavior w.r.t. touched shapes.
|
||||
|
||||
Setting this to NULL disables the callback.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
|
||||
@see PxControllerBehaviorCallback
|
||||
*/
|
||||
PxControllerBehaviorCallback* behaviorCallback;
|
||||
|
||||
/**
|
||||
\brief The non-walkable mode controls if a character controller slides or not on a non-walkable part.
|
||||
|
||||
This is only used when slopeLimit is non zero.
|
||||
|
||||
<b>Default:</b> PxControllerNonWalkableMode::ePREVENT_CLIMBING
|
||||
|
||||
@see PxControllerNonWalkableMode
|
||||
*/
|
||||
PxControllerNonWalkableMode::Enum nonWalkableMode;
|
||||
|
||||
/**
|
||||
\brief The material for the actor associated with the controller.
|
||||
|
||||
The controller internally creates a rigid body actor. This parameter specifies the material of the actor.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
|
||||
@see PxMaterial
|
||||
*/
|
||||
PxMaterial* material;
|
||||
|
||||
/**
|
||||
\brief Use a deletion listener to get informed about released objects and clear internal caches if needed.
|
||||
|
||||
If a character controller registers a deletion listener, it will get informed about released objects. That allows the
|
||||
controller to invalidate cached data that connects to a released object. If a deletion listener is not
|
||||
registered, PxController::invalidateCache has to be called manually after objects have been released.
|
||||
|
||||
@see PxController::invalidateCache
|
||||
|
||||
<b>Default:</b> true
|
||||
*/
|
||||
bool registerDeletionListener;
|
||||
|
||||
/**
|
||||
\brief Client ID for associated actor.
|
||||
|
||||
@see PxClientID PxActor::setOwnerClient
|
||||
|
||||
<b>Default:</b> PX_DEFAULT_CLIENT
|
||||
*/
|
||||
PxClientID clientID;
|
||||
|
||||
/**
|
||||
\brief User specified data associated with the controller.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
*/
|
||||
void* userData;
|
||||
|
||||
protected:
|
||||
const PxControllerShapeType::Enum mType; //!< The type of the controller. This gets set by the derived class' ctor, the user should not have to change it.
|
||||
|
||||
/**
|
||||
\brief constructor sets to default.
|
||||
*/
|
||||
PX_INLINE PxControllerDesc(PxControllerShapeType::Enum);
|
||||
PX_INLINE virtual ~PxControllerDesc();
|
||||
|
||||
/**
|
||||
\brief copy constructor.
|
||||
*/
|
||||
PX_INLINE PxControllerDesc(const PxControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief assignment operator.
|
||||
*/
|
||||
PX_INLINE PxControllerDesc& operator=(const PxControllerDesc&);
|
||||
|
||||
PX_INLINE void copy(const PxControllerDesc&);
|
||||
};
|
||||
|
||||
PX_INLINE PxControllerDesc::PxControllerDesc(PxControllerShapeType::Enum t) :
|
||||
position (PxExtended(0.0), PxExtended(0.0), PxExtended(0.0)),
|
||||
upDirection (0.0f, 1.0f, 0.0f),
|
||||
slopeLimit (0.707f),
|
||||
invisibleWallHeight (0.0f),
|
||||
maxJumpHeight (0.0f),
|
||||
contactOffset (0.1f),
|
||||
stepOffset (0.5f),
|
||||
density (10.0f),
|
||||
scaleCoeff (0.8f),
|
||||
volumeGrowth (1.5f),
|
||||
reportCallback (NULL),
|
||||
behaviorCallback (NULL),
|
||||
nonWalkableMode (PxControllerNonWalkableMode::ePREVENT_CLIMBING),
|
||||
material (NULL),
|
||||
registerDeletionListener (true),
|
||||
clientID (PX_DEFAULT_CLIENT),
|
||||
userData (NULL),
|
||||
mType (t)
|
||||
{
|
||||
}
|
||||
|
||||
PX_INLINE PxControllerDesc::PxControllerDesc(const PxControllerDesc& other) : mType(other.mType)
|
||||
{
|
||||
copy(other);
|
||||
}
|
||||
|
||||
PX_INLINE PxControllerDesc& PxControllerDesc::operator=(const PxControllerDesc& other)
|
||||
{
|
||||
copy(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE void PxControllerDesc::copy(const PxControllerDesc& other)
|
||||
{
|
||||
upDirection = other.upDirection;
|
||||
slopeLimit = other.slopeLimit;
|
||||
contactOffset = other.contactOffset;
|
||||
stepOffset = other.stepOffset;
|
||||
density = other.density;
|
||||
scaleCoeff = other.scaleCoeff;
|
||||
volumeGrowth = other.volumeGrowth;
|
||||
reportCallback = other.reportCallback;
|
||||
behaviorCallback = other.behaviorCallback;
|
||||
userData = other.userData;
|
||||
nonWalkableMode = other.nonWalkableMode;
|
||||
position.x = other.position.x;
|
||||
position.y = other.position.y;
|
||||
position.z = other.position.z;
|
||||
material = other.material;
|
||||
invisibleWallHeight = other.invisibleWallHeight;
|
||||
maxJumpHeight = other.maxJumpHeight;
|
||||
registerDeletionListener = other.registerDeletionListener;
|
||||
clientID = other.clientID;
|
||||
}
|
||||
|
||||
PX_INLINE PxControllerDesc::~PxControllerDesc()
|
||||
{
|
||||
}
|
||||
|
||||
PX_INLINE bool PxControllerDesc::isValid() const
|
||||
{
|
||||
if( mType!=PxControllerShapeType::eBOX
|
||||
&& mType!=PxControllerShapeType::eCAPSULE)
|
||||
return false;
|
||||
if(scaleCoeff<0.0f)
|
||||
return false;
|
||||
if(volumeGrowth<1.0f)
|
||||
return false;
|
||||
if(density<0.0f)
|
||||
return false;
|
||||
if(slopeLimit<0.0f)
|
||||
return false;
|
||||
if(stepOffset<0.0f)
|
||||
return false;
|
||||
if(contactOffset<=0.0f)
|
||||
return false;
|
||||
if(!material)
|
||||
return false;
|
||||
if(!toVec3(position).isFinite())
|
||||
return false; //the float version needs to be finite otherwise actor creation will fail.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Base class for character controllers.
|
||||
|
||||
@see PxCapsuleController PxBoxController
|
||||
*/
|
||||
class PxController
|
||||
{
|
||||
public:
|
||||
//*********************************************************************
|
||||
// DEPRECATED FUNCTIONS:
|
||||
//
|
||||
// PX_DEPRECATED virtual void setInteraction(PxCCTInteractionMode::Enum flag) = 0;
|
||||
// PX_DEPRECATED virtual PxCCTInteractionMode::Enum getInteraction() const = 0;
|
||||
// PX_DEPRECATED virtual void setGroupsBitmask(PxU32 bitmask) = 0;
|
||||
// PX_DEPRECATED virtual PxU32 getGroupsBitmask() const = 0;
|
||||
//
|
||||
// => replaced with:
|
||||
//
|
||||
// PxControllerFilters::mCCTFilterCallback. Please define a PxControllerFilterCallback object and emulate the old interaction mode there.
|
||||
//
|
||||
//*********************************************************************
|
||||
|
||||
/**
|
||||
\brief Return the type of controller
|
||||
|
||||
@see PxControllerType
|
||||
*/
|
||||
virtual PxControllerShapeType::Enum getType() const = 0;
|
||||
|
||||
/**
|
||||
\brief Releases the controller.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Moves the character using a "collide-and-slide" algorithm.
|
||||
|
||||
\param[in] disp Displacement vector
|
||||
\param[in] minDist The minimum travelled distance to consider. If travelled distance is smaller, the character doesn't move.
|
||||
This is used to stop the recursive motion algorithm when remaining distance to travel is small.
|
||||
\param[in] elapsedTime Time elapsed since last call
|
||||
\param[in] filters User-defined filters for this move
|
||||
\param[in] obstacles Potential additional obstacles the CCT should collide with.
|
||||
\return Collision flags, collection of ::PxControllerCollisionFlags
|
||||
*/
|
||||
virtual PxControllerCollisionFlags move(const PxVec3& disp, PxF32 minDist, PxF32 elapsedTime, const PxControllerFilters& filters, const PxObstacleContext* obstacles=NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's position.
|
||||
|
||||
The position controlled by this function is the center of the collision shape.
|
||||
|
||||
\warning This is a 'teleport' function, it doesn't check for collisions.
|
||||
\warning The character's position must be such that it does not overlap the static geometry.
|
||||
|
||||
To move the character under normal conditions use the #move() function.
|
||||
|
||||
\param[in] position The new (center) positon for the controller.
|
||||
\return Currently always returns true.
|
||||
|
||||
@see PxControllerDesc.position getPosition() getFootPosition() setFootPosition() move()
|
||||
*/
|
||||
virtual bool setPosition(const PxExtendedVec3& position) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the raw position of the controller.
|
||||
|
||||
The position retrieved by this function is the center of the collision shape. To retrieve the bottom position of the shape,
|
||||
a.k.a. the foot position, use the getFootPosition() function.
|
||||
|
||||
The position is updated by calls to move(). Calling this method without calling
|
||||
move() will return the last position or the initial position of the controller.
|
||||
|
||||
\return The controller's center position
|
||||
|
||||
@see PxControllerDesc.position setPosition() getFootPosition() setFootPosition() move()
|
||||
*/
|
||||
virtual const PxExtendedVec3& getPosition() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set controller's foot position.
|
||||
|
||||
The position controlled by this function is the bottom of the collision shape, a.k.a. the foot position.
|
||||
|
||||
\note The foot position takes the contact offset into account
|
||||
|
||||
\warning This is a 'teleport' function, it doesn't check for collisions.
|
||||
|
||||
To move the character under normal conditions use the #move() function.
|
||||
|
||||
\param[in] position The new (bottom) positon for the controller.
|
||||
\return Currently always returns true.
|
||||
|
||||
@see PxControllerDesc.position setPosition() getPosition() getFootPosition() move()
|
||||
*/
|
||||
virtual bool setFootPosition(const PxExtendedVec3& position) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the "foot" position of the controller, i.e. the position of the bottom of the CCT's shape.
|
||||
|
||||
\note The foot position takes the contact offset into account
|
||||
|
||||
\return The controller's foot position
|
||||
|
||||
@see PxControllerDesc.position setPosition() getPosition() setFootPosition() move()
|
||||
*/
|
||||
virtual PxExtendedVec3 getFootPosition() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the rigid body actor associated with this controller (see PhysX documentation).
|
||||
The behavior upon manually altering this actor is undefined, you should primarily
|
||||
use it for reading const properties.
|
||||
|
||||
\return the actor associated with the controller.
|
||||
*/
|
||||
virtual PxRigidDynamic* getActor() const = 0;
|
||||
|
||||
/**
|
||||
\brief The step height.
|
||||
|
||||
\param[in] offset The new step offset for the controller.
|
||||
|
||||
@see PxControllerDesc.stepOffset
|
||||
*/
|
||||
virtual void setStepOffset(const PxF32 offset) =0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the step height.
|
||||
|
||||
\return The step offset for the controller.
|
||||
|
||||
@see setStepOffset()
|
||||
*/
|
||||
virtual PxF32 getStepOffset() const =0;
|
||||
|
||||
/**
|
||||
\brief Sets the non-walkable mode for the CCT.
|
||||
|
||||
\param[in] flag The new value of the non-walkable mode.
|
||||
|
||||
@see PxControllerNonWalkableMode
|
||||
*/
|
||||
virtual void setNonWalkableMode(PxControllerNonWalkableMode::Enum flag) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the non-walkable mode for the CCT.
|
||||
|
||||
\return The current non-walkable mode.
|
||||
|
||||
@see PxControllerNonWalkableMode
|
||||
*/
|
||||
virtual PxControllerNonWalkableMode::Enum getNonWalkableMode() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the contact offset.
|
||||
|
||||
\return The contact offset for the controller.
|
||||
|
||||
@see PxControllerDesc.contactOffset
|
||||
*/
|
||||
virtual PxF32 getContactOffset() const =0;
|
||||
|
||||
/**
|
||||
\brief Sets the contact offset.
|
||||
|
||||
\param[in] offset The contact offset for the controller.
|
||||
|
||||
@see PxControllerDesc.contactOffset
|
||||
*/
|
||||
virtual void setContactOffset(PxF32 offset) =0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the 'up' direction.
|
||||
|
||||
\return The up direction for the controller.
|
||||
|
||||
@see PxControllerDesc.upDirection
|
||||
*/
|
||||
virtual PxVec3 getUpDirection() const =0;
|
||||
|
||||
/**
|
||||
\brief Sets the 'up' direction.
|
||||
|
||||
\param[in] up The up direction for the controller.
|
||||
|
||||
@see PxControllerDesc.upDirection
|
||||
*/
|
||||
virtual void setUpDirection(const PxVec3& up) =0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the slope limit.
|
||||
|
||||
\return The slope limit for the controller.
|
||||
|
||||
@see PxControllerDesc.slopeLimit
|
||||
*/
|
||||
virtual PxF32 getSlopeLimit() const =0;
|
||||
|
||||
/**
|
||||
\brief Sets the slope limit.
|
||||
|
||||
\note This feature can not be enabled at runtime, i.e. if the slope limit is zero when creating the CCT
|
||||
(which disables the feature) then changing the slope limit at runtime will not have any effect, and the call
|
||||
will be ignored.
|
||||
|
||||
\param[in] slopeLimit The slope limit for the controller.
|
||||
|
||||
@see PxControllerDesc.slopeLimit
|
||||
*/
|
||||
virtual void setSlopeLimit(PxF32 slopeLimit) =0;
|
||||
|
||||
/**
|
||||
\brief Flushes internal geometry cache.
|
||||
|
||||
The character controller uses caching in order to speed up collision testing. The cache is
|
||||
automatically flushed when a change to static objects is detected in the scene. For example when a
|
||||
static shape is added, updated, or removed from the scene, the cache is automatically invalidated.
|
||||
|
||||
However there may be situations that cannot be automatically detected, and those require manual
|
||||
invalidation of the cache. Currently the user must call this when the filtering behavior changes (the
|
||||
PxControllerFilters parameter of the PxController::move call). While the controller in principle
|
||||
could detect a change in these parameters, it cannot detect a change in the behavior of the filtering
|
||||
function.
|
||||
|
||||
@see PxController.move
|
||||
*/
|
||||
virtual void invalidateCache() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the scene associated with the controller.
|
||||
|
||||
\return The physics scene
|
||||
*/
|
||||
virtual PxScene* getScene() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the user data associated with this controller.
|
||||
|
||||
\return The user pointer associated with the controller.
|
||||
|
||||
@see PxControllerDesc.userData
|
||||
*/
|
||||
virtual void* getUserData() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the user data associated with this controller.
|
||||
|
||||
\param[in] userData The user pointer associated with the controller.
|
||||
|
||||
@see PxControllerDesc.userData
|
||||
*/
|
||||
virtual void setUserData(void* userData) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns information about the controller's internal state.
|
||||
|
||||
\param[out] state The controller's internal state
|
||||
|
||||
@see PxControllerState
|
||||
*/
|
||||
virtual void getState(PxControllerState& state) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the controller's internal statistics.
|
||||
|
||||
\param[out] stats The controller's internal statistics
|
||||
|
||||
@see PxControllerStats
|
||||
*/
|
||||
virtual void getStats(PxControllerStats& stats) const = 0;
|
||||
|
||||
/**
|
||||
\brief Resizes the controller.
|
||||
|
||||
This function attempts to resize the controller to a given size, while making sure the bottom
|
||||
position of the controller remains constant. In other words the function modifies both the
|
||||
height and the (center) position of the controller. This is a helper function that can be used
|
||||
to implement a 'crouch' functionality for example.
|
||||
|
||||
\param[in] height Desired controller's height
|
||||
*/
|
||||
virtual void resize(PxReal height) = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxController() {}
|
||||
virtual ~PxController() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,134 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTROLLER_BEHAVIOR_H
|
||||
#define PX_CONTROLLER_BEHAVIOR_H
|
||||
/** \addtogroup character
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxFiltering.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxShape;
|
||||
class PxObstacle;
|
||||
class PxController;
|
||||
|
||||
/**
|
||||
\brief specifies controller behavior
|
||||
*/
|
||||
struct PxControllerBehaviorFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eCCT_CAN_RIDE_ON_OBJECT = (1<<0), //!< Controller can ride on touched object (i.e. when this touched object is moving horizontally). \note The CCT vs. CCT case is not supported.
|
||||
eCCT_SLIDE = (1<<1), //!< Controller should slide on touched object
|
||||
eCCT_USER_DEFINED_RIDE = (1<<2) //!< Disable all code dealing with controllers riding on objects, let users define it outside of the SDK.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxControllerBehaviorFlag.
|
||||
|
||||
@see PxControllerBehaviorFlag
|
||||
*/
|
||||
typedef PxFlags<PxControllerBehaviorFlag::Enum, PxU8> PxControllerBehaviorFlags;
|
||||
PX_FLAGS_OPERATORS(PxControllerBehaviorFlag::Enum, PxU8)
|
||||
|
||||
/**
|
||||
\brief User behavior callback.
|
||||
|
||||
This behavior callback is called to customize the controller's behavior w.r.t. touched shapes.
|
||||
*/
|
||||
class PxControllerBehaviorCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Retrieve behavior flags for a shape.
|
||||
|
||||
When the CCT touches a shape, the CCT's behavior w.r.t. this shape can be customized by users.
|
||||
This function retrieves the desired PxControllerBehaviorFlag flags capturing the desired behavior.
|
||||
|
||||
\note See comments about deprecated functions at the start of this class
|
||||
|
||||
\param[in] shape The shape the CCT is currently touching
|
||||
\param[in] actor The actor owning the shape
|
||||
|
||||
\return Desired behavior flags for the given shape
|
||||
|
||||
@see PxControllerBehaviorFlag
|
||||
*/
|
||||
virtual PxControllerBehaviorFlags getBehaviorFlags(const PxShape& shape, const PxActor& actor) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve behavior flags for a controller.
|
||||
|
||||
When the CCT touches a controller, the CCT's behavior w.r.t. this controller can be customized by users.
|
||||
This function retrieves the desired PxControllerBehaviorFlag flags capturing the desired behavior.
|
||||
|
||||
\note The flag PxControllerBehaviorFlag::eCCT_CAN_RIDE_ON_OBJECT is not supported.
|
||||
\note See comments about deprecated functions at the start of this class
|
||||
|
||||
\param[in] controller The controller the CCT is currently touching
|
||||
|
||||
\return Desired behavior flags for the given controller
|
||||
|
||||
@see PxControllerBehaviorFlag
|
||||
*/
|
||||
virtual PxControllerBehaviorFlags getBehaviorFlags(const PxController& controller) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve behavior flags for an obstacle.
|
||||
|
||||
When the CCT touches an obstacle, the CCT's behavior w.r.t. this obstacle can be customized by users.
|
||||
This function retrieves the desired PxControllerBehaviorFlag flags capturing the desired behavior.
|
||||
|
||||
\note See comments about deprecated functions at the start of this class
|
||||
|
||||
\param[in] obstacle The obstacle the CCT is currently touching
|
||||
|
||||
\return Desired behavior flags for the given obstacle
|
||||
|
||||
@see PxControllerBehaviorFlag
|
||||
*/
|
||||
virtual PxControllerBehaviorFlags getBehaviorFlags(const PxObstacle& obstacle) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxControllerBehaviorCallback(){}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,298 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTROLLER_MANAGER_H
|
||||
#define PX_CONTROLLER_MANAGER_H
|
||||
/** \addtogroup character
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "foundation/PxErrorCallback.h"
|
||||
#include "common/PxRenderBuffer.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxPhysics;
|
||||
class PxScene;
|
||||
class PxController;
|
||||
class PxControllerDesc;
|
||||
class PxObstacleContext;
|
||||
class PxControllerFilterCallback;
|
||||
|
||||
/**
|
||||
\brief specifies debug-rendering flags
|
||||
*/
|
||||
struct PxControllerDebugRenderFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eTEMPORAL_BV = (1<<0), //!< Temporal bounding volume around controllers
|
||||
eCACHED_BV = (1<<1), //!< Cached bounding volume around controllers
|
||||
eOBSTACLES = (1<<2), //!< User-defined obstacles
|
||||
|
||||
eNONE = 0,
|
||||
eALL = 0xffffffff
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxControllerDebugRenderFlag.
|
||||
|
||||
@see PxControllerDebugRenderFlag
|
||||
*/
|
||||
typedef PxFlags<PxControllerDebugRenderFlag::Enum, PxU32> PxControllerDebugRenderFlags;
|
||||
PX_FLAGS_OPERATORS(PxControllerDebugRenderFlag::Enum, PxU32)
|
||||
|
||||
|
||||
/**
|
||||
\brief Manages an array of character controllers.
|
||||
|
||||
@see PxController PxBoxController PxCapsuleController
|
||||
*/
|
||||
class PxControllerManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Releases the controller manager.
|
||||
|
||||
\note This will release all associated controllers and obstacle contexts.
|
||||
|
||||
\note This function is required to be called to release foundation usage.
|
||||
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the scene the manager is adding the controllers to.
|
||||
|
||||
\return The associated physics scene.
|
||||
*/
|
||||
virtual PxScene& getScene() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of controllers that are being managed.
|
||||
|
||||
\return The number of controllers.
|
||||
*/
|
||||
virtual PxU32 getNbControllers() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve one of the controllers in the manager.
|
||||
|
||||
\param index the index of the controller to return
|
||||
\return The controller with the specified index.
|
||||
*/
|
||||
virtual PxController* getController(PxU32 index) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates a new character controller.
|
||||
|
||||
\param[in] desc The controllers descriptor
|
||||
\return The new controller
|
||||
|
||||
@see PxController PxController.release() PxControllerDesc
|
||||
*/
|
||||
virtual PxController* createController(const PxControllerDesc& desc) = 0;
|
||||
|
||||
/**
|
||||
\brief Releases all the controllers that are being managed.
|
||||
*/
|
||||
virtual void purgeControllers() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves debug data.
|
||||
|
||||
\return The render buffer filled with debug-render data
|
||||
|
||||
@see PxControllerManager.setDebugRenderingFlags()
|
||||
*/
|
||||
virtual PxRenderBuffer& getRenderBuffer() = 0;
|
||||
|
||||
/**
|
||||
\brief Sets debug rendering flags
|
||||
|
||||
\param[in] flags The debug rendering flags (combination of PxControllerDebugRenderFlags)
|
||||
|
||||
@see PxControllerManager.getRenderBuffer() PxControllerDebugRenderFlags
|
||||
*/
|
||||
virtual void setDebugRenderingFlags(PxControllerDebugRenderFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of obstacle contexts that are being managed.
|
||||
|
||||
\return The number of obstacle contexts.
|
||||
*/
|
||||
virtual PxU32 getNbObstacleContexts() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve one of the obstacle contexts in the manager.
|
||||
|
||||
\param index The index of the obstacle context to retrieve.
|
||||
\return The obstacle context with the specified index.
|
||||
*/
|
||||
virtual PxObstacleContext* getObstacleContext(PxU32 index) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates an obstacle context.
|
||||
|
||||
\return New obstacle context
|
||||
|
||||
@see PxObstacleContext
|
||||
*/
|
||||
virtual PxObstacleContext* createObstacleContext() = 0;
|
||||
|
||||
/**
|
||||
\brief Computes character-character interactions.
|
||||
|
||||
This function is an optional helper to properly resolve interactions between characters, in case they overlap (which can happen for gameplay reasons, etc).
|
||||
|
||||
You should call this once per frame, before your PxController::move() calls. The function will not move the characters directly, but it will
|
||||
compute overlap information for each character that will be used in the next move() call.
|
||||
|
||||
You need to provide a proper time value here so that interactions are resolved in a way that do not depend on the framerate.
|
||||
|
||||
If you only have one character in the scene, or if you can guarantee your characters will never overlap, then you do not need to call this function.
|
||||
|
||||
\note Releasing the manager will automatically release all the associated obstacle contexts.
|
||||
|
||||
\param[in] elapsedTime Elapsed time since last call
|
||||
\param[in] cctFilterCb Filtering callback for CCT-vs-CCT interactions
|
||||
*/
|
||||
virtual void computeInteractions(PxF32 elapsedTime, PxControllerFilterCallback* cctFilterCb=NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Enables or disables runtime tessellation.
|
||||
|
||||
Large triangles can create accuracy issues in the sweep code, which in turn can lead to characters not sliding smoothly
|
||||
against geometries, or even penetrating them. This feature allows one to reduce those issues by tessellating large
|
||||
triangles at runtime, before performing sweeps against them. The amount of tessellation is controlled by the 'maxEdgeLength' parameter.
|
||||
Any triangle with at least one edge length greater than the maxEdgeLength will get recursively tessellated, until resulting triangles are small enough.
|
||||
|
||||
This features only applies to triangle meshes, convex meshes, heightfields and boxes.
|
||||
|
||||
\param[in] flag True/false to enable/disable runtime tessellation.
|
||||
\param[in] maxEdgeLength Max edge length allowed before tessellation kicks in.
|
||||
*/
|
||||
virtual void setTessellation(bool flag, float maxEdgeLength) = 0;
|
||||
|
||||
/**
|
||||
\brief Enables or disables the overlap recovery module.
|
||||
|
||||
The overlap recovery module can be used to depenetrate CCTs from static objects when an overlap is detected. This can happen
|
||||
in three main cases:
|
||||
- when the CCT is directly spawned or teleported in another object
|
||||
- when the CCT algorithm fails due to limited FPU accuracy
|
||||
- when the "up vector" is modified, making the rotated CCT shape overlap surrounding objects
|
||||
|
||||
When activated, the CCT module will automatically try to resolve the penetration, and move the CCT to a safe place where it does
|
||||
not overlap other objects anymore. This only concerns static objects, dynamic objects are ignored by the recovery module.
|
||||
|
||||
When the recovery module is not activated, it is possible for the CCTs to go through static objects. By default, the recovery
|
||||
module is enabled.
|
||||
|
||||
The recovery module currently works with all geometries except heightfields.
|
||||
|
||||
\param[in] flag True/false to enable/disable overlap recovery module.
|
||||
*/
|
||||
virtual void setOverlapRecoveryModule(bool flag) = 0;
|
||||
|
||||
/**
|
||||
\brief Enables or disables the precise sweeps.
|
||||
|
||||
Precise sweeps are more accurate, but also potentially slower than regular sweeps.
|
||||
|
||||
By default, precise sweeps are enabled.
|
||||
|
||||
\param[in] flag True/false to enable/disable precise sweeps.
|
||||
*/
|
||||
virtual void setPreciseSweeps(bool flag) = 0;
|
||||
|
||||
/**
|
||||
\brief Enables or disables vertical sliding against ceilings.
|
||||
|
||||
Geometry is seen as "ceilings" when the following condition is met:
|
||||
|
||||
dot product(contact normal, up direction)<0.0f
|
||||
|
||||
This flag controls whether characters should slide vertically along the geometry in that case.
|
||||
|
||||
By default, sliding is allowed.
|
||||
|
||||
\param[in] flag True/false to enable/disable sliding.
|
||||
*/
|
||||
virtual void setPreventVerticalSlidingAgainstCeiling(bool flag) = 0;
|
||||
|
||||
/**
|
||||
\brief Shift the origin of the character controllers and obstacle objects by the specified vector.
|
||||
|
||||
The positions of all character controllers, obstacle objects and the corresponding data structures will get adjusted to reflect the shifted origin location
|
||||
(the shift vector will get subtracted from all character controller and obstacle object positions).
|
||||
|
||||
\note It is the user's responsibility to keep track of the summed total origin shift and adjust all input/output to/from PhysXCharacterKinematic accordingly.
|
||||
|
||||
\note This call will not automatically shift the PhysX scene and its objects. You need to call PxScene::shiftOrigin() seperately to keep the systems in sync.
|
||||
|
||||
\param[in] shift Translation vector to shift the origin by.
|
||||
*/
|
||||
virtual void shiftOrigin(const PxVec3& shift) = 0;
|
||||
|
||||
protected:
|
||||
PxControllerManager() {}
|
||||
virtual ~PxControllerManager() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Creates the controller manager.
|
||||
|
||||
\param[in] scene PhysX scene.
|
||||
\param[in] lockingEnabled Enables/disables internal locking.
|
||||
|
||||
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,
|
||||
internal data structures must be guarded against concurrent access.
|
||||
|
||||
Locking guarantees thread safety in such scenarios.
|
||||
|
||||
\note locking may result in significant slowdown for release of actors or shapes.
|
||||
|
||||
By default, locking is disabled.
|
||||
*/
|
||||
PX_C_EXPORT physx::PxControllerManager* PX_CALL_CONV PxCreateControllerManager(physx::PxScene& scene, bool lockingEnabled = false);
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTROLLER_OBSTACLES_H
|
||||
#define PX_CONTROLLER_OBSTACLES_H
|
||||
/** \addtogroup character
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "characterkinematic/PxExtended.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxControllerManager;
|
||||
|
||||
#define PX_INVALID_OBSTACLE_HANDLE 0xffffffff
|
||||
|
||||
/**
|
||||
\brief Base class for obstacles.
|
||||
|
||||
@see PxBoxObstacle PxCapsuleObstacle PxObstacleContext
|
||||
*/
|
||||
class PxObstacle
|
||||
{
|
||||
protected:
|
||||
PxObstacle() :
|
||||
mType (PxGeometryType::eINVALID),
|
||||
mUserData (NULL),
|
||||
mPos (0.0, 0.0, 0.0),
|
||||
mRot (PxQuat(PxIdentity))
|
||||
{}
|
||||
|
||||
PxGeometryType::Enum mType;
|
||||
public:
|
||||
|
||||
PX_FORCE_INLINE PxGeometryType::Enum getType() const { return mType; }
|
||||
|
||||
void* mUserData;
|
||||
PxExtendedVec3 mPos;
|
||||
PxQuat mRot;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A box obstacle.
|
||||
|
||||
@see PxObstacle PxCapsuleObstacle PxObstacleContext
|
||||
*/
|
||||
class PxBoxObstacle : public PxObstacle
|
||||
{
|
||||
public:
|
||||
PxBoxObstacle() :
|
||||
mHalfExtents(0.0f)
|
||||
{ mType = PxGeometryType::eBOX; }
|
||||
|
||||
PxVec3 mHalfExtents;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A capsule obstacle.
|
||||
|
||||
@see PxBoxObstacle PxObstacle PxObstacleContext
|
||||
*/
|
||||
class PxCapsuleObstacle : public PxObstacle
|
||||
{
|
||||
public:
|
||||
PxCapsuleObstacle() :
|
||||
mHalfHeight (0.0f),
|
||||
mRadius (0.0f)
|
||||
{ mType = PxGeometryType::eCAPSULE; }
|
||||
|
||||
PxReal mHalfHeight;
|
||||
PxReal mRadius;
|
||||
};
|
||||
|
||||
typedef PxU32 PxObstacleHandle;
|
||||
|
||||
/**
|
||||
\brief Context class for obstacles.
|
||||
|
||||
An obstacle context class contains and manages a set of user-defined obstacles.
|
||||
|
||||
@see PxBoxObstacle PxCapsuleObstacle PxObstacle
|
||||
*/
|
||||
class PxObstacleContext
|
||||
{
|
||||
public:
|
||||
PxObstacleContext() {}
|
||||
virtual ~PxObstacleContext() {}
|
||||
|
||||
/**
|
||||
\brief Releases the context.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the controller manager associated with this context.
|
||||
|
||||
\return The associated controller manager
|
||||
*/
|
||||
virtual PxControllerManager& getControllerManager() const = 0;
|
||||
|
||||
/**
|
||||
\brief Adds an obstacle to the context.
|
||||
|
||||
\param [in] obstacle Obstacle data for the new obstacle. The data gets copied.
|
||||
|
||||
\return Handle for newly-added obstacle
|
||||
*/
|
||||
virtual PxObstacleHandle addObstacle(const PxObstacle& obstacle) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes an obstacle from the context.
|
||||
|
||||
\param [in] handle Handle for the obstacle object that needs to be removed.
|
||||
|
||||
\return True if success
|
||||
*/
|
||||
virtual bool removeObstacle(PxObstacleHandle handle) = 0;
|
||||
|
||||
/**
|
||||
\brief Updates data for an existing obstacle.
|
||||
|
||||
\param [in] handle Handle for the obstacle object that needs to be updated.
|
||||
\param [in] obstacle New obstacle data
|
||||
|
||||
\return True if success
|
||||
*/
|
||||
virtual bool updateObstacle(PxObstacleHandle handle, const PxObstacle& obstacle) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves number of obstacles in the context.
|
||||
|
||||
\return Number of obstacles in the context
|
||||
*/
|
||||
virtual PxU32 getNbObstacles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves desired obstacle.
|
||||
|
||||
\param [in] i Obstacle index
|
||||
|
||||
\return Desired obstacle
|
||||
*/
|
||||
virtual const PxObstacle* getObstacle(PxU32 i) const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves desired obstacle by given handle.
|
||||
|
||||
\param [in] handle Obstacle handle
|
||||
|
||||
\return Desired obstacle
|
||||
*/
|
||||
virtual const PxObstacle* getObstacleByHandle(PxObstacleHandle handle) const = 0;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,273 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_EXTENDED_H
|
||||
#define PX_EXTENDED_H
|
||||
/** \addtogroup character
|
||||
@{
|
||||
*/
|
||||
|
||||
// This needs to be included in Foundation just for the debug renderer
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
// This has to be done here since it also changes the top-level "Px" and "Np" APIs
|
||||
#define PX_BIG_WORLDS
|
||||
|
||||
#ifdef PX_BIG_WORLDS
|
||||
typedef double PxExtended;
|
||||
#define PX_MAX_EXTENDED PX_MAX_F64
|
||||
#define PxExtendedAbs(x) fabs(x)
|
||||
|
||||
struct PxExtendedVec3
|
||||
{
|
||||
PX_INLINE PxExtendedVec3() {}
|
||||
PX_INLINE PxExtendedVec3(PxExtended _x, PxExtended _y, PxExtended _z) : x(_x), y(_y), z(_z) {}
|
||||
|
||||
PX_INLINE bool isZero() const
|
||||
{
|
||||
if(x!=0.0 || y!=0.0 || z!=0.0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtended dot(const PxVec3& v) const
|
||||
{
|
||||
return x * PxExtended(v.x) + y * PxExtended(v.y) + z * PxExtended(v.z);
|
||||
}
|
||||
|
||||
PX_INLINE PxExtended distanceSquared(const PxExtendedVec3& v) const
|
||||
{
|
||||
PxExtended dx = x - v.x;
|
||||
PxExtended dy = y - v.y;
|
||||
PxExtended dz = z - v.z;
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtended magnitudeSquared() const
|
||||
{
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtended magnitude() const
|
||||
{
|
||||
return PxSqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
PX_INLINE PxExtended normalize()
|
||||
{
|
||||
PxExtended m = magnitude();
|
||||
if (m != 0.0)
|
||||
{
|
||||
const PxExtended il = PxExtended(1.0) / m;
|
||||
x *= il;
|
||||
y *= il;
|
||||
z *= il;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
PX_INLINE bool isFinite() const
|
||||
{
|
||||
return PxIsFinite(x) && PxIsFinite(y) && PxIsFinite(z);
|
||||
}
|
||||
|
||||
PX_INLINE void maximum(const PxExtendedVec3& v)
|
||||
{
|
||||
if (x < v.x) x = v.x;
|
||||
if (y < v.y) y = v.y;
|
||||
if (z < v.z) z = v.z;
|
||||
}
|
||||
|
||||
|
||||
PX_INLINE void minimum(const PxExtendedVec3& v)
|
||||
{
|
||||
if (x > v.x) x = v.x;
|
||||
if (y > v.y) y = v.y;
|
||||
if (z > v.z) z = v.z;
|
||||
}
|
||||
|
||||
PX_INLINE void set(PxExtended x_, PxExtended y_, PxExtended z_)
|
||||
{
|
||||
this->x = x_;
|
||||
this->y = y_;
|
||||
this->z = z_;
|
||||
}
|
||||
|
||||
PX_INLINE void setPlusInfinity()
|
||||
{
|
||||
x = y = z = PX_MAX_EXTENDED;
|
||||
}
|
||||
|
||||
PX_INLINE void setMinusInfinity()
|
||||
{
|
||||
x = y = z = -PX_MAX_EXTENDED;
|
||||
}
|
||||
|
||||
PX_INLINE void cross(const PxExtendedVec3& left, const PxVec3& right)
|
||||
{
|
||||
// temps needed in case left or right is this.
|
||||
PxExtended a = (left.y * PxExtended(right.z)) - (left.z * PxExtended(right.y));
|
||||
PxExtended b = (left.z * PxExtended(right.x)) - (left.x * PxExtended(right.z));
|
||||
PxExtended c = (left.x * PxExtended(right.y)) - (left.y * PxExtended(right.x));
|
||||
|
||||
x = a;
|
||||
y = b;
|
||||
z = c;
|
||||
}
|
||||
|
||||
PX_INLINE void cross(const PxExtendedVec3& left, const PxExtendedVec3& right)
|
||||
{
|
||||
// temps needed in case left or right is this.
|
||||
PxExtended a = (left.y * right.z) - (left.z * right.y);
|
||||
PxExtended b = (left.z * right.x) - (left.x * right.z);
|
||||
PxExtended c = (left.x * right.y) - (left.y * right.x);
|
||||
|
||||
x = a;
|
||||
y = b;
|
||||
z = c;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtendedVec3 cross(const PxExtendedVec3& v) const
|
||||
{
|
||||
PxExtendedVec3 temp;
|
||||
temp.cross(*this,v);
|
||||
return temp;
|
||||
}
|
||||
|
||||
PX_INLINE void cross(const PxVec3& left, const PxExtendedVec3& right)
|
||||
{
|
||||
// temps needed in case left or right is this.
|
||||
PxExtended a = (PxExtended(left.y) * right.z) - (PxExtended(left.z) * right.y);
|
||||
PxExtended b = (PxExtended(left.z) * right.x) - (PxExtended(left.x) * right.z);
|
||||
PxExtended c = (PxExtended(left.x) * right.y) - (PxExtended(left.y) * right.x);
|
||||
|
||||
x = a;
|
||||
y = b;
|
||||
z = c;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtendedVec3 operator-() const
|
||||
{
|
||||
return PxExtendedVec3(-x, -y, -z);
|
||||
}
|
||||
|
||||
PX_INLINE PxExtendedVec3& operator+=(const PxExtendedVec3& v)
|
||||
{
|
||||
x += v.x;
|
||||
y += v.y;
|
||||
z += v.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtendedVec3& operator-=(const PxExtendedVec3& v)
|
||||
{
|
||||
x -= v.x;
|
||||
y -= v.y;
|
||||
z -= v.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtendedVec3& operator+=(const PxVec3& v)
|
||||
{
|
||||
x += PxExtended(v.x);
|
||||
y += PxExtended(v.y);
|
||||
z += PxExtended(v.z);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtendedVec3& operator-=(const PxVec3& v)
|
||||
{
|
||||
x -= PxExtended(v.x);
|
||||
y -= PxExtended(v.y);
|
||||
z -= PxExtended(v.z);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtendedVec3& operator*=(const PxReal& s)
|
||||
{
|
||||
x *= PxExtended(s);
|
||||
y *= PxExtended(s);
|
||||
z *= PxExtended(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE PxExtendedVec3 operator+(const PxExtendedVec3& v) const
|
||||
{
|
||||
return PxExtendedVec3(x + v.x, y + v.y, z + v.z);
|
||||
}
|
||||
|
||||
PX_INLINE PxVec3 operator-(const PxExtendedVec3& v) const
|
||||
{
|
||||
return PxVec3(PxReal(x - v.x), PxReal(y - v.y), PxReal(z - v.z));
|
||||
}
|
||||
|
||||
PX_INLINE PxExtended& operator[](int index)
|
||||
{
|
||||
PX_ASSERT(index>=0 && index<=2);
|
||||
|
||||
return reinterpret_cast<PxExtended*>(this)[index];
|
||||
}
|
||||
|
||||
|
||||
PX_INLINE PxExtended operator[](int index) const
|
||||
{
|
||||
PX_ASSERT(index>=0 && index<=2);
|
||||
|
||||
return reinterpret_cast<const PxExtended*>(this)[index];
|
||||
}
|
||||
|
||||
PxExtended x,y,z;
|
||||
};
|
||||
|
||||
PX_FORCE_INLINE PxVec3 toVec3(const PxExtendedVec3& v)
|
||||
{
|
||||
return PxVec3(float(v.x), float(v.y), float(v.z));
|
||||
}
|
||||
|
||||
#else
|
||||
// Big worlds not defined
|
||||
|
||||
typedef PxVec3 PxExtendedVec3;
|
||||
typedef PxReal PxExtended;
|
||||
#define PX_MAX_EXTENDED PX_MAX_F32
|
||||
#define PxExtendedAbs(x) fabsf(x)
|
||||
#endif
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_COLLISION_DEFS_H
|
||||
#define PX_COLLISION_DEFS_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A callback class to allocate memory to cache information used in contact generation.
|
||||
*/
|
||||
class PxCacheAllocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Allocates cache data for contact generation. This data is stored inside PxCache objects.
|
||||
The application can retain and provide this information for future contact generation passes
|
||||
for a given pair to improve contact generation performance. It is the application's responsibility
|
||||
to release this memory appropriately. If the memory is released, the application must ensure that
|
||||
this memory is no longer referenced by any PxCache objects passed to PxGenerateContacts.
|
||||
|
||||
\param byteSize [in] size of the allocation in bytes
|
||||
|
||||
\return the newly-allocated memory. The returned address must be 16-byte aligned.
|
||||
|
||||
@see PxCache, PxGenerateContacts
|
||||
*/
|
||||
virtual PxU8* allocateCacheData(const PxU32 byteSize) = 0;
|
||||
|
||||
virtual ~PxCacheAllocator() {}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A structure to cache contact information produced by low-level contact generation functions.
|
||||
*/
|
||||
struct PxCache
|
||||
{
|
||||
PxU8* mCachedData; //!< Cached data pointer. Allocated via PxCacheAllocator
|
||||
PxU16 mCachedSize; //!< The total size of the cached data
|
||||
PxU8 mPairData; //!< Pair data information used and cached internally by some contact generation functions to accelerate performance.
|
||||
PxU8 mManifoldFlags; //!< Manifold flags used to identify the format the cached data is stored in. @see Gu::ManifoldFlags
|
||||
|
||||
PX_FORCE_INLINE PxCache() : mCachedData(NULL), mCachedSize(0), mPairData(0), mManifoldFlags(0)
|
||||
{
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE void reset()
|
||||
{
|
||||
mCachedData = NULL;
|
||||
mCachedSize = 0;
|
||||
mPairData = 0;
|
||||
mManifoldFlags = 0;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_BASE_H
|
||||
#define PX_BASE_H
|
||||
|
||||
/** \addtogroup common
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "common/PxSerialFramework.h"
|
||||
#include "common/PxCollection.h"
|
||||
#include "common/PxTypeInfo.h"
|
||||
#include <string.h> // For strcmp
|
||||
#include "foundation/PxAssert.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef PxU16 PxType;
|
||||
|
||||
/**
|
||||
\brief Flags for PxBase.
|
||||
*/
|
||||
struct PxBaseFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eOWNS_MEMORY = (1<<0),
|
||||
eIS_RELEASABLE = (1<<1)
|
||||
};
|
||||
};
|
||||
|
||||
typedef PxFlags<PxBaseFlag::Enum, PxU16> PxBaseFlags;
|
||||
PX_FLAGS_OPERATORS(PxBaseFlag::Enum, PxU16)
|
||||
|
||||
/**
|
||||
\brief Base class for objects that can be members of a PxCollection.
|
||||
|
||||
All PxBase sub-classes can be serialized.
|
||||
|
||||
@see PxCollection
|
||||
*/
|
||||
class PxBase
|
||||
{
|
||||
//= ATTENTION! =====================================================================================
|
||||
// Changing the data layout of this class breaks the binary serialization format. See comments for
|
||||
// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
|
||||
// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
|
||||
// accordingly.
|
||||
//==================================================================================================
|
||||
public:
|
||||
/**
|
||||
\brief Releases the PxBase instance, please check documentation of release in derived class.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns string name of dynamic type.
|
||||
\return Class name of most derived type of this object.
|
||||
*/
|
||||
virtual const char* getConcreteTypeName() const = 0;
|
||||
|
||||
/* brief Implements dynamic cast functionality.
|
||||
|
||||
Example use:
|
||||
|
||||
if(actor->is<PxRigidDynamic>()) {...}
|
||||
|
||||
\return A pointer to the specified type if object matches, otherwise NULL
|
||||
*/
|
||||
template<class T> T* is() { return typeMatch<T>() ? static_cast<T*>(this) : NULL; }
|
||||
|
||||
/* brief Implements dynamic cast functionality for const objects.
|
||||
|
||||
Example use:
|
||||
|
||||
if(actor->is<PxRigidDynamic>()) {...}
|
||||
|
||||
\return A pointer to the specified type if object matches, otherwise NULL
|
||||
*/
|
||||
template<class T> const T* is() const { return typeMatch<T>() ? static_cast<const T*>(this) : NULL; }
|
||||
|
||||
/**
|
||||
\brief Returns concrete type of object.
|
||||
\return PxConcreteType::Enum of serialized object
|
||||
|
||||
@see PxConcreteType
|
||||
*/
|
||||
PX_FORCE_INLINE PxType getConcreteType() const { return mConcreteType; }
|
||||
|
||||
/**
|
||||
\brief Set PxBaseFlag
|
||||
|
||||
\param[in] flag The flag to be set
|
||||
\param[in] value The flags new value
|
||||
*/
|
||||
PX_FORCE_INLINE void setBaseFlag(PxBaseFlag::Enum flag, bool value) { mBaseFlags = value ? mBaseFlags|flag : mBaseFlags&~flag; }
|
||||
|
||||
/**
|
||||
\brief Set PxBaseFlags
|
||||
|
||||
\param[in] inFlags The flags to be set
|
||||
|
||||
@see PxBaseFlags
|
||||
*/
|
||||
PX_FORCE_INLINE void setBaseFlags(PxBaseFlags inFlags) { mBaseFlags = inFlags; }
|
||||
|
||||
/**
|
||||
\brief Returns PxBaseFlags
|
||||
|
||||
\return PxBaseFlags
|
||||
|
||||
@see PxBaseFlags
|
||||
*/
|
||||
PX_FORCE_INLINE PxBaseFlags getBaseFlags() const { return mBaseFlags; }
|
||||
|
||||
/**
|
||||
\brief Whether the object is subordinate.
|
||||
|
||||
A class is subordinate, if it can only be instantiated in the context of another class.
|
||||
|
||||
\return Whether the class is subordinate
|
||||
|
||||
@see PxSerialization::isSerializable
|
||||
*/
|
||||
virtual bool isReleasable() const { return mBaseFlags & PxBaseFlag::eIS_RELEASABLE; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
\brief Constructor setting concrete type and base flags.
|
||||
*/
|
||||
PX_INLINE PxBase(PxType concreteType, PxBaseFlags baseFlags)
|
||||
: mConcreteType(concreteType), mBaseFlags(baseFlags), mBuiltInRefCount(1) {}
|
||||
|
||||
/**
|
||||
\brief Deserialization constructor setting base flags.
|
||||
*/
|
||||
PX_INLINE PxBase(PxBaseFlags baseFlags) : mBaseFlags(baseFlags)
|
||||
{
|
||||
PX_ASSERT(mBuiltInRefCount == 1);
|
||||
}
|
||||
/**
|
||||
\brief Destructor.
|
||||
*/
|
||||
virtual ~PxBase() {}
|
||||
|
||||
/**
|
||||
\brief Returns whether a given type name matches with the type of this instance
|
||||
*/
|
||||
virtual bool isKindOf(const char* superClass) const { return !::strcmp(superClass, "PxBase"); }
|
||||
|
||||
template<class T> bool typeMatch() const
|
||||
{
|
||||
return PxU32(PxTypeInfo<T>::eFastTypeId)!=PxU32(PxConcreteType::eUNDEFINED) ?
|
||||
PxU32(getConcreteType()) == PxU32(PxTypeInfo<T>::eFastTypeId) : isKindOf(PxTypeInfo<T>::name());
|
||||
}
|
||||
|
||||
private:
|
||||
friend void getBinaryMetaData_PxBase(PxOutputStream& stream);
|
||||
|
||||
protected:
|
||||
PxType mConcreteType; // concrete type identifier - see PxConcreteType.
|
||||
PxBaseFlags mBaseFlags; // internal flags
|
||||
PxU32 mBuiltInRefCount;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Base class for ref-counted objects.
|
||||
*/
|
||||
class PxRefCounted : public PxBase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Decrements the reference count of the object and releases it if the new reference count is zero.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the reference count of the object.
|
||||
|
||||
At creation, the reference count of the object is 1. Every other object referencing this object increments the
|
||||
count by 1. When the reference count reaches 0, and only then, the object gets destroyed automatically.
|
||||
|
||||
\return the current reference count.
|
||||
*/
|
||||
virtual PxU32 getReferenceCount() const = 0;
|
||||
|
||||
/**
|
||||
\brief Acquires a counted reference to this object.
|
||||
|
||||
This method increases the reference count of the object by 1. Decrement the reference count by calling release()
|
||||
*/
|
||||
virtual void acquireReference() = 0;
|
||||
|
||||
protected:
|
||||
virtual void onRefCountZero() { delete this; }
|
||||
|
||||
PX_INLINE PxRefCounted(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
|
||||
PX_INLINE PxRefCounted(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
|
||||
virtual ~PxRefCounted() {}
|
||||
virtual bool isKindOf(const char* name) const { return !::strcmp("PxRefCounted", name) || PxBase::isKindOf(name); }
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,277 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_COLLECTION_H
|
||||
#define PX_COLLECTION_H
|
||||
|
||||
#include "common/PxSerialFramework.h"
|
||||
|
||||
/** \addtogroup common
|
||||
@{
|
||||
*/
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxBase;
|
||||
|
||||
/**
|
||||
\brief Collection class for serialization.
|
||||
|
||||
A collection is a set of PxBase objects. PxBase objects can be added to the collection
|
||||
regardless of other objects they depend on. Objects may be named using PxSerialObjectId values in order
|
||||
to resolve dependencies between objects of different collections.
|
||||
|
||||
Serialization and deserialization only work through collections.
|
||||
|
||||
A scene is typically serialized using the following steps:
|
||||
|
||||
-# create a serialization registry
|
||||
-# create a collection for scene objects
|
||||
-# complete the scene objects (adds all dependent objects, e.g. meshes)
|
||||
-# serialize collection
|
||||
-# release collection
|
||||
-# release serialization registry
|
||||
|
||||
For example the code may look like this:
|
||||
|
||||
\code
|
||||
PxPhysics* physics; // The physics
|
||||
PxScene* scene; // The physics scene
|
||||
SerialStream s; // The user-defined stream doing the actual write to disk
|
||||
|
||||
PxSerializationRegistry* registry = PxSerialization::createSerializationRegistry(*physics); // step 1)
|
||||
PxCollection* collection = PxSerialization::createCollection(*scene); // step 2)
|
||||
PxSerialization::complete(*collection, *registry); // step 3)
|
||||
PxSerialization::serializeCollectionToBinary(s, *collection, *registry); // step 4)
|
||||
collection->release(); // step 5)
|
||||
registry->release(); // step 6)
|
||||
\endcode
|
||||
|
||||
A scene is typically deserialized using the following steps:
|
||||
|
||||
-# load a serialized collection into memory
|
||||
-# create a serialization registry
|
||||
-# create a collection by passing the serialized memory block
|
||||
-# add collected objects to scene
|
||||
-# release collection
|
||||
-# release serialization registry
|
||||
|
||||
For example the code may look like this:
|
||||
|
||||
\code
|
||||
PxPhysics* physics; // The physics
|
||||
PxScene* scene; // The physics scene
|
||||
void* memory128; // a 128-byte aligned buffer previously loaded from disk by the user - step 1)
|
||||
|
||||
PxSerializationRegistry* registry = PxSerialization::createSerializationRegistry(*physics); // step 2)
|
||||
PxCollection* collection = PxSerialization::createCollectionFromBinary(memory128, *registry); // step 3)
|
||||
scene->addCollection(*collection); // step 4)
|
||||
collection->release(); // step 5)
|
||||
registry->release(); // step 6)
|
||||
\endcode
|
||||
|
||||
@see PxBase, PxCreateCollection()
|
||||
*/
|
||||
class PxCollection
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Adds a PxBase object to the collection.
|
||||
|
||||
Adds a PxBase object to the collection. Optionally a PxSerialObjectId can be provided
|
||||
in order to resolve dependencies between collections. A PxSerialObjectId value of PX_SERIAL_OBJECT_ID_INVALID
|
||||
means the object remains without id. Objects can be added regardless of other objects they require. If the object
|
||||
is already in the collection, the ID will be set if it was PX_SERIAL_OBJECT_ID_INVALID previously, otherwise the
|
||||
operation fails.
|
||||
|
||||
|
||||
\param[in] object Object to be added to the collection
|
||||
\param[in] id Optional PxSerialObjectId id
|
||||
*/
|
||||
virtual void add(PxBase& object, PxSerialObjectId id = PX_SERIAL_OBJECT_ID_INVALID) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes a PxBase member object from the collection.
|
||||
|
||||
Object needs to be contained by the collection.
|
||||
|
||||
\param[in] object PxBase object to be removed
|
||||
*/
|
||||
virtual void remove(PxBase& object) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns whether the collection contains a certain PxBase object.
|
||||
|
||||
\param[in] object PxBase object
|
||||
\return Whether object is contained.
|
||||
*/
|
||||
virtual bool contains(PxBase& object) const = 0;
|
||||
|
||||
/**
|
||||
\brief Adds an id to a member PxBase object.
|
||||
|
||||
If the object is already associated with an id within the collection, the id is replaced.
|
||||
May only be called for objects that are members of the collection. The id needs to be unique
|
||||
within the collection.
|
||||
|
||||
\param[in] object Member PxBase object
|
||||
\param[in] id PxSerialObjectId id to be given to the object
|
||||
*/
|
||||
virtual void addId(PxBase& object, PxSerialObjectId id) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes id from a contained PxBase object.
|
||||
|
||||
May only be called for ids that are associated with an object in the collection.
|
||||
|
||||
\param[in] id PxSerialObjectId value
|
||||
*/
|
||||
virtual void removeId(PxSerialObjectId id) = 0;
|
||||
|
||||
/**
|
||||
\brief Adds all PxBase objects and their ids of collection to this collection.
|
||||
|
||||
PxBase objects already in this collection are ignored. Object ids need to be conflict
|
||||
free, i.e. the same object may not have two different ids within the two collections.
|
||||
|
||||
\param[in] collection Collection to be added
|
||||
*/
|
||||
virtual void add(PxCollection& collection) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes all PxBase objects of collection from this collection.
|
||||
|
||||
PxBase objects not present in this collection are ignored. Ids of objects
|
||||
which are removed are also removed.
|
||||
|
||||
\param[in] collection Collection to be removed
|
||||
*/
|
||||
virtual void remove(PxCollection& collection) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets number of PxBase objects in this collection.
|
||||
|
||||
\return Number of objects in this collection
|
||||
*/
|
||||
virtual PxU32 getNbObjects() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the PxBase object of this collection given its index.
|
||||
|
||||
\param[in] index PxBase index in [0, getNbObjects())
|
||||
\return PxBase object at index index
|
||||
*/
|
||||
virtual PxBase& getObject(PxU32 index) const = 0;
|
||||
|
||||
/**
|
||||
\brief Copies member PxBase pointers to a user specified buffer.
|
||||
|
||||
\param[out] userBuffer Array of PxBase pointers
|
||||
\param[in] bufferSize Capacity of userBuffer
|
||||
\param[in] startIndex Offset into list of member PxBase objects
|
||||
\return number of members PxBase objects that have been written to the userBuffer
|
||||
*/
|
||||
virtual PxU32 getObjects(PxBase** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Looks for a PxBase object given a PxSerialObjectId value.
|
||||
|
||||
If there is no PxBase object in the collection with the given id, NULL is returned.
|
||||
|
||||
\param[in] id PxSerialObjectId value to look for
|
||||
\return PxBase object with the given id value or NULL
|
||||
*/
|
||||
virtual PxBase* find(PxSerialObjectId id) const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets number of PxSerialObjectId names in this collection.
|
||||
|
||||
\return Number of PxSerialObjectId names in this collection
|
||||
*/
|
||||
virtual PxU32 getNbIds() const = 0;
|
||||
|
||||
/**
|
||||
\brief Copies member PxSerialObjectId values to a user specified buffer.
|
||||
|
||||
\param[out] userBuffer Array of PxSerialObjectId values
|
||||
\param[in] bufferSize Capacity of userBuffer
|
||||
\param[in] startIndex Offset into list of member PxSerialObjectId values
|
||||
\return number of members PxSerialObjectId values that have been written to the userBuffer
|
||||
*/
|
||||
virtual PxU32 getIds(PxSerialObjectId* userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets the PxSerialObjectId name of a PxBase object within the collection.
|
||||
|
||||
The PxBase object needs to be a member of the collection.
|
||||
|
||||
\param[in] object PxBase object to get id for
|
||||
\return PxSerialObjectId name of the object or PX_SERIAL_OBJECT_ID_INVALID if the object is unnamed
|
||||
*/
|
||||
virtual PxSerialObjectId getId(const PxBase& object) const = 0;
|
||||
|
||||
/**
|
||||
\brief Deletes a collection object.
|
||||
|
||||
This function only deletes the collection object, i.e. the container class. It doesn't delete objects
|
||||
that are part of the collection.
|
||||
|
||||
@see PxCreateCollection()
|
||||
*/
|
||||
|
||||
virtual void release() = 0;
|
||||
|
||||
protected:
|
||||
PxCollection() {}
|
||||
virtual ~PxCollection() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Creates a collection object.
|
||||
|
||||
Objects can only be serialized or deserialized through a collection.
|
||||
For serialization, users must add objects to the collection and serialize the collection as a whole.
|
||||
For deserialization, the system gives back a collection of deserialized objects to users.
|
||||
|
||||
\return The new collection object.
|
||||
|
||||
@see PxCollection, PxCollection::release()
|
||||
*/
|
||||
PX_C_EXPORT PX_PHYSX_COMMON_API physx::PxCollection* PX_CALL_CONV PxCreateCollection();
|
||||
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,223 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CORE_UTILITY_TYPES_H
|
||||
#define PX_CORE_UTILITY_TYPES_H
|
||||
/** \addtogroup common
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
struct PxStridedData
|
||||
{
|
||||
/**
|
||||
\brief The offset in bytes between consecutive samples in the data.
|
||||
|
||||
<b>Default:</b> 0
|
||||
*/
|
||||
PxU32 stride;
|
||||
const void* data;
|
||||
|
||||
PxStridedData() : stride( 0 ), data( NULL ) {}
|
||||
|
||||
template<typename TDataType>
|
||||
PX_INLINE const TDataType& at( PxU32 idx ) const
|
||||
{
|
||||
PxU32 theStride( stride );
|
||||
if ( theStride == 0 )
|
||||
theStride = sizeof( TDataType );
|
||||
PxU32 offset( theStride * idx );
|
||||
return *(reinterpret_cast<const TDataType*>( reinterpret_cast< const PxU8* >( data ) + offset ));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename TDataType>
|
||||
struct PxTypedStridedData
|
||||
{
|
||||
PxU32 stride;
|
||||
const TDataType* data;
|
||||
|
||||
PxTypedStridedData()
|
||||
: stride( 0 )
|
||||
, data( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
PxTypedStridedData(const TDataType* data_, PxU32 stride_ = 0)
|
||||
: stride(stride_)
|
||||
, data(data_)
|
||||
{
|
||||
}
|
||||
|
||||
PX_INLINE const TDataType& at(PxU32 idx) const
|
||||
{
|
||||
PxU32 theStride(stride);
|
||||
if (theStride == 0)
|
||||
theStride = sizeof(TDataType);
|
||||
PxU32 offset(theStride * idx);
|
||||
return *(reinterpret_cast<const TDataType*>(reinterpret_cast<const PxU8*>(data) + offset));
|
||||
}
|
||||
};
|
||||
|
||||
struct PxBoundedData : public PxStridedData
|
||||
{
|
||||
PxU32 count;
|
||||
PxBoundedData() : count( 0 ) {}
|
||||
};
|
||||
|
||||
template<PxU8 TNumBytes>
|
||||
struct PxPadding
|
||||
{
|
||||
PxU8 mPadding[TNumBytes];
|
||||
PxPadding()
|
||||
{
|
||||
for ( PxU8 idx =0; idx < TNumBytes; ++idx )
|
||||
mPadding[idx] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <PxU32 NB_ELEMENTS> class PxFixedSizeLookupTable
|
||||
{
|
||||
//= ATTENTION! =====================================================================================
|
||||
// Changing the data layout of this class breaks the binary serialization format. See comments for
|
||||
// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
|
||||
// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
|
||||
// accordingly.
|
||||
//==================================================================================================
|
||||
public:
|
||||
|
||||
PxFixedSizeLookupTable()
|
||||
: mNbDataPairs(0)
|
||||
{
|
||||
}
|
||||
|
||||
PxFixedSizeLookupTable(const PxEMPTY) {}
|
||||
|
||||
PxFixedSizeLookupTable(const PxReal* dataPairs, const PxU32 numDataPairs)
|
||||
{
|
||||
PxMemCopy(mDataPairs,dataPairs,sizeof(PxReal)*2*numDataPairs);
|
||||
mNbDataPairs=numDataPairs;
|
||||
}
|
||||
|
||||
PxFixedSizeLookupTable(const PxFixedSizeLookupTable& src)
|
||||
{
|
||||
PxMemCopy(mDataPairs,src.mDataPairs,sizeof(PxReal)*2*src.mNbDataPairs);
|
||||
mNbDataPairs=src.mNbDataPairs;
|
||||
}
|
||||
|
||||
~PxFixedSizeLookupTable()
|
||||
{
|
||||
}
|
||||
|
||||
PxFixedSizeLookupTable& operator=(const PxFixedSizeLookupTable& src)
|
||||
{
|
||||
PxMemCopy(mDataPairs,src.mDataPairs,sizeof(PxReal)*2*src.mNbDataPairs);
|
||||
mNbDataPairs=src.mNbDataPairs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE void addPair(const PxReal x, const PxReal y)
|
||||
{
|
||||
PX_ASSERT(mNbDataPairs<NB_ELEMENTS);
|
||||
mDataPairs[2*mNbDataPairs+0]=x;
|
||||
mDataPairs[2*mNbDataPairs+1]=y;
|
||||
mNbDataPairs++;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxReal getYVal(const PxReal x) const
|
||||
{
|
||||
if(0==mNbDataPairs)
|
||||
{
|
||||
PX_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(1==mNbDataPairs || x<getX(0))
|
||||
{
|
||||
return getY(0);
|
||||
}
|
||||
|
||||
PxReal x0=getX(0);
|
||||
PxReal y0=getY(0);
|
||||
|
||||
for(PxU32 i=1;i<mNbDataPairs;i++)
|
||||
{
|
||||
const PxReal x1=getX(i);
|
||||
const PxReal y1=getY(i);
|
||||
|
||||
if((x>=x0)&&(x<x1))
|
||||
{
|
||||
return (y0+(y1-y0)*(x-x0)/(x1-x0));
|
||||
}
|
||||
|
||||
x0=x1;
|
||||
y0=y1;
|
||||
}
|
||||
|
||||
PX_ASSERT(x>=getX(mNbDataPairs-1));
|
||||
return getY(mNbDataPairs-1);
|
||||
}
|
||||
|
||||
PxU32 getNbDataPairs() const {return mNbDataPairs;}
|
||||
|
||||
void clear()
|
||||
{
|
||||
PxMemSet(mDataPairs, 0, NB_ELEMENTS*2*sizeof(PxReal));
|
||||
mNbDataPairs = 0;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxReal getX(const PxU32 i) const
|
||||
{
|
||||
return mDataPairs[2*i];
|
||||
}
|
||||
PX_FORCE_INLINE PxReal getY(const PxU32 i) const
|
||||
{
|
||||
return mDataPairs[2*i+1];
|
||||
}
|
||||
|
||||
PxReal mDataPairs[2*NB_ELEMENTS];
|
||||
PxU32 mNbDataPairs;
|
||||
PxU32 mPad[3];
|
||||
|
||||
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_INSERTION_CALLBACK_H
|
||||
#define PX_INSERTION_CALLBACK_H
|
||||
|
||||
#include "common/PxBase.h"
|
||||
|
||||
/** \addtogroup common
|
||||
@{
|
||||
*/
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Callback interface that permits TriangleMesh, Heightfield, ConvexMesh or BVH to be used
|
||||
directly without the need to store the cooking results into a stream.
|
||||
|
||||
Using this is advised only if real-time cooking is required; using "offline" cooking and
|
||||
streams is otherwise preferred.
|
||||
|
||||
The default PxInsertionCallback implementations must be used. The PxPhysics
|
||||
default callback can be obtained using the PxPhysics::getPhysicsInsertionCallback().
|
||||
The PxCooking default callback can be obtained using the PxCooking::getStandaloneInsertionCallback().
|
||||
|
||||
@see PxCooking PxPhysics
|
||||
*/
|
||||
class PxInsertionCallback
|
||||
{
|
||||
public:
|
||||
PxInsertionCallback() {}
|
||||
|
||||
/**
|
||||
\brief Builds object (TriangleMesh, Heightfield, ConvexMesh or BVH) from given data in PxPhysics.
|
||||
|
||||
\param type Object type to build.
|
||||
\param data Object data
|
||||
\return PxBase Created object in PxPhysics.
|
||||
*/
|
||||
virtual PxBase* buildObjectFromData(PxConcreteType::Enum type, void* data) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxInsertionCallback() {}
|
||||
};
|
||||
|
||||
typedef PxInsertionCallback PxPhysicsInsertionCallback;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
@@ -0,0 +1,226 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_METADATA_H
|
||||
#define PX_METADATA_H
|
||||
/** \addtogroup physics
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "foundation/Px.h"
|
||||
#include "foundation/PxIO.h"
|
||||
#include "PxMetaDataFlags.h"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Struct to store meta data definitions.
|
||||
|
||||
Note: The individual fields have different meaning depending on the meta data entry configuration.
|
||||
*/
|
||||
struct PxMetaDataEntry
|
||||
{
|
||||
const char* type; //!< Field type (bool, byte, quaternion, etc)
|
||||
const char* name; //!< Field name (appears exactly as in the source file)
|
||||
PxU32 offset; //!< Offset from the start of the class (ie from "this", field is located at "this"+Offset)
|
||||
PxU32 size; //!< sizeof(Type)
|
||||
PxU32 count; //!< Number of items of type Type (0 for dynamic sizes)
|
||||
PxU32 offsetSize; //!< Offset of dynamic size param, for dynamic arrays
|
||||
PxU32 flags; //!< Field parameters
|
||||
PxU32 alignment; //!< Explicit alignment
|
||||
};
|
||||
|
||||
#define PX_STORE_METADATA(stream, metaData) stream.write(&metaData, sizeof(PxMetaDataEntry))
|
||||
|
||||
#define PX_SIZE_OF(Class, Member) sizeof((reinterpret_cast<Class*>(0))->Member)
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for a member variable of a class
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_ITEM(stream, Class, type, name, flags) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #type, #name, PxU32(PX_OFFSET_OF_RT(Class, name)), PX_SIZE_OF(Class, name), \
|
||||
1, 0, flags, 0}; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for a member array variable of a class
|
||||
\details similar to PX_DEF_BIN_METADATA_ITEMS_AUTO but for cases with mismatch between specified type and array type
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_ITEMS(stream, Class, type, name, flags, count) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #type, #name, PxU32(PX_OFFSET_OF_RT(Class, name)), PX_SIZE_OF(Class, name), \
|
||||
count, 0, flags, 0}; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for a member array variable of a class
|
||||
\details similar to PX_DEF_BIN_METADATA_ITEMS but automatically detects the array length, which only works when the specified
|
||||
type matches the type of the array - does not support PxMetaDataFlag::ePTR
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Class, type, name, flags) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #type, #name, PxU32(PX_OFFSET_OF_RT(Class, name)), PX_SIZE_OF(Class, name), \
|
||||
sizeof((reinterpret_cast<Class*>(0))->name)/sizeof(type), 0, flags, 0}; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for a class
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_CLASS(stream, Class) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #Class, 0, 0, sizeof(Class), 0, 0, PxMetaDataFlag::eCLASS, 0 }; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for a virtual class
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_VCLASS(stream, Class) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #Class, 0, 0, sizeof(Class), 0, 0, PxMetaDataFlag::eCLASS|PxMetaDataFlag::eVIRTUAL, 0}; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for a typedef
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_TYPEDEF(stream, newType, oldType) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #newType, #oldType, 0, 0, 0, 0, PxMetaDataFlag::eTYPEDEF, 0 }; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for declaring a base class
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_BASE_CLASS(stream, Class, BaseClass) \
|
||||
{ \
|
||||
Class* myClass = reinterpret_cast<Class*>(42); \
|
||||
BaseClass* s = static_cast<BaseClass*>(myClass); \
|
||||
const PxU32 offset = PxU32(size_t(s) - size_t(myClass)); \
|
||||
PxMetaDataEntry tmp = { #Class, #BaseClass, offset, sizeof(Class), 0, 0, PxMetaDataFlag::eCLASS, 0 }; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for a union
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_UNION(stream, Class, name) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #Class, 0, PxU32(PX_OFFSET_OF_RT(Class, name)), PX_SIZE_OF(Class, name), \
|
||||
1, 0, PxMetaDataFlag::eUNION, 0 }; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for a particular member type of a union
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_UNION_TYPE(stream, Class, type, enumValue) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #Class, #type, enumValue, 0, 0, 0, PxMetaDataFlag::eUNION, 0 }; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for extra data
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_EXTRA_ITEM(stream, Class, type, control, align) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #type, 0, PxU32(PX_OFFSET_OF_RT(Class, control)), sizeof(type), 0, PxU32(PX_SIZE_OF(Class, control)), \
|
||||
PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_ITEM, align }; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for an array of extra data
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, Class, type, control, count, flags, align) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #type, 0, PxU32(PX_OFFSET_OF_RT(Class, control)), PxU32(PX_SIZE_OF(Class, control)), \
|
||||
PxU32(PX_OFFSET_OF_RT(Class, count)), PxU32(PX_SIZE_OF(Class, count)), \
|
||||
PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_ITEMS|flags, align }; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for an array of extra data
|
||||
additional to PX_DEF_BIN_METADATA_EXTRA_ITEMS a mask can be specified to interpret the control value
|
||||
@see PxMetaDataFlag::eCONTROL_MASK
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_EXTRA_ITEMS_MASKED_CONTROL(stream, Class, type, control, controlMask ,count, flags, align) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #type, 0, PxU32(PX_OFFSET_OF_RT(Class, control)), PxU32(PX_SIZE_OF(Class, control)), \
|
||||
PxU32(PX_OFFSET_OF_RT(Class, count)), PxU32(PX_SIZE_OF(Class, count)), \
|
||||
PxMetaDataFlag::eCONTROL_MASK|PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_ITEMS|flags|(controlMask & PxMetaDataFlag::eCONTROL_MASK_RANGE) << 16, \
|
||||
align}; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for an array of extra data
|
||||
\details similar to PX_DEF_BIN_METADATA_EXTRA_ITEMS, but supporting no control - PxMetaDataFlag::ePTR is also not supported
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_EXTRA_ARRAY(stream, Class, type, dyn_count, align, flags) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { #type, 0, PxU32(PX_OFFSET_OF_RT(Class, dyn_count)), PX_SIZE_OF(Class, dyn_count), align, 0, \
|
||||
PxMetaDataFlag::eEXTRA_DATA|flags, align }; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry for an string of extra data
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_EXTRA_NAME(stream, Class, control, align) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { "char", "string", 0, 0, 0, 0, PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_NAME, align }; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
\brief specifies a binary metadata entry declaring an extra data alignment for a class
|
||||
*/
|
||||
#define PX_DEF_BIN_METADATA_EXTRA_ALIGN(stream, Class, align) \
|
||||
{ \
|
||||
PxMetaDataEntry tmp = { "PxU8", "Alignment", 0, 0, 0, 0, PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eALIGNMENT, align}; \
|
||||
PX_STORE_METADATA(stream, tmp); \
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user