fix a bug

This commit is contained in:
blueloveTH 2023-08-12 22:50:36 +08:00
parent 620e82f0ab
commit 31e24ca9bd
2 changed files with 4 additions and 2 deletions

View File

@ -73,8 +73,10 @@ struct PyBody{
PyBody(): body(nullptr), fixture(nullptr), node_like(nullptr){} PyBody(): body(nullptr), fixture(nullptr), node_like(nullptr){}
void _gc_mark() { void _gc_mark() {
if(node_like != nullptr){
PK_OBJ_MARK(node_like); PK_OBJ_MARK(node_like);
} }
}
PyBody& _() { return *this; } PyBody& _() { return *this; }
b2Body& _b2Body() { return *body; } b2Body& _b2Body() { return *body; }

View File

@ -128,7 +128,7 @@ void PyBody::_register(VM* vm, PyObject* mod, PyObject* type){
// destroy // destroy
vm->bind(type, "destroy(self)", [](VM* vm, ArgsView args){ vm->bind(type, "destroy(self)", [](VM* vm, ArgsView args){
PyBody& body = CAST(PyBody&, args[1]); PyBody& body = CAST(PyBody&, args[0]);
body.body->GetWorld()->DestroyBody(body.body); body.body->GetWorld()->DestroyBody(body.body);
body.body = nullptr; body.body = nullptr;
body.fixture = nullptr; body.fixture = nullptr;