LibGDX BOX2D change maxPolygonVertices - libgdx

I need to make a body with more than 8 vertices, and i get the error.
AL lib: (EE) alc_cleanup: 1 device not closed
Assertion failed!
Program: C:\Program Files\Java\jre7\bin\javaw.exe
File: /var/lib/jenkins/workspace/libgdx/gdx/jni/Box2D/Collision/Shapes/b2PolygonShape.cpp, Line 122
Expression: 3 <= count && count <= 8
How can I change that constant?
I found this file https://github.com/libgdx/libgdx/blob/master/gdx/jni/Box2D/Common/b2Settings.h
Here i saw
#define b2_maxPolygonVertices 8
How can I change it from libGDX?

Actually you should not change that, since it would decrease the performance.
What you would do instead is create a Body with several Fixtures. Those fixtures will have max 8 vertices and will share some of the vertices, so you will simulate a bigger piece using smaller parts, which are stuck together.
This is called polygon decomposition. Some editors for Box2D do that automatically for you, when you export your scene. Probable the best editor for Box2D out there is R.U.B.E.. There is also a libgdx loader for rube scenes here.
If you create them programmatically you would probably have to do this yourself. Maybe some LibGDX tools like the EarClippingTriangulator could help you here.

Related

Java heap space,AIR 18

I am working on an IOS application, using Flashdevelop and AIR SDK version 18. I got the Java heap space error while compiling the project.
Here is what I have tried:
Modify the jvm.config - I have not tried this, because there is not such file in AIR SDK.
Modify the adt.bat file -Xms1024 -Xmx1024 - I tried it but not working
Modify the mxmlc.bat, but like adt.bat - not working
Any solution? I'll be grateful for any ideas! Please keep in mind I cannot divide the resources and the code - I must pack them together.
Ran across this problem today and wanted to let people know that this can be caused by programmer error...
I had just set up a simple parallax background for my game. It worked fine when the player moved a short distance but I needed to test a long distance. In my game the player moves right automatically until he encounters an enemy so to get him to walk a long distance I simply had to move the enemy further away. I set enemy x to 999999, compiled... and got the Java Heap Space error. I have no idea why that would cause me to run out of memory (I don't really understand how display objects work) but restoring the enemy's position and restarting FlashDevelop fixed the problem.

Cocos2d-x 2.0 - How do I Take Advantage of Sprite Auto-Batching Work?

I have seen references to a new 'auto batching' feature in Cocos2d-x 3.0, and even saw somewhere that they no longer recommending using SpriteBatchNodes. So how do I batch draw calls without using BatchNodes?
I can't find anything in the documentation but the vaguest references to this feature.
- https://docs.google.com/document/d/17zjC55vbP_PYTftTZEuvqXuMb9PbYNxRFu0EGTULPK8/edit#heading=h.3ssqg87hovgw
I tried simply getting rid of my SpriteBatchNode and creating my Sprites using files but the number of draw calls went up by about 1 per sprite :)
I think I have solved this, and it's pretty simple. I just changed all of my SpriteBatchNodes to Nodes and preloaded my atlases with
SpriteFrameCache* spriteFrameCache = SpriteFrameCache::sharedSpriteFrameCache();
spriteFrameCache->addSpriteFramesWithFile("spritesheets/xxx.plist");
The number of draw calls didn't change compared to what it was with SpriteBatchNode.
This new architecture is way more flexible than SpriteBatchNode. For example, the calls are properly batched if you do
Node -> Node -> Sprite
where you could never do
SpriteBatchNode -> Node -> Sprite
because SpriteBatchNode could have only Sprites as children.

CGAL::Polyhedron_3 demo - failing intersection

I started using CGAL demos to find the intersection of two polyhedra. I met a problem when the two polyhedra share some vertices and edges. The program extis with "Segmentation fault" call. I assume the problem refers to the shared vertices, since for other case I see no problem. My polyhedra are e.g. rhombic triacontahedra or truncated tiracontahedra (the latter are concave). Is it a problem of demo program or the CGAL algorithm itself?
Input OFF files I use:
https://www.dropbox.com/s/nywdv80yzr0wpxp/henley_3D.off
https://www.dropbox.com/s/slxzfwhchpuix2p/henley_shift_3D.off
I'm using CGAL with Ubuntu 10.04 under VirtualMachine with Win7 x64 as host.
I will be grateful for any help from you.
Best,
Radek
First problem, your polyhedra are inconsistently oriented (which explain the checkerboard coloration when you open them in the demo.
Second problem you have non triangular facets which would not
be a problem for Nef if the vertices of the facets were coplanar
(which is not the case).
To fix this you can use the "Orient polygon soup" plugin and "Inside outside" plugin to fix the orientation.
The plugin "Triangulated facets" will help before creating nef polyhedra.

Invalid BitmapData

So, I'm porting a game, build for web flash in AIR Mobile (using FlashDevelop). Now, I have one class that runs first, which make vector graphic in bitmaps and re-size them as needed. Than, all this bitmaps (actually, BitmapData) are stored in Vectors. This class is a object of a Singelton class, which allows me easy access to the stored BimapData.
Also, I'm using FlashPunk as the game engine.
Now, I already created around 16 BitmapData and stored them in that class and everything is fine. But, the next BitmapData I add, in new Vector object, is not working as it should. Everything is fine while in RenderScreen, but as soon the game starts, e.g. click start game, it should return the BitmapData to create the menu, but it reports "ArgumentError: Error #2015: Invalid BitmapData"
What might be the problem? The BitmapData in question is created from vector graphic using draw(), scaled as needed, with initial width 1024px and height 120px. Also, the game run with around 40Mb memory, so the size is not the problem ...
Any idea why this error shows?
EDIT: I founded the problem and resolve it. How to close this question?
I'd bet my hat that it's a memory problem... error 2015 is either because one of the dimensions are invalid (width or height < 1 ), or because there is not enough memory to create the BitmapData.
The System class has a few properties that might help you debug the state of the memory before you try to create the conflicted BitmapData ;)
And if you find that it is actually a memory problem, besides wearing a new hat, you will have to rethink the way you cache those sprites... try to cache only the necessary pieces for each stage of the application, dispose them before you need to create more, etc. Good luck!

What is the indexBuffer, and what might cause me to run out of them?

I am making a flash game using Flare3D and when i load a new scene it give me this error:
Error: Error #3691: Resource limit for this resource type exceeded.
at flash.display3D::Context3D/createIndexBuffer()
at flare.core::Surface3D/upload()[Z:\projects\flare3d 2\src\flare\core\Surface3D.as:237]
at flare.core::Mesh3D/upload()[Z:\projects\flare3d 2\src\flare\core\Mesh3D.as:130]
at flare.core::Mesh3D/draw()[Z:\projects\flare3d 2\src\flare\core\Mesh3D.as:335]
at flare.basic::Scene3D/render()[Z:\projects\flare3d 2\src\flare\basic\Scene3D.as:593]
at flare.basic::Scene3D/enterFrameEvent()[Z:\projects\flare3d 2\src\flare\basic\Scene3D.as:461]
I am guessing from the error that it is running of something, but I don't know what the Context3D.createIndexBuffer() does. Since flare3D is not open source I can't dig in for any clues there.
So i want to know: what is teh Context3D IndexBuffer, and what might make me run out of that resource type?
And please don't just link to the ASDocs for those classes, I have looked and they do not answer this question.
I could be wrong, but I'm guessing they are talking about the same Index Buffers that are used in OpenGL and DirectX. They are arrays of integers that are indices into a vertex array so that when drawing multiple polygons that share vertices, you don't have to specify the entire vertex every time.
This is a relatively good explanation:
http://openglbook.com/the-book/chapter-3-index-buffer-objects-and-primitive-types/#toc-enter-index-buffers
I don't know anything about Flare3D, but is it possible that your scene has too many complex meshes and is running out of memory for index buffers?