reflexion 0.1.47 → 0.1.48

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +5 -0
  3. data/VERSION +1 -1
  4. data/src/shape.cpp +62 -0
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbba01aa89b281514746d453c7fa419ce6549b575e4f104a10879590b36f7618
4
- data.tar.gz: 22e14f38d1e12250dbcbbef64e277d270199e9803a4f65d4843e97751d718f29
3
+ metadata.gz: f3d0609202b8620c5b7e5390dab43005bd7638529aaf8ea0b70e59f89590776e
4
+ data.tar.gz: 90739081a2547266e5393593524655eca4964e6d6c038655df675eac812a2622
5
5
  SHA512:
6
- metadata.gz: f47eedb2578dd14f8bb89921483de7a2a95c2b49a6f10946750f974bf8571ab2de4f9004646fae4548dce697fb443e35524b1bf97558051503d7d2e3f880ec80
7
- data.tar.gz: 5d22c08c4b141058bd1cadf70c0205a5e21873e6a73b3af635b8038a9bd68cae110a707737dbb7e0b38e1b5635d3f2e71047b0a257318890998a6d589bd66711
6
+ metadata.gz: 58cc9b938687a48640c9874ac9267fa9937012656350d378c55175a3b6cb229562535e48ffb4136c81927c32aca913c9c2ab55bc300e8ab11a78d7cb2d2dad44
7
+ data.tar.gz: 3fe06d4cbfcecd5c61caa472d6ab8598335cb78dcb19ae8a3b16f84c2392bd341313ba6ae67dbd0196804668e532a13f0a3d75ab657030d2be528efab2c773b5
data/ChangeLog.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # reflex ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.48] - 2023-07-10
5
+
6
+ - Fix a problem that a rectangle shape would be split into 2 triangles for physics
7
+
8
+
4
9
  ## [v0.1.47] - 2023-06-27
5
10
 
6
11
  - NONE -> TYPE_NONE
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.47
1
+ 0.1.48
data/src/shape.cpp CHANGED
@@ -793,6 +793,68 @@ namespace Reflex
793
793
 
794
794
  uint nsegment = 0;
795
795
 
796
+ Fixture* create_fixtures (Shape* shape) override
797
+ {
798
+ if (!has_rounds())
799
+ return create_rect_fixture(shape);
800
+ else if (nsegment <= 1)
801
+ return create_rect_fixture_without_division(shape);
802
+ else
803
+ return Super::create_fixtures(shape);
804
+ }
805
+
806
+ Fixture* create_rect_fixture (Shape* shape)
807
+ {
808
+ assert(shape);
809
+
810
+ if (!owner)
811
+ invalid_state_error(__FILE__, __LINE__);
812
+
813
+ Bounds f = get_frame();
814
+ float ppm = owner->meter2pixel();
815
+
816
+ coord l = to_b2coord(f.x, ppm);
817
+ coord t = to_b2coord(f.y, ppm);
818
+ coord r = to_b2coord(f.x + f.w, ppm);
819
+ coord b = to_b2coord(f.x + f.h, ppm);
820
+ b2Vec2 b2points[] = {{l, t}, {l, b}, {r, b}, {r, t}};
821
+
822
+ b2PolygonShape b2shape;
823
+ b2shape.Set(&b2points[0], 4);
824
+
825
+ return FixtureBuilder(shape, &b2shape).fixtures();
826
+ }
827
+
828
+ Fixture* create_rect_fixture_without_division (Shape* shape)
829
+ {
830
+ assert(shape);
831
+
832
+ if (!owner)
833
+ invalid_state_error(__FILE__, __LINE__);
834
+
835
+ Bounds f = get_frame();
836
+ float ppm = owner->meter2pixel();
837
+
838
+ Polygon polygon = Rays::create_rect(
839
+ f.x, f.y, f.width, f.height,
840
+ round_left_top, round_right_top,
841
+ round_left_bottom, round_right_bottom,
842
+ 1);
843
+ assert(polygon.size() == 1);
844
+
845
+ const Polyline& polyline = polygon[0];
846
+ assert(polyline[0].size() <= 8);
847
+
848
+ b2Vec2 b2points[8];
849
+ for (size_t i = 0; i < polyline.size(); ++i)
850
+ b2points[i] = to_b2vec2(polyline[i], ppm);
851
+
852
+ b2PolygonShape b2shape;
853
+ b2shape.Set(&b2points[0], polyline.size());
854
+
855
+ return FixtureBuilder(shape, &b2shape).fixtures();
856
+ }
857
+
796
858
  Polygon get_polygon_for_shape () const override
797
859
  {
798
860
  return Rays::create_rect(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reflexion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.47
4
+ version: 0.1.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-26 00:00:00.000000000 Z
11
+ date: 2023-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot