├── .github
├── ISSUE_TEMPLATE
│ └── issue.md
└── workflows
│ ├── deploy-docs.yml
│ ├── jitter-tests.yml
│ ├── publish.yml
│ └── test-deploy-docs.yml
├── LICENSE
├── README.md
├── docs
├── .gitignore
├── babel.config.js
├── docs
│ ├── 01_quickstart
│ │ ├── 01_boxes
│ │ │ ├── 00-project-setup.md
│ │ │ ├── 01-render-loop.md
│ │ │ ├── 02-hello-world.md
│ │ │ ├── _category_.json
│ │ │ └── img
│ │ │ │ ├── raylibjitter.gif
│ │ │ │ ├── raylibjitter.png
│ │ │ │ └── raylibplane.png
│ │ ├── 02_teapots
│ │ │ ├── 00-project-setup.md
│ │ │ ├── 02-hull-sampling.md
│ │ │ ├── 03-pointcloudshape.md
│ │ │ ├── 04-aftermath.md
│ │ │ ├── _category_.json
│ │ │ └── img
│ │ │ │ ├── teapot.png
│ │ │ │ └── teapots.gif
│ │ └── _category_.json
│ ├── 02_documentation
│ │ ├── 01-world.md
│ │ ├── 02-bodies.md
│ │ ├── 03-shapes.md
│ │ ├── 04-constraints.md
│ │ ├── 05-dynamictree.md
│ │ ├── 06-filters.md
│ │ ├── _category_.json
│ │ └── img
│ │ │ ├── dynamictree.odp
│ │ │ └── dynamictree.png
│ ├── changelog.md
│ └── intro.md
├── docusaurus.config.js
├── package-lock.json
├── package.json
├── run
├── sidebars.js
├── src
│ ├── css
│ │ └── custom.css
│ └── pages
│ │ └── index.js
└── static
│ ├── AppBundle
│ ├── WebDemo.runtimeconfig.json
│ ├── _framework
│ │ ├── Jitter2.wasm
│ │ ├── Raylib-cs.wasm
│ │ ├── System.Collections.wasm
│ │ ├── System.Diagnostics.TraceSource.wasm
│ │ ├── System.Private.CoreLib.wasm
│ │ ├── System.Runtime.InteropServices.JavaScript.wasm
│ │ ├── WebDemo.wasm
│ │ ├── blazor.boot.json
│ │ ├── dotnet.js
│ │ ├── dotnet.js.map
│ │ ├── dotnet.native.js
│ │ ├── dotnet.native.wasm
│ │ ├── dotnet.native.worker.mjs
│ │ ├── dotnet.runtime.js
│ │ ├── dotnet.runtime.js.map
│ │ └── supportFiles
│ │ │ ├── 0_lighting.fs
│ │ │ ├── 1_lighting.vs
│ │ │ ├── 2_texel_checker.png
│ │ │ └── 3_runtimeconfig.bin
│ ├── index.html
│ ├── main.js
│ └── package.json
│ ├── img
│ ├── favicon.ico
│ ├── jitter-social-card.jpg
│ └── logo.png
│ └── katex
│ ├── fonts
│ ├── KaTeX_AMS-Regular.ttf
│ ├── KaTeX_AMS-Regular.woff
│ ├── KaTeX_AMS-Regular.woff2
│ ├── KaTeX_Caligraphic-Bold.ttf
│ ├── KaTeX_Caligraphic-Bold.woff
│ ├── KaTeX_Caligraphic-Bold.woff2
│ ├── KaTeX_Caligraphic-Regular.ttf
│ ├── KaTeX_Caligraphic-Regular.woff
│ ├── KaTeX_Caligraphic-Regular.woff2
│ ├── KaTeX_Fraktur-Bold.ttf
│ ├── KaTeX_Fraktur-Bold.woff
│ ├── KaTeX_Fraktur-Bold.woff2
│ ├── KaTeX_Fraktur-Regular.ttf
│ ├── KaTeX_Fraktur-Regular.woff
│ ├── KaTeX_Fraktur-Regular.woff2
│ ├── KaTeX_Main-Bold.ttf
│ ├── KaTeX_Main-Bold.woff
│ ├── KaTeX_Main-Bold.woff2
│ ├── KaTeX_Main-BoldItalic.ttf
│ ├── KaTeX_Main-BoldItalic.woff
│ ├── KaTeX_Main-BoldItalic.woff2
│ ├── KaTeX_Main-Italic.ttf
│ ├── KaTeX_Main-Italic.woff
│ ├── KaTeX_Main-Italic.woff2
│ ├── KaTeX_Main-Regular.ttf
│ ├── KaTeX_Main-Regular.woff
│ ├── KaTeX_Main-Regular.woff2
│ ├── KaTeX_Math-BoldItalic.ttf
│ ├── KaTeX_Math-BoldItalic.woff
│ ├── KaTeX_Math-BoldItalic.woff2
│ ├── KaTeX_Math-Italic.ttf
│ ├── KaTeX_Math-Italic.woff
│ ├── KaTeX_Math-Italic.woff2
│ ├── KaTeX_SansSerif-Bold.ttf
│ ├── KaTeX_SansSerif-Bold.woff
│ ├── KaTeX_SansSerif-Bold.woff2
│ ├── KaTeX_SansSerif-Italic.ttf
│ ├── KaTeX_SansSerif-Italic.woff
│ ├── KaTeX_SansSerif-Italic.woff2
│ ├── KaTeX_SansSerif-Regular.ttf
│ ├── KaTeX_SansSerif-Regular.woff
│ ├── KaTeX_SansSerif-Regular.woff2
│ ├── KaTeX_Script-Regular.ttf
│ ├── KaTeX_Script-Regular.woff
│ ├── KaTeX_Script-Regular.woff2
│ ├── KaTeX_Size1-Regular.ttf
│ ├── KaTeX_Size1-Regular.woff
│ ├── KaTeX_Size1-Regular.woff2
│ ├── KaTeX_Size2-Regular.ttf
│ ├── KaTeX_Size2-Regular.woff
│ ├── KaTeX_Size2-Regular.woff2
│ ├── KaTeX_Size3-Regular.ttf
│ ├── KaTeX_Size3-Regular.woff
│ ├── KaTeX_Size3-Regular.woff2
│ ├── KaTeX_Size4-Regular.ttf
│ ├── KaTeX_Size4-Regular.woff
│ ├── KaTeX_Size4-Regular.woff2
│ ├── KaTeX_Typewriter-Regular.ttf
│ ├── KaTeX_Typewriter-Regular.woff
│ └── KaTeX_Typewriter-Regular.woff2
│ ├── katex.min.css
│ └── katex.min.js
├── media
├── logo
│ ├── jitterstackbig.png
│ ├── jitterstacksmall.png
│ ├── jitterstringbig.png
│ ├── jitterstringsmall.png
│ └── jitterstringsmallsmall.png
└── screenshots
│ ├── jitter_screenshot0.png
│ ├── jitter_screenshot1.png
│ ├── jitter_screenshot2.png
│ ├── jitter_screenshot3.png
│ ├── jitter_screenshot4.png
│ └── jitter_screenshot5.png
├── other
├── GodotDemo
│ ├── .gitattributes
│ ├── .gitignore
│ ├── JitterGodot.csproj
│ ├── JitterGodot.sln
│ ├── Program.cs
│ ├── README.md
│ ├── assets
│ │ ├── box.png
│ │ ├── box.png.import
│ │ ├── floor.png
│ │ └── floor.png.import
│ ├── box.material
│ ├── icon.svg
│ ├── icon.svg.import
│ ├── main_scene.tscn
│ └── project.godot
├── GodotSoftBodies
│ ├── .gitattributes
│ ├── .gitignore
│ ├── JitterGodot.csproj
│ ├── JitterGodot.sln
│ ├── Program.cs
│ ├── README.md
│ ├── assets
│ │ ├── texture_08.png
│ │ └── texture_08.png.import
│ ├── box.material
│ ├── icon.svg
│ ├── icon.svg.import
│ ├── main_scene.tscn
│ └── project.godot
└── WebDemo
│ ├── LICENSE
│ ├── Program.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ └── launchSettings.json
│ ├── README.md
│ ├── RLights.cs
│ ├── WebDemo.csproj
│ ├── assets
│ ├── lighting.fs
│ ├── lighting.vs
│ └── texel_checker.png
│ ├── index.html
│ ├── main.js
│ ├── run
│ ├── runtimeconfig.template.json
│ └── runtimes
│ └── raylib.a
├── publish
├── icon.png
└── readme.md
├── src
├── .gitignore
├── Jitter2.sln
├── Jitter2.slnx
├── Jitter2
│ ├── Attributes.cs
│ ├── Collision
│ │ ├── CollisionFilter
│ │ │ ├── IBroadPhaseFilter.cs
│ │ │ ├── INarrowPhaseFilter.cs
│ │ │ └── TriangleEdgeCollisionFilter.cs
│ │ ├── CollisionIsland.cs
│ │ ├── DynamicTree.RayCast.cs
│ │ ├── DynamicTree.cs
│ │ ├── IDynamicTreeProxy.cs
│ │ ├── IslandHelper.cs
│ │ ├── NarrowPhase
│ │ │ ├── CollisionManifold.cs
│ │ │ ├── ConvexPolytope.cs
│ │ │ ├── ISupportMappable.cs
│ │ │ ├── MinkowskiDifference.cs
│ │ │ ├── NarrowPhase.cs
│ │ │ ├── SimplexSolver.cs
│ │ │ └── SimplexSolverAB.cs
│ │ ├── PairHashSet.cs
│ │ └── Shapes
│ │ │ ├── BoxShape.cs
│ │ │ ├── CapsuleShape.cs
│ │ │ ├── ConeShape.cs
│ │ │ ├── ConvexHullShape.cs
│ │ │ ├── CylinderShape.cs
│ │ │ ├── PointCloudShape.cs
│ │ │ ├── RigidBodyShape.cs
│ │ │ ├── Shape.cs
│ │ │ ├── ShapeHelper.cs
│ │ │ ├── SphereShape.cs
│ │ │ ├── TransformedShape.cs
│ │ │ ├── TriangleMesh.cs
│ │ │ ├── TriangleShape.cs
│ │ │ └── VertexSupportMap.cs
│ ├── DataStructures
│ │ ├── PartitionedSet.cs
│ │ ├── ReadOnlyHashset.cs
│ │ ├── ReadOnlyList.cs
│ │ ├── ShardedDictionary.cs
│ │ └── SlimBag.cs
│ ├── Dynamics
│ │ ├── Arbiter.cs
│ │ ├── Constraints
│ │ │ ├── AngularMotor.cs
│ │ │ ├── BallSocket.cs
│ │ │ ├── ConeLimit.cs
│ │ │ ├── Constraint.cs
│ │ │ ├── DistanceLimit.cs
│ │ │ ├── FixedAngle.cs
│ │ │ ├── HingeAngle.cs
│ │ │ ├── Internal
│ │ │ │ └── QMatrix.cs
│ │ │ ├── Limit.cs
│ │ │ ├── LinearMotor.cs
│ │ │ ├── PointOnLine.cs
│ │ │ ├── PointOnPlane.cs
│ │ │ └── TwistAngle.cs
│ │ ├── Contact.cs
│ │ ├── Joints
│ │ │ ├── HingeJoint.cs
│ │ │ ├── Joint.cs
│ │ │ ├── PrismaticJoint.cs
│ │ │ └── UniversalJoint.cs
│ │ └── RigidBody.cs
│ ├── IDebugDrawer.cs
│ ├── Jitter2.csproj
│ ├── LinearMath
│ │ ├── Interop.cs
│ │ ├── JAngle.cs
│ │ ├── JBBox.cs
│ │ ├── JMatrix.cs
│ │ ├── JQuaternion.cs
│ │ ├── JTriangle.cs
│ │ ├── JVector.cs
│ │ └── MathHelper.cs
│ ├── Logger.cs
│ ├── Parallelization
│ │ ├── Parallel.cs
│ │ ├── ParallelExtensions.cs
│ │ ├── ReaderWriterLock.cs
│ │ └── ThreadPool.cs
│ ├── Precision.cs
│ ├── SoftBodies
│ │ ├── BroadPhaseCollisionFilter.cs
│ │ ├── DynamicTreeCollisionFilter.cs
│ │ ├── SoftBody.cs
│ │ ├── SoftBodyShape.cs
│ │ ├── SoftBodyTetrahedron.cs
│ │ ├── SoftBodyTriangle.cs
│ │ └── SpringConstraint.cs
│ ├── Unmanaged
│ │ ├── MaximumSizeException.cs
│ │ ├── MemoryHelper.cs
│ │ └── PartitionedBuffer.cs
│ ├── World.Capacity.cs
│ ├── World.Detect.cs
│ ├── World.Step.cs
│ └── World.cs
├── JitterBenchmark
│ ├── JitterBenchmark.csproj
│ ├── Program.cs
│ └── Usings.cs
├── JitterDemo
│ ├── ColorGenerator.cs
│ ├── Conversion.cs
│ ├── ConvexDecomposition.cs
│ ├── Demos
│ │ ├── Car
│ │ │ ├── ConstraintCar.cs
│ │ │ ├── RayCastCar.cs
│ │ │ └── Wheel.cs
│ │ ├── Ccd
│ │ │ └── CcdSolver.cs
│ │ ├── Common.cs
│ │ ├── CustomCollision
│ │ │ └── Octree.cs
│ │ ├── Demo00.cs
│ │ ├── Demo01.cs
│ │ ├── Demo02.cs
│ │ ├── Demo03.cs
│ │ ├── Demo04.cs
│ │ ├── Demo05.cs
│ │ ├── Demo06.cs
│ │ ├── Demo07.cs
│ │ ├── Demo08.cs
│ │ ├── Demo09.cs
│ │ ├── Demo10.cs
│ │ ├── Demo11.cs
│ │ ├── Demo12.cs
│ │ ├── Demo13.cs
│ │ ├── Demo14.cs
│ │ ├── Demo15.cs
│ │ ├── Demo16.cs
│ │ ├── Demo17.cs
│ │ ├── Demo18.cs
│ │ ├── Demo19.cs
│ │ ├── Demo20.cs
│ │ ├── Demo21.cs
│ │ ├── Demo22.cs
│ │ ├── Demo23.cs
│ │ ├── Demo24.cs
│ │ ├── Demo25.cs
│ │ ├── Demo26.cs
│ │ ├── Demo27.cs
│ │ ├── IDemo.cs
│ │ ├── Player
│ │ │ └── Player.cs
│ │ ├── SoftBody
│ │ │ ├── PressurizedSphere.cs
│ │ │ ├── SoftBodyCloth.cs
│ │ │ └── SoftBodyCube.cs
│ │ └── Voxels
│ │ │ ├── VoxelEdgeCollisionFilter.cs
│ │ │ ├── VoxelGrid.cs
│ │ │ └── VoxelShape.cs
│ ├── JitterDemo.csproj
│ ├── Playground.Debug.cs
│ ├── Playground.Gui.cs
│ ├── Playground.Picking.cs
│ ├── Playground.cs
│ ├── Program.cs
│ ├── Renderer
│ │ ├── Assets
│ │ │ ├── Image.cs
│ │ │ └── Mesh.cs
│ │ ├── CSM
│ │ │ ├── CSMInstance.cs
│ │ │ ├── CSMRenderer.cs
│ │ │ ├── CSMShader.cs
│ │ │ └── Instances
│ │ │ │ ├── Cloth.cs
│ │ │ │ ├── Cone.cs
│ │ │ │ ├── Cube.cs
│ │ │ │ ├── Cylinder.cs
│ │ │ │ ├── DebugInstance.cs
│ │ │ │ ├── Floor.cs
│ │ │ │ ├── HalfSphere.cs
│ │ │ │ ├── MultiMesh.cs
│ │ │ │ ├── Sphere.cs
│ │ │ │ ├── TestCube.cs
│ │ │ │ ├── TriangleMesh.cs
│ │ │ │ └── Tube.cs
│ │ ├── Camera.cs
│ │ ├── DearImGui
│ │ │ ├── ImGui.cs
│ │ │ ├── ImGuiNative.cs
│ │ │ └── ImGuiStructs.cs
│ │ ├── DebugRenderer.cs
│ │ ├── ImGuiRenderer.cs
│ │ ├── ImportResolver.cs
│ │ ├── OpenGL
│ │ │ ├── GLDebug.cs
│ │ │ ├── GLDevice.cs
│ │ │ ├── GLFWWindow.cs
│ │ │ ├── Input
│ │ │ │ ├── Joystick.cs
│ │ │ │ ├── Keyboard.cs
│ │ │ │ └── Mouse.cs
│ │ │ ├── LinearMath
│ │ │ │ ├── Matrix4.cs
│ │ │ │ ├── MatrixHelper.cs
│ │ │ │ ├── Vector2.cs
│ │ │ │ ├── Vector3.cs
│ │ │ │ └── Vector4.cs
│ │ │ ├── Native
│ │ │ │ ├── GL.cs
│ │ │ │ └── GLFW.cs
│ │ │ ├── Objects
│ │ │ │ ├── ArrayBuffer.cs
│ │ │ │ ├── ElementArrayBuffer.cs
│ │ │ │ ├── Framebuffer.cs
│ │ │ │ ├── GLBuffer.cs
│ │ │ │ ├── GLObject.cs
│ │ │ │ ├── Shader.cs
│ │ │ │ ├── Texture.cs
│ │ │ │ └── VertexArrayObject.cs
│ │ │ └── Uniforms.cs
│ │ ├── RenderWindow.cs
│ │ ├── Skybox.cs
│ │ ├── TextureOverlay.cs
│ │ └── VertexDefintions.cs
│ ├── assets
│ │ ├── car.LICENSE
│ │ ├── car.blend
│ │ ├── car.obj
│ │ ├── car.tga
│ │ ├── dragon.LICENSE
│ │ ├── dragon.obj.zip
│ │ ├── level.LICENSE
│ │ ├── level.blend
│ │ ├── level.obj
│ │ ├── logo.tga
│ │ ├── teapot.obj.zip
│ │ ├── teapot_hull.obj
│ │ ├── texture_10.LICENSE
│ │ ├── texture_10.tga
│ │ ├── unit.tga
│ │ └── wheel.obj
│ └── runtimes
│ │ ├── LICENSE
│ │ ├── linux-arm64
│ │ └── native
│ │ │ ├── cimgui.so
│ │ │ └── libglfw.so.3
│ │ ├── linux-x64
│ │ └── native
│ │ │ ├── cimgui.so
│ │ │ └── libglfw.so.3
│ │ ├── osx-arm64
│ │ └── native
│ │ │ ├── cimgui.dylib
│ │ │ └── libglfw.3.dylib
│ │ ├── osx-x64
│ │ └── native
│ │ │ ├── cimgui.dylib
│ │ │ └── libglfw.3.dylib
│ │ ├── win-arm64
│ │ └── native
│ │ │ ├── cimgui.dll
│ │ │ └── glfw3.dll
│ │ ├── win-x64
│ │ └── native
│ │ │ ├── cimgui.dll
│ │ │ └── glfw3.dll
│ │ └── win-x86
│ │ └── native
│ │ ├── cimgui.dll
│ │ └── glfw3.dll
└── JitterTests
│ ├── AddRemoveTests.cs
│ ├── BoundingBoxTests.cs
│ ├── CollisionTests.cs
│ ├── ConstraintTests.cs
│ ├── Helper.cs
│ ├── InertiaTests.cs
│ ├── JitterTests.csproj
│ ├── MathTests.cs
│ ├── MiscTests.cs
│ ├── ParallelTests.cs
│ ├── RayTriangle.cs
│ ├── ReproducibilityTest.cs
│ ├── SequentialTests.cs
│ ├── StackingTests.cs
│ └── Usings.cs
└── tools
├── CoACD
├── README
├── run.py
└── run.sh
└── ImGui.NET
├── CodeGenerator
├── CSharpCodeWriter.cs
├── CodeGenerator.csproj
├── ImguiDefinitions.cs
├── Program.cs
├── TypeInfo.cs
└── definitions
│ ├── cimgui
│ ├── definitions.json
│ ├── structs_and_enums.json
│ └── variants.json
│ ├── cimguizmo
│ ├── definitions.json
│ ├── structs_and_enums.json
│ └── variants.json
│ ├── cimnodes
│ ├── definitions.json
│ ├── structs_and_enums.json
│ └── variants.json
│ └── cimplot
│ ├── definitions.json
│ ├── structs_and_enums.json
│ └── variants.json
├── LICENSE
├── README
└── cimgui
└── mingw-w64-x86_64.cmake
/.github/ISSUE_TEMPLATE/issue.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Issue
3 | about: Generic Jitter Issue
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Note:** For general inquiries, such as "How do I...?", please use the discussion page instead of opening issues. You can find the discussion page [here](https://github.com/notgiven688/jitterphysics2/discussions).
11 |
--------------------------------------------------------------------------------
/.github/workflows/deploy-docs.yml:
--------------------------------------------------------------------------------
1 | name: Build and deploy documentation
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | # Review gh actions docs if you want to further define triggers, paths, etc
8 | # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
9 |
10 | jobs:
11 | deploy:
12 | name: Build and deploy documentation
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4
16 | - uses: actions/setup-node@v4
17 | with:
18 | node-version: 18
19 | cache: npm
20 | cache-dependency-path: docs/package-lock.json
21 |
22 | - name: Install dependencies
23 | run: npm ci --prefix docs
24 | - name: Build website
25 | run: npm run build --prefix docs
26 |
27 | # Popular action to deploy to GitHub Pages:
28 | # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
29 | - name: Deploy to GitHub Pages
30 | uses: peaceiris/actions-gh-pages@v4
31 | with:
32 | github_token: ${{ secrets.GITHUB_TOKEN }}
33 | # Build output to publish to the `gh-pages` branch:
34 | publish_dir: ./docs/build
35 | cname: jitterphysics.com
36 | publish_branch: pages # default: gh-pages
37 | # The following lines assign commit authorship to the official
38 | # GH-Actions bot for deploys to `gh-pages` branch:
39 | # https://github.com/actions/checkout/issues/13#issuecomment-724415212
40 | # The GH actions bot is used by default if you didn't specify the two fields.
41 | # You can swap them out with your own user credentials.
42 | user_name: github-actions[bot]
43 | user_email: 41898282+github-actions[bot]@users.noreply.github.com
44 |
--------------------------------------------------------------------------------
/.github/workflows/jitter-tests.yml:
--------------------------------------------------------------------------------
1 | name: JitterTests
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | pull_request:
7 |
8 | permissions:
9 | id-token: write
10 | contents: write
11 | checks: write
12 | actions: write
13 |
14 | env:
15 | CONFIGURATION: Release
16 | TEST_RESULTS_DIR: ./TestResults
17 |
18 | jobs:
19 | build-and-test:
20 |
21 | runs-on: ubuntu-latest
22 |
23 | defaults:
24 | run:
25 | working-directory: ./src/JitterTests
26 |
27 | steps:
28 | - uses: actions/checkout@v4
29 |
30 | - name: Setup .NET
31 | uses: actions/setup-dotnet@v4
32 | with:
33 | dotnet-version: 9.0.x
34 |
35 | - name: Restore dependencies
36 | run: dotnet restore
37 |
38 | - name: Build
39 | run: dotnet build --configuration ${{ env.CONFIGURATION }} --no-restore
40 |
41 | - name: Run Tests
42 | run: |
43 | mkdir -p ${{ env.TEST_RESULTS_DIR }}
44 |
45 | # Run Single Precision Tests
46 | dotnet test --configuration ${{ env.CONFIGURATION }} --no-restore \
47 | --test-adapter-path:. --logger "trx;LogFileName=single-precision.trx"
48 |
49 | # Run Double Precision Tests
50 | dotnet test --configuration ${{ env.CONFIGURATION }} -p:DefineConstants="USE_DOUBLE_PRECISION" --no-restore \
51 | --test-adapter-path:. --logger "trx;LogFileName=double-precision.trx"
52 | if: always()
--------------------------------------------------------------------------------
/.github/workflows/test-deploy-docs.yml:
--------------------------------------------------------------------------------
1 | name: Build documentation
2 |
3 | on:
4 | pull_request:
5 | branches:
6 | - main
7 | # Review gh actions docs if you want to further define triggers, paths, etc
8 | # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
9 |
10 | jobs:
11 | test-deploy:
12 | name: Build documentation
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4
16 | - uses: actions/setup-node@v4
17 | with:
18 | node-version: 18
19 | cache: npm
20 | cache-dependency-path: docs/package-lock.json
21 |
22 | - name: Install dependencies
23 | run: npm ci --prefix docs
24 | - name: Build website
25 | run: npm run build --prefix docs
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2009-2023 Thorben Linneweber and others
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | # Dependencies
2 | /node_modules
3 |
4 | # Production
5 | /build
6 |
7 | # Generated files
8 | .docusaurus
9 | .cache-loader
10 |
11 | # Misc
12 | .DS_Store
13 | .env.local
14 | .env.development.local
15 | .env.test.local
16 | .env.production.local
17 |
18 | npm-debug.log*
19 | yarn-debug.log*
20 | yarn-error.log*
21 |
22 | .odp#
--------------------------------------------------------------------------------
/docs/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3 | };
4 |
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/01_boxes/00-project-setup.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # Project Setup
6 |
7 | In this project we will use Raylib and Jitter to implement a simple scene of boxes falling to the ground.
8 |
9 | ### Requirements
10 |
11 | Install the [.NET 9.0 SDK](https://dotnet.microsoft.com/download/dotnet/9.0).
12 |
13 | Ensure that dotnet is correctly set up by executing the following command:
14 |
15 | ```sh
16 | dotnet --version
17 | ```
18 |
19 | ### Create a New Console Application and Add Jitter and Raylib
20 |
21 | First, create a new directory named "BoxDrop" and navigate into it:
22 |
23 | ```sh
24 | mkdir BoxDrop && cd BoxDrop
25 | ```
26 |
27 | Next, create a new console application in this directory and add Raylib-cs and Jitter2:
28 |
29 | ```sh
30 | dotnet new console
31 | dotnet add package Raylib-cs --version 6.1.1
32 | dotnet add package Jitter2
33 | ```
34 |
35 | You have completed the setup. If you now execute the following command:
36 |
37 | ```sh
38 | dotnet run
39 | ```
40 |
41 | Your console should display: "Hello, World!".
42 |
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/01_boxes/01-render-loop.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Render Loop
6 |
7 | The first thing we need to do is to familiarize ourselves a bit with Raylib_cs. Replace the content of `Program.cs` with the following code:
8 |
9 | ```cs Program.cs showLineNumbers
10 | using System.Numerics;
11 | using Raylib_cs;
12 | using static Raylib_cs.Raylib;
13 |
14 | static Texture2D GenCheckedTexture(int size, int checks, Color colorA, Color colorB)
15 | {
16 | Image imageMag = GenImageChecked(size, size, checks, checks, colorA, colorB);
17 | Texture2D textureMag = LoadTextureFromImage(imageMag);
18 | UnloadImage(imageMag);
19 | return textureMag;
20 | }
21 |
22 | // set a hint for anti-aliasing
23 | SetConfigFlags(ConfigFlags.Msaa4xHint);
24 |
25 | // initialize a 1200x800 px window with a title
26 | InitWindow(1200, 800, "BoxDrop example");
27 |
28 | // dynamically create a plane model
29 | Texture2D texture = GenCheckedTexture(10, 1, Color.LightGray, Color.Gray);
30 | Model planeModel = LoadModelFromMesh(GenMeshPlane(10, 10, 10, 10));
31 | SetMaterialTexture(ref planeModel, 0, MaterialMapIndex.Diffuse, ref texture);
32 |
33 | // create a camera
34 | Camera3D camera = new ()
35 | {
36 | Position = new Vector3(-20.0f, 8.0f, 10.0f),
37 | Target = new Vector3(0.0f, 4.0f, 0.0f),
38 | Up = new Vector3(0.0f, 1.0f, 0.0f),
39 | FovY = 45.0f,
40 | Projection = CameraProjection.Perspective
41 | };
42 |
43 | // 100 fps target
44 | SetTargetFPS(100);
45 |
46 | // simple render loop
47 | while (!WindowShouldClose())
48 | {
49 | BeginDrawing();
50 | ClearBackground(Color.Blue);
51 |
52 | BeginMode3D(camera);
53 |
54 | DrawModel(planeModel, Vector3.Zero, 1.0f, Color.White);
55 |
56 | EndMode3D();
57 | DrawText($"{GetFPS()} fps", 10, 10, 20, Color.White);
58 |
59 | EndDrawing();
60 | }
61 |
62 | CloseWindow();
63 | ```
64 |
65 | Running your program should now display a plane:
66 |
67 | 
68 |
69 | We will add some physically simulated boxes in the next chapter.
70 |
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/01_boxes/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Dropping Boxes",
3 | "position": 1,
4 | "collapsed": false,
5 | "link": {
6 | "type": "generated-index",
7 | "description": "Implement a simple scene of boxes falling to the ground."
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/01_boxes/img/raylibjitter.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/docs/01_quickstart/01_boxes/img/raylibjitter.gif
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/01_boxes/img/raylibjitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/docs/01_quickstart/01_boxes/img/raylibjitter.png
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/01_boxes/img/raylibplane.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/docs/01_quickstart/01_boxes/img/raylibplane.png
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/02_teapots/00-project-setup.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # Project Setup
6 |
7 | In the previous section, we created a simulation of falling boxes. Jitter includes several default shapes, such as capsules, cylinders, and spheres.
8 | These shapes can be transformed and/or combined, and they are already sufficient to represent many types of collidable entities.
9 |
10 | In this section, we will add a custom convex shape to the simulation—specifically, the famous *Utah teapot*. We'll construct this shape from its visual representation by loading a `teapot.obj` file and using its vertices to create the convex shape.
11 |
12 |
13 | ### Requirements
14 |
15 | Install the [.NET 9.0 SDK](https://dotnet.microsoft.com/download/dotnet/9.0).
16 |
17 | Ensure that dotnet is correctly set up by executing the following command:
18 |
19 | ```sh
20 | dotnet --version
21 | ```
22 |
23 | ### Create a New Console Application and Add Jitter and Raylib
24 |
25 | First, create a new directory named "TeaDrop" and navigate into it:
26 |
27 | ```sh
28 | mkdir TeaDrop && cd TeaDrop
29 | ```
30 |
31 | Download and unzip the [teapot.obj](ahttps://github.com/notgiven688/jitterphysics2/raw/refs/heads/main/src/JitterDemo/assets/teapot.obj.zip) model.
32 |
33 | ```sh
34 | wget https://github.com/notgiven688/jitterphysics2/raw/refs/heads/main/src/JitterDemo/assets/teapot.obj.zip
35 | unzip teapot.obj.zip
36 | ```
37 |
38 | Next, create a new console application in this directory and add Raylib-cs and Jitter2:
39 |
40 | ```sh
41 | dotnet new console
42 | dotnet add package Raylib-cs --version 6.1.1
43 | dotnet add package Jitter2
44 | ```
45 |
46 | Add the following code to `TeaDrop.csproj` to allow unsafe code, and to copy teapot.obj automatically to the output directory:
47 |
48 | ```xml
49 |
50 | true
51 |
52 |
53 |
54 |
55 | Always
56 |
57 |
58 | ```
59 |
60 | You have completed the setup. If you now execute the following command:
61 |
62 | ```sh
63 | dotnet run
64 | ```
65 |
66 | Your console should display: "Hello, World!".
67 |
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/02_teapots/04-aftermath.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 4
3 | ---
4 |
5 | # Aftermath
6 |
7 | ### `PointCloudShape` vs `ConvexHullShape`
8 |
9 | In this example, we used the `PointCloudShape` to simulate a rigid body with a convex hull. As the name suggests, this shape only requires a set of points — they don’t need to lie exactly on a convex surface. By design, Jitter treats the convex hull of these points as the actual shape for collision detection.
10 |
11 | Although the algorithm used here is brute-force, it can be extremely fast: the data is stored in a linear memory layout, and SIMD instructions are used to accelerate the support function. Because of this, `PointCloudShape` is usually the best choice for quickly and efficiently adding simple convex geometry to your simulation.
12 |
13 | The `ConvexHullShape`, on the other hand, is intended for more complex and detailed convex models. Unlike `PointCloudShape`, this shape requires a precomputed convex hull provided as a list of triangles (`List`). Jitter does not generate this for you — you'll need to use third-party tools like Blender or dedicated convex hull libraries. The input mesh must be strictly convex for collision detection to work correctly.
14 |
15 | Internally, `ConvexHullShape` uses a hill-climbing algorithm to compute the support function. While this approach is algorithmically more efficient than brute-force, the performance benefits only become noticeable with larger shapes. As a general rule of thumb, `ConvexHullShape` starts to outperform `PointCloudShape` at around 300 vertices or more.
16 |
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/02_teapots/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Dropping Teapots",
3 | "position": 2,
4 | "collapsed": false,
5 | "link": {
6 | "type": "generated-index",
7 | "description": "A small example which shows how to simulate convex hulls from models."
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/02_teapots/img/teapot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/docs/01_quickstart/02_teapots/img/teapot.png
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/02_teapots/img/teapots.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/docs/01_quickstart/02_teapots/img/teapots.gif
--------------------------------------------------------------------------------
/docs/docs/01_quickstart/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Quickstart",
3 | "position": 1,
4 | "collapsed": false,
5 | "link": {
6 | "type": "generated-index",
7 | "description": "Small independent examples using Raylib and Jitter."
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/docs/docs/02_documentation/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Overview",
3 | "position": 1,
4 | "collapsed": false,
5 | "link": {
6 | "type": "generated-index",
7 | "description": "A still incomplete collection of articles to shed light on how to use Jitter."
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/docs/docs/02_documentation/img/dynamictree.odp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/docs/02_documentation/img/dynamictree.odp
--------------------------------------------------------------------------------
/docs/docs/02_documentation/img/dynamictree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/docs/02_documentation/img/dynamictree.png
--------------------------------------------------------------------------------
/docs/docs/intro.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 0
3 | ---
4 |
5 | # Welcome
6 |
7 | You will find tutorials and documentation here. Work in progress. You can help
8 | by editing or adding new content 👋
9 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jitterphysics",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "docusaurus": "docusaurus",
7 | "start": "docusaurus start",
8 | "build": "docusaurus build",
9 | "swizzle": "docusaurus swizzle",
10 | "deploy": "docusaurus deploy",
11 | "clear": "docusaurus clear",
12 | "serve": "docusaurus serve",
13 | "write-translations": "docusaurus write-translations",
14 | "write-heading-ids": "docusaurus write-heading-ids"
15 | },
16 | "dependencies": {
17 | "@docusaurus/core": "^3.5.2",
18 | "@docusaurus/preset-classic": "^3.5.2",
19 | "@mdx-js/react": "^3.0.0",
20 | "clsx": "^2.0.0",
21 | "prism-react-renderer": "^2.3.0",
22 | "react": "^18.0.0",
23 | "react-dom": "^18.0.0",
24 | "rehype-katex": "^7.0.0",
25 | "remark-math": "^6.0.0"
26 | },
27 | "devDependencies": {
28 | "@docusaurus/module-type-aliases": "^3.5.2",
29 | "@docusaurus/types": "^3.5.2"
30 | },
31 | "browserslist": {
32 | "production": [
33 | ">0.5%",
34 | "not dead",
35 | "not op_mini all"
36 | ],
37 | "development": [
38 | "last 3 chrome version",
39 | "last 3 firefox version",
40 | "last 5 safari version"
41 | ]
42 | },
43 | "engines": {
44 | "node": ">=18.0"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/docs/run:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | npm install
4 | npx docusaurus start
5 |
--------------------------------------------------------------------------------
/docs/sidebars.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Creating a sidebar enables you to:
3 | - create an ordered group of docs
4 | - render a sidebar for each doc of that group
5 | - provide next/previous navigation
6 |
7 | The sidebars can be generated from the filesystem, or explicitly defined here.
8 |
9 | Create as many sidebars as you want.
10 | */
11 |
12 | // @ts-check
13 |
14 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
15 | const sidebars = {
16 | // By default, Docusaurus generates a sidebar from the docs folder structure
17 | tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
18 |
19 | // But you can create a sidebar manually
20 | /*
21 | tutorialSidebar: [
22 | 'intro',
23 | 'hello',
24 | {
25 | type: 'category',
26 | label: 'Tutorial',
27 | items: ['tutorial-basics/create-a-document'],
28 | },
29 | ],
30 | */
31 | };
32 |
33 | export default sidebars;
34 |
--------------------------------------------------------------------------------
/docs/src/css/custom.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Any CSS included here will be global. The classic template
3 | * bundles Infima by default. Infima is a CSS framework designed to
4 | * work well for content-centric websites.
5 | */
6 |
7 | /* You can override the default Infima variables here. */
8 | :root {
9 | --ifm-color-primary: #2e8555;
10 | --ifm-color-primary-dark: #29784c;
11 | --ifm-color-primary-darker: #277148;
12 | --ifm-color-primary-darkest: #205d3b;
13 | --ifm-color-primary-light: #33925d;
14 | --ifm-color-primary-lighter: #359962;
15 | --ifm-color-primary-lightest: #3cad6e;
16 | --ifm-code-font-size: 95%;
17 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
18 | }
19 |
20 | /* For readability concerns, you should choose a lighter palette in dark mode. */
21 | [data-theme='dark'] {
22 | --ifm-color-primary: #25c2a0;
23 | --ifm-color-primary-dark: #21af90;
24 | --ifm-color-primary-darker: #1fa588;
25 | --ifm-color-primary-darkest: #1a8870;
26 | --ifm-color-primary-light: #29d5b0;
27 | --ifm-color-primary-lighter: #32d8b4;
28 | --ifm-color-primary-lightest: #4fddbf;
29 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
30 | }
31 |
--------------------------------------------------------------------------------
/docs/src/pages/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Redirect } from 'react-router-dom';
3 |
4 | export default function Home() {
5 | return ;
6 | }
7 |
--------------------------------------------------------------------------------
/docs/static/AppBundle/WebDemo.runtimeconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeOptions": {
3 | "tfm": "net9.0",
4 | "includedFrameworks": [
5 | {
6 | "name": "Microsoft.NETCore.App",
7 | "version": "9.0.0"
8 | }
9 | ],
10 | "wasmHostProperties": {
11 | "perHostConfig": [
12 | {
13 | "name": "browser",
14 | "html-path": "index.html",
15 | "Host": "browser"
16 | }
17 | ],
18 | "runtimeArgs": [],
19 | "mainAssembly": "WebDemo.dll"
20 | },
21 | "configProperties": {
22 | "Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability": true,
23 | "System.ComponentModel.DefaultValueAttribute.IsSupported": false,
24 | "System.ComponentModel.Design.IDesignerHost.IsSupported": false,
25 | "System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization": false,
26 | "System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported": false,
27 | "System.Diagnostics.Debugger.IsSupported": false,
28 | "System.Diagnostics.Metrics.Meter.IsSupported": false,
29 | "System.Diagnostics.Tracing.EventSource.IsSupported": false,
30 | "System.Globalization.Invariant": true,
31 | "System.Globalization.Hybrid": false,
32 | "System.Globalization.PredefinedCulturesOnly": true,
33 | "System.Net.Http.EnableActivityPropagation": false,
34 | "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
35 | "System.Resources.ResourceManager.AllowCustomResourceTypes": false,
36 | "System.Resources.UseSystemResourceKeys": true,
37 | "System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported": true,
38 | "System.Runtime.InteropServices.BuiltInComInterop.IsSupported": false,
39 | "System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": false,
40 | "System.Runtime.InteropServices.EnableCppCLIHostActivation": false,
41 | "System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop": false,
42 | "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
43 | "System.StartupHookProvider.IsSupported": false,
44 | "System.Text.Encoding.EnableUnsafeUTF7Encoding": false,
45 | "System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault": false,
46 | "System.Threading.Thread.EnableAutoreleasePool": false
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/Jitter2.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/AppBundle/_framework/Jitter2.wasm
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/Raylib-cs.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/AppBundle/_framework/Raylib-cs.wasm
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/System.Collections.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/AppBundle/_framework/System.Collections.wasm
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/System.Diagnostics.TraceSource.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/AppBundle/_framework/System.Diagnostics.TraceSource.wasm
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/System.Private.CoreLib.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/AppBundle/_framework/System.Private.CoreLib.wasm
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/System.Runtime.InteropServices.JavaScript.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/AppBundle/_framework/System.Runtime.InteropServices.JavaScript.wasm
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/WebDemo.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/AppBundle/_framework/WebDemo.wasm
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/blazor.boot.json:
--------------------------------------------------------------------------------
1 | {
2 | "mainAssemblyName": "WebDemo.dll",
3 | "resources": {
4 | "hash": "sha256-RCdSVPHOs6KAic+xFmPCvRYoaPnuPvU+Kc8CphtXEas=",
5 | "jsModuleNative": {
6 | "dotnet.native.js": "sha256-xMh4WeE8mQDEZK2+LK1LFlo7V6W+n1UdaFe9TSeMQog="
7 | },
8 | "jsModuleRuntime": {
9 | "dotnet.runtime.js": "sha256-uD1t4tsPtmIHsx30SC4OztehGGaHVDksFD38rL2e3P4="
10 | },
11 | "wasmNative": {
12 | "dotnet.native.wasm": "sha256-uVc65D8+eea+vPJA+OZbvkl0J/+se/I/fiaRTllosVs="
13 | },
14 | "coreAssembly": {
15 | "Jitter2.wasm": "sha256-wYytxKRKlJ0zW9Wl0J7suE8BdIjoZV3zs/Gs78u+MvY=",
16 | "Raylib-cs.wasm": "sha256-zx3sCNba74J68HtjbQvFqj5WirJb8KKXrxJhHzuKkjY=",
17 | "System.Collections.wasm": "sha256-iF12mqnqJpTePUB1dp84WAByDE783mhpCan6kHJRR7A=",
18 | "System.Diagnostics.TraceSource.wasm": "sha256-f+3Elnx9efxFqMeQwPmR/eBY81wQduJGJohmIy3CYVA=",
19 | "System.Private.CoreLib.wasm": "sha256-aPD1Ub4c7JrYIl6FmYrAO0MsSgCOOqMvjC1/dtDxoQI=",
20 | "System.Runtime.InteropServices.JavaScript.wasm": "sha256-XNXRuTJP6o1BGPLeqQcHjDLpNMRusjivjAHKa/MBZB4=",
21 | "WebDemo.wasm": "sha256-fYvRUW5lyxcFBFu5XBx1drDbLDmmwvfVUm/Q5R3gEHc="
22 | },
23 | "assembly": {},
24 | "coreVfs": {
25 | "runtimeconfig.bin": {
26 | "supportFiles/3_runtimeconfig.bin": "sha256-j8dmK7YPHHTbkS+ZwJixur+jBDk8AnCzB1le9oZbtDQ="
27 | }
28 | },
29 | "vfs": {
30 | "assets/lighting.fs": {
31 | "supportFiles/0_lighting.fs": "sha256-9P7bpnmnFzpHKF+2l7LLdMsUr3+eHrSVFvOYCzJ9QRM="
32 | },
33 | "assets/lighting.vs": {
34 | "supportFiles/1_lighting.vs": "sha256-J7tfxNROREVTHbd5xFSmwN74ufTd78DeWF/DD2wSKeI="
35 | },
36 | "assets/texel_checker.png": {
37 | "supportFiles/2_texel_checker.png": "sha256-RlKqyTT0KikXcijV/O5Qm0m/AT2TSMH4gRT/JR+AvTY="
38 | }
39 | }
40 | },
41 | "debugLevel": 0,
42 | "globalizationMode": "invariant"
43 | }
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/dotnet.native.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/AppBundle/_framework/dotnet.native.wasm
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/supportFiles/0_lighting.fs:
--------------------------------------------------------------------------------
1 | #version 100
2 |
3 | precision mediump float;
4 |
5 | // Input vertex attributes (from vertex shader)
6 | varying vec3 fragPosition;
7 | varying vec2 fragTexCoord;
8 | varying vec4 fragColor;
9 | varying vec3 fragNormal;
10 |
11 | // Input uniform values
12 | uniform sampler2D texture0;
13 | uniform vec4 colDiffuse;
14 |
15 | // NOTE: Add here your custom variables
16 |
17 | #define MAX_LIGHTS 4
18 | #define LIGHT_DIRECTIONAL 0
19 | #define LIGHT_POINT 1
20 |
21 | struct MaterialProperty {
22 | vec3 color;
23 | int useSampler;
24 | sampler2D sampler;
25 | };
26 |
27 | struct Light {
28 | int enabled;
29 | int type;
30 | vec3 position;
31 | vec3 target;
32 | vec4 color;
33 | };
34 |
35 | // Input lighting values
36 | uniform Light lights[MAX_LIGHTS];
37 | uniform vec4 ambient;
38 | uniform vec3 viewPos;
39 |
40 | void main()
41 | {
42 | // Texel color fetching from texture sampler
43 | vec4 texelColor = texture2D(texture0, fragTexCoord);
44 | vec3 lightDot = vec3(0.0);
45 | vec3 normal = normalize(fragNormal);
46 | vec3 viewD = normalize(viewPos - fragPosition);
47 | vec3 specular = vec3(0.0);
48 |
49 | // NOTE: Implement here your fragment shader code
50 |
51 | for (int i = 0; i < MAX_LIGHTS; i++)
52 | {
53 | if (lights[i].enabled == 1)
54 | {
55 | vec3 light = vec3(0.0);
56 |
57 | if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position);
58 | if (lights[i].type == LIGHT_POINT) light = normalize(lights[i].position - fragPosition);
59 |
60 | float NdotL = max(dot(normal, light), 0.0);
61 | lightDot += lights[i].color.rgb*NdotL;
62 |
63 | float specCo = 0.0;
64 | if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // Shine: 16.0
65 | specular += specCo;
66 | }
67 | }
68 |
69 | vec4 finalColor = (texelColor*((colDiffuse + vec4(specular,1))*vec4(lightDot, 1.0)));
70 | finalColor += texelColor*(ambient/10.0);
71 |
72 | // Gamma correction
73 | gl_FragColor = pow(finalColor, vec4(1.0/2.2));
74 | }
75 |
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/supportFiles/1_lighting.vs:
--------------------------------------------------------------------------------
1 | #version 100
2 |
3 | // Input vertex attributes
4 | attribute vec3 vertexPosition;
5 | attribute vec2 vertexTexCoord;
6 | attribute vec3 vertexNormal;
7 | attribute vec4 vertexColor;
8 |
9 | // Input uniform values
10 | uniform mat4 mvp;
11 | uniform mat4 matModel;
12 |
13 | // Output vertex attributes (to fragment shader)
14 | varying vec3 fragPosition;
15 | varying vec2 fragTexCoord;
16 | varying vec4 fragColor;
17 | varying vec3 fragNormal;
18 |
19 | // NOTE: Add here your custom variables
20 |
21 | // https://github.com/glslify/glsl-inverse
22 | mat3 inverse(mat3 m)
23 | {
24 | float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
25 | float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
26 | float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
27 |
28 | float b01 = a22*a11 - a12*a21;
29 | float b11 = -a22*a10 + a12*a20;
30 | float b21 = a21*a10 - a11*a20;
31 |
32 | float det = a00*b01 + a01*b11 + a02*b21;
33 |
34 | return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11),
35 | b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10),
36 | b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det;
37 | }
38 |
39 | // https://github.com/glslify/glsl-transpose
40 | mat3 transpose(mat3 m)
41 | {
42 | return mat3(m[0][0], m[1][0], m[2][0],
43 | m[0][1], m[1][1], m[2][1],
44 | m[0][2], m[1][2], m[2][2]);
45 | }
46 |
47 | void main()
48 | {
49 | // Send vertex attributes to fragment shader
50 | fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
51 | fragTexCoord = vertexTexCoord;
52 | fragColor = vertexColor;
53 |
54 | mat3 normalMatrix = transpose(inverse(mat3(matModel)));
55 | fragNormal = normalize(normalMatrix*vertexNormal);
56 |
57 | // Calculate final vertex position
58 | gl_Position = mvp*vec4(vertexPosition, 1.0);
59 | }
60 |
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/supportFiles/2_texel_checker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/AppBundle/_framework/supportFiles/2_texel_checker.png
--------------------------------------------------------------------------------
/docs/static/AppBundle/_framework/supportFiles/3_runtimeconfig.bin:
--------------------------------------------------------------------------------
1 | MMicrosoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmabilitytrue7System.ComponentModel.DefaultValueAttribute.IsSupportedfalse6System.ComponentModel.Design.IDesignerHost.IsSupportedfalsefSystem.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerializationfalseCSystem.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupportedfalse'System.Diagnostics.Debugger.IsSupportedfalse,System.Diagnostics.Metrics.Meter.IsSupportedfalse2System.Diagnostics.Tracing.EventSource.IsSupportedfalseSystem.Globalization.InvarianttrueSystem.Globalization.Hybridfalse+System.Globalization.PredefinedCulturesOnlytrue)System.Net.Http.EnableActivityPropagationfalse6System.Reflection.Metadata.MetadataUpdater.IsSupportedfalse9System.Resources.ResourceManager.AllowCustomResourceTypesfalse&System.Resources.UseSystemResourceKeystrueESystem.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupportedtrue
2 |
3 |
4 |
5 | DotnetRaylibWasm
6 |
7 |
8 |
9 |
10 |
11 |
46 |
47 |
48 |
49 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/docs/static/AppBundle/main.js:
--------------------------------------------------------------------------------
1 | import { dotnet } from './_framework/dotnet.js';
2 |
3 | async function initialize() {
4 | const { getAssemblyExports, getConfig, runMain } = await dotnet
5 | .withDiagnosticTracing(false)
6 | .create();
7 |
8 | const config = getConfig();
9 | const exports = await getAssemblyExports(config.mainAssemblyName);
10 |
11 | dotnet.instance.Module['canvas'] = document.getElementById('canvas');
12 |
13 | function mainLoop() {
14 | exports.WebDemo.Application.UpdateFrame();
15 | window.requestAnimationFrame(mainLoop);
16 | }
17 |
18 | // Run the C# Main() method and keep the runtime process running and executing further API calls
19 | await runMain();
20 |
21 | // Remove the spinner once the application is ready
22 | const loading_div = document.getElementById('spinner');
23 | loading_div.remove();
24 |
25 | window.requestAnimationFrame(mainLoop);
26 | }
27 |
28 | // Initialize the application
29 | initialize().catch(err => {
30 | console.error('An error occurred during initialization:', err);
31 | });
32 |
--------------------------------------------------------------------------------
/docs/static/AppBundle/package.json:
--------------------------------------------------------------------------------
1 | { "type":"module" }
--------------------------------------------------------------------------------
/docs/static/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/img/favicon.ico
--------------------------------------------------------------------------------
/docs/static/img/jitter-social-card.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/img/jitter-social-card.jpg
--------------------------------------------------------------------------------
/docs/static/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/img/logo.png
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_AMS-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_AMS-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_AMS-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_AMS-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_AMS-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_AMS-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Caligraphic-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Caligraphic-Bold.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Caligraphic-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Caligraphic-Bold.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Caligraphic-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Caligraphic-Bold.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Caligraphic-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Caligraphic-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Caligraphic-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Caligraphic-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Caligraphic-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Caligraphic-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Fraktur-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Fraktur-Bold.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Fraktur-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Fraktur-Bold.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Fraktur-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Fraktur-Bold.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Fraktur-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Fraktur-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Fraktur-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Fraktur-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Fraktur-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Fraktur-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-Bold.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-Bold.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-Bold.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-BoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-BoldItalic.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-BoldItalic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-BoldItalic.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-BoldItalic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-BoldItalic.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-Italic.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-Italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-Italic.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-Italic.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Main-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Main-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Math-BoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Math-BoldItalic.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Math-BoldItalic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Math-BoldItalic.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Math-BoldItalic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Math-BoldItalic.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Math-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Math-Italic.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Math-Italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Math-Italic.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Math-Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Math-Italic.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_SansSerif-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_SansSerif-Bold.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_SansSerif-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_SansSerif-Bold.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_SansSerif-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_SansSerif-Bold.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_SansSerif-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_SansSerif-Italic.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_SansSerif-Italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_SansSerif-Italic.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_SansSerif-Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_SansSerif-Italic.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_SansSerif-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_SansSerif-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_SansSerif-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_SansSerif-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_SansSerif-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_SansSerif-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Script-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Script-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Script-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Script-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Script-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Script-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size1-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size1-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size1-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size1-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size1-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size1-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size2-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size2-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size2-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size2-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size2-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size2-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size3-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size3-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size3-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size3-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size3-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size3-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size4-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size4-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size4-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size4-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Size4-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Size4-Regular.woff2
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Typewriter-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Typewriter-Regular.ttf
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Typewriter-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Typewriter-Regular.woff
--------------------------------------------------------------------------------
/docs/static/katex/fonts/KaTeX_Typewriter-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/docs/static/katex/fonts/KaTeX_Typewriter-Regular.woff2
--------------------------------------------------------------------------------
/media/logo/jitterstackbig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/logo/jitterstackbig.png
--------------------------------------------------------------------------------
/media/logo/jitterstacksmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/logo/jitterstacksmall.png
--------------------------------------------------------------------------------
/media/logo/jitterstringbig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/logo/jitterstringbig.png
--------------------------------------------------------------------------------
/media/logo/jitterstringsmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/logo/jitterstringsmall.png
--------------------------------------------------------------------------------
/media/logo/jitterstringsmallsmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/logo/jitterstringsmallsmall.png
--------------------------------------------------------------------------------
/media/screenshots/jitter_screenshot0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/screenshots/jitter_screenshot0.png
--------------------------------------------------------------------------------
/media/screenshots/jitter_screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/screenshots/jitter_screenshot1.png
--------------------------------------------------------------------------------
/media/screenshots/jitter_screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/screenshots/jitter_screenshot2.png
--------------------------------------------------------------------------------
/media/screenshots/jitter_screenshot3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/screenshots/jitter_screenshot3.png
--------------------------------------------------------------------------------
/media/screenshots/jitter_screenshot4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/screenshots/jitter_screenshot4.png
--------------------------------------------------------------------------------
/media/screenshots/jitter_screenshot5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/media/screenshots/jitter_screenshot5.png
--------------------------------------------------------------------------------
/other/GodotDemo/.gitattributes:
--------------------------------------------------------------------------------
1 | # Normalize EOL for all files that Git considers text files.
2 | * text=auto eol=lf
3 |
--------------------------------------------------------------------------------
/other/GodotDemo/.gitignore:
--------------------------------------------------------------------------------
1 | # Godot 4+ specific ignores
2 | .godot/
3 | .idea
4 |
--------------------------------------------------------------------------------
/other/GodotDemo/JitterGodot.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/other/GodotDemo/JitterGodot.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio 2012
3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JitterGodot", "JitterGodot.csproj", "{D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}"
4 | EndProject
5 | Global
6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
7 | Debug|Any CPU = Debug|Any CPU
8 | ExportDebug|Any CPU = ExportDebug|Any CPU
9 | ExportRelease|Any CPU = ExportRelease|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
15 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
16 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
17 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
18 | EndGlobalSection
19 | EndGlobal
20 |
--------------------------------------------------------------------------------
/other/GodotDemo/README.md:
--------------------------------------------------------------------------------
1 | ## Jitter2 in Godot
2 |
3 | Small demo to get started with Jitter2 in Godot.
4 |
5 | Get Godot (.NET, Version >= 4.3) from https://godotengine.org/. Open Godot and select "project.godot".
6 |
7 |
--------------------------------------------------------------------------------
/other/GodotDemo/assets/box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/other/GodotDemo/assets/box.png
--------------------------------------------------------------------------------
/other/GodotDemo/assets/box.png.import:
--------------------------------------------------------------------------------
1 | [remap]
2 |
3 | importer="texture"
4 | type="CompressedTexture2D"
5 | uid="uid://bmwn361sv2cuo"
6 | path.s3tc="res://.godot/imported/box.png-52cc4e41fddadef836f9ad4dbe7936fa.s3tc.ctex"
7 | metadata={
8 | "imported_formats": ["s3tc_bptc"],
9 | "vram_texture": true
10 | }
11 |
12 | [deps]
13 |
14 | source_file="res://assets/box.png"
15 | dest_files=["res://.godot/imported/box.png-52cc4e41fddadef836f9ad4dbe7936fa.s3tc.ctex"]
16 |
17 | [params]
18 |
19 | compress/mode=2
20 | compress/high_quality=false
21 | compress/lossy_quality=0.7
22 | compress/hdr_compression=1
23 | compress/normal_map=0
24 | compress/channel_pack=0
25 | mipmaps/generate=true
26 | mipmaps/limit=-1
27 | roughness/mode=0
28 | roughness/src_normal=""
29 | process/fix_alpha_border=true
30 | process/premult_alpha=false
31 | process/normal_map_invert_y=false
32 | process/hdr_as_srgb=false
33 | process/hdr_clamp_exposure=false
34 | process/size_limit=0
35 | detect_3d/compress_to=0
36 |
--------------------------------------------------------------------------------
/other/GodotDemo/assets/floor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/other/GodotDemo/assets/floor.png
--------------------------------------------------------------------------------
/other/GodotDemo/assets/floor.png.import:
--------------------------------------------------------------------------------
1 | [remap]
2 |
3 | importer="texture"
4 | type="CompressedTexture2D"
5 | uid="uid://bmalqw2x4nhkw"
6 | path.s3tc="res://.godot/imported/floor.png-38406586736af2fe805d7b886727ee47.s3tc.ctex"
7 | metadata={
8 | "imported_formats": ["s3tc_bptc"],
9 | "vram_texture": true
10 | }
11 |
12 | [deps]
13 |
14 | source_file="res://assets/floor.png"
15 | dest_files=["res://.godot/imported/floor.png-38406586736af2fe805d7b886727ee47.s3tc.ctex"]
16 |
17 | [params]
18 |
19 | compress/mode=2
20 | compress/high_quality=false
21 | compress/lossy_quality=0.7
22 | compress/hdr_compression=1
23 | compress/normal_map=0
24 | compress/channel_pack=0
25 | mipmaps/generate=true
26 | mipmaps/limit=-1
27 | roughness/mode=0
28 | roughness/src_normal=""
29 | process/fix_alpha_border=true
30 | process/premult_alpha=false
31 | process/normal_map_invert_y=false
32 | process/hdr_as_srgb=false
33 | process/hdr_clamp_exposure=false
34 | process/size_limit=0
35 | detect_3d/compress_to=0
36 |
--------------------------------------------------------------------------------
/other/GodotDemo/box.material:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/other/GodotDemo/box.material
--------------------------------------------------------------------------------
/other/GodotDemo/icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/other/GodotDemo/icon.svg.import:
--------------------------------------------------------------------------------
1 | [remap]
2 |
3 | importer="texture"
4 | type="CompressedTexture2D"
5 | uid="uid://bj3qla3sx2dm8"
6 | path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
7 | metadata={
8 | "vram_texture": false
9 | }
10 |
11 | [deps]
12 |
13 | source_file="res://icon.svg"
14 | dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
15 |
16 | [params]
17 |
18 | compress/mode=0
19 | compress/high_quality=false
20 | compress/lossy_quality=0.7
21 | compress/hdr_compression=1
22 | compress/normal_map=0
23 | compress/channel_pack=0
24 | mipmaps/generate=false
25 | mipmaps/limit=-1
26 | roughness/mode=0
27 | roughness/src_normal=""
28 | process/fix_alpha_border=true
29 | process/premult_alpha=false
30 | process/normal_map_invert_y=false
31 | process/hdr_as_srgb=false
32 | process/hdr_clamp_exposure=false
33 | process/size_limit=0
34 | detect_3d/compress_to=1
35 | svg/scale=1.0
36 | editor/scale_with_editor_scale=false
37 | editor/convert_colors_with_editor_theme=false
38 |
--------------------------------------------------------------------------------
/other/GodotDemo/main_scene.tscn:
--------------------------------------------------------------------------------
1 | [gd_scene load_steps=10 format=3 uid="uid://coyqv4677vx2l"]
2 |
3 | [ext_resource type="Texture2D" uid="uid://bmalqw2x4nhkw" path="res://assets/floor.png" id="1_cx0yb"]
4 | [ext_resource type="Script" path="res://Program.cs" id="1_q0tim"]
5 | [ext_resource type="Material" uid="uid://drmul300eph46" path="res://box.material" id="2_ht1to"]
6 |
7 | [sub_resource type="PlaneMesh" id="PlaneMesh_bdasd"]
8 |
9 | [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6v48f"]
10 | albedo_color = Color(0.34902, 0.505882, 0.717647, 1)
11 | albedo_texture = ExtResource("1_cx0yb")
12 | metallic = 0.29
13 | metallic_specular = 0.54
14 | roughness = 0.65
15 | uv1_scale = Vector3(10, 10, 10)
16 |
17 | [sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_hoxee"]
18 | ground_color = Color(0.729412, 0.627451, 0.52549, 1)
19 | energy_multiplier = 4.35
20 |
21 | [sub_resource type="Sky" id="Sky_u73ht"]
22 | sky_material = SubResource("PhysicalSkyMaterial_hoxee")
23 |
24 | [sub_resource type="Environment" id="Environment_ekotd"]
25 | background_mode = 2
26 | sky = SubResource("Sky_u73ht")
27 | ambient_light_energy = 2.86
28 |
29 | [sub_resource type="BoxMesh" id="BoxMesh_0u3bq"]
30 |
31 | [node name="Node3D" type="Node3D"]
32 | script = ExtResource("1_q0tim")
33 |
34 | [node name="Floor" type="MeshInstance3D" parent="."]
35 | transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
36 | mesh = SubResource("PlaneMesh_bdasd")
37 | surface_material_override/0 = SubResource("StandardMaterial3D_6v48f")
38 |
39 | [node name="Camera3D" type="Camera3D" parent="."]
40 | transform = Transform3D(0.966823, -0.0320158, 0.253432, 0, 0.992115, 0.125333, -0.255446, -0.121175, 0.9592, 2.65486, 4.6383, 9.92122)
41 |
42 | [node name="WorldEnvironment" type="WorldEnvironment" parent="."]
43 | environment = SubResource("Environment_ekotd")
44 |
45 | [node name="TestCube" type="MeshInstance3D" parent="."]
46 | transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.49664, 0)
47 | visible = false
48 | mesh = SubResource("BoxMesh_0u3bq")
49 | surface_material_override/0 = ExtResource("2_ht1to")
50 |
51 | [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
52 | transform = Transform3D(0.574853, -0.657468, 0.487113, 0.0171256, 0.604843, 0.796161, -0.818077, -0.449333, 0.358955, 7.26371, 4.83944, 0)
53 | light_energy = 1.61
54 | shadow_enabled = true
55 |
--------------------------------------------------------------------------------
/other/GodotDemo/project.godot:
--------------------------------------------------------------------------------
1 | ; Engine configuration file.
2 | ; It's best edited using the editor UI and not directly,
3 | ; since the parameters that go here are not all obvious.
4 | ;
5 | ; Format:
6 | ; [section] ; section goes between []
7 | ; param=value ; assign values to parameters
8 |
9 | config_version=5
10 |
11 | [application]
12 |
13 | config/name="JitterGodot"
14 | run/main_scene="res://main_scene.tscn"
15 | config/features=PackedStringArray("4.3", "C#", "Forward Plus")
16 | config/icon="res://icon.svg"
17 |
18 | [display]
19 |
20 | window/size/viewport_width=1200
21 | window/size/viewport_height=800
22 |
23 | [dotnet]
24 |
25 | project/assembly_name="JitterGodot"
26 |
27 | [rendering]
28 |
29 | anti_aliasing/quality/msaa_3d=2
30 | anti_aliasing/quality/use_taa=true
31 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/.gitattributes:
--------------------------------------------------------------------------------
1 | # Normalize EOL for all files that Git considers text files.
2 | * text=auto eol=lf
3 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/.gitignore:
--------------------------------------------------------------------------------
1 | # Godot 4+ specific ignores
2 | .godot/
3 | .idea
4 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/JitterGodot.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/JitterGodot.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio 2012
3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JitterGodot", "JitterGodot.csproj", "{D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}"
4 | EndProject
5 | Global
6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
7 | Debug|Any CPU = Debug|Any CPU
8 | ExportDebug|Any CPU = ExportDebug|Any CPU
9 | ExportRelease|Any CPU = ExportRelease|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
15 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
16 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
17 | {D95E4F8D-CDCA-48E7-95EC-3EBBD7A0431A}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
18 | EndGlobalSection
19 | EndGlobal
20 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/README.md:
--------------------------------------------------------------------------------
1 | ## Jitter2 Soft Bodies in Godot
2 |
3 | Small demo to showing Jitter2 soft bodies in Godot.
4 |
5 | Get Godot (.NET, Version >= 4.3) from https://godotengine.org/. Open Godot and select "project.godot".
6 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/assets/texture_08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/other/GodotSoftBodies/assets/texture_08.png
--------------------------------------------------------------------------------
/other/GodotSoftBodies/assets/texture_08.png.import:
--------------------------------------------------------------------------------
1 | [remap]
2 |
3 | importer="texture"
4 | type="CompressedTexture2D"
5 | uid="uid://couisnncdt24n"
6 | path.s3tc="res://.godot/imported/texture_08.png-55422b6c9181f85f6ecd7904cb7603ac.s3tc.ctex"
7 | metadata={
8 | "imported_formats": ["s3tc_bptc"],
9 | "vram_texture": true
10 | }
11 |
12 | [deps]
13 |
14 | source_file="res://assets/texture_08.png"
15 | dest_files=["res://.godot/imported/texture_08.png-55422b6c9181f85f6ecd7904cb7603ac.s3tc.ctex"]
16 |
17 | [params]
18 |
19 | compress/mode=2
20 | compress/high_quality=false
21 | compress/lossy_quality=0.7
22 | compress/hdr_compression=1
23 | compress/normal_map=0
24 | compress/channel_pack=0
25 | mipmaps/generate=true
26 | mipmaps/limit=-1
27 | roughness/mode=0
28 | roughness/src_normal=""
29 | process/fix_alpha_border=true
30 | process/premult_alpha=false
31 | process/normal_map_invert_y=false
32 | process/hdr_as_srgb=false
33 | process/hdr_clamp_exposure=false
34 | process/size_limit=0
35 | detect_3d/compress_to=0
36 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/box.material:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/other/GodotSoftBodies/box.material
--------------------------------------------------------------------------------
/other/GodotSoftBodies/icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/icon.svg.import:
--------------------------------------------------------------------------------
1 | [remap]
2 |
3 | importer="texture"
4 | type="CompressedTexture2D"
5 | uid="uid://bj3qla3sx2dm8"
6 | path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
7 | metadata={
8 | "vram_texture": false
9 | }
10 |
11 | [deps]
12 |
13 | source_file="res://icon.svg"
14 | dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
15 |
16 | [params]
17 |
18 | compress/mode=0
19 | compress/high_quality=false
20 | compress/lossy_quality=0.7
21 | compress/hdr_compression=1
22 | compress/normal_map=0
23 | compress/channel_pack=0
24 | mipmaps/generate=false
25 | mipmaps/limit=-1
26 | roughness/mode=0
27 | roughness/src_normal=""
28 | process/fix_alpha_border=true
29 | process/premult_alpha=false
30 | process/normal_map_invert_y=false
31 | process/hdr_as_srgb=false
32 | process/hdr_clamp_exposure=false
33 | process/size_limit=0
34 | detect_3d/compress_to=1
35 | svg/scale=1.0
36 | editor/scale_with_editor_scale=false
37 | editor/convert_colors_with_editor_theme=false
38 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/main_scene.tscn:
--------------------------------------------------------------------------------
1 | [gd_scene load_steps=9 format=3 uid="uid://coyqv4677vx2l"]
2 |
3 | [ext_resource type="Script" path="res://Program.cs" id="1_q0tim"]
4 | [ext_resource type="Material" uid="uid://bnmu1bn4m70pu" path="res://box.material" id="4_umvs4"]
5 |
6 | [sub_resource type="PlaneMesh" id="PlaneMesh_bdasd"]
7 |
8 | [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6v48f"]
9 | albedo_color = Color(0.694118, 0.756863, 0.976471, 1)
10 | uv1_scale = Vector3(10, 10, 10)
11 |
12 | [sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_hoxee"]
13 | ground_color = Color(0.627451, 0.607843, 0.890196, 1)
14 | energy_multiplier = 4.35
15 |
16 | [sub_resource type="Sky" id="Sky_u73ht"]
17 | sky_material = SubResource("PhysicalSkyMaterial_hoxee")
18 |
19 | [sub_resource type="Environment" id="Environment_ekotd"]
20 | background_mode = 2
21 | sky = SubResource("Sky_u73ht")
22 | ambient_light_energy = 2.86
23 |
24 | [sub_resource type="BoxMesh" id="BoxMesh_0u3bq"]
25 |
26 | [node name="Node3D" type="Node3D"]
27 | script = ExtResource("1_q0tim")
28 |
29 | [node name="Floor" type="MeshInstance3D" parent="."]
30 | transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
31 | mesh = SubResource("PlaneMesh_bdasd")
32 | surface_material_override/0 = SubResource("StandardMaterial3D_6v48f")
33 |
34 | [node name="Camera3D" type="Camera3D" parent="."]
35 | transform = Transform3D(0.956687, -0.036487, 0.288824, 0, 0.992115, 0.125333, -0.29112, -0.119904, 0.949143, 4.44888, 6.19976, 15.391)
36 | visible = false
37 |
38 | [node name="WorldEnvironment" type="WorldEnvironment" parent="."]
39 | environment = SubResource("Environment_ekotd")
40 |
41 | [node name="TestCube" type="MeshInstance3D" parent="."]
42 | transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.49664, 0)
43 | visible = false
44 | mesh = SubResource("BoxMesh_0u3bq")
45 | surface_material_override/0 = ExtResource("4_umvs4")
46 |
47 | [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
48 | transform = Transform3D(0.574853, -0.657468, 0.487113, 0.0171256, 0.604843, 0.796161, -0.818077, -0.449333, 0.358955, 7.26371, 4.83944, 0)
49 | shadow_enabled = true
50 |
--------------------------------------------------------------------------------
/other/GodotSoftBodies/project.godot:
--------------------------------------------------------------------------------
1 | ; Engine configuration file.
2 | ; It's best edited using the editor UI and not directly,
3 | ; since the parameters that go here are not all obvious.
4 | ;
5 | ; Format:
6 | ; [section] ; section goes between []
7 | ; param=value ; assign values to parameters
8 |
9 | config_version=5
10 |
11 | [application]
12 |
13 | config/name="JitterGodot"
14 | run/main_scene="res://main_scene.tscn"
15 | config/features=PackedStringArray("4.3", "C#", "Forward Plus")
16 | config/icon="res://icon.svg"
17 |
18 | [display]
19 |
20 | window/size/viewport_width=1920
21 | window/size/viewport_height=1200
22 |
23 | [dotnet]
24 |
25 | project/assembly_name="JitterGodot"
26 |
27 | [rendering]
28 |
29 | lights_and_shadows/directional_shadow/size=8192
30 | anti_aliasing/quality/msaa_3d=3
31 |
--------------------------------------------------------------------------------
/other/WebDemo/LICENSE:
--------------------------------------------------------------------------------
1 | The WebDemo uses the outstanding code from
2 |
3 | https://github.com/disketteman/DotnetRaylibWasm
4 | and
5 | https://github.com/Kiriller12/RaylibWasm
6 |
7 | to setup a wasm demo in the browser. License below.
8 |
9 | MIT License
10 |
11 | Copyright (c) 2022 Stan
12 | Copyright (c) 2023 Kiriller12
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in all
22 | copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 | SOFTWARE.
31 |
32 | The demo code itself is a modified demo (fog) from raylib
33 |
34 | https://github.com/raysan5/raylib
35 |
36 | License below.
37 |
38 | Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
39 |
40 | This software is provided "as-is", without any express or implied warranty. In no event
41 | will the authors be held liable for any damages arising from the use of this software.
42 |
43 | Permission is granted to anyone to use this software for any purpose, including commercial
44 | applications, and to alter it and redistribute it freely, subject to the following restrictions:
45 |
46 | 1. The origin of this software must not be misrepresented; you must not claim that you
47 | wrote the original software. If you use this software in a product, an acknowledgment
48 | in the product documentation would be appreciated but is not required.
49 |
50 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented
51 | as being the original software.
52 |
53 | 3. This notice may not be removed or altered from any source distribution.
--------------------------------------------------------------------------------
/other/WebDemo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | [assembly:System.Runtime.Versioning.SupportedOSPlatform("browser")]
5 |
--------------------------------------------------------------------------------
/other/WebDemo/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "WebDemo": {
4 | "commandName": "Project",
5 | "launchBrowser": true,
6 | "environmentVariables": {
7 | "ASPNETCORE_ENVIRONMENT": "Development"
8 | },
9 | "applicationUrl": "https://localhost:7022;http://localhost:5269",
10 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/debug?browser={browserInspectUri}"
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/other/WebDemo/README.md:
--------------------------------------------------------------------------------
1 | ## Jitter2 in the browser
2 |
3 | **Credits for raylib-cs in the browser and this README go to: https://github.com/disketteman/DotnetRaylibWasm and https://github.com/Kiriller12/RaylibWasm**
4 |
5 | ## Setup
6 |
7 | Make sure you have the latest version of .NET 9.
8 |
9 | Install the official wasm tooling:
10 |
11 | ```
12 | dotnet workload install wasm-tools
13 | dotnet workload install wasm-experimental
14 | ```
15 |
16 | Install a tool to create ad-hoc http server to serve `application/wasm`:
17 |
18 | ```
19 | dotnet tool install --global dotnet-serve
20 | ```
21 |
22 | ## Run it
23 |
24 | `publish` the solution. Don't use `build`. Publishing may take a while.
25 |
26 | ```
27 | dotnet publish -c Release
28 | ```
29 |
30 | To serve the files use this command:
31 |
32 | ```
33 | dotnet serve --mime .wasm=application/wasm --mime .js=text/javascript --mime .json=application/json --directory ./bin/Release/net9.0/browser-wasm/AppBundle
34 | ```
35 |
--------------------------------------------------------------------------------
/other/WebDemo/WebDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net9.0
4 | browser-wasm
5 | main.js
6 | Exe
7 | true
8 | true
9 | true
10 | true
11 | true
12 | true
13 | full
14 |
15 | true
16 |
17 |
18 |
19 |
20 |
21 | true
22 | -sUSE_GLFW=3
23 |
24 |
25 |
26 |
27 | -s USE_GLFW=3 -O3
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/other/WebDemo/assets/lighting.fs:
--------------------------------------------------------------------------------
1 | #version 100
2 |
3 | precision mediump float;
4 |
5 | // Input vertex attributes (from vertex shader)
6 | varying vec3 fragPosition;
7 | varying vec2 fragTexCoord;
8 | varying vec4 fragColor;
9 | varying vec3 fragNormal;
10 |
11 | // Input uniform values
12 | uniform sampler2D texture0;
13 | uniform vec4 colDiffuse;
14 |
15 | // NOTE: Add here your custom variables
16 |
17 | #define MAX_LIGHTS 4
18 | #define LIGHT_DIRECTIONAL 0
19 | #define LIGHT_POINT 1
20 |
21 | struct MaterialProperty {
22 | vec3 color;
23 | int useSampler;
24 | sampler2D sampler;
25 | };
26 |
27 | struct Light {
28 | int enabled;
29 | int type;
30 | vec3 position;
31 | vec3 target;
32 | vec4 color;
33 | };
34 |
35 | // Input lighting values
36 | uniform Light lights[MAX_LIGHTS];
37 | uniform vec4 ambient;
38 | uniform vec3 viewPos;
39 |
40 | void main()
41 | {
42 | // Texel color fetching from texture sampler
43 | vec4 texelColor = texture2D(texture0, fragTexCoord);
44 | vec3 lightDot = vec3(0.0);
45 | vec3 normal = normalize(fragNormal);
46 | vec3 viewD = normalize(viewPos - fragPosition);
47 | vec3 specular = vec3(0.0);
48 |
49 | // NOTE: Implement here your fragment shader code
50 |
51 | for (int i = 0; i < MAX_LIGHTS; i++)
52 | {
53 | if (lights[i].enabled == 1)
54 | {
55 | vec3 light = vec3(0.0);
56 |
57 | if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position);
58 | if (lights[i].type == LIGHT_POINT) light = normalize(lights[i].position - fragPosition);
59 |
60 | float NdotL = max(dot(normal, light), 0.0);
61 | lightDot += lights[i].color.rgb*NdotL;
62 |
63 | float specCo = 0.0;
64 | if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // Shine: 16.0
65 | specular += specCo;
66 | }
67 | }
68 |
69 | vec4 finalColor = (texelColor*((colDiffuse + vec4(specular,1))*vec4(lightDot, 1.0)));
70 | finalColor += texelColor*(ambient/10.0);
71 |
72 | // Gamma correction
73 | gl_FragColor = pow(finalColor, vec4(1.0/2.2));
74 | }
75 |
--------------------------------------------------------------------------------
/other/WebDemo/assets/lighting.vs:
--------------------------------------------------------------------------------
1 | #version 100
2 |
3 | // Input vertex attributes
4 | attribute vec3 vertexPosition;
5 | attribute vec2 vertexTexCoord;
6 | attribute vec3 vertexNormal;
7 | attribute vec4 vertexColor;
8 |
9 | // Input uniform values
10 | uniform mat4 mvp;
11 | uniform mat4 matModel;
12 |
13 | // Output vertex attributes (to fragment shader)
14 | varying vec3 fragPosition;
15 | varying vec2 fragTexCoord;
16 | varying vec4 fragColor;
17 | varying vec3 fragNormal;
18 |
19 | // NOTE: Add here your custom variables
20 |
21 | // https://github.com/glslify/glsl-inverse
22 | mat3 inverse(mat3 m)
23 | {
24 | float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
25 | float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
26 | float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
27 |
28 | float b01 = a22*a11 - a12*a21;
29 | float b11 = -a22*a10 + a12*a20;
30 | float b21 = a21*a10 - a11*a20;
31 |
32 | float det = a00*b01 + a01*b11 + a02*b21;
33 |
34 | return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11),
35 | b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10),
36 | b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det;
37 | }
38 |
39 | // https://github.com/glslify/glsl-transpose
40 | mat3 transpose(mat3 m)
41 | {
42 | return mat3(m[0][0], m[1][0], m[2][0],
43 | m[0][1], m[1][1], m[2][1],
44 | m[0][2], m[1][2], m[2][2]);
45 | }
46 |
47 | void main()
48 | {
49 | // Send vertex attributes to fragment shader
50 | fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
51 | fragTexCoord = vertexTexCoord;
52 | fragColor = vertexColor;
53 |
54 | mat3 normalMatrix = transpose(inverse(mat3(matModel)));
55 | fragNormal = normalize(normalMatrix*vertexNormal);
56 |
57 | // Calculate final vertex position
58 | gl_Position = mvp*vec4(vertexPosition, 1.0);
59 | }
60 |
--------------------------------------------------------------------------------
/other/WebDemo/assets/texel_checker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/other/WebDemo/assets/texel_checker.png
--------------------------------------------------------------------------------
/other/WebDemo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DotnetRaylibWasm
6 |
7 |
8 |
9 |
10 |
11 |
46 |
47 |
48 |
49 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/other/WebDemo/main.js:
--------------------------------------------------------------------------------
1 | import { dotnet } from './_framework/dotnet.js';
2 |
3 | async function initialize() {
4 | const { getAssemblyExports, getConfig, runMain } = await dotnet
5 | .withDiagnosticTracing(false)
6 | .create();
7 |
8 | const config = getConfig();
9 | const exports = await getAssemblyExports(config.mainAssemblyName);
10 |
11 | dotnet.instance.Module['canvas'] = document.getElementById('canvas');
12 |
13 | function mainLoop() {
14 | exports.WebDemo.Application.UpdateFrame();
15 | window.requestAnimationFrame(mainLoop);
16 | }
17 |
18 | // Run the C# Main() method and keep the runtime process running and executing further API calls
19 | await runMain();
20 |
21 | // Remove the spinner once the application is ready
22 | const loading_div = document.getElementById('spinner');
23 | loading_div.remove();
24 |
25 | window.requestAnimationFrame(mainLoop);
26 | }
27 |
28 | // Initialize the application
29 | initialize().catch(err => {
30 | console.error('An error occurred during initialization:', err);
31 | });
32 |
--------------------------------------------------------------------------------
/other/WebDemo/run:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | dotnet publish -c Release && dotnet serve --mime .wasm=application/wasm --mime .js=text/javascript --mime .json=application/json --directory ./bin/Release/net7.0/browser-wasm/AppBundle
4 |
--------------------------------------------------------------------------------
/other/WebDemo/runtimeconfig.template.json:
--------------------------------------------------------------------------------
1 | {
2 | "wasmHostProperties": {
3 | "perHostConfig": [
4 | {
5 | "name": "browser",
6 | "html-path": "index.html",
7 | "Host": "browser"
8 | }
9 | ]
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/other/WebDemo/runtimes/raylib.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/other/WebDemo/runtimes/raylib.a
--------------------------------------------------------------------------------
/publish/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/publish/icon.png
--------------------------------------------------------------------------------
/publish/readme.md:
--------------------------------------------------------------------------------
1 | Fast, simple, and dependency-free physics engine written in C# with a clear and user-friendly API.
--------------------------------------------------------------------------------
/src/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | .vs
3 | imgui.ini
4 | [Bb]in/
5 | [Oo]bj/
6 | BenchmarkDotNet.Artifacts
7 |
--------------------------------------------------------------------------------
/src/Jitter2.slnx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/Jitter2/Attributes.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System;
25 |
26 | namespace Jitter2;
27 |
28 | ///
29 | /// Enum representing reference frames.
30 | ///
31 | public enum ReferenceFrame
32 | {
33 | Local,
34 | World
35 | }
36 |
37 | ///
38 | /// Attribute to specify the reference frame of a member.
39 | ///
40 | [AttributeUsage(AttributeTargets.All)]
41 | public class ReferenceFrameAttribute : Attribute
42 | {
43 | ///
44 | /// Gets or sets the reference frame.
45 | ///
46 | public ReferenceFrame Frame { get; set; }
47 |
48 | ///
49 | /// Initializes a new instance of the class.
50 | ///
51 | /// The reference frame.
52 | public ReferenceFrameAttribute(ReferenceFrame frame)
53 | {
54 | Frame = frame;
55 | }
56 | }
--------------------------------------------------------------------------------
/src/Jitter2/Collision/CollisionFilter/IBroadPhaseFilter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | namespace Jitter2.Collision;
25 |
26 | ///
27 | /// Interface for implementing a generic filter to exclude specific pairs of shapes
28 | /// that should not be considered in the collision system pipeline of Jitter.
29 | /// Refer to for more details.
30 | ///
31 | public interface IBroadPhaseFilter
32 | {
33 | ///
34 | /// Filters out pairs of shapes that should not generate contacts.
35 | ///
36 | /// False if the collision should be filtered out; true otherwise.
37 | bool Filter(IDynamicTreeProxy proxyA, IDynamicTreeProxy proxyB);
38 | }
--------------------------------------------------------------------------------
/src/Jitter2/Collision/CollisionFilter/INarrowPhaseFilter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using Jitter2.Collision.Shapes;
25 | using Jitter2.LinearMath;
26 |
27 | namespace Jitter2.Collision;
28 |
29 | ///
30 | /// Interface to facilitate the implementation of a generic filter. This filter can either exclude certain pairs of shapes or modify collision
31 | /// information subsequent to Jitter's execution of narrow phase collision detection between the shapes.
32 | ///
33 | public interface INarrowPhaseFilter
34 | {
35 | ///
36 | /// Invoked following the narrow phase of collision detection in Jitter. This allows for the modification of collision information.
37 | /// Refer to the corresponding methods for details on the parameters.
38 | ///
39 | /// False if the collision should be filtered out, true otherwise.
40 | bool Filter(RigidBodyShape shapeA, RigidBodyShape shapeB,
41 | ref JVector pointA, ref JVector pointB,
42 | ref JVector normal, ref Real penetration);
43 | }
--------------------------------------------------------------------------------
/src/Jitter2/Collision/CollisionIsland.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System.Collections.Generic;
25 | using Jitter2.DataStructures;
26 | using Jitter2.Dynamics;
27 |
28 | namespace Jitter2.Collision;
29 |
30 | ///
31 | /// Represents an island, which is a collection of bodies that are either directly or indirectly in contact with each other.
32 | ///
33 | public sealed class Island : IPartitionedSetIndex
34 | {
35 | internal readonly HashSet bodies = new();
36 | internal bool MarkedAsActive;
37 | internal bool NeedsUpdate;
38 |
39 | ///
40 | /// Gets a collection of all the bodies present in this island.
41 | ///
42 | public ReadOnlyHashSet Bodies => new(bodies);
43 |
44 | int IPartitionedSetIndex.SetIndex { get; set; } = -1;
45 |
46 | ///
47 | /// Initializes a new instance of the class.
48 | ///
49 | public Island()
50 | {
51 | }
52 |
53 | ///
54 | /// Clears all the bodies from the lists within this island.
55 | ///
56 | internal void ClearLists()
57 | {
58 | bodies.Clear();
59 | }
60 | }
--------------------------------------------------------------------------------
/src/Jitter2/Collision/NarrowPhase/ISupportMappable.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using Jitter2.LinearMath;
25 |
26 | namespace Jitter2.Collision;
27 |
28 | ///
29 | /// Defines an interface for a generic convex shape, which is characterized by its support function.
30 | ///
31 | public interface ISupportMappable
32 | {
33 | ///
34 | /// Identifies the point on the shape that is furthest in the specified direction.
35 | ///
36 | /// The direction in which to search for the furthest point. It does not need to be normalized.
37 | void SupportMap(in JVector direction, out JVector result);
38 |
39 | ///
40 | /// Returns a point deep within the shape. This is used in algorithms which work with the implicit
41 | /// definition of the support map function. The center of mass is a good choice.
42 | ///
43 | void GetCenter(out JVector point);
44 | }
--------------------------------------------------------------------------------
/src/Jitter2/DataStructures/ReadOnlyHashset.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System.Collections;
25 | using System.Collections.Generic;
26 |
27 | namespace Jitter2.DataStructures;
28 |
29 | ///
30 | /// Implements a wrapper for , eliminating garbage collection (GC) overhead during enumeration.
31 | ///
32 | public readonly struct ReadOnlyHashSet : IReadOnlyCollection
33 | {
34 | private readonly HashSet hashset;
35 |
36 | public ReadOnlyHashSet(HashSet hashset)
37 | {
38 | this.hashset = hashset;
39 | }
40 |
41 | public HashSet.Enumerator GetEnumerator()
42 | {
43 | return hashset.GetEnumerator();
44 | }
45 |
46 | IEnumerator IEnumerable.GetEnumerator()
47 | {
48 | return hashset.GetEnumerator();
49 | }
50 |
51 | IEnumerator IEnumerable.GetEnumerator()
52 | {
53 | return hashset.GetEnumerator();
54 | }
55 |
56 | public int Count => hashset.Count;
57 | }
--------------------------------------------------------------------------------
/src/Jitter2/DataStructures/ReadOnlyList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System.Collections;
25 | using System.Collections.Generic;
26 |
27 | namespace Jitter2.DataStructures;
28 |
29 | ///
30 | /// Implements a wrapper for , eliminating garbage collection (GC) overhead during enumeration.
31 | ///
32 | public readonly struct ReadOnlyList : IReadOnlyCollection
33 | {
34 | private readonly List list;
35 |
36 | public ReadOnlyList(List list)
37 | {
38 | this.list = list;
39 | }
40 |
41 | public T this[int i] => list[i];
42 |
43 | public List.Enumerator GetEnumerator()
44 | {
45 | return list.GetEnumerator();
46 | }
47 |
48 | IEnumerator IEnumerable.GetEnumerator()
49 | {
50 | return list.GetEnumerator();
51 | }
52 |
53 | IEnumerator IEnumerable.GetEnumerator()
54 | {
55 | return list.GetEnumerator();
56 | }
57 |
58 | public int Count => list.Count;
59 | }
--------------------------------------------------------------------------------
/src/Jitter2/IDebugDrawer.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using Jitter2.LinearMath;
25 |
26 | namespace Jitter2;
27 |
28 | ///
29 | /// Defines an interface for objects that can be debug-drawn.
30 | ///
31 | public interface IDebugDrawable
32 | {
33 | ///
34 | /// Passes an to draw basic debug information for the object.
35 | ///
36 | /// The debug drawer used for rendering debug information.
37 | public void DebugDraw(IDebugDrawer drawer);
38 | }
39 |
40 | ///
41 | /// Defines an interface for drawing debug visualization elements.
42 | ///
43 | public interface IDebugDrawer
44 | {
45 | public void DrawSegment(in JVector pA, in JVector pB);
46 | public void DrawTriangle(in JVector pA, in JVector pB, in JVector pC);
47 | public void DrawPoint(in JVector p);
48 | }
--------------------------------------------------------------------------------
/src/Jitter2/LinearMath/Interop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 |
4 | namespace Jitter2.LinearMath;
5 |
6 | using System.Numerics;
7 |
8 | // Enables implicit conversion between JVector/JQuaternion and .NET's own numeric types (Vector3 and Quaternion).
9 | // This allows seamless interoperability with .NET libraries that use these types.
10 |
11 | public partial struct JVector
12 | {
13 | public static implicit operator JVector((Real x, Real y, Real z) tuple) => new JVector(tuple.x, tuple.y, tuple.z);
14 |
15 | public static implicit operator Vector3(in JVector v) => new((float)v.X, (float)v.Y, (float)v.Z); // Unsafe.As(ref Unsafe.AsRef(v));
16 |
17 | public static implicit operator JVector(in Vector3 v) => new(v.X, v.Y, v.Z); // Unsafe.As(ref Unsafe.AsRef(v));
18 | }
19 |
20 | public partial struct JQuaternion
21 | {
22 | public static implicit operator JQuaternion((Real x, Real y, Real z, Real w) tuple) => new JQuaternion(tuple.x, tuple.y, tuple.z, tuple.w);
23 |
24 | public static implicit operator Quaternion(in JQuaternion q) => new((float)q.X, (float)q.Y, (float)q.Z, (float)q.W); // Unsafe.As(ref Unsafe.AsRef(q));
25 |
26 | public static implicit operator JQuaternion(in Quaternion q) => new(q.X, q.Y, q.Z, q.W); // Unsafe.As(ref Unsafe.AsRef(q));
27 | }
28 |
29 | #if DEBUG
30 |
31 | public static class UnsafeBase64Serializer where T : unmanaged
32 | {
33 | public static string Serialize(in T value)
34 | {
35 | int size = Unsafe.SizeOf();
36 | byte[] buffer = new byte[size];
37 |
38 | unsafe
39 | {
40 | fixed (byte* ptr = buffer)
41 | {
42 | *(T*)ptr = value;
43 | }
44 | }
45 |
46 | return Convert.ToBase64String(buffer);
47 | }
48 |
49 | public static T Deserialize(string base64)
50 | {
51 | byte[] buffer = Convert.FromBase64String(base64);
52 | if (buffer.Length != Unsafe.SizeOf())
53 | throw new InvalidOperationException("Data size does not match type size.");
54 |
55 | unsafe
56 | {
57 | fixed (byte* ptr = buffer)
58 | {
59 | return *(T*)ptr;
60 | }
61 | }
62 | }
63 | }
64 |
65 | #endif
--------------------------------------------------------------------------------
/src/Jitter2/SoftBodies/DynamicTreeCollisionFilter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using Jitter2.Collision;
25 | using Jitter2.Collision.Shapes;
26 |
27 | namespace Jitter2.SoftBodies;
28 |
29 | public static class DynamicTreeCollisionFilter
30 | {
31 | public static bool Filter(IDynamicTreeProxy proxyA, IDynamicTreeProxy proxyB)
32 | {
33 | if (proxyA is RigidBodyShape rbsA && proxyB is RigidBodyShape rbsB)
34 | {
35 | if (rbsA.RigidBody == rbsB.RigidBody) return false;
36 | }
37 | else if (proxyA is SoftBodyShape softBodyShapeA &&
38 | proxyB is SoftBodyShape softBodyShapeB)
39 | {
40 | SoftBody ta = softBodyShapeA.SoftBody;
41 | SoftBody tb = softBodyShapeB.SoftBody;
42 | return ta != tb;
43 | }
44 |
45 | return true;
46 | }
47 | }
--------------------------------------------------------------------------------
/src/Jitter2/SoftBodies/SoftBodyShape.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using Jitter2.Collision;
25 | using Jitter2.Collision.Shapes;
26 | using Jitter2.Dynamics;
27 | using Jitter2.LinearMath;
28 |
29 | namespace Jitter2.SoftBodies;
30 |
31 | public abstract class SoftBodyShape : Shape
32 | {
33 | public abstract RigidBody GetClosest(in JVector pos);
34 | public SoftBody SoftBody { get; internal init; } = null!;
35 |
36 | public override bool RayCast(in JVector origin, in JVector direction, out JVector normal, out Real lambda)
37 | {
38 | return NarrowPhase.RayCast(this, origin, direction, out lambda, out normal);
39 | }
40 | }
--------------------------------------------------------------------------------
/src/Jitter2/Unmanaged/MaximumSizeException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Thorben Linneweber and others
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining
5 | * a copy of this software and associated documentation files (the
6 | * "Software"), to deal in the Software without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be
13 | * included in all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System;
25 |
26 | namespace Jitter2.Unmanaged;
27 |
28 | ///
29 | /// An exception thrown when a size limit of a data structure
30 | /// is reached.
31 | ///
32 | public class MaximumSizeException : Exception
33 | {
34 | public MaximumSizeException()
35 | {
36 | }
37 |
38 | public MaximumSizeException(string message)
39 | : base(message)
40 | {
41 | }
42 |
43 | public MaximumSizeException(string message, Exception inner)
44 | : base(message, inner)
45 | {
46 | }
47 | }
--------------------------------------------------------------------------------
/src/JitterBenchmark/JitterBenchmark.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | enable
6 | enable
7 | net9.0
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/JitterBenchmark/Program.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Attributes;
2 | using BenchmarkDotNet.Running;
3 | using BenchmarkDotNet.Jobs;
4 | using JitterTests;
5 | using ThreadPool = Jitter2.Parallelization.ThreadPool;
6 |
7 | BenchmarkRunner.Run();
8 |
9 | [MemoryDiagnoser]
10 | [SimpleJob(RuntimeMoniker.HostProcess, launchCount: 1, warmupCount: 1, iterationCount: 3)]
11 | public class TowerStack
12 | {
13 | private World world = null!;
14 |
15 | [Params(2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40)]
16 | public int ThreadCount;
17 |
18 | [GlobalSetup]
19 | public void GlobalSetup()
20 | {
21 | world = new World();
22 | ThreadPool.Instance.ChangeThreadCount(ThreadCount);
23 | world.AllowDeactivation = false;
24 | }
25 |
26 | [Benchmark]
27 | public void Test()
28 | {
29 | world.SolverIterations = (14, 4);
30 | world.SubstepCount = 4;
31 |
32 | Helper.BuildTower(world, JVector.Zero, 400);
33 | Helper.AdvanceWorld(world, 20, 1.0f / 100.0f, true);
34 |
35 | world.Clear();
36 | }
37 | }
--------------------------------------------------------------------------------
/src/JitterBenchmark/Usings.cs:
--------------------------------------------------------------------------------
1 | global using Jitter2;
2 | global using Jitter2.Collision;
3 | global using Jitter2.Dynamics;
4 | global using Jitter2.LinearMath;
5 | global using Jitter2.Parallelization;
6 | global using Jitter2.Unmanaged;
7 | global using Jitter2.Collision.Shapes;
8 | global using BenchmarkDotNet;
9 | global using BenchmarkDotNet.Attributes;
10 | global using BenchmarkDotNet.Running;
--------------------------------------------------------------------------------
/src/JitterDemo/ColorGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using JitterDemo.Renderer.OpenGL;
3 |
4 | namespace JitterDemo;
5 |
6 | public static class ColorGenerator
7 | {
8 | private const int NumColors = 127;
9 |
10 | // Surprisingly buffering the colors is about 20 times
11 | // faster than generating them on the fly.
12 | private static readonly Vector3[] buffer = new Vector3[NumColors];
13 |
14 | static ColorGenerator()
15 | {
16 | for (int i = 0; i < NumColors; i++)
17 | {
18 | buffer[i] = ColorFromHSV((float)i / NumColors, 1, 0.6f);
19 | }
20 | }
21 |
22 | private static Vector3 ColorFromHSV(float h, float s, float v)
23 | {
24 | float Gen(float n)
25 | {
26 | float k = (n + h * 6) % 6;
27 | return v - v * s * Math.Max(0.0f, Math.Min(Math.Min(k, 4.0f - k), 1.0f));
28 | }
29 |
30 | return new Vector3(Gen(5), Gen(3), Gen(1));
31 | }
32 |
33 | public static Vector3 GetColor(int seed)
34 | {
35 | return buffer[(uint)seed % NumColors];
36 | }
37 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Conversion.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | using Jitter2.Dynamics;
3 | using Jitter2.LinearMath;
4 | using JitterDemo.Renderer.OpenGL;
5 |
6 | namespace JitterDemo;
7 |
8 | public class Conversion
9 | {
10 | public static JVector ToJitterVector(Vector3 im)
11 | {
12 | return new JVector(im.X, im.Y, im.Z);
13 | }
14 |
15 | public static Vector3 FromJitter(JVector vector)
16 | {
17 | return new Vector3(vector.X, vector.Y, vector.Z);
18 | }
19 |
20 | public static Matrix4 FromJitter(JMatrix jmat)
21 | {
22 | return new Matrix4
23 | {
24 | M11 = jmat.M11,
25 | M12 = jmat.M12,
26 | M13 = jmat.M13,
27 | M14 = 0,
28 |
29 | M21 = jmat.M21,
30 | M22 = jmat.M22,
31 | M23 = jmat.M23,
32 | M24 = 0,
33 |
34 | M31 = jmat.M31,
35 | M32 = jmat.M32,
36 | M33 = jmat.M33,
37 | M34 = 0,
38 |
39 | M41 = 0,
40 | M42 = 0,
41 | M43 = 0,
42 | M44 = 1
43 | };
44 | }
45 |
46 | public static Matrix4 FromJitter(RigidBody body)
47 | {
48 | Unsafe.SkipInit(out Matrix4 mat);
49 |
50 | JMatrix ori = JMatrix.CreateFromQuaternion(body.Data.Orientation);
51 | ref JVector pos = ref body.Data.Position;
52 |
53 | mat.M11 = ori.M11;
54 | mat.M12 = ori.M12;
55 | mat.M13 = ori.M13;
56 | mat.M14 = pos.X;
57 |
58 | mat.M21 = ori.M21;
59 | mat.M22 = ori.M22;
60 | mat.M23 = ori.M23;
61 | mat.M24 = pos.Y;
62 |
63 | mat.M31 = ori.M31;
64 | mat.M32 = ori.M32;
65 | mat.M33 = ori.M33;
66 | mat.M34 = pos.Z;
67 |
68 | mat.M41 = 0;
69 | mat.M42 = 0;
70 | mat.M43 = 0;
71 | mat.M44 = 1;
72 |
73 | return mat;
74 | }
75 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo00.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Jitter2;
3 | using Jitter2.LinearMath;
4 | using JitterDemo.Renderer;
5 |
6 | namespace JitterDemo;
7 |
8 | public class DecomposedTeapot : MultiMesh
9 | {
10 | public DecomposedTeapot() : base(Path.Combine("assets", "teapot_hull.obj"), 0.03f)
11 | {
12 | }
13 | }
14 |
15 | public class Demo00 : IDemo
16 | {
17 | private ConvexDecomposition teapotDecomp = null!;
18 |
19 | public string Name => "Convex Decomposition";
20 |
21 | public void Build()
22 | {
23 | Playground pg = (Playground)RenderWindow.Instance;
24 | World world = pg.World;
25 |
26 | pg.ResetScene();
27 |
28 | teapotDecomp = new ConvexDecomposition(world);
29 | teapotDecomp.Load();
30 |
31 | for (int i = 0; i < 6; i++)
32 | teapotDecomp.Spawn(new JVector(0, 10 + i * 3, -14));
33 |
34 | for (int i = 0; i < 6; i++)
35 | teapotDecomp.Spawn(new JVector(0, 10 + i * 3, -6));
36 |
37 | for (int i = 0; i < 6; i++)
38 | teapotDecomp.Spawn(new JVector(5, 10 + i * 3, -14));
39 |
40 | for (int i = 0; i < 6; i++)
41 | teapotDecomp.Spawn(new JVector(5, 10 + i * 3, -6));
42 |
43 | world.SolverIterations = (8, 4);
44 | }
45 |
46 | public void Draw()
47 | {
48 | teapotDecomp.PushMatrices();
49 | }
50 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo02.cs:
--------------------------------------------------------------------------------
1 | using Jitter2;
2 | using Jitter2.LinearMath;
3 | using JitterDemo.Renderer;
4 |
5 | namespace JitterDemo;
6 |
7 | public class Demo02 : IDemo
8 | {
9 | public string Name => "Tower of Jitter";
10 |
11 | public void Build()
12 | {
13 | Playground pg = (Playground)RenderWindow.Instance;
14 | World world = pg.World;
15 |
16 | pg.ResetScene();
17 |
18 | Common.BuildTower(JVector.Zero);
19 |
20 | world.SolverIterations = (12, 4);
21 | }
22 |
23 | public void Draw()
24 | {
25 | }
26 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo03.cs:
--------------------------------------------------------------------------------
1 | using Jitter2;
2 | using Jitter2.LinearMath;
3 | using JitterDemo.Renderer;
4 |
5 | namespace JitterDemo;
6 |
7 | public class Demo03 : IDemo
8 | {
9 | public string Name => "Ancient Pyramids";
10 |
11 | public void Build()
12 | {
13 | Playground pg = (Playground)RenderWindow.Instance;
14 | World world = pg.World;
15 |
16 | pg.ResetScene();
17 |
18 | Common.BuildPyramid(JVector.Zero, 40);
19 | Common.BuildPyramidCylinder(new JVector(10, 0, 10));
20 |
21 | world.SolverIterations = (4, 4);
22 | }
23 |
24 | public void Draw()
25 | {
26 | }
27 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo04.cs:
--------------------------------------------------------------------------------
1 | using Jitter2;
2 | using Jitter2.LinearMath;
3 | using JitterDemo.Renderer;
4 | using static JitterDemo.Common;
5 |
6 | namespace JitterDemo;
7 |
8 | public class Demo04 : IDemo
9 | {
10 | public string Name => "Many Ragdolls";
11 |
12 |
13 | public void Build()
14 | {
15 | Playground pg = (Playground)RenderWindow.Instance;
16 | World world = pg.World;
17 |
18 | var filter = new IgnoreCollisionBetweenFilter();
19 |
20 | world.BroadPhaseFilter = filter;
21 |
22 | pg.ResetScene();
23 |
24 | for (int i = 0; i < 100; i++)
25 | {
26 | BuildRagdoll(new JVector(0, 3 + 2 * i, 0));
27 | }
28 |
29 | world.SolverIterations = (8, 4);
30 | }
31 |
32 | public void Draw()
33 | {
34 | }
35 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo07.cs:
--------------------------------------------------------------------------------
1 | using Jitter2;
2 | using Jitter2.LinearMath;
3 | using JitterDemo.Renderer;
4 |
5 | namespace JitterDemo;
6 |
7 | public class Demo07 : IDemo
8 | {
9 | public string Name => "Many Pyramids";
10 |
11 | public void Build()
12 | {
13 | Playground pg = (Playground)RenderWindow.Instance;
14 | World world = pg.World;
15 |
16 | pg.ResetScene();
17 |
18 | world.SolverIterations = (4, 2);
19 |
20 | for (int e = 0; e < 2; e++)
21 | {
22 | for (int i = 0; i < 30; i++)
23 | {
24 | Common.BuildPyramid(new JVector(-20 + 40 * e, 0, -75 + 5 * i), 20,
25 | body => body.SetActivationState(false));
26 | }
27 | }
28 | }
29 |
30 | public void Draw()
31 | {
32 | }
33 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo08.cs:
--------------------------------------------------------------------------------
1 | using Jitter2;
2 | using Jitter2.Collision.Shapes;
3 | using Jitter2.LinearMath;
4 | using JitterDemo.Renderer;
5 |
6 | namespace JitterDemo;
7 |
8 | public class Demo08 : IDemo
9 | {
10 | public string Name => "Contact Manifold Test";
11 |
12 | public void Build()
13 | {
14 | Playground pg = (Playground)RenderWindow.Instance;
15 | World world = pg.World;
16 |
17 | pg.ResetScene();
18 |
19 | world.SolverIterations = (4, 4);
20 |
21 | var body = world.CreateRigidBody();
22 | body.AddShape(new BoxShape(new JVector(5, 0.5f, 0.5f)));
23 | body.Position = new JVector(0, 1, 0);
24 | body.IsStatic = true;
25 |
26 | var body2 = world.CreateRigidBody();
27 | body2.AddShape(new CylinderShape(0.5f, 3.0f));
28 | body2.Position = new JVector(0, 2.5f, 0);
29 | body2.Friction = 0;
30 | }
31 |
32 | public void Draw()
33 | {
34 | }
35 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo09.cs:
--------------------------------------------------------------------------------
1 | #pragma warning disable CS8602
2 |
3 | using Jitter2;
4 | using Jitter2.Collision.Shapes;
5 | using Jitter2.LinearMath;
6 | using JitterDemo.Renderer;
7 |
8 | namespace JitterDemo;
9 |
10 | public class Demo09 : IDemo
11 | {
12 | public string Name => "Restitution and Friction";
13 |
14 | public void Build()
15 | {
16 | Playground pg = (Playground)RenderWindow.Instance;
17 | World world = pg.World;
18 |
19 | pg.ResetScene();
20 |
21 | world.SolverIterations = (20, 4);
22 |
23 | if (pg.FloorShape != null)
24 | {
25 | pg.FloorShape.RigidBody.Friction = 0.0f;
26 | pg.FloorShape.RigidBody.Restitution = 0.0f;
27 | }
28 |
29 | for (int i = 0; i < 11; i++)
30 | {
31 | var body = world.CreateRigidBody();
32 | body.AddShape(new BoxShape(0.5f));
33 | body.Position = new JVector(-10 + i * 1, 4, -10);
34 | body.Restitution = i * 0.1f;
35 | body.Damping = (0.001f, 0.001f);
36 | }
37 |
38 | for (int i = 0; i < 11; i++)
39 | {
40 | var body = world.CreateRigidBody();
41 | body.AddShape(new BoxShape(0.5f));
42 | body.Position = new JVector(2 + i, 0.25f, 0);
43 | body.Friction = 1.0f - i * 0.1f;
44 | body.Velocity = new JVector(0, 0, -10);
45 | body.Damping = (0.001f, 0.001f);
46 | }
47 | }
48 |
49 | public void Draw()
50 | {
51 | }
52 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo10.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Jitter2;
3 | using Jitter2.Collision.Shapes;
4 | using Jitter2.Dynamics;
5 | using Jitter2.LinearMath;
6 | using JitterDemo.Renderer;
7 |
8 | namespace JitterDemo;
9 |
10 | public class Demo10 : IDemo
11 | {
12 | public string Name => "Stacked Cubes";
13 |
14 | public void Build()
15 | {
16 | var pg = (Playground)RenderWindow.Instance;
17 | World world = pg.World;
18 |
19 | pg.ResetScene();
20 |
21 | List bodies = new();
22 |
23 | for (int i = 0; i < 32; i++)
24 | {
25 | var body = world.CreateRigidBody();
26 | bodies.Add(body);
27 |
28 | body.Position = new JVector(0, 0.5f + i * 0.999f, 0);
29 | body.AddShape(new BoxShape(1));
30 | body.Damping = (0.002f, 0.002f);
31 | }
32 |
33 | for (int i = 0; i < 32; i++)
34 | {
35 | var body = world.CreateRigidBody();
36 | bodies.Add(body);
37 |
38 | body.Position = new JVector(10, 0.5f + i * 0.999f, 0);
39 | body.AddShape(new TransformedShape(new ConeShape(), JVector.Zero, JMatrix.CreateScale(0.4f, 1, 1)));
40 | body.Damping = (0.002f, 0.002f);
41 | }
42 |
43 | world.SolverIterations = (4, 2);
44 | world.SubstepCount = 3;
45 | }
46 |
47 | public void Draw()
48 | {
49 | }
50 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo11.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Jitter2;
3 | using Jitter2.Collision.Shapes;
4 | using Jitter2.Dynamics;
5 | using Jitter2.Dynamics.Constraints;
6 | using Jitter2.LinearMath;
7 | using JitterDemo.Renderer;
8 |
9 | namespace JitterDemo;
10 |
11 | public class Demo11 : IDemo
12 | {
13 | public string Name => "Double Pendulum";
14 |
15 | private RigidBody b0 = null!, b1 = null!;
16 |
17 | private World world = null!;
18 |
19 | public void Build()
20 | {
21 | Playground pg = (Playground)RenderWindow.Instance;
22 | world = pg.World;
23 |
24 | pg.ResetScene();
25 |
26 | b0 = world.CreateRigidBody();
27 | b0.AddShape(new SphereShape(0.2f));
28 | b0.Position = new JVector(0, 12, 0);
29 | b0.Velocity = new JVector(0.01f, 0, 0);
30 | b0.DeactivationTime = TimeSpan.MaxValue;
31 |
32 | b1 = world.CreateRigidBody();
33 | b1.AddShape(new SphereShape(0.2f));
34 | b1.Velocity = new JVector(0, 0, 0.01f);
35 | b1.Position = new JVector(0, 13, 0);
36 |
37 | var c0 = world.CreateConstraint(world.NullBody, b0);
38 | c0.Initialize(new JVector(0, 8, 0), b0.Position);
39 |
40 | var c1 = world.CreateConstraint(b0, b1);
41 | c1.Initialize(b0.Position, b1.Position);
42 |
43 | world.SubstepCount = 10;
44 | world.SolverIterations = (2, 2);
45 |
46 | b0.Damping = (0, 0);
47 | b1.Damping = (0, 0);
48 | }
49 |
50 | public void Draw()
51 | {
52 | float ekin = 0.5f * (b0.Velocity.LengthSquared() + b1.Velocity.LengthSquared());
53 | float epot = -world.Gravity.Y * (b0.Position.Y + b1.Position.Y);
54 |
55 | Console.WriteLine($"Energy: {ekin + epot} Kinetic {ekin}; Potential {epot}");
56 |
57 | var dr = RenderWindow.Instance.DebugRenderer;
58 | dr.PushLine(DebugRenderer.Color.Green, Conversion.FromJitter(new JVector(0, 8, 0)), Conversion.FromJitter(b0.Position));
59 | dr.PushLine(DebugRenderer.Color.White, Conversion.FromJitter(b0.Position), Conversion.FromJitter(b1.Position));
60 | }
61 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo12.cs:
--------------------------------------------------------------------------------
1 | using Jitter2;
2 | using Jitter2.Collision.Shapes;
3 | using Jitter2.LinearMath;
4 | using JitterDemo.Renderer;
5 |
6 | namespace JitterDemo;
7 |
8 | public class Demo12 : IDemo
9 | {
10 | public string Name => "Speculative Contacts";
11 |
12 | public void Build()
13 | {
14 | Playground pg = (Playground)RenderWindow.Instance;
15 | World world = pg.World;
16 |
17 | pg.ResetScene();
18 |
19 | world.BroadPhaseFilter = new Common.IgnoreCollisionBetweenFilter();
20 |
21 | var wallBody = world.CreateRigidBody();
22 | wallBody.AddShape(new BoxShape(10, 10f, 0.02f));
23 | wallBody.Position = new JVector(0, 6, -10);
24 | wallBody.IsStatic = true;
25 |
26 | var sphereBody = world.CreateRigidBody();
27 | sphereBody.AddShape(new SphereShape(0.3f));
28 | sphereBody.Position = new JVector(-3, 8, -1);
29 | sphereBody.Velocity = new JVector(0, 0, -107);
30 | sphereBody.EnableSpeculativeContacts = true;
31 |
32 | var boxBody = world.CreateRigidBody();
33 | boxBody.AddShape(new BoxShape(0.3f));
34 | boxBody.Position = new JVector(+3, 8, -1);
35 | boxBody.Velocity = new JVector(0, 0, -107);
36 | boxBody.EnableSpeculativeContacts = true;
37 |
38 |
39 | Common.BuildRagdoll(new JVector(0, 8, -1),
40 | body =>
41 | {
42 | body.Velocity = new JVector(0, 0, -107);
43 | body.EnableSpeculativeContacts = true;
44 | body.SetActivationState(false);
45 | }
46 | );
47 | }
48 |
49 | public void Draw()
50 | {
51 | //Console.WriteLine(sphereBody.Velocity.Y);
52 | }
53 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo13.cs:
--------------------------------------------------------------------------------
1 | using Jitter2;
2 | using Jitter2.Collision.Shapes;
3 | using Jitter2.Dynamics.Constraints;
4 | using Jitter2.LinearMath;
5 | using JitterDemo.Renderer;
6 |
7 | namespace JitterDemo;
8 |
9 | public class Demo13 : IDemo
10 | {
11 | public string Name => "Motor and Limit";
12 |
13 | public void Build()
14 | {
15 | var pg = (Playground)RenderWindow.Instance;
16 | World world = pg.World;
17 |
18 | pg.ResetScene();
19 |
20 | {
21 | // Motor
22 | var b0 = world.CreateRigidBody();
23 | b0.AddShape(new BoxShape(2, 0.1f, 0.1f));
24 | b0.Position = new JVector(-1.1f, 4, 0);
25 |
26 | var b1 = world.CreateRigidBody();
27 | b1.AddShape(new BoxShape(2, 0.1f, 0.1f));
28 | b1.Position = new JVector(1.1f, 4, 0);
29 |
30 | HingeJoint hj = new HingeJoint(world, world.NullBody, b0, b0.Position, JVector.UnitX, AngularLimit.Full, true);
31 | UniversalJoint uj = new UniversalJoint(world, b0, b1, new JVector(0, 4, 0), JVector.UnitX, JVector.UnitX);
32 |
33 | if (hj.Motor != null)
34 | {
35 | hj.Motor.TargetVelocity = 4;
36 | hj.Motor.MaximumForce = 1;
37 | }
38 |
39 | if (world.BroadPhaseFilter is not Common.IgnoreCollisionBetweenFilter filter)
40 | {
41 | filter = new Common.IgnoreCollisionBetweenFilter();
42 | world.BroadPhaseFilter = filter;
43 | }
44 |
45 | filter.IgnoreCollisionBetween(b0.Shapes[0], b1.Shapes[0]);
46 | }
47 |
48 | {
49 | // Hinge Joint with -120 <-> + 120 Limit
50 | var b0 = world.CreateRigidBody();
51 | b0.AddShape(new BoxShape(2, 0.1f, 3));
52 | b0.AddShape(new BoxShape(0.1f, 2, 2.9f));
53 | b0.Position = new JVector(-5, 3, 0);
54 |
55 | HingeJoint hj = new HingeJoint(world, world.NullBody, b0, b0.Position, JVector.UnitZ, AngularLimit.FromDegree(-120, 120));
56 | hj.HingeAngle.Bias = 0.3f;
57 | hj.HingeAngle.Softness = 0.0f;
58 | hj.HingeAngle.LimitBias = 0.3f;
59 | hj.HingeAngle.LimitSoftness = 0.0f;
60 |
61 | for (int i = 0; i < 4; i++)
62 | Common.BuildRagdoll(new JVector(-4, 5 + i * 3, 0));
63 | }
64 |
65 |
66 | world.SolverIterations = (4, 2);
67 | world.SubstepCount = 3;
68 | }
69 |
70 | public void Draw()
71 | {
72 | }
73 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo15.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Jitter2;
3 | using Jitter2.LinearMath;
4 | using Jitter2.SoftBodies;
5 | using JitterDemo.Renderer;
6 |
7 | namespace JitterDemo;
8 |
9 | public class Demo15 : IDemo, ICleanDemo
10 | {
11 | public string Name => "Pressurized Soft Bodies";
12 |
13 | private Playground pg = null!;
14 | private readonly List spheres = new();
15 | private World world = null!;
16 |
17 | public void Build()
18 | {
19 | spheres.Clear();
20 |
21 | pg = (Playground)RenderWindow.Instance;
22 | world = pg.World;
23 |
24 | pg.ResetScene();
25 |
26 | // Prepare Jitter to handle soft bodies.
27 | world.DynamicTree.Filter = DynamicTreeCollisionFilter.Filter;
28 | world.BroadPhaseFilter = new BroadPhaseCollisionFilter(world);
29 |
30 | for (int i = 0; i < 3; i++)
31 | {
32 | var sphere = new SoftBodySphere(world, new JVector(-3 + i * 3, 2, 0));
33 | sphere.Pressure = 300;
34 | spheres.Add(sphere);
35 | }
36 |
37 | world.SolverIterations = (4, 2);
38 | world.SubstepCount = 3;
39 | }
40 |
41 | public void Draw()
42 | {
43 | var dr = RenderWindow.Instance.DebugRenderer;
44 |
45 | foreach (var sphere in spheres)
46 | {
47 | foreach (var spring in sphere.Springs)
48 | {
49 | dr.PushLine(DebugRenderer.Color.Green, Conversion.FromJitter(spring.Body1.Position),
50 | Conversion.FromJitter(spring.Body2.Position));
51 | }
52 | }
53 | }
54 |
55 | public void CleanUp()
56 | {
57 | spheres.ForEach(sphere => sphere.Destroy());
58 | }
59 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo18.cs:
--------------------------------------------------------------------------------
1 | using Jitter2;
2 | using Jitter2.Collision;
3 | using Jitter2.Collision.Shapes;
4 | using Jitter2.LinearMath;
5 | using JitterDemo.Renderer;
6 |
7 | namespace JitterDemo;
8 |
9 | public class Demo18 : IDemo
10 | {
11 | public void Draw()
12 | {
13 | float time = (float)pg.Time;
14 |
15 | JMatrix ori = JMatrix.CreateRotationX(1.1f * time) *
16 | JMatrix.CreateRotationY(2.1f * time) *
17 | JMatrix.CreateRotationZ(1.7f * time);
18 |
19 | for (int i = -15; i < 16; i++)
20 | {
21 | for (int e = -15; e < 16; e++)
22 | {
23 | for (int k = -15; k < 16; k++)
24 | {
25 | JVector point = new JVector(i, e, k) * 0.1f;
26 |
27 | bool result = NarrowPhase.PointTest(testShape, ori, JVector.Zero, point);
28 |
29 | if (result)
30 | {
31 | pg.DebugRenderer.PushPoint(DebugRenderer.Color.White,
32 | Conversion.FromJitter(point), 0.01f);
33 | }
34 | }
35 | }
36 | }
37 | }
38 |
39 | public string Name => "PointTest";
40 |
41 | private Playground pg = null!;
42 | private World world = null!;
43 |
44 | private Shape testShape = null!;
45 |
46 | public void Build()
47 | {
48 | pg = (Playground)RenderWindow.Instance;
49 | world = pg.World;
50 |
51 | testShape = new ConeShape(1f);
52 | pg.ResetScene(false);
53 | }
54 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo19.cs:
--------------------------------------------------------------------------------
1 | using Jitter2;
2 | using Jitter2.Collision;
3 | using Jitter2.Collision.Shapes;
4 | using Jitter2.Dynamics;
5 | using Jitter2.LinearMath;
6 | using JitterDemo.Renderer;
7 |
8 | namespace JitterDemo;
9 |
10 | public class Demo19 : IDemo
11 | {
12 | public void Draw()
13 | {
14 | var dr = pg.DebugRenderer;
15 |
16 | var origin = new JVector(0, 20, 0);
17 |
18 | JVector rayVector = new JVector(0, -1, 0);
19 |
20 | for (int i = 0; i < 10000; i++)
21 | {
22 | JVector dir = JVector.Transform(rayVector, JMatrix.CreateRotationX(0.1f + 0.0001f * i));
23 | dir = 60.0f * JVector.Transform(dir, JMatrix.CreateRotationY(0.004f * i));
24 |
25 | dr.PushLine(DebugRenderer.Color.Green, Conversion.FromJitter(origin),
26 | Conversion.FromJitter(origin + dir));
27 |
28 | bool hit = world.DynamicTree.RayCast(origin, dir, null, null, out IDynamicTreeProxy? shape,
29 | out JVector normal, out float frac);
30 |
31 | if (hit)
32 | {
33 | dr.PushPoint(DebugRenderer.Color.White, Conversion.FromJitter(origin + frac * dir), 0.2f);
34 | }
35 | }
36 | }
37 |
38 | public string Name => "RayCastTest";
39 |
40 | private Playground pg = null!;
41 | private World world = null!;
42 |
43 | private RigidBody box = null!;
44 |
45 | public void Build()
46 | {
47 | pg = (Playground)RenderWindow.Instance;
48 | world = pg.World;
49 |
50 | pg.ResetScene();
51 |
52 | box = world.CreateRigidBody();
53 | box.AddShape(new BoxShape(1));
54 | box.Position = new JVector(0, 0.5f, -6);
55 | box.IsStatic = true;
56 | }
57 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo23.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Jitter2;
3 | using Jitter2.Collision.Shapes;
4 | using Jitter2.Dynamics;
5 | using Jitter2.LinearMath;
6 | using JitterDemo.Renderer;
7 |
8 | namespace JitterDemo;
9 |
10 | public class Demo23 : IDemo
11 | {
12 | public string Name => "Rotating Cube";
13 |
14 | private Playground pg = null!;
15 | private World world = null!;
16 |
17 | private RigidBody rotatingBox = null!;
18 |
19 | public void Build()
20 | {
21 | pg = (Playground)RenderWindow.Instance;
22 | world = pg.World;
23 |
24 | pg.ResetScene(false);
25 |
26 | rotatingBox = world.CreateRigidBody();
27 |
28 | float size = 50;
29 |
30 | var bs0 = new TransformedShape(new BoxShape(size, 1, size), new JVector(0, +size / 2, 0));
31 | var bs1 = new TransformedShape(new BoxShape(size, 1, size), new JVector(0, -size / 2, 0));
32 |
33 | var bs2 = new TransformedShape(new BoxShape(1, size, size), new JVector(+size / 2,0, 0));
34 | var bs3 = new TransformedShape(new BoxShape(1, size, size), new JVector(-size / 2,0, 0));
35 |
36 | var bs4 = new TransformedShape(new BoxShape(size, size, 1), new JVector(0,0, +size / 2));
37 | var bs5 = new TransformedShape(new BoxShape(size, size, 1), new JVector(0,0, -size / 2));
38 |
39 | rotatingBox.AddShape([bs0, bs1, bs2, bs3, bs4, bs5]);
40 | rotatingBox.Tag = new RigidBodyTag(true);
41 |
42 | rotatingBox.IsStatic = true;
43 |
44 | rotatingBox.DeactivationTime = TimeSpan.MaxValue;
45 | rotatingBox.SetActivationState(true);
46 |
47 | for (int i = -10; i < 10; i++)
48 | {
49 | for (int e = -10; e < 10; e++)
50 | {
51 | for (int j = -10; j < 10; j++)
52 | {
53 | RigidBody rb = world.CreateRigidBody();
54 | rb.AddShape(new BoxShape(1.5f));
55 | rb.Position = new JVector(i, e, j) * 2;
56 | }
57 | }
58 | }
59 | }
60 |
61 | public void Draw()
62 | {
63 | rotatingBox.AngularVelocity = new JVector(0.14f, 0.02f, 0.03f);
64 | }
65 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Demo27.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Jitter2;
3 | using Jitter2.Collision.Shapes;
4 | using Jitter2.Dynamics.Constraints;
5 | using Jitter2.LinearMath;
6 | using JitterDemo.Renderer;
7 |
8 | namespace JitterDemo;
9 |
10 | public class Demo27 : IDemo, ICleanDemo
11 | {
12 | public string Name => "CCD: Proof of concept";
13 |
14 | private CcdSolver ccdSolver = null!;
15 |
16 | public void Build()
17 | {
18 | Playground pg = (Playground)RenderWindow.Instance;
19 | World world = pg.World;
20 |
21 | ccdSolver = new CcdSolver(world);
22 |
23 | pg.ResetScene(true);
24 |
25 | var paddle = world.CreateRigidBody();
26 | paddle.AddShape(new BoxShape(5, 1, 0.01f));
27 | paddle.Position = (0, 3, -20);
28 | paddle.AffectedByGravity = false;
29 |
30 | var hinge = new HingeJoint(world, world.NullBody, paddle, paddle.Position,
31 | JVector.UnitY, AngularLimit.Full, false);
32 |
33 | var ball = world.CreateRigidBody();
34 | ball.AddShape(new SphereShape(0.2f));
35 | ball.Position = (+2.2f, 3, 400);
36 | ball.Velocity = (0, 0, -400);
37 | ball.Damping = (0, 0);
38 | ball.AffectedByGravity = false;
39 |
40 | Common.BuildRagdoll((-2.2f, 3.5f, -19.7f), body =>
41 | {
42 | body.AffectedByGravity = false;
43 | ccdSolver.Add(body);
44 | });
45 |
46 | ccdSolver.Add(paddle);
47 | ccdSolver.Add(ball);
48 |
49 | world.SpeculativeRelaxationFactor = 0.5f;
50 | }
51 |
52 | public void Draw()
53 | {
54 | }
55 |
56 | public void CleanUp()
57 | {
58 | ccdSolver.Destroy();
59 | }
60 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/IDemo.cs:
--------------------------------------------------------------------------------
1 | namespace JitterDemo;
2 |
3 | public interface ICleanDemo
4 | {
5 | public void CleanUp();
6 | }
7 |
8 | public interface IDemo
9 | {
10 | public void Build();
11 | public void Draw();
12 | public string Name { get; }
13 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Voxels/VoxelGrid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Jitter2;
4 | using Jitter2.Dynamics;
5 | using Jitter2.LinearMath;
6 |
7 | namespace JitterDemo;
8 |
9 | public class VoxelGrid
10 | {
11 | public const int Size = 100;
12 | private readonly World world;
13 | public HashSet Voxels = new();
14 |
15 | public VoxelGrid(World world)
16 | {
17 | this.world = world;
18 | }
19 |
20 | public uint GetNeighbours(int index)
21 | {
22 | uint result = 0;
23 |
24 | if (Voxels.Contains(index + 1)) result |= 1;
25 | if (Voxels.Contains(index - 1)) result |= 2;
26 | if (Voxels.Contains(index + Size)) result |= 4;
27 | if (Voxels.Contains(index - Size)) result |= 8;
28 | if (Voxels.Contains(index + Size * Size)) result |= 16;
29 | if (Voxels.Contains(index - Size * Size)) result |= 32;
30 |
31 | return result;
32 | }
33 |
34 | public JVector PositionFromIndex(int index)
35 | {
36 | if (index < 0 || index >= Size * Size * Size)
37 | {
38 | throw new ArgumentOutOfRangeException();
39 | }
40 |
41 | int z = index / (Size * Size);
42 | int y = (index - z * (Size * Size)) / Size;
43 | int x = index - z * (Size * Size) - y * Size;
44 | return new JVector(x, y, z);
45 | }
46 |
47 | public RigidBody? Body { get; }
48 |
49 | public bool AddVoxel(int x, int y, int z)
50 | {
51 | if (x < 0 || x >= Size || y < 0 || y >= Size || z < 0 || z >= Size)
52 | {
53 | throw new ArgumentOutOfRangeException();
54 | }
55 |
56 | return Voxels.Add(x + y * Size + z * Size * Size);
57 | }
58 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Demos/Voxels/VoxelShape.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using Jitter2.Collision.Shapes;
4 | using Jitter2.LinearMath;
5 |
6 | namespace JitterDemo;
7 |
8 | public class VoxelShape : RigidBodyShape
9 | {
10 | public JVector Position { get; }
11 | public int VoxelIndex { private set; get; }
12 | public VoxelGrid VoxelGrid { private set; get; }
13 |
14 | public uint Neighbours { private set; get; }
15 |
16 | public VoxelShape(VoxelGrid grid, int index)
17 | {
18 | Position = grid.PositionFromIndex(index);
19 | Neighbours = grid.GetNeighbours(index);
20 | VoxelIndex = index;
21 | VoxelGrid = grid;
22 | UpdateWorldBoundingBox();
23 | }
24 |
25 | public override void SupportMap(in JVector direction, out JVector result)
26 | {
27 | // this is the support function of a box with size 1.
28 | result.X = Math.Sign(direction.X) * 0.5f;
29 | result.Y = Math.Sign(direction.Y) * 0.5f;
30 | result.Z = Math.Sign(direction.Z) * 0.5f;
31 |
32 | result += Position;
33 | }
34 |
35 | public override void GetCenter(out JVector point)
36 | {
37 | point = Position;
38 | }
39 |
40 | public override void CalculateBoundingBox(in JQuaternion orientation, in JVector position, out JBBox box)
41 | {
42 | // NOTE: We do not support any transformation of the body here.
43 | Debug.Assert(orientation.W > 0.999f, "Voxel shape can not be attached to a transformed body.");
44 | Debug.Assert(MathHelper.CloseToZero(position), "Voxel shape can not be attached to a transformed body.");
45 |
46 | box.Min = Position - JVector.One * 0.5f;
47 | box.Max = Position + JVector.One * 0.5f;
48 | }
49 |
50 | public override void CalculateMassInertia(out JMatrix inertia, out JVector com, out float mass)
51 | {
52 | // Do not try to calculate mass properties here.
53 | mass = 1;
54 | inertia = JMatrix.Identity;
55 | com = Position;
56 | }
57 | }
--------------------------------------------------------------------------------
/src/JitterDemo/JitterDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | true
13 | true
14 | true
15 |
16 |
17 |
18 | Exe
19 | WinExe
20 | true
21 | UNSAFE
22 |
23 |
24 |
25 | $(DefineConstants);RELEASE;TRACE
26 | false
27 | portable
28 | true
29 |
30 |
31 |
32 |
33 | PreserveNewest
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 | Exe
45 | net9.0
46 | disable
47 | enable
48 | true
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/JitterDemo/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using JitterDemo.Renderer.OpenGL;
3 |
4 | namespace JitterDemo;
5 |
6 | public static class Program
7 | {
8 | private static void PrintException(Exception ex, string info)
9 | {
10 | Console.ForegroundColor = ConsoleColor.Red;
11 | Console.WriteLine($"{ex.GetType()}");
12 | Console.ForegroundColor = ConsoleColor.Yellow;
13 | Console.WriteLine(info);
14 | Console.ResetColor();
15 | Console.WriteLine(ex.Message);
16 | }
17 |
18 | public static void Main()
19 | {
20 | Jitter2.Logger.Listener = (level, message) => Console.WriteLine($"{level}: {message}");
21 |
22 | CreationSettings cs = new(1200, 800, "JitterDemo");
23 |
24 | try
25 | {
26 | new Playground().Open(cs);
27 | }
28 | catch (DllNotFoundException ex)
29 | {
30 | PrintException(ex, "Unable to load library.");
31 | }
32 | catch (OpenGLVersionNotSupportedException ex)
33 | {
34 | PrintException(ex, "The OpenGL version available on this system is too old.");
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/Cone.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using JitterDemo.Renderer.OpenGL;
4 |
5 | namespace JitterDemo.Renderer;
6 |
7 | public class Cone : CSMInstance
8 | {
9 | public const int Tesselation = 20;
10 |
11 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
12 | {
13 | static Vector3 GetSpherical(double alpha, double beta)
14 | {
15 | return new Vector3((float)(Math.Cos(alpha) * Math.Sin(beta)),
16 | (float)Math.Sin(beta),
17 | (float)(Math.Sin(alpha) * Math.Sin(beta)));
18 | }
19 |
20 | List vertices = new();
21 | List indices = new();
22 |
23 | float p1o4 = 1.0f / 4.0f;
24 | float p2o4 = 3.0f / 4.0f;
25 |
26 | vertices.Add(new Vertex(-p1o4 * Vector3.UnitY, -Vector3.UnitY));
27 |
28 | for (int i = 0; i < Tesselation; i++)
29 | {
30 | double alpha1 = 2.0d * Math.PI / Tesselation * i;
31 | double alpha2 = alpha1 + Math.PI / Tesselation;
32 | float beta = (float)(2.0d / Math.Sqrt(5.0d));
33 |
34 | Vector3 v1 = new()
35 | {
36 | X = 0.5f * (float)Math.Cos(alpha1),
37 | Z = 0.5f * (float)Math.Sin(alpha1)
38 | };
39 |
40 | Vector3 v2 = GetSpherical(alpha1, beta);
41 | Vector3 v3 = GetSpherical(alpha2, beta);
42 |
43 | vertices.Add(new Vertex(v1 - p1o4 * Vector3.UnitY, -Vector3.UnitY));
44 | vertices.Add(new Vertex(v1 - p1o4 * Vector3.UnitY, v2));
45 | vertices.Add(new Vertex(p2o4 * Vector3.UnitY, v3));
46 | }
47 |
48 | int t3 = 3 * Tesselation;
49 |
50 | for (int i = 0; i < Tesselation; i++)
51 | {
52 | indices.Add(new TriangleVertexIndex(0, 1 + 3 * i, 1 + (3 * i + 3) % t3));
53 | indices.Add(new TriangleVertexIndex(2 + 3 * i, 3 + 3 * i, 2 + (3 * i + 3) % t3));
54 | }
55 |
56 | return (vertices.ToArray(), indices.ToArray());
57 | }
58 |
59 | public override void LightPass(PhongShader shader)
60 | {
61 | shader.MaterialProperties.SetDefaultMaterial();
62 |
63 | base.LightPass(shader);
64 | }
65 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/Cube.cs:
--------------------------------------------------------------------------------
1 | using JitterDemo.Renderer.OpenGL;
2 |
3 | namespace JitterDemo.Renderer;
4 |
5 | public class Cube : CSMInstance
6 | {
7 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
8 | {
9 | // a 1x1x1 unit cube centered around the origin.
10 | Vertex[] vertices = new Vertex[24]; // 6 faces times 4 vertices
11 | TriangleVertexIndex[] indices = new TriangleVertexIndex[12]; // 2 triangles per face
12 |
13 | Vector3[] normals =
14 | {
15 | new(0, 0, 1),
16 | new(0, 0, -1),
17 | new(1, 0, 0),
18 | new(-1, 0, 0),
19 | new(0, 1, 0),
20 | new(0, -1, 0)
21 | };
22 |
23 | for (int i = 0; i < 6; i++)
24 | {
25 | Vector3 n = normals[i];
26 | Vector3 s1 = new(n.Y, n.Z, n.X);
27 | Vector3 s2 = Vector3.Cross(n, s1);
28 |
29 | vertices[4 * i + 0] = new Vertex((n - s1 - s2) * 0.5f, n);
30 | vertices[4 * i + 1] = new Vertex((n - s1 + s2) * 0.5f, n);
31 | vertices[4 * i + 2] = new Vertex((n + s1 + s2) * 0.5f, n);
32 | vertices[4 * i + 3] = new Vertex((n + s1 - s2) * 0.5f, n);
33 |
34 | indices[2 * i + 0] = new TriangleVertexIndex(4 * i + 1, 4 * i + 0, 4 * i + 2);
35 | indices[2 * i + 1] = new TriangleVertexIndex(4 * i + 2, 4 * i + 0, 4 * i + 3);
36 | }
37 |
38 | return (vertices, indices);
39 | }
40 |
41 | public override void LightPass(PhongShader shader)
42 | {
43 | base.LightPass(shader);
44 | }
45 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/Cylinder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using JitterDemo.Renderer.OpenGL;
4 |
5 | namespace JitterDemo.Renderer;
6 |
7 | public class Cylinder : CSMInstance
8 | {
9 | public const int Tesselation = 20;
10 |
11 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
12 | {
13 | List vertices = new();
14 | List indices = new();
15 |
16 | vertices.Add(new Vertex(-0.5f * Vector3.UnitY, -Vector3.UnitY));
17 | vertices.Add(new Vertex(+0.5f * Vector3.UnitY, +Vector3.UnitY));
18 |
19 | for (int i = 0; i < Tesselation; i++)
20 | {
21 | double alpha = 2.0d * Math.PI / Tesselation * i;
22 |
23 | Vector3 vertex = new()
24 | {
25 | X = (float)Math.Cos(alpha),
26 | Z = (float)Math.Sin(alpha)
27 | };
28 |
29 | vertices.Add(new Vertex(vertex - 0.5f * Vector3.UnitY, -Vector3.UnitY));
30 | vertices.Add(new Vertex(vertex + 0.5f * Vector3.UnitY, +Vector3.UnitY));
31 |
32 | vertices.Add(new Vertex(vertex - 0.5f * Vector3.UnitY, vertex));
33 | vertices.Add(new Vertex(vertex + 0.5f * Vector3.UnitY, vertex));
34 | }
35 |
36 | int t4 = 4 * Tesselation;
37 |
38 | for (int i = 0; i < Tesselation; i++)
39 | {
40 | indices.Add(new TriangleVertexIndex(0, 2 + 4 * i, 2 + (4 * i + 4) % t4));
41 | indices.Add(new TriangleVertexIndex(3 + 4 * i, 1, 3 + (4 * i + 4) % t4));
42 | indices.Add(new TriangleVertexIndex(4 + 4 * i, 5 + 4 * i, 4 + (4 * i + 4) % t4));
43 | indices.Add(new TriangleVertexIndex(5 + 4 * i, 5 + (4 * i + 4) % t4, 4 + (4 * i + 4) % t4));
44 | }
45 |
46 | return (vertices.ToArray(), indices.ToArray());
47 | }
48 |
49 | public override void LightPass(PhongShader shader)
50 | {
51 | shader.MaterialProperties.SetDefaultMaterial();
52 |
53 | base.LightPass(shader);
54 | }
55 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/DebugInstance.cs:
--------------------------------------------------------------------------------
1 | namespace JitterDemo.Renderer;
2 |
3 | public class DebugInstance : CSMInstance
4 | {
5 | private readonly Vertex[] vertices;
6 | private readonly TriangleVertexIndex[] indices;
7 |
8 | public DebugInstance(Vertex[] vertices, TriangleVertexIndex[] indices)
9 | {
10 | this.vertices = vertices;
11 | this.indices = indices;
12 | }
13 |
14 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
15 | {
16 | return (vertices, indices);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/Floor.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using JitterDemo.Renderer.OpenGL;
3 |
4 | namespace JitterDemo.Renderer;
5 |
6 | public class JitterFloor : CSMInstance
7 | {
8 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
9 | {
10 | const int size = 100;
11 |
12 | Vertex[] vertices = new Vertex[4];
13 | vertices[0] = new Vertex(new Vector3(-size, 0, -size), Vector3.UnitY, new Vector2(0, 0));
14 | vertices[1] = new Vertex(new Vector3(-size, 0, +size), Vector3.UnitY, new Vector2(0, size));
15 | vertices[2] = new Vertex(new Vector3(+size, 0, -size), Vector3.UnitY, new Vector2(size, 0));
16 | vertices[3] = new Vertex(new Vector3(+size, 0, +size), Vector3.UnitY, new Vector2(size, size));
17 |
18 | TriangleVertexIndex[] indices = new TriangleVertexIndex[2];
19 | indices[0] = new TriangleVertexIndex(0, 1, 2);
20 | indices[1] = new TriangleVertexIndex(2, 1, 3);
21 |
22 | return (vertices, indices);
23 | }
24 |
25 | public override void LightPass(PhongShader shader)
26 | {
27 | shader.MaterialProperties.SetDefaultMaterial();
28 |
29 | shader.MaterialProperties.Shininess.Set(10.0f);
30 |
31 | shader.MaterialProperties.ColorMixing.Set(0.0f, 0, 1f);
32 |
33 | base.LightPass(shader);
34 | }
35 |
36 | public override void Load()
37 | {
38 | string filename = Path.Combine("assets", "unit.tga");
39 |
40 | Image.LoadImage(filename).FixedData((img, ptr) => { Texture.LoadImage(ptr, img.Width, img.Height); });
41 |
42 | Texture.SetWrap(OpenGL.Texture.Wrap.Repeat);
43 | Texture.SetAnisotropicFiltering(OpenGL.Texture.Anisotropy.Filter_8x);
44 |
45 | base.Load();
46 | }
47 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/HalfSphere.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using JitterDemo.Renderer.OpenGL;
4 |
5 | namespace JitterDemo.Renderer;
6 |
7 | public class HalfSphere : CSMInstance
8 | {
9 | public const int Tesselation = 20;
10 |
11 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
12 | {
13 | List vertices = new();
14 | List indices = new();
15 |
16 | for (int e = 0; e < Tesselation / 2; e++)
17 | {
18 | for (int i = 0; i < Tesselation; i++)
19 | {
20 | double alpha = 2.0d * Math.PI / Tesselation * i;
21 | double beta = Math.PI / Tesselation * e;
22 |
23 | Vector3 vertex;
24 | vertex.X = (float)(Math.Cos(alpha) * Math.Cos(beta));
25 | vertex.Y = (float)Math.Sin(beta);
26 | vertex.Z = (float)(Math.Sin(alpha) * Math.Cos(beta));
27 |
28 | vertices.Add(new Vertex(vertex * 0.5f, vertex));
29 | }
30 | }
31 |
32 | vertices.Add(new Vertex(Vector3.UnitY * 0.5f, Vector3.UnitY));
33 |
34 | int t1 = Tesselation;
35 | int td2 = Tesselation / 2;
36 |
37 | for (int e = 0; e < td2 - 1; e++)
38 | {
39 | for (int i = 0; i < Tesselation; i++)
40 | {
41 | indices.Add(new TriangleVertexIndex(e * t1 + (i + 1) % t1,e * t1 + i, (e + 1) * t1 + i));
42 | indices.Add(new TriangleVertexIndex((e + 1) * t1 + (i + 1) % t1, e * t1 + (i + 1) % t1, (e + 1) * t1 + i));
43 | }
44 | }
45 |
46 | for (int i = 0; i < Tesselation; i++)
47 | {
48 | int e = td2 - 1;
49 | indices.Add(new TriangleVertexIndex(e * t1 + (i + 1) % t1, e * t1 + i, td2 * t1));
50 | }
51 |
52 | return (vertices.ToArray(), indices.ToArray());
53 | }
54 |
55 | public override void LightPass(PhongShader shader)
56 | {
57 | shader.MaterialProperties.SetDefaultMaterial();
58 |
59 | base.LightPass(shader);
60 | }
61 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/MultiMesh.cs:
--------------------------------------------------------------------------------
1 | using JitterDemo.Renderer.OpenGL;
2 |
3 | namespace JitterDemo.Renderer;
4 |
5 | public class MultiMesh : CSMInstance
6 | {
7 | public readonly Mesh mesh;
8 |
9 | public MultiMesh(string filename, float scale = 1.0f)
10 | {
11 | mesh = Mesh.LoadMesh(filename, false);
12 | mesh.Transform(MatrixHelper.CreateScale(scale));
13 | }
14 |
15 | public override void LightPass(PhongShader shader)
16 | {
17 | if (mesh.Groups.Length == 0) return;
18 |
19 | Texture?.Bind(3);
20 |
21 | shader.MaterialProperties.SetDefaultMaterial();
22 |
23 | Vao.Bind();
24 |
25 | int sof = sizeof(float);
26 |
27 | for (int i = 0; i < mesh.Groups.Length; i++)
28 | {
29 | shader.MaterialProperties.Color.Set(ColorGenerator.GetColor(i * (i << 6)));
30 | shader.MaterialProperties.ColorMixing.Set(0, 1, 0);
31 |
32 |
33 | GLDevice.DrawElementsInstanced(DrawMode.Triangles,
34 | 3 * (mesh.Groups[i].ToExclusive - mesh.Groups[i].FromInclusive), IndexType.UnsignedInt,
35 | mesh.Groups[i].FromInclusive * sof * 3, Count);
36 | }
37 |
38 | shader.MaterialProperties.SetDefaultMaterial();
39 | }
40 |
41 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
42 | {
43 | return (mesh.Vertices, mesh.Indices);
44 | }
45 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/Sphere.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using JitterDemo.Renderer.OpenGL;
4 |
5 | namespace JitterDemo.Renderer;
6 |
7 | public class Sphere : CSMInstance
8 | {
9 | public const int Tesselation = 20;
10 |
11 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
12 | {
13 | List vertices = new();
14 | List indices = new();
15 |
16 | for (int e = 0; e < Tesselation; e++)
17 | {
18 | for (int i = 0; i < Tesselation; i++)
19 | {
20 | double alpha = 2.0d * Math.PI / Tesselation * i;
21 | double beta = Math.PI / (Tesselation + 1) * (e + 1);
22 |
23 | Vector3 vertex;
24 | vertex.X = (float)(Math.Cos(alpha) * Math.Sin(beta));
25 | vertex.Y = (float)Math.Cos(beta);
26 | vertex.Z = (float)(Math.Sin(alpha) * Math.Sin(beta));
27 |
28 | vertices.Add(new Vertex(vertex * 0.5f, vertex));
29 | }
30 | }
31 |
32 | vertices.Add(new Vertex(Vector3.UnitY * -0.5f, -Vector3.UnitY));
33 | vertices.Add(new Vertex(Vector3.UnitY * +0.5f, Vector3.UnitY));
34 |
35 | int t1 = Tesselation;
36 |
37 | for (int e = 0; e < Tesselation - 1; e++)
38 | {
39 | for (int i = 0; i < Tesselation; i++)
40 | {
41 | indices.Add(new TriangleVertexIndex(e * t1 + i, e * t1 + (i + 1) % t1, (e + 1) * t1 + i));
42 | indices.Add(new TriangleVertexIndex(e * t1 + (i + 1) % t1, (e + 1) * t1 + (i + 1) % t1,
43 | (e + 1) * t1 + i));
44 | }
45 | }
46 |
47 | for (int i = 0; i < Tesselation; i++)
48 | {
49 | int e = t1 - 1;
50 | indices.Add(new TriangleVertexIndex(e * t1 + i, e * t1 + (i + 1) % t1, t1 * t1 + 0));
51 | e = 0;
52 | indices.Add(new TriangleVertexIndex(e * t1 + (i + 1) % t1, e * t1 + i, t1 * t1 + 1));
53 | }
54 |
55 | return (vertices.ToArray(), indices.ToArray());
56 | }
57 |
58 | public override void LightPass(PhongShader shader)
59 | {
60 | shader.MaterialProperties.SetDefaultMaterial();
61 |
62 | base.LightPass(shader);
63 | }
64 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/TriangleMesh.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using JitterDemo.Renderer.OpenGL;
3 |
4 | namespace JitterDemo.Renderer;
5 |
6 | public class TriangleMesh : CSMInstance
7 | {
8 | public readonly Mesh Mesh;
9 |
10 | public Vector3 Color { get; set; }
11 |
12 | public TriangleMesh(string objFile, float scale = 1.0f)
13 | {
14 | string filename = Path.Combine("assets", objFile);
15 | Mesh = Mesh.LoadMesh(filename);
16 | Mesh.Transform(MatrixHelper.CreateScale(scale));
17 | }
18 |
19 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
20 | {
21 | return (Mesh.Vertices, Mesh.Indices);
22 | }
23 |
24 | public override void LightPass(PhongShader shader)
25 | {
26 | //Renderer.OpenGL.Native.GL.PolygonMode(Renderer.OpenGL.Native.GLC.FRONT_AND_BACK, Renderer.OpenGL.Native.GLC.LINE);
27 | base.LightPass(shader);
28 | //Renderer.OpenGL.Native.GL.PolygonMode(Renderer.OpenGL.Native.GLC.FRONT_AND_BACK, Renderer.OpenGL.Native.GLC.FILL);
29 | }
30 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/CSM/Instances/Tube.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using JitterDemo.Renderer.OpenGL;
4 |
5 | namespace JitterDemo.Renderer;
6 |
7 | public class Tube : CSMInstance
8 | {
9 | public const int Tesselation = 30;
10 |
11 | public override (Vertex[] vertices, TriangleVertexIndex[] indices) ProvideVertices()
12 | {
13 | List vertices = new();
14 | List indices = new();
15 |
16 | vertices.Add(new Vertex(-0.5f * Vector3.UnitY, -Vector3.UnitY));
17 | vertices.Add(new Vertex(+0.5f * Vector3.UnitY, +Vector3.UnitY));
18 |
19 | for (int i = 0; i < Tesselation; i++)
20 | {
21 | double alpha = 2.0d * Math.PI / Tesselation * i;
22 |
23 | Vector3 vertex = new()
24 | {
25 | X = (float)Math.Cos(alpha),
26 | Z = (float)Math.Sin(alpha)
27 | };
28 |
29 | vertices.Add(new Vertex(0.5f * (vertex - Vector3.UnitY), vertex));
30 | vertices.Add(new Vertex(0.5f * (vertex + Vector3.UnitY), vertex));
31 | }
32 |
33 | int t2 = 2 * Tesselation;
34 |
35 | for (int i = 0; i < Tesselation; i++)
36 | {
37 | indices.Add(new TriangleVertexIndex(2 + 2 * i, 3 + 2 * i, 2 + (2 * i + 2) % t2));
38 | indices.Add(new TriangleVertexIndex(3 + 2 * i, 3 + (2 * i + 2) % t2, 2 + (2 * i + 2) % t2));
39 | }
40 |
41 | return (vertices.ToArray(), indices.ToArray());
42 | }
43 |
44 | public override void LightPass(PhongShader shader)
45 | {
46 | shader.MaterialProperties.SetDefaultMaterial();
47 |
48 | base.LightPass(shader);
49 | }
50 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/OpenGL/GLDebug.cs:
--------------------------------------------------------------------------------
1 | /* Copyright <2022>
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy
4 | * of this software and associated documentation files (the "Software"), to deal
5 | * in the Software without restriction, including without limitation the rights
6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | * copies of the Software, and to permit persons to whom the Software is
8 | * furnished to do so, subject to the following conditions:
9 | *
10 | * The above copyright notice and this permission notice shall be included in all
11 | * copies or substantial portions of the Software.
12 | *
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | * SOFTWARE.
20 | *
21 | */
22 |
23 | using JitterDemo.Renderer.OpenGL.Native;
24 |
25 | namespace JitterDemo.Renderer.OpenGL;
26 |
27 | public enum GLDebugMessageSeverity : uint
28 | {
29 | Notification = GLC.DEBUG_SEVERITY_NOTIFICATION,
30 | Low = GLC.DEBUG_SEVERITY_LOW,
31 | Medium = GLC.DEBUG_SEVERITY_MEDIUM,
32 | High = GLC.DEBUG_SEVERITY_HIGH
33 | }
34 |
35 | public enum GLDebugMessageSource : uint
36 | {
37 | API = GLC.DEBUG_SOURCE_API,
38 | WindowSystem = GLC.DEBUG_SOURCE_WINDOW_SYSTEM,
39 | ShaderCompiler = GLC.DEBUG_SOURCE_SHADER_COMPILER,
40 | ThirdParty = GLC.DEBUG_SOURCE_THIRD_PARTY,
41 | Application = GLC.DEBUG_SOURCE_APPLICATION,
42 | Other = GLC.DEBUG_SOURCE_OTHER
43 | }
44 |
45 | public enum GLDebugMessageType : uint
46 | {
47 | Error = GLC.DEBUG_TYPE_ERROR,
48 | DeprecatedBehavior = GLC.DEBUG_TYPE_DEPRECATED_BEHAVIOR,
49 | UndefinedBehavior = GLC.DEBUG_TYPE_UNDEFINED_BEHAVIOR,
50 | Portability = GLC.DEBUG_TYPE_PORTABILITY,
51 | Performance = GLC.DEBUG_TYPE_PERFORMANCE,
52 | Marker = GLC.DEBUG_TYPE_MARKER,
53 | PushGroup = GLC.DEBUG_TYPE_PUSH_GROUP,
54 | PopGroup = GLC.DEBUG_TYPE_POP_GROUP,
55 | Other = GLC.DEBUG_TYPE_OTHER
56 | }
57 |
58 | public struct GLDebugMessage
59 | {
60 | public GLDebugMessageSeverity Severity;
61 | public GLDebugMessageSource Source;
62 | public GLDebugMessageType Type;
63 | public string Message;
64 | public uint Id;
65 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/OpenGL/Objects/ArrayBuffer.cs:
--------------------------------------------------------------------------------
1 | /* Copyright <2022>
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy
4 | * of this software and associated documentation files (the "Software"), to deal
5 | * in the Software without restriction, including without limitation the rights
6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | * copies of the Software, and to permit persons to whom the Software is
8 | * furnished to do so, subject to the following conditions:
9 | *
10 | * The above copyright notice and this permission notice shall be included in all
11 | * copies or substantial portions of the Software.
12 | *
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | * SOFTWARE.
20 | *
21 | */
22 |
23 | using JitterDemo.Renderer.OpenGL.Native;
24 |
25 | namespace JitterDemo.Renderer.OpenGL;
26 |
27 | [GLObject(GLObjectType.ArrayBuffer)]
28 | public sealed class ArrayBuffer : GLBuffer
29 | {
30 | public ArrayBuffer() : base(GLC.ARRAY_BUFFER)
31 | {
32 | }
33 |
34 | public ArrayBuffer(uint buffer) : base(buffer, GLC.ARRAY_BUFFER)
35 | {
36 | }
37 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/OpenGL/Objects/ElementArrayBuffer.cs:
--------------------------------------------------------------------------------
1 | /* Copyright <2022>
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy
4 | * of this software and associated documentation files (the "Software"), to deal
5 | * in the Software without restriction, including without limitation the rights
6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | * copies of the Software, and to permit persons to whom the Software is
8 | * furnished to do so, subject to the following conditions:
9 | *
10 | * The above copyright notice and this permission notice shall be included in all
11 | * copies or substantial portions of the Software.
12 | *
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | * SOFTWARE.
20 | *
21 | */
22 |
23 | using JitterDemo.Renderer.OpenGL.Native;
24 |
25 | namespace JitterDemo.Renderer.OpenGL;
26 |
27 | [GLObject(GLObjectType.ElementArrayBuffer)]
28 | public sealed class ElementArrayBuffer : GLBuffer
29 | {
30 | public ElementArrayBuffer() : base(GLC.ELEMENT_ARRAY_BUFFER)
31 | {
32 | }
33 |
34 | public ElementArrayBuffer(uint buffer) : base(buffer, GLC.ELEMENT_ARRAY_BUFFER)
35 | {
36 | }
37 | }
--------------------------------------------------------------------------------
/src/JitterDemo/Renderer/OpenGL/Objects/Framebuffer.cs:
--------------------------------------------------------------------------------
1 | /* Copyright <2022>
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy
4 | * of this software and associated documentation files (the "Software"), to deal
5 | * in the Software without restriction, including without limitation the rights
6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | * copies of the Software, and to permit persons to whom the Software is
8 | * furnished to do so, subject to the following conditions:
9 | *
10 | * The above copyright notice and this permission notice shall be included in all
11 | * copies or substantial portions of the Software.
12 | *
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | * SOFTWARE.
20 | *
21 | */
22 |
23 | using JitterDemo.Renderer.OpenGL.Native;
24 |
25 | namespace JitterDemo.Renderer.OpenGL;
26 |
27 | [GLObject(GLObjectType.FrameBuffer)]
28 | public class FrameBuffer : GLObject
29 | {
30 | public static readonly FrameBuffer Default = new(0);
31 |
32 | public FrameBuffer() : base(GL.GenFramebuffer())
33 | {
34 | }
35 |
36 | private FrameBuffer(uint fbo) : base(fbo)
37 | {
38 | }
39 |
40 | public void Bind()
41 | {
42 | GL.BindFramebuffer(GLC.FRAMEBUFFER, Handle);
43 | }
44 |
45 | public void AttachDepthTexture(Texture2D texture)
46 | {
47 | Bind();
48 | GL.FramebufferTexture2D(GLC.FRAMEBUFFER, GLC.DEPTH_ATTACHMENT, GLC.TEXTURE_2D, texture.Handle, 0);
49 | GL.DrawBuffer(GLC.NONE);
50 | }
51 | }
--------------------------------------------------------------------------------
/src/JitterDemo/assets/car.blend:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/assets/car.blend
--------------------------------------------------------------------------------
/src/JitterDemo/assets/car.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/assets/car.tga
--------------------------------------------------------------------------------
/src/JitterDemo/assets/dragon.LICENSE:
--------------------------------------------------------------------------------
1 | This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
2 | https://creativecommons.org/licenses/by-sa/4.0/deed.en
3 |
4 | http://graphics.stanford.edu/data/3Dscanrep/
5 | http://www-graphics.stanford.edu
6 |
7 | see: https://en.wikipedia.org/wiki/Stanford_dragon
8 |
--------------------------------------------------------------------------------
/src/JitterDemo/assets/dragon.obj.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/assets/dragon.obj.zip
--------------------------------------------------------------------------------
/src/JitterDemo/assets/level.LICENSE:
--------------------------------------------------------------------------------
1 | de_dust2 1.6 by CalciumOxide on Thingiverse: https://www.thingiverse.com/thing:3481976
2 |
3 | This thing was created by Thingiverse user CalciumOxide, and is licensed under cc-nc.
4 |
5 | https://creativecommons.org/licenses/by-nc/4.0/
6 |
--------------------------------------------------------------------------------
/src/JitterDemo/assets/level.blend:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/assets/level.blend
--------------------------------------------------------------------------------
/src/JitterDemo/assets/logo.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/assets/logo.tga
--------------------------------------------------------------------------------
/src/JitterDemo/assets/teapot.obj.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/assets/teapot.obj.zip
--------------------------------------------------------------------------------
/src/JitterDemo/assets/texture_10.LICENSE:
--------------------------------------------------------------------------------
1 |
2 |
3 | Prototype Textures 1.0
4 |
5 | Created/distributed by Kenney (www.kenney.nl)
6 | Creation date: 08-04-2020
7 |
8 | ------------------------------
9 |
10 | License: (Creative Commons Zero, CC0)
11 | http://creativecommons.org/publicdomain/zero/1.0/
12 |
13 | This content is free to use in personal, educational and commercial projects.
14 |
15 |
16 | Support us by crediting Kenney or www.kenney.nl (this is not mandatory)
17 |
18 | ------------------------------
19 |
20 | Donate: http://support.kenney.nl
21 | Request: http://request.kenney.nl
22 | Patreon: http://patreon.com/kenney/
23 |
24 | Follow on Twitter for updates:
25 | http://twitter.com/KenneyNL
26 |
--------------------------------------------------------------------------------
/src/JitterDemo/assets/texture_10.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/assets/texture_10.tga
--------------------------------------------------------------------------------
/src/JitterDemo/assets/unit.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/assets/unit.tga
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/linux-arm64/native/cimgui.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/linux-arm64/native/cimgui.so
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/linux-arm64/native/libglfw.so.3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/linux-arm64/native/libglfw.so.3
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/linux-x64/native/cimgui.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/linux-x64/native/cimgui.so
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/linux-x64/native/libglfw.so.3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/linux-x64/native/libglfw.so.3
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/osx-arm64/native/cimgui.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/osx-arm64/native/cimgui.dylib
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/osx-arm64/native/libglfw.3.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/osx-arm64/native/libglfw.3.dylib
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/osx-x64/native/cimgui.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/osx-x64/native/cimgui.dylib
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/osx-x64/native/libglfw.3.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/osx-x64/native/libglfw.3.dylib
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/win-arm64/native/cimgui.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/win-arm64/native/cimgui.dll
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/win-arm64/native/glfw3.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/win-arm64/native/glfw3.dll
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/win-x64/native/cimgui.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/win-x64/native/cimgui.dll
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/win-x64/native/glfw3.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/win-x64/native/glfw3.dll
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/win-x86/native/cimgui.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/win-x86/native/cimgui.dll
--------------------------------------------------------------------------------
/src/JitterDemo/runtimes/win-x86/native/glfw3.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/notgiven688/jitterphysics2/77252590e4410be3504a418eaf3003a0bd0d5d5a/src/JitterDemo/runtimes/win-x86/native/glfw3.dll
--------------------------------------------------------------------------------
/src/JitterTests/BoundingBoxTests.cs:
--------------------------------------------------------------------------------
1 | using Jitter2.SoftBodies;
2 |
3 | namespace JitterTests;
4 |
5 | public class BoundingBoxTests
6 | {
7 | private static void CheckBoundingBox(RigidBodyShape shape)
8 | {
9 | JQuaternion ori = new JQuaternion(1, 2, 3, 4);
10 | ori.Normalize();
11 |
12 | JVector pos = new JVector(12, -11, 17);
13 |
14 | ShapeHelper.CalculateBoundingBox(shape, ori, pos, out JBBox shr);
15 | shape.CalculateBoundingBox(ori, pos, out JBBox sbb);
16 |
17 | Real fraction = shr.GetVolume() / sbb.GetVolume();
18 |
19 | Assert.That(fraction - (Real)1e-7, Is.LessThan((Real)1.0));
20 | Assert.That(fraction, Is.GreaterThan((Real)0.2));
21 | }
22 |
23 | [TestCase]
24 | public static void RigidBodyShapeTests()
25 | {
26 | CheckBoundingBox(new BoxShape(1, 2, 3));
27 | CheckBoundingBox(new CapsuleShape(1, 2));
28 | CheckBoundingBox(new ConeShape(1, 2));
29 | CheckBoundingBox(new CylinderShape(1, 2));
30 | CheckBoundingBox(new SphereShape(1));
31 |
32 | JVector a = new JVector(1, 2, 3);
33 | JVector b = new JVector(2, 2, 3);
34 | JVector c = new JVector(1, -2, 4);
35 | JVector d = new JVector(3, 3, 3);
36 |
37 | List vertices =
38 | [
39 | a, b, c, d
40 | ];
41 |
42 | List triangles =
43 | [
44 | new JTriangle(a, b, c),
45 | new JTriangle(a, b, d),
46 | new JTriangle(a, d, c),
47 | new JTriangle(d, b, c)
48 | ];
49 |
50 | TriangleMesh tm = new TriangleMesh(triangles);
51 |
52 | CheckBoundingBox(new ConvexHullShape(triangles));
53 | CheckBoundingBox(new PointCloudShape(vertices));
54 | CheckBoundingBox(new TriangleShape(tm, 0));
55 | }
56 | }
--------------------------------------------------------------------------------
/src/JitterTests/ConstraintTests.cs:
--------------------------------------------------------------------------------
1 | using Jitter2.Dynamics.Constraints;
2 | using Jitter2.SoftBodies;
3 |
4 | namespace JitterTests;
5 |
6 | public class ConstraintTests
7 | {
8 | [SetUp]
9 | public void Setup()
10 | {
11 | }
12 |
13 | [TestCase]
14 | public void TestSizes()
15 | {
16 | using World world = new World();
17 |
18 | RigidBody b0 = world.CreateRigidBody();
19 | RigidBody b1 = world.CreateRigidBody();
20 |
21 | world.Remove(world.CreateConstraint(b0, b1));
22 | world.Remove(world.CreateConstraint(b0, b1));
23 | world.Remove(world.CreateConstraint(b0, b1));
24 | world.Remove(world.CreateConstraint(b0, b1));
25 | world.Remove(world.CreateConstraint(b0, b1));
26 | world.Remove(world.CreateConstraint(b0, b1));
27 | world.Remove(world.CreateConstraint(b0, b1));
28 | world.Remove(world.CreateConstraint(b0, b1));
29 | world.Remove(world.CreateConstraint(b0, b1));
30 | world.Remove(world.CreateConstraint(b0, b1));
31 | world.Remove(world.CreateConstraint(b0, b1));
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/src/JitterTests/JitterTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | all
17 | runtime; build; native; contentfiles; analyzers; buildtransitive
18 |
19 |
20 | all
21 | runtime; build; native; contentfiles; analyzers; buildtransitive
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | Precision.cs
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/JitterTests/MiscTests.cs:
--------------------------------------------------------------------------------
1 | using Jitter2.DataStructures;
2 |
3 | namespace JitterTests;
4 |
5 | public class MiscTests
6 | {
7 | [SetUp]
8 | public void Setup()
9 | {
10 | }
11 |
12 | [TestCase]
13 | public static void RequestId()
14 | {
15 | ulong id0 = World.RequestId();
16 | Assert.That(World.RequestId() == id0 + 1);
17 | Assert.That(World.RequestId(1) == (id0 + 2, id0 + 3));
18 | Assert.That(World.RequestId() == id0 + 3);
19 | Assert.That(World.RequestId(2) == (id0 + 4, id0 + 6));
20 | Assert.That(World.RequestId() == id0 + 6);
21 | Assert.That(World.RequestId(3) == (id0 + 7, id0 + 10));
22 | Assert.That(World.RequestId(3) == (id0 + 10, id0 + 13));
23 | }
24 | }
--------------------------------------------------------------------------------
/src/JitterTests/ParallelTests.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using Parallel = Jitter2.Parallelization.Parallel;
3 | using ReaderWriterLock = Jitter2.Parallelization.ReaderWriterLock;
4 | using ThreadPool = Jitter2.Parallelization.ThreadPool;
5 |
6 | namespace JitterTests;
7 |
8 | public class ParallelTests
9 | {
10 | private static volatile int current;
11 |
12 | [TestCase]
13 | public static void ReaderWriterLockTest()
14 | {
15 | ReaderWriterLock rwl = new();
16 |
17 | int[] test = new int[40];
18 | List tasks = new();
19 |
20 | // 4 readers
21 | for (int i = 0; i < 4; i++)
22 | {
23 | tasks.Add(Task.Run(() =>
24 | {
25 | Stopwatch sw = Stopwatch.StartNew();
26 | while (true)
27 | {
28 | if (sw.ElapsedMilliseconds > 1000) break;
29 | rwl.EnterReadLock();
30 | test[current]++;
31 | rwl.ExitReadLock();
32 | }
33 | }));
34 | }
35 |
36 | // 1 writer
37 | tasks.Add(Task.Run(() =>
38 | {
39 | Stopwatch sw = Stopwatch.StartNew();
40 | while (true)
41 | {
42 | if (sw.ElapsedMilliseconds > 1000) break;
43 | Thread.Sleep(10);
44 | rwl.EnterWriteLock();
45 | test[current] = 0;
46 | current = (current + 1) % test.Length;
47 | rwl.ExitWriteLock();
48 | }
49 | }));
50 |
51 | Task.WaitAll(tasks.ToArray());
52 | test[current] = 0;
53 |
54 | for (int i = 0; i < test.Length; i++)
55 | {
56 | Assert.That(test[i], Is.EqualTo(0));
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/src/JitterTests/ReproducibilityTest.cs:
--------------------------------------------------------------------------------
1 | using Jitter2.DataStructures;
2 |
3 | namespace JitterTests;
4 |
5 | public class ReproducibilityTest
6 | {
7 | [SetUp]
8 | public void Setup()
9 | {
10 | }
11 |
12 | [TestCase]
13 | public static void BasicReproducibilityTest()
14 | {
15 | var worldA = new World();
16 | worldA.SolverIterations = (2, 2);
17 | Helper.BuildSimpleStack(worldA);
18 | Helper.AdvanceWorld(worldA, 10, (Real)(1.0 / 100.0), false);
19 | worldA.Remove(worldA.RigidBodies.Last());
20 | Helper.BuildSimpleStack(worldA);
21 | Helper.AdvanceWorld(worldA, 10, (Real)(1.0 / 100.0), false);
22 | worldA.Clear();
23 | Helper.BuildSimpleStack(worldA);
24 | worldA.RigidBodies.Last().Velocity = new JVector(10);
25 | Helper.AdvanceWorld(worldA, 10, (Real)(1.0 / 100.0), false);
26 |
27 | var worldB = new World();
28 | worldB.SolverIterations = (2, 2);
29 | Helper.BuildSimpleStack(worldB);
30 | Helper.AdvanceWorld(worldB, 10, (Real)(1.0 / 100.0), false);
31 | worldB.Remove(worldB.RigidBodies.Last());
32 | Helper.BuildSimpleStack(worldB);
33 | Helper.AdvanceWorld(worldB, 10, (Real)(1.0 / 100.0), false);
34 | worldB.Clear();
35 | Helper.BuildSimpleStack(worldB);
36 | worldB.RigidBodies.Last().Velocity = new JVector(10);
37 | Helper.AdvanceWorld(worldB, 10, (Real)(1.0 / 100.0), false);
38 |
39 | var positionsA = worldA.RigidBodies.Select(body => body.Position);
40 | var positionsB = worldB.RigidBodies.Select(body => body.Position);
41 |
42 | Assert.That(positionsA.SequenceEqual(positionsB));
43 |
44 | worldA.Dispose();
45 | worldB.Dispose();
46 | }
47 | }
--------------------------------------------------------------------------------
/src/JitterTests/SequentialTests.cs:
--------------------------------------------------------------------------------
1 | using Jitter2.DataStructures;
2 |
3 | namespace JitterTests;
4 |
5 | public class SequentialTests
6 | {
7 | [SetUp]
8 | public void Setup()
9 | {
10 | }
11 |
12 | public class Number : IPartitionedSetIndex
13 | {
14 | public int SetIndex { get; set; }
15 | public int Value;
16 |
17 | public Number(int num)
18 | {
19 | SetIndex = -1;
20 | Value = num;
21 | }
22 | }
23 |
24 | [TestCase]
25 | public static void AddRemoveTest()
26 | {
27 | var num1 = new Number(1);
28 | var num2 = new Number(2);
29 | var num3 = new Number(3);
30 | var num4 = new Number(4);
31 | var num5 = new Number(5);
32 |
33 | PartitionedSet ts = new();
34 |
35 | Assert.That(ts.Count, Is.EqualTo(0));
36 | Assert.That(ts.ActiveCount, Is.EqualTo(0));
37 |
38 | ts.Add(num5);
39 |
40 | Assert.That(ts.Count, Is.EqualTo(1));
41 | Assert.That(ts.ActiveCount, Is.EqualTo(0));
42 |
43 | ts.MoveToInactive(num5);
44 |
45 | Assert.That(ts.Count, Is.EqualTo(1));
46 | Assert.That(ts.ActiveCount, Is.EqualTo(0));
47 |
48 | ts.MoveToActive(num5);
49 |
50 | Assert.That(ts.Count, Is.EqualTo(1));
51 | Assert.That(ts.ActiveCount, Is.EqualTo(1));
52 |
53 | ts.Remove(num5);
54 |
55 | Assert.That(ts.Count, Is.EqualTo(0));
56 | Assert.That(ts.ActiveCount, Is.EqualTo(0));
57 |
58 | ts.Add(num5, true);
59 |
60 | Assert.That(ts.Count, Is.EqualTo(1));
61 | Assert.That(ts.ActiveCount, Is.EqualTo(1));
62 |
63 | ts.Add(num1);
64 | ts.Add(num2);
65 | ts.Add(num3);
66 | ts.Add(num4);
67 |
68 | Assert.That(ts.Count, Is.EqualTo(5));
69 | Assert.That(ts.ActiveCount, Is.EqualTo(1));
70 |
71 | ts.MoveToActive(num2);
72 | ts.MoveToActive(num1);
73 | ts.MoveToActive(num4);
74 | ts.Remove(num4);
75 | ts.MoveToInactive(num5);
76 |
77 | Assert.That(ts.Count, Is.EqualTo(4));
78 | Assert.That(ts.ActiveCount, Is.EqualTo(2));
79 |
80 | List elements = new();
81 | for (int i = 0; i < ts.ActiveCount; i++)
82 | {
83 | elements.Add(ts[i]);
84 | }
85 |
86 | Assert.That(elements, Does.Contain(num1));
87 | Assert.That(elements, Does.Contain(num2));
88 | }
89 | }
--------------------------------------------------------------------------------
/src/JitterTests/StackingTests.cs:
--------------------------------------------------------------------------------
1 | namespace JitterTests;
2 |
3 | public class StackingTests
4 | {
5 | private World world = null!;
6 |
7 | [SetUp]
8 | public void Setup()
9 | {
10 | world = new World()
11 | {
12 | AllowDeactivation = false
13 | };
14 | }
15 |
16 | [TearDown]
17 | public void TearDown()
18 | {
19 | world.Dispose();
20 | }
21 |
22 | [TestCase]
23 | public void SimpleStack()
24 | {
25 | world.SolverIterations = (4, 4);
26 |
27 | RigidBody last = Helper.BuildSimpleStack(world);
28 |
29 |
30 | Real stackHeight = last.Position.Y;
31 | Helper.AdvanceWorld(world, 10, (Real)(1.0 / 100.0), true);
32 | Real delta = MathR.Abs(stackHeight - last.Position.Y);
33 |
34 | Assert.That(delta, Is.LessThan(1));
35 | }
36 |
37 | [TestCase(0, 0, 0, true)]
38 | [TestCase(0, 0, 0, false)]
39 | [TestCase(1, 0, 0, true)]
40 | public void PyramidStack(int x, int y, int z, bool multiThread)
41 | {
42 | world.SolverIterations = (4, 4);
43 |
44 | RigidBody last = Helper.BuildPyramidBox(world, new JVector(x, y, z));
45 |
46 | Real stackHeight = last.Position.Y;
47 | Helper.AdvanceWorld(world, 10, (Real)(1.0 / 100.0), multiThread);
48 | Real delta = MathR.Abs(stackHeight - last.Position.Y);
49 |
50 | Assert.That(delta, Is.LessThan(1f));
51 | }
52 |
53 | [TestCase(0, 0, 0, true)]
54 | [TestCase(0, 0, 0, false)]
55 | [TestCase(0, 0, 0, true)]
56 | [TestCase(1000, 1000, 1000, true)]
57 | public void PyramidStackCylinder(int x, int y, int z, bool multiThread)
58 | {
59 | world.SolverIterations = (4, 4);
60 |
61 | RigidBody last = Helper.BuildPyramidCylinder(world, new JVector(x, y, z));
62 |
63 | Real stackHeight = last.Position.Y;
64 | Helper.AdvanceWorld(world, 10, (Real)(1.0 / 100.0), multiThread);
65 | Real delta = MathR.Abs(stackHeight - last.Position.Y);
66 |
67 | Assert.That(delta, Is.LessThan(1f));
68 | }
69 |
70 | [TestCase(true)]
71 | [TestCase(true)]
72 | public void TowerStack(bool multiThread)
73 | {
74 | world.SolverIterations = (14, 4);
75 |
76 | RigidBody last = Helper.BuildTower(world, JVector.Zero, 30);
77 |
78 | Real stackHeight = last.Position.Y;
79 | Helper.AdvanceWorld(world, 10, (Real)(1.0 / 100.0), multiThread);
80 | Real delta = MathR.Abs(stackHeight - last.Position.Y);
81 |
82 | Assert.That(delta, Is.LessThan(1f));
83 | }
84 | }
--------------------------------------------------------------------------------
/src/JitterTests/Usings.cs:
--------------------------------------------------------------------------------
1 | global using NUnit.Framework;
2 | global using Jitter2;
3 | global using Jitter2.Collision;
4 | global using Jitter2.Dynamics;
5 | global using Jitter2.LinearMath;
6 | global using Jitter2.Parallelization;
7 | global using Jitter2.Unmanaged;
8 | global using Jitter2.Collision.Shapes;
--------------------------------------------------------------------------------
/tools/CoACD/README:
--------------------------------------------------------------------------------
1 | Using CoACD to get a convex decomposition of the Utah teapot.
2 |
--------------------------------------------------------------------------------
/tools/CoACD/run.sh:
--------------------------------------------------------------------------------
1 | ./run.py -i teapot.obj -o teapot_hull.obj -t 0.06 -pr 60
2 |
3 | # further simplify in blender using decimate modifier and create convehex hulls.
4 |
--------------------------------------------------------------------------------
/tools/ImGui.NET/CodeGenerator/CSharpCodeWriter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 |
6 | namespace CodeGenerator
7 | {
8 | class CSharpCodeWriter : IDisposable
9 | {
10 | private readonly StreamWriter _sw;
11 | private int _indentLevel = 0;
12 |
13 | public CSharpCodeWriter(string outputPath)
14 | {
15 | _sw = File.CreateText(outputPath);
16 | }
17 |
18 | public void Using(string ns)
19 | {
20 | WriteIndented($"using {ns};");
21 | }
22 |
23 | public void PushBlock(string blockHeader)
24 | {
25 | WriteIndented(blockHeader);
26 | WriteIndented("{");
27 | _indentLevel += 4;
28 | }
29 |
30 | public void PopBlock()
31 | {
32 | _indentLevel -= 4;
33 | WriteIndented("}");
34 | }
35 |
36 | public void WriteLine(string text)
37 | {
38 | WriteIndented(text);
39 | }
40 |
41 | public void WriteLine()
42 | {
43 | _sw.WriteLine();
44 | }
45 |
46 | private void WriteIndented(string text)
47 | {
48 | for (int i = 0; i < _indentLevel; i++)
49 | {
50 | _sw.Write(' ');
51 | }
52 | _sw.WriteLine(text);
53 | }
54 |
55 | public void Dispose()
56 | {
57 | _sw.Dispose();
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/tools/ImGui.NET/CodeGenerator/CodeGenerator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 |
7 |
8 |
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/tools/ImGui.NET/CodeGenerator/definitions/cimgui/variants.json:
--------------------------------------------------------------------------------
1 | {
2 | "ImFontAtlas_GetTexDataAsAlpha8": [
3 | {
4 | "name": "out_pixels",
5 | "type": "unsigned char**",
6 | "variants": [ "IntPtr*" ]
7 | }
8 | ],
9 | "ImFontAtlas_GetTexDataAsRGBA32": [
10 | {
11 | "name": "out_pixels",
12 | "type": "unsigned char**",
13 | "variants": [ "IntPtr*" ]
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/tools/ImGui.NET/CodeGenerator/definitions/cimguizmo/structs_and_enums.json:
--------------------------------------------------------------------------------
1 | {
2 | "enums": {
3 | "MODE": [
4 | {
5 | "calc_value": 0,
6 | "name": "LOCAL",
7 | "value": "0"
8 | },
9 | {
10 | "calc_value": 1,
11 | "name": "WORLD",
12 | "value": "1"
13 | }
14 | ],
15 | "OPERATION": [
16 | {
17 | "calc_value": 1,
18 | "name": "TRANSLATE_X",
19 | "value": "(1u << 0)"
20 | },
21 | {
22 | "calc_value": 2,
23 | "name": "TRANSLATE_Y",
24 | "value": "(1u << 1)"
25 | },
26 | {
27 | "calc_value": 4,
28 | "name": "TRANSLATE_Z",
29 | "value": "(1u << 2)"
30 | },
31 | {
32 | "calc_value": 8,
33 | "name": "ROTATE_X",
34 | "value": "(1u << 3)"
35 | },
36 | {
37 | "calc_value": 16,
38 | "name": "ROTATE_Y",
39 | "value": "(1u << 4)"
40 | },
41 | {
42 | "calc_value": 32,
43 | "name": "ROTATE_Z",
44 | "value": "(1u << 5)"
45 | },
46 | {
47 | "calc_value": 64,
48 | "name": "ROTATE_SCREEN",
49 | "value": "(1u << 6)"
50 | },
51 | {
52 | "calc_value": 128,
53 | "name": "SCALE_X",
54 | "value": "(1u << 7)"
55 | },
56 | {
57 | "calc_value": 256,
58 | "name": "SCALE_Y",
59 | "value": "(1u << 8)"
60 | },
61 | {
62 | "calc_value": 512,
63 | "name": "SCALE_Z",
64 | "value": "(1u << 9)"
65 | },
66 | {
67 | "calc_value": 1024,
68 | "name": "BOUNDS",
69 | "value": "(1u << 10)"
70 | },
71 | {
72 | "calc_value": 7,
73 | "name": "TRANSLATE",
74 | "value": "TRANSLATE_X | TRANSLATE_Y | TRANSLATE_Z"
75 | },
76 | {
77 | "calc_value": 120,
78 | "name": "ROTATE",
79 | "value": "ROTATE_X | ROTATE_Y | ROTATE_Z | ROTATE_SCREEN"
80 | },
81 | {
82 | "calc_value": 896,
83 | "name": "SCALE",
84 | "value": "SCALE_X | SCALE_Y | SCALE_Z"
85 | }
86 | ]
87 | },
88 | "enumtypes": [],
89 | "locations": {
90 | "MODE": "ImGuizmo:189",
91 | "OPERATION": "ImGuizmo:166"
92 | },
93 | "structs": []
94 | }
--------------------------------------------------------------------------------
/tools/ImGui.NET/CodeGenerator/definitions/cimguizmo/variants.json:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/tools/ImGui.NET/CodeGenerator/definitions/cimnodes/variants.json:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/tools/ImGui.NET/CodeGenerator/definitions/cimplot/variants.json:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/tools/ImGui.NET/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 Eric Mellino and ImGui.NET contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/tools/ImGui.NET/README:
--------------------------------------------------------------------------------
1 | JitterDemo is using a slightly modified version of the ImGUI.NET
2 | source code generator to generate a native wrapper for cimgui.
3 |
4 | Derived from
5 |
6 | commit 7cea5ef042aa7302346340653f6cf5de55dd87ec
7 | (HEAD -> master, tag: v1.89.4, origin/master, origin/HEAD)
8 |
--------------------------------------------------------------------------------
/tools/ImGui.NET/cimgui/mingw-w64-x86_64.cmake:
--------------------------------------------------------------------------------
1 | # Derived from
2 | # https://gist.github.com/peterspackman/8cf73f7f12ba270aa8192d6911972fe8
3 | #
4 | # Sample toolchain file for building for Windows from an Ubuntu Linux system.
5 | #
6 | # Typical usage:
7 | # *) install cross compiler: `sudo apt-get install mingw-w64`
8 | # *) cd build
9 | # *) cmake -DCMAKE_TOOLCHAIN_FILE=~/mingw-w64-x86_64.cmake ..
10 | # This is free and unencumbered software released into the public domain.
11 |
12 | # cimgui
13 | # git clone --recursive https://github.com/cimgui/cimgui.git
14 | # cd cimgui
15 | # mkdir build; cd build
16 | # cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=~/mingw-w64-x86_64.cmake ..
17 | # cmake --build .
18 |
19 | set(CMAKE_SYSTEM_NAME Windows)
20 | set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) # 64bit
21 | # set(TOOLCHAIN_PREFIX i686-w64-mingw32) # 32bit
22 |
23 | #set(TOOLCHAIN_SUFFIX "-win32")
24 |
25 | # cross compilers to use for C, C++ and Fortran
26 | set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
27 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
28 | set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran${TOOLCHAIN_SUFFIX})
29 | set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres${TOOLCHAIN_SUFFIX})
30 |
31 | # target environment on the build host system
32 | set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
33 |
34 | # modify default behavior of FIND_XXX() commands
35 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
36 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
37 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
38 |
39 | #set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lwsock32 -lws2_32 ${CMAKE_CXX_STANDARD_LIBRARIES}")
40 | #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
41 | #set(CMAKE_C_FLAGS "-static ${CMAKE_C_FLAGS}")
42 |
43 | # otherwise we get nasty dependencies
44 | set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++")
45 |
46 |
--------------------------------------------------------------------------------