rngine 0.11.4 → 0.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,8 @@ interface Circle {
18
18
  interface Shaped {
19
19
  /** Shape of the entity. */
20
20
  shape: Rect | Circle;
21
+ /** Rotation angle in radians. */
22
+ angle?: number;
21
23
  /** Indicates whether the entity is a sensor. Sensors trigger collision events but don't react physically. */
22
24
  isSensor?: boolean;
23
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,UAAU,UAAU;IAClB,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,UAAU,IAAI;IACZ,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,MAAM;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,MAAM;IACd,2BAA2B;IAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,CAAC;IACrB,6GAA6G;IAC7G,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtE,UAAU,UAAU;IAClB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,KAAK,CAAC,EAAE,OAA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AC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,6CAA6C;IAC7C,KAAK,EAAE,KAAK,CAAC;IACb,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,8GAA8G;IAC9G,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wDAAwD;IACxD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC"}
@@ -56,6 +56,7 @@ namespace margelo::nitro::rngine {
56
56
  double px SWIFT_PRIVATE;
57
57
  double py SWIFT_PRIVATE;
58
58
  std::variant<Rect, Circle> shape SWIFT_PRIVATE;
59
+ std::optional<double> angle SWIFT_PRIVATE;
59
60
  std::optional<bool> isSensor SWIFT_PRIVATE;
60
61
  std::optional<std::string> color SWIFT_PRIVATE;
61
62
  std::optional<double> asset SWIFT_PRIVATE;
@@ -75,7 +76,7 @@ namespace margelo::nitro::rngine {
75
76
 
76
77
  public:
77
78
  Entity() = default;
78
- explicit Entity(std::string id, double px, double py, std::variant<Rect, Circle> shape, std::optional<bool> isSensor, std::optional<std::string> color, std::optional<double> asset, std::optional<bool> flipH, std::optional<bool> flipV, std::optional<ObjectFit> objectFit, std::optional<bool> clip, std::optional<Repeat> repeat, std::optional<double> progress, std::optional<double> speed, std::optional<bool> loop, std::optional<double> vx, std::optional<double> vy, std::optional<double> ax, std::optional<double> ay, std::optional<double> mass): id(id), px(px), py(py), shape(shape), isSensor(isSensor), color(color), asset(asset), flipH(flipH), flipV(flipV), objectFit(objectFit), clip(clip), repeat(repeat), progress(progress), speed(speed), loop(loop), vx(vx), vy(vy), ax(ax), ay(ay), mass(mass) {}
79
+ explicit Entity(std::string id, double px, double py, std::variant<Rect, Circle> shape, std::optional<double> angle, std::optional<bool> isSensor, std::optional<std::string> color, std::optional<double> asset, std::optional<bool> flipH, std::optional<bool> flipV, std::optional<ObjectFit> objectFit, std::optional<bool> clip, std::optional<Repeat> repeat, std::optional<double> progress, std::optional<double> speed, std::optional<bool> loop, std::optional<double> vx, std::optional<double> vy, std::optional<double> ax, std::optional<double> ay, std::optional<double> mass): id(id), px(px), py(py), shape(shape), angle(angle), isSensor(isSensor), color(color), asset(asset), flipH(flipH), flipV(flipV), objectFit(objectFit), clip(clip), repeat(repeat), progress(progress), speed(speed), loop(loop), vx(vx), vy(vy), ax(ax), ay(ay), mass(mass) {}
79
80
 
80
81
  public:
81
82
  friend bool operator==(const Entity& lhs, const Entity& rhs) = default;
@@ -95,6 +96,7 @@ namespace margelo::nitro {
95
96
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "px"))),
96
97
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "py"))),
97
98
  JSIConverter<std::variant<margelo::nitro::rngine::Rect, margelo::nitro::rngine::Circle>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "shape"))),
99
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "angle"))),
98
100
  JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSensor"))),
99
101
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color"))),
100
102
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset"))),
@@ -119,6 +121,7 @@ namespace margelo::nitro {
119
121
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "px"), JSIConverter<double>::toJSI(runtime, arg.px));
120
122
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "py"), JSIConverter<double>::toJSI(runtime, arg.py));
121
123
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "shape"), JSIConverter<std::variant<margelo::nitro::rngine::Rect, margelo::nitro::rngine::Circle>>::toJSI(runtime, arg.shape));
124
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "angle"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.angle));
122
125
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "isSensor"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isSensor));
123
126
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "color"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.color));
124
127
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "asset"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.asset));
@@ -149,6 +152,7 @@ namespace margelo::nitro {
149
152
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "px")))) return false;
150
153
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "py")))) return false;
151
154
  if (!JSIConverter<std::variant<margelo::nitro::rngine::Rect, margelo::nitro::rngine::Circle>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "shape")))) return false;
155
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "angle")))) return false;
152
156
  if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSensor")))) return false;
153
157
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color")))) return false;
154
158
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset")))) return false;
@@ -56,6 +56,7 @@ namespace margelo::nitro::rngine {
56
56
  std::optional<double> px SWIFT_PRIVATE;
57
57
  std::optional<double> py SWIFT_PRIVATE;
58
58
  std::optional<std::variant<Rect, Circle>> shape SWIFT_PRIVATE;
59
+ std::optional<double> angle SWIFT_PRIVATE;
59
60
  std::optional<bool> isSensor SWIFT_PRIVATE;
60
61
  std::optional<std::string> color SWIFT_PRIVATE;
61
62
  std::optional<double> asset SWIFT_PRIVATE;
@@ -75,7 +76,7 @@ namespace margelo::nitro::rngine {
75
76
 
76
77
  public:
77
78
  EntityUpdate() = default;
78
- explicit EntityUpdate(std::string id, std::optional<double> px, std::optional<double> py, std::optional<std::variant<Rect, Circle>> shape, std::optional<bool> isSensor, std::optional<std::string> color, std::optional<double> asset, std::optional<bool> flipH, std::optional<bool> flipV, std::optional<ObjectFit> objectFit, std::optional<bool> clip, std::optional<Repeat> repeat, std::optional<double> progress, std::optional<double> speed, std::optional<bool> loop, std::optional<double> vx, std::optional<double> vy, std::optional<double> ax, std::optional<double> ay, std::optional<double> mass): id(id), px(px), py(py), shape(shape), isSensor(isSensor), color(color), asset(asset), flipH(flipH), flipV(flipV), objectFit(objectFit), clip(clip), repeat(repeat), progress(progress), speed(speed), loop(loop), vx(vx), vy(vy), ax(ax), ay(ay), mass(mass) {}
79
+ explicit EntityUpdate(std::string id, std::optional<double> px, std::optional<double> py, std::optional<std::variant<Rect, Circle>> shape, std::optional<double> angle, std::optional<bool> isSensor, std::optional<std::string> color, std::optional<double> asset, std::optional<bool> flipH, std::optional<bool> flipV, std::optional<ObjectFit> objectFit, std::optional<bool> clip, std::optional<Repeat> repeat, std::optional<double> progress, std::optional<double> speed, std::optional<bool> loop, std::optional<double> vx, std::optional<double> vy, std::optional<double> ax, std::optional<double> ay, std::optional<double> mass): id(id), px(px), py(py), shape(shape), angle(angle), isSensor(isSensor), color(color), asset(asset), flipH(flipH), flipV(flipV), objectFit(objectFit), clip(clip), repeat(repeat), progress(progress), speed(speed), loop(loop), vx(vx), vy(vy), ax(ax), ay(ay), mass(mass) {}
79
80
 
80
81
  public:
81
82
  friend bool operator==(const EntityUpdate& lhs, const EntityUpdate& rhs) = default;
@@ -95,6 +96,7 @@ namespace margelo::nitro {
95
96
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "px"))),
96
97
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "py"))),
97
98
  JSIConverter<std::optional<std::variant<margelo::nitro::rngine::Rect, margelo::nitro::rngine::Circle>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "shape"))),
99
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "angle"))),
98
100
  JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSensor"))),
99
101
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color"))),
100
102
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset"))),
@@ -119,6 +121,7 @@ namespace margelo::nitro {
119
121
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "px"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.px));
120
122
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "py"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.py));
121
123
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "shape"), JSIConverter<std::optional<std::variant<margelo::nitro::rngine::Rect, margelo::nitro::rngine::Circle>>>::toJSI(runtime, arg.shape));
124
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "angle"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.angle));
122
125
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "isSensor"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isSensor));
123
126
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "color"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.color));
124
127
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "asset"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.asset));
@@ -149,6 +152,7 @@ namespace margelo::nitro {
149
152
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "px")))) return false;
150
153
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "py")))) return false;
151
154
  if (!JSIConverter<std::optional<std::variant<margelo::nitro::rngine::Rect, margelo::nitro::rngine::Circle>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "shape")))) return false;
155
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "angle")))) return false;
152
156
  if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSensor")))) return false;
153
157
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color")))) return false;
154
158
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset")))) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rngine",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
4
4
  "description": "React Native 2D game engine powered by Nitro Modules",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -130,6 +130,7 @@ void GameMethods::updateEntities(
130
130
  patch(entityUpdate.px, entity->px);
131
131
  patch(entityUpdate.py, entity->py);
132
132
  patch(entityUpdate.shape, entity->shape);
133
+ patch(entityUpdate.angle, entity->angle);
133
134
  patch(entityUpdate.isSensor, entity->isSensor);
134
135
  patch(entityUpdate.asset, entity->asset);
135
136
  patch(entityUpdate.progress, entity->progress);
@@ -8,6 +8,9 @@
8
8
  #include <android/native_window.h>
9
9
 
10
10
  #include "Repeat.hpp"
11
+
12
+ #include <numbers>
13
+
11
14
  #include "include/core/SkCanvas.h"
12
15
  #include "include/core/SkColor.h"
13
16
  #include "include/core/SkColorSpace.h"
@@ -178,7 +181,7 @@ void GameRenderer::render(const Screen &screen,
178
181
  canvas->translate(gameBounds.left(), gameBounds.top());
179
182
  AssetUtils::drawAsset(
180
183
  canvas, screen.asset.value(), virtualWidth, virtualHeight,
181
- screen.flipH.value_or(false), screen.flipV.value_or(false),
184
+ screen.flipH.value_or(false), screen.flipV.value_or(false), 0.0,
182
185
  screen.objectFit.value_or(ObjectFit::FILL), screen.clip.value_or(false),
183
186
  screen.repeat.value_or(Repeat::NO_REPEAT),
184
187
  screen.progress.value_or(0.0));
@@ -206,7 +209,17 @@ void GameRenderer::render(const Screen &screen,
206
209
  if constexpr (std::is_same_v<T, Rect>) {
207
210
  float width = static_cast<float>(shape.width);
208
211
  float height = static_cast<float>(shape.height);
209
- SkRect rect = SkRect::MakeXYWH(px - width / 2, py - height / 2,
212
+
213
+ SkAutoCanvasRestore shapeRestore(canvas, true);
214
+
215
+ canvas->translate(px, py);
216
+
217
+ if (entity.angle.value_or(0.0) != 0.0) {
218
+ canvas->rotate(static_cast<float>(
219
+ entity.angle.value_or(0.0) * (180.0 / std::numbers::pi)));
220
+ }
221
+
222
+ SkRect rect = SkRect::MakeXYWH(-width / 2.0f, -height / 2.0f,
210
223
  width, height);
211
224
  canvas->drawRect(rect, paint);
212
225
  } else {
@@ -239,6 +252,7 @@ void GameRenderer::render(const Screen &screen,
239
252
  AssetUtils::drawAsset(canvas, entity.asset.value(), width, height,
240
253
  entity.flipH.value_or(false),
241
254
  entity.flipV.value_or(false),
255
+ entity.angle.value_or(0.0),
242
256
  entity.objectFit.value_or(ObjectFit::FILL),
243
257
  entity.clip.value_or(false),
244
258
  entity.repeat.value_or(Repeat::NO_REPEAT),
@@ -2,6 +2,7 @@
2
2
  #include "FitTransform.hpp"
3
3
  #include "GameRenderer.hpp"
4
4
  #include "include/core/SkPictureRecorder.h"
5
+ #include <numbers>
5
6
  #include <variant>
6
7
 
7
8
  namespace margelo::nitro::rngine::AssetUtils {
@@ -264,17 +265,25 @@ static void drawLottie(SkCanvas *canvas,
264
265
  }
265
266
 
266
267
  void drawAsset(SkCanvas *canvas, double asset, float targetWidth,
267
- float targetHeight, bool flipH, bool flipV, ObjectFit objectFit,
268
- bool clip, Repeat repeat, double progress) {
268
+ float targetHeight, bool flipH, bool flipV, double angle,
269
+ ObjectFit objectFit, bool clip, Repeat repeat, double progress) {
269
270
  if (asset == 0) {
270
271
  return;
271
272
  }
272
273
 
273
274
  SkAutoCanvasRestore restoreGuard(canvas, true);
274
275
 
275
- if (flipH || flipV) {
276
+ if (flipH || flipV || angle != 0.0) {
276
277
  canvas->translate(targetWidth * 0.5f, targetHeight * 0.5f);
277
- canvas->scale(flipH ? -1.0f : 1.0f, flipV ? -1.0f : 1.0f);
278
+
279
+ if (angle != 0.0) {
280
+ canvas->rotate(static_cast<float>(angle * (180.0 / std::numbers::pi)));
281
+ }
282
+
283
+ if (flipH || flipV) {
284
+ canvas->scale(flipH ? -1.0f : 1.0f, flipV ? -1.0f : 1.0f);
285
+ }
286
+
278
287
  canvas->translate(-targetWidth * 0.5f, -targetHeight * 0.5f);
279
288
  }
280
289
 
@@ -6,8 +6,8 @@
6
6
 
7
7
  namespace margelo::nitro::rngine::AssetUtils {
8
8
  void drawAsset(SkCanvas *canvas, double asset, float targetWidth,
9
- float targetHeight, bool flipH, bool flipV, ObjectFit objectFit,
10
- bool clip, Repeat repeat, double progress);
9
+ float targetHeight, bool flipH, bool flipV, double angle,
10
+ ObjectFit objectFit, bool clip, Repeat repeat, double progress);
11
11
  void updateProgress(std::optional<double> &progress,
12
12
  const std::optional<double> &speed,
13
13
  const std::optional<bool> &loop, const double asset,
@@ -5,30 +5,51 @@
5
5
 
6
6
  namespace margelo::nitro::rngine::CollisionUtils {
7
7
  static std::optional<Overlap> overlap(const Rect &a, double ax, double ay,
8
- const Rect &b, double bx, double by) {
8
+ double aa, const Rect &b, double bx,
9
+ double by, double ba) {
10
+ const double dx = bx - ax, dy = by - ay;
11
+ const double ahw = a.width / 2.0, ahh = a.height / 2.0;
12
+ const double bhw = b.width / 2.0, bhh = b.height / 2.0;
9
13
 
10
- double aLeft = ax - a.width / 2.0, aRight = ax + a.width / 2.0;
11
- double aTop = ay - a.height / 2.0, aBottom = ay + a.height / 2.0;
12
- double bLeft = bx - b.width / 2.0, bRight = bx + b.width / 2.0;
13
- double bTop = by - b.height / 2.0, bBottom = by + b.height / 2.0;
14
+ const double ac = std::cos(aa), as = std::sin(aa);
15
+ const double bc = std::cos(ba), bs = std::sin(ba);
14
16
 
15
- double overlapX = std::min(aRight, bRight) - std::max(aLeft, bLeft);
16
- double overlapY = std::min(aBottom, bBottom) - std::max(aTop, bTop);
17
+ const double aux = ac, auy = as, avx = -as, avy = ac;
18
+ const double bux = bc, buy = bs, bvx = -bs, bvy = bc;
17
19
 
18
- if (overlapX <= 0 || overlapY <= 0)
19
- return std::nullopt;
20
+ const double axes[4][2] = {{aux, auy}, {avx, avy}, {bux, buy}, {bvx, bvy}};
20
21
 
21
- if (overlapX < overlapY) {
22
- double nx = (bx >= ax) ? 1.0 : -1.0;
23
- return Overlap{overlapX, nx, 0.0};
24
- } else {
25
- double ny = (by >= ay) ? 1.0 : -1.0;
26
- return Overlap{overlapY, 0.0, ny};
22
+ double minDepth = std::numeric_limits<double>::infinity();
23
+ double bestNx = 0.0, bestNy = 0.0;
24
+
25
+ for (const auto &axis : axes) {
26
+ const double nx = axis[0], ny = axis[1];
27
+
28
+ const double ra = ahw * std::abs(nx * aux + ny * auy) +
29
+ ahh * std::abs(nx * avx + ny * avy);
30
+ const double rb = bhw * std::abs(nx * bux + ny * buy) +
31
+ bhh * std::abs(nx * bvx + ny * bvy);
32
+
33
+ const double dist = dx * nx + dy * ny;
34
+ const double depth = ra + rb - std::abs(dist);
35
+
36
+ if (depth <= 0)
37
+ return std::nullopt;
38
+
39
+ if (depth < minDepth) {
40
+ minDepth = depth;
41
+ const double sign = (dist >= 0) ? 1.0 : -1.0;
42
+ bestNx = nx * sign;
43
+ bestNy = ny * sign;
44
+ }
27
45
  }
46
+
47
+ return Overlap{minDepth, bestNx, bestNy};
28
48
  }
29
49
 
30
50
  static std::optional<Overlap> overlap(const Circle &a, double ax, double ay,
31
- const Circle &b, double bx, double by) {
51
+ double aa, const Circle &b, double bx,
52
+ double by, double ba) {
32
53
  double dx = bx - ax, dy = by - ay;
33
54
  double dist = std::sqrt(dx * dx + dy * dy);
34
55
  double depth = (a.radius + b.radius) - dist;
@@ -43,34 +64,53 @@ static std::optional<Overlap> overlap(const Circle &a, double ax, double ay,
43
64
  }
44
65
 
45
66
  static std::optional<Overlap> overlap(const Rect &a, double ax, double ay,
46
- const Circle &b, double bx, double by) {
47
- double left = ax - a.width / 2.0, right = ax + a.width / 2.0;
48
- double top = ay - a.height / 2.0, bottom = ay + a.height / 2.0;
67
+ double aa, const Circle &b, double bx,
68
+ double by, double ba) {
69
+ const double hw = a.width / 2.0, hh = a.height / 2.0;
70
+ const double c = std::cos(aa), s = std::sin(aa);
49
71
 
50
- double closestX = std::clamp(bx, left, right);
51
- double closestY = std::clamp(by, top, bottom);
72
+ const double wx = bx - ax, wy = by - ay;
73
+ const double lx = wx * c + wy * s;
74
+ const double ly = -wx * s + wy * c;
52
75
 
53
- double dx = bx - closestX, dy = by - closestY;
54
- double distSq = dx * dx + dy * dy;
76
+ const double closestX = std::clamp(lx, -hw, hw);
77
+ const double closestY = std::clamp(ly, -hh, hh);
78
+ const double dx = lx - closestX, dy = ly - closestY;
79
+ const double distSq = dx * dx + dy * dy;
55
80
 
56
81
  if (distSq >= b.radius * b.radius)
57
82
  return std::nullopt;
58
83
 
84
+ double nlx, nly, depth;
85
+
59
86
  if (distSq == 0.0) {
60
- double cdx = bx - ax, cdy = by - ay;
61
- double cdist = std::sqrt(cdx * cdx + cdy * cdy);
62
- if (cdist == 0.0)
63
- return Overlap{b.radius, 0.0, -1.0};
64
- return Overlap{b.radius, cdx / cdist, cdy / cdist};
87
+ const double px = hw - std::abs(lx);
88
+ const double py = hh - std::abs(ly);
89
+ if (px < py) {
90
+ nlx = (lx >= 0) ? 1.0 : -1.0;
91
+ nly = 0.0;
92
+ depth = px + b.radius;
93
+ } else {
94
+ nlx = 0.0;
95
+ nly = (ly >= 0) ? 1.0 : -1.0;
96
+ depth = py + b.radius;
97
+ }
98
+ } else {
99
+ const double dist = std::sqrt(distSq);
100
+ nlx = dx / dist;
101
+ nly = dy / dist;
102
+ depth = b.radius - dist;
65
103
  }
66
104
 
67
- double dist = std::sqrt(distSq);
68
- return Overlap{b.radius - dist, dx / dist, dy / dist};
105
+ const double nx = nlx * c - nly * s;
106
+ const double ny = nlx * s + nly * c;
107
+ return Overlap{depth, nx, ny};
69
108
  }
70
109
 
71
110
  static std::optional<Overlap> overlap(const Circle &a, double ax, double ay,
72
- const Rect &b, double bx, double by) {
73
- auto result = overlap(b, bx, by, a, ax, ay);
111
+ double aa, const Rect &b, double bx,
112
+ double by, double ba) {
113
+ auto result = overlap(b, bx, by, ba, a, ax, ay, aa);
74
114
 
75
115
  if (!result.has_value()) {
76
116
  return std::nullopt;
@@ -88,8 +128,9 @@ std::optional<Collision> shapeOverlap(const Entity &entityA,
88
128
  [&](const auto &shapeA) -> std::optional<Overlap> {
89
129
  return std::visit(
90
130
  [&](const auto &shapeB) -> std::optional<Overlap> {
91
- return overlap(shapeA, entityA.px, entityA.py, shapeB, entityB.px,
92
- entityB.py);
131
+ return overlap(shapeA, entityA.px, entityA.py,
132
+ entityA.angle.value_or(0.0), shapeB, entityB.px,
133
+ entityB.py, entityB.angle.value_or(0.0));
93
134
  },
94
135
  entityB.shape);
95
136
  },
package/src/types.ts CHANGED
@@ -22,6 +22,8 @@ interface Circle {
22
22
  interface Shaped {
23
23
  /** Shape of the entity. */
24
24
  shape: Rect | Circle;
25
+ /** Rotation angle in radians. */
26
+ angle?: number;
25
27
  /** Indicates whether the entity is a sensor. Sensors trigger collision events but don't react physically. */
26
28
  isSensor?: boolean;
27
29
  }