New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 3191 expose isbullet #5905
Conversation
that is, besided interfacing with the box2d engine
Fantastic! Is the feature ready for review? |
@JCash , please tell me if you need any more help with this PR. I noticed there is a test failing. I'll try merging from dev in case something is left out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Missing test + implementation for null implementation.
@@ -1160,6 +1164,15 @@ namespace dmGameSystem | |||
out_value.m_Variant = dmGameObject::PropertyVar(dmPhysics::GetMass2D(component->m_Object2D)); | |||
} | |||
return dmGameObject::PROPERTY_RESULT_OK; | |||
} else if (params.m_PropertyId == PROP_BULLET) { | |||
if (physics_context->m_3D) { | |||
// TODO - display not-implemented warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've done the TODO, so you can remove the comment :)
@JCash , i've added "implementation" in physics_2d_null.cpp locally. I still need to understand how this works.
|
@otsakir As I mentioned in the Discord chat, our users use the Since it's easy to forget, we also added a unit test specifically for this. they are called These tests link against the Try it! |
…efold#3191 Also removed obsolete comment
typename TypeParam::CollisionShapeType shape = (*TestFixture::m_Test.m_NewBoxShapeFunc)(TestFixture::m_Context, Vector3(0.5f, 0.5f, 0.0f)); | ||
typename TypeParam::CollisionObjectType dynamic_co = (*TestFixture::m_Test.m_NewCollisionObjectFunc)(TestFixture::m_World, data, &shape, 1u); | ||
|
||
(*TestFixture::m_Test.m_IsBulletFunc)(dynamic_co); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you don't check the return values of the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the test was mostly about calling the functions and assuring they don't produce a link error. Let me fix...
typename TypeParam::CollisionObjectType dynamic_co = (*TestFixture::m_Test.m_NewCollisionObjectFunc)(TestFixture::m_World, data, &shape, 1u); | ||
|
||
(*TestFixture::m_Test.m_IsBulletFunc)(dynamic_co); | ||
(*TestFixture::m_Test.m_SetBulletFunc)(dynamic_co, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SInce the default is false
, isn't it better to test to set it to true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the test was mostly about calling the functions and assuring they don't produce a link error. Let me fix...
@JCash , ready for review! |
* Added 'bullet' property to go and underlying glue code with box2d - ref defold#3191 * Issue 3191: getter/setter test for collision-object bullet property - ref defold#3191 * Issue 3191: proper support for 'bullet' property in the engine that is, besided interfacing with the box2d engine * Issue 3191: Added 'bullet' property to editor - ref defold#3191 * Issue 3191: Added bullet tests for null physics implementation - ref defold#3191 Also removed obsolete comment * Issue 3191: Small fix for IsBullet() test - ref defold#3191
Introduces 'bullet' property to collisionobject. See #3191.
Implementation
Property added only for 2D physics - Box2D. In 3D physics if you try to get the 'bullet' property the following warning/error is displayed
Testing
The feature is tested by getting and setting the 'bullet' property and asserting it is valid. No test code is written to test actual behavior of a bullet sprite and whether this is accomplished. This is assumed to be part part of box2d testing. Also, you'll notice that i've renamed
Sleeping2DCollisionObjectTest
toCollisionObject2DTest
. The idea is to use this test class as the base for generic high-level collision object testing in gamesys module. Also,properties.script
is supposed to be the test script where elementary testing is done for physics properties.I've also built the editor with bullet property support, created a new project that plays with the property and assured it is shown and initialized properly while getters setters also work. Everything seems to work ok.
Editor
After the core implementation (writing code that makes the calls to box2d and provide the lua api) and test, some further changes were needed to make the property work seamlessly, allow initialization from a .collisionobject file, get displayed in the editor. I used 'Locked Rotation' property as a guide.