Bug with addBody ?

Should i report bug for function addBody when it does not throw error and only writes it on output screen only?

Even pcall could not catch it.

My guess is that it was made to detect error but forgot to propagate that error to function result.

It happens when you have outline that has intersecting points or joins.

Hello, Before you report it can you please make a sample of that problem and share it with us? Maybe we can help!

–SonicX278

Ok, here it is i hope someone wont delete like last time :slight_smile:

so i generated outline with newOutline and i got table which i analysed and determined it has joins.

This is last example i found:

x  y

11 1

30 4

29 8

26 8

27 15

23 18

29 20

30 30

26 32

25 23

22 23

18 33

26 32

26 41

24 38

15 39

15 45

8 45

6 43

9 43

10 33

6 31

4 23

7 22

6 17

13 18

9 15

9 10

6 10

10 1


as you can see (26,32) appears on 2 places.

when i use this outline to create body it recognizes this correctly and wont create it.

Code 1:

[lua]print( physics.addBody( testObj, “dynamic”, { outline=testOutline } ) )[/lua]

output:

ERROR: C:\tmp\main.lua:257: physics.addBody() : invalid “outline”

true

Code 2:

[lua]print( pcall( physics.addBody, testObj, “dynamic”, { outline=testOutline } ) )[/lua]

output:

ERROR: physics.addBody() : invalid “outline”

true    true

It is just error in propagating this ERROR to end of function addBody.

The two most common options for a body are:

  1. Outlines are created from images:

https://docs.coronalabs.com/daily/api/library/graphics/newOutline.html

Please show your call to this function in future post.

Also, if you can post your shape image so folks can download and try it.

Note: These cannot be too complex or have intersections (or near intersections).  This feature is meant for generating relatively simple bodies from fairly simple shapes and is not guaranteed to give an exact body (i.e. may not perfectly match shape).

  1. Body shapes are tables with UP TO 8 vertices:

https://docs.coronalabs.com/daily/guide/physics/physicsBodies/index.html#polygonal-bodies

@roaminggamer is correct on this point.  however i’ll agree with OP that if newOutline() fails to “trace” the image into a valid non-degenerate outline then there ought to be some more “graceful” method of failing rather than awaiting addBody() to generate an _ internal _ error that can’t be trapped with pcall().  (that is, the error must be occurring “inside” corona, and not propagated “outside” to the exposed lua interface of those internals, otherwise pcall could trap it if it were lua).

the imagined conversation you DON’T want to have:

dev: hey corona make me an outline of this image

corona:  here ya go, no errors reported

dev:  and so i assume it’s now safe to use the outline that YOU created with the rest of YOUR sdk??

corona:  well maybe, though it might not be valid

dev:  so how can i determine if it’s valid?

corona:  try it with addBody() - if it generates a hard non-trappable internal run-time crash, then it was invalid.

dev:  isn’t that a bit too late?

cuz generating any type of non-trappable internal error ought to be a no-no.  use-cases would include a user-specified arbitrary image or a run-time gesture-generated image or etc, where the outline trace can’t realistically be “validated” in advance.

suggest OP post a simple-as-possible test case (along with an image that reliably reproduces a failed outline trace).

Please create a sample project (main.lua, build.settings, config.lua and any asset needed to run) and put it in a .zip file. Use the “Report a Bug” link at the top of the page. After you submit that form, you will get an email with a CaseID # in the subject. Please post that number back to this thread as a reference.

Rob

I think I am experiencing this same error if it supports your argument. I am getting a “non-trappable internal error” like you.

Has any one filed a bug report on this yet?

Rob

Hello, Before you report it can you please make a sample of that problem and share it with us? Maybe we can help!

–SonicX278

Ok, here it is i hope someone wont delete like last time :slight_smile:

so i generated outline with newOutline and i got table which i analysed and determined it has joins.

This is last example i found:

x  y

11 1

30 4

29 8

26 8

27 15

23 18

29 20

30 30

26 32

25 23

22 23

18 33

26 32

26 41

24 38

15 39

15 45

8 45

6 43

9 43

10 33

6 31

4 23

7 22

6 17

13 18

9 15

9 10

6 10

10 1


as you can see (26,32) appears on 2 places.

when i use this outline to create body it recognizes this correctly and wont create it.

Code 1:

[lua]print( physics.addBody( testObj, “dynamic”, { outline=testOutline } ) )[/lua]

output:

ERROR: C:\tmp\main.lua:257: physics.addBody() : invalid “outline”

true

Code 2:

[lua]print( pcall( physics.addBody, testObj, “dynamic”, { outline=testOutline } ) )[/lua]

output:

ERROR: physics.addBody() : invalid “outline”

true    true

It is just error in propagating this ERROR to end of function addBody.

The two most common options for a body are:

  1. Outlines are created from images:

https://docs.coronalabs.com/daily/api/library/graphics/newOutline.html

Please show your call to this function in future post.

Also, if you can post your shape image so folks can download and try it.

Note: These cannot be too complex or have intersections (or near intersections).  This feature is meant for generating relatively simple bodies from fairly simple shapes and is not guaranteed to give an exact body (i.e. may not perfectly match shape).

  1. Body shapes are tables with UP TO 8 vertices:

https://docs.coronalabs.com/daily/guide/physics/physicsBodies/index.html#polygonal-bodies

@roaminggamer is correct on this point.  however i’ll agree with OP that if newOutline() fails to “trace” the image into a valid non-degenerate outline then there ought to be some more “graceful” method of failing rather than awaiting addBody() to generate an _ internal _ error that can’t be trapped with pcall().  (that is, the error must be occurring “inside” corona, and not propagated “outside” to the exposed lua interface of those internals, otherwise pcall could trap it if it were lua).

the imagined conversation you DON’T want to have:

dev: hey corona make me an outline of this image

corona:  here ya go, no errors reported

dev:  and so i assume it’s now safe to use the outline that YOU created with the rest of YOUR sdk??

corona:  well maybe, though it might not be valid

dev:  so how can i determine if it’s valid?

corona:  try it with addBody() - if it generates a hard non-trappable internal run-time crash, then it was invalid.

dev:  isn’t that a bit too late?

cuz generating any type of non-trappable internal error ought to be a no-no.  use-cases would include a user-specified arbitrary image or a run-time gesture-generated image or etc, where the outline trace can’t realistically be “validated” in advance.

suggest OP post a simple-as-possible test case (along with an image that reliably reproduces a failed outline trace).

Please create a sample project (main.lua, build.settings, config.lua and any asset needed to run) and put it in a .zip file. Use the “Report a Bug” link at the top of the page. After you submit that form, you will get an email with a CaseID # in the subject. Please post that number back to this thread as a reference.

Rob

I think I am experiencing this same error if it supports your argument. I am getting a “non-trappable internal error” like you.

Has any one filed a bug report on this yet?

Rob