2016-09-04 2 views
1
이 메시지와

내 게임 충돌에 가끔 충돌을 Box2D의libgdx는 createBody

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) 
j com.badlogic.gdx.physics.box2d.World.jniCreateBody(JIFFFFFFFFZZZZZF)J+0 
j com.badlogic.gdx.physics.box2d.World.createBody(Lcom/badlogic/gdx/physics/box2d/BodyDef;)Lcom/badlogic/gdx/physics/box2d/Body;+80 
j de.tennoxlab.cellolution.Food.<init>(Lde/tennoxlab/cellolution/CellWorld;FFZZ)V+115 
j de.tennoxlab.cellolution.CellWorld.generateFood(IFFFFZ)V+54 
J 89 C2 de.tennoxlab.cellolution.CellWorld.update()V (159 bytes) @ 0x00000000024623b4 [0x0000000002461c60+0x754] 
j de.tennoxlab.cellolution.Cellolution.render()V+40 
j com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop()V+698 
j com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run()V+27 
v ~StubRoutines::call_stub 

전체 로그 : 비슷한 충돌 모든 다른 게시물에서 http://pastebin.com/QjY3msYS

그것은 일어나지 않아야 할 때 아마 세계 수정 일 것입니다. 식품 생성자

// generateFood() - called during World.update 
for (int i = 0; i < count; i++) { 
    float x = minX + (float) Math.random() * (maxX - minX); 
    float y = minY + (float) Math.random() * (maxY - minY); 
    Gdx.app.debug("World", "Generating food piece "+i); 
    this.foods.add(new Food(this, x, y, animateGrowth, this.renderable)); 
} 

: 충돌은 새로운 식품 객체의 생성 중에 발생

// in Food(...) constructor 
BodyDef bodyDef = new BodyDef(); //TODO: set to sleep on init? 
bodyDef.type = BodyDef.BodyType.DynamicBody; 
bodyDef.position.set(x, y); 
bodyDef.linearDamping = 0.5f; 
bodyDef.angularDamping = 1f; 
Gdx.app.debug("Food", "Init body with " + bodyDef + " at " + x + "," + y); 
foodBody = world.box2dWorld.createBody(bodyDef); // <== HERE IS WHERE THE CRASH HAPPENS 
CircleShape shape = new CircleShape(); 
shape.setRadius(getSizeFromEnergy()); 
fixtureDef = new FixtureDef(); 
fixtureDef.shape = shape; 
fixtureDef.density = 0.5f; 
fixtureDef.friction = 0.4f; 
fixtureDef.restitution = 0.2f; 
fixture = foodBody.createFixture(fixtureDef); 
fixture.setUserData(this); 
shape.dispose(); 

그러나 generateFood 코드가 성공적으로 실행되었을 때 그것은 단지 (때로는 게임 플레이의 분, 이따금 발생 수백 번). 그래서 저는 추락이 음식 세대 이전에 일어났던 일과 관련이 있어야한다고 생각했습니다.

World: Generating food piece 99 
Food: Init body with [email protected] at -28.201607,-56.101532 
World: Removing cell: de.tenno[email protected] 
Cell: Destroying [email protected] at -51.92446,-56.464954 
World: Removing cell: [email protected] 
Cell: Destroying [email protected] at -51.92446,-56.464954 
World: Generating 100 new food pieces 
World: Generating food piece 0 
Food: Init body with [email protected] at 14.653984,96.249084 
[...] 
World: Generating food piece 21 
Food: Init body with [email protected] at -15.35305,13.934067 
# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000066bcbd0d, pid=9792, tid=13288 
# 

답변

0
: 여기
public void update() { // Cell.update - called during World.update 
    if (this.energy <= 0) { 
     world.cells.remove(this); 
     Vector2 pos = cellBody.getPosition(); 
     Gdx.app.debug("Cell", "Destroying " + cellBody+" at "+pos.x+","+pos.y); 
     world.box2dWorld.destroyBody(cellBody); // -> Without this line, the crashes don't happen! 
     return; 
    } 
} 

로그입니다 : 내 세포의 Box2D의 몸의 파괴가 객체 후 때 충돌 만, 발생하는 것을 발견 할 때까지 그래서, 사용 및 코드를 비활성화 시작

나는 그것을 직접 풀었다. 아마 다른 모든 문제들에서와 같이 불쾌한 작은 버그 였을 것입니다. 로그 파일에서 볼 수 있듯이

, 같은 셀을 두 번을 삭제 : 나는 목록에 플레이어 셀을 두 번 추가되었습니다

World: Removing cell: [email protected] 
Cell: Destroying [email protected] at -51.92446,-56.464954 
World: Removing cell: [email protected] 
Cell: Destroying [email protected] at -51.92446,-56.464954 

내가 문제를 신속하게 발견 깨달았을 때 따라서 두 번 업데이트하면 두 번 삭제됩니다.이 경우 box2d는 분명히 마음에 들지 않습니다.

이러한 '해결 방법'이 이와 같은 크래시로 인해 사용자가 직접 버그를 일으킬 수 있으므로이 문제를 해결하는 데 도움이되지 않으므로 디버깅을 통해 문제를 파악하는 것이 좋습니다. (나는 여러 곳의 디버그 로그 라인을 추가하고 출력을 조사했다.) 몇 시간 동안 ... 이런 실수가 발생하기 때문이다. 어떤 경우에는 더 자주, 어떤 경우에는 덜 자주하지만, 그렇게됩니다.

내가 추가하고 싶은 다른 것 : box2d 크래시 메시지는 실제로 도움이되지 않습니다. 정말로 ** 충돌이 무엇인지 알아내는 것은 정말로 어렵습니다. 그거 끔찍해. 라이브러리 자체 (또는 libgdx, 아마도)와 같은 디버깅 정보, 더 많은 안전성 검사 및 그런 것들이 있기를 바랍니다. 난 정말 그 이상을 기대하고

(겉으로는) 해결 못하는 버그/게임의 지속적인 developement에 중 충돌 : Z

0

당신은 이미 당신의 문제를 해결하지만 누군가가이 스레드에 stubles 경우 : 내 경우에는 문제는 Box2D 세계가 두 번 폐기되었다는 것입니다.

관련 문제