3dprimitives optimizations + fix warnings