Skip to content

Commit

Permalink
heaps math support
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinEast committed Sep 29, 2021
1 parent d7b0a4d commit 3f72e0a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
35 changes: 9 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,53 +117,36 @@ body.entity = new some.package.Entity();

Echo comes with basic implementations of common math structures (Vector2, Vector3, Matrix3), but also allows these structures to be extended and used seamlessly with other popular Haxe math libraries.

Support is currently available for [hxmath](https://github.com/tbrosman/hxmath), [vector-math](https://github.com/haxiomic/vector-math), and [zerolib](https://github.com/01010111/zerolib).
Support is currently available for the following libraries (activated by adding the listed compiler flag to your project's build parameters):

| Library | Compiler Flag |
| --- | --- |
| [hxmath](https://github.com/tbrosman/hxmath) | ECHO_USE_HXMATH |
| [vector-math](https://github.com/haxiomic/vector-math) | ECHO_USE_VECTORMATH |
| [zerolib](https://github.com/01010111/zerolib) | ECHO_USE_ZEROLIB |
| [heaps](https://heaps.io) | ECHO_USE_HEAPS |

(pull requests for other libraries happily accepted!)

If you compile your project with a standard `.hxml`, add one of these to your file:
If you compile your project with a standard `.hxml`:
```hxml
# hxmath support
-lib hxmath
-D ECHO_USE_HXMATH
# vector-math support
-lib vector-math
-D ECHO_USE_VECTORMATH
# zerolib support
-lib zerolib
-D ECHO_USE_ZEROLIB
```

For OpenFL users, add one of the following into your `Project.xml`:
```xml
<!-- hxmath support -->
<haxelib name="hxmath" />
<haxedef name="ECHO_USE_HXMATH" />

<!-- vector-math support -->
<haxelib name="vector-math" />
<haxedef name="ECHO_USE_VECTORMATH" />

<!-- zerolib support -->
<haxelib name="zerolib" />
<haxedef name="ECHO_USE_ZEROLIB" />
```

For Kha users, add one of the following into your `khafile.js`:
```js
// hxmath support
project.addLibrary('hxmath');
project.addDefine('ECHO_USE_HXMATH');

// vector-math support
project.addLibrary('vector-math');
project.addDefine('ECHO_USE_VECTORMATH');

// zerolib support
project.addLibrary('zerolib');
project.addDefine('ECHO_USE_ZEROLIB');
```

# Examples
Expand Down
4 changes: 4 additions & 0 deletions echo/math/Types.hx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ abstract Mat3Impl(Mat3) from Mat3 to Mat3 {
this = new Mat3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
}
}
#elseif ECHO_USE_HEAPS
typedef Vector2Type = h2d.col.Point;
typedef Vector3Type = h3d.col.Point;
typedef Matrix3Type = echo.math.Matrix3.Matrix3Default;
#else
typedef Vector2Type = echo.math.Vector2.Vector2Default;
typedef Vector3Type = echo.math.Vector3.Vector3Default;
Expand Down
2 changes: 2 additions & 0 deletions sample-hl.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# -lib vector-math
# -D ECHO_USE_VECTORMATH

# -D ECHO_USE_HEAPS

#flags
-dce full
-D windowSize=1280x720
Expand Down
2 changes: 2 additions & 0 deletions sample.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# -lib vector-math
# -D ECHO_USE_VECTORMATH

# -D ECHO_USE_HEAPS

# copy assets
--macro util.Assets.copyProjectAssets()

Expand Down
2 changes: 2 additions & 0 deletions test.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# -lib vector-math
# -D ECHO_USE_VECTORMATH

# -D ECHO_USE_HEAPS

--each

# output
Expand Down

0 comments on commit 3f72e0a

Please sign in to comment.