• R/O
  • SSH
  • HTTPS

nlgp1: Commit


Commit MetaInfo

Revision752 (tree)
Zeit2011-02-22 14:11:49
Autormassa_senohito

Log Message

RigidBodyに潜むバグを潰した
SpriteBodyにfront等追加、bodyが512超えそうになるとbody生成をやめます(削除予定)

Ändern Zusammenfassung

Diff

--- trunk/Nlgp1/Nlgp1/Parameters/SpriteBody.cs (revision 751)
+++ trunk/Nlgp1/Nlgp1/Parameters/SpriteBody.cs (revision 752)
@@ -14,6 +14,7 @@
1414 public SpriteBody(Sprite sprite, IEnumerable<SpriteShape> shapes, Vec2 position)
1515 {
1616 this.position = position;
17+ if (GameMap.World.GetBodyCount() > 511) return;
1718
1819 switch (sprite.LayerType)
1920 {
@@ -20,15 +21,31 @@
2021 //キャラクターの場合、sprite.Shape.Width, sprite.Shape.Heightから値をとっている
2122 //myUserDataは決まっていない
2223 case Nlgp1.Common.LayerType.Character:
23- DynamicRigid chara = new DynamicRigid(position, 0, liniervelocity, angulervelocity);
24- chara.SetAsBox(sprite.Shape.Width, sprite.Shape.Height, new Polygondef2(friction, restitution, density, new myUserData()), false);
25- chara.MakeBody(GameMap.World);
24+ foreach (SpriteShape ss in shapes)
25+ {
26+ Vec2 lb = ss.AABB.UpperBound - ss.AABB.LowerBound;
27+ lb.X /= 2; lb.Y /= 2;
28+ DynamicRigid chara = new DynamicRigid(position, 0, liniervelocity, angulervelocity);
29+ chara.SetAsBox(lb.X, lb.Y, new Polygondef2(friction, restitution, density, new myUserData()), false);
30+ chara.MakeBody(GameMap.World);
31+ }
2632 break;
33+ case Nlgp1.Common.LayerType.Front:
34+ foreach (SpriteShape ss in shapes)
35+ {
36+ Vec2 lb = ss.AABB.UpperBound - ss.AABB.LowerBound;
37+ lb.X /= 2; lb.Y /= 2;
38+ StaticRigid chara = new StaticRigid(position, 0, 0, 0);
39+ chara.SetAsBox(lb.X, lb.Y, new Polygondef2(3,0,0, new myUserData()), false);
40+ chara.MakeBody(GameMap.World);
41+ }
42+ break;
2743 default:
2844 break;
2945 }
3046 }
3147 public void Act() {
48+
3249 }
3350
3451 public Vec2 Position {
--- trunk/Nlgp1/Nlgp1.Box2DX/RigidBody.cs (revision 751)
+++ trunk/Nlgp1/Nlgp1.Box2DX/RigidBody.cs (revision 752)
@@ -196,7 +196,7 @@
196196 {
197197 SelfBody.CreateShape(pd);
198198 });
199- if (!this.BodyKind.Equals("Static"))
199+ if (!this.BodyKind.Contains("Static"))
200200 {
201201 SelfBody.SetMassFromShapes();
202202 }
Show on old repository browser