そこで、SFMLスプライトに関連付けられたHumanエンティティ、およびBox2Dのボディとフィクスチャを作成しようとしています。ただし、このエラーが発生します。
Assertion failed: area > 1.19209289550781250000e-7F, file ...b2PolygonShape.cpp, line 352
それで、私はいくつかの簡単なグーグルをしました、そして、私の問題が間違った頂点を作る私の形の中にあることに気づきました。しかし、関数を使用している場合、それがどのように可能かわかりませんShape.SetAsBox()
...
これが私のコードです:
#include "../../include/entity/Human.hpp"
Human::Human(unsigned int id, b2World& world, sf::Vector2f pos, sf::Texture* texture)
: AnimatedEntity(id, world, pos, sf::Vector2i(32, 32), texture)
{
b2PolygonShape shape;
shape.SetAsBox((32/2)/SCALE, (32/2)/SCALE); // Set the size; Box2D takes the half-width/height as params, and then scale.
b2FixtureDef fixtureDef;
fixtureDef.density = .8f;
fixtureDef.friction = .4f;
fixtureDef.restitution = .2f;
fixtureDef.shape = &shape;
e_body->CreateFixture(&fixtureDef); // Assuming: shape and density are set
}
FTRSCALE
はstatic const int
、値が30
(30px / 1m)のaです。どうしたの?