Design stuff

Post and discuss features you'd like to see in the BEPUphysics library.
Post Reply
johnnylightbulb
Posts: 3
Joined: Mon Nov 19, 2007 12:06 am

Design stuff

Post by johnnylightbulb »

Very cool - Good job here! I've been trying for 6mos during my off-time and still nothing bounces! All the collisions I've seen in the demo look pretty good and realistic.

The only problem is I got 1 fps on the stress test.. I could bring the blocks down to 5 or 10 and get ~60 fps, but at the preset 20 (and higher, I tried 200 and it nearly locked up) it was quite slow. Obviously you've gotten better perf, I saw the videos and they looked pretty good.

I haven't decompiled the dll to render any sort of opinion, but from the demo code the API looks very clean.

Good luck!
(My laptop is a Core 2 Duo 1.66GHz, 2GB RAM, 100GB HDD, Vista, GeForce 7600 mobile)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Post by Norbo »

I think my wording might have been a little misleading on the stress test- my FPS shows 0 during the major computation parts, and my 1830-block test never went above 0, even at the start.

I think the film was run in either .5 or 1 timescale, then I sped it up to 'real time' with the video render. Interestingly, when it gets that stressed the timescale isn't adhered to entirely precisely (a bit of the 'moon gravity' effect).

I should be able to get the 20-block base test a good chunk faster through optimizations. This first release includes a lot of the base functionality, but it isn't nearly at maximum efficiency. That combined with multithreading should see some large boosts.

Did the 200-block long base even start up? I actually had to wait about 5 minutes for the 60-block base test to finish initializing, and 19900 is quite a lot larger than 1830 :D

Thanks for checking it out!
johnnylightbulb
Posts: 3
Joined: Mon Nov 19, 2007 12:06 am

Post by johnnylightbulb »

I don't recall, I did fuss with it enough to get many, many blocks to start out too far to the right and then fall down because the platform wasn't large enough to hold them :)

I imagine the moon-gravity effect is just some frames rendering fast than others - which would make sense unless you used a fixed-step and output to jpgs or something before compressing those into a movie.

If you're going to start profiling the code, I would highly recommend Ants Profiler to see which paths are getting the most traffic - NProf is a free but less capable package for the same.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Post by Norbo »

Every once in a while I find myself wanting a little more than NProf, and I have checked out Ants a few times; I'll probably end up grabbing it at some point.

Fortunately, I know where the bottlenecks are right now so my optimizations can be targeted without Ants, but I foresee it being very useful once I get into tracking down smaller or less obvious performance hits.
johnnylightbulb
Posts: 3
Joined: Mon Nov 19, 2007 12:06 am

Post by johnnylightbulb »

I was bored and ran ANTS against the release build of the demo code, the only thing I did was uncomment the 'stress test' demo. I killed it after a couple minutes because it didn't show me the screen - I haven't tried profiling an XNA app yet so that may be normal.

(You might need to paste this into Excel to get it looking right, or just email me at MYBEPUGAMESUSERNAME@gmail.com and I'll send you the HTML report)

Namespace Method name Time (sec.) Time with children (sec.) Hit count Source file
BEPUphysicsDemos Program.Main(string[] args) 115.6038 479.8484 1 Program.cs
BEPUphysicsDemos Demos..ctor() 3.3147 3.3147 1 Demos.cs
BEPUphysics Controller..cctor() 0.0012 0.0012 1
BEPUphysicsDemos Demos.Initialize() 0.008 24.3596 1 Demos.cs
BEPUphysics Space..ctor() 0 0 1
BEPUphysics PrimitiveToolbox.constructHexahedronStaticConvexPolyhedron(float width, float height, float length, Vector3 position) 0.0037 0.147 1
BEPUphysics PrimitiveToolbox.constructHexahedronStaticConvexPolyhedron(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector3 p5, Vector3 p6, Vector3 p7, Vector3 p8) 0.002 0.1433 1
BEPUphysics StaticConvexPolyhedron..ctor(List<PolyhedronTriangle> tris) 0.0065 0.1402 1
BEPUphysics StaticConvexPolyhedron.initialize() 0.0315 0.1318 1
BEPUphysics Toolbox..cctor() 0 0 1
BEPUphysicsDemos Demos.LoadGraphicsContent(bool loadAllContent) 0 0 1 Demos.cs
BEPUphysicsDemos Demos.Update(GameTime gameTime) 0.046 336.569 1 Demos.cs
BEPUphysics Space.update(GameTime gameTime) 0.266 336.523 1
BEPUphysics Space.broadPhase() 0.1333 0.1528 1
BEPUphysics PhysSphere..ctor(Vector3 pos, float rad, float m) 0.0009 0.0034 6
BEPUphysics Sphere..ctor() 0 0 6
BEPUphysics PhysSphere.initialize() 0.0001 0.0024 6
BEPUphysics PhysSphere.set_linearMomentum(Vector3 value) 0 0 6
BEPUphysics DisplaySphere..ctor(Sphere aSphere, GraphicsDeviceManager graphics) 0.0182 0.0456 6
BEPUphysics DisplaySphere.initializeEffect() 0.0262 0.0262 6
BEPUphysics DisplaySphere.initializeShape() 0.0012 0.0012 6
BEPUphysics PhysSphere.applyForces(float wait, float timeScale) 0.0026 0.0026 6
BEPUphysics PhysSphere.get_forces() 0 0 6
BEPUphysics PhysSphere.getTotalForce() 0 0 6
BEPUphysics PhysSphere.getTotalTorque() 0 0 6
BEPUphysics PhysSphere.set_linearVelocityBias(Vector3 value) 0 0 6
BEPUphysics PhysSphere.set_angularVelocityBias(Vector3 value) 0 0 6
BEPUphysics PhysSphere.get_mass() 0 0 12
BEPUphysics Sphere.getExtremePoints(Vector3 d, out Vector3 min, out Vector3 max) 0.0007 0.002 18
BEPUphysics Toolbox.getClosestPointsBetweenObjects(Entity objA, Entity objB, Controller controller, out Vector3 closestA, out Vector3 closestB) 0.0063 0.0216 20
BEPUphysics Toolbox.getClosestPointOnSegmentToPoint(List<Vector3> q, int i, int j, Vector3 p, out List<int> subsimplex, out List<float> baryCoords) 0 0 20
BEPUphysics Contact..ctor(Vector3 pos, Vector3 norm, Entity collider, Entity collidee, float depth) 0 0 20
BEPUphysics Toolbox.getClosestPointOnTetrahedronToPoint(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 p, out List<Vector3> subsimplex) 0.0006 0.0007 21
BEPUphysics Toolbox.getClosestPointOnSegmentToPoint(Vector3 a, Vector3 b, Vector3 p, out List<Vector3> subsimplex) 0 0 25
BEPUphysics Controller.updateCollision() 0.0098 336.0983 26
BEPUphysics Toolbox.areObjectsColliding(Entity objA, Entity objB, Controller controller) 0.0036 336.0669 26
BEPUphysics Sphere.getExtremePoint(Vector3 d) 0.0013 0.0013 36
BEPUphysics Toolbox.getBarycenter(List<Vector3> q, List<float> baryCoords) 0 0 40
BEPUphysics Toolbox.getPointProjectedOnPlane(Vector3 point, Vector3 normal, Vector3 pointOnPlane) 0 0 40
BEPUphysics Controller.get_simplexA() 0 0 46
BEPUphysics Toolbox.getClosestPointOnTriangleToPoint(Vector3 a, Vector3 b, Vector3 c, Vector3 p, out List<Vector3> subsimplex) 0.0001 0.0001 49
BEPUphysics Toolbox.getClosestPointOnTetrahedronToPoint(List<Vector3> tetrahedron, Vector3 p, out List<int> subsimplex, out List<float> baryCoords) 0.0002 0.0009 59
BEPUphysics Toolbox.findMinkowskiDifferenceExtremePoint(Entity a, Entity b, Vector3 axis) 0.0003 336.0555 79
BEPUphysics Toolbox.findPointOfMinimumNorm(List<Vector3> q, out List<Vector3> subsimplex) 0.0069 0.0077 99
BEPUphysics Toolbox.findPointOfMinimumNorm(List<Vector3> q, out List<int> subsimplex, out List<float> baryCoords) 0.0131 0.0141 120
BEPUphysics Toolbox.getClosestPointOnTriangleToPoint(List<Vector3> q, int i, int j, int k, Vector3 p, out List<int> subsimplex, out List<float> baryCoords) 0.0006 0.0006 198
BEPUphysics PrimitiveToolbox.constructCubePhysConvexPolyhedron(float width, Vector3 position, float mass) 0.0036 23.3093 210
BEPUphysics PrimitiveToolbox.constructHexahedronPhysConvexPolyhedron(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector3 p5, Vector3 p6, Vector3 p7, Vector3 p8, float mass) 0.0029 23.3057 210
BEPUphysics PhysConvexPolyhedron..ctor(List<PolyhedronTriangle> tris, float m) 0.278 23.2942 210
BEPUphysics PhysConvexPolyhedron.initialize() 4.9419 23.0159 210
BEPUphysics PhysConvexPolyhedron.applyForces(float wait, float timeScale) 0.0032 0.0033 210
BEPUphysics PhysConvexPolyhedron.get_forces() 0 0 210
BEPUphysics PhysConvexPolyhedron.getTotalForce() 0 0 210
BEPUphysics PhysConvexPolyhedron.get_mass() 0 0 210
BEPUphysics PhysConvexPolyhedron.getTotalTorque() 0 0 210
BEPUphysics PhysConvexPolyhedron.set_linearVelocityBias(Vector3 value) 0 0 210
BEPUphysics PhysConvexPolyhedron.set_angularVelocityBias(Vector3 value) 0 0 210
BEPUphysics ConvexPolyhedron..ctor() 0.0014 0.0022 211
BEPUphysics ConvexPolyhedron.findVertices() 0.0085 0.0173 211
BEPUphysics ConvexPolyhedron.findEdges() 0.064 0.1384 211
BEPUphysics ConvexPolyhedron.findNormals() 0.0022 0.0077 211
BEPUphysics ConvexPolyhedron.calibrateNormals() 0.0014 0.0059 211
BEPUphysics ConvexPolyhedron.findConvexPolyhedronGeometry() 0.0075 0.0345 211
BEPUphysics DisplayPolyhedron..ctor(ConvexPolyhedron body, GraphicsDeviceManager graphics) 0.0102 0.8456 211
BEPUphysics DisplayPolyhedron.initializeEffect() 0.8211 0.8211 211
BEPUphysics DisplayPolyhedron.initializeShape() 0.0043 0.0143 211
BEPUphysics Entity..ctor() 0.0008 0.0008 217
BEPUphysics Entity.findBoundingBox() 0.0014 0.0065 217
BEPUphysics Space.addEntity(Entity entity) 0.0006 0.0006 217
BEPUphysics Entity.getPosition() 0 0 252
BEPUphysics Toolbox.arePointsOnOppositeSidesOfPlane(Vector3 o, Vector3 p, Vector3 a, Vector3 b, Vector3 c) 0.0002 0.0002 320
BEPUphysics ConvexPolyhedron.getExtremePoint(Vector3 d) 0.0005 336.0564 397
BEPUphysics Toolbox.findExtremePoint(ConvexPolyhedron body, Vector3 axis) 303.2014 336.0559 397
BEPUphysics Toolbox.findExtremePoint(ConvexPolyhedron body, Vector3 axis, Vertex guess) 25.4689 32.8545 397
BEPUphysics ConvexPolyhedron.getExtremePoints(Vector3 d, out Vector3 min, out Vector3 max) 0.001 0.0031 633
BEPUphysics Toolbox.findInterval(ConvexPolyhedron body, Vector3 axis, out float min, out float max, out Vertex minVertex, out Vertex maxVertex) 0.0018 0.002 633
BEPUphysics Controller..ctor(Entity a, Entity b) 0.0005 0.0005 1108
BEPUphysics PolyhedronTriangle.reverseNormal() 0.0001 0.0012 1266
BEPUphysics Vertex.set_owner(ConvexPolyhedron value) 0.0001 0.0001 1688
BEPUphysics Vertex.move(Vector3 v) 0.0002 0.0002 1688
BEPUphysics PolyhedronTriangle.set_owner(ConvexPolyhedron value) 0.0001 0.0001 2532
BEPUphysics PolyhedronTriangle.calibrateNormal(Vector3 p) 0.0013 0.0026 2532
BEPUphysics Toolbox.clone(PolyhedronTriangle t) 0.0013 0.0202 2532
BEPUphysics PolyhedronTriangle.set_normal(Vector3 value) 0.0001 0.0001 2532
BEPUphysics PolyhedronTriangle.move(Vector3 v) 0.0016 0.0023 2532
BEPUphysics Vertex.findNormal() 0.0037 0.0044 3376
BEPUphysics PolyhedronTriangle.findNormal() 0.0033 0.004 3798
BEPUphysics PolyhedronTriangle..ctor(Vertex a, Vertex b, Vertex c) 0.0028 0.0156 5064
BEPUphysics Edge..ctor(Vertex va, Vertex vb) 0.0004 0.0004 7596
BEPUphysics Edge.set_triangleA(PolyhedronTriangle value) 0.0003 0.0003 7596
BEPUphysics Edge.set_triangleB(PolyhedronTriangle value) 0.0003 0.0003 7596
BEPUphysics Vertex.addEdge(Edge edge) 0.006 0.0095 7596
BEPUphysics Vertex.set_position(Vector3 value) 0.0003 0.0003 7596
BEPUphysics Toolbox.clone(Vertex v) 0.0034 0.0164 9284
BEPUphysics Vertex.set_normal(Vector3 value) 0.0004 0.0004 9284
BEPUphysics Vertex..ctor(Vector3 pos) 0.0018 0.0018 10972
BEPUphysics Vertex.addTriangle(PolyhedronTriangle triangle) 0.0127 0.0127 15192
BEPUphysics Vertex.get_normal() 0.0161 0.0195 16880
BEPUphysics Vertex.Equals(object obj) 0.0069 0.0083 32072
BEPUphysics Edge.set_owner(ConvexPolyhedron value) 0.002 0.002 45576
BEPUphysics Edge.get_endpointB() 0.0021 0.0021 60571
BEPUphysics Edge.get_triangleB() 0.0023 0.0023 64355
BEPUphysics Edge.get_triangleA() 0.0059 0.0059 168378
BEPUphysics Edge.Equals(object obj) 0.0325 0.049 211422
BEPUphysics PolyhedronTriangle.get_edges() 0.0073 0.0073 211844
BEPUphysics Controller.Equals(object o) 0.019 0.019 306916
BEPUphysics Toolbox.isPointWithinConvexPolyhedron(Vector3 p, ConvexPolyhedron body) 12.633 17.5318 3296875
BEPUphysics Entity.set_position(Vector3 value) 0.1447 0.1447 3297303
BEPUphysics Entity.get_position() 0.2905 0.2905 6590405
BEPUphysics Vertex.get_edges() 0.4875 0.4875 13735965
BEPUphysics PolyhedronTriangle.get_vertices() 1.4153 1.4153 39611452
BEPUphysics PolyhedronTriangle.get_normal() 1.7231 1.7231 39658716
BEPUphysics Vertex.get_position() 3.6184 3.6184 80854983
BEPUphysics Edge.get_endpointA() 5.0643 5.0643 137774320
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Post by Norbo »

Thanks, I'll look through it.
Post Reply