diff --git a/cocos/physics/CCPhysicsContact.h b/cocos/physics/CCPhysicsContact.h index 34d918bea3..74092ba3b0 100644 --- a/cocos/physics/CCPhysicsContact.h +++ b/cocos/physics/CCPhysicsContact.h @@ -76,7 +76,7 @@ public: /** get contact shape B. */ inline PhysicsShape* getShapeB() const { return _shapeB; } /** get contact data */ - inline const PhysicsContactData& getContactData() const { return *_contactData; } + inline const PhysicsContactData* getContactData() const { return _contactData; } /** get data. */ inline void* getData() const { return _data; } /** diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index 4bc0e5aae1..047b253fcb 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -1631,23 +1631,23 @@ void physics_raycastinfo_to_luaval(lua_State* L, const PhysicsRayCastInfo& info) lua_rawset(L, -3); /* table[key] = value, L: table */ } -void physics_contactdata_to_luaval(lua_State* L, const PhysicsContactData& data) +void physics_contactdata_to_luaval(lua_State* L, const PhysicsContactData* data) { - if (NULL == L) + if (nullptr == L || nullptr == data) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "points"); - points_to_luaval(L, data.points, data.count); + points_to_luaval(L, data->points, data->count); lua_rawset(L, -3); lua_pushstring(L, "normal"); - point_to_luaval(L, data.normal); + point_to_luaval(L, data->normal); lua_rawset(L, -3); lua_pushstring(L, "POINT_MAX"); - lua_pushnumber(L, data.POINT_MAX); + lua_pushnumber(L, data->POINT_MAX); lua_rawset(L, -3); } diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.h b/cocos/scripting/lua/bindings/LuaBasicConversions.h index 7cf07bea24..3f62c98719 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.h +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.h @@ -204,7 +204,7 @@ extern void color4b_to_luaval(lua_State* L,const Color4B& cc); extern void color4f_to_luaval(lua_State* L,const Color4F& cc); extern void physics_material_to_luaval(lua_State* L,const PhysicsMaterial& pm); extern void physics_raycastinfo_to_luaval(lua_State* L, const PhysicsRayCastInfo& info); -extern void physics_contactdata_to_luaval(lua_State* L, const PhysicsContactData& data); +extern void physics_contactdata_to_luaval(lua_State* L, const PhysicsContactData* data); extern void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValue); extern void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue); extern void array_to_luaval(lua_State* L,Array* inValue); diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 9bf5b49a91..aedc0f3e09 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -1107,7 +1107,7 @@ void PhysicsDemoOneWayPlatform::onEnter() bool PhysicsDemoOneWayPlatform::onContactBegin(EventCustom* event, const PhysicsContact& contact) { - return contact.getContactData().normal.y < 0; + return contact.getContactData()->normal.y < 0; } std::string PhysicsDemoOneWayPlatform::title() const