physics performance drop after update to current daily build..

hej.

I just updated to the current daily build to get the new Particle Designer Feature and I had a HUGH performance Drop. I use physics and I saw, that the line Vector Shapes now look different, when viewed in hybrid mode ( green lines with little dots at the corner ). The level takes now ages to load ( up to 10 seconds ) and it seems that there is a maximum amount of dots you can add per shape. is that right?

I need that to build the walls of my level and am now a little scared, that it means I have to decide to use either Particle Designer or a good performance.

Is there a way to get maybe a legacy mode for the physics line shape drawings? 

would be really great, if somebody could give me a hint.

Thanks,

Philip

Hi Philip,

So this doesn’t relate to Particle Designer? You’re not actually using that, but you just upgraded to gain (potential) access to Particle Designer, but now you’re seeing reduced physics performance?

I’m not sure what would be causing this. How are you using lines with physics? They are not intended to support physics unless the body type is static (this is documented and has been for a long time).

What do you mean by “maximum amount of dots per shape”?

Please clarify some of these points and we’ll try to figure out what’s happening.

Brent

Hej Brent,

thanks for your fast reply.

No I am not using Particle Designer yet.

Yes I use lines with physics, but they are static. I use them as walls for my levels with the SVG Level builder from Karnak Games.

And yes, it seems that there is a maximum amount of lines that can be added to a shape. every line after that will be disgarded, though I am not sure, as this is an issue from the way the svgparser builds the path.

Would you know what changed in the latest builds with the physics engine?

Thanks a lot,

Philip

After further investigation it seems that the SVG Level builder divides each bezier segment into 30 points. This undoubtedly slows down the game. I know thats a lot of verts for a simple segment of a curve, but the funny part is, that it worked like a charm before and now the performance is really bad. So is there a way to get back the old way of dealing with physics lines? Maybe in a legacy mode?

Would be a blast, as I dont want to miss out on the Particle Designer fun :slight_smile:

Thanks,

Philip

Hi Philip,

I don’t know what the SVG product is doing internally. Physics bodies cannot have more than 8 vertices, and that has always been the case, as imposed by Box2D. Supposedly it’s making multiple body parts, which is the proper practice, but I see no reason why it would be slowing down so much compared to previous versions. What versions of Corona are you comparing?

Brent

Hej Brent,

I updated from 2115 to 2259.

body = display.newLine(0, -screenY, 0, 0) if bodyInfo.rotation ~= nil then body.rotation = bodyInfo.rotation end if (element.drawVector or drawVector) and notDrawn == nil then for vertPos = 2, amountVerts, 3 do if vertPos \>= 3 then body:append(bodyInfo.pathVerts[vertPos].x, bodyInfo.pathVerts[vertPos].y) end end end if not (element.drawVector or drawVector) then body.isVisible = false elseif bodyInfo.stroke then body:setColor(bodyInfo.stroke.color.r, bodyInfo.stroke.color.g, bodyInfo.stroke.color.b) body.width = bodyInfo.stroke.width end for vertPos = 2, amountVerts, 2 do shape[shapePos] = bodyInfo.pathVerts[vertPos].x; shapePos = shapePos + 1 shape[shapePos] = bodyInfo.pathVerts[vertPos].y; shapePos = shapePos + 1 shape[shapePos] = bodyInfo.pathVerts[vertPos-1].x; shapePos = shapePos + 1 shape[shapePos] = bodyInfo.pathVerts[vertPos-1].y; shapePos = shapePos + 1 table.insert(properties, { friction = friction, bounce = bounce, shape = shape }) shape = {} shapePos = 1 end if physicsEnabled then properties = { data = { ["edge"] = properties }} physics.addBody(body, "static", unpack(properties.data["edge"])) end

Hi Philip,

Can you post a screenshot showing the “hybrid” view of this?

can I send you the screenshot confidentially?

Hi Philip,

Yes, you can send it to me: my first name [at] coronalabs [dot] com.

Were you able to isolate this to a smaller project that proves it’s something related to physics and lines? Can you build a mini-project and test between the two versions of Corona?

Brent

Hej Brent,

I send you a test scene per mail.

Did you by any chance take a look at it?

Thanks,

Philip

Hi Philip,

When did you send it? I have not received the test project.

Brent

hej Brent,

I resend you the email.

Could you let me know when you got it?

Thanks,

Philip

Hi Philip,

Still didn’t receive it. Can you check the address again? brent [at] coronalabs [dot] com.

Thanks.

Hej Brent,

yes thats where I send it twice.

any other email. I could send it to?

Thanks

Hi Philip,

I found the e-mail and tested your project. Unfortunately, it’s a bit difficult for me to help “debug” this since you’re using a 3rd-party product, and I’m not sure how it functions or takes the material/content you provide for it. Have you contacted the author of that product and asked if there are other developers with similar reports?

I asked the engineers and they report that lines (for physics) haven’t been touched internally for quite some time.

One thing I can comment on is that massive multi-segment line objects are not “cheap” and they may be severely affecting physics performance. The program you’re using is generating a massive amount of segments and, as far as I can tell, it’s trying to apply a single physics body to the entire thing. I caution against this approach, but perhaps the author of the software can clarify how it’s all working.

Best regards,

Brent

Hej Brent,

well running the same code on the two different builds and having these performance and look differences, is a pretty good indicator that something changed internally, I would say.

Hi Philip,

It appears that you changed the code between the two versions, yes? One seems to have many more points/vertices than the other? Is that correct? Perhaps I’m mistaken?

Take care,

Brent

I modified the original code slightly, so it could work on both builds the same way. the only line you have to change is the 1474/1475 which will only move the whole body to the center again. no points added or removed.

this should clearly show the differences between the builds.

Thanks for your time.

So I rewrote the code. Now it creates a new Line for every two vertices instead of making one big Polygon.

It works smooth now. Still I believe that something changed in the physics engine.

But I dont care anymore, as long as my game runs smoothly :slight_smile:

Thanks for the help.

Hi Philip,

So this doesn’t relate to Particle Designer? You’re not actually using that, but you just upgraded to gain (potential) access to Particle Designer, but now you’re seeing reduced physics performance?

I’m not sure what would be causing this. How are you using lines with physics? They are not intended to support physics unless the body type is static (this is documented and has been for a long time).

What do you mean by “maximum amount of dots per shape”?

Please clarify some of these points and we’ll try to figure out what’s happening.

Brent