Metadata-Version: 2.1
Name: gimpact
Version: 1.0.1
Summary: An unofficial python extension for the GImpact collision library
Home-page: https://github.com/StephenNneji
Author: Stephen Nneji
Author-email: Stephen Nneji <steve.nneji@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2019, Stephen Nneji
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the copyright holder nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Keywords: GImpact,Trimesh,Collision detection,Cython
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Games/Entertainment :: Simulation
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Cython
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

GImpact-Python
==================
An unofficial python extension for the [GImpact collision library](http://gimpact.sourceforge.net/manual/gimpact_manual.html). This extension integrates directly with GImpact's C++ API using Cython.

Features
---------
* Create trimesh object from numpy array
* Mesh decimation using Sven Forstmann's C++ mesh simplification [code](https://github.com/sp4cerat/Fast-Quadric-Mesh-Simplification) 
* Axis Aligned Bounding Box (AABB)
* AABB set for box prunning
* Collision of triangle mesh with the following
    * triangle mesh
    * sphere
    * capsule
    * plane
    * ray
 * Supports "first contact" or "all contacts" modes

Build Wheel
-----------
``` shell
pip install -q build
python -m build
```


Installation
------------
Build requires numpy and cython (tested on Linux and Windows).
``` shell
pip install gimpact
```

Example Usage
-------------
AABB
```  python
import gimpact


aabb1 = gimpact.AABB(-1, 1, -1, 1, -1, 1)
aabb2 = gimpact.AABB(-1, 1, -1, 1, 1.5, 2)

print(aabb1.intersects(aabb2))
print(aabb1.intersection(aabb2))

aabb1.merge(aabb2)
print(aabb1)
```

Box Prunning
``` python
import gimpact

aabb_set = gimpact.AABBSet(10)
print(len(aabb_set))
print(aabb_set.global_bounds)
for aabb in aabb_set:
    aabb.bounds = (0., 0., 0., 0., 0., 0.)

for aabb in aabb_set:
    print(aabb)

print(aabb_set.global_bounds)
pairs = aabb_set.find_intersections(aabb_set)
print(pairs)

del aabb_set
print(aabb.bounds)
```

Collision
```  python
import gimpact
import numpy as np

contacts = gimpact.trimesh_trimesh_collision(trimesh1, trimesh2)
contacts = gimpact.trimesh_sphere_collision(trimesh1, [0., 0., 0.], 1, True)
contacts = gimpact.trimesh_capsule_collision(trimesh1, np.array([0., 0., 0.]), np.array([1., 0., 0.]), 1, True)
contacts = gimpact.trimesh_plane_collision(trimesh1, [0., 0., 1., 0.], True)
```
