Skip to content

Commit

Permalink
Revert "Update docusaurus to 3.4 (#156)"
Browse files Browse the repository at this point in the history
This reverts commit e3c06e2.
  • Loading branch information
notgiven688 committed Jun 22, 2024
1 parent e3c06e2 commit 33c58ee
Show file tree
Hide file tree
Showing 17 changed files with 4,411 additions and 6,428 deletions.
2 changes: 1 addition & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

.odp#
.odp#
8 changes: 8 additions & 0 deletions docs/blog/2023.10-01-hello-world/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
slug: Hello World
title: Hello World
authors: [notgiven688]
tags: [general]
---

#### Hello World
5 changes: 5 additions & 0 deletions docs/blog/authors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
notgiven688:
name: notgiven688
# title:
url: https://github.com/notgiven688
# image_url:
6 changes: 3 additions & 3 deletions docs/docs/02_documentation/00unmanaged-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ These values specify the maximum number of entities that can exist in the world

- **numConstraints**: This parameter indicates the maximum number of **Constraints**. A constraint limits the positions or velocities of a pair of rigid bodies.

**RigidBodies**, **Arbiters**, and **Constraints** are regular C# classes that reside on the managed heap. However, these objects are linked to their unmanaged counterparts: **RigidBodyData**, **ContactData**, and **ConstraintData**. Memory management for these structures is facilitated by Jitter: An array of pointers is allocated (referred to as the index-list in the following), where each entry indicates the actual memory of the data structure. These data structures exist in a contiguous blob of allocated memory. The managed classes maintain pointers to the index-list. Whenever the memory position of a native data structure is altered, the index-list gets updated. *Jitter relocates the native structures in a manner that ensures active objects are housed in contiguous memory, enabling efficient access by the iterative solver*. The size of the index-list is dictated by the corresponding number specified in the constructor. For instance, with the default constructor, the index-list can hold 32768 pointers (256 KB on a 64-bit system). The continuous block of memory that hosts the native structures adapts to the actual number of rigid bodies in the simulation in a grow-only manner. Consequently, only 265 KB are initially earmarked for a maximum of 32768 bodies, scaling up to (256 KB + 32768 x \{size of RigidBodyData\}) of unmanaged memory usage if 32768 bodies are effectively integrated into the simulation.
**RigidBodies**, **Arbiters**, and **Constraints** are regular C# classes that reside on the managed heap. However, these objects are linked to their unmanaged counterparts: **RigidBodyData**, **ContactData**, and **ConstraintData**. Memory management for these structures is facilitated by Jitter: An array of pointers is allocated (referred to as the index-list in the following), where each entry indicates the actual memory of the data structure. These data structures exist in a contiguous blob of allocated memory. The managed classes maintain pointers to the index-list. Whenever the memory position of a native data structure is altered, the index-list gets updated. *Jitter relocates the native structures in a manner that ensures active objects are housed in contiguous memory, enabling efficient access by the iterative solver*. The size of the index-list is dictated by the corresponding number specified in the constructor. For instance, with the default constructor, the index-list can hold 32768 pointers (256 KB on a 64-bit system). The continuous block of memory that hosts the native structures adapts to the actual number of rigid bodies in the simulation in a grow-only manner. Consequently, only 265 KB are initially earmarked for a maximum of 32768 bodies, scaling up to (256 KB + 32768 x {size of RigidBodyData}) of unmanaged memory usage if 32768 bodies are effectively integrated into the simulation.

## Accessing Unmanaged Memory

:::danger Raw Memory Access
Accessing raw memory is generally not required when utilizing the standard functionalities of Jitter. Although reading the raw data of objects is generally safe, modifying data can corrupt the internal state of the engine.
:::
:::danger

`world.RawData` facilitates access to `Span`s into unmanaged contiguous memory. This data is also reachable via `body.Handle.Data`, `arbiter.Handle.Data`, and `constraint.Handle.Data`.
`world.RawData` facilitates access to `Span`s into unmanaged contiguous memory. This data is also reachable via `body.Handle.Data`, `arbiter.Handle.Data`, and `constraint.Handle.Data`.
6 changes: 3 additions & 3 deletions docs/docs/02_documentation/01world-entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ It is not valid to add the same instance of a shape to multiple bodies.

:::info Order of Initialization
When calling `body.AddShape(shape)`, the shape is registered in the collision system of the engine and added to the spatial tree structure (AABB-tree) for efficient broad-phase collision detection. Make sure to not accidentally register many objects at (0, 0, 0). This may happen by repeatedly calling `body.AddShape`, before specifying the positions of the associated rigid bodies.
:::
:::info

Constraints are another type of entities that can be explicitly added to the world using `world.CreateConstraint<T>(body1, body2)`, where T is a constraint. In the following example, two constraints (a HingeAngle and a BallSocket constraint) are added:

Expand All @@ -33,7 +33,7 @@ ballSocket.Initialize(hingeCenter);

:::caution Constraint Initialization
For all default constraints available in Jitter, `constraint.Initialize` must be called once after `world.CreateConstraint`.
:::
:::caution

### Accessing Entities

Expand Down Expand Up @@ -82,4 +82,4 @@ Removing a rigid body also removes all constraints and contacts in which the bod

:::caution Accessing Removed Entities
Instances of `RigidBody`, `Arbiter`, and `Constraint` store some of their data in unmanaged memory, which is automatically freed once the entities are removed from the world. Do not use these entities any longer, i.e., do not call functions or use their properties, otherwise, a NullReferenceException may be thrown.
:::
:::caution
6 changes: 3 additions & 3 deletions docs/docs/02_documentation/02simulation-step.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Call `world.Step(float dt, bool multiThread = true)` to simulate a time step of

:::info Units in Jitter
The unit system of Jitter is not explicitly defined. The engine utilizes 32-bit floating-point arithmetic and is optimized for objects with a size of 1 [len_unit]. For instance, the collision system uses length thresholds on the order of 1e-04 [len_unit]. It assumes a unit density of 1 [mass_unit/len_unit³] for the mass properties of shapes. Consequently, the default mass of a unit cube is 1 [mass_unit]. The default value for gravity in Jitter is $9.81$ [len_unit/time_unit²], which aligns with the gravitational acceleration on Earth in metric units (m/s²). Therefore, it is reasonable to use metric units (kg, m, s) when conceptualizing these values.
:::
:::info

### Step Size

To achieve accurate physical results, the time step (dt) should be as small as possible. However, to maintain interactive frame rates, it's not feasible to call `world.Step` too frequently. A suitable compromise, aligning with the engine's design, is to choose dt=1/100. The time step should not exceed 1/60 to prevent potential simulation instability.

:::info Time Step Size
Maintain a consistent time step size, if possible, to avoid instabilities introduced by fluctuating time steps.
:::
:::info

Suppose your game using Jitter operates at a varying frame rate of 80-160 fps. In this case, calling `world.Step(1.0f / 100.0f)` each frame might cause the simulated time to desynchronize from real time. You can implement a strategy to accumulate delta times (the discrepancy between the elapsed real time and the simulation step) and accordingly adjust the calls to `world.Step(1.0f / 100.0f)` based on the magnitude of the delta time.

Expand All @@ -33,7 +33,7 @@ This adjusts the number of worker threads to four. Jitter utilizes the thread po

:::info Thread Safety
Methods in Jitter are generally not thread-safe.
:::
:::info

### Substepping

Expand Down
72 changes: 14 additions & 58 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// @ts-check
// `@type` JSDoc annotations allow editor autocompletion and type checking
// (when paired with `@ts-check`).
// There are various equivalent ways to declare your Docusaurus config.
// See: https://docusaurus.io/docs/api/docusaurus-config
// Note: type annotations allow type checking and IDEs autocompletion

import {themes as prismThemes} from 'prism-react-renderer';
const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');

const math = require('remark-math');
const katex = require('rehype-katex');
Expand All @@ -29,9 +27,9 @@ const config = {
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',

// Even if you don't use internationalization, you can use this field to set
// useful metadata like html lang. For example, if your site is Chinese, you
// may want to replace "en" with "zh-Hans".
// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
Expand All @@ -45,7 +43,7 @@ const config = {
docs: {
remarkPlugins: [math],
rehypePlugins: [katex],
sidebarPath: './sidebars.js',
sidebarPath: require.resolve('./sidebars.js'),
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
Expand All @@ -61,19 +59,18 @@ const config = {
// 'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
},
theme: {
customCss: './src/css/custom.css',
customCss: require.resolve('./src/css/custom.css'),
},
}),
],
],

stylesheets: [
{
href: '/katex/katex.min.css',
type: 'text/css'
},
],

themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
Expand All @@ -90,9 +87,9 @@ const config = {
type: 'docSidebar',
sidebarId: 'tutorialSidebar',
position: 'left',
label: 'Documentation',
label: 'Tutorial',
},
//{to: '/blog', label: 'Blog', position: 'left'},
{to: '/blog', label: 'Blog', position: 'left'},
{
href: 'https://github.com/notgiven688/jitterphysics2',
label: 'GitHub',
Expand All @@ -102,55 +99,14 @@ const config = {
},
footer: {
style: 'dark',
// links: [
// {
// title: 'Docs',
// items: [
// {
// label: 'Tutorial',
// to: '/docs/intro',
// },
// ],
// },
// {
// title: 'Community',
// items: [
// {
// label: 'Stack Overflow',
// href: 'https://stackoverflow.com/questions/tagged/docusaurus',
// },
// {
// label: 'Discord',
// href: 'https://discordapp.com/invite/docusaurus',
// },
// {
// label: 'Twitter',
// href: 'https://twitter.com/docusaurus',
// },
// ],
// },
// {
// title: 'More',
// items: [
// {
// label: 'Blog',
// to: '/blog',
// },
// {
// label: 'GitHub',
// href: 'https://github.com/facebook/docusaurus',
// },
// ],
// },
// ],
copyright: `Copyright © ${new Date().getFullYear()} Jitter Physics Developers. Built with Docusaurus.`,
},
prism: {
additionalLanguages: ['csharp', ],
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
}),
};

export default config;
module.exports = config;
Binary file removed docs/impress/collision.odp
Binary file not shown.
Loading

0 comments on commit 33c58ee

Please sign in to comment.