Open slembcke opened 10 years ago
I have been trying to use CCDrawNode for a geometry based game I am working on. It has actually been really nice (especially during this prototype stage), but I have on problem with drawPolyWithVerts. The problem is that I am using a simple Triangulation algorithm (from http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml) and when I draw with transparency then there is the tiniest bit of overlap between the generated triangles. I am not sure if it is the fault of the triangulation algorithm or if there is some issue with aliasing in the the drawnode. I guess I really need to start digging. If I solve the problem, I could submit a patch to use this for concave polygons.
Related forum thread: http://www.cocos2d-iphone.org/forums/topic/ccdrawnode-anti-aliasing/
@FramusRock also PMed me about it and we discussed it quite a bit more... I did a quick copy paste job of it and edited out personal contact info. It's sort of long but answers some of your questions. http://files.slembcke.net/temp/CCDrawNodeConversation.txt
Missing Functionality:
CCDrawNode was originally created specifically for debug rendering Chipmunk physics. It's functionality is still limited to drawing circles (filled), rounded line segments (filled), and convex polygons (filled/outlined). CCDrawingPrimitives additionally supports convenience methods for rects, curves and more fill/outline options. These should probably be added to CCDrawNode if CCDrawingPrimitives are going to be deprecated.
Performance:
CCDrawNode batches it's rendering so it's fairly efficient to draw hundreds of primitives. Because of how the shader is written, it's not very efficient with fillrate usage though. Trilinear texture filtering can do the same job at the cost of the VRAM to store a large anti-aliased circle texture and it's mipmaps. It's worth looking into I think.
Concave Polygons:
There are several relatively easy triangulation algorithms, such as ear clipping, that work fine for rendering purposes. It would be a nice addition I think if it doesn't take long to implement.