Skip to content
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

Physics crashes when adding collision shape: box. and set scale 0 #8957

Open
JetGames777 opened this issue May 19, 2024 · 4 comments
Open

Physics crashes when adding collision shape: box. and set scale 0 #8957

JetGames777 opened this issue May 19, 2024 · 4 comments
Labels
bug Something is not working as expected engine Issues related to the Defold engine physics Issues related to physics (2D and/or 3D)

Comments

@JetGames777
Copy link

JetGames777 commented May 19, 2024

Describe the bug (REQUIRED)
When adding collisionobject with shape box to game object and create this object through factory we will get a bug.

To Reproduce (REQUIRED)

  1. Create GO in Assets
  2. add #collisionobject with collision shape: box
  3. Create a GO through the factory
  4. See error

Expected behavior (REQUIRED)
No crash

Defold version (REQUIRED):

  • Version 1.8.0

Platforms (REQUIRED):

  • Platforms: Windows
  • OS: Windows 11

Logs (OPTIONAL):

Assertion failed: area > 1.192092896e-07F, file ..\src\box2d\Box2D\Collision\Shapes\b2PolygonShape.cpp, line 123
INFO:CRASH: Successfully wrote Crashdump to file: C:\Users\cdart\AppData\Roaming\Defold/_crash
ERROR:CRASH: CALL STACK:

ERROR:CRASH:  0 0x7FF79792AFD0 dmCrash::GenerateCallstack D:\a\defold\defold\engine\crash\src\backtrace_win32.cpp:144
ERROR:CRASH:  1 0x7FF797CE7B54 raise /tmp/job2174380374303029695/minkernel/crts/ucrt/src/appcrt/misc/signal.cpp:547
ERROR:CRASH:  2 0x7FF797CD8250 abort /tmp/job2174380374303029695/minkernel/crts/ucrt/src/appcrt/startup/abort.cpp:71
ERROR:CRASH:  3 0x7FF797CD7534 common_assert_to_stderr<wchar_t> /tmp/job2174380374303029695/minkernel/crts/ucrt/src/appcrt/startup/assert.cpp:186
ERROR:CRASH:  4 0x7FF797CD704C _wassert /tmp/job2174380374303029695/minkernel/crts/ucrt/src/appcrt/startup/assert.cpp:443
ERROR:CRASH:  5 0x7FF797B714C0 ComputeCentroid D:\a\defold\defold\engine\physics\src\box2d\Box2D\Collision\Shapes\b2PolygonShape.cpp:124
ERROR:CRASH:  6 0x7FF797B6FEE0 b2PolygonShape::Set D:\a\defold\defold\engine\physics\src\box2d\Box2D\Collision\Shapes\b2PolygonShape.cpp:180
ERROR:CRASH:  7 0x7FF797AD1F40 dmPhysics::TransformCopyShape D:\a\defold\defold\engine\physics\src\physics\physics_2d.cpp:834
ERROR:CRASH:  8 0x7FF797ACD8E0 dmPhysics::NewCollisionObject2D D:\a\defold\defold\engine\physics\src\physics\physics_2d.cpp:988
ERROR:CRASH:  9 0x7FF797A043D0 dmGameSystem::CreateCollisionObject D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_collision_object.cpp:420
ERROR:CRASH: 10 0x7FF797A01B00 dmGameSystem::CompCollisionObjectCreate D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_collision_object.cpp:470
ERROR:CRASH: 11 0x7FF797985240 dmGameObject::CreateComponents D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:829
ERROR:CRASH: 12 0x7FF7978F6E70 dmGameObject::AcquireResources D:\a\defold\defold\engine\gameobject\src\gameobject\res_collection.cpp:143
ERROR:CRASH: 13 0x7FF7978F7810 dmGameObject::ResCollectionCreate D:\a\defold\defold\engine\gameobject\src\gameobject\res_collection.cpp:262
ERROR:CRASH: 14 0x7FF79796E4A0 dmResource::DoCreateResource D:\a\defold\defold\engine\resource\src\resource.cpp:628
ERROR:CRASH: 15 0x7FF79796E9E0 dmResource::CreateAndLoadResource D:\a\defold\defold\engine\resource\src\resource.cpp:755
ERROR:CRASH: 16 0x7FF797969430 dmResource::Get D:\a\defold\defold\engine\resource\src\resource.cpp:830
ERROR:CRASH: 17 0x7FF797A8E5F0 dmGameSystem::DoLoad D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_collection_proxy.cpp:92
ERROR:CRASH: 18 0x7FF797A8DF20 dmGameSystem::CompCollectionProxyOnMessage D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_collection_proxy.cpp:427
ERROR:CRASH: 19 0x7FF79798BD70 dmGameObject::DispatchMessagesFunction D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2323
ERROR:CRASH: 20 0x7FF7979F69B0 dmMessage::InternalDispatch D:\a\defold\defold\engine\dlib\src\dlib\message.cpp:573
ERROR:CRASH: 21 0x7FF797987ED0 dmGameObject::InitCollection D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:1780
ERROR:CRASH: 22 0x7FF797A0A080 dmEngine::Init D:\a\defold\defold\engine\engine\src\engine.cpp:1347
ERROR:CRASH: 23 0x7FF797A08FC0 dmEngineCreate D:\a\defold\defold\engine\engine\src\engine.cpp:2159
ERROR:CRASH: 24 0x7FF797A0ECD0 dmEngine::RunLoop D:\a\defold\defold\engine\engine\src\engine_loop.cpp:68
ERROR:CRASH: 25 0x7FF7979188A0 engine_main D:\a\defold\defold\engine\engine\src\engine_main.cpp:152
ERROR:CRASH: 26 0x7FF797C91034 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
ERROR:CRASH: 27 0x7FF9C7222560 BaseThreadInitThunk <unknown>:0
ERROR:CRASH: 28 0x7FF9C89AAA20 RtlUserThreadStart <unknown>:0
ERROR:CRASH: 
@JetGames777 JetGames777 added the bug Something is not working as expected label May 19, 2024
@AGulev
Copy link
Contributor

AGulev commented May 19, 2024

add minimal repro project

@JetGames777
Copy link
Author

add minimal repro project

Ohhh, I was testing and realized the error was different. It's easy enough to set scale 0 for an object with physics

@JetGames777 JetGames777 changed the title Physics crashes when adding collision shape: box Physics crashes when adding collision shape: box. and set scale 0 May 19, 2024
@britzl britzl added engine Issues related to the Defold engine physics Issues related to physics (2D and/or 3D) labels May 20, 2024
@britzl
Copy link
Contributor

britzl commented May 20, 2024

Screen.Recording.2024-05-20.at.09.56.25.mov

@JCash
Copy link
Contributor

JCash commented May 20, 2024

Looking at the code, it's the final area calculation that becomes too small:
https://github.com/defold/defold/blob/dev/engine/physics/src/box2d/Box2D/Collision/Shapes/b2PolygonShape.cpp#L123

As we don't want to sprinkle fixes inside the physics engines, we should try to validate the data being processed in the engine.
E.g. for 2D shapes, we should set a minimum area size.

@AGulev AGulev reopened this May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working as expected engine Issues related to the Defold engine physics Issues related to physics (2D and/or 3D)
Projects
None yet
Development

No branches or pull requests

4 participants