1
 2
 3
 4
 5
 6
 7
 8
 9
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! # IMPORTANT:
//! This library is not meant to stay inside the amethyst project.
//!
//! Actually this is here only to make it more simple to develop.
//! The idea is to move this outside once it's almost done.

//! # NPhysics backend for `amethyst_physics`.
//! To use this backend you have to specify the `NPhysicsBackend` type in the `PhysicsBundle`.
//!
//! Follow the `amethyst_physics` instructions know more.
//!

// ## Naming
// Since NPhysics doesn't use any prefix to identify its structures this implementation take care
// to append the prefix `Np` to any struct that come from NPhysics.
// In this way is possible to have a clear distinction of what is what.
// Example: `RigidBody` and `NpRigidBody`.

#![warn(
    missing_debug_implementations,
    rust_2018_idioms,
    rust_2018_compatibility,
    clippy::all
)]

use area_physics_server::AreaNpServer;
use joint_physics_server::JointNpServer;
use rigid_body_physics_server::RBodyNpServer;
use shape_physics_server::ShapeNpServer;
use world_physics_server::WorldNpServer;

use amethyst_physics::{servers::PhysicsWorld, PtReal};

/// NPhysics backend can be specified as type of the PhysicsBundle to use NPhysics engine.
#[allow(missing_debug_implementations)]
pub struct NPhysicsBackend;

/// NPhysics Backend
impl<N> amethyst_physics::PhysicsBackend<N> for NPhysicsBackend
where
    N: PtReal,
{
    fn create_world() -> PhysicsWorld<N> {
        let storages = servers_storage::ServersStorage::new();

        PhysicsWorld::new(
            Box::new(WorldNpServer::new(storages.clone())),
            Box::new(RBodyNpServer::new(storages.clone())),
            Box::new(AreaNpServer::new(storages.clone())),
            Box::new(ShapeNpServer::new(storages.clone())),
            Box::new(JointNpServer::new(storages.clone())),
        )
    }
}

#[macro_use]
mod conditional_macros;
mod area_physics_server;
mod body;
mod body_storage;
mod collider_storage;
mod conversors;
mod force_generator;
mod force_generator_storage;
mod joint;
mod joint_physics_server;
mod joint_storage;
mod rigid_body_physics_server;
pub mod servers_storage;
mod shape;
mod shape_physics_server;
mod storage;
mod utils;
mod world_physics_server;